From fbbd9d43874f55d0bdcad4e7eac1018073d6dcfe Mon Sep 17 00:00:00 2001 From: Prad N Date: Thu, 3 Apr 2025 23:19:22 -0400 Subject: [PATCH] refactor: migrate to modular architecture for improved scalability --- .taskfiles/Generate.yml | 2 +- x/account/controller.go | 1 - x/account/db.go | 31 -- x/account/models.go | 27 -- x/account/querier.go | 25 -- x/account/query.sql | 76 ----- x/account/query.sql.go | 452 ------------------------- x/account/schema.sql | 24 -- x/account/view.templ | 11 - x/account/view_templ.go | 44 --- x/asset/controller.go | 1 - x/asset/schema.sql | 22 -- x/balance/query.sql | 48 --- x/credential/controller.go | 1 - x/credential/query.sql | 48 --- x/credential/schema.sql | 23 -- x/credential/sqlc.yaml | 11 - x/credential/view.templ | 11 - x/credential/view_templ.go | 44 --- x/device/controller.go | 1 - x/device/query.sql | 48 --- x/device/schema.sql | 23 -- x/device/sqlc.yaml | 11 - x/device/view_templ.go | 44 --- x/identity/controller.go | 1 + x/identity/query.sql | 183 ++++++++++ x/identity/schema.sql | 72 ++++ x/{asset => identity}/sqlc.yaml | 4 +- x/{device => identity}/view.templ | 2 +- x/{asset => identity}/view_templ.go | 2 +- x/{balance => portfolio}/controller.go | 0 x/{asset => portfolio}/query.sql | 48 +++ x/{balance => portfolio}/schema.sql | 21 ++ x/{balance => portfolio}/sqlc.yaml | 2 +- x/{balance => portfolio}/view.templ | 2 +- x/{balance => portfolio}/view_templ.go | 0 x/profile/controller.go | 1 - x/profile/query.sql | 48 --- x/profile/schema.sql | 23 -- x/profile/sqlc.yaml | 11 - x/profile/view.templ | 11 - x/profile/view_templ.go | 44 --- x/session/controller.go | 1 - x/session/query.sql | 48 --- x/session/schema.sql | 23 -- x/session/sqlc.yaml | 11 - x/session/view.templ | 11 - x/user/controller.go | 1 + x/user/query.sql | 116 +++++++ x/user/schema.sql | 62 ++++ x/{account => user}/sqlc.yaml | 2 +- x/{asset => user}/view.templ | 2 +- x/{session => user}/view_templ.go | 0 x/vault/controller.go | 1 - x/vault/query.sql | 13 - x/vault/schema.sql | 18 - x/vault/sqlc.yaml | 11 - x/vault/view.templ | 11 - x/vault/view_templ.go | 44 --- 59 files changed, 513 insertions(+), 1366 deletions(-) delete mode 100644 x/account/controller.go delete mode 100644 x/account/db.go delete mode 100644 x/account/models.go delete mode 100644 x/account/querier.go delete mode 100644 x/account/query.sql delete mode 100644 x/account/query.sql.go delete mode 100644 x/account/schema.sql delete mode 100644 x/account/view.templ delete mode 100644 x/account/view_templ.go delete mode 100644 x/asset/controller.go delete mode 100644 x/asset/schema.sql delete mode 100644 x/balance/query.sql delete mode 100644 x/credential/controller.go delete mode 100644 x/credential/query.sql delete mode 100644 x/credential/schema.sql delete mode 100644 x/credential/sqlc.yaml delete mode 100644 x/credential/view.templ delete mode 100644 x/credential/view_templ.go delete mode 100644 x/device/controller.go delete mode 100644 x/device/query.sql delete mode 100644 x/device/schema.sql delete mode 100644 x/device/sqlc.yaml delete mode 100644 x/device/view_templ.go create mode 100644 x/identity/controller.go create mode 100644 x/identity/query.sql create mode 100644 x/identity/schema.sql rename x/{asset => identity}/sqlc.yaml (76%) rename x/{device => identity}/view.templ (88%) rename x/{asset => identity}/view_templ.go (98%) rename x/{balance => portfolio}/controller.go (100%) rename x/{asset => portfolio}/query.sql (58%) rename x/{balance => portfolio}/schema.sql (60%) rename x/{balance => portfolio}/sqlc.yaml (88%) rename x/{balance => portfolio}/view.templ (87%) rename x/{balance => portfolio}/view_templ.go (100%) delete mode 100644 x/profile/controller.go delete mode 100644 x/profile/query.sql delete mode 100644 x/profile/schema.sql delete mode 100644 x/profile/sqlc.yaml delete mode 100644 x/profile/view.templ delete mode 100644 x/profile/view_templ.go delete mode 100644 x/session/controller.go delete mode 100644 x/session/query.sql delete mode 100644 x/session/schema.sql delete mode 100644 x/session/sqlc.yaml delete mode 100644 x/session/view.templ create mode 100644 x/user/controller.go create mode 100644 x/user/query.sql create mode 100644 x/user/schema.sql rename x/{account => user}/sqlc.yaml (87%) rename x/{asset => user}/view.templ (90%) rename x/{session => user}/view_templ.go (100%) delete mode 100644 x/vault/controller.go delete mode 100644 x/vault/query.sql delete mode 100644 x/vault/schema.sql delete mode 100644 x/vault/sqlc.yaml delete mode 100644 x/vault/view.templ delete mode 100644 x/vault/view_templ.go diff --git a/.taskfiles/Generate.yml b/.taskfiles/Generate.yml index e0ac713..bcfb34f 100644 --- a/.taskfiles/Generate.yml +++ b/.taskfiles/Generate.yml @@ -41,7 +41,7 @@ tasks: internal: true requires: vars: [PATH] - dir: "{{.PATH}}" + dir: "{{.ROOT_DIR}}/{{.PATH}}" sources: - "**/query.sql" - "**/schema.sql" diff --git a/x/account/controller.go b/x/account/controller.go deleted file mode 100644 index 0bc7635..0000000 --- a/x/account/controller.go +++ /dev/null @@ -1 +0,0 @@ -package account diff --git a/x/account/db.go b/x/account/db.go deleted file mode 100644 index 66b6cd4..0000000 --- a/x/account/db.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 - -package account - -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, - } -} diff --git a/x/account/models.go b/x/account/models.go deleted file mode 100644 index 59d8438..0000000 --- a/x/account/models.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 - -package account - -import ( - "database/sql" - "time" -) - -type Account struct { - ID string `json:"id"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` - DeletedAt sql.NullTime `json:"deleted_at"` - Number int64 `json:"number"` - Sequence int64 `json:"sequence"` - Address string `json:"address"` - PublicKey string `json:"public_key"` - ChainID string `json:"chain_id"` - Controller string `json:"controller"` - IsSubsidiary bool `json:"is_subsidiary"` - IsValidator bool `json:"is_validator"` - IsDelegator bool `json:"is_delegator"` - IsAccountable bool `json:"is_accountable"` -} diff --git a/x/account/querier.go b/x/account/querier.go deleted file mode 100644 index 5fed80c..0000000 --- a/x/account/querier.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 - -package account - -import ( - "context" -) - -type Querier interface { - CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error) - GetAccountByAddress(ctx context.Context, address string) (Account, error) - GetAccountByID(ctx context.Context, id string) (Account, error) - GetAccountsByChainID(ctx context.Context, chainID string) ([]Account, error) - GetAccountsByController(ctx context.Context, controller string) ([]Account, error) - GetDelegatorAccounts(ctx context.Context) ([]Account, error) - GetValidatorAccounts(ctx context.Context) ([]Account, error) - ListAccounts(ctx context.Context) ([]Account, error) - SoftDeleteAccount(ctx context.Context, id string) error - UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error) - UpdateAccountSequence(ctx context.Context, arg UpdateAccountSequenceParams) (Account, error) -} - -var _ Querier = (*Queries)(nil) diff --git a/x/account/query.sql b/x/account/query.sql deleted file mode 100644 index 6a16fe9..0000000 --- a/x/account/query.sql +++ /dev/null @@ -1,76 +0,0 @@ --- name: CreateAccount :one -INSERT INTO accounts ( - id, - number, - sequence, - address, - public_key, - chain_id, - controller, - 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: GetAccountsByChainID :many -SELECT * FROM accounts -WHERE chain_id = ? AND deleted_at IS NULL -ORDER BY number; - --- name: ListAccounts :many -SELECT * FROM accounts -WHERE deleted_at IS NULL -ORDER BY chain_id, number; - --- name: UpdateAccountSequence :one -UPDATE accounts -SET - sequence = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING *; - --- name: UpdateAccount :one -UPDATE accounts -SET - public_key = ?, - controller = ?, - is_subsidiary = ?, - is_validator = ?, - is_delegator = ?, - is_accountable = ?, - 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: GetAccountsByController :many -SELECT * FROM accounts -WHERE controller = ? AND deleted_at IS NULL -ORDER BY chain_id, number; - --- name: GetValidatorAccounts :many -SELECT * FROM accounts -WHERE is_validator = true AND deleted_at IS NULL -ORDER BY chain_id, number; - --- name: GetDelegatorAccounts :many -SELECT * FROM accounts -WHERE is_delegator = true AND deleted_at IS NULL -ORDER BY chain_id, number; diff --git a/x/account/query.sql.go b/x/account/query.sql.go deleted file mode 100644 index b56bd3c..0000000 --- a/x/account/query.sql.go +++ /dev/null @@ -1,452 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: query.sql - -package account - -import ( - "context" -) - -const createAccount = `-- name: CreateAccount :one -INSERT INTO accounts ( - id, - number, - sequence, - address, - public_key, - chain_id, - controller, - is_subsidiary, - is_validator, - is_delegator, - is_accountable -) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) -RETURNING id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable -` - -type CreateAccountParams struct { - ID string `json:"id"` - Number int64 `json:"number"` - Sequence int64 `json:"sequence"` - Address string `json:"address"` - PublicKey string `json:"public_key"` - ChainID string `json:"chain_id"` - Controller string `json:"controller"` - IsSubsidiary bool `json:"is_subsidiary"` - IsValidator bool `json:"is_validator"` - IsDelegator bool `json:"is_delegator"` - IsAccountable bool `json:"is_accountable"` -} - -func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error) { - row := q.db.QueryRowContext(ctx, createAccount, - arg.ID, - arg.Number, - arg.Sequence, - arg.Address, - arg.PublicKey, - arg.ChainID, - arg.Controller, - arg.IsSubsidiary, - arg.IsValidator, - arg.IsDelegator, - arg.IsAccountable, - ) - var i Account - err := row.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ) - return i, err -} - -const getAccountByAddress = `-- name: GetAccountByAddress :one -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE address = ? AND deleted_at IS NULL -LIMIT 1 -` - -func (q *Queries) GetAccountByAddress(ctx context.Context, address string) (Account, error) { - row := q.db.QueryRowContext(ctx, getAccountByAddress, address) - var i Account - err := row.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ) - return i, err -} - -const getAccountByID = `-- name: GetAccountByID :one -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE id = ? AND deleted_at IS NULL -LIMIT 1 -` - -func (q *Queries) GetAccountByID(ctx context.Context, id string) (Account, error) { - row := q.db.QueryRowContext(ctx, getAccountByID, id) - var i Account - err := row.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ) - return i, err -} - -const getAccountsByChainID = `-- name: GetAccountsByChainID :many -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE chain_id = ? AND deleted_at IS NULL -ORDER BY number -` - -func (q *Queries) GetAccountsByChainID(ctx context.Context, chainID string) ([]Account, error) { - rows, err := q.db.QueryContext(ctx, getAccountsByChainID, chainID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Account - for rows.Next() { - var i Account - if err := rows.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getAccountsByController = `-- name: GetAccountsByController :many -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE controller = ? AND deleted_at IS NULL -ORDER BY chain_id, number -` - -func (q *Queries) GetAccountsByController(ctx context.Context, controller string) ([]Account, error) { - rows, err := q.db.QueryContext(ctx, getAccountsByController, controller) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Account - for rows.Next() { - var i Account - if err := rows.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getDelegatorAccounts = `-- name: GetDelegatorAccounts :many -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE is_delegator = true AND deleted_at IS NULL -ORDER BY chain_id, number -` - -func (q *Queries) GetDelegatorAccounts(ctx context.Context) ([]Account, error) { - rows, err := q.db.QueryContext(ctx, getDelegatorAccounts) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Account - for rows.Next() { - var i Account - if err := rows.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getValidatorAccounts = `-- name: GetValidatorAccounts :many -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE is_validator = true AND deleted_at IS NULL -ORDER BY chain_id, number -` - -func (q *Queries) GetValidatorAccounts(ctx context.Context) ([]Account, error) { - rows, err := q.db.QueryContext(ctx, getValidatorAccounts) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Account - for rows.Next() { - var i Account - if err := rows.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const listAccounts = `-- name: ListAccounts :many -SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts -WHERE deleted_at IS NULL -ORDER BY chain_id, number -` - -func (q *Queries) ListAccounts(ctx context.Context) ([]Account, error) { - rows, err := q.db.QueryContext(ctx, listAccounts) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Account - for rows.Next() { - var i Account - if err := rows.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const softDeleteAccount = `-- name: SoftDeleteAccount :exec -UPDATE accounts -SET deleted_at = CURRENT_TIMESTAMP -WHERE id = ? -` - -func (q *Queries) SoftDeleteAccount(ctx context.Context, id string) error { - _, err := q.db.ExecContext(ctx, softDeleteAccount, id) - return err -} - -const updateAccount = `-- name: UpdateAccount :one -UPDATE accounts -SET - public_key = ?, - controller = ?, - is_subsidiary = ?, - is_validator = ?, - is_delegator = ?, - is_accountable = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable -` - -type UpdateAccountParams struct { - PublicKey string `json:"public_key"` - Controller string `json:"controller"` - IsSubsidiary bool `json:"is_subsidiary"` - IsValidator bool `json:"is_validator"` - IsDelegator bool `json:"is_delegator"` - IsAccountable bool `json:"is_accountable"` - ID string `json:"id"` -} - -func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error) { - row := q.db.QueryRowContext(ctx, updateAccount, - arg.PublicKey, - arg.Controller, - arg.IsSubsidiary, - arg.IsValidator, - arg.IsDelegator, - arg.IsAccountable, - arg.ID, - ) - var i Account - err := row.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ) - return i, err -} - -const updateAccountSequence = `-- name: UpdateAccountSequence :one -UPDATE accounts -SET - sequence = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, controller, is_subsidiary, is_validator, is_delegator, is_accountable -` - -type UpdateAccountSequenceParams struct { - Sequence int64 `json:"sequence"` - ID string `json:"id"` -} - -func (q *Queries) UpdateAccountSequence(ctx context.Context, arg UpdateAccountSequenceParams) (Account, error) { - row := q.db.QueryRowContext(ctx, updateAccountSequence, arg.Sequence, arg.ID) - var i Account - err := row.Scan( - &i.ID, - &i.CreatedAt, - &i.UpdatedAt, - &i.DeletedAt, - &i.Number, - &i.Sequence, - &i.Address, - &i.PublicKey, - &i.ChainID, - &i.Controller, - &i.IsSubsidiary, - &i.IsValidator, - &i.IsDelegator, - &i.IsAccountable, - ) - return i, err -} diff --git a/x/account/schema.sql b/x/account/schema.sql deleted file mode 100644 index a921d9f..0000000 --- a/x/account/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ - --- 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, - chain_id TEXT NOT NULL, - controller TEXT NOT NULL, - is_subsidiary BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_subsidiary IN (0,1)), - is_validator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_validator IN (0,1)), - is_delegator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegator IN (0,1)), - is_accountable BOOLEAN NOT NULL DEFAULT TRUE CHECK(is_accountable IN (0,1)) -); - -CREATE INDEX idx_accounts_address ON accounts(address); -CREATE INDEX idx_accounts_chain_id ON accounts(chain_id); -CREATE INDEX idx_accounts_deleted_at ON accounts(deleted_at); - - diff --git a/x/account/view.templ b/x/account/view.templ deleted file mode 100644 index a7e091b..0000000 --- a/x/account/view.templ +++ /dev/null @@ -1,11 +0,0 @@ -package account - -func View() templ.Component { - return initialAccountView() -} - -templ initialAccountView() { -
-

Account

-
-} diff --git a/x/account/view_templ.go b/x/account/view_templ.go deleted file mode 100644 index b2e7b27..0000000 --- a/x/account/view_templ.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.857 -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 View() templ.Component { - return initialAccountView() -} - -func initialAccountView() 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, "

Account

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/x/asset/controller.go b/x/asset/controller.go deleted file mode 100644 index 29bdbf9..0000000 --- a/x/asset/controller.go +++ /dev/null @@ -1 +0,0 @@ -package asset diff --git a/x/asset/schema.sql b/x/asset/schema.sql deleted file mode 100644 index 9d86fae..0000000 --- a/x/asset/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ - --- Assets represent tokens and coins -CREATE TABLE assets ( - id TEXT PRIMARY KEY, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - deleted_at TIMESTAMP, - name TEXT NOT NULL, - symbol TEXT NOT NULL, - decimals INTEGER NOT NULL CHECK(decimals >= 0), - chain_id TEXT NOT NULL, - channel TEXT NOT NULL, - asset_type TEXT NOT NULL, - coingecko_id TEXT, - UNIQUE(chain_id, symbol) -); - -CREATE INDEX idx_assets_symbol ON assets(symbol); -CREATE INDEX idx_assets_chain_id ON assets(chain_id); -CREATE INDEX idx_assets_deleted_at ON assets(deleted_at); - - diff --git a/x/balance/query.sql b/x/balance/query.sql deleted file mode 100644 index 21f970b..0000000 --- a/x/balance/query.sql +++ /dev/null @@ -1,48 +0,0 @@ - --- Balance table methods --- name: CreateBalance :one -INSERT INTO balances ( - id, - account_id, - asset_id, - amount, - last_updated_height, - is_delegated, - is_staked, - is_vesting -) VALUES (?, ?, ?, ?, ?, ?, ?, ?) -RETURNING *; - --- name: GetBalanceByID :one -SELECT * FROM balances -WHERE id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: GetBalanceByAccountAndAsset :one -SELECT * FROM balances -WHERE account_id = ? AND asset_id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: ListBalancesByAccount :many -SELECT * FROM balances -WHERE account_id = ? AND deleted_at IS NULL -ORDER BY asset_id; - --- name: UpdateBalance :one -UPDATE balances -SET - amount = ?, - last_updated_height = ?, - is_delegated = ?, - is_staked = ?, - is_vesting = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING *; - --- name: SoftDeleteBalance :exec -UPDATE balances -SET deleted_at = CURRENT_TIMESTAMP -WHERE id = ?; - - diff --git a/x/credential/controller.go b/x/credential/controller.go deleted file mode 100644 index 9aa9396..0000000 --- a/x/credential/controller.go +++ /dev/null @@ -1 +0,0 @@ -package credential diff --git a/x/credential/query.sql b/x/credential/query.sql deleted file mode 100644 index 21f970b..0000000 --- a/x/credential/query.sql +++ /dev/null @@ -1,48 +0,0 @@ - --- Balance table methods --- name: CreateBalance :one -INSERT INTO balances ( - id, - account_id, - asset_id, - amount, - last_updated_height, - is_delegated, - is_staked, - is_vesting -) VALUES (?, ?, ?, ?, ?, ?, ?, ?) -RETURNING *; - --- name: GetBalanceByID :one -SELECT * FROM balances -WHERE id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: GetBalanceByAccountAndAsset :one -SELECT * FROM balances -WHERE account_id = ? AND asset_id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: ListBalancesByAccount :many -SELECT * FROM balances -WHERE account_id = ? AND deleted_at IS NULL -ORDER BY asset_id; - --- name: UpdateBalance :one -UPDATE balances -SET - amount = ?, - last_updated_height = ?, - is_delegated = ?, - is_staked = ?, - is_vesting = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING *; - --- name: SoftDeleteBalance :exec -UPDATE balances -SET deleted_at = CURRENT_TIMESTAMP -WHERE id = ?; - - diff --git a/x/credential/schema.sql b/x/credential/schema.sql deleted file mode 100644 index 13fc1da..0000000 --- a/x/credential/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Balances track asset holdings for accounts -CREATE TABLE balances ( - 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, - asset_id TEXT NOT NULL, - amount TEXT NOT NULL, -- Stored as string to handle large decimal numbers precisely - last_updated_height INTEGER NOT NULL DEFAULT 0, - is_delegated BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegated IN (0,1)), - is_staked BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_staked IN (0,1)), - is_vesting BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_vesting IN (0,1)), - FOREIGN KEY (account_id) REFERENCES accounts(id), - FOREIGN KEY (asset_id) REFERENCES assets(id), - UNIQUE(account_id, asset_id) -); - -CREATE INDEX idx_balances_account_id ON balances(account_id); -CREATE INDEX idx_balances_asset_id ON balances(asset_id); -CREATE INDEX idx_balances_deleted_at ON balances(deleted_at); - - diff --git a/x/credential/sqlc.yaml b/x/credential/sqlc.yaml deleted file mode 100644 index 7271ed0..0000000 --- a/x/credential/sqlc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "2" -sql: - - engine: "sqlite" - queries: "query.sql" - schema: "schema.sql" - gen: - go: - emit_interface: true - emit_json_tags: true - package: "credential" - out: "orm.gen.go" diff --git a/x/credential/view.templ b/x/credential/view.templ deleted file mode 100644 index 78a81b5..0000000 --- a/x/credential/view.templ +++ /dev/null @@ -1,11 +0,0 @@ -package credential - -func View() templ.Component { - return initialAssetView() -} - -templ initialAssetView() { -
-

Account

-
-} diff --git a/x/credential/view_templ.go b/x/credential/view_templ.go deleted file mode 100644 index 31e9d30..0000000 --- a/x/credential/view_templ.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.857 -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 View() templ.Component { - return initialAssetView() -} - -func initialAssetView() 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, "

Account

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/x/device/controller.go b/x/device/controller.go deleted file mode 100644 index 76a9bfa..0000000 --- a/x/device/controller.go +++ /dev/null @@ -1 +0,0 @@ -package device diff --git a/x/device/query.sql b/x/device/query.sql deleted file mode 100644 index 21f970b..0000000 --- a/x/device/query.sql +++ /dev/null @@ -1,48 +0,0 @@ - --- Balance table methods --- name: CreateBalance :one -INSERT INTO balances ( - id, - account_id, - asset_id, - amount, - last_updated_height, - is_delegated, - is_staked, - is_vesting -) VALUES (?, ?, ?, ?, ?, ?, ?, ?) -RETURNING *; - --- name: GetBalanceByID :one -SELECT * FROM balances -WHERE id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: GetBalanceByAccountAndAsset :one -SELECT * FROM balances -WHERE account_id = ? AND asset_id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: ListBalancesByAccount :many -SELECT * FROM balances -WHERE account_id = ? AND deleted_at IS NULL -ORDER BY asset_id; - --- name: UpdateBalance :one -UPDATE balances -SET - amount = ?, - last_updated_height = ?, - is_delegated = ?, - is_staked = ?, - is_vesting = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING *; - --- name: SoftDeleteBalance :exec -UPDATE balances -SET deleted_at = CURRENT_TIMESTAMP -WHERE id = ?; - - diff --git a/x/device/schema.sql b/x/device/schema.sql deleted file mode 100644 index 13fc1da..0000000 --- a/x/device/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Balances track asset holdings for accounts -CREATE TABLE balances ( - 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, - asset_id TEXT NOT NULL, - amount TEXT NOT NULL, -- Stored as string to handle large decimal numbers precisely - last_updated_height INTEGER NOT NULL DEFAULT 0, - is_delegated BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegated IN (0,1)), - is_staked BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_staked IN (0,1)), - is_vesting BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_vesting IN (0,1)), - FOREIGN KEY (account_id) REFERENCES accounts(id), - FOREIGN KEY (asset_id) REFERENCES assets(id), - UNIQUE(account_id, asset_id) -); - -CREATE INDEX idx_balances_account_id ON balances(account_id); -CREATE INDEX idx_balances_asset_id ON balances(asset_id); -CREATE INDEX idx_balances_deleted_at ON balances(deleted_at); - - diff --git a/x/device/sqlc.yaml b/x/device/sqlc.yaml deleted file mode 100644 index 4212bd1..0000000 --- a/x/device/sqlc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "2" -sql: - - engine: "sqlite" - queries: "query.sql" - schema: "schema.sql" - gen: - go: - emit_interface: true - emit_json_tags: true - package: "device" - out: "orm.gen.go" diff --git a/x/device/view_templ.go b/x/device/view_templ.go deleted file mode 100644 index 164f222..0000000 --- a/x/device/view_templ.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.857 -package device - -//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 View() templ.Component { - return initialAssetView() -} - -func initialAssetView() 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, "

