* ui: improve visual consistency across components

* feat: simplify task execution with consolidated commands

* feat: enable account registration flow

* feat: integrate price tracking functionality

* feat: add metadata components for improved SEO and web crawling

* refactor: improve code organization and consistency

* fix: update login template package names

* refactor: rename and restructure UI components for clarity

* feat: introduce dynamic asset selection for transfer UI

* chore: update dependencies and build process

* feat: Add KVNamespace interface for Cloudflare KV store operations

* refactor: Update JSON operations to use Golang generics with JSON Marshaller interface

* feat: Add json import for KVNamespace generic JSON operations

* refactor: Update PutJSON method to accept any type for JSON marshaling

* refactor: migrate to modular architecture with domain-driven design

* fix: directory structure for component routing

* refactor: partial routes to htmx

* docs: update documentation to reflect UI structure changes

* refactor: relocate build artifacts for cleaner project structure

* feat: integrate Cloudflare cache for improved performance

* build: update import paths for middleware package

* feat: implement core authentication flows

* refactor: rename view handler to index handler for clarity

* feat: introduce devbox for streamlined development environment

* feat: introduce deployment and build scripts

* feat: introduce radar and worker services with build automation

* feat: introduce WASM-based worker and radar services

* feat: migrate to standard go build process

* fix: correct worker script path in wrangler configuration

* feat: enhance service monitoring capabilities

* refactor: migrate to new database and KV store context pattern

* build: streamline worker builds using devbox scripts

* feat: migrate to D1 database bindings for improved data access

* feat: introduce session ID middleware

* perf: optimize WASM build size by stripping debug information

* feat: introduce process-compose for simplified local development

* feat: enable direct wrangler commands and simplify deployment
This commit is contained in:
2025-05-28 12:50:38 -04:00
committed by GitHub
parent 992de8115e
commit 7fdfd5f570
174 changed files with 13605 additions and 9142 deletions

33
.github/doppler-template.yaml vendored Normal file
View File

@@ -0,0 +1,33 @@
projects:
- name: motr
description: Your project description
environments:
- name: Development # Name may contain letters, spaces, numbers, hyphens, and underscores
slug: dev # Slug may contain letters, numbers, hyphens, and underscores
configs:
- slug: dev # First slug *must* match environment slug name
- name: CICD
slug: ci
configs:
- slug: ci
- name: Production
slug: prod
configs:
- slug: prod
secrets:
dev:
ENV: development
ci:
ENV: ci-cd
DOCKER_HUB_USERNAME: ""
DOCKER_HUB_TOKEN: ""
GITHUB_TOKEN: ""
CLOUDFLARE_API_TOKEN: ""
NPM_TOKEN: ""
prod:
ENV: production

106
.github/setup_env.sh vendored Normal file
View File

@@ -0,0 +1,106 @@
#!/bin/bash
# Set up environment variables
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$GOBIN:$PATH
# Setup Motr specific environment variables
export ROOT_DIR=$(git rev-parse --show-toplevel)
export RADAR_ROOT=$ROOT_DIR/cmd/radar
export WORKER_ROOT=$ROOT_DIR/cmd/worker
# Setup Build Outputs
export RADAR_OUT=$RADAR_ROOT/build/app.wasm
export WORKER_OUT=$WORKER_ROOT/build/app.wasm
function go_tidy() {
cd $ROOT_DIR
go mod tidy
go mod download
go install github.com/syumai/workers/cmd/workers-assets-gen@latest
}
function npm_install() {
cd $1
npm install
}
function wrangler_deploy() {
cd $1
wrangler deploy
}
function wrangler_dev() {
cd $1
wrangler dev
}
function check_deps() {
command -v go >/dev/null 2>&1 || { echo >&2 "go is required but not installed. Aborting."; exit 1; }
command -v npm >/dev/null 2>&1 || { echo >&2 "npm is required but not installed. Aborting."; exit 1; }
command -v npx >/dev/null 2>&1 || { echo >&2 "npx is required but not installed. Aborting."; exit 1; }
command -v task >/dev/null 2>&1 || { echo >&2 "task is required but not installed. Aborting."; exit 1; }
command -v wrangler >/dev/null 2>&1 || { echo >&2 "wrangler is required but not installed. Aborting."; exit 1; }
}
function check_vars() {
if [ -z "$ROOT_DIR" ]; then
echo "ROOT_DIR is not set. Aborting."
exit 1
fi
if [ -z "$RADAR_ROOT" ]; then
echo "RADAR_ROOT is not set. Aborting."
exit 1
fi
if [ -z "$WORKER_ROOT" ]; then
echo "WORKER_ROOT is not set. Aborting."
exit 1
fi
if [ -z "$RADAR_OUT" ]; then
echo "RADAR_OUT is not set. Aborting."
exit 1
fi
if [ -z "$WORKER_OUT" ]; then
echo "WORKER_OUT is not set. Aborting."
exit 1
fi
}
function check_secrets() {
if [ -z "$DOCKER_HUB_USERNAME" ]; then
echo "DOCKER_HUB_USERNAME is not set. Aborting."
exit 1
fi
if [ -z "$DOCKER_HUB_TOKEN" ]; then
echo "DOCKER_HUB_TOKEN is not set. Aborting."
exit 1
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is not set. Aborting."
exit 1
fi
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
echo "CLOUDFLARE_API_TOKEN is not set. Aborting."
exit 1
fi
if [ -z "$NPM_TOKEN" ]; then
echo "NPM_TOKEN is not set. Aborting."
exit 1
fi
}
function publish_release() {
check_secrets
goreleaser check
goreleaser release --clean
}

View File

@@ -27,4 +27,4 @@ jobs:
uses: cloudflare/wrangler-action@v3 uses: cloudflare/wrangler-action@v3
with: with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: cmd/vault workingDirectory: cmd

1
.gitignore vendored
View File

@@ -14,6 +14,7 @@ go.work
go.work.sum go.work.sum
!.taskfile.yml !.taskfile.yml
!.taskfile.dist.yml !.taskfile.dist.yml
build
# Aider related generated files # Aider related generated files
.aider-context .aider-context

View File

@@ -1,23 +0,0 @@
# MOTR Development Guide
## Commands
- Build: `task build` - Compiles WASM with `GOOS=js GOARCH=wasm go build -o web/vault.wasm .`
- Generate: `task gen:templ` - Generate Go code from templ templates
- Generate: `task gen:sqlc` - Generate Go code from SQL queries
- Test: `task test` - Run all tests with `go test -v ./...`
- Run single test: `go test -v ./path/to/package -run TestName`
- Serve: `task serve` - Run development server with `bunx live-server` in web directory
## Code Style
- **Imports**: Standard library first, external packages second, local packages last
- **Formatting**: Use gofmt
- **Types**: Prefer explicit types over interface{}
- **Naming**: Follow Go conventions (CamelCase for exported, camelCase for unexported)
- **Error Handling**: Always check errors and return them when appropriate
- **Domain Structure**: Keep domain logic in `/x` directory with handler.go, model/ and view/ subdirectories
- **Templates**: Use templ for HTML templating
- **Database**: Use sqlc for type-safe SQL queries
- **Middleware**: Place middleware in pkg/[service]/middleware.go
## Architecture
MOTR follows a modular architecture with domain-driven design principles. WebAssembly is used for browser execution with progressive web app capabilities.

35
Makefile Normal file
View File

@@ -0,0 +1,35 @@
.PHONY: tidy templ sqlc worker radar
all: help
help:
@echo "Usage: make <command>"
@echo ""
@echo "Commands:"
@echo " help Show this help message"
@echo " tidy Tidy up the project"
@echo " templ Generate templates"
@echo " sqlc Generate SQL schema"
@echo " worker Build and deploy worker"
@echo " radar Build and deploy radar"
templ:
@devbox run gen:templ
sqlc:
@devbox run gen:sqlc
worker:
@devbox run serve:worker
radar:
@devbox run serve:radar
deploy:
@devbox run deploy
release:
@devbox run release
templ-watch:
@devbox run watch:templ

View File

@@ -103,6 +103,31 @@ Motr can be integrated into progressive web applications, providing:
- Seamless blockchain account management - Seamless blockchain account management
- Cross-device synchronization - Cross-device synchronization
## Commands
- Build: `task build` - Compiles WASM with `GOOS=js GOARCH=wasm go build -o web/vault.wasm .`
- Generate: `task gen:templ` - Generate Go code from templ templates
- Generate: `task gen:sqlc` - Generate Go code from SQL queries
- Test: `task test` - Run all tests with `go test -v ./...`
- Run single test: `go test -v ./path/to/package -run TestName`
- Serve: `task serve` - Run development server with `bunx live-server` in web directory
## Code Style
- **Imports**: Standard library first, external packages second, local packages last
- **Formatting**: Use gofmt
- **Types**: Prefer explicit types over interface{}
- **Naming**: Follow Go conventions (CamelCase for exported, camelCase for unexported)
- **Error Handling**: Always check errors and return them when appropriate
- **Domain Structure**: Keep domain logic in `/x` directory with handler.go, model/ and view/ subdirectories
- **Templates**: Use templ for HTML templating
- **Database**: Use sqlc for type-safe SQL queries
- **Middleware**: Place middleware in pkg/[service]/middleware.go
## Architecture
MOTR follows a modular architecture with domain-driven design principles. WebAssembly is used for browser execution with progressive web app capabilities.
## Architecture ## Architecture
Motr consists of several components: Motr consists of several components:
@@ -118,6 +143,7 @@ Motr consists of several components:
### Component Details ### Component Details
1. **Vault** 1. **Vault**
- Core component deployed as a Cloudflare Worker - Core component deployed as a Cloudflare Worker
- Manages decentralized identity and authentication - Manages decentralized identity and authentication
- Integrates with IPFS/Helia for decentralized storage - Integrates with IPFS/Helia for decentralized storage
@@ -125,11 +151,13 @@ Motr consists of several components:
- Package located at `cmd/vault/` - Package located at `cmd/vault/`
2. **Controller** 2. **Controller**
- Manages user credentials and authentication - Manages user credentials and authentication
- Integrates with WebAuthn for credential storage - Integrates with WebAuthn for credential storage
- Uses SQLite via D1 database for persistent storage - Uses SQLite via D1 database for persistent storage
3. **Resolver** 3. **Resolver**
- Resolves Sonr names to addresses and profiles - Resolves Sonr names to addresses and profiles
- Serves as a gateway to the Sonr network - Serves as a gateway to the Sonr network
- Implemented as a Cloudflare Worker - Implemented as a Cloudflare Worker

View File

@@ -1,124 +0,0 @@
#yaml-language-server: $schema=https://json.schemastore.org/taskfile
version: "3"
silent: true
vars:
ROOT_DIR:
sh: git rev-parse --show-toplevel
tasks:
clean:
desc: Remove build artifacts
cmds:
- task: tidy:vault
- task: tidy:front
- task: tidy:root
serve:
desc: Serve the app with air
cmd: air
deploy:
desc: Deploy all
cmds:
- task: deploy:vault
- task: deploy:front
build:
desc: Build all
cmds:
- task: build:vault
- task: build:front
start:vault:
desc: Start the vault
dir: "{{.ROOT_DIR}}/cmd/vault"
cmd: bun run start
start:front:
desc: Start the frontend
dir: "{{.ROOT_DIR}}/cmd/front"
cmd: bun run start
build:vault:
desc: Build the vault
dir: "{{.ROOT_DIR}}/cmd/vault"
cmd: bun run build
sources:
- main.go
generates:
- build/app.wasm
build:front:
desc: Build the frontend
dir: "{{.ROOT_DIR}}/cmd/front"
cmd: bun run build
sources:
- main.go
generates:
- build/app.wasm
deploy:vault:
desc: Deploy the vault
dir: "{{.ROOT_DIR}}/cmd/vault"
cmds:
- bun run deploy
deploy:front:
desc: Deploy the frontend
dir: "{{.ROOT_DIR}}/cmd/front"
cmd: bun run deploy
gen:templ:
desc: Generate templ
cmds:
- templ generate
- rm -rf .task
gen:sqlc:
desc: Generate sqlc
cmd: sqlc generate
db:migrate:
desc: Migrate the database
prompt:
- Are you sure you want to run this command? This will delete all data in the database.
cmds:
- task: migrate:d1
- task: gen:sqlc
migrate:d1:
internal: true
desc: Migrate the common database
dir: "{{.ROOT_DIR}}/cmd/vault"
cmd: npm run migrate
sources:
- schema.sql
generates:
- schema.sql
tidy:vault:
desc: Go mod tidy the vault
internal: true
dir: "{{.ROOT_DIR}}/cmd/vault"
cmds:
- bun run clean
- rm -rf ./build
- rm -rf ./dist
tidy:front:
desc: Go mod tidy the frontend
internal: true
dir: "{{.ROOT_DIR}}/cmd/front"
cmds:
- bun run clean
- rm -rf ./build
- rm -rf ./dist
tidy:root:
desc: Go mod tidy the root
internal: true
dir: "{{.ROOT_DIR}}"
cmds:
- go mod tidy
- rm -rf .task

View File

@@ -1,5 +0,0 @@
build
node_modules
.wrangler
.dev.vars*

View File

@@ -1,25 +0,0 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/routes"
"github.com/sonr-io/motr/sink/config"
)
func main() {
// Setup config
e, c := config.New()
// Setup middleware
e.Use(
middleware.UseSession(c),
middleware.UseCloudflareCache(c),
)
// Setup routes
routes.SetupRoutes(e)
e.Serve()
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +0,0 @@
{
"name": "@sonr-io/motr-front",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "npm run clean && npm run assets && npm run wasm",
"assets": "go run github.com/syumai/workers/cmd/workers-assets-gen -mode=go",
"wasm": "GOOS=js GOARCH=wasm go build -o ./build/app.wasm .",
"deploy": "wrangler deploy",
"start": "wrangler dev",
"clean": "rm -rf ./build && rm -rf .wrangler && rm -rf ./dist && rm -rf ./node_modules && npm install"
},
"devDependencies": {
"wrangler": "^4.10.0"
}
}

22
cmd/radar/main.go Normal file
View File

@@ -0,0 +1,22 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/pkg/database"
"github.com/sonr-io/motr/pkg/session"
"github.com/sonr-io/motr/routes"
"github.com/syumai/workers"
_ "github.com/syumai/workers/cloudflare/d1"
)
func main() {
e := echo.New()
e.Use(session.Middleware(), database.Middleware())
routes.SetupViews(e)
routes.SetupPartials(e)
workers.Serve(e)
}

File diff suppressed because it is too large Load Diff

