mirror of
https://github.com/cf-sonr/motr.git
synced 2026-01-12 02:59:13 +00:00
refactor: fs
This commit is contained in:
182
.goreleaser.yaml
Normal file
182
.goreleaser.yaml
Normal file
@@ -0,0 +1,182 @@
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
|
||||
version: 2
|
||||
project_name: sonr
|
||||
|
||||
builds:
|
||||
- id: motr
|
||||
main: ./cmd/motr
|
||||
binary: app
|
||||
goos:
|
||||
- js
|
||||
goarch:
|
||||
- wasm
|
||||
|
||||
- id: sonr
|
||||
main: ./cmd/sonrd
|
||||
binary: sonrd
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
goamd64:
|
||||
- v1
|
||||
flags:
|
||||
- -mod=readonly
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
||||
- -X github.com/cosmos/cosmos-sdk/version.AppName=sonrd
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
|
||||
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
|
||||
tags:
|
||||
- netgo
|
||||
- ledger
|
||||
|
||||
- id: hway
|
||||
main: ./cmd/hway
|
||||
binary: hway
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
flags:
|
||||
- -mod=readonly
|
||||
- -trimpath
|
||||
goamd64:
|
||||
- v1
|
||||
tags:
|
||||
- netgo
|
||||
ldflags:
|
||||
- -X main.version={{.Version}}
|
||||
- -X main.commit={{.Commit}}
|
||||
- -X main.date={{.Date}}
|
||||
archives:
|
||||
- id: sonr
|
||||
builds: [sonr]
|
||||
name_template: >-
|
||||
sonr_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64
|
||||
{{- else if eq .Arch "386" }}i386
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
format: tar.gz
|
||||
files:
|
||||
- src: README*
|
||||
wrap_in_directory: true
|
||||
|
||||
- id: hway
|
||||
builds: [hway]
|
||||
name_template: >-
|
||||
hway_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64
|
||||
{{- else if eq .Arch "386" }}i386
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
format: tar.gz
|
||||
files:
|
||||
- src: README*
|
||||
wrap_in_directory: true
|
||||
|
||||
nfpms:
|
||||
- id: hway
|
||||
package_name: hway
|
||||
file_name_template: "hway_{{ .Os }}_{{ .Arch }}{{ .ConventionalExtension }}"
|
||||
builds: [hway]
|
||||
vendor: Sonr
|
||||
homepage: "https://onsonr.dev"
|
||||
maintainer: "Sonr <support@onsonr.dev>"
|
||||
description: "Sonr Highway is a decentralized, permissionless, and censorship-resistant identity network proxy."
|
||||
license: "Apache 2.0"
|
||||
formats:
|
||||
- rpm
|
||||
- deb
|
||||
- apk
|
||||
dependencies:
|
||||
- ipfs
|
||||
contents:
|
||||
- src: README*
|
||||
dst: /usr/share/doc/hway
|
||||
bindir: /usr/bin
|
||||
section: net
|
||||
priority: optional
|
||||
# Add these lines to match build config
|
||||
|
||||
- id: sonr
|
||||
package_name: sonrd
|
||||
file_name_template: "sonrd_{{ .Os }}_{{ .Arch }}{{ .ConventionalExtension }}"
|
||||
builds: [sonr]
|
||||
vendor: Sonr
|
||||
homepage: "https://onsonr.dev"
|
||||
maintainer: "Sonr <support@onsonr.dev>"
|
||||
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||
license: "Apache 2.0"
|
||||
formats:
|
||||
- rpm
|
||||
- deb
|
||||
- apk
|
||||
dependencies:
|
||||
- ipfs
|
||||
contents:
|
||||
- src: README*
|
||||
dst: /usr/share/doc/sonrd
|
||||
bindir: /usr/bin
|
||||
section: net
|
||||
priority: optional
|
||||
# Add these lines to match build config
|
||||
|
||||
brews:
|
||||
- name: hway
|
||||
ids: [hway]
|
||||
commit_author:
|
||||
name: goreleaserbot
|
||||
email: bot@goreleaser.com
|
||||
directory: Formula
|
||||
caveats: "Run a local hway node and access it with the hway proxy"
|
||||
homepage: "https://onsonr.dev"
|
||||
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||
dependencies:
|
||||
- name: ipfs
|
||||
repository:
|
||||
owner: onsonr
|
||||
name: homebrew-tap
|
||||
branch: master
|
||||
token: "{{ .Env.GITHUB_PERSONAL_AUTH_TOKEN }}"
|
||||
|
||||
- name: sonr
|
||||
ids: [sonr]
|
||||
commit_author:
|
||||
name: goreleaserbot
|
||||
email: bot@goreleaser.com
|
||||
directory: Formula
|
||||
caveats: "Run a local sonr node and access it with the hway proxy"
|
||||
homepage: "https://onsonr.dev"
|
||||
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||
dependencies:
|
||||
- name: ipfs
|
||||
repository:
|
||||
owner: onsonr
|
||||
name: homebrew-tap
|
||||
branch: master
|
||||
token: "{{ .Env.GITHUB_PERSONAL_AUTH_TOKEN }}"
|
||||
|
||||
release:
|
||||
github:
|
||||
owner: onsonr
|
||||
name: sonr
|
||||
name_template: 'Release {{ .Env.RELEASE_DATE }}'
|
||||
draft: false
|
||||
replace_existing_draft: true
|
||||
replace_existing_artifacts: true
|
||||
extra_files:
|
||||
- glob: ./README*
|
||||
- glob: ./scripts/install.sh
|
||||
- glob: ./scripts/test_node.sh
|
||||
- glob: ./scripts/test_ics_node.sh
|
||||
|
||||
announce:
|
||||
telegram:
|
||||
enabled: true
|
||||
chat_id: -1002222617755
|
||||
0
CONVENTIONS.md
Normal file
0
CONVENTIONS.md
Normal file
41
app/vault.go
Normal file
41
app/vault.go
Normal file
@@ -0,0 +1,41 @@
|
||||
//go:build js && wasm
|
||||
|
||||
package vault
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
echomiddleware "github.com/labstack/echo/v4/middleware"
|
||||
"github.com/onsonr/sonr/internal/config/motr"
|
||||
"github.com/onsonr/sonr/internal/database/motrorm"
|
||||
"github.com/onsonr/sonr/vault/context"
|
||||
)
|
||||
|
||||
type Vault = *echo.Echo
|
||||
|
||||
// New returns a new Vault instance
|
||||
func New(config *motr.Config, dbq *motrorm.Queries) (Vault, error) {
|
||||
e := echo.New()
|
||||
// Override default behaviors
|
||||
e.IPExtractor = echo.ExtractIPDirect()
|
||||
e.HTTPErrorHandler = handleError()
|
||||
|
||||
// Built-in middleware
|
||||
e.Use(echomiddleware.Logger())
|
||||
e.Use(echomiddleware.Recover())
|
||||
e.Use(context.WASMMiddleware)
|
||||
registerRoutes(e)
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func handleError() echo.HTTPErrorHandler {
|
||||
return func(err error, c echo.Context) {
|
||||
if he, ok := err.(*echo.HTTPError); ok {
|
||||
// Log the error if needed
|
||||
c.Logger().Errorf("Error: %v", he.Message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterRoutes registers the Decentralized Web Node API routes.
|
||||
func registerRoutes(e *echo.Echo) {
|
||||
}
|
||||
259
cmd/vault/main.go
Normal file
259
cmd/vault/main.go
Normal file
@@ -0,0 +1,259 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall/js"
|
||||
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
"github.com/onsonr/sonr/internal/config/motr"
|
||||
"github.com/onsonr/sonr/internal/database/motrorm"
|
||||
sink "github.com/onsonr/sonr/internal/database/sink"
|
||||
vault "github.com/onsonr/sonr/vault"
|
||||
)
|
||||
|
||||
var (
|
||||
// Global buffer pool to reduce allocations
|
||||
bufferPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new(bytes.Buffer)
|
||||
},
|
||||
}
|
||||
|
||||
// Cached JS globals
|
||||
jsGlobal = js.Global()
|
||||
jsUint8Array = jsGlobal.Get("Uint8Array")
|
||||
jsResponse = jsGlobal.Get("Response")
|
||||
jsPromise = jsGlobal.Get("Promise")
|
||||
jsWasmHTTP = jsGlobal.Get("wasmhttp")
|
||||
)
|
||||
|
||||
func main() {
|
||||
configString := "TODO"
|
||||
config, _ := loadConfig(configString)
|
||||
dbq, err := createDB()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
e, err := vault.New(config, dbq)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
serveFetch(e)
|
||||
}
|
||||
|
||||
// loadConfig loads the config from the given JSON string
|
||||
func loadConfig(configString string) (*motr.Config, error) {
|
||||
var config motr.Config
|
||||
err := json.Unmarshal([]byte(configString), &config)
|
||||
return &config, err
|
||||
}
|
||||
|
||||
// createDB initializes and returns a configured database connection
|
||||
func createDB() (*motrorm.Queries, error) {
|
||||
db, err := sql.Open("sqlite3", ":memory:")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// create tables
|
||||
if _, err := db.ExecContext(context.Background(), sink.SchemaVaultSQL); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return motrorm.New(db), nil
|
||||
}
|
||||
|
||||
// serveFetch serves HTTP requests with optimized handler management
|
||||
func serveFetch(handler http.Handler) func() {
|
||||
h := handler
|
||||
if h == nil {
|
||||
h = http.DefaultServeMux
|
||||
}
|
||||
|
||||
// Optimize prefix handling
|
||||
prefix := strings.TrimRight(jsWasmHTTP.Get("path").String(), "/")
|
||||
if prefix != "" {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle(prefix+"/", http.StripPrefix(prefix, h))
|
||||
h = mux
|
||||
}
|
||||
|
||||
// Create request handler function
|
||||
cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
promise, resolve, reject := newPromiseOptimized()
|
||||
|
||||
go handleRequest(h, args[1], resolve, reject)
|
||||
|
||||
return promise
|
||||
})
|
||||
|
||||
jsWasmHTTP.Call("setHandler", cb)
|
||||
return cb.Release
|
||||
}
|
||||
|
||||
// handleRequest processes the request with panic recovery
|
||||
func handleRequest(h http.Handler, jsReq js.Value, resolve, reject func(interface{})) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
var errMsg string
|
||||
if err, ok := r.(error); ok {
|
||||
errMsg = fmt.Sprintf("wasmhttp: panic: %+v", err)
|
||||
} else {
|
||||
errMsg = fmt.Sprintf("wasmhttp: panic: %v", r)
|
||||
}
|
||||
reject(errMsg)
|
||||
}
|
||||
}()
|
||||
|
||||
recorder := newResponseRecorder()
|
||||
h.ServeHTTP(recorder, buildRequest(jsReq))
|
||||
resolve(recorder.jsResponse())
|
||||
}
|
||||
|
||||
// buildRequest creates an http.Request from JS Request
|
||||
func buildRequest(jsReq js.Value) *http.Request {
|
||||
// Get request body
|
||||
arrayBuffer, err := awaitPromiseOptimized(jsReq.Call("arrayBuffer"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Create body buffer
|
||||
jsBody := jsUint8Array.New(arrayBuffer)
|
||||
bodyLen := jsBody.Get("length").Int()
|
||||
body := make([]byte, bodyLen)
|
||||
js.CopyBytesToGo(body, jsBody)
|
||||
|
||||
// Create request
|
||||
req := httptest.NewRequest(
|
||||
jsReq.Get("method").String(),
|
||||
jsReq.Get("url").String(),
|
||||
bytes.NewReader(body),
|
||||
)
|
||||
|
||||
// Set headers efficiently
|
||||
headers := jsReq.Get("headers")
|
||||
headersIt := headers.Call("entries")
|
||||
for {
|
||||
entry := headersIt.Call("next")
|
||||
if entry.Get("done").Bool() {
|
||||
break
|
||||
}
|
||||
pair := entry.Get("value")
|
||||
req.Header.Set(pair.Index(0).String(), pair.Index(1).String())
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
// ResponseRecorder with optimized buffer handling
|
||||
type ResponseRecorder struct {
|
||||
*httptest.ResponseRecorder
|
||||
buffer *bytes.Buffer
|
||||
}
|
||||
|
||||
func newResponseRecorder() *ResponseRecorder {
|
||||
return &ResponseRecorder{
|
||||
ResponseRecorder: httptest.NewRecorder(),
|
||||
buffer: bufferPool.Get().(*bytes.Buffer),
|
||||
}
|
||||
}
|
||||
|
||||
// jsResponse creates a JS Response with optimized memory usage
|
||||
func (rr *ResponseRecorder) jsResponse() js.Value {
|
||||
defer func() {
|
||||
rr.buffer.Reset()
|
||||
bufferPool.Put(rr.buffer)
|
||||
}()
|
||||
|
||||
res := rr.Result()
|
||||
defer res.Body.Close()
|
||||
|
||||
// Prepare response body
|
||||
body := js.Undefined()
|
||||
if res.ContentLength != 0 {
|
||||
if _, err := io.Copy(rr.buffer, res.Body); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
bodyBytes := rr.buffer.Bytes()
|
||||
body = jsUint8Array.New(len(bodyBytes))
|
||||
js.CopyBytesToJS(body, bodyBytes)
|
||||
}
|
||||
|
||||
// Prepare response init object
|
||||
init := make(map[string]interface{}, 3)
|
||||
if res.StatusCode != 0 {
|
||||
init["status"] = res.StatusCode
|
||||
}
|
||||
|
||||
if len(res.Header) > 0 {
|
||||
headers := make(map[string]interface{}, len(res.Header))
|
||||
for k, v := range res.Header {
|
||||
if len(v) > 0 {
|
||||
headers[k] = v[0]
|
||||
}
|
||||
}
|
||||
init["headers"] = headers
|
||||
}
|
||||
|
||||
return jsResponse.New(body, init)
|
||||
}
|
||||
|
||||
// newPromiseOptimized creates a new JavaScript Promise with optimized callback handling
|
||||
func newPromiseOptimized() (js.Value, func(interface{}), func(interface{})) {
|
||||
var (
|
||||
resolve func(interface{})
|
||||
reject func(interface{})
|
||||
promiseFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
resolve = func(v interface{}) { args[0].Invoke(v) }
|
||||
reject = func(v interface{}) { args[1].Invoke(v) }
|
||||
return js.Undefined()
|
||||
})
|
||||
)
|
||||
defer promiseFunc.Release()
|
||||
|
||||
return jsPromise.New(promiseFunc), resolve, reject
|
||||
}
|
||||
|
||||
// awaitPromiseOptimized waits for Promise resolution with optimized channel handling
|
||||
func awaitPromiseOptimized(promise js.Value) (js.Value, error) {
|
||||
done := make(chan struct{})
|
||||
var (
|
||||
result js.Value
|
||||
err error
|
||||
)
|
||||
|
||||
thenFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
result = args[0]
|
||||
close(done)
|
||||
return nil
|
||||
})
|
||||
defer thenFunc.Release()
|
||||
|
||||
catchFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
err = js.Error{Value: args[0]}
|
||||
close(done)
|
||||
return nil
|
||||
})
|
||||
defer catchFunc.Release()
|
||||
|
||||
promise.Call("then", thenFunc).Call("catch", catchFunc)
|
||||
<-done
|
||||
|
||||
return result, err
|
||||
}
|
||||
32
internal/database/hwayorm/db.go
Normal file
32
internal/database/hwayorm/db.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package hwayorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
68
internal/database/hwayorm/models.go
Normal file
68
internal/database/hwayorm/models.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package hwayorm
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type Credential struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
AuthenticatorAttachment string `json:"authenticator_attachment"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID string `json:"profile_id"`
|
||||
}
|
||||
|
||||
type Vault struct {
|
||||
ID int64 `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Address string `json:"address"`
|
||||
Cid string `json:"cid"`
|
||||
Config []byte `json:"config"`
|
||||
SessionID int64 `json:"session_id"`
|
||||
RedirectUri string `json:"redirect_uri"`
|
||||
}
|
||||
34
internal/database/hwayorm/querier.go
Normal file
34
internal/database/hwayorm/querier.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package hwayorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
CheckHandleExists(ctx context.Context, handle string) (bool, error)
|
||||
CreateSession(ctx context.Context, arg CreateSessionParams) (*Session, error)
|
||||
GetChallengeBySessionID(ctx context.Context, id string) (string, error)
|
||||
GetCredentialByID(ctx context.Context, credentialID string) (*Credential, error)
|
||||
GetCredentialsByHandle(ctx context.Context, handle string) ([]*Credential, error)
|
||||
GetHumanVerificationNumbers(ctx context.Context, id string) (*GetHumanVerificationNumbersRow, error)
|
||||
GetProfileByAddress(ctx context.Context, address string) (*Profile, error)
|
||||
GetProfileByHandle(ctx context.Context, handle string) (*Profile, error)
|
||||
GetProfileByID(ctx context.Context, id string) (*Profile, error)
|
||||
GetSessionByClientIP(ctx context.Context, clientIpaddr string) (*Session, error)
|
||||
GetSessionByID(ctx context.Context, id string) (*Session, error)
|
||||
GetVaultConfigByCID(ctx context.Context, cid string) (*Vault, error)
|
||||
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID int64) (string, error)
|
||||
InsertCredential(ctx context.Context, arg InsertCredentialParams) (*Credential, error)
|
||||
InsertProfile(ctx context.Context, arg InsertProfileParams) (*Profile, error)
|
||||
SoftDeleteCredential(ctx context.Context, credentialID string) error
|
||||
SoftDeleteProfile(ctx context.Context, address string) error
|
||||
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (*Profile, error)
|
||||
UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (*Session, error)
|
||||
UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (*Session, error)
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
583
internal/database/hwayorm/query.sql.go
Normal file
583
internal/database/hwayorm/query.sql.go
Normal file
@@ -0,0 +1,583 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: query.sql
|
||||
|
||||
package hwayorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const checkHandleExists = `-- name: CheckHandleExists :one
|
||||
SELECT COUNT(*) > 0 as handle_exists FROM profiles
|
||||
WHERE handle = $1
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
func (q *Queries) CheckHandleExists(ctx context.Context, handle string) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, checkHandleExists, handle)
|
||||
var handle_exists bool
|
||||
err := row.Scan(&handle_exists)
|
||||
return handle_exists, err
|
||||
}
|
||||
|
||||
const createSession = `-- name: CreateSession :one
|
||||
INSERT INTO sessions (
|
||||
id,
|
||||
browser_name,
|
||||
browser_version,
|
||||
client_ipaddr,
|
||||
platform,
|
||||
is_desktop,
|
||||
is_mobile,
|
||||
is_tablet,
|
||||
is_tv,
|
||||
is_bot,
|
||||
challenge,
|
||||
is_human_first,
|
||||
is_human_last,
|
||||
profile_id
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
|
||||
RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id
|
||||
`
|
||||
|
||||
type CreateSessionParams struct {
|
||||
ID string `json:"id"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID string `json:"profile_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, createSession,
|
||||
arg.ID,
|
||||
arg.BrowserName,
|
||||
arg.BrowserVersion,
|
||||
arg.ClientIpaddr,
|
||||
arg.Platform,
|
||||
arg.IsDesktop,
|
||||
arg.IsMobile,
|
||||
arg.IsTablet,
|
||||
arg.IsTv,
|
||||
arg.IsBot,
|
||||
arg.Challenge,
|
||||
arg.IsHumanFirst,
|
||||
arg.IsHumanLast,
|
||||
arg.ProfileID,
|
||||
)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getChallengeBySessionID = `-- name: GetChallengeBySessionID :one
|
||||
SELECT challenge FROM sessions
|
||||
WHERE id = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetChallengeBySessionID(ctx context.Context, id string) (string, error) {
|
||||
row := q.db.QueryRow(ctx, getChallengeBySessionID, id)
|
||||
var challenge string
|
||||
err := row.Scan(&challenge)
|
||||
return challenge, err
|
||||
}
|
||||
|
||||
const getCredentialByID = `-- name: GetCredentialByID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports FROM credentials
|
||||
WHERE credential_id = $1
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentialByID(ctx context.Context, credentialID string) (*Credential, error) {
|
||||
row := q.db.QueryRow(ctx, getCredentialByID, credentialID)
|
||||
var i Credential
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.CredentialID,
|
||||
&i.AuthenticatorAttachment,
|
||||
&i.Origin,
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getCredentialsByHandle = `-- name: GetCredentialsByHandle :many
|
||||
SELECT id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports FROM credentials
|
||||
WHERE handle = $1
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentialsByHandle(ctx context.Context, handle string) ([]*Credential, error) {
|
||||
rows, err := q.db.Query(ctx, getCredentialsByHandle, handle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []*Credential
|
||||
for rows.Next() {
|
||||
var i Credential
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.CredentialID,
|
||||
&i.AuthenticatorAttachment,
|
||||
&i.Origin,
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getHumanVerificationNumbers = `-- name: GetHumanVerificationNumbers :one
|
||||
SELECT is_human_first, is_human_last FROM sessions
|
||||
WHERE id = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetHumanVerificationNumbersRow struct {
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetHumanVerificationNumbers(ctx context.Context, id string) (*GetHumanVerificationNumbersRow, error) {
|
||||
row := q.db.QueryRow(ctx, getHumanVerificationNumbers, id)
|
||||
var i GetHumanVerificationNumbersRow
|
||||
err := row.Scan(&i.IsHumanFirst, &i.IsHumanLast)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getProfileByAddress = `-- name: GetProfileByAddress :one
|
||||
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name, status FROM profiles
|
||||
WHERE address = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, getProfileByAddress, address)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getProfileByHandle = `-- name: GetProfileByHandle :one
|
||||
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name, status FROM profiles
|
||||
WHERE handle = $1
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, getProfileByHandle, handle)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getProfileByID = `-- name: GetProfileByID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name, status FROM profiles
|
||||
WHERE id = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByID(ctx context.Context, id string) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, getProfileByID, id)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getSessionByClientIP = `-- name: GetSessionByClientIP :one
|
||||
SELECT id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id FROM sessions
|
||||
WHERE client_ipaddr = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetSessionByClientIP(ctx context.Context, clientIpaddr string) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, getSessionByClientIP, clientIpaddr)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getSessionByID = `-- name: GetSessionByID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id FROM sessions
|
||||
WHERE id = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetSessionByID(ctx context.Context, id string) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, getSessionByID, id)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getVaultConfigByCID = `-- name: GetVaultConfigByCID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri FROM vaults
|
||||
WHERE cid = $1
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetVaultConfigByCID(ctx context.Context, cid string) (*Vault, error) {
|
||||
row := q.db.QueryRow(ctx, getVaultConfigByCID, cid)
|
||||
var i Vault
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Address,
|
||||
&i.Cid,
|
||||
&i.Config,
|
||||
&i.SessionID,
|
||||
&i.RedirectUri,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getVaultRedirectURIBySessionID = `-- name: GetVaultRedirectURIBySessionID :one
|
||||
SELECT redirect_uri FROM vaults
|
||||
WHERE session_id = $1
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetVaultRedirectURIBySessionID(ctx context.Context, sessionID int64) (string, error) {
|
||||
row := q.db.QueryRow(ctx, getVaultRedirectURIBySessionID, sessionID)
|
||||
var redirect_uri string
|
||||
err := row.Scan(&redirect_uri)
|
||||
return redirect_uri, err
|
||||
}
|
||||
|
||||
const insertCredential = `-- name: InsertCredential :one
|
||||
INSERT INTO credentials (
|
||||
handle,
|
||||
credential_id,
|
||||
origin,
|
||||
type,
|
||||
transports
|
||||
) VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports
|
||||
`
|
||||
|
||||
type InsertCredentialParams struct {
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) (*Credential, error) {
|
||||
row := q.db.QueryRow(ctx, insertCredential,
|
||||
arg.Handle,
|
||||
arg.CredentialID,
|
||||
arg.Origin,
|
||||
arg.Type,
|
||||
arg.Transports,
|
||||
)
|
||||
var i Credential
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.CredentialID,
|
||||
&i.AuthenticatorAttachment,
|
||||
&i.Origin,
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const insertProfile = `-- name: InsertProfile :one
|
||||
INSERT INTO profiles (
|
||||
address,
|
||||
handle,
|
||||
origin,
|
||||
name
|
||||
) VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name, status
|
||||
`
|
||||
|
||||
type InsertProfileParams struct {
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, insertProfile,
|
||||
arg.Address,
|
||||
arg.Handle,
|
||||
arg.Origin,
|
||||
arg.Name,
|
||||
)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const softDeleteCredential = `-- name: SoftDeleteCredential :exec
|
||||
UPDATE credentials
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE credential_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) SoftDeleteCredential(ctx context.Context, credentialID string) error {
|
||||
_, err := q.db.Exec(ctx, softDeleteCredential, credentialID)
|
||||
return err
|
||||
}
|
||||
|
||||
const softDeleteProfile = `-- name: SoftDeleteProfile :exec
|
||||
UPDATE profiles
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE address = $1
|
||||
`
|
||||
|
||||
func (q *Queries) SoftDeleteProfile(ctx context.Context, address string) error {
|
||||
_, err := q.db.Exec(ctx, softDeleteProfile, address)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateProfile = `-- name: UpdateProfile :one
|
||||
UPDATE profiles
|
||||
SET
|
||||
name = $1,
|
||||
handle = $2,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE address = $3
|
||||
AND deleted_at IS NULL
|
||||
RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name, status
|
||||
`
|
||||
|
||||
type UpdateProfileParams struct {
|
||||
Name string `json:"name"`
|
||||
Handle string `json:"handle"`
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, updateProfile, arg.Name, arg.Handle, arg.Address)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const updateSessionHumanVerification = `-- name: UpdateSessionHumanVerification :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
is_human_first = $1,
|
||||
is_human_last = $2,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $3
|
||||
RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id
|
||||
`
|
||||
|
||||
type UpdateSessionHumanVerificationParams struct {
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, updateSessionHumanVerification, arg.IsHumanFirst, arg.IsHumanLast, arg.ID)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const updateSessionWithProfileID = `-- name: UpdateSessionWithProfileID :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
profile_id = $1,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $2
|
||||
RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id
|
||||
`
|
||||
|
||||
type UpdateSessionWithProfileIDParams struct {
|
||||
ProfileID string `json:"profile_id"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, updateSessionWithProfileID, arg.ProfileID, arg.ID)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
31
internal/database/motrorm/db.go
Normal file
31
internal/database/motrorm/db.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package motrorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
||||
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
99
internal/database/motrorm/models.go
Normal file
99
internal/database/motrorm/models.go
Normal file
@@ -0,0 +1,99 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package motrorm
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Number int64 `json:"number"`
|
||||
Sequence int64 `json:"sequence"`
|
||||
Address string `json:"address"`
|
||||
PublicKey string `json:"public_key"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Controller string `json:"controller"`
|
||||
IsSubsidiary bool `json:"is_subsidiary"`
|
||||
IsValidator bool `json:"is_validator"`
|
||||
IsDelegator bool `json:"is_delegator"`
|
||||
IsAccountable bool `json:"is_accountable"`
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Name string `json:"name"`
|
||||
Symbol string `json:"symbol"`
|
||||
Decimals int64 `json:"decimals"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Channel string `json:"channel"`
|
||||
AssetType string `json:"asset_type"`
|
||||
CoingeckoID sql.NullString `json:"coingecko_id"`
|
||||
}
|
||||
|
||||
type Credential struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
AuthenticatorAttachment string `json:"authenticator_attachment"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID int64 `json:"profile_id"`
|
||||
}
|
||||
|
||||
type Vault struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Address string `json:"address"`
|
||||
Cid string `json:"cid"`
|
||||
Config string `json:"config"`
|
||||
SessionID string `json:"session_id"`
|
||||
RedirectUri string `json:"redirect_uri"`
|
||||
}
|
||||
34
internal/database/motrorm/querier.go
Normal file
34
internal/database/motrorm/querier.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package motrorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
CheckHandleExists(ctx context.Context, handle string) (bool, error)
|
||||
CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
|
||||
GetChallengeBySessionID(ctx context.Context, id string) (string, error)
|
||||
GetCredentialByID(ctx context.Context, credentialID string) (Credential, error)
|
||||
GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, error)
|
||||
GetHumanVerificationNumbers(ctx context.Context, id string) (GetHumanVerificationNumbersRow, error)
|
||||
GetProfileByAddress(ctx context.Context, address string) (Profile, error)
|
||||
GetProfileByHandle(ctx context.Context, handle string) (Profile, error)
|
||||
GetProfileByID(ctx context.Context, id string) (Profile, error)
|
||||
GetSessionByClientIP(ctx context.Context, clientIpaddr string) (Session, error)
|
||||
GetSessionByID(ctx context.Context, id string) (Session, error)
|
||||
GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error)
|
||||
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error)
|
||||
InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error)
|
||||
InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error)
|
||||
SoftDeleteCredential(ctx context.Context, credentialID string) error
|
||||
SoftDeleteProfile(ctx context.Context, address string) error
|
||||
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)
|
||||
UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (Session, error)
|
||||
UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (Session, error)
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
581
internal/database/motrorm/query.sql.go
Normal file
581
internal/database/motrorm/query.sql.go
Normal file
@@ -0,0 +1,581 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: query.sql
|
||||
|
||||
package motrorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const checkHandleExists = `-- name: CheckHandleExists :one
|
||||
SELECT COUNT(*) > 0 as handle_exists FROM profiles
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
func (q *Queries) CheckHandleExists(ctx context.Context, handle string) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, checkHandleExists, handle)
|
||||
var handle_exists bool
|
||||
err := row.Scan(&handle_exists)
|
||||
return handle_exists, err
|
||||
}
|
||||
|
||||
const createSession = `-- name: CreateSession :one
|
||||
INSERT INTO sessions (
|
||||
id,
|
||||
browser_name,
|
||||
browser_version,
|
||||
client_ipaddr,
|
||||
platform,
|
||||
is_desktop,
|
||||
is_mobile,
|
||||
is_tablet,
|
||||
is_tv,
|
||||
is_bot,
|
||||
challenge,
|
||||
is_human_first,
|
||||
is_human_last,
|
||||
profile_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
|
||||
RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id
|
||||
`
|
||||
|
||||
type CreateSessionParams struct {
|
||||
ID string `json:"id"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID int64 `json:"profile_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error) {
|
||||
row := q.db.QueryRowContext(ctx, createSession,
|
||||
arg.ID,
|
||||
arg.BrowserName,
|
||||
arg.BrowserVersion,
|
||||
arg.ClientIpaddr,
|
||||
arg.Platform,
|
||||
arg.IsDesktop,
|
||||
arg.IsMobile,
|
||||
arg.IsTablet,
|
||||
arg.IsTv,
|
||||
arg.IsBot,
|
||||
arg.Challenge,
|
||||
arg.IsHumanFirst,
|
||||
arg.IsHumanLast,
|
||||
arg.ProfileID,
|
||||
)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getChallengeBySessionID = `-- name: GetChallengeBySessionID :one
|
||||
SELECT challenge FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetChallengeBySessionID(ctx context.Context, id string) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getChallengeBySessionID, id)
|
||||
var challenge string
|
||||
err := row.Scan(&challenge)
|
||||
return challenge, err
|
||||
}
|
||||
|
||||
const getCredentialByID = `-- name: GetCredentialByID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports FROM credentials
|
||||
WHERE credential_id = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentialByID(ctx context.Context, credentialID string) (Credential, error) {
|
||||
row := q.db.QueryRowContext(ctx, getCredentialByID, credentialID)
|
||||
var i Credential
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.CredentialID,
|
||||
&i.AuthenticatorAttachment,
|
||||
&i.Origin,
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getCredentialsByHandle = `-- name: GetCredentialsByHandle :many
|
||||
SELECT id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports FROM credentials
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getCredentialsByHandle, handle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Credential
|
||||
for rows.Next() {
|
||||
var i Credential
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.CredentialID,
|
||||
&i.AuthenticatorAttachment,
|
||||
&i.Origin,
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getHumanVerificationNumbers = `-- name: GetHumanVerificationNumbers :one
|
||||
SELECT is_human_first, is_human_last FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetHumanVerificationNumbersRow struct {
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetHumanVerificationNumbers(ctx context.Context, id string) (GetHumanVerificationNumbersRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getHumanVerificationNumbers, id)
|
||||
var i GetHumanVerificationNumbersRow
|
||||
err := row.Scan(&i.IsHumanFirst, &i.IsHumanLast)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProfileByAddress = `-- name: GetProfileByAddress :one
|
||||
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
|
||||
WHERE address = ? AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (Profile, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProfileByAddress, address)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProfileByHandle = `-- name: GetProfileByHandle :one
|
||||
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (Profile, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProfileByHandle, handle)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProfileByID = `-- name: GetProfileByID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByID(ctx context.Context, id string) (Profile, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProfileByID, id)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSessionByClientIP = `-- name: GetSessionByClientIP :one
|
||||
SELECT id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id FROM sessions
|
||||
WHERE client_ipaddr = ? AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetSessionByClientIP(ctx context.Context, clientIpaddr string) (Session, error) {
|
||||
row := q.db.QueryRowContext(ctx, getSessionByClientIP, clientIpaddr)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSessionByID = `-- name: GetSessionByID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetSessionByID(ctx context.Context, id string) (Session, error) {
|
||||
row := q.db.QueryRowContext(ctx, getSessionByID, id)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getVaultConfigByCID = `-- name: GetVaultConfigByCID :one
|
||||
SELECT id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri FROM vaults
|
||||
WHERE cid = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error) {
|
||||
row := q.db.QueryRowContext(ctx, getVaultConfigByCID, cid)
|
||||
var i Vault
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Address,
|
||||
&i.Cid,
|
||||
&i.Config,
|
||||
&i.SessionID,
|
||||
&i.RedirectUri,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getVaultRedirectURIBySessionID = `-- name: GetVaultRedirectURIBySessionID :one
|
||||
SELECT redirect_uri FROM vaults
|
||||
WHERE session_id = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getVaultRedirectURIBySessionID, sessionID)
|
||||
var redirect_uri string
|
||||
err := row.Scan(&redirect_uri)
|
||||
return redirect_uri, err
|
||||
}
|
||||
|
||||
const insertCredential = `-- name: InsertCredential :one
|
||||
INSERT INTO credentials (
|
||||
handle,
|
||||
credential_id,
|
||||
origin,
|
||||
type,
|
||||
transports
|
||||
) VALUES (?, ?, ?, ?, ?)
|
||||
RETURNING id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports
|
||||
`
|
||||
|
||||
type InsertCredentialParams struct {
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error) {
|
||||
row := q.db.QueryRowContext(ctx, insertCredential,
|
||||
arg.Handle,
|
||||
arg.CredentialID,
|
||||
arg.Origin,
|
||||
arg.Type,
|
||||
arg.Transports,
|
||||
)
|
||||
var i Credential
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Handle,
|
||||
&i.CredentialID,
|
||||
&i.AuthenticatorAttachment,
|
||||
&i.Origin,
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertProfile = `-- name: InsertProfile :one
|
||||
INSERT INTO profiles (
|
||||
address,
|
||||
handle,
|
||||
origin,
|
||||
name
|
||||
) VALUES (?, ?, ?, ?)
|
||||
RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name
|
||||
`
|
||||
|
||||
type InsertProfileParams struct {
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error) {
|
||||
row := q.db.QueryRowContext(ctx, insertProfile,
|
||||
arg.Address,
|
||||
arg.Handle,
|
||||
arg.Origin,
|
||||
arg.Name,
|
||||
)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const softDeleteCredential = `-- name: SoftDeleteCredential :exec
|
||||
UPDATE credentials
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE credential_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) SoftDeleteCredential(ctx context.Context, credentialID string) error {
|
||||
_, err := q.db.ExecContext(ctx, softDeleteCredential, credentialID)
|
||||
return err
|
||||
}
|
||||
|
||||
const softDeleteProfile = `-- name: SoftDeleteProfile :exec
|
||||
UPDATE profiles
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE address = ?
|
||||
`
|
||||
|
||||
func (q *Queries) SoftDeleteProfile(ctx context.Context, address string) error {
|
||||
_, err := q.db.ExecContext(ctx, softDeleteProfile, address)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateProfile = `-- name: UpdateProfile :one
|
||||
UPDATE profiles
|
||||
SET
|
||||
name = ?,
|
||||
handle = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE address = ?
|
||||
AND deleted_at IS NULL
|
||||
RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name
|
||||
`
|
||||
|
||||
type UpdateProfileParams struct {
|
||||
Name string `json:"name"`
|
||||
Handle string `json:"handle"`
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateProfile, arg.Name, arg.Handle, arg.Address)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.Address,
|
||||
&i.Handle,
|
||||
&i.Origin,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateSessionHumanVerification = `-- name: UpdateSessionHumanVerification :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
is_human_first = ?,
|
||||
is_human_last = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id
|
||||
`
|
||||
|
||||
type UpdateSessionHumanVerificationParams struct {
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (Session, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateSessionHumanVerification, arg.IsHumanFirst, arg.IsHumanLast, arg.ID)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateSessionWithProfileID = `-- name: UpdateSessionWithProfileID :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
profile_id = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version, client_ipaddr, platform, is_desktop, is_mobile, is_tablet, is_tv, is_bot, challenge, is_human_first, is_human_last, profile_id
|
||||
`
|
||||
|
||||
type UpdateSessionWithProfileIDParams struct {
|
||||
ProfileID int64 `json:"profile_id"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (Session, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateSessionWithProfileID, arg.ProfileID, arg.ID)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.BrowserName,
|
||||
&i.BrowserVersion,
|
||||
&i.ClientIpaddr,
|
||||
&i.Platform,
|
||||
&i.IsDesktop,
|
||||
&i.IsMobile,
|
||||
&i.IsTablet,
|
||||
&i.IsTv,
|
||||
&i.IsBot,
|
||||
&i.Challenge,
|
||||
&i.IsHumanFirst,
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
151
internal/database/sink/highway/query.sql
Normal file
151
internal/database/sink/highway/query.sql
Normal file
@@ -0,0 +1,151 @@
|
||||
-- name: InsertCredential :one
|
||||
INSERT INTO credentials (
|
||||
id,
|
||||
created_at,
|
||||
updated_at,
|
||||
deleted_at,
|
||||
handle,
|
||||
credential_id,
|
||||
authenticator_attachment,
|
||||
origin,
|
||||
type,
|
||||
transports
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: InsertProfile :one
|
||||
INSERT INTO profiles (
|
||||
id,
|
||||
created_at,
|
||||
updated_at,
|
||||
deleted_at,
|
||||
address,
|
||||
handle,
|
||||
origin,
|
||||
name,
|
||||
status
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetProfileByID :one
|
||||
SELECT * FROM profiles
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetProfileByAddress :one
|
||||
SELECT * FROM profiles
|
||||
WHERE address = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetChallengeBySessionID :one
|
||||
SELECT challenge FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetHumanVerificationNumbers :one
|
||||
SELECT is_human_first, is_human_last FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetSessionByID :one
|
||||
SELECT * FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetSessionByClientIP :one
|
||||
SELECT * FROM sessions
|
||||
WHERE client_ipaddr = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: UpdateSessionHumanVerification :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
is_human_first = ?,
|
||||
is_human_last = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateSessionWithProfileID :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
profile_id = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
RETURNING *;
|
||||
|
||||
-- name: CheckHandleExists :one
|
||||
SELECT COUNT(*) > 0 as handle_exists FROM profiles
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL;
|
||||
|
||||
-- name: GetCredentialsByHandle :many
|
||||
SELECT * FROM credentials
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL;
|
||||
|
||||
-- name: GetCredentialByID :one
|
||||
SELECT * FROM credentials
|
||||
WHERE credential_id = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: SoftDeleteCredential :exec
|
||||
UPDATE credentials
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE credential_id = ?;
|
||||
|
||||
-- name: SoftDeleteProfile :exec
|
||||
UPDATE profiles
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: UpdateProfile :one
|
||||
UPDATE profiles
|
||||
SET
|
||||
name = ?,
|
||||
handle = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
AND deleted_at IS NULL
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetProfileByHandle :one
|
||||
SELECT * FROM profiles
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetVaultConfigByCID :one
|
||||
SELECT * FROM vaults
|
||||
WHERE cid = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetVaultRedirectURIBySessionID :one
|
||||
SELECT redirect_uri FROM vaults
|
||||
WHERE session_id = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: CreateSession :one
|
||||
INSERT INTO sessions (
|
||||
id,
|
||||
created_at,
|
||||
updated_at,
|
||||
deleted_at,
|
||||
browser_name,
|
||||
browser_version,
|
||||
client_ipaddr,
|
||||
platform,
|
||||
is_desktop,
|
||||
is_mobile,
|
||||
is_tablet,
|
||||
is_tv,
|
||||
is_bot,
|
||||
challenge,
|
||||
is_human_first,
|
||||
is_human_last,
|
||||
profile_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
122
internal/database/sink/highway/schema.sql
Normal file
122
internal/database/sink/highway/schema.sql
Normal file
@@ -0,0 +1,122 @@
|
||||
-- Profiles represent user identities
|
||||
CREATE TABLE profiles (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at DATETIME,
|
||||
address TEXT NOT NULL,
|
||||
handle TEXT NOT NULL UNIQUE,
|
||||
origin TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
UNIQUE(address, origin)
|
||||
);
|
||||
|
||||
-- Accounts represent blockchain accounts
|
||||
CREATE TABLE accounts (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at DATETIME,
|
||||
number INTEGER NOT NULL,
|
||||
sequence INTEGER NOT NULL DEFAULT 0,
|
||||
address TEXT NOT NULL UNIQUE,
|
||||
public_key TEXT NOT NULL,
|
||||
chain_id TEXT NOT NULL,
|
||||
controller TEXT NOT NULL,
|
||||
is_subsidiary INTEGER NOT NULL DEFAULT 0,
|
||||
is_validator INTEGER NOT NULL DEFAULT 0,
|
||||
is_delegator INTEGER NOT NULL DEFAULT 0,
|
||||
is_accountable INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
|
||||
-- Assets represent tokens and coins
|
||||
CREATE TABLE assets (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at DATETIME,
|
||||
name TEXT NOT NULL,
|
||||
symbol TEXT NOT NULL,
|
||||
decimals INTEGER NOT NULL CHECK(decimals >= 0),
|
||||
chain_id TEXT NOT NULL,
|
||||
channel TEXT NOT NULL,
|
||||
asset_type TEXT NOT NULL,
|
||||
coingecko_id TEXT,
|
||||
UNIQUE(chain_id, symbol)
|
||||
);
|
||||
|
||||
-- Credentials store WebAuthn credentials
|
||||
CREATE TABLE credentials (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at DATETIME,
|
||||
handle TEXT NOT NULL,
|
||||
credential_id TEXT NOT NULL UNIQUE,
|
||||
authenticator_attachment TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
transports TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- Sessions track user authentication state
|
||||
CREATE TABLE sessions (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at DATETIME,
|
||||
browser_name TEXT NOT NULL,
|
||||
browser_version TEXT NOT NULL,
|
||||
client_ipaddr TEXT NOT NULL,
|
||||
platform TEXT NOT NULL,
|
||||
is_desktop INTEGER NOT NULL DEFAULT 0,
|
||||
is_mobile INTEGER NOT NULL DEFAULT 0,
|
||||
is_tablet INTEGER NOT NULL DEFAULT 0,
|
||||
is_tv INTEGER NOT NULL DEFAULT 0,
|
||||
is_bot INTEGER NOT NULL DEFAULT 0,
|
||||
challenge TEXT NOT NULL,
|
||||
is_human_first INTEGER NOT NULL DEFAULT 0,
|
||||
is_human_last INTEGER NOT NULL DEFAULT 0,
|
||||
profile_id TEXT NOT NULL,
|
||||
FOREIGN KEY (profile_id) REFERENCES profiles(id)
|
||||
);
|
||||
|
||||
-- Vaults store encrypted data
|
||||
CREATE TABLE vaults (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at DATETIME,
|
||||
handle TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
cid TEXT NOT NULL UNIQUE,
|
||||
config TEXT NOT NULL,
|
||||
session_id TEXT NOT NULL,
|
||||
redirect_uri TEXT NOT NULL,
|
||||
FOREIGN KEY (session_id) REFERENCES sessions(id)
|
||||
);
|
||||
|
||||
-- Indexes for common queries
|
||||
CREATE INDEX idx_profiles_handle ON profiles(handle);
|
||||
CREATE INDEX idx_profiles_address ON profiles(address);
|
||||
CREATE INDEX idx_profiles_origin ON profiles(origin);
|
||||
CREATE INDEX idx_profiles_status ON profiles(status);
|
||||
CREATE INDEX idx_profiles_deleted_at ON profiles(deleted_at);
|
||||
|
||||
CREATE INDEX idx_accounts_address ON accounts(address);
|
||||
CREATE INDEX idx_accounts_chain_id ON accounts(chain_id);
|
||||
CREATE INDEX idx_accounts_deleted_at ON accounts(deleted_at);
|
||||
|
||||
CREATE INDEX idx_assets_symbol ON assets(symbol);
|
||||
CREATE INDEX idx_assets_chain_id ON assets(chain_id);
|
||||
CREATE INDEX idx_assets_deleted_at ON assets(deleted_at);
|
||||
|
||||
CREATE INDEX idx_credentials_handle ON credentials(handle);
|
||||
CREATE INDEX idx_credentials_origin ON credentials(origin);
|
||||
CREATE INDEX idx_credentials_deleted_at ON credentials(deleted_at);
|
||||
|
||||
CREATE INDEX idx_sessions_profile_id ON sessions(profile_id);
|
||||
CREATE INDEX idx_sessions_client_ipaddr ON sessions(client_ipaddr);
|
||||
CREATE INDEX idx_sessions_deleted_at ON sessions(deleted_at);
|
||||
8
internal/database/sink/sink.go
Normal file
8
internal/database/sink/sink.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package sink
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed vault/schema.sql
|
||||
var SchemaVaultSQL string
|
||||
138
internal/database/sink/vault/query.sql
Normal file
138
internal/database/sink/vault/query.sql
Normal file
@@ -0,0 +1,138 @@
|
||||
-- name: InsertCredential :one
|
||||
INSERT INTO credentials (
|
||||
handle,
|
||||
credential_id,
|
||||
origin,
|
||||
type,
|
||||
transports
|
||||
) VALUES (?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: InsertProfile :one
|
||||
INSERT INTO profiles (
|
||||
address,
|
||||
handle,
|
||||
origin,
|
||||
name
|
||||
) VALUES (?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetProfileByID :one
|
||||
SELECT * FROM profiles
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetProfileByAddress :one
|
||||
SELECT * FROM profiles
|
||||
WHERE address = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetChallengeBySessionID :one
|
||||
SELECT challenge FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetHumanVerificationNumbers :one
|
||||
SELECT is_human_first, is_human_last FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetSessionByID :one
|
||||
SELECT * FROM sessions
|
||||
WHERE id = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetSessionByClientIP :one
|
||||
SELECT * FROM sessions
|
||||
WHERE client_ipaddr = ? AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: UpdateSessionHumanVerification :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
is_human_first = ?,
|
||||
is_human_last = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateSessionWithProfileID :one
|
||||
UPDATE sessions
|
||||
SET
|
||||
profile_id = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
RETURNING *;
|
||||
|
||||
-- name: CheckHandleExists :one
|
||||
SELECT COUNT(*) > 0 as handle_exists FROM profiles
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL;
|
||||
|
||||
-- name: GetCredentialsByHandle :many
|
||||
SELECT * FROM credentials
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL;
|
||||
|
||||
-- name: GetCredentialByID :one
|
||||
SELECT * FROM credentials
|
||||
WHERE credential_id = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: SoftDeleteCredential :exec
|
||||
UPDATE credentials
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE credential_id = ?;
|
||||
|
||||
-- name: SoftDeleteProfile :exec
|
||||
UPDATE profiles
|
||||
SET deleted_at = CURRENT_TIMESTAMP
|
||||
WHERE address = ?;
|
||||
|
||||
-- name: UpdateProfile :one
|
||||
UPDATE profiles
|
||||
SET
|
||||
name = ?,
|
||||
handle = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE address = ?
|
||||
AND deleted_at IS NULL
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetProfileByHandle :one
|
||||
SELECT * FROM profiles
|
||||
WHERE handle = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetVaultConfigByCID :one
|
||||
SELECT * FROM vaults
|
||||
WHERE cid = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetVaultRedirectURIBySessionID :one
|
||||
SELECT redirect_uri FROM vaults
|
||||
WHERE session_id = ?
|
||||
AND deleted_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: CreateSession :one
|
||||
INSERT INTO sessions (
|
||||
id,
|
||||
browser_name,
|
||||
browser_version,
|
||||
client_ipaddr,
|
||||
platform,
|
||||
is_desktop,
|
||||
is_mobile,
|
||||
is_tablet,
|
||||
is_tv,
|
||||
is_bot,
|
||||
challenge,
|
||||
is_human_first,
|
||||
is_human_last,
|
||||
profile_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
|
||||
RETURNING *;
|
||||
121
internal/database/sink/vault/schema.sql
Normal file
121
internal/database/sink/vault/schema.sql
Normal file
@@ -0,0 +1,121 @@
|
||||
-- Profiles represent user identities
|
||||
CREATE TABLE profiles (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
address TEXT NOT NULL,
|
||||
handle TEXT NOT NULL UNIQUE,
|
||||
origin TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
UNIQUE(address, origin)
|
||||
);
|
||||
|
||||
-- Accounts represent blockchain accounts
|
||||
CREATE TABLE accounts (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
number INTEGER NOT NULL,
|
||||
sequence INTEGER NOT NULL DEFAULT 0,
|
||||
address TEXT NOT NULL UNIQUE,
|
||||
public_key TEXT NOT NULL CHECK(json_valid(public_key)),
|
||||
chain_id TEXT NOT NULL,
|
||||
controller TEXT NOT NULL,
|
||||
is_subsidiary BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_subsidiary IN (0,1)),
|
||||
is_validator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_validator IN (0,1)),
|
||||
is_delegator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegator IN (0,1)),
|
||||
is_accountable BOOLEAN NOT NULL DEFAULT TRUE CHECK(is_accountable IN (0,1))
|
||||
);
|
||||
|
||||
-- Assets represent tokens and coins
|
||||
CREATE TABLE assets (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
name TEXT NOT NULL,
|
||||
symbol TEXT NOT NULL,
|
||||
decimals INTEGER NOT NULL CHECK(decimals >= 0),
|
||||
chain_id TEXT NOT NULL,
|
||||
channel TEXT NOT NULL,
|
||||
asset_type TEXT NOT NULL,
|
||||
coingecko_id TEXT,
|
||||
UNIQUE(chain_id, symbol)
|
||||
);
|
||||
|
||||
-- Credentials store WebAuthn credentials
|
||||
CREATE TABLE credentials (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
handle TEXT NOT NULL,
|
||||
credential_id TEXT NOT NULL UNIQUE,
|
||||
authenticator_attachment TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
transports TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- Sessions track user authentication state
|
||||
CREATE TABLE sessions (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
browser_name TEXT NOT NULL,
|
||||
browser_version TEXT NOT NULL,
|
||||
client_ipaddr TEXT NOT NULL,
|
||||
platform TEXT NOT NULL,
|
||||
is_desktop BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_desktop IN (0,1)),
|
||||
is_mobile BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_mobile IN (0,1)),
|
||||
is_tablet BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_tablet IN (0,1)),
|
||||
is_tv BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_tv IN (0,1)),
|
||||
is_bot BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_bot IN (0,1)),
|
||||
challenge TEXT NOT NULL,
|
||||
is_human_first BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_human_first IN (0,1)),
|
||||
is_human_last BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_human_last IN (0,1)),
|
||||
profile_id INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- Vaults store encrypted data
|
||||
CREATE TABLE vaults (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
handle TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
cid TEXT NOT NULL UNIQUE,
|
||||
config TEXT NOT NULL CHECK(json_valid(config)),
|
||||
session_id TEXT NOT NULL,
|
||||
redirect_uri TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes for common queries
|
||||
CREATE INDEX idx_profiles_handle ON profiles(handle);
|
||||
CREATE INDEX idx_profiles_address ON profiles(address);
|
||||
CREATE INDEX idx_profiles_deleted_at ON profiles(deleted_at);
|
||||
|
||||
CREATE INDEX idx_accounts_address ON accounts(address);
|
||||
CREATE INDEX idx_accounts_chain_id ON accounts(chain_id);
|
||||
CREATE INDEX idx_accounts_deleted_at ON accounts(deleted_at);
|
||||
|
||||
CREATE INDEX idx_assets_symbol ON assets(symbol);
|
||||
CREATE INDEX idx_assets_chain_id ON assets(chain_id);
|
||||
CREATE INDEX idx_assets_deleted_at ON assets(deleted_at);
|
||||
|
||||
CREATE INDEX idx_credentials_handle ON credentials(handle);
|
||||
CREATE INDEX idx_credentials_origin ON credentials(origin);
|
||||
CREATE INDEX idx_credentials_deleted_at ON credentials(deleted_at);
|
||||
|
||||
CREATE INDEX idx_sessions_profile_id ON sessions(profile_id);
|
||||
CREATE INDEX idx_sessions_client_ipaddr ON sessions(client_ipaddr);
|
||||
CREATE INDEX idx_sessions_deleted_at ON sessions(deleted_at);
|
||||
|
||||
CREATE INDEX idx_vaults_handle ON vaults(handle);
|
||||
CREATE INDEX idx_vaults_session_id ON vaults(session_id);
|
||||
CREATE INDEX idx_vaults_deleted_at ON vaults(deleted_at);
|
||||
26
internal/database/sqlc.yaml
Normal file
26
internal/database/sqlc.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "sqlite"
|
||||
queries: "./sink/vault/query.sql"
|
||||
schema: "./sink/vault/schema.sql"
|
||||
gen:
|
||||
go:
|
||||
emit_interface: true
|
||||
emit_json_tags: true
|
||||
package: "motrorm"
|
||||
out: "motrorm"
|
||||
|
||||
- engine: "postgresql"
|
||||
queries: "./sink/highway/query.sql"
|
||||
schema: "./sink/highway/schema.sql"
|
||||
gen:
|
||||
go:
|
||||
emit_all_enum_values: true
|
||||
emit_enum_valid_method: true
|
||||
emit_json_tags: true
|
||||
emit_interface: true
|
||||
emit_result_struct_pointers: true
|
||||
omit_unused_structs: true
|
||||
package: "hwayorm"
|
||||
out: "hwayorm"
|
||||
sql_package: "pgx/v5"
|
||||
Submodule libs/es-client deleted from e49ecaffe2
34
pkg/context/wasm.go
Normal file
34
pkg/context/wasm.go
Normal file
@@ -0,0 +1,34 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package context
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func WASMMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
// Extract WASM context from headers
|
||||
if wasmCtx := c.Request().Header.Get("X-Wasm-Context"); wasmCtx != "" {
|
||||
if ctx, err := decodeWasmContext(wasmCtx); err == nil {
|
||||
c.Set("wasm_context", ctx)
|
||||
}
|
||||
}
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
|
||||
// decodeWasmContext decodes the WASM context from a base64 encoded string
|
||||
func decodeWasmContext(ctx string) (map[string]any, error) {
|
||||
decoded, err := base64.StdEncoding.DecodeString(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ctxData map[string]any
|
||||
err = json.Unmarshal(decoded, &ctxData)
|
||||
return ctxData, err
|
||||
}
|
||||
58
pkg/views/base_form.templ
Normal file
58
pkg/views/base_form.templ
Normal file
@@ -0,0 +1,58 @@
|
||||
package views
|
||||
|
||||
templ Form(action, id string) {
|
||||
<form hx-post={ action } hx-target="#{ id }" hx-swap="outerHTML">
|
||||
{ children... }
|
||||
</form>
|
||||
}
|
||||
|
||||
templ FormHeader() {
|
||||
<div slot="header">
|
||||
<div class="w-full py-2">
|
||||
{ children... }
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ FormBody() {
|
||||
<sl-card class="card-form max-w-lg mx-auto">
|
||||
{ children... }
|
||||
<style>
|
||||
.card-form {
|
||||
space-y: 1rem;
|
||||
}
|
||||
|
||||
.card-form [slot='header'] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.card-form [slot='footer'] {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</sl-card>
|
||||
}
|
||||
|
||||
templ FormFooter() {
|
||||
<div slot="footer">
|
||||
{ children... }
|
||||
</div>
|
||||
}
|
||||
|
||||
templ FormCancel() {
|
||||
<sl-button href="/" outline>
|
||||
<sl-icon slot="prefix" name="x-lg"></sl-icon>
|
||||
Cancel
|
||||
</sl-button>
|
||||
}
|
||||
|
||||
templ FormSubmit(text string) {
|
||||
<sl-button type="submit">
|
||||
{ text }
|
||||
<sl-icon slot="suffix" name="arrow-right" library="sonr"></sl-icon>
|
||||
</sl-button>
|
||||
}
|
||||
243
pkg/views/base_form_templ.go
Normal file
243
pkg/views/base_form_templ.go
Normal file
@@ -0,0 +1,243 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.793
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func Form(action, id string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form hx-post=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(action)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_form.templ`, Line: 4, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"#{ id }\" hx-swap=\"outerHTML\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FormHeader() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var3 == nil {
|
||||
templ_7745c5c3_Var3 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div slot=\"header\"><div class=\"w-full py-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FormBody() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<sl-card class=\"card-form max-w-lg mx-auto\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var4.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<style>\n\t\t.card-form {\n\t\t\t\tspace-y: 1rem;\n\t\t}\n\n \t.card-form [slot='header'] {\n \tdisplay: flex;\n \talign-items: center;\n \t justify-content: space-between;\n\t }\n\n\t .card-form [slot='footer'] {\n \t \tdisplay: flex;\n \tjustify-content: space-between;\n \talign-items: center;\n \t}\n\t\t</style></sl-card>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FormFooter() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var5 == nil {
|
||||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div slot=\"footer\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var5.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FormCancel() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var6 == nil {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<sl-button href=\"/\" outline><sl-icon slot=\"prefix\" name=\"x-lg\"></sl-icon> Cancel</sl-button>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FormSubmit(text string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var7 == nil {
|
||||
templ_7745c5c3_Var7 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<sl-button type=\"submit\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_form.templ`, Line: 55, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <sl-icon slot=\"suffix\" name=\"arrow-right\" library=\"sonr\"></sl-icon></sl-button>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
135
pkg/views/base_head.templ
Normal file
135
pkg/views/base_head.templ
Normal file
@@ -0,0 +1,135 @@
|
||||
package views
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
nebulaHandle = templ.NewOnceHandle()
|
||||
tailwindHandle = templ.NewOnceHandle()
|
||||
alpineHandle = templ.NewOnceHandle()
|
||||
dexieHandle = templ.NewOnceHandle()
|
||||
htmxHandle = templ.NewOnceHandle()
|
||||
turnstileHandle = templ.NewOnceHandle()
|
||||
)
|
||||
|
||||
templ Head(title string, nebulaVersion string) {
|
||||
<head>
|
||||
@Turnstile()
|
||||
@Tailwind()
|
||||
@Alpine()
|
||||
@Htmx()
|
||||
@Dexie()
|
||||
@Nebula(nebulaVersion)
|
||||
<meta charset="UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>{ title }</title>
|
||||
<!-- Sets the status bar style to transparent -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
|
||||
<link rel="icon" type="image/png" href="https://cdn.sonr.id/favicon.png"/>
|
||||
<style>
|
||||
@keyframes fade-in {
|
||||
from { opacity: 0; }
|
||||
}
|
||||
|
||||
@keyframes fade-out {
|
||||
to { opacity: 0; }
|
||||
}
|
||||
|
||||
@keyframes slide-from-right {
|
||||
from { transform: translateX(90px); }
|
||||
}
|
||||
|
||||
@keyframes slide-to-left {
|
||||
to { transform: translateX(-90px); }
|
||||
}
|
||||
|
||||
.slide-it {
|
||||
view-transition-name: slide-it;
|
||||
}
|
||||
|
||||
::view-transition-old(slide-it) {
|
||||
animation: 180ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
|
||||
600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;
|
||||
}
|
||||
::view-transition-new(slide-it) {
|
||||
animation: 420ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
|
||||
600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right;
|
||||
}
|
||||
</style>
|
||||
{ children... }
|
||||
</head>
|
||||
}
|
||||
|
||||
// ╭──────────────────────────────────────────────────────────╮
|
||||
// │ 3rd Party Libraries │
|
||||
// ╰──────────────────────────────────────────────────────────╯
|
||||
|
||||
// Tailwind css dependencies
|
||||
templ Tailwind() {
|
||||
@tailwindHandle.Once() {
|
||||
<script src="https://cdn.tailwindcss.com?plugins=typography,aspect-ratio,container-queries"></script>
|
||||
<script src="https://kit.fontawesome.com/9909219bb5.js" crossorigin="anonymous"></script>
|
||||
}
|
||||
}
|
||||
|
||||
// Turnstile is used for cloudflare challenges
|
||||
templ Turnstile() {
|
||||
@turnstileHandle.Once() {
|
||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
||||
}
|
||||
}
|
||||
|
||||
// Alpine is a component that renders the Alpine.js library
|
||||
templ Alpine() {
|
||||
@alpineHandle.Once() {
|
||||
<script src={ jsDelivrURL("alpinejs", "3.14.6", "dist/cdn.min.js") }></script>
|
||||
<script src={ jsDelivrURL("@alpinejs/focus", "3.14.6", "dist/cdn.min.js") }></script>
|
||||
}
|
||||
}
|
||||
|
||||
// Dexie is a component that renders the Dexie.js library
|
||||
templ Dexie() {
|
||||
@dexieHandle.Once() {
|
||||
<script src={ jsDelivrURL("dexie", "4.0.10", "dist/dexie.min.js") }></script>
|
||||
<script src={ jsDelivrURL("dexie-export-import", "4.1.4", "dist/dexie-export-import.min.js") }></script>
|
||||
}
|
||||
}
|
||||
|
||||
// Htmx is a component that renders the Htmx.js library
|
||||
templ Htmx() {
|
||||
@htmxHandle.Once() {
|
||||
<script src={ jsDelivrURL("htmx.org", "1.9.12", "dist/htmx.min.js") }></script>
|
||||
<script src={ jsDelivrURL("htmx-ext-include-vals", "2.0.0", "include-vals.min.js") }></script>
|
||||
<script src={ jsDelivrURL("htmx-ext-path-params", "2.0.0", "path-params.min.js") }></script>
|
||||
<script src={ jsDelivrURL("htmx-ext-alpine-morph", "2.0.0", "alpine-morph.min.js") }></script>
|
||||
<script src={ jsDelivrURL("htmx-ext-sse", "2.2.2", "sse.min.js") }></script>
|
||||
<script src={ jsDelivrURL("htmx-ext-ws", "2.0.2", "ws.min.js") }></script>
|
||||
}
|
||||
}
|
||||
|
||||
// Nebula is a component that renders the Nebula.js library
|
||||
templ Nebula(version string) {
|
||||
<link
|
||||
rel="stylesheet"
|
||||
media="(prefers-color-scheme:light)"
|
||||
href={ jsDelivrURL("@onsonr/nebula", version, "cdn/themes/light.css") }
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
media="(prefers-color-scheme:dark)"
|
||||
href={ jsDelivrURL("@onsonr/nebula", version, "cdn/themes/dark.css") }
|
||||
onload="document.documentElement.classList.add('sl-theme-dark');"
|
||||
/>
|
||||
@nebulaHandle.Once() {
|
||||
<script type="module" src={ jsDelivrURL("@onsonr/nebula", version, "cdn/shoelace-autoloader.js") }></script>
|
||||
}
|
||||
}
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Helper Functions │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
func jsDelivrURL(pkg string, version string, path string) string {
|
||||
return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s@%s/%s", pkg, version, path)
|
||||
}
|
||||
573
pkg/views/base_head_templ.go
Normal file
573
pkg/views/base_head_templ.go
Normal file
@@ -0,0 +1,573 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.793
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
nebulaHandle = templ.NewOnceHandle()
|
||||
tailwindHandle = templ.NewOnceHandle()
|
||||
alpineHandle = templ.NewOnceHandle()
|
||||
dexieHandle = templ.NewOnceHandle()
|
||||
htmxHandle = templ.NewOnceHandle()
|
||||
turnstileHandle = templ.NewOnceHandle()
|
||||
)
|
||||
|
||||
func Head(title string, nebulaVersion string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<head>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Turnstile().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Tailwind().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Alpine().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Htmx().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Dexie().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Nebula(nebulaVersion).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 25, Col: 16}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</title><!-- Sets the status bar style to transparent --><meta name=\"apple-mobile-web-app-capable\" content=\"yes\"><meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\"><link rel=\"icon\" type=\"image/png\" href=\"https://cdn.sonr.id/favicon.png\"><style>\n \t\t@keyframes fade-in {\n \t\tfrom { opacity: 0; }\n \t\t}\n\n \t\t@keyframes fade-out {\n \t\tto { opacity: 0; }\n \t\t}\n\n \t\t@keyframes slide-from-right {\n \t\tfrom { transform: translateX(90px); }\n \t\t}\n\n \t\t@keyframes slide-to-left {\n \t\tto { transform: translateX(-90px); }\n \t\t}\n\n \t\t.slide-it {\n \t\tview-transition-name: slide-it;\n \t\t}\n\n \t\t::view-transition-old(slide-it) {\n \t\tanimation: 180ms cubic-bezier(0.4, 0, 1, 1) both fade-out,\n \t\t600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;\n \t\t}\n \t\t::view-transition-new(slide-it) {\n \t\tanimation: 420ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,\n \t\t600ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right;\n \t\t}\n\t\t</style>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</head>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// ╭──────────────────────────────────────────────────────────╮
|
||||
// │ 3rd Party Libraries │
|
||||
// ╰──────────────────────────────────────────────────────────╯
|
||||
|
||||
// Tailwind css dependencies
|
||||
func Tailwind() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var3 == nil {
|
||||
templ_7745c5c3_Var3 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"https://cdn.tailwindcss.com?plugins=typography,aspect-ratio,container-queries\"></script> <script src=\"https://kit.fontawesome.com/9909219bb5.js\" crossorigin=\"anonymous\"></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = tailwindHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Turnstile is used for cloudflare challenges
|
||||
func Turnstile() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var5 == nil {
|
||||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"https://challenges.cloudflare.com/turnstile/v0/api.js\" async defer></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = turnstileHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Alpine is a component that renders the Alpine.js library
|
||||
func Alpine() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var7 == nil {
|
||||
templ_7745c5c3_Var7 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var8 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("alpinejs", "3.14.6", "dist/cdn.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 86, Col: 68}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@alpinejs/focus", "3.14.6", "dist/cdn.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 87, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Dexie is a component that renders the Dexie.js library
|
||||
func Dexie() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var11 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var11 == nil {
|
||||
templ_7745c5c3_Var11 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie", "4.0.10", "dist/dexie.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 94, Col: 67}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie-export-import", "4.1.4", "dist/dexie-export-import.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 95, Col: 94}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = dexieHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Htmx is a component that renders the Htmx.js library
|
||||
func Htmx() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var15 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var15 == nil {
|
||||
templ_7745c5c3_Var15 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var16 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx.org", "1.9.12", "dist/htmx.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 102, Col: 69}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-include-vals", "2.0.0", "include-vals.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 103, Col: 84}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-path-params", "2.0.0", "path-params.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 104, Col: 82}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-alpine-morph", "2.0.0", "alpine-morph.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 105, Col: 84}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-sse", "2.2.2", "sse.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 106, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-ws", "2.0.2", "ws.min.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 107, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Nebula is a component that renders the Nebula.js library
|
||||
func Nebula(version string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var23 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var23 == nil {
|
||||
templ_7745c5c3_Var23 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<link rel=\"stylesheet\" media=\"(prefers-color-scheme:light)\" href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var24 string
|
||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/light.css"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 116, Col: 71}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><link rel=\"stylesheet\" media=\"(prefers-color-scheme:dark)\" href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var25 string
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/dark.css"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 121, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" onload=\"document.documentElement.classList.add('sl-theme-dark');\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var26 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script type=\"module\" src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/shoelace-autoloader.js"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_head.templ`, Line: 125, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = nebulaHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var26), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Helper Functions │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
func jsDelivrURL(pkg string, version string, path string) string {
|
||||
return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s@%s/%s", pkg, version, path)
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
36
pkg/views/base_hero.templ
Normal file
36
pkg/views/base_hero.templ
Normal file
@@ -0,0 +1,36 @@
|
||||
package views
|
||||
|
||||
templ HeroTitle(title string, subtitle string) {
|
||||
<div class="flex flex-col items-center justify-center h-full w-full gap-2.5">
|
||||
<h1 class="text-2xl md:text-3xl lg:text-4xl font-bold">
|
||||
{ title }
|
||||
</h1>
|
||||
<p class="text-md md:text-lg lg:text-xl font-medium text-gray-500">
|
||||
{ subtitle }
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ HeroStart() {
|
||||
<div class="pt-1.5 mb-3 flex flex-col items-center justify-center h-full">
|
||||
<sl-button size="large" hx-target="#container" hx-get="/register" hx-push-url="/register" type="button">
|
||||
<sl-icon slot="prefix" library="sonr" name="sonr"></sl-icon>
|
||||
Create Vault
|
||||
<sl-icon slot="suffix" library="sonr" name="arrow-right"></sl-icon>
|
||||
</sl-button>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ HeroSocials() {
|
||||
<div class="pt-1.5 flex flex-row items-center justify-center h-full gap-3">
|
||||
<sl-button circle outline href="https://sonr.io">
|
||||
<sl-icon name="home" library="sonr" label="Home"></sl-icon>
|
||||
</sl-button>
|
||||
<sl-button circle outline href="https://onsonr.dev">
|
||||
<sl-icon name="docs" library="sonr" label="Docs"></sl-icon>
|
||||
</sl-button>
|
||||
<sl-button circle outline href="https://github.com/onsonr/sonr">
|
||||
<sl-icon name="social-github" library="sonr" label="Open Source"></sl-icon>
|
||||
</sl-button>
|
||||
</div>
|
||||
}
|
||||
124
pkg/views/base_hero_templ.go
Normal file
124
pkg/views/base_hero_templ.go
Normal file
@@ -0,0 +1,124 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.793
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func HeroTitle(title string, subtitle string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col items-center justify-center h-full w-full gap-2.5\"><h1 class=\"text-2xl md:text-3xl lg:text-4xl font-bold\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_hero.templ`, Line: 6, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h1><p class=\"text-md md:text-lg lg:text-xl font-medium text-gray-500\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(subtitle)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_hero.templ`, Line: 9, Col: 13}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func HeroStart() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"pt-1.5 mb-3 flex flex-col items-center justify-center h-full\"><sl-button size=\"large\" hx-target=\"#container\" hx-get=\"/register\" hx-push-url=\"/register\" type=\"button\"><sl-icon slot=\"prefix\" library=\"sonr\" name=\"sonr\"></sl-icon> Create Vault <sl-icon slot=\"suffix\" library=\"sonr\" name=\"arrow-right\"></sl-icon></sl-button></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func HeroSocials() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var5 == nil {
|
||||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"pt-1.5 flex flex-row items-center justify-center h-full gap-3\"><sl-button circle outline href=\"https://sonr.io\"><sl-icon name=\"home\" library=\"sonr\" label=\"Home\"></sl-icon></sl-button> <sl-button circle outline href=\"https://onsonr.dev\"><sl-icon name=\"docs\" library=\"sonr\" label=\"Docs\"></sl-icon></sl-button> <sl-button circle outline href=\"https://github.com/onsonr/sonr\"><sl-icon name=\"social-github\" library=\"sonr\" label=\"Open Source\"></sl-icon></sl-button></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
59
pkg/views/base_layout.templ
Normal file
59
pkg/views/base_layout.templ
Normal file
@@ -0,0 +1,59 @@
|
||||
package views
|
||||
|
||||
templ LayoutContainer() {
|
||||
<div id="container" class="flex fixed inset-0 z-[99] w-screen min-h-screen">
|
||||
<div class="relative flex flex-wrap items-center w-full min-h-full px-4 py-6 sm:px-6 md:px-8">
|
||||
<div class="relative w-full max-w-screen-lg mx-auto">
|
||||
<div class="flex flex-col items-center justify-center min-h-full gap-4">
|
||||
{ children... }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
// Columns is a component that renders a responsive flex container that stacks on mobile
|
||||
templ LayoutColumns() {
|
||||
<div class="flex flex-col h-full w-full gap-4 md:gap-6 md:flex-row md:flex-wrap">
|
||||
{ children... }
|
||||
</div>
|
||||
}
|
||||
|
||||
// Rows is a component that renders a responsive flex container that wraps on mobile
|
||||
templ LayoutRows() {
|
||||
<div class="flex flex-col w-full gap-3 sm:flex-row sm:flex-wrap sm:gap-4">
|
||||
{ children... }
|
||||
</div>
|
||||
}
|
||||
|
||||
templ LayoutSeparator(text string) {
|
||||
<div class="relative py-6">
|
||||
<div class="absolute inset-0 flex items-center"><span class="w-full border-t"></span></div>
|
||||
<div class="relative flex justify-center text-xs uppercase">
|
||||
<span class="px-2 text-neutral-500">{ text }</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
// Layout is a component that renders the general layout of the application
|
||||
templ LayoutView(title string) {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@Head(title, "0.0.11")
|
||||
<body class="flex items-center justify-center h-full lg:p-24 md:16 p-4 no-scrollbar">
|
||||
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-lg gap-y-3">
|
||||
{ children... }
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
func Clsx(attrs ...templ.Attributes) templ.Attributes {
|
||||
merged := templ.Attributes{}
|
||||
for _, attr := range attrs {
|
||||
for k, v := range attr {
|
||||
merged[k] = v
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
222
pkg/views/base_layout_templ.go
Normal file
222
pkg/views/base_layout_templ.go
Normal file
@@ -0,0 +1,222 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.793
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func LayoutContainer() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"container\" class=\"flex fixed inset-0 z-[99] w-screen min-h-screen\"><div class=\"relative flex flex-wrap items-center w-full min-h-full px-4 py-6 sm:px-6 md:px-8\"><div class=\"relative w-full max-w-screen-lg mx-auto\"><div class=\"flex flex-col items-center justify-center min-h-full gap-4\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Columns is a component that renders a responsive flex container that stacks on mobile
|
||||
func LayoutColumns() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var2 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var2 == nil {
|
||||
templ_7745c5c3_Var2 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col h-full w-full gap-4 md:gap-6 md:flex-row md:flex-wrap\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var2.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Rows is a component that renders a responsive flex container that wraps on mobile
|
||||
func LayoutRows() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var3 == nil {
|
||||
templ_7745c5c3_Var3 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col w-full gap-3 sm:flex-row sm:flex-wrap sm:gap-4\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func LayoutSeparator(text string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"relative py-6\"><div class=\"absolute inset-0 flex items-center\"><span class=\"w-full border-t\"></span></div><div class=\"relative flex justify-center text-xs uppercase\"><span class=\"px-2 text-neutral-500\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `vault/views/base_layout.templ`, Line: 33, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// Layout is a component that renders the general layout of the application
|
||||
func LayoutView(title string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var6 == nil {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Head(title, "0.0.11").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<body class=\"flex items-center justify-center h-full lg:p-24 md:16 p-4 no-scrollbar\"><main class=\"flex-row items-center justify-center mx-auto w-fit max-w-screen-lg gap-y-3\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var6.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main></body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func Clsx(attrs ...templ.Attributes) templ.Attributes {
|
||||
merged := templ.Attributes{}
|
||||
for _, attr := range attrs {
|
||||
for k, v := range attr {
|
||||
merged[k] = v
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
14
pkg/views/initial.templ
Normal file
14
pkg/views/initial.templ
Normal file
@@ -0,0 +1,14 @@
|
||||
package views
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
templ InitialView() {
|
||||
@LayoutView("Sonr.ID") {
|
||||
@LayoutContainer() {
|
||||
@HeroTitle("Sonr.ID", "The decentralized identity layer for the web.")
|
||||
@HeroStart()
|
||||
@HeroSocials()
|
||||
}
|
||||
}
|
||||
}
|
||||
94
pkg/views/initial_templ.go
Normal file
94
pkg/views/initial_templ.go
Normal file
@@ -0,0 +1,94 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.793
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import ()
|
||||
|
||||
func InitialView() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = HeroTitle("Sonr.ID", "The decentralized identity layer for the web.").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = HeroStart().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = HeroSocials().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = LayoutContainer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = LayoutView("Sonr.ID").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
26
sqlc.yaml
Normal file
26
sqlc.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "sqlite"
|
||||
queries: "./sink/vault/query.sql"
|
||||
schema: "./sink/vault/schema.sql"
|
||||
gen:
|
||||
go:
|
||||
emit_interface: true
|
||||
emit_json_tags: true
|
||||
package: "motrorm"
|
||||
out: "motrorm"
|
||||
|
||||
- engine: "postgresql"
|
||||
queries: "./sink/highway/query.sql"
|
||||
schema: "./sink/highway/schema.sql"
|
||||
gen:
|
||||
go:
|
||||
emit_all_enum_values: true
|
||||
emit_enum_valid_method: true
|
||||
emit_json_tags: true
|
||||
emit_interface: true
|
||||
emit_result_struct_pointers: true
|
||||
omit_unused_structs: true
|
||||
package: "hwayorm"
|
||||
out: "hwayorm"
|
||||
sql_package: "pgx/v5"
|
||||
33
web/es-client/.eslintrc.cjs
Normal file
33
web/es-client/.eslintrc.cjs
Normal file
@@ -0,0 +1,33 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: ["@typescript-eslint"],
|
||||
extends: [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
/**
|
||||
* Should be last in this array to override other configs
|
||||
* @see https://github.com/prettier/eslint-config-prettier#installation
|
||||
*/
|
||||
"prettier",
|
||||
],
|
||||
rules: {
|
||||
// Remove errors for unused args/vars starting with underscore
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
caughtErrorsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
// Remove errors for intentional empty functions
|
||||
"no-empty-function": "off",
|
||||
"@typescript-eslint/no-empty-function": [
|
||||
"error",
|
||||
{
|
||||
allow: ["private-constructors", "protected-constructors"],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
41
web/es-client/.gitignore
vendored
Normal file
41
web/es-client/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
coverage
|
||||
|
||||
# build
|
||||
dist/
|
||||
|
||||
# production
|
||||
build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
.vscode
|
||||
.tmp
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# local env files
|
||||
.env
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
|
||||
# turbo
|
||||
.turbo
|
||||
.aider*
|
||||
10
web/es-client/.prettierrc.cjs
Normal file
10
web/es-client/.prettierrc.cjs
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @type {import("prettier").Config} */
|
||||
module.exports = {
|
||||
tabWidth: 2,
|
||||
printWidth: 80,
|
||||
singleQuote: false,
|
||||
jsxSingleQuote: false,
|
||||
semi: true,
|
||||
trailingComma: "es5",
|
||||
arrowParens: "always",
|
||||
};
|
||||
337
web/es-client/CHANGELOG.md
Normal file
337
web/es-client/CHANGELOG.md
Normal file
@@ -0,0 +1,337 @@
|
||||
# Changelog
|
||||
|
||||
## `v0.0.71`
|
||||
|
||||
### Features
|
||||
|
||||
- Add optional `label` field to `ConnectedWallet` instances, which contains the user-defined label of the wallet
|
||||
|
||||
### Fixes
|
||||
|
||||
- Handle more wallet errors in the `wrap` function
|
||||
|
||||
## `v0.0.70`
|
||||
|
||||
### Features
|
||||
|
||||
- Add legacy amino type to `MsgSend` model
|
||||
- Add `MsgMigrateContract`, `MsgStoreCode`, `MsgBeginRedelegate`, `MsgDelegate`, `MsgUndelegate`, `MsgWithdrawDelegatorRewards`, `MsgWithdrawValidatorCommission` models
|
||||
- Add ed25519 signature type
|
||||
|
||||
### Fixes
|
||||
|
||||
- Add Keplr default sign options to `WalletConnectV2`
|
||||
|
||||
## `v0.0.69`
|
||||
|
||||
### Chore
|
||||
|
||||
- Pin `@walletconnect/sign-client` dep to v2.8.x to reduce bundle size
|
||||
|
||||
## `v0.0.68`
|
||||
|
||||
### Chore
|
||||
|
||||
- Regenerate `pnpm-lock.yaml` to fix dep issues
|
||||
|
||||
## `v0.0.67`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix `RpcClient`'s `RequestMessage` type error when using a request with an existing `height` field
|
||||
|
||||
## `v0.0.66`
|
||||
|
||||
### Features
|
||||
|
||||
- Add custom `WalletError` class to normalise wallet errors
|
||||
- Add `MsgInstantiateContract` class
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed verification of station mobile signatures
|
||||
|
||||
## `v0.0.65`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed `verifyArbitrary` to verify arbitrary signatures done via Station's new Keplr interface
|
||||
|
||||
## `v0.0.64`
|
||||
|
||||
### Features
|
||||
|
||||
- Added OWallet extension support (*does not support wallet connect yet*)
|
||||
|
||||
## `v0.0.63`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Ignore all errors in retrieving public keys for Station Extension
|
||||
|
||||
## `v0.0.62`
|
||||
|
||||
### Improvements
|
||||
|
||||
- Txs are now broadcasted directly via the user-specified RPC instead of via the wallet (closes <https://github.com/coinhall/@onsonr/es/issues/17>)
|
||||
- Update Station extension to use Keplr's API interface
|
||||
|
||||
## `v0.0.60`
|
||||
|
||||
### Features
|
||||
|
||||
- Parse `EthermintAccount` in `toBaseAccount` util function
|
||||
|
||||
## `v0.0.59`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix Station mobile wallet to not throw errors if pub keys do not exist
|
||||
|
||||
## `v0.0.58`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix Station mobile wallet connect issue when connecting more than 1 chain
|
||||
|
||||
## `v0.0.57`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Allow Terra testnet to work correctly with Station extension
|
||||
|
||||
## `v0.0.56`
|
||||
|
||||
### Features
|
||||
|
||||
- Added Dymension's GAMM protobufs
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Pinned Cosmos SDK protobuf to `v0.47.9`
|
||||
|
||||
## `v0.0.55`
|
||||
|
||||
### Features
|
||||
|
||||
- Added tx signing support for Dymension chain
|
||||
|
||||
## `v0.0.54`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed `MnemonicWallet` to generate Injective signatures correctly
|
||||
|
||||
## `v0.0.53`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed `MnemonicWallet` to resolve Injective address correctly
|
||||
|
||||
## `v0.0.52`
|
||||
|
||||
### Features
|
||||
|
||||
- Added Ninji wallet support to execute txs via Ninji extension on Injective network (*does not support wallet connect yet*)
|
||||
|
||||
## `v0.0.51`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed MetaMask on Injective to work correctly with `MsgExecuteContractCompat` when `funds` are empty
|
||||
|
||||
## `v0.0.50`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed the `verifyArbitrary` function to work correctly for all chains, including Injective which uses a different key algorithm
|
||||
|
||||
## `v0.0.49`
|
||||
|
||||
### Features
|
||||
|
||||
- Added the `verifyArbitrary` helper function (exported by `@onsonr/es/wallet`) to verify signatures signed using `ConnectedWallet.signArbitrary`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed the `recoverPubKeyFromEthSignature` helper function to calculate and use the correct recovery bit when generating the `secp256k1` model
|
||||
|
||||
## `v0.0.48`
|
||||
|
||||
### Features
|
||||
|
||||
- Added Compass wallet support to execute txs via Compass extension on Sei network (*does not support wallet connect yet*)
|
||||
|
||||
## `v0.0.47`
|
||||
|
||||
### Features
|
||||
|
||||
- Added MetaMask wallet support to execute txs via MetaMask extension on Injective network (*does not support wallet connect yet*)
|
||||
|
||||
### Improvements
|
||||
|
||||
- Added `extensionOptions` to `Tx.toSignedProto`
|
||||
|
||||
## `v0.0.46`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed `ConnectedWallet.estimateFee` to properly extract account sequences from errors thrown by Injective RPCs
|
||||
|
||||
## `v0.0.45`
|
||||
|
||||
### Improvements
|
||||
|
||||
- Included `isCW20` option for `simulateAstroportSinglePoolSwap` function to handle swapping from CW20 assets
|
||||
|
||||
## `v0.0.44`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed Leap wallet android deep link to ensure redirect happens correctly
|
||||
- Fixed `toKeplrChainInfo` to return `undefined` for coingecko ID if it is absent
|
||||
|
||||
## `v0.0.43`
|
||||
|
||||
### Improvements
|
||||
|
||||
- Added `timeout_height` parameter when simulating or broadcasting txs
|
||||
- Use sign mode direct (instead of legacy amino) for non-ledger extension wallets and `MnemonicWallet`
|
||||
- Added support for sign mode direct for `WalletConnectV2` (although no mobile wallets support it currently)
|
||||
- Reduced bundle size by combining Keplr-like wallets into the same interface (`examples/solid-vite` reduced from 509kb to 487kb minified)
|
||||
|
||||
## `v0.0.42`
|
||||
|
||||
### Features
|
||||
|
||||
- Added support for Injective chain (both mainnet and testnet)
|
||||
|
||||
## `v0.0.40`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Use `JSON.stringify` on errors thrown by Station Extension to avoid `[object Object]` errors
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Added `Tx.toSignDoc` method to form an unsigned, proto encoded tx ready to be signed by a wallet
|
||||
|
||||
## `v0.0.39`
|
||||
|
||||
### Features
|
||||
|
||||
- Added the optional `height` params to the `FetchClient` to execute queries at a custom block height
|
||||
- Added batching of queries to `FetchClient` (see `examples/batch-query`)
|
||||
|
||||
## `v0.0.38` [breaking change]
|
||||
|
||||
### Features
|
||||
|
||||
- Added `MnemonicWallet` to allow programmatic signing and broadcasting of txs without relying on a 3rd party wallet/signer (see examples directory)
|
||||
- Simplified wallet APIs **[breaking change]**
|
||||
- `getAccount()`: renamed and reworked to `getAuthInfo()`, but consumers are no longer required to call this method to broadcast transactions
|
||||
- `estimateFee()`: second parameter now accepts the `feeMultiplier` directly (still optional) instead of the auth info
|
||||
- `broadcastTx()`: second parameter now accepts the `fee` from the result of `estimateFee()` (no longer optional) instead of the auth info
|
||||
- `broadcastTxSync()`: new function that executes `estimateFee`, `broadcastTx`, and `pollTx` sequentially
|
||||
- Handle account sequence mismatch errors directly in `ConnectedWallet.estimateFee()` by retrying once with the correct sequence
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Removed the various `fromXxxToYyy` encoding/decoding functions within `@onsonr/es/codec` in favour of `@scure/base` **[breaking change]**
|
||||
- The `@scure/base` pkg is re-exported in `@onsonr/es/codec`
|
||||
- Consumers should import the correct encoder or decoder directly from `@onsonr/es/codec`: eg. change `fromHexToUint8Array(...)` to `base16.decode(...)`
|
||||
- Re-exported `@keplr-wallet/types` from `@onsonr/es/registry`
|
||||
|
||||
## `v0.0.35`
|
||||
|
||||
### Features
|
||||
|
||||
- Added the `@onsonr/es/registry` package with the following additions:
|
||||
- APIs to dynamically query for data in Chain Registry
|
||||
- Util function to transform Chain Registry data to Keplr's chain info
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- The `toBaseAccount` utility can now handle all vesting account types
|
||||
|
||||
## `v0.0.34`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Prevent redirecting users to the mobile app when querying for the user's account via WalletConnect (on first connect)
|
||||
|
||||
## `v0.0.33`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Allow memo and fee fields to be set by user for WalletConnect wallets
|
||||
- Fixed Cosmostation WalletConnect to use updated API changes
|
||||
|
||||
## `v0.0.32`
|
||||
|
||||
### Fixes
|
||||
|
||||
- Added missing `memo` field for `MsgIbcTransfer`
|
||||
|
||||
## `v0.0.31`
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Added missing barrel export for `MsgIbcTransfer` model
|
||||
|
||||
## `v0.0.30`
|
||||
|
||||
### Features
|
||||
|
||||
- Added ICS 23 protobufs from [`cosmos/ics23`](https://github.com/cosmos/ics23) to fix `ibc-go` dependency issues
|
||||
|
||||
## `v0.0.29`
|
||||
|
||||
### Features
|
||||
|
||||
- Added IBC protobufs from [`cosmos/ibc-go`](https://github.com/cosmos/ibc-go)
|
||||
- Added `MsgIbcTransfer` model
|
||||
|
||||
## `v0.0.28`
|
||||
|
||||
### Features
|
||||
|
||||
- Updated Station extension to use the new APIs injected into the `window` scope
|
||||
|
||||
## `v0.0.27`
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Changed `lodash` dependency to `lodash-es`
|
||||
|
||||
## `v0.0.26`
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- The `onDisconnect` callback in the `WalletController` class now accepts a function that contains a list of disconnected wallets instead of a list of disconnected chain ID strings
|
||||
|
||||
### Features
|
||||
|
||||
- Added the `onAccountChange` event to the `WalletController` class to allow consumers to detect wallet account changes (works for all wallets except Station via WalletConnect v1)
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Added `lodash` as peer dependency
|
||||
|
||||
## `v0.0.25`
|
||||
|
||||
### Improvements
|
||||
|
||||
- Replaced all `@walletconnect-v1` dependencies with correct legacy libraries at <https://github.com/WalletConnect/walletconnect-legacy>
|
||||
- Added bundle size benchmarks (see `./benchmarks` folder)
|
||||
- Improved docs on installing, polyfills, and benchmarks
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- Changed GPL v3 license to MIT license
|
||||
|
||||
## `v0.0.24`
|
||||
|
||||
### Features
|
||||
|
||||
- First public release
|
||||
149
web/es-client/CONTRIBUTING.md
Normal file
149
web/es-client/CONTRIBUTING.md
Normal file
@@ -0,0 +1,149 @@
|
||||
<!-- omit in toc -->
|
||||
# Contributing
|
||||
|
||||
- [Directory Structure](#directory-structure)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Installing](#installing)
|
||||
- [Adding Dependencies](#adding-dependencies)
|
||||
- [Developing](#developing)
|
||||
- [Building](#building)
|
||||
- [Publishing](#publishing)
|
||||
- [Testing \& CI](#testing--ci)
|
||||
- [Design Decisions](#design-decisions)
|
||||
- [Minimise Bundle Size](#minimise-bundle-size)
|
||||
- [Minimise Side Effects](#minimise-side-effects)
|
||||
- [No Minifying](#no-minifying)
|
||||
- [No Bundling](#no-bundling)
|
||||
- [No Barrel Files](#no-barrel-files)
|
||||
- [Full ESM Compatibility](#full-esm-compatibility)
|
||||
|
||||
## Directory Structure
|
||||
|
||||
This is a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), written in TypeScript and managed by [pnpm](https://pnpm.io).
|
||||
|
||||
- [`/benchmarks`](./benchmarks) - contains bundle size comparisons between `@onsonr/es` and other packages like Cosmos Kit
|
||||
- [`/examples`](./examples) - contains example applications that consume from the `@onsonr/es` package
|
||||
- [`/scripts`](./scripts) - contains internal scripts for use in this monorepo
|
||||
- [`/src`](./src) - contains the source code for the `@onsonr/es` package
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installing
|
||||
|
||||
Firstly, install all dependencies by running:
|
||||
|
||||
```sh
|
||||
pnpm i
|
||||
```
|
||||
|
||||
### Adding Dependencies
|
||||
|
||||
Dependencies that are not `devDependencies` should be added as `peerDependencies`. See ["No Bundling"](#no-bundling) for more information.
|
||||
|
||||
To add a new dev dependency, run:
|
||||
|
||||
```sh
|
||||
pnpm add -D [dependency_name]
|
||||
```
|
||||
|
||||
To add a new peer dependency (note that it is also automatically added as a dev dependency), run:
|
||||
|
||||
```sh
|
||||
pnpm add --save-peer [dependency_name]
|
||||
```
|
||||
|
||||
### Developing
|
||||
|
||||
All examples in the `/examples` directory are independent packages that contain a symlink to the root `@onsonr/es` package. This allows us to develop the `@onsonr/es` package and test it in the examples at the same time.
|
||||
|
||||
Firstly, to watch the `@onsonr/es` package and rebuild on changes, run the following in the root of the project:
|
||||
|
||||
```sh
|
||||
# Run `pnpm build` first if this is your first time running this command
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Then, in a separate terminal, start the example app:
|
||||
|
||||
```sh
|
||||
cd examples/solid-vite
|
||||
pnpm install # If necessary
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
### Building
|
||||
|
||||
All generated files should be committed to the repository. The convention is to prefix the commands with `gen:`. If there is a need to regenerate the files, run:
|
||||
|
||||
```sh
|
||||
pnpm gen:protobufs
|
||||
pnpm gen:registry
|
||||
```
|
||||
|
||||
To build the package to the `dist` folder, run:
|
||||
|
||||
```sh
|
||||
pnpm build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
To bump the package version prior to publishing, run:
|
||||
|
||||
```sh
|
||||
# To bump the patch number (most publishes should use this)
|
||||
pnpm version patch --no-git-tag-version
|
||||
|
||||
# To bump the prerelease number (if and only if a RC version is required)
|
||||
pnpm version prerelease --no-git-tag-version --preid=rc
|
||||
```
|
||||
|
||||
To publish the package to NPM, run:
|
||||
|
||||
```sh
|
||||
pnpm publish
|
||||
```
|
||||
|
||||
### Testing & CI
|
||||
|
||||
To run all unit tests, run:
|
||||
|
||||
```sh
|
||||
pnpm test
|
||||
```
|
||||
|
||||
To emulate the full test suite (linting, typechecking, unit tests) that is automatically run in CI, run:
|
||||
|
||||
```sh
|
||||
pnpm test:suite
|
||||
```
|
||||
|
||||
## Design Decisions
|
||||
|
||||
If you intend to contribute to this monorepo, please read this section carefully and adhere to the guidelines (which are listed most important first).
|
||||
|
||||
### Minimise Bundle Size
|
||||
|
||||
This library's primary target users are web apps, built using a suitable bundler, running on modern browsers. As such, we should ensure that tree shaking works as well as possible, and use native browser APIs instead of relying on external dependencies/polyfills.
|
||||
|
||||
### Minimise Side Effects
|
||||
|
||||
Modules must not contain [side effects](https://blog.saeloun.com/2022/11/24/tree-shaking-in-webpack-5/#what-are-sideeffects) where possible. This allows us to specify the `sideEffects: false` flag in `package.json`, which allows bundlers to tree shake more effectively.
|
||||
|
||||
### No Minifying
|
||||
|
||||
All TypeScript code is *only transpiled*, not minified. Minifying changes the code structure and may [cause tree shaking issues for bundlers](https://stackoverflow.com/questions/71275009/bundling-and-publishing-an-npm-library-is-it-common-to-resolve-all-dependencies). Assuming that most consumers worried about bundle size will already be using a bundler, it is better to leave the minifying to their bundler.
|
||||
|
||||
### No Bundling
|
||||
|
||||
Dependencies must not be bundled but should instead be installed as [`peerDependencies`](https://blog.bitsrc.io/understanding-peer-dependencies-in-javascript-dbdb4ab5a7be?gi=c8dc907bb6cf). This allows consumers to use a different version of the dependency if need be, and [shifts dependency resolution and bundling](https://stackoverflow.com/questions/71275009/bundling-and-publishing-an-npm-library-is-it-common-to-resolve-all-dependencies) to the consumer's package manager and bundler. For the latter, it allows consumers to avoid having multiple copies of the same dependency in their bundle.
|
||||
|
||||
### No Barrel Files
|
||||
|
||||
There should only be one [barrel file](https://basarat.gitbook.io/typescript/main-1/barrel) located in the immediate subdirectories in the `src` directory, which defines the public API of the library. No other barrel files should exist as it [creates more issue than it solves](https://steven-lemon182.medium.com/are-typescript-barrel-files-an-anti-pattern-72a713004250), like making it [harder for bundlers to tree shake](https://github.com/vercel/next.js/issues/12557).
|
||||
|
||||
### Full ESM Compatibility
|
||||
|
||||
Full ESM compatibility of the emitted JavaScript files is required so that consumers can still use this library *without having to use a bundler* (even if they are not our primary target users). Most importantly, all imports and exports must use a [fully qualified relative path](https://nodejs.org/api/esm.html#mandatory-file-extensions) (ie. starts with `.` and ends with `.js`).
|
||||
|
||||
We achieve this by using `tsc-alias` on the emitted JavaScript files. It transforms the `path` alias configured in `tsconfig.json` to the relative path and adds the `.js` extensions to all imports and exports. See [`configs/tsconfig`](./configs/tsconfig) for the up to date configurations.
|
||||
21
web/es-client/LICENSE
Normal file
21
web/es-client/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Coinhall
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
183
web/es-client/README.md
Normal file
183
web/es-client/README.md
Normal file
@@ -0,0 +1,183 @@
|
||||
!-- omit in toc -->
|
||||
|
||||
# `@onsonr/es`
|
||||
|
||||
A tree-shakeable, framework agnostic, [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) alternative of [CosmJS](https://github.com/cosmos/cosmjs) and [Cosmos Kit](https://cosmoskit.com) (**generate bundles up to 10x smaller than Cosmos Kit**).
|
||||
|
||||
- [Features](#features)
|
||||
- [Installing](#installing)
|
||||
- [Using with TypeScript](#using-with-typescript)
|
||||
- [Using with Vite](#using-with-vite)
|
||||
- [Using Station wallet](#using-station-wallet)
|
||||
- [Examples](#examples)
|
||||
- [Modules](#modules)
|
||||
- [`@onsonr/es/client`](#@onsonr/esclient)
|
||||
- [`@onsonr/es/codec`](#@onsonr/escodec)
|
||||
- [`@onsonr/es/protobufs`](#@onsonr/esprotobufs)
|
||||
- [`@onsonr/es/registry`](#@onsonr/esregistry)
|
||||
- [`@onsonr/es/wallet`](#@onsonr/eswallet)
|
||||
- [Benchmarks](#benchmarks)
|
||||
- [Results](#results)
|
||||
- [See More](#see-more)
|
||||
|
||||
## Features
|
||||
|
||||
> [!WARNING]
|
||||
> **This is still a work in progress**. Before `v1` is reached, the API is not guaranteed to be semver compatible - patch releases may break everything. See the [changelog](./CHANGELOG.md) for notable changes.
|
||||
|
||||
- **Fully tree-shakeable**: import and bundle only the modules you need
|
||||
- **Framework agnostic**: integrate with any web framework (React, Vue, Svelte, Solid, etc.)
|
||||
- **Lightweight and minimal**: 153 KB gzipped to connect a React app to Keplr via browser extension or WalletConnect, 10x smaller than Cosmos Kit V2 (see [benchmarks](#benchmarks))
|
||||
- **Uses modern web APIs**: no dependencies on Node.js and minimal dependencies on third-party libraries where possible
|
||||
- **Supports modern bundlers**: works with Vite, SWC, Rollup, etc.
|
||||
- **Fully typed**: written in TypeScript and ships with type definitions
|
||||
|
||||
## Installing
|
||||
|
||||
For Cosmos SDK v0.47 and below:
|
||||
|
||||
```sh
|
||||
npm install @onsonr/es
|
||||
|
||||
pnpm add @onsonr/es
|
||||
|
||||
yarn add @onsonr/es
|
||||
```
|
||||
|
||||
For Cosmos SDK v0.50, install using the `sdk50` tag:
|
||||
|
||||
```sh
|
||||
npm install @onsonr/es@sdk50
|
||||
|
||||
pnpm add @onsonr/es@sdk50
|
||||
|
||||
yarn add @onsonr/es@sdk50
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The bump from v0.47 to v0.50 introduces significant breaking changes and is not recommended to be used unless necessary. To reduce the impact on consumers, the `main` branch and the published package on npm with the `latest` tag will continue to target v0.47 until the majority of live chains have migrated to v0.50.
|
||||
>
|
||||
> The [`parallel/sdk50`](https://github.com/coinhall/@onsonr/es/tree/parallel/sdk50) branch targetting v0.50 will be developed and maintained in parallel with the `main` branch, where the same patch version number should have feature parity (eg. `@onsonr/es@0.0.69` should have the same features as `@onsonr/es@0.0.69-sdk50.0`).
|
||||
|
||||
### Using with TypeScript
|
||||
|
||||
This library only exports ES modules. To ensure imports from this library work correctly, the following configuration is required in `tsconfig.json`:
|
||||
|
||||
```ts
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "bundler", // recommended if using modern bundlers
|
||||
// or "node16"
|
||||
// or "nodenext"
|
||||
// but NOT "node"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Using with Vite
|
||||
|
||||
If you are using Vite, the following configuration is required in `vite.config.ts`:
|
||||
|
||||
```ts
|
||||
export default defineConfig({
|
||||
define: {
|
||||
global: "window",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
> This can be removed once support for WalletConnect v1 is no longer required.
|
||||
|
||||
### Using Station wallet
|
||||
|
||||
The Station wallet currently relies on WalletConnect v1. If you want to import and use `StationController`, a polyfill for `Buffer` is required:
|
||||
|
||||
```ts
|
||||
// First, install the buffer package
|
||||
npm install buffer
|
||||
|
||||
// Then, create a new file 'polyfill.ts'
|
||||
import { Buffer } from "buffer";
|
||||
(window as any).Buffer = Buffer;
|
||||
|
||||
// Finally, import the above file in your entry file
|
||||
import "./polyfill";
|
||||
```
|
||||
|
||||
See [`examples/solid-vite`](./examples/solid-vite) for a working example.
|
||||
|
||||
> This can be removed once support for WalletConnect v1 is no longer required.
|
||||
|
||||
## Examples
|
||||
|
||||
Docs do not exist yet - see the [`examples`](./examples) folder for various working examples:
|
||||
|
||||
1. [How do I connect to third party wallets via browser extension or WalletConnect? How do I create, sign, and broadcast transactions?](./examples/solid-vite)
|
||||
2. [How do I programmatically sign and broadcast transactions without relying on a third party wallet?](./examples/mnemonic-wallet)
|
||||
3. [How do I verify signatures signed using the `signArbitrary` function?](./examples/verify-signatures)
|
||||
4. [How do I batch queries to the blockchain?](./examples/batch-query)
|
||||
|
||||
## Modules
|
||||
|
||||
This package is split into multiple subdirectories, with each subdirectory having their own set of functionalities. The root directory does not contain any exports, and all exports are exported from the subdirectories. Thus, imports must be done by referencing the subdirectories (ie. `import { ... } from "@onsonr/es/client"`).
|
||||
|
||||
### `@onsonr/es/client`
|
||||
|
||||
This directory contains models and helper functions to interact with Cosmos SDK via the [CometBFT RPC](https://docs.cosmos.network/v0.50/core/grpc_rest#cometbft-rpc).
|
||||
|
||||
### `@onsonr/es/codec`
|
||||
|
||||
This directory contains various encoding and decoding functions that relies solely on [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) and has no dependencies on Node.js. For modern browsers and Node v16+, this should work out of the box.
|
||||
|
||||
### `@onsonr/es/protobufs`
|
||||
|
||||
This directory contains the auto-generated code for various Cosmos SDK based protobufs. See `scripts/gen-protobufs.mjs` for the script that generates the code.
|
||||
|
||||
### `@onsonr/es/registry`
|
||||
|
||||
This directory contains various APIs, data, and types needed for wallet interactions (ie. Keplr). Some types are auto-generated, see `scripts/gen-registry.mjs` for the script that generates the types.
|
||||
|
||||
### `@onsonr/es/wallet`
|
||||
|
||||
This directory is a [Cosmos Kit](https://cosmoskit.com) alternative to interact with wallets across all Cosmos SDK based blockchains. See [`examples/solid-vite`](./examples/solid-vite) for a working example.
|
||||
|
||||
**Wallets supported**:
|
||||
|
||||
- [Station](https://docs.terra.money/learn/station/)
|
||||
- [Keplr](https://www.keplr.app/)
|
||||
- [Leap](https://www.leapwallet.io/)
|
||||
- [Cosmostation](https://wallet.cosmostation.io/)
|
||||
- [OWallet](https://owallet.dev/)
|
||||
- [Compass](https://compasswallet.io/) (for Sei only)
|
||||
- [MetaMask](https://metamask.io/) (for Injective only)
|
||||
- [Ninji](https://ninji.xyz/) (for Injective only)
|
||||
|
||||
**Features**:
|
||||
|
||||
- Supports both browser extension (desktop) and WalletConnect (mobile)
|
||||
- Unified interface for connecting, signing, broadcasting, and event handling
|
||||
- Signing of arbitrary messages (for wallets that support it)
|
||||
- Simultaneous connections to multiple WalletConnect wallets
|
||||
|
||||
## Benchmarks
|
||||
|
||||
See the [`benchmarks`](./benchmarks) folder, where the bundle size of SonrES is compared against Cosmos Kit. The following are adhered to:
|
||||
|
||||
- Apps should only contain the minimal functionality of connecting to Osmosis via Keplr using both the browser extension and WalletConnect wallets
|
||||
- Apps should be built using React 18 (as Cosmos Kit has a [hard dependency](https://docs.cosmoskit.com/get-started)) and Vite
|
||||
- Use the total sum of all generated bundles as reported by Vite after running the `vite build` command, including the size of all other dependencies like React/HTML/CSS/etc. (note: this is crude and not 100% accurate, but is the simplest method)
|
||||
|
||||
### Results
|
||||
|
||||
> Last updated: 4th May 2024
|
||||
|
||||
| Package | Minified | Gzipped |
|
||||
| ------------- | -------- | ------- |
|
||||
| SonrES | 553 KB | 153 KB |
|
||||
| Cosmos Kit v1 | 6010 KB | 1399 KB |
|
||||
| Cosmos Kit v2 | 6780 KB | 1556 KB |
|
||||
|
||||
## See More
|
||||
|
||||
- [Changelog](./CHANGELOG.md) - for notable changes
|
||||
- [Contributing](./CONTRIBUTING.md) - if you want to contribute to this project
|
||||
24
web/es-client/benchmarks/cosmes-react/.gitignore
vendored
Normal file
24
web/es-client/benchmarks/cosmes-react/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
13
web/es-client/benchmarks/cosmes-react/index.html
Normal file
13
web/es-client/benchmarks/cosmes-react/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@onsonr/es Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
26
web/es-client/benchmarks/cosmes-react/package.json
Normal file
26
web/es-client/benchmarks/cosmes-react/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@onsonr/es-react",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@onsonr/es": "link:../..",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.37",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.24",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"typescript": "^5.0.4",
|
||||
"vite": "^4.3.9"
|
||||
}
|
||||
}
|
||||
1345
web/es-client/benchmarks/cosmes-react/pnpm-lock.yaml
generated
Normal file
1345
web/es-client/benchmarks/cosmes-react/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
web/es-client/benchmarks/cosmes-react/postcss.config.js
Normal file
6
web/es-client/benchmarks/cosmes-react/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
1
web/es-client/benchmarks/cosmes-react/public/vite.svg
Normal file
1
web/es-client/benchmarks/cosmes-react/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
62
web/es-client/benchmarks/cosmes-react/src/App.tsx
Normal file
62
web/es-client/benchmarks/cosmes-react/src/App.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import { ConnectedWallet, KeplrController, WalletType } from "@onsonr/es/wallet";
|
||||
import { useState } from "react";
|
||||
|
||||
const WC_PROJECT_ID = "2b7d5a2da89dd74fed821d184acabf95";
|
||||
const OSMOSIS_CHAIN_INFO = {
|
||||
chainId: "osmosis-1",
|
||||
rpc: "https://rpc.osmosis.zone",
|
||||
gasPrice: { amount: "0.0025", denom: "uosmo" },
|
||||
} as const;
|
||||
|
||||
const Keplr = new KeplrController(WC_PROJECT_ID);
|
||||
|
||||
export function App() {
|
||||
const [wallet, setWallet] = useState<ConnectedWallet | null>(null);
|
||||
|
||||
async function onConnectClick(type: WalletType) {
|
||||
try {
|
||||
const res = await Keplr.connect(type, [OSMOSIS_CHAIN_INFO]);
|
||||
setWallet(res.get("osmosis-1") ?? null);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
alert((err as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDisconnectClick() {
|
||||
Keplr.disconnect(["osmosis-1"]);
|
||||
setWallet(null);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-900 flex flex-col justify-center items-center text-gray-100 space-y-2">
|
||||
<div className="font-mono text-xs text-center">
|
||||
Address: {wallet?.address ?? "-"}
|
||||
</div>
|
||||
|
||||
{wallet ? (
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-red-600 text-red-50"
|
||||
onClick={onDisconnectClick}
|
||||
>
|
||||
Disconnect from Keplr
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-green-600 text-green-50"
|
||||
onClick={() => onConnectClick(WalletType.EXTENSION)}
|
||||
>
|
||||
Connect Keplr Extension
|
||||
</button>
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-green-600 text-green-50"
|
||||
onClick={() => onConnectClick(WalletType.WALLETCONNECT)}
|
||||
>
|
||||
Connect Keplr WalletConnect
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
3
web/es-client/benchmarks/cosmes-react/src/index.css
Normal file
3
web/es-client/benchmarks/cosmes-react/src/index.css
Normal file
@@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
12
web/es-client/benchmarks/cosmes-react/src/main.tsx
Normal file
12
web/es-client/benchmarks/cosmes-react/src/main.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
||||
import { App } from "./App.tsx";
|
||||
|
||||
import "./index.css";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
1
web/es-client/benchmarks/cosmes-react/src/vite-env.d.ts
vendored
Normal file
1
web/es-client/benchmarks/cosmes-react/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
8
web/es-client/benchmarks/cosmes-react/tailwind.config.js
Normal file
8
web/es-client/benchmarks/cosmes-react/tailwind.config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
25
web/es-client/benchmarks/cosmes-react/tsconfig.json
Normal file
25
web/es-client/benchmarks/cosmes-react/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
10
web/es-client/benchmarks/cosmes-react/tsconfig.node.json
Normal file
10
web/es-client/benchmarks/cosmes-react/tsconfig.node.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
10
web/es-client/benchmarks/cosmes-react/vite.config.ts
Normal file
10
web/es-client/benchmarks/cosmes-react/vite.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
define: {
|
||||
global: "window",
|
||||
},
|
||||
});
|
||||
24
web/es-client/benchmarks/cosmoskit-v1-react/.gitignore
vendored
Normal file
24
web/es-client/benchmarks/cosmoskit-v1-react/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
13
web/es-client/benchmarks/cosmoskit-v1-react/index.html
Normal file
13
web/es-client/benchmarks/cosmoskit-v1-react/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CosmosKit Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
30
web/es-client/benchmarks/cosmoskit-v1-react/package.json
Normal file
30
web/es-client/benchmarks/cosmoskit-v1-react/package.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "cosmoskit-react",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmos-kit/core": "1.7.1-beta.4",
|
||||
"@cosmos-kit/keplr": "^0.33.41",
|
||||
"@cosmos-kit/react": "^1.3.34",
|
||||
"buffer": "^6.0.3",
|
||||
"chain-registry": "^1.20.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.37",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.24",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"typescript": "^5.0.4",
|
||||
"vite": "^4.3.9"
|
||||
}
|
||||
}
|
||||
4874
web/es-client/benchmarks/cosmoskit-v1-react/pnpm-lock.yaml
generated
Normal file
4874
web/es-client/benchmarks/cosmoskit-v1-react/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
30
web/es-client/benchmarks/cosmoskit-v1-react/src/App.tsx
Normal file
30
web/es-client/benchmarks/cosmoskit-v1-react/src/App.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useChain } from "@cosmos-kit/react";
|
||||
|
||||
export function App() {
|
||||
const { connect, disconnect, address, isWalletConnected } =
|
||||
useChain("osmosis");
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-900 flex flex-col justify-center items-center text-gray-100 space-y-2">
|
||||
<div className="font-mono text-xs text-center">
|
||||
Address: {address || "-"}
|
||||
</div>
|
||||
|
||||
{isWalletConnected ? (
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-red-600 text-red-50"
|
||||
onClick={disconnect}
|
||||
>
|
||||
Disconnect Wallet
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-green-600 text-green-50"
|
||||
onClick={connect}
|
||||
>
|
||||
Connect Wallet
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
31
web/es-client/benchmarks/cosmoskit-v1-react/src/main.tsx
Normal file
31
web/es-client/benchmarks/cosmoskit-v1-react/src/main.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import "./polyfill.ts";
|
||||
|
||||
import { wallets } from "@cosmos-kit/keplr";
|
||||
import { ChainProvider } from "@cosmos-kit/react";
|
||||
import { assets, chains } from "chain-registry";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
||||
import { App } from "./App.tsx";
|
||||
|
||||
import "./index.css";
|
||||
|
||||
const WC_PROJECT_ID = "2b7d5a2da89dd74fed821d184acabf95";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<ChainProvider
|
||||
chains={chains} // supported chains
|
||||
assetLists={assets} // supported asset lists
|
||||
wallets={wallets} // supported wallets
|
||||
wrappedWithChakra={true}
|
||||
walletConnectOptions={{
|
||||
signClient: {
|
||||
projectId: WC_PROJECT_ID,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<App />
|
||||
</ChainProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Buffer } from "buffer";
|
||||
(window as any).Buffer = Buffer;
|
||||
1
web/es-client/benchmarks/cosmoskit-v1-react/src/vite-env.d.ts
vendored
Normal file
1
web/es-client/benchmarks/cosmoskit-v1-react/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
@@ -0,0 +1,8 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
25
web/es-client/benchmarks/cosmoskit-v1-react/tsconfig.json
Normal file
25
web/es-client/benchmarks/cosmoskit-v1-react/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
10
web/es-client/benchmarks/cosmoskit-v1-react/vite.config.ts
Normal file
10
web/es-client/benchmarks/cosmoskit-v1-react/vite.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
define: {
|
||||
global: "window",
|
||||
},
|
||||
});
|
||||
24
web/es-client/benchmarks/cosmoskit-v2-react/.gitignore
vendored
Normal file
24
web/es-client/benchmarks/cosmoskit-v2-react/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
13
web/es-client/benchmarks/cosmoskit-v2-react/index.html
Normal file
13
web/es-client/benchmarks/cosmoskit-v2-react/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CosmosKit V2 Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
31
web/es-client/benchmarks/cosmoskit-v2-react/package.json
Normal file
31
web/es-client/benchmarks/cosmoskit-v2-react/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "cosmoskit-react",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmos-kit/core": "^2.9.2",
|
||||
"@cosmos-kit/keplr": "^2.7.2",
|
||||
"@cosmos-kit/react": "^2.11.2",
|
||||
"@interchain-ui/react": "^1.23.11",
|
||||
"buffer": "^6.0.3",
|
||||
"chain-registry": "^1.20.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.37",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.24",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"typescript": "^5.0.4",
|
||||
"vite": "^4.3.9"
|
||||
}
|
||||
}
|
||||
5228
web/es-client/benchmarks/cosmoskit-v2-react/pnpm-lock.yaml
generated
Normal file
5228
web/es-client/benchmarks/cosmoskit-v2-react/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
30
web/es-client/benchmarks/cosmoskit-v2-react/src/App.tsx
Normal file
30
web/es-client/benchmarks/cosmoskit-v2-react/src/App.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useChain } from "@cosmos-kit/react";
|
||||
|
||||
export function App() {
|
||||
const { connect, disconnect, address, isWalletConnected } =
|
||||
useChain("osmosis");
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-900 flex flex-col justify-center items-center text-gray-100 space-y-2">
|
||||
<div className="font-mono text-xs text-center">
|
||||
Address: {address || "-"}
|
||||
</div>
|
||||
|
||||
{isWalletConnected ? (
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-red-600 text-red-50"
|
||||
onClick={() => disconnect()}
|
||||
>
|
||||
Disconnect Wallet
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="py-1 px-3 rounded bg-green-600 text-green-50"
|
||||
onClick={connect}
|
||||
>
|
||||
Connect Wallet
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
31
web/es-client/benchmarks/cosmoskit-v2-react/src/main.tsx
Normal file
31
web/es-client/benchmarks/cosmoskit-v2-react/src/main.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import "./polyfill.ts";
|
||||
|
||||
import { wallets } from "@cosmos-kit/keplr";
|
||||
import { ChainProvider } from "@cosmos-kit/react";
|
||||
import { assets, chains } from "chain-registry";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
||||
import { App } from "./App.tsx";
|
||||
|
||||
import "@interchain-ui/react/styles";
|
||||
import "./index.css";
|
||||
|
||||
const WC_PROJECT_ID = "2b7d5a2da89dd74fed821d184acabf95";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<ChainProvider
|
||||
chains={chains} // supported chains
|
||||
assetLists={assets} // supported asset lists
|
||||
wallets={wallets} // supported wallets
|
||||
walletConnectOptions={{
|
||||
signClient: {
|
||||
projectId: WC_PROJECT_ID,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<App />
|
||||
</ChainProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Buffer } from "buffer";
|
||||
(window as any).Buffer = Buffer;
|
||||
1
web/es-client/benchmarks/cosmoskit-v2-react/src/vite-env.d.ts
vendored
Normal file
1
web/es-client/benchmarks/cosmoskit-v2-react/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
@@ -0,0 +1,8 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
25
web/es-client/benchmarks/cosmoskit-v2-react/tsconfig.json
Normal file
25
web/es-client/benchmarks/cosmoskit-v2-react/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
10
web/es-client/benchmarks/cosmoskit-v2-react/vite.config.ts
Normal file
10
web/es-client/benchmarks/cosmoskit-v2-react/vite.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
define: {
|
||||
global: "window",
|
||||
},
|
||||
});
|
||||
10
web/es-client/buf.gen.yaml
Normal file
10
web/es-client/buf.gen.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
# see: https://docs.buf.build/configuration/v1/buf-gen-yaml
|
||||
version: v1
|
||||
plugins:
|
||||
- plugin: es
|
||||
opt: target=ts
|
||||
out: .
|
||||
- plugin: @onsonr/es
|
||||
path: ./scripts/protoc-gen-@onsonr/es.mjs
|
||||
opt: target=ts
|
||||
out: .
|
||||
2
web/es-client/buf.lock
Normal file
2
web/es-client/buf.lock
Normal file
@@ -0,0 +1,2 @@
|
||||
# Generated by buf. DO NOT EDIT.
|
||||
version: v1
|
||||
20
web/es-client/devbox.json
Normal file
20
web/es-client/devbox.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.1/.schema/devbox.schema.json",
|
||||
"packages": [
|
||||
"pnpm@latest"
|
||||
],
|
||||
"shell": {
|
||||
"init_hook": [
|
||||
"pnpm install"
|
||||
],
|
||||
"scripts": {
|
||||
"build": [
|
||||
"pnpm run gen:protobufs",
|
||||
"pnpm run build"
|
||||
],
|
||||
"publish": [
|
||||
"pnpm publish"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
53
web/es-client/devbox.lock
Normal file
53
web/es-client/devbox.lock
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"lockfile_version": "1",
|
||||
"packages": {
|
||||
"pnpm@latest": {
|
||||
"last_modified": "2024-09-13T05:52:00Z",
|
||||
"resolved": "github:NixOS/nixpkgs/673d99f1406cb09b8eb6feab4743ebdf70046557#pnpm",
|
||||
"source": "devbox-search",
|
||||
"version": "9.10.0",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/78jk4n2nn48f19cincpzk0fk1ylnhfw1-pnpm-9.10.0",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/78jk4n2nn48f19cincpzk0fk1ylnhfw1-pnpm-9.10.0"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/sgkja64j6077yla4wm0f1zck60imxxv6-pnpm-9.10.0",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/sgkja64j6077yla4wm0f1zck60imxxv6-pnpm-9.10.0"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/zw1lnwjig1anr1gjkp5ps5g0pd03hxmn-pnpm-9.10.0",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/zw1lnwjig1anr1gjkp5ps5g0pd03hxmn-pnpm-9.10.0"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/8zlqhgw5hbakbk2850wvky9x2vqbsqyw-pnpm-9.10.0",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/8zlqhgw5hbakbk2850wvky9x2vqbsqyw-pnpm-9.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
web/es-client/examples/batch-query/package.json
Normal file
16
web/es-client/examples/batch-query/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@onsonr/es/batch-query",
|
||||
"private": true,
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"start": "tsx src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"sonr-es": "link:../.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.2.0",
|
||||
"tsx": "^3.12.7",
|
||||
"typescript": "^5.0.4"
|
||||
}
|
||||
}
|
||||
312
web/es-client/examples/batch-query/pnpm-lock.yaml
generated
Normal file
312
web/es-client/examples/batch-query/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,312 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
@onsonr/es:
|
||||
specifier: link:../..
|
||||
version: link:../..
|
||||
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^20.2.0
|
||||
version: 20.8.6
|
||||
tsx:
|
||||
specifier: ^3.12.7
|
||||
version: 3.13.0
|
||||
typescript:
|
||||
specifier: ^5.0.4
|
||||
version: 5.2.2
|
||||
|
||||
packages:
|
||||
|
||||
/@esbuild/android-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm@0.18.20:
|
||||
resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-x64@0.18.20:
|
||||
resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-x64@0.18.20:
|
||||
resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-x64@0.18.20:
|
||||
resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm@0.18.20:
|
||||
resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ia32@0.18.20:
|
||||
resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-loong64@0.18.20:
|
||||
resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-mips64el@0.18.20:
|
||||
resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ppc64@0.18.20:
|
||||
resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-riscv64@0.18.20:
|
||||
resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-s390x@0.18.20:
|
||||
resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-x64@0.18.20:
|
||||
resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/netbsd-x64@0.18.20:
|
||||
resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/openbsd-x64@0.18.20:
|
||||
resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/sunos-x64@0.18.20:
|
||||
resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-ia32@0.18.20:
|
||||
resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-x64@0.18.20:
|
||||
resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@types/node@20.8.6:
|
||||
resolution: {integrity: sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==}
|
||||
dependencies:
|
||||
undici-types: 5.25.3
|
||||
dev: true
|
||||
|
||||
/buffer-from@1.1.2:
|
||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||
dev: true
|
||||
|
||||
/esbuild@0.18.20:
|
||||
resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==}
|
||||
engines: {node: '>=12'}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
optionalDependencies:
|
||||
'@esbuild/android-arm': 0.18.20
|
||||
'@esbuild/android-arm64': 0.18.20
|
||||
'@esbuild/android-x64': 0.18.20
|
||||
'@esbuild/darwin-arm64': 0.18.20
|
||||
'@esbuild/darwin-x64': 0.18.20
|
||||
'@esbuild/freebsd-arm64': 0.18.20
|
||||
'@esbuild/freebsd-x64': 0.18.20
|
||||
'@esbuild/linux-arm': 0.18.20
|
||||
'@esbuild/linux-arm64': 0.18.20
|
||||
'@esbuild/linux-ia32': 0.18.20
|
||||
'@esbuild/linux-loong64': 0.18.20
|
||||
'@esbuild/linux-mips64el': 0.18.20
|
||||
'@esbuild/linux-ppc64': 0.18.20
|
||||
'@esbuild/linux-riscv64': 0.18.20
|
||||
'@esbuild/linux-s390x': 0.18.20
|
||||
'@esbuild/linux-x64': 0.18.20
|
||||
'@esbuild/netbsd-x64': 0.18.20
|
||||
'@esbuild/openbsd-x64': 0.18.20
|
||||
'@esbuild/sunos-x64': 0.18.20
|
||||
'@esbuild/win32-arm64': 0.18.20
|
||||
'@esbuild/win32-ia32': 0.18.20
|
||||
'@esbuild/win32-x64': 0.18.20
|
||||
dev: true
|
||||
|
||||
/fsevents@2.3.3:
|
||||
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/get-tsconfig@4.7.2:
|
||||
resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==}
|
||||
dependencies:
|
||||
resolve-pkg-maps: 1.0.0
|
||||
dev: true
|
||||
|
||||
/resolve-pkg-maps@1.0.0:
|
||||
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
|
||||
dev: true
|
||||
|
||||
/source-map-support@0.5.21:
|
||||
resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
|
||||
dependencies:
|
||||
buffer-from: 1.1.2
|
||||
source-map: 0.6.1
|
||||
dev: true
|
||||
|
||||
/source-map@0.6.1:
|
||||
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/tsx@3.13.0:
|
||||
resolution: {integrity: sha512-rjmRpTu3as/5fjNq/kOkOtihgLxuIz6pbKdj9xwP4J5jOLkBxw/rjN5ANw+KyrrOXV5uB7HC8+SrrSJxT65y+A==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
esbuild: 0.18.20
|
||||
get-tsconfig: 4.7.2
|
||||
source-map-support: 0.5.21
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
dev: true
|
||||
|
||||
/typescript@5.2.2:
|
||||
resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/undici-types@5.25.3:
|
||||
resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==}
|
||||
dev: true
|
||||
55
web/es-client/examples/batch-query/src/index.ts
Normal file
55
web/es-client/examples/batch-query/src/index.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { RpcClient, toBaseAccount } from "sonr-es/client";
|
||||
import {
|
||||
CosmosAuthV1beta1QueryAccountService as QueryAccountService,
|
||||
CosmosBankV1beta1QueryAllBalancesService as QueryAllBalancesService,
|
||||
} from "sonr-es/protobufs";
|
||||
|
||||
RpcClient.newBatchQuery("https://phoenix-rpc.terra.dev")
|
||||
.add(
|
||||
QueryAllBalancesService,
|
||||
{
|
||||
address:
|
||||
"terra1fd68ah02gr2y8ze7tm9te7m70zlmc7vjyyhs6xlhsdmqqcjud4dql4wpxr",
|
||||
height: 7_500_000, // this will produce errors if the full node does not have the block
|
||||
},
|
||||
(err, res) =>
|
||||
err
|
||||
? console.log("[1] QUERY ERROR:", err)
|
||||
: console.log("[1] QUERY SUCCESS:", res.balances)
|
||||
)
|
||||
.add(
|
||||
QueryAccountService,
|
||||
{
|
||||
address:
|
||||
"terra1fd68ah02gr2y8ze7tm9te7m70zlmc7vjyyhs6xlhsdmqqcjud4dql4wpxr",
|
||||
},
|
||||
(err, res) =>
|
||||
err
|
||||
? console.log("[2] QUERY ERROR:", err)
|
||||
: console.log("[2] QUERY SUCCESS:", toBaseAccount(res.account!))
|
||||
)
|
||||
.add(
|
||||
QueryAllBalancesService,
|
||||
{ address: "terra1x9jh7pl623jaj8dlt4q53mpmv5mv5nlpzdpxfs" },
|
||||
(err, res) =>
|
||||
err
|
||||
? console.log("[3] QUERY ERROR:", err)
|
||||
: console.log("[3] QUERY SUCCESS:", res.balances)
|
||||
)
|
||||
.add(
|
||||
QueryAccountService,
|
||||
{ address: "terra1x9jh7pl623jaj8dlt4q53mpmv5mv5nlpzdpxfs" },
|
||||
(err, res) =>
|
||||
err
|
||||
? console.log("[4] QUERY ERROR:", err)
|
||||
: console.log("[4] QUERY SUCCESS:", toBaseAccount(res.account!))
|
||||
)
|
||||
.add(
|
||||
QueryAccountService,
|
||||
{ address: "THIS IS AN INVALID ADDRESS" },
|
||||
(err, res) =>
|
||||
err
|
||||
? console.log("[5] QUERY ERROR:", err) // this should log an error
|
||||
: console.log("[5] QUERY SUCCESS:", toBaseAccount(res.account!))
|
||||
)
|
||||
.send();
|
||||
14
web/es-client/examples/batch-query/tsconfig.json
Normal file
14
web/es-client/examples/batch-query/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ES2020",
|
||||
"baseUrl": ".",
|
||||
"moduleResolution": "bundler",
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
16
web/es-client/examples/mnemonic-wallet/package.json
Normal file
16
web/es-client/examples/mnemonic-wallet/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@@onsonr/es/mnemonic-wallet",
|
||||
"private": true,
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"start": "tsx src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@onsonr/es": "link:../.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.2.0",
|
||||
"tsx": "^3.12.7",
|
||||
"typescript": "^5.0.4"
|
||||
}
|
||||
}
|
||||
312
web/es-client/examples/mnemonic-wallet/pnpm-lock.yaml
generated
Normal file
312
web/es-client/examples/mnemonic-wallet/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,312 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
@onsonr/es:
|
||||
specifier: link:../..
|
||||
version: link:../..
|
||||
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^20.2.0
|
||||
version: 20.8.6
|
||||
tsx:
|
||||
specifier: ^3.12.7
|
||||
version: 3.13.0
|
||||
typescript:
|
||||
specifier: ^5.0.4
|
||||
version: 5.2.2
|
||||
|
||||
packages:
|
||||
|
||||
/@esbuild/android-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm@0.18.20:
|
||||
resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-x64@0.18.20:
|
||||
resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-x64@0.18.20:
|
||||
resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-x64@0.18.20:
|
||||
resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm@0.18.20:
|
||||
resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ia32@0.18.20:
|
||||
resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-loong64@0.18.20:
|
||||
resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-mips64el@0.18.20:
|
||||
resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ppc64@0.18.20:
|
||||
resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-riscv64@0.18.20:
|
||||
resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-s390x@0.18.20:
|
||||
resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-x64@0.18.20:
|
||||
resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/netbsd-x64@0.18.20:
|
||||
resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/openbsd-x64@0.18.20:
|
||||
resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/sunos-x64@0.18.20:
|
||||
resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-arm64@0.18.20:
|
||||
resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-ia32@0.18.20:
|
||||
resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-x64@0.18.20:
|
||||
resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@types/node@20.8.6:
|
||||
resolution: {integrity: sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==}
|
||||
dependencies:
|
||||
undici-types: 5.25.3
|
||||
dev: true
|
||||
|
||||
/buffer-from@1.1.2:
|
||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||
dev: true
|
||||
|
||||
/esbuild@0.18.20:
|
||||
resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==}
|
||||
engines: {node: '>=12'}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
optionalDependencies:
|
||||
'@esbuild/android-arm': 0.18.20
|
||||
'@esbuild/android-arm64': 0.18.20
|
||||
'@esbuild/android-x64': 0.18.20
|
||||
'@esbuild/darwin-arm64': 0.18.20
|
||||
'@esbuild/darwin-x64': 0.18.20
|
||||
'@esbuild/freebsd-arm64': 0.18.20
|
||||
'@esbuild/freebsd-x64': 0.18.20
|
||||
'@esbuild/linux-arm': 0.18.20
|
||||
'@esbuild/linux-arm64': 0.18.20
|
||||
'@esbuild/linux-ia32': 0.18.20
|
||||
'@esbuild/linux-loong64': 0.18.20
|
||||
'@esbuild/linux-mips64el': 0.18.20
|
||||
'@esbuild/linux-ppc64': 0.18.20
|
||||
'@esbuild/linux-riscv64': 0.18.20
|
||||
'@esbuild/linux-s390x': 0.18.20
|
||||
'@esbuild/linux-x64': 0.18.20
|
||||
'@esbuild/netbsd-x64': 0.18.20
|
||||
'@esbuild/openbsd-x64': 0.18.20
|
||||
'@esbuild/sunos-x64': 0.18.20
|
||||
'@esbuild/win32-arm64': 0.18.20
|
||||
'@esbuild/win32-ia32': 0.18.20
|
||||
'@esbuild/win32-x64': 0.18.20
|
||||
dev: true
|
||||
|
||||
/fsevents@2.3.3:
|
||||
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/get-tsconfig@4.7.2:
|
||||
resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==}
|
||||
dependencies:
|
||||
resolve-pkg-maps: 1.0.0
|
||||
dev: true
|
||||
|
||||
/resolve-pkg-maps@1.0.0:
|
||||
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
|
||||
dev: true
|
||||
|
||||
/source-map-support@0.5.21:
|
||||
resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
|
||||
dependencies:
|
||||
buffer-from: 1.1.2
|
||||
source-map: 0.6.1
|
||||
dev: true
|
||||
|
||||
/source-map@0.6.1:
|
||||
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/tsx@3.13.0:
|
||||
resolution: {integrity: sha512-rjmRpTu3as/5fjNq/kOkOtihgLxuIz6pbKdj9xwP4J5jOLkBxw/rjN5ANw+KyrrOXV5uB7HC8+SrrSJxT65y+A==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
esbuild: 0.18.20
|
||||
get-tsconfig: 4.7.2
|
||||
source-map-support: 0.5.21
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
dev: true
|
||||
|
||||
/typescript@5.2.2:
|
||||
resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/undici-types@5.25.3:
|
||||
resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==}
|
||||
dev: true
|
||||
30
web/es-client/examples/mnemonic-wallet/src/index.ts
Normal file
30
web/es-client/examples/mnemonic-wallet/src/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { MnemonicWallet } from "@onsonr/es/wallet";
|
||||
|
||||
async function main() {
|
||||
// Example usage for Osmosis chain
|
||||
const wallet = new MnemonicWallet({
|
||||
// TODO: replace with your mnemonic
|
||||
mnemonic:
|
||||
"witness snack faint milk gesture memory exhibit oak require mountain hammer crawl innocent day library drum youth result mutual remove capable hour front connect",
|
||||
bech32Prefix: "osmo",
|
||||
chainId: "osmosis-1",
|
||||
rpc: "https://rpc.osmosis.zone",
|
||||
gasPrice: {
|
||||
amount: "0.0025",
|
||||
denom: "uosmo",
|
||||
},
|
||||
coinType: 118, // optional (default: 118)
|
||||
index: 0, // optional (default: 0)
|
||||
});
|
||||
console.log("Address:", wallet.address); // prints the bech32 address
|
||||
|
||||
// Sign an arbitrary message
|
||||
const { signature } = await wallet.signArbitrary("Hello from @onsonr/es!");
|
||||
console.log("Signature:", signature);
|
||||
|
||||
// Broadcast a transaction
|
||||
// const res = await wallet.broadcastTxSync( ... );
|
||||
// console.log("Tx result:", res);
|
||||
}
|
||||
|
||||
main();
|
||||
14
web/es-client/examples/mnemonic-wallet/tsconfig.json
Normal file
14
web/es-client/examples/mnemonic-wallet/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ES2020",
|
||||
"baseUrl": ".",
|
||||
"moduleResolution": "bundler",
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
22
web/es-client/examples/solid-vite/assets/favicon.svg
Normal file
22
web/es-client/examples/solid-vite/assets/favicon.svg
Normal file
@@ -0,0 +1,22 @@
|
||||
<svg
|
||||
width="580"
|
||||
height="580"
|
||||
viewBox="0 0 153 153"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<rect width="580" height="580" fill="#0F172A" />
|
||||
<path
|
||||
d="M 60.854168,121.70833 A 42.333332,42.333332 0 0 1 30.919981,109.30919 42.333332,42.333332 0 0 1 18.520836,79.375 h 42.333332 z"
|
||||
style="fill:#ddd6fe;fill-opacity:1" />
|
||||
<path
|
||||
d="m -92.604164,-79.375011 a 42.333332,42.333332 0 0 1 -29.934186,-12.399147 42.333332,42.333332 0 0 1 -12.39915,-29.934182 h 42.333336 z"
|
||||
transform="scale(-1)" style="fill:#a78bfa;fill-opacity:1" />
|
||||
<path
|
||||
d="M 74.083336,-18.520836 A 42.333332,42.333332 0 0 1 44.149149,-30.919982 42.333332,42.333332 0 0 1 31.750004,-60.854168 h 42.333332 z"
|
||||
transform="rotate(90)" style="fill:#ede9fe;fill-opacity:1" />
|
||||
<rect width="21.166666" height="42.333332" x="66.145828" y="31.750002"
|
||||
style="fill:#f5f3ff;fill-opacity:1;stroke-width:0.264583" />
|
||||
<rect width="21.166666" height="42.333332" x="66.145828" y="79.375008"
|
||||
style="fill:#c4b5fd;fill-opacity:1;stroke-width:0.264583" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
16
web/es-client/examples/solid-vite/index.html
Normal file
16
web/es-client/examples/solid-vite/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<link rel="shortcut icon" type="image/ico" href="/assets/favicon.svg" />
|
||||
<title>Solid Vite Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
|
||||
<script src="/src/index.tsx" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
22
web/es-client/examples/solid-vite/package.json
Normal file
22
web/es-client/examples/solid-vite/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@@onsonr/es/solid-vite",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"buffer": "^6.0.3",
|
||||
"@onsonr/es": "link:../..",
|
||||
"solid-js": "^1.7.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.23",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"vite": "^4.3.5",
|
||||
"vite-plugin-solid": "^2.7.0"
|
||||
}
|
||||
}
|
||||
1498
web/es-client/examples/solid-vite/pnpm-lock.yaml
generated
Normal file
1498
web/es-client/examples/solid-vite/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
7
web/es-client/examples/solid-vite/postcss.config.cjs
Normal file
7
web/es-client/examples/solid-vite/postcss.config.cjs
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
"tailwindcss/nesting": {},
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
343
web/es-client/examples/solid-vite/src/App.tsx
Normal file
343
web/es-client/examples/solid-vite/src/App.tsx
Normal file
@@ -0,0 +1,343 @@
|
||||
import { Component, createSignal, For, onMount } from "solid-js";
|
||||
import { createStore } from "solid-js/store";
|
||||
|
||||
import { MsgSend } from "@onsonr/es/client";
|
||||
import {
|
||||
CompassController,
|
||||
ConnectedWallet,
|
||||
CosmostationController,
|
||||
KeplrController,
|
||||
LeapController,
|
||||
MetamaskInjectiveController,
|
||||
NinjiController,
|
||||
OWalletController,
|
||||
StationController,
|
||||
UnsignedTx,
|
||||
WalletController,
|
||||
WalletName,
|
||||
WalletType,
|
||||
} from "@onsonr/es/wallet";
|
||||
|
||||
const WC_PROJECT_ID = "2b7d5a2da89dd74fed821d184acabf95";
|
||||
const SIGN_ARBITRARY_MSG =
|
||||
"Hi from CosmeES! This is a test message just to prove that the wallet is working.";
|
||||
const TX_MEMO = "signed via @onsonr/es";
|
||||
|
||||
const CHAINS: Record<string, string> = {
|
||||
"osmosis-1": "Osmosis",
|
||||
"juno-1": "Juno",
|
||||
"kaiyo-1": "Kujira",
|
||||
"phoenix-1": "Terra",
|
||||
"columbus-5": "Terra Classic",
|
||||
"neutron-1": "Neutron",
|
||||
"migaloo-1": "Migaloo",
|
||||
"injective-1": "Injective",
|
||||
"pacific-1": "Sei",
|
||||
"dymension_1100-1": "Dymension",
|
||||
Oraichain: "Oraichain",
|
||||
};
|
||||
const WALLETS: Record<WalletName, string> = {
|
||||
[WalletName.KEPLR]: "Keplr",
|
||||
[WalletName.COSMOSTATION]: "Cosmostation",
|
||||
[WalletName.STATION]: "Station",
|
||||
[WalletName.LEAP]: "Leap",
|
||||
[WalletName.COMPASS]: "Compass",
|
||||
[WalletName.METAMASK_INJECTIVE]: "MetaMask",
|
||||
[WalletName.NINJI]: "Ninji",
|
||||
[WalletName.OWALLET]: "OWallet",
|
||||
};
|
||||
const TYPES: Record<WalletType, string> = {
|
||||
[WalletType.EXTENSION]: "Extension",
|
||||
[WalletType.WALLETCONNECT]: "Wallet Connect",
|
||||
};
|
||||
const CONTROLLERS: Record<string, WalletController> = {
|
||||
[WalletName.STATION]: new StationController(),
|
||||
[WalletName.KEPLR]: new KeplrController(WC_PROJECT_ID),
|
||||
[WalletName.LEAP]: new LeapController(WC_PROJECT_ID),
|
||||
[WalletName.COMPASS]: new CompassController(),
|
||||
[WalletName.COSMOSTATION]: new CosmostationController(WC_PROJECT_ID),
|
||||
[WalletName.METAMASK_INJECTIVE]: new MetamaskInjectiveController(),
|
||||
[WalletName.NINJI]: new NinjiController(),
|
||||
[WalletName.OWALLET]: new OWalletController(),
|
||||
};
|
||||
|
||||
function getRpc(chain: string): string {
|
||||
switch (chain) {
|
||||
case "osmosis-1":
|
||||
return "https://rpc.osmosis.zone";
|
||||
case "juno-1":
|
||||
return "https://juno-rpc.polkachu.com";
|
||||
case "kaiyo-1":
|
||||
return "https://kujira-rpc.polkachu.com";
|
||||
case "phoenix-1":
|
||||
return "https://terra-rpc.publicnode.com";
|
||||
case "columbus-5":
|
||||
return "https://terra-classic-rpc.publicnode.com";
|
||||
case "neutron-1":
|
||||
return "https://neutron-rpc.polkachu.com";
|
||||
case "migaloo-1":
|
||||
return "https://migaloo-rpc.polkachu.com";
|
||||
case "injective-1":
|
||||
return "https://injective-rpc.polkachu.com";
|
||||
case "pacific-1":
|
||||
return "https://rpc-sei-ia.cosmosia.notional.ventures";
|
||||
case "dymension_1100-1":
|
||||
return "https://rpc.dymension.nodestake.org";
|
||||
case "Oraichain":
|
||||
return "https://rpc.orai.io";
|
||||
default:
|
||||
throw new Error("Unknown chain");
|
||||
}
|
||||
}
|
||||
|
||||
function getGasPrice(chain: string): { amount: string; denom: string } {
|
||||
switch (chain) {
|
||||
case "osmosis-1":
|
||||
return { amount: "0.0025", denom: getDenom(chain) };
|
||||
case "juno-1":
|
||||
return { amount: "0.001", denom: getDenom(chain) };
|
||||
case "kaiyo-1":
|
||||
return { amount: "0.00119", denom: getDenom(chain) };
|
||||
case "phoenix-1":
|
||||
return { amount: "0.015", denom: getDenom(chain) };
|
||||
case "columbus-5":
|
||||
return { amount: "28.325", denom: getDenom(chain) };
|
||||
case "neutron-1":
|
||||
return { amount: "0.01", denom: getDenom(chain) };
|
||||
case "migaloo-1":
|
||||
return { amount: "1", denom: getDenom(chain) };
|
||||
case "injective-1":
|
||||
return { amount: "500000000", denom: getDenom(chain) };
|
||||
case "pacific-1":
|
||||
return { amount: "0.1", denom: getDenom(chain) };
|
||||
case "dymension_1100-1":
|
||||
return { amount: "20000000000", denom: getDenom(chain) };
|
||||
case "Oraichain":
|
||||
return { amount: "0.003", denom: getDenom(chain) };
|
||||
default:
|
||||
throw new Error("Unknown chain");
|
||||
}
|
||||
}
|
||||
|
||||
function getDenom(chain: string): string {
|
||||
switch (chain) {
|
||||
case "osmosis-1":
|
||||
return "uosmo";
|
||||
case "juno-1":
|
||||
return "ujuno";
|
||||
case "kaiyo-1":
|
||||
return "ukuji";
|
||||
case "phoenix-1":
|
||||
case "columbus-5":
|
||||
return "uluna";
|
||||
case "neutron-1":
|
||||
return "untrn";
|
||||
case "migaloo-1":
|
||||
return "uwhale";
|
||||
case "injective-1":
|
||||
return "inj";
|
||||
case "pacific-1":
|
||||
return "usei";
|
||||
case "dymension_1100-1":
|
||||
return "adym";
|
||||
case "Oraichain":
|
||||
return "orai";
|
||||
default:
|
||||
throw new Error("Unknown chain");
|
||||
}
|
||||
}
|
||||
|
||||
const App: Component = () => {
|
||||
const [chain, setChain] = createSignal<string>("pacific-1");
|
||||
const [wallet, setWallet] = createSignal<WalletName>(WalletName.COMPASS);
|
||||
const [wallets, setWallets] = createStore<Record<string, ConnectedWallet>>(
|
||||
{}
|
||||
);
|
||||
const [type, setType] = createSignal<WalletType>(WalletType.EXTENSION);
|
||||
|
||||
onMount(() => {
|
||||
for (const controller of Object.values(CONTROLLERS)) {
|
||||
// Register to diconnect event
|
||||
controller.onDisconnect((wallets) => {
|
||||
const chains = wallets.map((w) => w.chainId);
|
||||
console.log("Wallet disconnected", {
|
||||
wallet: controller.id,
|
||||
chains,
|
||||
});
|
||||
for (const chain of chains) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
setWallets(chain, undefined!);
|
||||
}
|
||||
});
|
||||
// Register to account change event
|
||||
controller.onAccountChange((wallets) => {
|
||||
// Reconnect the affected wallets
|
||||
const chains = wallets.map((w) => w.chainId);
|
||||
console.log("Wallet account changed", {
|
||||
wallet: controller.id,
|
||||
chains,
|
||||
});
|
||||
connect(wallets[0].type, chains);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
async function connect(type: WalletType, chainIds: string[]) {
|
||||
try {
|
||||
const chainInfos = chainIds.map((chainId) => ({
|
||||
chainId,
|
||||
rpc: getRpc(chainId),
|
||||
gasPrice: getGasPrice(chainId),
|
||||
}));
|
||||
const res = await CONTROLLERS[wallet()].connect(type, chainInfos);
|
||||
setWallets({ ...wallets, ...Object.fromEntries(res) });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
alert((err as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
CONTROLLERS[wallet()].disconnect([chain()]);
|
||||
}
|
||||
|
||||
async function signArbitrary() {
|
||||
const wallet = wallets[chain()];
|
||||
if (!wallet) {
|
||||
alert("Wallet not connected yet");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await wallet.signArbitrary(SIGN_ARBITRARY_MSG);
|
||||
console.log(res);
|
||||
alert("Sign success! Check console logs for details.");
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
alert((err as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
async function broadcastTx() {
|
||||
const wallet = wallets[chain()];
|
||||
if (!wallet) {
|
||||
alert("Wallet not connected yet");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const tx: UnsignedTx = {
|
||||
msgs: [
|
||||
new MsgSend({
|
||||
fromAddress: wallet.address,
|
||||
toAddress: wallet.address,
|
||||
amount: [
|
||||
{
|
||||
denom: getDenom(chain()),
|
||||
amount: "1",
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
memo: TX_MEMO,
|
||||
};
|
||||
|
||||
const fee = await wallet.estimateFee(tx);
|
||||
console.log("Tx fee:", fee);
|
||||
|
||||
const txHash = await wallet.broadcastTx(tx, fee);
|
||||
console.log("Tx hash:", txHash);
|
||||
|
||||
const { txResponse } = await wallet.pollTx(txHash);
|
||||
console.log("Tx response:", txResponse);
|
||||
|
||||
alert(
|
||||
"Broadcast success!\n\nTx hash: " +
|
||||
txHash +
|
||||
"\n\nCheck console logs for details."
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
alert((err as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="min-h-screen bg-gray-900 text-gray-100 flex flex-col items-center justify-center text-sm sm:text-base md:text-lg space-y-3 p-3">
|
||||
<select
|
||||
class="bg-gray-700 rounded p-2 text-gray-200"
|
||||
value={chain()}
|
||||
onChange={(e) => setChain(e.target.value)}
|
||||
>
|
||||
<For each={Object.keys(CHAINS)}>
|
||||
{(id) => <option value={id}>{CHAINS[id]}</option>}
|
||||
</For>
|
||||
</select>
|
||||
<div class="flex space-x-2">
|
||||
<select
|
||||
class="bg-gray-700 rounded p-2 text-gray-200"
|
||||
value={wallet()}
|
||||
onChange={(e) => setWallet(e.target.value as WalletName)}
|
||||
>
|
||||
<For each={Object.keys(WALLETS)}>
|
||||
{(wallet) => (
|
||||
<option value={wallet}>{WALLETS[wallet as WalletName]}</option>
|
||||
)}
|
||||
</For>
|
||||
</select>
|
||||
<select
|
||||
class="bg-gray-700 rounded p-2 text-gray-200"
|
||||
value={type()}
|
||||
onChange={(e) => setType(e.target.value as WalletType)}
|
||||
>
|
||||
<For each={Object.keys(TYPES)}>
|
||||
{(type) => (
|
||||
<option value={type}>{TYPES[type as WalletType]}</option>
|
||||
)}
|
||||
</For>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex space-x-2">
|
||||
<button
|
||||
class="bg-red-700 hover:bg-red-600 text-red-100 p-2 rounded"
|
||||
onClick={disconnect}
|
||||
>
|
||||
Disconnect
|
||||
</button>
|
||||
<button
|
||||
class="bg-green-700 hover:bg-green-600 text-green-100 p-2 rounded"
|
||||
onClick={() => connect(type(), [chain()])}
|
||||
>
|
||||
Connect
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="bg-blue-800 hover:bg-blue-700 text-blue-100 p-2 rounded"
|
||||
onClick={signArbitrary}
|
||||
>
|
||||
Sign Arbitrary
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="bg-blue-800 hover:bg-blue-700 text-blue-100 p-2 rounded"
|
||||
onClick={broadcastTx}
|
||||
>
|
||||
Broadcast Tx
|
||||
</button>
|
||||
|
||||
<div class="flex flex-col items-center border py-2 px-4 border-gray-400">
|
||||
<div class="font-semibold">Connected Wallets</div>
|
||||
<For each={Object.values(wallets)}>
|
||||
{(wallet) => (
|
||||
<code>
|
||||
{wallet.address.slice(0, 10)}…{wallet.address.slice(-5)} [
|
||||
{WALLETS[wallet.id]}: {wallet.label ?? "-"}]
|
||||
</code>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user