Account

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/x/identity/controller.go b/x/identity/controller.go new file mode 100644 index 0000000..cca56a0 --- /dev/null +++ b/x/identity/controller.go @@ -0,0 +1 @@ +package identity diff --git a/x/identity/query.sql b/x/identity/query.sql new file mode 100644 index 0000000..3471935 --- /dev/null +++ b/x/identity/query.sql @@ -0,0 +1,183 @@ +-- name: CreateAccount :one +INSERT INTO accounts ( + id, + number, + sequence, + address, + public_key, + chain_id, + controller, + 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: GetAccountsByChainID :many +SELECT * FROM accounts +WHERE chain_id = ? AND deleted_at IS NULL +ORDER BY number; + +-- name: ListAccounts :many +SELECT * FROM accounts +WHERE deleted_at IS NULL +ORDER BY chain_id, number; + +-- name: UpdateAccountSequence :one +UPDATE accounts +SET + sequence = ?, + updated_at = CURRENT_TIMESTAMP +WHERE id = ? AND deleted_at IS NULL +RETURNING *; + +-- name: UpdateAccount :one +UPDATE accounts +SET + public_key = ?, + controller = ?, + is_subsidiary = ?, + is_validator = ?, + is_delegator = ?, + is_accountable = ?, + 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: GetAccountsByController :many +SELECT * FROM accounts +WHERE controller = ? AND deleted_at IS NULL +ORDER BY chain_id, number; + +-- name: GetValidatorAccounts :many +SELECT * FROM accounts +WHERE is_validator = true AND deleted_at IS NULL +ORDER BY chain_id, number; + +-- name: GetDelegatorAccounts :many +SELECT * FROM accounts +WHERE is_delegator = true AND deleted_at IS NULL +ORDER BY chain_id, number; + +-- name: InsertCredential :one +INSERT INTO credentials ( + handle, + credential_id, + 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 = ?; + + +-- Additional credential methods for better integration with devices +-- name: UpdateCredential :one +UPDATE credentials +SET + authenticator_attachment = ?, + transports = ?, + updated_at = CURRENT_TIMESTAMP +WHERE credential_id = ? AND deleted_at IS NULL +RETURNING *; + +-- name: GetCredentialsByProfile :many +SELECT c.* FROM credentials c +JOIN devices d ON c.credential_id = d.credential_id +WHERE d.profile_id = ? AND c.deleted_at IS NULL AND d.deleted_at IS NULL; + +-- Device table methods +-- name: CreateDevice :one +INSERT INTO devices ( + id, + profile_id, + credential_id, + name, + device_type, + os_name, + os_version, + browser_name, + browser_version, + is_trusted, + is_current, + fingerprint, + user_agent, + ip_address +) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +RETURNING *; + +-- name: GetDeviceByID :one +SELECT * FROM devices +WHERE id = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: GetDeviceByFingerprint :one +SELECT * FROM devices +WHERE profile_id = ? AND fingerprint = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: ListDevicesByProfile :many +SELECT * FROM devices +WHERE profile_id = ? AND deleted_at IS NULL +ORDER BY last_used_at DESC; + +-- name: GetTrustedDevicesByProfile :many +SELECT * FROM devices +WHERE profile_id = ? AND is_trusted = true AND deleted_at IS NULL +ORDER BY last_used_at DESC; + +-- name: UpdateDevice :one +UPDATE devices +SET + name = ?, + is_trusted = ?, + is_current = ?, + last_used_at = CURRENT_TIMESTAMP, + updated_at = CURRENT_TIMESTAMP +WHERE id = ? AND deleted_at IS NULL +RETURNING *; + +-- name: UpdateDeviceLastUsed :one +UPDATE devices +SET + last_used_at = CURRENT_TIMESTAMP, + ip_address = ?, + updated_at = CURRENT_TIMESTAMP +WHERE id = ? AND deleted_at IS NULL +RETURNING *; + +-- name: SoftDeleteDevice :exec +UPDATE devices +SET deleted_at = CURRENT_TIMESTAMP +WHERE id = ?; diff --git a/x/identity/schema.sql b/x/identity/schema.sql new file mode 100644 index 0000000..e55257c --- /dev/null +++ b/x/identity/schema.sql @@ -0,0 +1,72 @@ +-- 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, + chain_id TEXT NOT NULL, + controller TEXT NOT NULL, + is_subsidiary BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_subsidiary IN (0,1)), + is_validator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_validator IN (0,1)), + is_delegator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegator IN (0,1)), + is_accountable BOOLEAN NOT NULL DEFAULT TRUE CHECK(is_accountable IN (0,1)) +); + +CREATE INDEX idx_accounts_address ON accounts(address); +CREATE INDEX idx_accounts_chain_id ON accounts(chain_id); +CREATE INDEX idx_accounts_deleted_at ON accounts(deleted_at); + + + +-- 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 +); + +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); + +-- Devices link profiles to their authenticated devices +CREATE TABLE devices ( + id TEXT PRIMARY KEY, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP, + profile_id TEXT NOT NULL, + credential_id TEXT NOT NULL, + name TEXT NOT NULL, -- User-friendly device name + device_type TEXT NOT NULL, -- mobile, desktop, tablet, etc. + os_name TEXT NOT NULL, -- iOS, Android, Windows, macOS, etc. + os_version TEXT NOT NULL, -- OS version string + browser_name TEXT, -- Browser name if applicable + browser_version TEXT, -- Browser version if applicable + last_used_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + is_trusted BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_trusted IN (0,1)), + is_current BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_current IN (0,1)), + fingerprint TEXT NOT NULL, -- Device fingerprint for additional verification + user_agent TEXT, -- Full user agent string + ip_address TEXT, -- Last known IP address + FOREIGN KEY (profile_id) REFERENCES profiles(id), + FOREIGN KEY (credential_id) REFERENCES credentials(id), + UNIQUE(profile_id, fingerprint) +); + +CREATE INDEX idx_devices_profile_id ON devices(profile_id); +CREATE INDEX idx_devices_credential_id ON devices(credential_id); +CREATE INDEX idx_devices_is_trusted ON devices(is_trusted); +CREATE INDEX idx_devices_last_used_at ON devices(last_used_at); +CREATE INDEX idx_devices_deleted_at ON devices(deleted_at); diff --git a/x/asset/sqlc.yaml b/x/identity/sqlc.yaml similarity index 76% rename from x/asset/sqlc.yaml rename to x/identity/sqlc.yaml index ab204ec..7095c46 100644 --- a/x/asset/sqlc.yaml +++ b/x/identity/sqlc.yaml @@ -7,5 +7,5 @@ sql: go: emit_interface: true emit_json_tags: true - package: "asset" - out: "orm.gen.go" + package: "identity" + out: "." diff --git a/x/device/view.templ b/x/identity/view.templ similarity index 88% rename from x/device/view.templ rename to x/identity/view.templ index ed5b33b..6fa4a05 100644 --- a/x/device/view.templ +++ b/x/identity/view.templ @@ -1,4 +1,4 @@ -package device +package identity func View() templ.Component { return initialAssetView() diff --git a/x/asset/view_templ.go b/x/identity/view_templ.go similarity index 98% rename from x/asset/view_templ.go rename to x/identity/view_templ.go index 716a53a..bd8760f 100644 --- a/x/asset/view_templ.go +++ b/x/identity/view_templ.go @@ -1,7 +1,7 @@ // Code generated by templ - DO NOT EDIT. // templ: version: v0.3.857 -package asset +package identity //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/x/balance/controller.go b/x/portfolio/controller.go similarity index 100% rename from x/balance/controller.go rename to x/portfolio/controller.go diff --git a/x/asset/query.sql b/x/portfolio/query.sql similarity index 58% rename from x/asset/query.sql rename to x/portfolio/query.sql index 8f2fd5e..9f968c8 100644 --- a/x/asset/query.sql +++ b/x/portfolio/query.sql @@ -1,3 +1,51 @@ + +-- Balance table methods +-- name: CreateBalance :one +INSERT INTO balances ( + id, + account_id, + asset_id, + amount, + last_updated_height, + is_delegated, + is_staked, + is_vesting +) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +RETURNING *; + +-- name: GetBalanceByID :one +SELECT * FROM balances +WHERE id = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: GetBalanceByAccountAndAsset :one +SELECT * FROM balances +WHERE account_id = ? AND asset_id = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: ListBalancesByAccount :many +SELECT * FROM balances +WHERE account_id = ? AND deleted_at IS NULL +ORDER BY asset_id; + +-- name: UpdateBalance :one +UPDATE balances +SET + amount = ?, + last_updated_height = ?, + is_delegated = ?, + is_staked = ?, + is_vesting = ?, + updated_at = CURRENT_TIMESTAMP +WHERE id = ? AND deleted_at IS NULL +RETURNING *; + +-- name: SoftDeleteBalance :exec +UPDATE balances +SET deleted_at = CURRENT_TIMESTAMP +WHERE id = ?; + + -- name: CreateAsset :one INSERT INTO assets ( id, diff --git a/x/balance/schema.sql b/x/portfolio/schema.sql similarity index 60% rename from x/balance/schema.sql rename to x/portfolio/schema.sql index 13fc1da..69ad311 100644 --- a/x/balance/schema.sql +++ b/x/portfolio/schema.sql @@ -1,3 +1,24 @@ +-- Assets represent tokens and coins +CREATE TABLE assets ( + id TEXT PRIMARY KEY, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP, + name TEXT NOT NULL, + symbol TEXT NOT NULL, + decimals INTEGER NOT NULL CHECK(decimals >= 0), + chain_id TEXT NOT NULL, + channel TEXT NOT NULL, + asset_type TEXT NOT NULL, + coingecko_id TEXT, + UNIQUE(chain_id, symbol) +); + +CREATE INDEX idx_assets_symbol ON assets(symbol); +CREATE INDEX idx_assets_chain_id ON assets(chain_id); +CREATE INDEX idx_assets_deleted_at ON assets(deleted_at); + + -- Balances track asset holdings for accounts CREATE TABLE balances ( id TEXT PRIMARY KEY, diff --git a/x/balance/sqlc.yaml b/x/portfolio/sqlc.yaml similarity index 88% rename from x/balance/sqlc.yaml rename to x/portfolio/sqlc.yaml index a3ad6ae..67c60dc 100644 --- a/x/balance/sqlc.yaml +++ b/x/portfolio/sqlc.yaml @@ -8,4 +8,4 @@ sql: emit_interface: true emit_json_tags: true package: "balance" - out: "orm.gen.go" + out: "." diff --git a/x/balance/view.templ b/x/portfolio/view.templ similarity index 87% rename from x/balance/view.templ rename to x/portfolio/view.templ index 9dddb7e..138313c 100644 --- a/x/balance/view.templ +++ b/x/portfolio/view.templ @@ -1,4 +1,4 @@ -package balance +package portfolio func View() templ.Component { return initialAssetView() diff --git a/x/balance/view_templ.go b/x/portfolio/view_templ.go similarity index 100% rename from x/balance/view_templ.go rename to x/portfolio/view_templ.go diff --git a/x/profile/controller.go b/x/profile/controller.go deleted file mode 100644 index 73330f1..0000000 --- a/x/profile/controller.go +++ /dev/null @@ -1 +0,0 @@ -package profile diff --git a/x/profile/query.sql b/x/profile/query.sql deleted file mode 100644 index 21f970b..0000000 --- a/x/profile/query.sql +++ /dev/null @@ -1,48 +0,0 @@ - --- Balance table methods --- name: CreateBalance :one -INSERT INTO balances ( - id, - account_id, - asset_id, - amount, - last_updated_height, - is_delegated, - is_staked, - is_vesting -) VALUES (?, ?, ?, ?, ?, ?, ?, ?) -RETURNING *; - --- name: GetBalanceByID :one -SELECT * FROM balances -WHERE id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: GetBalanceByAccountAndAsset :one -SELECT * FROM balances -WHERE account_id = ? AND asset_id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: ListBalancesByAccount :many -SELECT * FROM balances -WHERE account_id = ? AND deleted_at IS NULL -ORDER BY asset_id; - --- name: UpdateBalance :one -UPDATE balances -SET - amount = ?, - last_updated_height = ?, - is_delegated = ?, - is_staked = ?, - is_vesting = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING *; - --- name: SoftDeleteBalance :exec -UPDATE balances -SET deleted_at = CURRENT_TIMESTAMP -WHERE id = ?; - - diff --git a/x/profile/schema.sql b/x/profile/schema.sql deleted file mode 100644 index 13fc1da..0000000 --- a/x/profile/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Balances track asset holdings for accounts -CREATE TABLE balances ( - 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, - asset_id TEXT NOT NULL, - amount TEXT NOT NULL, -- Stored as string to handle large decimal numbers precisely - last_updated_height INTEGER NOT NULL DEFAULT 0, - is_delegated BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegated IN (0,1)), - is_staked BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_staked IN (0,1)), - is_vesting BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_vesting IN (0,1)), - FOREIGN KEY (account_id) REFERENCES accounts(id), - FOREIGN KEY (asset_id) REFERENCES assets(id), - UNIQUE(account_id, asset_id) -); - -CREATE INDEX idx_balances_account_id ON balances(account_id); -CREATE INDEX idx_balances_asset_id ON balances(asset_id); -CREATE INDEX idx_balances_deleted_at ON balances(deleted_at); - - diff --git a/x/profile/sqlc.yaml b/x/profile/sqlc.yaml deleted file mode 100644 index 21b6b73..0000000 --- a/x/profile/sqlc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "2" -sql: - - engine: "sqlite" - queries: "query.sql" - schema: "schema.sql" - gen: - go: - emit_interface: true - emit_json_tags: true - package: "profile" - out: "orm.gen.go" diff --git a/x/profile/view.templ b/x/profile/view.templ deleted file mode 100644 index 6025cb9..0000000 --- a/x/profile/view.templ +++ /dev/null @@ -1,11 +0,0 @@ -package profile - -func View() templ.Component { - return initialAssetView() -} - -templ initialAssetView() { -
-

Account

-
-} diff --git a/x/profile/view_templ.go b/x/profile/view_templ.go deleted file mode 100644 index e178544..0000000 --- a/x/profile/view_templ.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.857 -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 View() templ.Component { - return initialAssetView() -} - -func initialAssetView() 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, "