23
cmd/radar/package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "@sonr-io/radar-worker",
"version": "0.0.1",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
"start": "wrangler dev"
},
"dependencies": {
"@extism/extism": "^2.0.0-rc11",
"@helia/dag-cbor": "^1.0.1",
"@helia/dag-json": "^1.0.1",
"@helia/json": "^1.0.1",
"@helia/strings": "^1.0.1",
"@helia/unixfs": "^1.4.1",
"helia": "^2.1.0",
"sonr-cosmes": "^0.0.5"
},
"devDependencies": {
"concurrently": "^9.1.2",
"wrangler": "^4.10.0"
}
}

View File

@@ -1,41 +1,25 @@
# Top-level configuration # Top-level configuration
name = "motr-front" name = "motr-radar"
main = "build/worker.mjs" main = "build/worker.mjs"
compatibility_date = "2025-04-14" compatibility_date = "2025-04-14"
routes = [ routes = [
{ pattern = "sonr.id", custom_domain = true }, { pattern = "did.run", custom_domain = true },
] ]
[build] [build]
command = "npm run build" command = "devbox run build:radar"
[dev] [dev]
port = 8787 port = 4242
[vars]
SONR_CHAIN_ID = 'sonr-testnet-1'
IPFS_GATEWAY = 'https://ipfs.sonr.land'
SONR_API_URL = 'https://api.sonr.land'
SONR_RPC_URL = 'https://rpc.sonr.land'
SONR_GRPC_URL = 'https://grpc.sonr.id'
MATRIX_SERVER = 'https://bm.chat'
MOTR_GATEWAY = 'https://sonr.id'
MOTR_VAULT = 'https://did.run'
MOTR_MODE = 'resolver'
[observability] [observability]
enabled = true enabled = true
logpush = true
[[r2_buckets]]
binding = 'PROFILES'
bucket_name = 'profiles'
[[d1_databases]] [[d1_databases]]
binding = "DB" # available in your Worker on env.DB binding = "DB" # available in your Worker on env.DB
database_name = "motr-db" database_name = "motr-controller-db"
database_id = "abc70ab3-32ce-4600-9b15-a452f92b7987" database_id = "872a4b08-7e07-4978-b227-5b60940238ed"
[[kv_namespaces]] [[kv_namespaces]]
binding = "SESSIONS" # available in your Worker on env.KV binding = "SESSIONS" # available in your Worker on env.KV
@@ -45,3 +29,17 @@ id = "ea5de66fcfc14b5eba170395e29432ee"
binding = "HANDLES" # available in your Worker on env.KV binding = "HANDLES" # available in your Worker on env.KV
id = "271d47087a8842b2aac5ee79cf7bb203" id = "271d47087a8842b2aac5ee79cf7bb203"
[[r2_buckets]]
binding = 'PROFILES'
bucket_name = 'profiles'
[vars]
SONR_CHAIN_ID = 'sonr-testnet-1'
IPFS_GATEWAY = 'https://ipfs.sonr.land'
SONR_API_URL = 'https://api.sonr.land'
SONR_RPC_URL = 'https://rpc.sonr.land'
SONR_GRPC_URL = 'https://grpc.sonr.land'
MATRIX_SERVER = 'https://bm.chat'
MOTR_GATEWAY = 'https://sonr.id'
MOTR_VAULT = 'https://did.run'
MOTR_MODE = 'controller'

View File

@@ -1,5 +0,0 @@
build
node_modules
.wrangler
.dev.vars*

View File

@@ -1,18 +0,0 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/routes"
"github.com/sonr-io/motr/sink/config"
)
func main() {
// Setup config
e, c := config.New()
e.Use(middleware.UseSession(c), middleware.UseCloudflareCache(c))
routes.SetupRoutes(e)
e.Serve()
}

View File

@@ -1,27 +0,0 @@
{
"name": "@sonr-io/motr-vault",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "npm run clean && npm run assets && npm run wasm",
"assets": "go run github.com/syumai/workers/cmd/workers-assets-gen -mode=go",
"wasm": "GOOS=js GOARCH=wasm go build -o ./build/app.wasm .",
"migrate": "npx wrangler d1 execute motr-db --remote --file=./schema.sql",
"deploy": "npx wrangler deploy",
"start": "npx wrangler dev",
"clean": "rm -rf ./build && rm -rf .wrangler && rm -rf ./dist && rm -rf ./node_modules && npm install"
},
"dependencies": {
"@extism/extism": "^2.0.0-rc11",
"@helia/dag-cbor": "^1.0.1",
"@helia/dag-json": "^1.0.1",
"@helia/json": "^1.0.1",
"@helia/strings": "^1.0.1",
"@helia/unixfs": "^1.4.1",
"helia": "^2.1.0",
"sonr-cosmes": "^0.0.5"
},
"devDependencies": {
"wrangler": "^4.10.0"
}
}

23
cmd/worker/main.go Normal file
View File

@@ -0,0 +1,23 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/pkg/database"
"github.com/sonr-io/motr/pkg/session"
"github.com/sonr-io/motr/routes"
"github.com/syumai/workers"
_ "github.com/syumai/workers/cloudflare/d1"
)
func main() {
e := echo.New()
e.Use(session.Middleware(), database.Middleware())
routes.SetupViews(e)
routes.SetupPartials(e)
workers.Serve(e)
}

6675
cmd/worker/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

23
cmd/worker/package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "@sonr-io/motr-worker",
"version": "0.0.1",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
"start": "wrangler dev"
},
"dependencies": {
"@extism/extism": "^2.0.0-rc11",
"@helia/dag-cbor": "^1.0.1",
"@helia/dag-json": "^1.0.1",
"@helia/json": "^1.0.1",
"@helia/strings": "^1.0.1",
"@helia/unixfs": "^1.4.1",
"helia": "^2.1.0",
"sonr-cosmes": "^0.0.5"
},
"devDependencies": {
"concurrently": "^9.1.2",
"wrangler": "^4.10.0"
}
}

View File

@@ -1,21 +1,20 @@
# Top-level configuration # Top-level configuration
name = "motr-vault" name = "motr-worker"
main = "./worker.mjs" main = "worker.mjs"
compatibility_date = "2025-04-14" compatibility_date = "2025-04-14"
routes = [ routes = [
{ pattern = "did.run", custom_domain = true }, { pattern = "sonr.id", custom_domain = true },
] ]
[build] [build]
command = "npm run build" command = "devbox run build:worker"
[dev] [dev]
port = 6969 port = 6969
[observability] [observability]
enabled = true enabled = true
logpush = true
[[d1_databases]] [[d1_databases]]
binding = "DB" # available in your Worker on env.DB binding = "DB" # available in your Worker on env.DB
@@ -43,7 +42,6 @@ SONR_GRPC_URL = 'https://grpc.sonr.land'
MATRIX_SERVER = 'https://bm.chat' MATRIX_SERVER = 'https://bm.chat'
MOTR_GATEWAY = 'https://sonr.id' MOTR_GATEWAY = 'https://sonr.id'
MOTR_VAULT = 'https://did.run' MOTR_VAULT = 'https://did.run'
MOTR_MODE = 'controller'
[durable_objects] [durable_objects]
bindings = [{name = "VAULT", class_name = "Vault"}] bindings = [{name = "VAULT", class_name = "Vault"}]

69
config/config.go Normal file
View File

@@ -0,0 +1,69 @@
//go:build js && wasm
// +build js,wasm
package config
import (
"time"
"github.com/syumai/workers/cloudflare"
)
type Config struct {
Cache CacheSettings `json:"cache"` // Added Cache configuration
Sonr NetworkParams `json:"network"`
DefaultExpiry time.Duration `json:"expiry"`
}
type NetworkParams struct {
SonrChainID string `json:"sonr_chain_id"`
SonrAPIURL string `json:"sonr_api_url"`
SonrRPCURL string `json:"sonr_rpc_url"`
IPFSGateway string `json:"ipfs_gateway"`
}
// CacheSettings defines the configuration for Cloudflare cache
type CacheSettings struct {
Enabled bool `json:"enabled"`
DefaultMaxAge int `json:"default_max_age"`
BypassHeader string `json:"bypass_header"`
BypassValue string `json:"bypass_value"`
CacheableStatusCodes []int `json:"cacheable_status_codes"`
CacheableContentTypes []string `json:"cacheable_content_types"`
}
func Get() Config {
cache := CacheSettings{
Enabled: true,
DefaultMaxAge: 60, // 1 minute by default
BypassHeader: "X-Cache-Bypass",
BypassValue: "true",
CacheableStatusCodes: []int{
200, 301, 302,
},
CacheableContentTypes: []string{
"text/html",
"text/css",
"text/javascript",
"application/javascript",
"application/json",
"image/jpeg",
"image/png",
"image/gif",
"image/webp",
},
}
sonr := NetworkParams{
SonrChainID: cloudflare.Getenv("SONR_CHAIN_ID"),
SonrAPIURL: cloudflare.Getenv("SONR_API_URL"),
SonrRPCURL: cloudflare.Getenv("SONR_RPC_URL"),
IPFSGateway: cloudflare.Getenv("IPFS_GATEWAY"),
}
c := Config{
Sonr: sonr,
Cache: cache,
DefaultExpiry: time.Hour * 1,
}
return c
}

View File

@@ -1,48 +0,0 @@
package account
import "github.com/sonr-io/motr/sink/models"
templ cardComponent(handle, addr, block, name string) {
<div class="profile-card min-w-[320px]">
<div class="text-white max-w-xs my-auto mx-auto bg-gradient-to-r from-cyan-600 to-cyan-300 p-4 py-5 px-5 rounded-xl">
<div class="flex justify-between">
<div>
<h2>sonr-testnet-1</h2>
<p class="text-2xl font-bold">{ handle }</p>
</div>
<div class="flex items-center opacity-60">
<sl-icon style="font-size: 52px;" library="sonr" name="sonr-fill"></sl-icon>
</div>
</div>
<div class="mt-5 flex justify-between items-center w-52">
<span class="text-lg font-mono">{ addr }</span>
</div>
<div class="flex justify-between mt-5 w-48 ">
<div>
<h3 class="text-xs">Block Created </h3>
<p class="font-bold"><span>#</span>{ block }</p>
</div>
<div>
<h3 class="text-xs">Issued to</h3>
<p class="font-bold">{ name }</p>
</div>
</div>
</div>
</div>
}
// option is a single option in the dropdown
templ optionComponent(account models.Account) {
<div class="flex justify-between items-center">
{ account.Address }
<sl-icon style="font-size: 24px;" library="sonr" name="chevron-right"></sl-icon>
</div>
}
// row is a single row in the list with a basic card
templ rowComponent(account models.Account) {
<div class="flex justify-between items-center">
{ account.Address }
<sl-icon style="font-size: 24px;" library="sonr" name="chevron-right"></sl-icon>
</div>
}

View File

@@ -1,180 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package account
//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 "github.com/sonr-io/motr/sink/models"
func cardComponent(handle, addr, block, name 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"profile-card min-w-[320px]\"><div class=\"text-white max-w-xs my-auto mx-auto bg-gradient-to-r from-cyan-600 to-cyan-300 p-4 py-5 px-5 rounded-xl\"><div class=\"flex justify-between\"><div><h2>sonr-testnet-1</h2><p class=\"text-2xl font-bold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(handle)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/account/card.templ`, Line: 11, Col: 43}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</p></div><div class=\"flex items-center opacity-60\"><sl-icon style=\"font-size: 52px;\" library=\"sonr\" name=\"sonr-fill\"></sl-icon></div></div><div class=\"mt-5 flex justify-between items-center w-52\"><span class=\"text-lg font-mono\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(addr)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/account/card.templ`, Line: 18, Col: 42}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</span></div><div class=\"flex justify-between mt-5 w-48 \"><div><h3 class=\"text-xs\">Block Created </h3><p class=\"font-bold\"><span>#</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(block)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/account/card.templ`, Line: 23, Col: 47}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</p></div><div><h3 class=\"text-xs\">Issued to</h3><p class=\"font-bold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/account/card.templ`, Line: 27, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</p></div></div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// option is a single option in the dropdown
func optionComponent(account models.Account) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(account.Address)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/account/card.templ`, Line: 37, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " <sl-icon style=\"font-size: 24px;\" library=\"sonr\" name=\"chevron-right\"></sl-icon></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// row is a single row in the list with a basic card
func rowComponent(account models.Account) 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_Var8 := templ.GetChildren(ctx)
if templ_7745c5c3_Var8 == nil {
templ_7745c5c3_Var8 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(account.Address)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/account/card.templ`, Line: 45, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " <sl-icon style=\"font-size: 24px;\" library=\"sonr\" name=\"chevron-right\"></sl-icon></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,63 +0,0 @@
package account
import (
"strconv"
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type AccountEntity interface {
GetModel() models.Account
GetCard() templ.Component
shortAddr() string
}
type AccountsEntity interface {
GetModels() []models.Account
GetList() templ.Component
GetDropdown() templ.Component
}
func NewAccountEntity(account models.Account) AccountEntity {
return &accountEntity{Account: account}
}
func NewAccountsEntity(accounts []models.Account) AccountsEntity {
return &accountsEntity{Accounts: accounts}
}
type accountEntity struct {
models.Account
}
func (a *accountEntity) shortAddr() string {
if len(a.Address) <= 20 {
return a.Address
}
return a.Address[:16] + "..." + a.Address[len(a.Address)-4:]
}
func (a *accountEntity) GetModel() models.Account {
return a.Account
}
func (a *accountEntity) GetCard() templ.Component {
return cardComponent(a.Handle, a.shortAddr(), strconv.FormatInt(a.BlockCreated, 10), a.Label)
}
type accountsEntity struct {
Accounts []models.Account
}
func (a *accountsEntity) GetModels() []models.Account {
return a.Accounts
}
func (a *accountsEntity) GetList() templ.Component {
return nil
}
func (a *accountsEntity) GetDropdown() templ.Component {
return nil
}

View File

@@ -1,11 +0,0 @@
package account
templ listComponent(accounts AccountsEntity) {
<div class="flex flex-col gap-4 mt-4">
for _,account := range accounts.GetModels() {
<div class="flex justify-between items-center">
@rowComponent(account)
</div>
}
</div>
}

View File

@@ -1,58 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package account
//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 listComponent(accounts AccountsEntity) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-col gap-4 mt-4\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, account := range accounts.GetModels() {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = rowComponent(account).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,32 +0,0 @@
package account
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetAccountByID(ctx context.Context, id string) (models.Account, error)
GetAccountByAddress(ctx context.Context, address string) (models.Account, error)
GetAccountByController(ctx context.Context, controller string) (models.Account, error)
GetAccountByPublicKey(ctx context.Context, publicKey string) (models.Account, error)
GetAccountByNumber(ctx context.Context, number int64) (models.Account, error)
GetAccountBySequence(ctx context.Context, sequence int64) (models.Account, error)
GetAccountsByChainID(ctx context.Context, chainID string) ([]models.Account, error)
GetAccountsByHandle(ctx context.Context, handle string) ([]models.Account, error)
GetAccountsByLabel(ctx context.Context, name string) ([]models.Account, error)
UpdateAccountLabel(ctx context.Context, arg models.UpdateAccountLabelParams) (models.Account, error)
UpdateAccountSequence(ctx context.Context, arg models.UpdateAccountSequenceParams) (models.Account, error)
SoftDeleteAccount(ctx context.Context, id string) error
ListValidatorAccounts(ctx context.Context) ([]models.Account, error)
ListDelegatorAccounts(ctx context.Context) ([]models.Account, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,11 +0,0 @@
package account
templ selectComponent(accounts AccountsEntity) {
<div class="flex flex-col gap-4 mt-4">
for _,account := range accounts.GetModels() {
<div class="flex justify-between items-center">
@optionComponent(account)
</div>
}
</div>
}

View File

@@ -1,58 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package account
//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 selectComponent(accounts AccountsEntity) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-col gap-4 mt-4\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, account := range accounts.GetModels() {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = optionComponent(account).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,48 +0,0 @@
package activity
import "github.com/sonr-io/motr/sink/models"
templ cardComponent(handle, addr, block, name string) {
<div class="profile-card min-w-[320px]">
<div class="text-white max-w-xs my-auto mx-auto bg-gradient-to-r from-cyan-600 to-cyan-300 p-4 py-5 px-5 rounded-xl">
<div class="flex justify-between">
<div>
<h2>sonr-testnet-1</h2>
<p class="text-2xl font-bold">{ handle }</p>
</div>
<div class="flex items-center opacity-60">
<sl-icon style="font-size: 52px;" library="sonr" name="sonr-fill"></sl-icon>
</div>
</div>
<div class="mt-5 flex justify-between items-center w-52">
<span class="text-lg font-mono">{ addr }</span>
</div>
<div class="flex justify-between mt-5 w-48 ">
<div>
<h3 class="text-xs">Block Created </h3>
<p class="font-bold"><span>#</span>{ block }</p>
</div>
<div>
<h3 class="text-xs">Issued to</h3>
<p class="font-bold">{ name }</p>
</div>
</div>
</div>
</div>
}
// option is a single option in the dropdown
templ optionComponent(account models.Activity) {
<div class="flex justify-between items-center">
{ account.Status }
<sl-icon style="font-size: 24px;" library="sonr" name="chevron-right"></sl-icon>
</div>
}
// row is a single row in the list with a basic card
templ rowComponent(account models.Activity) {
<div class="flex justify-between items-center">
{ account.Status }
<sl-icon style="font-size: 24px;" library="sonr" name="chevron-right"></sl-icon>
</div>
}

View File

@@ -1,180 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package activity
//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 "github.com/sonr-io/motr/sink/models"
func cardComponent(handle, addr, block, name 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"profile-card min-w-[320px]\"><div class=\"text-white max-w-xs my-auto mx-auto bg-gradient-to-r from-cyan-600 to-cyan-300 p-4 py-5 px-5 rounded-xl\"><div class=\"flex justify-between\"><div><h2>sonr-testnet-1</h2><p class=\"text-2xl font-bold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(handle)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/activity/card.templ`, Line: 11, Col: 43}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</p></div><div class=\"flex items-center opacity-60\"><sl-icon style=\"font-size: 52px;\" library=\"sonr\" name=\"sonr-fill\"></sl-icon></div></div><div class=\"mt-5 flex justify-between items-center w-52\"><span class=\"text-lg font-mono\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(addr)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/activity/card.templ`, Line: 18, Col: 42}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</span></div><div class=\"flex justify-between mt-5 w-48 \"><div><h3 class=\"text-xs\">Block Created </h3><p class=\"font-bold\"><span>#</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(block)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/activity/card.templ`, Line: 23, Col: 47}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</p></div><div><h3 class=\"text-xs\">Issued to</h3><p class=\"font-bold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/activity/card.templ`, Line: 27, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</p></div></div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// option is a single option in the dropdown
func optionComponent(account models.Activity) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(account.Status)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/activity/card.templ`, Line: 37, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " <sl-icon style=\"font-size: 24px;\" library=\"sonr\" name=\"chevron-right\"></sl-icon></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// row is a single row in the list with a basic card
func rowComponent(account models.Activity) 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_Var8 := templ.GetChildren(ctx)
if templ_7745c5c3_Var8 == nil {
templ_7745c5c3_Var8 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(account.Status)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `controllers/activity/card.templ`, Line: 45, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " <sl-icon style=\"font-size: 24px;\" library=\"sonr\" name=\"chevron-right\"></sl-icon></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,16 +0,0 @@
package activity
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type ActivityEntity interface {
GetModel() models.Activity
GetCard() templ.Component
}
type ActivitiesEntity interface {
GetModels() []models.Activity
GetList() templ.Component
}

View File

@@ -1,11 +0,0 @@
package activity
templ listComponent(accounts ActivitiesEntity) {
<div class="flex flex-col gap-4 mt-4">
for _,account := range accounts.GetModels() {
<div class="flex justify-between items-center">
@rowComponent(account)
</div>
}
</div>
}

View File

@@ -1,58 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package activity
//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 listComponent(accounts ActivitiesEntity) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-col gap-4 mt-4\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, account := range accounts.GetModels() {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"flex justify-between items-center\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = rowComponent(account).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,27 +0,0 @@
package activity
import (
"context"
"database/sql"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetActivityByID(ctx context.Context, id string) (models.Activity, error)
GetActivityByTxHash(ctx context.Context, txHash sql.NullString) (models.Activity, error)
InsertActivity(ctx context.Context, arg models.InsertActivityParams) (models.Activity, error)
ListActivitiesByAccount(ctx context.Context, arg models.ListActivitiesByAccountParams) ([]models.Activity, error)
ListActivitiesByStatus(ctx context.Context, arg models.ListActivitiesByStatusParams) ([]models.Activity, error)
ListActivitiesByType(ctx context.Context, arg models.ListActivitiesByTypeParams) ([]models.Activity, error)
SoftDeleteActivity(ctx context.Context, id string) error
UpdateActivityStatus(ctx context.Context, arg models.UpdateActivityStatusParams) (models.Activity, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,17 +0,0 @@
package asset
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type AssetEntity interface {
GetModel() models.Asset
GetCard(ticker, price string) templ.Component
}
type AssetsEntity interface {
GetModels() []models.Asset
GetList() templ.Component
GetDropdown() templ.Component
}

View File

@@ -1,27 +0,0 @@
package asset
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetAssetByChainAndSymbol(ctx context.Context, arg models.GetAssetByChainAndSymbolParams) (models.Asset, error)
GetAssetByID(ctx context.Context, id string) (models.Asset, error)
GetAssetBySymbol(ctx context.Context, symbol string) (models.Asset, error)
GetAssetWithLatestPrice(ctx context.Context, id string) (models.GetAssetWithLatestPriceRow, error)
InsertAsset(ctx context.Context, arg models.InsertAssetParams) (models.Asset, error)
ListAssetsByChain(ctx context.Context, chainID string) ([]models.Asset, error)
ListAssetsWithLatestPrices(ctx context.Context, arg models.ListAssetsWithLatestPricesParams) ([]models.ListAssetsWithLatestPricesRow, error)
SoftDeleteAsset(ctx context.Context, id string) error
UpdateAsset(ctx context.Context, arg models.UpdateAssetParams) (models.Asset, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,7 +0,0 @@
package asset
templ selectComponent() {
<div class="flex flex-col gap-4 mt-4">
<div class="flex justify-between items-center"></div>
</div>
}

View File

@@ -1,40 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package asset
//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 selectComponent() 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-col gap-4 mt-4\"><div class=\"flex justify-between items-center\"></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,17 +0,0 @@
package blockchain
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type BlockchainEntity interface {
GetModel() models.Blockchain
GetCard(ticker, price string) templ.Component
}
type BlockchainsEntity interface {
GetModels() []models.Blockchain
GetList() templ.Component
GetDropdown() templ.Component
}

View File

@@ -1,41 +0,0 @@
package blockchain
import (
"context"
"database/sql"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetBlockchainByChainName(ctx context.Context, chainName string) (models.Blockchain, error)
GetBlockchainByCosmosChainID(ctx context.Context, chainIDCosmos sql.NullString) (models.Blockchain, error)
GetBlockchainByEvmChainID(ctx context.Context, chainIDEvm sql.NullString) (models.Blockchain, error)
GetBlockchainByID(ctx context.Context, id string) (models.Blockchain, error)
GetBlockchainEndpoints(ctx context.Context, id string) (models.GetBlockchainEndpointsRow, error)
GetBlockchainExplorer(ctx context.Context, id string) (models.GetBlockchainExplorerRow, error)
GetBlockchainWithAssetInfo(ctx context.Context, id string) (models.GetBlockchainWithAssetInfoRow, error)
InsertBlockchain(ctx context.Context, arg models.InsertBlockchainParams) (models.Blockchain, error)
ListBlockchainsWithAssetInfo(ctx context.Context, arg models.ListBlockchainsWithAssetInfoParams) ([]models.ListBlockchainsWithAssetInfoRow, error)
ListBlockchainsWithERC20Support(ctx context.Context) ([]models.Blockchain, error)
ListBlockchainsWithExtensionSupport(ctx context.Context) ([]models.Blockchain, error)
ListBlockchainsWithMobileSupport(ctx context.Context) ([]models.Blockchain, error)
ListBlockchainsWithStaking(ctx context.Context) ([]models.Blockchain, error)
SearchBlockchains(ctx context.Context, arg models.SearchBlockchainsParams) ([]models.Blockchain, error)
SoftDeleteBlockchain(ctx context.Context, id string) error
UpdateBlockchain(ctx context.Context, arg models.UpdateBlockchainParams) (models.Blockchain, error)
UpdateBlockchainDescriptions(ctx context.Context, arg models.UpdateBlockchainDescriptionsParams) (models.Blockchain, error)
UpdateBlockchainEndpoints(ctx context.Context, arg models.UpdateBlockchainEndpointsParams) (models.Blockchain, error)
UpdateBlockchainExplorer(ctx context.Context, arg models.UpdateBlockchainExplorerParams) (models.Blockchain, error)
UpdateBlockchainFeeInfo(ctx context.Context, arg models.UpdateBlockchainFeeInfoParams) (models.Blockchain, error)
UpdateBlockchainImages(ctx context.Context, arg models.UpdateBlockchainImagesParams) (models.Blockchain, error)
UpdateBlockchainSocialLinks(ctx context.Context, arg models.UpdateBlockchainSocialLinksParams) (models.Blockchain, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,18 +0,0 @@
package credential
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type CredentialEntity interface {
GetModel() models.Credential
GetDescriptor() *CredentialDescriptor
GetInfoModal() templ.Component
}
type CredentialsEntity interface {
GetModels() []models.Credential
GetDescriptors() []*CredentialDescriptor
GetList() templ.Component
}

View File

@@ -1,232 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package credential
//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 PasskeyInitial(clickHandler templ.ComponentScript) 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.RenderScriptItems(ctx, templ_7745c5c3_Buffer, clickHandler)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<sl-button style=\"width: 100%;\" onclick=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 templ.ComponentScript = clickHandler
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\"><sl-icon slot=\"prefix\" name=\"passkey\" library=\"sonr\" style=\"font-size: 24px;\" class=\"text-neutral-500\"></sl-icon> Register Passkey</sl-button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func PasskeyError(clickHandler templ.ComponentScript) 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.RenderScriptItems(ctx, templ_7745c5c3_Buffer, clickHandler)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<sl-button style=\"width: 100%;\" onclick=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 templ.ComponentScript = clickHandler
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\"><sl-icon slot=\"prefix\" name=\"passkey\" library=\"sonr\" style=\"font-size: 24px;\" class=\"text-red-500\"></sl-icon> Register Passkey</sl-button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func PasskeySuccess(clickHandler templ.ComponentScript) 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.RenderScriptItems(ctx, templ_7745c5c3_Buffer, clickHandler)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<sl-button style=\"width: 100%;\" onclick=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 templ.ComponentScript = clickHandler
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\"><sl-icon slot=\"prefix\" name=\"passkey\" library=\"sonr\" style=\"font-size: 24px;\" class=\"text-green-500\"></sl-icon> Register Passkey</sl-button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func NavigatorCredentialsCreate(userId string, userHandle string, challenge string) templ.ComponentScript {
return templ.ComponentScript{
Name: `__templ_NavigatorCredentialsCreate_8f96`,
Function: `function __templ_NavigatorCredentialsCreate_8f96(userId, userHandle, challenge){const publicKey = {
challenge: Uint8Array.from(challenge, (c) => c.charCodeAt(0)),
rp: {
name: "Sonr.ID",
},
user: {
// Assuming that userId is ASCII-only
id: Uint8Array.from(userId, (c) => c.charCodeAt(0)),
name: userId,
displayName: userHandle,
},
pubKeyCredParams: [
{
type: "public-key",
alg: -7, // "ES256"
},
{
type: "public-key",
alg: -257, // "RS256"
},
],
authenticatorSelection: {
userVerification: "required",
residentKey: "required",
authenticatorAttachment: "platform",
},
timeout: 60000, // 1 minute
extensions: {
payment: {
isPayment: true,
},
largeBlob: {
supported: "preferred",
},
},
};
// Helper function to convert ArrayBuffer to Base64URL string
function arrayBufferToBase64URL(buffer) {
const bytes = new Uint8Array(buffer);
let str = '';
bytes.forEach(byte => { str += String.fromCharCode(byte) });
return btoa(str)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
}
navigator.credentials
.create({ publicKey })
.then((newCredentialInfo) => {
if (!(newCredentialInfo instanceof PublicKeyCredential)) {
throw new Error('Received credential is not a PublicKeyCredential');
}
const response = newCredentialInfo.response;
if (!(response instanceof AuthenticatorAttestationResponse)) {
throw new Error('Response is not an AuthenticatorAttestationResponse');
}
// Convert the credential data to a cross-platform compatible format
const credentialJSON = {
id: newCredentialInfo.id,
rawId: arrayBufferToBase64URL(newCredentialInfo.rawId),
type: newCredentialInfo.type,
authenticatorAttachment: newCredentialInfo.authenticatorAttachment || null,
transports: Array.isArray(response.getTransports) ? response.getTransports() : [],
clientExtensionResults: newCredentialInfo.getClientExtensionResults(),
response: {
attestationObject: arrayBufferToBase64URL(response.attestationObject),
clientDataJSON: arrayBufferToBase64URL(response.clientDataJSON)
}
};
// Set the form value with the stringified credential data
const credential = document.getElementById('credential-data');
credential.value = JSON.stringify(credentialJSON);
// Submit the form
const form = document.getElementById('passkey-form');
form.submit();
})
.catch((err) => {
console.error('Passkey creation failed:', err);
alert(` + "`" + `Failed to create passkey: ${err.message || 'Unknown error'}` + "`" + `);
});
}`,
Call: templ.SafeScript(`__templ_NavigatorCredentialsCreate_8f96`, userId, userHandle, challenge),
CallInline: templ.SafeScriptInline(`__templ_NavigatorCredentialsCreate_8f96`, userId, userHandle, challenge),
}
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,22 +0,0 @@
package credential
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetCredentialByID(ctx context.Context, credentialID string) (models.Credential, error)
GetCredentialsByHandle(ctx context.Context, handle string) ([]models.Credential, error)
InsertCredential(ctx context.Context, arg models.InsertCredentialParams) (models.Credential, error)
SoftDeleteCredential(ctx context.Context, credentialID string) error
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,16 +0,0 @@
package health
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type HealthEntity interface {
GetModel() models.Health
GetCard() templ.Component
}
type HealthsEntity interface {
GetModels() []models.Health
GetList() templ.Component
}

View File

@@ -1,26 +0,0 @@
package health
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetHealthByEndpoint(ctx context.Context, endpointUrl string) (models.Health, error)
GetHealthByID(ctx context.Context, id string) (models.Health, error)
InsertHealth(ctx context.Context, arg models.InsertHealthParams) (models.Health, error)
ListHealthByChain(ctx context.Context, arg models.ListHealthByChainParams) ([]models.Health, error)
ListHealthByStatus(ctx context.Context, arg models.ListHealthByStatusParams) ([]models.Health, error)
ListHealthChecksNeedingUpdate(ctx context.Context, limit int64) ([]models.Health, error)
SoftDeleteHealth(ctx context.Context, id string) error
UpdateHealthCheck(ctx context.Context, arg models.UpdateHealthCheckParams) (models.Health, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,16 +0,0 @@
package prices
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type PriceEntity interface {
GetModel() models.Price
GetCard() templ.Component
}
type PricesEntity interface {
GetModels() []models.Price
GetList() templ.Component
}

View File

@@ -1,23 +0,0 @@
package prices
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetPriceByAssetID(ctx context.Context, assetID string) (models.Price, error)
GetPriceByID(ctx context.Context, id string) (models.Price, error)
InsertPrice(ctx context.Context, arg models.InsertPriceParams) (models.Price, error)
ListPriceHistoryByAssetID(ctx context.Context, arg models.ListPriceHistoryByAssetIDParams) ([]models.Price, error)
UpdatePrice(ctx context.Context, arg models.UpdatePriceParams) (models.Price, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,16 +0,0 @@
package profile
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type ProfileEntity interface {
GetModel() models.Profile
}
type ProfilesEntity interface {
GetModels() []models.Profile
GetList() templ.Component
GetDropdown() templ.Component
}

View File

@@ -1,8 +0,0 @@
package profile
templ InputAvatar(value string, helpText string) {
<input type="file" name="avatar" id="avatar" name="avatar" accept="image/*"/>
<sl-button variant="neutral" slot="suffix" type="button">
<sl-icon name="upload-2-fill" slot="prefix"></sl-icon>
</sl-button>
}

View File

@@ -1,40 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package profile
//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 InputAvatar(value string, helpText 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<input type=\"file\" name=\"avatar\" id=\"avatar\" name=\"avatar\" accept=\"image/*\"> <sl-button variant=\"neutral\" slot=\"suffix\" type=\"button\"><sl-icon name=\"upload-2-fill\" slot=\"prefix\"></sl-icon></sl-button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,26 +0,0 @@
package profile
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
CheckHandleExists(ctx context.Context, handle string) (bool, error)
GetAccountsByHandle(ctx context.Context, handle string) ([]models.Account, error)
GetCredentialsByHandle(ctx context.Context, handle string) ([]models.Credential, error)
GetVaultsByHandle(ctx context.Context, handle string) ([]models.Vault, error)
InsertProfile(ctx context.Context, arg models.InsertProfileParams) (models.Profile, error)
ListProfiles(ctx context.Context, arg models.ListProfilesParams) ([]models.Profile, error)
SoftDeleteProfile(ctx context.Context, address string) error
UpdateProfile(ctx context.Context, arg models.UpdateProfileParams) (models.Profile, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,16 +0,0 @@
package service
import (
"github.com/a-h/templ"
"github.com/sonr-io/motr/sink/models"
)
type ServiceEntity interface {
GetModel() models.Service
GetCard() templ.Component
}
type ServicesEntity interface {
GetModels() []models.Service
GetList() templ.Component
}

View File

@@ -1,26 +0,0 @@
package service
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetServiceByAddress(ctx context.Context, address string) (models.Service, error)
GetServiceByChainAndAddress(ctx context.Context, arg models.GetServiceByChainAndAddressParams) (models.Service, error)
GetServiceByID(ctx context.Context, id string) (models.Service, error)
InsertService(ctx context.Context, arg models.InsertServiceParams) (models.Service, error)
ListServicesByChain(ctx context.Context, arg models.ListServicesByChainParams) ([]models.Service, error)
ListServicesByOwner(ctx context.Context, arg models.ListServicesByOwnerParams) ([]models.Service, error)
SoftDeleteService(ctx context.Context, id string) error
UpdateService(ctx context.Context, arg models.UpdateServiceParams) (models.Service, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

View File

@@ -1,9 +0,0 @@
package vault
import (
"github.com/sonr-io/motr/sink/models"
)
type VaultEntity interface {
GetModel() models.Vault
}

View File

@@ -1,7 +0,0 @@
package vault
templ LoginForm(opts LoginOptions) {
<form method="post" action="/login">
<sl-button type="submit" variant="primary">Login</sl-button>
</form>
}

View File

@@ -1,40 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.865
package vault
//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 LoginForm(opts LoginOptions) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<form method=\"post\" action=\"/login\"><sl-button type=\"submit\" variant=\"primary\">Login</sl-button></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View File

@@ -1,18 +0,0 @@
package vault
import "github.com/sonr-io/motr/controllers/credential"
type LoginOptions struct {
Account string
Handle string
HelpText string
Label string
Challenge string
AllowedCredentials []*credential.CredentialDescriptor
}
type RegisterOptions struct {
Address string
Handle string
Challenge string
}

View File

@@ -1,25 +0,0 @@
package vault
import (
"context"
"github.com/sonr-io/motr/sink/models"
)
type Queries interface {
GetVaultByID(ctx context.Context, id string) (models.Vault, error)
GetVaultConfigByCID(ctx context.Context, cid string) (models.Vault, error)
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error)
GetVaultsByHandle(ctx context.Context, handle string) ([]models.Vault, error)
InsertVault(ctx context.Context, arg models.InsertVaultParams) (models.Vault, error)
SoftDeleteVault(ctx context.Context, id string) error
UpdateVault(ctx context.Context, arg models.UpdateVaultParams) (models.Vault, error)
}
func NewQueries(q models.Querier) Queries {
return &queries{Querier: q}
}
type queries struct {
models.Querier
}

61
devbox.json Normal file
View File

@@ -0,0 +1,61 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.14.1/.schema/devbox.schema.json",
"packages": [
"templ@latest",
"sqlc@latest",
"nodejs@latest",
"goreleaser@latest",
"doppler@latest",
"commitizen@latest",
"process-compose@latest"
],
"shell": {
"init_hook": [
"source .github/setup_env.sh",
"go_tidy",
"npm_install $RADAR_ROOT",
"npm_install $WORKER_ROOT"
],
"scripts": {
"dev": [
"process-compose up"
],
"deploy": [
"wrangler_deploy $RADAR_ROOT",
"wrangler_deploy $WORKER_ROOT"
],
"release": [
"check_deps",
"check_vars",
"publish_release"
],
"build:radar": [
"cd $RADAR_ROOT",
"workers-assets-gen -mode=go",
"GOOS=js GOARCH=wasm go build -ldflags=\"-s -w\" -o ./build/app.wasm ."
],
"build:worker": [
"cd $WORKER_ROOT",
"workers-assets-gen -mode=go",
"GOOS=js GOARCH=wasm go build -ldflags=\"-s -w\" -o ./build/app.wasm ."
],
"serve:radar": [
"cd $RADAR_ROOT",
"npm run start"
],
"serve:worker": [
"cd $WORKER_ROOT",
"npm run start"
],
"gen:sqlc": [
"cd ./internal/sink && sqlc generate"
],
"gen:templ": [
"templ generate"
],
"watch:templ": [
"templ generate --watch"
]
}
}
}

394
devbox.lock Normal file
View File

@@ -0,0 +1,394 @@
{
"lockfile_version": "1",
"packages": {
"commitizen@latest": {
"last_modified": "2025-05-21T01:27:34Z",
"resolved": "github:NixOS/nixpkgs/f0d925b947cca0bbe7f2d25115cbaf021844aba7#commitizen",
"source": "devbox-search",
"version": "4.7.1",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/m3307fx56ifajpg0qgqjj9dg71xjcfn4-python3.12-commitizen-4.7.1",
"default": true
},
{
"name": "dist",
"path": "/nix/store/1081mrd0v09sx6g2c12h2bsyyim0s204-python3.12-commitizen-4.7.1-dist"
}
],
"store_path": "/nix/store/m3307fx56ifajpg0qgqjj9dg71xjcfn4-python3.12-commitizen-4.7.1"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/kiaab8hfkacad3nh3ygc9p6m02sskb0l-python3.12-commitizen-4.7.1",
"default": true
},
{
"name": "dist",
"path": "/nix/store/y7yqhxmmfnb5i012xvkzg8g5qkq8vrkj-python3.12-commitizen-4.7.1-dist"
}
],
"store_path": "/nix/store/kiaab8hfkacad3nh3ygc9p6m02sskb0l-python3.12-commitizen-4.7.1"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/06s8d1qwgd1mw0jmp35fhfdznwpppb0l-python3.12-commitizen-4.7.1",
"default": true
},
{
"name": "dist",
"path": "/nix/store/nlvvhrsg465n918474zh3jirlifvqbww-python3.12-commitizen-4.7.1-dist"
}
],
"store_path": "/nix/store/06s8d1qwgd1mw0jmp35fhfdznwpppb0l-python3.12-commitizen-4.7.1"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/gaqvcwn0dya1crk789s0xsf7s4knraxz-python3.12-commitizen-4.7.1",
"default": true
},
{
"name": "dist",
"path": "/nix/store/iagih5hd0nq8a5fh3naads5xc3gpg9jn-python3.12-commitizen-4.7.1-dist"
}
],
"store_path": "/nix/store/gaqvcwn0dya1crk789s0xsf7s4knraxz-python3.12-commitizen-4.7.1"
}
}
},
"doppler@latest": {
"last_modified": "2025-05-16T20:19:48Z",
"resolved": "github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3#doppler",
"source": "devbox-search",
"version": "3.74.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/y668f58njmrwndq2vzvd2013klgyr8mc-doppler-3.74.0",
"default": true
}
],
"store_path": "/nix/store/y668f58njmrwndq2vzvd2013klgyr8mc-doppler-3.74.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/n751mbf77ldbv4daw6nxykzrs2bq84a2-doppler-3.74.0",
"default": true
}
],
"store_path": "/nix/store/n751mbf77ldbv4daw6nxykzrs2bq84a2-doppler-3.74.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/abmclxna8750chlc5i8yj6hvlmb86q0k-doppler-3.74.0",
"default": true
}
],
"store_path": "/nix/store/abmclxna8750chlc5i8yj6hvlmb86q0k-doppler-3.74.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/9xmw5l1y9p6s1bw21jj54f77yldrb35p-doppler-3.74.0",
"default": true
}
],
"store_path": "/nix/store/9xmw5l1y9p6s1bw21jj54f77yldrb35p-doppler-3.74.0"
}
}
},
"github:NixOS/nixpkgs/nixpkgs-unstable": {
"last_modified": "2025-05-26T00:03:27Z",
"resolved": "github:NixOS/nixpkgs/3108eaa516ae22c2360928589731a4f1581526ef?lastModified=1748217807&narHash=sha256-P3u2PXxMlo49PutQLnk2PhI%2FimC69hFl1yY4aT5Nax8%3D"
},
"goreleaser@latest": {
"last_modified": "2025-05-16T20:19:48Z",
"resolved": "github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3#goreleaser",
"source": "devbox-search",
"version": "2.9.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/lqihz0f2h9zjqlhk74cayb9l74zgkxj2-goreleaser-2.9.0",
"default": true
}
],
"store_path": "/nix/store/lqihz0f2h9zjqlhk74cayb9l74zgkxj2-goreleaser-2.9.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/wg1ndxx3hq7lcxg0nkzgs3myrflr5jm0-goreleaser-2.9.0",
"default": true
}
],
"store_path": "/nix/store/wg1ndxx3hq7lcxg0nkzgs3myrflr5jm0-goreleaser-2.9.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/v17lq7ap19pajdhp04n4b7p4y5f2mxrr-goreleaser-2.9.0",
"default": true
}
],
"store_path": "/nix/store/v17lq7ap19pajdhp04n4b7p4y5f2mxrr-goreleaser-2.9.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/rvjwgy6zz5qwipcm709jvf3j38r552nw-goreleaser-2.9.0",
"default": true
}
],
"store_path": "/nix/store/rvjwgy6zz5qwipcm709jvf3j38r552nw-goreleaser-2.9.0"
}
}
},
"nodejs@latest": {
"last_modified": "2025-05-22T03:53:02Z",
"plugin_version": "0.0.2",
"resolved": "github:NixOS/nixpkgs/a16efe5d2fc7455d7328a01f4692bfec152965b3#nodejs_24",
"source": "devbox-search",
"version": "24.1.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/2q5an9rpdq4vhc5ag04ajxnzxxqsqchq-nodejs-24.1.0",
"default": true
},
{
"name": "dev",
"path": "/nix/store/hb25vqffnqd3hl7glmm1y4n54bmpfppr-nodejs-24.1.0-dev"
},
{
"name": "libv8",
"path": "/nix/store/jw04y4lzw7x0v2yh437s3l6cri5l50vv-nodejs-24.1.0-libv8"
}
],
"store_path": "/nix/store/2q5an9rpdq4vhc5ag04ajxnzxxqsqchq-nodejs-24.1.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/1ypnf27d1amna71zl7jgjpli4r2xqzx9-nodejs-24.1.0",
"default": true
},
{
"name": "dev",
"path": "/nix/store/3alphvmg91jin165pj9q5zfk7j40azbg-nodejs-24.1.0-dev"
},
{
"name": "libv8",
"path": "/nix/store/z1cbkwmgw0f94rhvc40v3k8z1rg9zkzf-nodejs-24.1.0-libv8"
}
],
"store_path": "/nix/store/1ypnf27d1amna71zl7jgjpli4r2xqzx9-nodejs-24.1.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/plga9910l27vbg30ajmdsmccyj2a3pxm-nodejs-24.1.0",
"default": true
},
{
"name": "libv8",
"path": "/nix/store/d6cq633qq8jr8liaip97fjwpv9r15ivb-nodejs-24.1.0-libv8"
},
{
"name": "dev",
"path": "/nix/store/4b8xp5vrd08ca1im5b607x1wwvy4njjx-nodejs-24.1.0-dev"
}
],
"store_path": "/nix/store/plga9910l27vbg30ajmdsmccyj2a3pxm-nodejs-24.1.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/wnayblhh0555nwfccnzcqkzph52y4yby-nodejs-24.1.0",
"default": true
},
{
"name": "dev",
"path": "/nix/store/8ydr7k53w188y9fhskl7ahl8ibchx7w8-nodejs-24.1.0-dev"
},
{
"name": "libv8",
"path": "/nix/store/4paqvzbw7jjzvn64liv5wwzc7fdsr7k7-nodejs-24.1.0-libv8"
}
],
"store_path": "/nix/store/wnayblhh0555nwfccnzcqkzph52y4yby-nodejs-24.1.0"
}
}
},
"process-compose@latest": {
"last_modified": "2025-05-16T20:19:48Z",
"resolved": "github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3#process-compose",
"source": "devbox-search",
"version": "1.64.1",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/yffykcwzkaqy490wzkiyw0ff6lss5fcx-process-compose-1.64.1",
"default": true
}
],
"store_path": "/nix/store/yffykcwzkaqy490wzkiyw0ff6lss5fcx-process-compose-1.64.1"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/2n23nlnm52pi84vn3g8mg14xxsg5ww00-process-compose-1.64.1",
"default": true
}
],
"store_path": "/nix/store/2n23nlnm52pi84vn3g8mg14xxsg5ww00-process-compose-1.64.1"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/g3r6rxrfk09vfv19rzpd6fmc9s75d21p-process-compose-1.64.1",
"default": true
}
],
"store_path": "/nix/store/g3r6rxrfk09vfv19rzpd6fmc9s75d21p-process-compose-1.64.1"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/4hymfhkv9ldhbjqz6wjln05bhyxfd9xl-process-compose-1.64.1",
"default": true
}
],
"store_path": "/nix/store/4hymfhkv9ldhbjqz6wjln05bhyxfd9xl-process-compose-1.64.1"
}
}
},
"sqlc@latest": {
"last_modified": "2025-05-16T20:19:48Z",
"resolved": "github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3#sqlc",
"source": "devbox-search",
"version": "1.29.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/59x6309fph8whrgq9km66vh0m6xxbbsm-sqlc-1.29.0",
"default": true
}
],
"store_path": "/nix/store/59x6309fph8whrgq9km66vh0m6xxbbsm-sqlc-1.29.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8fivw8sfx1b5lskjzwdy3jpahpmpkgsf-sqlc-1.29.0",
"default": true
}
],
"store_path": "/nix/store/8fivw8sfx1b5lskjzwdy3jpahpmpkgsf-sqlc-1.29.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/0klmpx4r5y22qw4q7i77rak1qfxqmmi1-sqlc-1.29.0",
"default": true
}
],
"store_path": "/nix/store/0klmpx4r5y22qw4q7i77rak1qfxqmmi1-sqlc-1.29.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/qs2fwl68y7vl6v82w7jh6bm0zp6k8xbz-sqlc-1.29.0",
"default": true
}
],
"store_path": "/nix/store/qs2fwl68y7vl6v82w7jh6bm0zp6k8xbz-sqlc-1.29.0"
}
}
},
"templ@latest": {
"last_modified": "2025-05-16T20:19:48Z",
"resolved": "github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3#templ",
"source": "devbox-search",
"version": "0.3.865",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/6lhjwyf6rdrmihdlc4ypy46gsd2ysjyv-templ-0.3.865",
"default": true
}
],
"store_path": "/nix/store/6lhjwyf6rdrmihdlc4ypy46gsd2ysjyv-templ-0.3.865"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/6rr5gq33mnj76g8r3bwx35inq2iwx1jk-templ-0.3.865",
"default": true
}
],
"store_path": "/nix/store/6rr5gq33mnj76g8r3bwx35inq2iwx1jk-templ-0.3.865"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/s79pg2247kpidi5sf8p3mvz7jbli7j2p-templ-0.3.865",
"default": true
}
],
"store_path": "/nix/store/s79pg2247kpidi5sf8p3mvz7jbli7j2p-templ-0.3.865"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/yq6xygf7hq5alzfwyalfd5wixwzswcfl-templ-0.3.865",
"default": true
}
],
"store_path": "/nix/store/yq6xygf7hq5alzfwyalfd5wixwzswcfl-templ-0.3.865"
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleDefaultError(c echo.Context) error {
return middleware.Render(c, views.HomeView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleDefaultIndex(c echo.Context) error {
return middleware.Render(c, views.HomeView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleDefaultValid(c echo.Context) error {
return middleware.Render(c, views.HomeView())
}

11
handlers/error_handler.go Normal file
View File

@@ -0,0 +1,11 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/internal/ui/home"
"github.com/sonr-io/motr/pkg/render"
)
func HandleItemNotFound(c echo.Context) error {
return render.View(c, home.HomeView())
}

15
handlers/index_handler.go Normal file
View File

@@ -0,0 +1,15 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/internal/ui/home"
"github.com/sonr-io/motr/pkg/render"
)
func HandleDefaultIndex(c echo.Context) error {
return render.View(c, home.HomeView())
}
func HandleDefaultValid(c echo.Context) error {
return render.View(c, home.HomeView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleLoginCheck(c echo.Context) error {
return middleware.Render(c, views.LoginView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleLoginFinish(c echo.Context) error {
return middleware.Render(c, views.LoginView())
}

33
handlers/login_handler.go Normal file
View File

@@ -0,0 +1,33 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/internal/ui/login"
"github.com/sonr-io/motr/pkg/render"
"github.com/sonr-io/motr/pkg/webauth"
)
type LoginOptions struct {
Account string
Handle string
HelpText string
Label string
Challenge string
AllowedCredentials []*webauth.CredentialDescriptor
}
func HandleLoginCheck(c echo.Context) error {
return render.View(c, login.LoginView())
}
func HandleLoginInitial(c echo.Context) error {
return render.View(c, login.LoginView())
}
func HandleLoginFinish(c echo.Context) error {
return render.View(c, login.LoginView())
}
func HandleLoginStart(c echo.Context) error {
return render.View(c, login.LoginView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleLoginInitial(c echo.Context) error {
return middleware.Render(c, views.LoginView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleLoginStart(c echo.Context) error {
return middleware.Render(c, views.LoginView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleRegisterCheck(c echo.Context) error {
return middleware.Render(c, views.RegisterView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleRegisterFinish(c echo.Context) error {
return middleware.Render(c, views.RegisterView())
}

View File

@@ -0,0 +1,29 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/internal/ui/register"
"github.com/sonr-io/motr/pkg/render"
)
type RegisterOptions struct {
Address string
Handle string
Challenge string
}
func HandleRegisterInitial(c echo.Context) error {
return render.View(c, register.RegisterView())
}
func HandleRegisterCheck(c echo.Context) error {
return render.View(c, register.RegisterView())
}
func HandleRegisterFinish(c echo.Context) error {
return render.View(c, register.RegisterView())
}
func HandleRegisterStart(c echo.Context) error {
return render.View(c, register.RegisterView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleRegisterInitial(c echo.Context) error {
return middleware.Render(c, views.RegisterView())
}

View File

@@ -1,11 +0,0 @@
package handlers
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/middleware"
"github.com/sonr-io/motr/ui/views"
)
func HandleRegisterStart(c echo.Context) error {
return middleware.Render(c, views.RegisterView())
}

View File

@@ -0,0 +1,31 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package activity
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,
}
}

View File

@@ -0,0 +1,63 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package activity
import (
"database/sql"
"time"
)
type Activity struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt sql.NullTime `json:"deleted_at"`
AccountID string `json:"account_id"`
TxHash sql.NullString `json:"tx_hash"`
TxType string `json:"tx_type"`
Status string `json:"status"`
Amount sql.NullString `json:"amount"`
Fee sql.NullString `json:"fee"`
GasUsed sql.NullInt64 `json:"gas_used"`
GasWanted sql.NullInt64 `json:"gas_wanted"`
Memo sql.NullString `json:"memo"`
BlockHeight sql.NullInt64 `json:"block_height"`
Timestamp time.Time `json:"timestamp"`
RawLog sql.NullString `json:"raw_log"`
Error sql.NullString `json:"error"`
}
type Health struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt sql.NullTime `json:"deleted_at"`
EndpointUrl string `json:"endpoint_url"`
EndpointType string `json:"endpoint_type"`
ChainID sql.NullString `json:"chain_id"`
Status string `json:"status"`
ResponseTimeMs sql.NullInt64 `json:"response_time_ms"`
LastChecked time.Time `json:"last_checked"`
NextCheck sql.NullTime `json:"next_check"`
FailureCount int64 `json:"failure_count"`
SuccessCount int64 `json:"success_count"`
ResponseData sql.NullString `json:"response_data"`
ErrorMessage sql.NullString `json:"error_message"`
}
type Service 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"`
Description sql.NullString `json:"description"`
ChainID string `json:"chain_id"`
Address string `json:"address"`
OwnerAddress string `json:"owner_address"`
Metadata sql.NullString `json:"metadata"`
Status string `json:"status"`
BlockHeight int64 `json:"block_height"`
}

View File

@@ -0,0 +1,41 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package activity
import (
"context"
"database/sql"
)
type Querier interface {
GetActivityByID(ctx context.Context, id string) (Activity, error)
GetActivityByTxHash(ctx context.Context, txHash sql.NullString) (Activity, error)
GetHealthByEndpoint(ctx context.Context, endpointUrl string) (Health, error)
GetHealthByID(ctx context.Context, id string) (Health, error)
GetServiceByAddress(ctx context.Context, address string) (Service, error)
GetServiceByChainAndAddress(ctx context.Context, arg GetServiceByChainAndAddressParams) (Service, error)
GetServiceByID(ctx context.Context, id string) (Service, error)
// ACTIVITY QUERIES
InsertActivity(ctx context.Context, arg InsertActivityParams) (Activity, error)
// HEALTH QUERIES
InsertHealth(ctx context.Context, arg InsertHealthParams) (Health, error)
InsertService(ctx context.Context, arg InsertServiceParams) (Service, error)
ListActivitiesByAccount(ctx context.Context, arg ListActivitiesByAccountParams) ([]Activity, error)
ListActivitiesByStatus(ctx context.Context, arg ListActivitiesByStatusParams) ([]Activity, error)
ListActivitiesByType(ctx context.Context, arg ListActivitiesByTypeParams) ([]Activity, error)
ListHealthByChain(ctx context.Context, arg ListHealthByChainParams) ([]Health, error)
ListHealthByStatus(ctx context.Context, arg ListHealthByStatusParams) ([]Health, error)
ListHealthChecksNeedingUpdate(ctx context.Context, limit int64) ([]Health, error)
ListServicesByChain(ctx context.Context, arg ListServicesByChainParams) ([]Service, error)
ListServicesByOwner(ctx context.Context, arg ListServicesByOwnerParams) ([]Service, error)
SoftDeleteActivity(ctx context.Context, id string) error
SoftDeleteHealth(ctx context.Context, id string) error
SoftDeleteService(ctx context.Context, id string) error
UpdateActivityStatus(ctx context.Context, arg UpdateActivityStatusParams) (Activity, error)
UpdateHealthCheck(ctx context.Context, arg UpdateHealthCheckParams) (Health, error)
UpdateService(ctx context.Context, arg UpdateServiceParams) (Service, error)
}
var _ Querier = (*Queries)(nil)

View File

@@ -0,0 +1,191 @@
-- name: InsertService :one
INSERT INTO services (
name,
description,
chain_id,
address,
owner_address,
metadata,
status,
block_height
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetServiceByID :one
SELECT * FROM services
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetServiceByAddress :one
SELECT * FROM services
WHERE address = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetServiceByChainAndAddress :one
SELECT * FROM services
WHERE chain_id = ? AND address = ? AND deleted_at IS NULL
LIMIT 1;
-- name: ListServicesByChain :many
SELECT * FROM services
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY name ASC
LIMIT ? OFFSET ?;
-- name: ListServicesByOwner :many
SELECT * FROM services
WHERE owner_address = ? AND deleted_at IS NULL
ORDER BY created_at DESC
LIMIT ? OFFSET ?;
-- name: UpdateService :one
UPDATE services
SET
name = ?,
description = ?,
owner_address = ?,
metadata = ?,
status = ?,
block_height = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteService :exec
UPDATE services
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- ACTIVITY QUERIES
-- name: InsertActivity :one
INSERT INTO activities (
account_id,
tx_hash,
tx_type,
status,
amount,
fee,
gas_used,
gas_wanted,
memo,
block_height,
timestamp,
raw_log,
error
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetActivityByID :one
SELECT * FROM activities
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetActivityByTxHash :one
SELECT * FROM activities
WHERE tx_hash = ? AND deleted_at IS NULL
LIMIT 1;
-- name: ListActivitiesByAccount :many
SELECT * FROM activities
WHERE account_id = ? AND deleted_at IS NULL
ORDER BY timestamp DESC
LIMIT ? OFFSET ?;
-- name: ListActivitiesByType :many
SELECT * FROM activities
WHERE tx_type = ? AND deleted_at IS NULL
ORDER BY timestamp DESC
LIMIT ? OFFSET ?;
-- name: ListActivitiesByStatus :many
SELECT * FROM activities
WHERE status = ? AND deleted_at IS NULL
ORDER BY timestamp DESC
LIMIT ? OFFSET ?;
-- name: UpdateActivityStatus :one
UPDATE activities
SET
status = ?,
tx_hash = ?,
block_height = ?,
gas_used = ?,
raw_log = ?,
error = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteActivity :exec
UPDATE activities
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- HEALTH QUERIES
-- name: InsertHealth :one
INSERT INTO health (
endpoint_url,
endpoint_type,
chain_id,
status,
response_time_ms,
last_checked,
next_check,
failure_count,
success_count,
response_data,
error_message
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetHealthByID :one
SELECT * FROM health
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetHealthByEndpoint :one
SELECT * FROM health
WHERE endpoint_url = ? AND deleted_at IS NULL
ORDER BY last_checked DESC
LIMIT 1;
-- name: ListHealthByChain :many
SELECT * FROM health
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY last_checked DESC
LIMIT ? OFFSET ?;
-- name: ListHealthByStatus :many
SELECT * FROM health
WHERE status = ? AND deleted_at IS NULL
ORDER BY last_checked DESC
LIMIT ? OFFSET ?;
-- name: ListHealthChecksNeedingUpdate :many
SELECT * FROM health
WHERE next_check <= CURRENT_TIMESTAMP AND deleted_at IS NULL
ORDER BY next_check ASC
LIMIT ?;
-- name: UpdateHealthCheck :one
UPDATE health
SET
status = ?,
response_time_ms = ?,
last_checked = CURRENT_TIMESTAMP,
next_check = ?,
failure_count = CASE WHEN status = 'failed' THEN failure_count + 1 ELSE failure_count END,
success_count = CASE WHEN status = 'success' THEN success_count + 1 ELSE success_count END,
response_data = ?,
error_message = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteHealth :exec
UPDATE health
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,84 @@
-- Service for Service Records sourced on chain
CREATE TABLE services (
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,
description TEXT,
chain_id TEXT NOT NULL,
address TEXT NOT NULL,
owner_address TEXT NOT NULL,
metadata TEXT CHECK(json_valid(metadata)),
status TEXT NOT NULL,
block_height INTEGER NOT NULL,
FOREIGN KEY (chain_id) REFERENCES assets(chain_id),
UNIQUE(chain_id, address)
);
-- Activity table for basic transaction broadcast activity
CREATE TABLE activities (
id TEXT PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP,
account_id TEXT NOT NULL,
tx_hash TEXT,
tx_type TEXT NOT NULL,
status TEXT NOT NULL,
amount TEXT,
fee TEXT,
gas_used INTEGER,
gas_wanted INTEGER,
memo TEXT,
block_height INTEGER,
timestamp TIMESTAMP NOT NULL,
raw_log TEXT,
error TEXT,
FOREIGN KEY (account_id) REFERENCES accounts(id)
);
-- Health table for scheduled checks for API endpoints
CREATE TABLE health (
id TEXT PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP,
endpoint_url TEXT NOT NULL,
endpoint_type TEXT NOT NULL,
chain_id TEXT,
status TEXT NOT NULL,
response_time_ms INTEGER,
last_checked TIMESTAMP NOT NULL,
next_check TIMESTAMP,
failure_count INTEGER NOT NULL DEFAULT 0,
success_count INTEGER NOT NULL DEFAULT 0,
response_data TEXT,
error_message TEXT,
FOREIGN KEY (chain_id) REFERENCES assets(chain_id)
);
CREATE INDEX idx_services_name ON services(name);
CREATE INDEX idx_services_chain_id ON services(chain_id);
CREATE INDEX idx_services_address ON services(address);
CREATE INDEX idx_services_owner_address ON services(owner_address);
CREATE INDEX idx_services_status ON services(status);
CREATE INDEX idx_services_deleted_at ON services(deleted_at);
CREATE INDEX idx_activities_account_id ON activities(account_id);
CREATE INDEX idx_activities_tx_hash ON activities(tx_hash);
CREATE INDEX idx_activities_tx_type ON activities(tx_type);
CREATE INDEX idx_activities_status ON activities(status);
CREATE INDEX idx_activities_timestamp ON activities(timestamp);
CREATE INDEX idx_activities_block_height ON activities(block_height);
CREATE INDEX idx_activities_deleted_at ON activities(deleted_at);
CREATE INDEX idx_health_endpoint_url ON health(endpoint_url);
CREATE INDEX idx_health_endpoint_type ON health(endpoint_type);
CREATE INDEX idx_health_chain_id ON health(chain_id);
CREATE INDEX idx_health_status ON health(status);
CREATE INDEX idx_health_last_checked ON health(last_checked);
CREATE INDEX idx_health_next_check ON health(next_check);
CREATE INDEX idx_health_deleted_at ON health(deleted_at);

View File

@@ -0,0 +1,31 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package network
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,
}
}

View File

@@ -1,54 +1,14 @@
// Code generated by sqlc. DO NOT EDIT. // Code generated by sqlc. DO NOT EDIT.
// versions: // versions:
// sqlc v1.28.0 // sqlc v1.29.0
package models package network
import ( import (
"database/sql" "database/sql"
"time" "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"`
BlockCreated int64 `json:"block_created"`
Controller string `json:"controller"`
Label string `json:"label"`
Handle string `json:"handle"`
IsSubsidiary bool `json:"is_subsidiary"`
IsValidator bool `json:"is_validator"`
IsDelegator bool `json:"is_delegator"`
IsAccountable bool `json:"is_accountable"`
}
type Activity struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt sql.NullTime `json:"deleted_at"`
AccountID string `json:"account_id"`
TxHash sql.NullString `json:"tx_hash"`
TxType string `json:"tx_type"`
Status string `json:"status"`
Amount sql.NullString `json:"amount"`
Fee sql.NullString `json:"fee"`
GasUsed sql.NullInt64 `json:"gas_used"`
GasWanted sql.NullInt64 `json:"gas_wanted"`
Memo sql.NullString `json:"memo"`
BlockHeight sql.NullInt64 `json:"block_height"`
Timestamp time.Time `json:"timestamp"`
RawLog sql.NullString `json:"raw_log"`
Error sql.NullString `json:"error"`
}
type Asset struct { type Asset struct {
ID string `json:"id"` ID string `json:"id"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
@@ -102,19 +62,6 @@ type Blockchain struct {
Forum sql.NullString `json:"forum"` Forum sql.NullString `json:"forum"`
} }
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 CryptoListing struct { type CryptoListing struct {
ID string `json:"id"` ID string `json:"id"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
@@ -151,24 +98,6 @@ type GlobalMarket struct {
LastUpdated time.Time `json:"last_updated"` LastUpdated time.Time `json:"last_updated"`
} }
type Health struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt sql.NullTime `json:"deleted_at"`
EndpointUrl string `json:"endpoint_url"`
EndpointType string `json:"endpoint_type"`
ChainID sql.NullString `json:"chain_id"`
Status string `json:"status"`
ResponseTimeMs sql.NullInt64 `json:"response_time_ms"`
LastChecked time.Time `json:"last_checked"`
NextCheck sql.NullTime `json:"next_check"`
FailureCount int64 `json:"failure_count"`
SuccessCount int64 `json:"success_count"`
ResponseData sql.NullString `json:"response_data"`
ErrorMessage sql.NullString `json:"error_message"`
}
type Price struct { type Price struct {
ID string `json:"id"` ID string `json:"id"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
@@ -201,43 +130,3 @@ type PriceConversion struct {
MarketCap sql.NullFloat64 `json:"market_cap"` MarketCap sql.NullFloat64 `json:"market_cap"`
LastUpdated time.Time `json:"last_updated"` LastUpdated time.Time `json:"last_updated"`
} }
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 Service 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"`
Description sql.NullString `json:"description"`
ChainID string `json:"chain_id"`
Address string `json:"address"`
OwnerAddress string `json:"owner_address"`
Metadata sql.NullString `json:"metadata"`
Status string `json:"status"`
BlockHeight int64 `json:"block_height"`
}
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"`
}

View File

@@ -1,8 +1,8 @@
// Code generated by sqlc. DO NOT EDIT. // Code generated by sqlc. DO NOT EDIT.
// versions: // versions:
// sqlc v1.28.0 // sqlc v1.29.0
package models package network
import ( import (
"context" "context"
@@ -10,20 +10,7 @@ import (
) )
type Querier interface { type Querier interface {
CheckHandleExists(ctx context.Context, handle string) (bool, error)
CountBlockchainsByChainType(ctx context.Context, dollar_1 sql.NullString) (int64, error) CountBlockchainsByChainType(ctx context.Context, dollar_1 sql.NullString) (int64, error)
GetAccountByAddress(ctx context.Context, address string) (Account, error)
GetAccountByController(ctx context.Context, controller string) (Account, error)
GetAccountByID(ctx context.Context, id string) (Account, error)
GetAccountByNumber(ctx context.Context, number int64) (Account, error)
GetAccountByPublicKey(ctx context.Context, publicKey string) (Account, error)
GetAccountBySequence(ctx context.Context, sequence int64) (Account, error)
GetAccountsByChainID(ctx context.Context, chainID string) ([]Account, error)
GetAccountsByController(ctx context.Context, controller string) ([]Account, error)
GetAccountsByHandle(ctx context.Context, handle string) ([]Account, error)
GetAccountsByLabel(ctx context.Context, label string) ([]Account, error)
GetActivityByID(ctx context.Context, id string) (Activity, error)
GetActivityByTxHash(ctx context.Context, txHash sql.NullString) (Activity, error)
GetAssetByChainAndSymbol(ctx context.Context, arg GetAssetByChainAndSymbolParams) (Asset, error) GetAssetByChainAndSymbol(ctx context.Context, arg GetAssetByChainAndSymbolParams) (Asset, error)
GetAssetByID(ctx context.Context, id string) (Asset, error) GetAssetByID(ctx context.Context, id string) (Asset, error)
GetAssetBySymbol(ctx context.Context, symbol string) (Asset, error) GetAssetBySymbol(ctx context.Context, symbol string) (Asset, error)
@@ -35,16 +22,12 @@ type Querier interface {
GetBlockchainEndpoints(ctx context.Context, id string) (GetBlockchainEndpointsRow, error) GetBlockchainEndpoints(ctx context.Context, id string) (GetBlockchainEndpointsRow, error)
GetBlockchainExplorer(ctx context.Context, id string) (GetBlockchainExplorerRow, error) GetBlockchainExplorer(ctx context.Context, id string) (GetBlockchainExplorerRow, error)
GetBlockchainWithAssetInfo(ctx context.Context, id string) (GetBlockchainWithAssetInfoRow, error) GetBlockchainWithAssetInfo(ctx context.Context, id string) (GetBlockchainWithAssetInfoRow, error)
GetCredentialByID(ctx context.Context, credentialID string) (Credential, error)
GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, error)
GetCryptoListingByApiID(ctx context.Context, apiID string) (CryptoListing, error) GetCryptoListingByApiID(ctx context.Context, apiID string) (CryptoListing, error)
GetCryptoListingByID(ctx context.Context, id string) (CryptoListing, error) GetCryptoListingByID(ctx context.Context, id string) (CryptoListing, error)
GetCryptoListingBySymbol(ctx context.Context, symbol string) (CryptoListing, error) GetCryptoListingBySymbol(ctx context.Context, symbol string) (CryptoListing, error)
GetCryptoListingByWebsiteSlug(ctx context.Context, websiteSlug string) (CryptoListing, error) GetCryptoListingByWebsiteSlug(ctx context.Context, websiteSlug string) (CryptoListing, error)
GetFearGreedIndexByID(ctx context.Context, id string) (FearGreedIndex, error) GetFearGreedIndexByID(ctx context.Context, id string) (FearGreedIndex, error)
GetGlobalMarketByID(ctx context.Context, id string) (GlobalMarket, error) GetGlobalMarketByID(ctx context.Context, id string) (GlobalMarket, error)
GetHealthByEndpoint(ctx context.Context, endpointUrl string) (Health, error)
GetHealthByID(ctx context.Context, id string) (Health, error)
GetLatestFearGreedIndex(ctx context.Context) (FearGreedIndex, error) GetLatestFearGreedIndex(ctx context.Context) (FearGreedIndex, error)
GetLatestGlobalMarket(ctx context.Context) (GlobalMarket, error) GetLatestGlobalMarket(ctx context.Context) (GlobalMarket, error)
GetPriceByAssetID(ctx context.Context, assetID string) (Price, error) GetPriceByAssetID(ctx context.Context, assetID string) (Price, error)
@@ -52,47 +35,20 @@ type Querier interface {
GetPriceConversionByCurrency(ctx context.Context, arg GetPriceConversionByCurrencyParams) (PriceConversion, error) GetPriceConversionByCurrency(ctx context.Context, arg GetPriceConversionByCurrencyParams) (PriceConversion, error)
GetPriceConversionByID(ctx context.Context, id string) (PriceConversion, error) GetPriceConversionByID(ctx context.Context, id string) (PriceConversion, error)
GetPriceConversionsByPriceID(ctx context.Context, priceID string) ([]PriceConversion, error) GetPriceConversionsByPriceID(ctx context.Context, priceID string) ([]PriceConversion, 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)
GetServiceByAddress(ctx context.Context, address string) (Service, error)
GetServiceByChainAndAddress(ctx context.Context, arg GetServiceByChainAndAddressParams) (Service, error)
GetServiceByID(ctx context.Context, id string) (Service, error)
GetVaultByID(ctx context.Context, id string) (Vault, error)
GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error)
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error)
GetVaultsByHandle(ctx context.Context, handle string) ([]Vault, error)
// ACCOUNT QUERIES
InsertAccount(ctx context.Context, arg InsertAccountParams) (Account, error)
// ACTIVITY QUERIES
InsertActivity(ctx context.Context, arg InsertActivityParams) (Activity, error)
// ASSET QUERIES // ASSET QUERIES
InsertAsset(ctx context.Context, arg InsertAssetParams) (Asset, error) InsertAsset(ctx context.Context, arg InsertAssetParams) (Asset, error)
// BLOCKCHAIN QUERIES // BLOCKCHAIN QUERIES
InsertBlockchain(ctx context.Context, arg InsertBlockchainParams) (Blockchain, error) InsertBlockchain(ctx context.Context, arg InsertBlockchainParams) (Blockchain, error)
// CREDENTIAL QUERIES
InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error)
// CRYPTO LISTINGS QUERIES (NEW) // CRYPTO LISTINGS QUERIES (NEW)
InsertCryptoListing(ctx context.Context, arg InsertCryptoListingParams) (CryptoListing, error) InsertCryptoListing(ctx context.Context, arg InsertCryptoListingParams) (CryptoListing, error)
// FEAR AND GREED INDEX QUERIES (NEW) // FEAR AND GREED INDEX QUERIES (NEW)
InsertFearGreedIndex(ctx context.Context, arg InsertFearGreedIndexParams) (FearGreedIndex, error) InsertFearGreedIndex(ctx context.Context, arg InsertFearGreedIndexParams) (FearGreedIndex, error)
// GLOBAL MARKET QUERIES (NEW) // GLOBAL MARKET QUERIES (NEW)
InsertGlobalMarket(ctx context.Context, arg InsertGlobalMarketParams) (GlobalMarket, error) InsertGlobalMarket(ctx context.Context, arg InsertGlobalMarketParams) (GlobalMarket, error)
// HEALTH QUERIES
InsertHealth(ctx context.Context, arg InsertHealthParams) (Health, error)
// PRICE QUERIES (UPDATED) // PRICE QUERIES (UPDATED)
InsertPrice(ctx context.Context, arg InsertPriceParams) (Price, error) InsertPrice(ctx context.Context, arg InsertPriceParams) (Price, error)
// PRICE CONVERSION QUERIES (NEW) // PRICE CONVERSION QUERIES (NEW)
InsertPriceConversion(ctx context.Context, arg InsertPriceConversionParams) (PriceConversion, error) InsertPriceConversion(ctx context.Context, arg InsertPriceConversionParams) (PriceConversion, error)
// PROFILE QUERIES
InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error)
// SERVICE QUERIES
InsertService(ctx context.Context, arg InsertServiceParams) (Service, error)
// VAULT QUERIES
InsertVault(ctx context.Context, arg InsertVaultParams) (Vault, error)
ListActivitiesByAccount(ctx context.Context, arg ListActivitiesByAccountParams) ([]Activity, error)
ListActivitiesByStatus(ctx context.Context, arg ListActivitiesByStatusParams) ([]Activity, error)
ListActivitiesByType(ctx context.Context, arg ListActivitiesByTypeParams) ([]Activity, error)
ListAllBlockchains(ctx context.Context) ([]Blockchain, error) ListAllBlockchains(ctx context.Context) ([]Blockchain, error)
ListAssetsByChain(ctx context.Context, chainID string) ([]Asset, error) ListAssetsByChain(ctx context.Context, chainID string) ([]Asset, error)
ListAssetsWithLatestPrices(ctx context.Context, arg ListAssetsWithLatestPricesParams) ([]ListAssetsWithLatestPricesRow, error) ListAssetsWithLatestPrices(ctx context.Context, arg ListAssetsWithLatestPricesParams) ([]ListAssetsWithLatestPricesRow, error)
@@ -103,34 +59,16 @@ type Querier interface {
ListBlockchainsWithMobileSupport(ctx context.Context) ([]Blockchain, error) ListBlockchainsWithMobileSupport(ctx context.Context) ([]Blockchain, error)
ListBlockchainsWithStaking(ctx context.Context) ([]Blockchain, error) ListBlockchainsWithStaking(ctx context.Context) ([]Blockchain, error)
ListCryptoListings(ctx context.Context, arg ListCryptoListingsParams) ([]CryptoListing, error) ListCryptoListings(ctx context.Context, arg ListCryptoListingsParams) ([]CryptoListing, error)
ListDelegatorAccounts(ctx context.Context) ([]Account, error)
ListFearGreedIndexHistory(ctx context.Context, arg ListFearGreedIndexHistoryParams) ([]FearGreedIndex, error) ListFearGreedIndexHistory(ctx context.Context, arg ListFearGreedIndexHistoryParams) ([]FearGreedIndex, error)
ListGlobalMarketHistory(ctx context.Context, arg ListGlobalMarketHistoryParams) ([]GlobalMarket, error) ListGlobalMarketHistory(ctx context.Context, arg ListGlobalMarketHistoryParams) ([]GlobalMarket, error)
ListHealthByChain(ctx context.Context, arg ListHealthByChainParams) ([]Health, error)
ListHealthByStatus(ctx context.Context, arg ListHealthByStatusParams) ([]Health, error)
ListHealthChecksNeedingUpdate(ctx context.Context, limit int64) ([]Health, error)
ListPriceHistoryByAssetID(ctx context.Context, arg ListPriceHistoryByAssetIDParams) ([]Price, error) ListPriceHistoryByAssetID(ctx context.Context, arg ListPriceHistoryByAssetIDParams) ([]Price, error)
ListProfiles(ctx context.Context, arg ListProfilesParams) ([]Profile, error)
ListServicesByChain(ctx context.Context, arg ListServicesByChainParams) ([]Service, error)
ListServicesByOwner(ctx context.Context, arg ListServicesByOwnerParams) ([]Service, error)
ListValidatorAccounts(ctx context.Context) ([]Account, error)
SearchBlockchains(ctx context.Context, arg SearchBlockchainsParams) ([]Blockchain, error) SearchBlockchains(ctx context.Context, arg SearchBlockchainsParams) ([]Blockchain, error)
SoftDeleteAccount(ctx context.Context, id string) error
SoftDeleteActivity(ctx context.Context, id string) error
SoftDeleteAsset(ctx context.Context, id string) error SoftDeleteAsset(ctx context.Context, id string) error
SoftDeleteBlockchain(ctx context.Context, id string) error SoftDeleteBlockchain(ctx context.Context, id string) error
SoftDeleteCredential(ctx context.Context, credentialID string) error
SoftDeleteCryptoListing(ctx context.Context, id string) error SoftDeleteCryptoListing(ctx context.Context, id string) error
SoftDeleteFearGreedIndex(ctx context.Context, id string) error SoftDeleteFearGreedIndex(ctx context.Context, id string) error
SoftDeleteGlobalMarket(ctx context.Context, id string) error SoftDeleteGlobalMarket(ctx context.Context, id string) error
SoftDeleteHealth(ctx context.Context, id string) error
SoftDeletePriceConversion(ctx context.Context, id string) error SoftDeletePriceConversion(ctx context.Context, id string) error
SoftDeleteProfile(ctx context.Context, address string) error
SoftDeleteService(ctx context.Context, id string) error
SoftDeleteVault(ctx context.Context, id string) error
UpdateAccountLabel(ctx context.Context, arg UpdateAccountLabelParams) (Account, error)
UpdateAccountSequence(ctx context.Context, arg UpdateAccountSequenceParams) (Account, error)
UpdateActivityStatus(ctx context.Context, arg UpdateActivityStatusParams) (Activity, error)
UpdateAsset(ctx context.Context, arg UpdateAssetParams) (Asset, error) UpdateAsset(ctx context.Context, arg UpdateAssetParams) (Asset, error)
UpdateBlockchain(ctx context.Context, arg UpdateBlockchainParams) (Blockchain, error) UpdateBlockchain(ctx context.Context, arg UpdateBlockchainParams) (Blockchain, error)
UpdateBlockchainDescriptions(ctx context.Context, arg UpdateBlockchainDescriptionsParams) (Blockchain, error) UpdateBlockchainDescriptions(ctx context.Context, arg UpdateBlockchainDescriptionsParams) (Blockchain, error)
@@ -142,12 +80,8 @@ type Querier interface {
UpdateCryptoListing(ctx context.Context, arg UpdateCryptoListingParams) (CryptoListing, error) UpdateCryptoListing(ctx context.Context, arg UpdateCryptoListingParams) (CryptoListing, error)
UpdateFearGreedIndex(ctx context.Context, arg UpdateFearGreedIndexParams) (FearGreedIndex, error) UpdateFearGreedIndex(ctx context.Context, arg UpdateFearGreedIndexParams) (FearGreedIndex, error)
UpdateGlobalMarket(ctx context.Context, arg UpdateGlobalMarketParams) (GlobalMarket, error) UpdateGlobalMarket(ctx context.Context, arg UpdateGlobalMarketParams) (GlobalMarket, error)
UpdateHealthCheck(ctx context.Context, arg UpdateHealthCheckParams) (Health, error)
UpdatePrice(ctx context.Context, arg UpdatePriceParams) (Price, error) UpdatePrice(ctx context.Context, arg UpdatePriceParams) (Price, error)
UpdatePriceConversion(ctx context.Context, arg UpdatePriceConversionParams) (PriceConversion, error) UpdatePriceConversion(ctx context.Context, arg UpdatePriceConversionParams) (PriceConversion, error)
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)
UpdateService(ctx context.Context, arg UpdateServiceParams) (Service, error)
UpdateVault(ctx context.Context, arg UpdateVaultParams) (Vault, error)
} }
var _ Querier = (*Queries)(nil) var _ Querier = (*Queries)(nil)

View File

@@ -1,237 +1,3 @@
-- PROFILE QUERIES
-- 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: GetProfileByHandle :one
SELECT * FROM profiles
WHERE handle = ?
AND deleted_at IS NULL
LIMIT 1;
-- name: CheckHandleExists :one
SELECT COUNT(*) > 0 as handle_exists FROM profiles
WHERE handle = ?
AND deleted_at IS NULL;
-- name: UpdateProfile :one
UPDATE profiles
SET
name = ?,
handle = ?,
updated_at = CURRENT_TIMESTAMP
WHERE address = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteProfile :exec
UPDATE profiles
SET deleted_at = CURRENT_TIMESTAMP
WHERE address = ?;
-- name: ListProfiles :many
SELECT * FROM profiles
WHERE deleted_at IS NULL
ORDER BY created_at DESC
LIMIT ? OFFSET ?;
-- VAULT QUERIES
-- name: InsertVault :one
INSERT INTO vaults (
handle,
origin,
address,
cid,
config,
session_id,
redirect_uri
) VALUES (?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetVaultByID :one
SELECT * FROM vaults
WHERE id = ?
AND deleted_at IS NULL
LIMIT 1;
-- name: GetVaultsByHandle :many
SELECT * FROM vaults
WHERE handle = ?
AND deleted_at IS NULL
ORDER BY created_at DESC;
-- 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: UpdateVault :one
UPDATE vaults
SET
config = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteVault :exec
UPDATE vaults
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- ACCOUNT QUERIES
-- name: InsertAccount :one
INSERT INTO accounts (
number,
sequence,
address,
public_key,
chain_id,
block_created,
controller,
label,
is_subsidiary,
is_validator,
is_delegator,
is_accountable
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetAccountByID :one
SELECT * FROM accounts
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountByAddress :one
SELECT * FROM accounts
WHERE address = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountsByHandle :many
SELECT * FROM accounts
WHERE handle = ? AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: GetAccountByController :one
SELECT * FROM accounts
WHERE controller = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountByPublicKey :one
SELECT * FROM accounts
WHERE public_key = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountByNumber :one
SELECT * FROM accounts
WHERE number = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountBySequence :one
SELECT * FROM accounts
WHERE sequence = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountsByChainID :many
SELECT * FROM accounts
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY sequence DESC;
-- name: GetAccountsByController :many
SELECT * FROM accounts
WHERE controller = ? AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: GetAccountsByLabel :many
SELECT * FROM accounts
WHERE label = ? AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: UpdateAccountSequence :one
UPDATE accounts
SET
sequence = ?,
updated_at = CURRENT_TIMESTAMP
WHERE address = ?
AND deleted_at IS NULL
RETURNING *;
-- name: UpdateAccountLabel :one
UPDATE accounts
SET
label = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteAccount :exec
UPDATE accounts
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- name: ListValidatorAccounts :many
SELECT * FROM accounts
WHERE is_validator = 1
AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: ListDelegatorAccounts :many
SELECT * FROM accounts
WHERE is_delegator = 1
AND deleted_at IS NULL
ORDER BY created_at DESC;
-- CREDENTIAL QUERIES
-- name: InsertCredential :one
INSERT INTO credentials (
handle,
credential_id,
authenticator_attachment,
origin,
type,
transports
) VALUES (?, ?, ?, ?, ?, ?)
RETURNING *;
-- 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 = ?;
-- ASSET QUERIES -- ASSET QUERIES
-- name: InsertAsset :one -- name: InsertAsset :one
INSERT INTO assets ( INSERT INTO assets (
@@ -570,199 +336,6 @@ UPDATE crypto_listings
SET deleted_at = CURRENT_TIMESTAMP SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?; WHERE id = ?;
-- SERVICE QUERIES
-- name: InsertService :one
INSERT INTO services (
name,
description,
chain_id,
address,
owner_address,
metadata,
status,
block_height
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetServiceByID :one
SELECT * FROM services
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetServiceByAddress :one
SELECT * FROM services
WHERE address = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetServiceByChainAndAddress :one
SELECT * FROM services
WHERE chain_id = ? AND address = ? AND deleted_at IS NULL
LIMIT 1;
-- name: ListServicesByChain :many
SELECT * FROM services
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY name ASC
LIMIT ? OFFSET ?;
-- name: ListServicesByOwner :many
SELECT * FROM services
WHERE owner_address = ? AND deleted_at IS NULL
ORDER BY created_at DESC
LIMIT ? OFFSET ?;
-- name: UpdateService :one
UPDATE services
SET
name = ?,
description = ?,
owner_address = ?,
metadata = ?,
status = ?,
block_height = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteService :exec
UPDATE services
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- ACTIVITY QUERIES
-- name: InsertActivity :one
INSERT INTO activities (
account_id,
tx_hash,
tx_type,
status,
amount,
fee,
gas_used,
gas_wanted,
memo,
block_height,
timestamp,
raw_log,
error
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetActivityByID :one
SELECT * FROM activities
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetActivityByTxHash :one
SELECT * FROM activities
WHERE tx_hash = ? AND deleted_at IS NULL
LIMIT 1;
-- name: ListActivitiesByAccount :many
SELECT * FROM activities
WHERE account_id = ? AND deleted_at IS NULL
ORDER BY timestamp DESC
LIMIT ? OFFSET ?;
-- name: ListActivitiesByType :many
SELECT * FROM activities
WHERE tx_type = ? AND deleted_at IS NULL
ORDER BY timestamp DESC
LIMIT ? OFFSET ?;
-- name: ListActivitiesByStatus :many
SELECT * FROM activities
WHERE status = ? AND deleted_at IS NULL
ORDER BY timestamp DESC
LIMIT ? OFFSET ?;
-- name: UpdateActivityStatus :one
UPDATE activities
SET
status = ?,
tx_hash = ?,
block_height = ?,
gas_used = ?,
raw_log = ?,
error = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteActivity :exec
UPDATE activities
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- HEALTH QUERIES
-- name: InsertHealth :one
INSERT INTO health (
endpoint_url,
endpoint_type,
chain_id,
status,
response_time_ms,
last_checked,
next_check,
failure_count,
success_count,
response_data,
error_message
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetHealthByID :one
SELECT * FROM health
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetHealthByEndpoint :one
SELECT * FROM health
WHERE endpoint_url = ? AND deleted_at IS NULL
ORDER BY last_checked DESC
LIMIT 1;
-- name: ListHealthByChain :many
SELECT * FROM health
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY last_checked DESC
LIMIT ? OFFSET ?;
-- name: ListHealthByStatus :many
SELECT * FROM health
WHERE status = ? AND deleted_at IS NULL
ORDER BY last_checked DESC
LIMIT ? OFFSET ?;
-- name: ListHealthChecksNeedingUpdate :many
SELECT * FROM health
WHERE next_check <= CURRENT_TIMESTAMP AND deleted_at IS NULL
ORDER BY next_check ASC
LIMIT ?;
-- name: UpdateHealthCheck :one
UPDATE health
SET
status = ?,
response_time_ms = ?,
last_checked = CURRENT_TIMESTAMP,
next_check = ?,
failure_count = CASE WHEN status = 'failed' THEN failure_count + 1 ELSE failure_count END,
success_count = CASE WHEN status = 'success' THEN success_count + 1 ELSE success_count END,
response_data = ?,
error_message = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteHealth :exec
UPDATE health
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- BLOCKCHAIN QUERIES -- BLOCKCHAIN QUERIES
-- name: InsertBlockchain :one -- name: InsertBlockchain :one
INSERT INTO blockchains ( INSERT INTO blockchains (

File diff suppressed because it is too large Load Diff

View File

@@ -14,69 +14,6 @@ CREATE TABLE assets (
UNIQUE(chain_id, symbol) 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
);
-- 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,
block_created INTEGER NOT NULL,
controller TEXT NOT NULL,
label TEXT NOT NULL,
handle 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))
);
-- 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)
);
-- 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
);
-- Prices entity based on the Alternative.me API for crypto prices -- Prices entity based on the Alternative.me API for crypto prices
CREATE TABLE prices ( CREATE TABLE prices (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
@@ -155,66 +92,6 @@ CREATE TABLE crypto_listings (
UNIQUE(api_id) UNIQUE(api_id)
); );
-- Service for Service Records sourced on chain
CREATE TABLE services (
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,
description TEXT,
chain_id TEXT NOT NULL,
address TEXT NOT NULL,
owner_address TEXT NOT NULL,
metadata TEXT CHECK(json_valid(metadata)),
status TEXT NOT NULL,
block_height INTEGER NOT NULL,
FOREIGN KEY (chain_id) REFERENCES assets(chain_id),
UNIQUE(chain_id, address)
);
-- Activity table for basic transaction broadcast activity
CREATE TABLE activities (
id TEXT PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP,
account_id TEXT NOT NULL,
tx_hash TEXT,
tx_type TEXT NOT NULL,
status TEXT NOT NULL,
amount TEXT,
fee TEXT,
gas_used INTEGER,
gas_wanted INTEGER,
memo TEXT,
block_height INTEGER,
timestamp TIMESTAMP NOT NULL,
raw_log TEXT,
error TEXT,
FOREIGN KEY (account_id) REFERENCES accounts(id)
);
-- Health table for scheduled checks for API endpoints
CREATE TABLE health (
id TEXT PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP,
endpoint_url TEXT NOT NULL,
endpoint_type TEXT NOT NULL,
chain_id TEXT,
status TEXT NOT NULL,
response_time_ms INTEGER,
last_checked TIMESTAMP NOT NULL,
next_check TIMESTAMP,
failure_count INTEGER NOT NULL DEFAULT 0,
success_count INTEGER NOT NULL DEFAULT 0,
response_data TEXT,
error_message TEXT,
FOREIGN KEY (chain_id) REFERENCES assets(chain_id)
);
-- Blockchains table to store chain configuration parameters -- Blockchains table to store chain configuration parameters
CREATE TABLE blockchains ( CREATE TABLE blockchains (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
@@ -286,25 +163,6 @@ CREATE INDEX idx_assets_symbol ON assets(symbol);
CREATE INDEX idx_assets_chain_id ON assets(chain_id); CREATE INDEX idx_assets_chain_id ON assets(chain_id);
CREATE INDEX idx_assets_deleted_at ON assets(deleted_at); 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_accounts_address ON accounts(address);
CREATE INDEX idx_accounts_chain_id ON accounts(chain_id);
CREATE INDEX idx_accounts_block_created ON accounts(block_created);
CREATE INDEX idx_accounts_label ON accounts(label);
CREATE INDEX idx_accounts_controller ON accounts(controller);
CREATE INDEX idx_accounts_deleted_at ON accounts(deleted_at);
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_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);
CREATE INDEX idx_prices_asset_id ON prices(asset_id); CREATE INDEX idx_prices_asset_id ON prices(asset_id);
CREATE INDEX idx_prices_rank ON prices(rank); CREATE INDEX idx_prices_rank ON prices(rank);
CREATE INDEX idx_prices_last_updated ON prices(last_updated); CREATE INDEX idx_prices_last_updated ON prices(last_updated);
@@ -326,29 +184,6 @@ CREATE INDEX idx_crypto_listings_symbol ON crypto_listings(symbol);
CREATE INDEX idx_crypto_listings_website_slug ON crypto_listings(website_slug); CREATE INDEX idx_crypto_listings_website_slug ON crypto_listings(website_slug);
CREATE INDEX idx_crypto_listings_deleted_at ON crypto_listings(deleted_at); CREATE INDEX idx_crypto_listings_deleted_at ON crypto_listings(deleted_at);
CREATE INDEX idx_services_name ON services(name);
CREATE INDEX idx_services_chain_id ON services(chain_id);
CREATE INDEX idx_services_address ON services(address);
CREATE INDEX idx_services_owner_address ON services(owner_address);
CREATE INDEX idx_services_status ON services(status);
CREATE INDEX idx_services_deleted_at ON services(deleted_at);
CREATE INDEX idx_activities_account_id ON activities(account_id);
CREATE INDEX idx_activities_tx_hash ON activities(tx_hash);
CREATE INDEX idx_activities_tx_type ON activities(tx_type);
CREATE INDEX idx_activities_status ON activities(status);
CREATE INDEX idx_activities_timestamp ON activities(timestamp);
CREATE INDEX idx_activities_block_height ON activities(block_height);
CREATE INDEX idx_activities_deleted_at ON activities(deleted_at);
CREATE INDEX idx_health_endpoint_url ON health(endpoint_url);
CREATE INDEX idx_health_endpoint_type ON health(endpoint_type);
CREATE INDEX idx_health_chain_id ON health(chain_id);
CREATE INDEX idx_health_status ON health(status);
CREATE INDEX idx_health_last_checked ON health(last_checked);
CREATE INDEX idx_health_next_check ON health(next_check);
CREATE INDEX idx_health_deleted_at ON health(deleted_at);
CREATE INDEX idx_blockchains_chain_name ON blockchains(chain_name); CREATE INDEX idx_blockchains_chain_name ON blockchains(chain_name);
CREATE INDEX idx_blockchains_chain_id_cosmos ON blockchains(chain_id_cosmos); CREATE INDEX idx_blockchains_chain_id_cosmos ON blockchains(chain_id_cosmos);
CREATE INDEX idx_blockchains_chain_id_evm ON blockchains(chain_id_evm); CREATE INDEX idx_blockchains_chain_id_evm ON blockchains(chain_id_evm);

34
internal/sink/sqlc.yaml Normal file
View File

@@ -0,0 +1,34 @@
version: "2"
sql:
# Activity DB - User to User Interactions
- engine: "sqlite"
queries: "./activity/query.sql"
schema: "./activity/schema.sql"
gen:
go:
emit_interface: true
emit_json_tags: true
package: "activity"
out: "./activity"
# Network DB - Blockchain Parameters and Asset Metadata
- engine: "sqlite"
queries: "./network/query.sql"
schema: "./network/schema.sql"
gen:
go:
emit_interface: true
emit_json_tags: true
package: "network"
out: "./network"
# Users DB - Accounts, Profiles, and Vault Metadata
- engine: "sqlite"
queries: "./users/query.sql"
schema: "./users/schema.sql"
gen:
go:
emit_interface: true
emit_json_tags: true
package: "users"
out: "./users"

View File

@@ -1,8 +1,8 @@
// Code generated by sqlc. DO NOT EDIT. // Code generated by sqlc. DO NOT EDIT.
// versions: // versions:
// sqlc v1.28.0 // sqlc v1.29.0
package models package users
import ( import (
"context" "context"

View File

@@ -0,0 +1,68 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package users
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"`
BlockCreated int64 `json:"block_created"`
Controller string `json:"controller"`
Label string `json:"label"`
Handle string `json:"handle"`
IsSubsidiary bool `json:"is_subsidiary"`
IsValidator bool `json:"is_validator"`
IsDelegator bool `json:"is_delegator"`
IsAccountable bool `json:"is_accountable"`
}
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 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"`
}

View File

@@ -0,0 +1,53 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package users
import (
"context"
)
type Querier interface {
CheckHandleExists(ctx context.Context, handle string) (bool, error)
GetAccountByAddress(ctx context.Context, address string) (Account, error)
GetAccountByController(ctx context.Context, controller string) (Account, error)
GetAccountByID(ctx context.Context, id string) (Account, error)
GetAccountByNumber(ctx context.Context, number int64) (Account, error)
GetAccountByPublicKey(ctx context.Context, publicKey string) (Account, error)
GetAccountBySequence(ctx context.Context, sequence int64) (Account, error)
GetAccountsByChainID(ctx context.Context, chainID string) ([]Account, error)
GetAccountsByController(ctx context.Context, controller string) ([]Account, error)
GetAccountsByHandle(ctx context.Context, handle string) ([]Account, error)
GetAccountsByLabel(ctx context.Context, label string) ([]Account, error)
GetCredentialByID(ctx context.Context, credentialID string) (Credential, error)
GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, 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)
GetVaultByID(ctx context.Context, id string) (Vault, error)
GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error)
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error)
GetVaultsByHandle(ctx context.Context, handle string) ([]Vault, error)
// ACCOUNT QUERIES
InsertAccount(ctx context.Context, arg InsertAccountParams) (Account, error)
// CREDENTIAL QUERIES
InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error)
// PROFILE QUERIES
InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error)
// VAULT QUERIES
InsertVault(ctx context.Context, arg InsertVaultParams) (Vault, error)
ListDelegatorAccounts(ctx context.Context) ([]Account, error)
ListProfiles(ctx context.Context, arg ListProfilesParams) ([]Profile, error)
ListValidatorAccounts(ctx context.Context) ([]Account, error)
SoftDeleteAccount(ctx context.Context, id string) error
SoftDeleteCredential(ctx context.Context, credentialID string) error
SoftDeleteProfile(ctx context.Context, address string) error
SoftDeleteVault(ctx context.Context, id string) error
UpdateAccountLabel(ctx context.Context, arg UpdateAccountLabelParams) (Account, error)
UpdateAccountSequence(ctx context.Context, arg UpdateAccountSequenceParams) (Account, error)
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)
UpdateVault(ctx context.Context, arg UpdateVaultParams) (Vault, error)
}
var _ Querier = (*Queries)(nil)

View File

@@ -0,0 +1,234 @@
-- PROFILE QUERIES
-- 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: GetProfileByHandle :one
SELECT * FROM profiles
WHERE handle = ?
AND deleted_at IS NULL
LIMIT 1;
-- name: CheckHandleExists :one
SELECT COUNT(*) > 0 as handle_exists FROM profiles
WHERE handle = ?
AND deleted_at IS NULL;
-- name: UpdateProfile :one
UPDATE profiles
SET
name = ?,
handle = ?,
updated_at = CURRENT_TIMESTAMP
WHERE address = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteProfile :exec
UPDATE profiles
SET deleted_at = CURRENT_TIMESTAMP
WHERE address = ?;
-- name: ListProfiles :many
SELECT * FROM profiles
WHERE deleted_at IS NULL
ORDER BY created_at DESC
LIMIT ? OFFSET ?;
-- VAULT QUERIES
-- name: InsertVault :one
INSERT INTO vaults (
handle,
origin,
address,
cid,
config,
session_id,
redirect_uri
) VALUES (?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetVaultByID :one
SELECT * FROM vaults
WHERE id = ?
AND deleted_at IS NULL
LIMIT 1;
-- name: GetVaultsByHandle :many
SELECT * FROM vaults
WHERE handle = ?
AND deleted_at IS NULL
ORDER BY created_at DESC;
-- 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: UpdateVault :one
UPDATE vaults
SET
config = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteVault :exec
UPDATE vaults
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- ACCOUNT QUERIES
-- name: InsertAccount :one
INSERT INTO accounts (
number,
sequence,
address,
public_key,
chain_id,
block_created,
controller,
label,
is_subsidiary,
is_validator,
is_delegator,
is_accountable
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: GetAccountByID :one
SELECT * FROM accounts
WHERE id = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountByAddress :one
SELECT * FROM accounts
WHERE address = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountsByHandle :many
SELECT * FROM accounts
WHERE handle = ? AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: GetAccountByController :one
SELECT * FROM accounts
WHERE controller = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountByPublicKey :one
SELECT * FROM accounts
WHERE public_key = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountByNumber :one
SELECT * FROM accounts
WHERE number = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountBySequence :one
SELECT * FROM accounts
WHERE sequence = ? AND deleted_at IS NULL
LIMIT 1;
-- name: GetAccountsByChainID :many
SELECT * FROM accounts
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY sequence DESC;
-- name: GetAccountsByController :many
SELECT * FROM accounts
WHERE controller = ? AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: GetAccountsByLabel :many
SELECT * FROM accounts
WHERE label = ? AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: UpdateAccountSequence :one
UPDATE accounts
SET
sequence = ?,
updated_at = CURRENT_TIMESTAMP
WHERE address = ?
AND deleted_at IS NULL
RETURNING *;
-- name: UpdateAccountLabel :one
UPDATE accounts
SET
label = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING *;
-- name: SoftDeleteAccount :exec
UPDATE accounts
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- name: ListValidatorAccounts :many
SELECT * FROM accounts
WHERE is_validator = 1
AND deleted_at IS NULL
ORDER BY created_at DESC;
-- name: ListDelegatorAccounts :many
SELECT * FROM accounts
WHERE is_delegator = 1
AND deleted_at IS NULL
ORDER BY created_at DESC;
-- CREDENTIAL QUERIES
-- name: InsertCredential :one
INSERT INTO credentials (
handle,
credential_id,
authenticator_attachment,
origin,
type,
transports
) VALUES (?, ?, ?, ?, ?, ?)
RETURNING *;
-- 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 = ?;

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More