Account

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/x/session/controller.go b/x/session/controller.go deleted file mode 100644 index ab87616..0000000 --- a/x/session/controller.go +++ /dev/null @@ -1 +0,0 @@ -package session diff --git a/x/session/query.sql b/x/session/query.sql deleted file mode 100644 index 21f970b..0000000 --- a/x/session/query.sql +++ /dev/null @@ -1,48 +0,0 @@ - --- Balance table methods --- name: CreateBalance :one -INSERT INTO balances ( - id, - account_id, - asset_id, - amount, - last_updated_height, - is_delegated, - is_staked, - is_vesting -) VALUES (?, ?, ?, ?, ?, ?, ?, ?) -RETURNING *; - --- name: GetBalanceByID :one -SELECT * FROM balances -WHERE id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: GetBalanceByAccountAndAsset :one -SELECT * FROM balances -WHERE account_id = ? AND asset_id = ? AND deleted_at IS NULL -LIMIT 1; - --- name: ListBalancesByAccount :many -SELECT * FROM balances -WHERE account_id = ? AND deleted_at IS NULL -ORDER BY asset_id; - --- name: UpdateBalance :one -UPDATE balances -SET - amount = ?, - last_updated_height = ?, - is_delegated = ?, - is_staked = ?, - is_vesting = ?, - updated_at = CURRENT_TIMESTAMP -WHERE id = ? AND deleted_at IS NULL -RETURNING *; - --- name: SoftDeleteBalance :exec -UPDATE balances -SET deleted_at = CURRENT_TIMESTAMP -WHERE id = ?; - - diff --git a/x/session/schema.sql b/x/session/schema.sql deleted file mode 100644 index 13fc1da..0000000 --- a/x/session/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Balances track asset holdings for accounts -CREATE TABLE balances ( - 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, - asset_id TEXT NOT NULL, - amount TEXT NOT NULL, -- Stored as string to handle large decimal numbers precisely - last_updated_height INTEGER NOT NULL DEFAULT 0, - is_delegated BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegated IN (0,1)), - is_staked BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_staked IN (0,1)), - is_vesting BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_vesting IN (0,1)), - FOREIGN KEY (account_id) REFERENCES accounts(id), - FOREIGN KEY (asset_id) REFERENCES assets(id), - UNIQUE(account_id, asset_id) -); - -CREATE INDEX idx_balances_account_id ON balances(account_id); -CREATE INDEX idx_balances_asset_id ON balances(asset_id); -CREATE INDEX idx_balances_deleted_at ON balances(deleted_at); - - diff --git a/x/session/sqlc.yaml b/x/session/sqlc.yaml deleted file mode 100644 index 1edd810..0000000 --- a/x/session/sqlc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "2" -sql: - - engine: "sqlite" - queries: "query.sql" - schema: "schema.sql" - gen: - go: - emit_interface: true - emit_json_tags: true - package: "session" - out: "orm.gen.go" diff --git a/x/session/view.templ b/x/session/view.templ deleted file mode 100644 index bc97f35..0000000 --- a/x/session/view.templ +++ /dev/null @@ -1,11 +0,0 @@ -package session - -func View() templ.Component { - return initialAssetView() -} - -templ initialAssetView() { -
-

Account

-
-} diff --git a/x/user/controller.go b/x/user/controller.go new file mode 100644 index 0000000..a00006b --- /dev/null +++ b/x/user/controller.go @@ -0,0 +1 @@ +package user diff --git a/x/user/query.sql b/x/user/query.sql new file mode 100644 index 0000000..f4020f3 --- /dev/null +++ b/x/user/query.sql @@ -0,0 +1,116 @@ +-- name: GetVaultConfigByCID :one +SELECT * FROM vaults +WHERE cid = ? +AND deleted_at IS NULL +LIMIT 1; + +-- name: GetVaultRedirectURIBySessionID :one +SELECT redirect_uri FROM vaults +WHERE session_id = ? +AND deleted_at IS NULL +LIMIT 1; + +-- name: CreateSession :one +INSERT INTO sessions ( + id, + browser_name, + browser_version, + client_ipaddr, + platform, + is_desktop, + is_mobile, + is_tablet, + is_tv, + is_bot, + challenge, + is_human_first, + is_human_last, + profile_id +) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) +RETURNING *; + +-- name: GetChallengeBySessionID :one +SELECT challenge FROM sessions +WHERE id = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: GetHumanVerificationNumbers :one +SELECT is_human_first, is_human_last FROM sessions +WHERE id = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: GetSessionByID :one +SELECT * FROM sessions +WHERE id = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: GetSessionByClientIP :one +SELECT * FROM sessions +WHERE client_ipaddr = ? AND deleted_at IS NULL +LIMIT 1; + +-- name: UpdateSessionHumanVerification :one +UPDATE sessions +SET + is_human_first = ?, + is_human_last = ?, + updated_at = CURRENT_TIMESTAMP +WHERE id = ? +RETURNING *; + +-- name: UpdateSessionWithProfileID :one +UPDATE sessions +SET + profile_id = ?, + updated_at = CURRENT_TIMESTAMP +WHERE id = ? +RETURNING *; + +-- name: CheckHandleExists :one +SELECT COUNT(*) > 0 as handle_exists FROM profiles +WHERE handle = ? +AND deleted_at IS NULL; + + +-- name: 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: SoftDeleteProfile :exec +UPDATE profiles +SET deleted_at = CURRENT_TIMESTAMP +WHERE address = ?; + +-- name: UpdateProfile :one +UPDATE profiles +SET + name = ?, + handle = ?, + updated_at = CURRENT_TIMESTAMP +WHERE address = ? +AND deleted_at IS NULL +RETURNING *; + +-- name: GetProfileByHandle :one +SELECT * FROM profiles +WHERE handle = ? +AND deleted_at IS NULL +LIMIT 1; + + diff --git a/x/user/schema.sql b/x/user/schema.sql new file mode 100644 index 0000000..b18faac --- /dev/null +++ b/x/user/schema.sql @@ -0,0 +1,62 @@ +-- 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) +); + +-- Indexes for common queries +CREATE INDEX idx_profiles_handle ON profiles(handle); +CREATE INDEX idx_profiles_address ON profiles(address); +CREATE INDEX idx_profiles_deleted_at ON profiles(deleted_at); + +-- Sessions track user authentication state +CREATE TABLE sessions ( + id TEXT PRIMARY KEY, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP, + browser_name TEXT NOT NULL, + browser_version TEXT NOT NULL, + client_ipaddr TEXT NOT NULL, + platform TEXT NOT NULL, + is_desktop BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_desktop IN (0,1)), + is_mobile BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_mobile IN (0,1)), + is_tablet BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_tablet IN (0,1)), + is_tv BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_tv IN (0,1)), + is_bot BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_bot IN (0,1)), + challenge TEXT NOT NULL, + is_human_first BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_human_first IN (0,1)), + is_human_last BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_human_last IN (0,1)), + profile_id INTEGER NOT NULL +); + +CREATE INDEX idx_sessions_profile_id ON sessions(profile_id); +CREATE INDEX idx_sessions_client_ipaddr ON sessions(client_ipaddr); +CREATE INDEX idx_sessions_deleted_at ON sessions(deleted_at); + + +-- 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, + session_id TEXT NOT NULL, + redirect_uri TEXT NOT NULL +); + +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); diff --git a/x/account/sqlc.yaml b/x/user/sqlc.yaml similarity index 87% rename from x/account/sqlc.yaml rename to x/user/sqlc.yaml index 8b9696a..7316a50 100644 --- a/x/account/sqlc.yaml +++ b/x/user/sqlc.yaml @@ -7,5 +7,5 @@ sql: go: emit_interface: true emit_json_tags: true - package: "account" + package: "user" out: "." diff --git a/x/asset/view.templ b/x/user/view.templ similarity index 90% rename from x/asset/view.templ rename to x/user/view.templ index e747ecb..7c9d037 100644 --- a/x/asset/view.templ +++ b/x/user/view.templ @@ -1,4 +1,4 @@ -package asset +package user func View() templ.Component { return initialAssetView() diff --git a/x/session/view_templ.go b/x/user/view_templ.go similarity index 100% rename from x/session/view_templ.go rename to x/user/view_templ.go diff --git a/x/vault/controller.go b/x/vault/controller.go deleted file mode 100644 index f7e34c8..0000000 --- a/x/vault/controller.go +++ /dev/null @@ -1 +0,0 @@ -package vault diff --git a/x/vault/query.sql b/x/vault/query.sql deleted file mode 100644 index 204c457..0000000 --- a/x/vault/query.sql +++ /dev/null @@ -1,13 +0,0 @@ - --- 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; - diff --git a/x/vault/schema.sql b/x/vault/schema.sql deleted file mode 100644 index e1f6b63..0000000 --- a/x/vault/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ --- 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, - session_id TEXT NOT NULL, - redirect_uri TEXT NOT NULL -); - -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); diff --git a/x/vault/sqlc.yaml b/x/vault/sqlc.yaml deleted file mode 100644 index f12f3f2..0000000 --- a/x/vault/sqlc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "2" -sql: - - engine: "sqlite" - queries: "query.sql" - schema: "schema.sql" - gen: - go: - emit_interface: true - emit_json_tags: true - package: "vault" - out: "orm.gen.go" diff --git a/x/vault/view.templ b/x/vault/view.templ deleted file mode 100644 index 8770524..0000000 --- a/x/vault/view.templ +++ /dev/null @@ -1,11 +0,0 @@ -package vault - -func View() templ.Component { - return initialVaultView() -} - -templ initialVaultView() { -
-

Account

-
-} diff --git a/x/vault/view_templ.go b/x/vault/view_templ.go deleted file mode 100644 index e83aaaa..0000000 --- a/x/vault/view_templ.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.857 -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 View() templ.Component { - return initialVaultView() -} - -func initialVaultView() 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, "

Account

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate