mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 21:09:11 +00:00
- **docs: remove discord badge from README** - **fix: ensure go version is up-to-date** - **<no value>** - **refactor: update import paths for blocks to components** - **feat: add Hero component template** - **fix: update footer logo to svg** - **feat: add Query/Sign and Query/Verify RPC methods** - **refactor: rename Keyshares to KsVal in did/v1/state.proto**
236 lines
6.4 KiB
Go
236 lines
6.4 KiB
Go
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
|
|
|
package vaultv1
|
|
|
|
import (
|
|
context "context"
|
|
ormlist "cosmossdk.io/orm/model/ormlist"
|
|
ormtable "cosmossdk.io/orm/model/ormtable"
|
|
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
|
)
|
|
|
|
type DWNTable interface {
|
|
Insert(ctx context.Context, dWN *DWN) error
|
|
InsertReturningId(ctx context.Context, dWN *DWN) (uint64, error)
|
|
LastInsertedSequence(ctx context.Context) (uint64, error)
|
|
Update(ctx context.Context, dWN *DWN) error
|
|
Save(ctx context.Context, dWN *DWN) error
|
|
Delete(ctx context.Context, dWN *DWN) error
|
|
Has(ctx context.Context, id uint64) (found bool, err error)
|
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
Get(ctx context.Context, id uint64) (*DWN, error)
|
|
HasByAlias(ctx context.Context, alias string) (found bool, err error)
|
|
// GetByAlias returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
GetByAlias(ctx context.Context, alias string) (*DWN, error)
|
|
HasByCid(ctx context.Context, cid string) (found bool, err error)
|
|
// GetByCid returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
GetByCid(ctx context.Context, cid string) (*DWN, error)
|
|
List(ctx context.Context, prefixKey DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error)
|
|
ListRange(ctx context.Context, from, to DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error)
|
|
DeleteBy(ctx context.Context, prefixKey DWNIndexKey) error
|
|
DeleteRange(ctx context.Context, from, to DWNIndexKey) error
|
|
|
|
doNotImplement()
|
|
}
|
|
|
|
type DWNIterator struct {
|
|
ormtable.Iterator
|
|
}
|
|
|
|
func (i DWNIterator) Value() (*DWN, error) {
|
|
var dWN DWN
|
|
err := i.UnmarshalMessage(&dWN)
|
|
return &dWN, err
|
|
}
|
|
|
|
type DWNIndexKey interface {
|
|
id() uint32
|
|
values() []interface{}
|
|
dWNIndexKey()
|
|
}
|
|
|
|
// primary key starting index..
|
|
type DWNPrimaryKey = DWNIdIndexKey
|
|
|
|
type DWNIdIndexKey struct {
|
|
vs []interface{}
|
|
}
|
|
|
|
func (x DWNIdIndexKey) id() uint32 { return 0 }
|
|
func (x DWNIdIndexKey) values() []interface{} { return x.vs }
|
|
func (x DWNIdIndexKey) dWNIndexKey() {}
|
|
|
|
func (this DWNIdIndexKey) WithId(id uint64) DWNIdIndexKey {
|
|
this.vs = []interface{}{id}
|
|
return this
|
|
}
|
|
|
|
type DWNAliasIndexKey struct {
|
|
vs []interface{}
|
|
}
|
|
|
|
func (x DWNAliasIndexKey) id() uint32 { return 1 }
|
|
func (x DWNAliasIndexKey) values() []interface{} { return x.vs }
|
|
func (x DWNAliasIndexKey) dWNIndexKey() {}
|
|
|
|
func (this DWNAliasIndexKey) WithAlias(alias string) DWNAliasIndexKey {
|
|
this.vs = []interface{}{alias}
|
|
return this
|
|
}
|
|
|
|
type DWNCidIndexKey struct {
|
|
vs []interface{}
|
|
}
|
|
|
|
func (x DWNCidIndexKey) id() uint32 { return 2 }
|
|
func (x DWNCidIndexKey) values() []interface{} { return x.vs }
|
|
func (x DWNCidIndexKey) dWNIndexKey() {}
|
|
|
|
func (this DWNCidIndexKey) WithCid(cid string) DWNCidIndexKey {
|
|
this.vs = []interface{}{cid}
|
|
return this
|
|
}
|
|
|
|
type dWNTable struct {
|
|
table ormtable.AutoIncrementTable
|
|
}
|
|
|
|
func (this dWNTable) Insert(ctx context.Context, dWN *DWN) error {
|
|
return this.table.Insert(ctx, dWN)
|
|
}
|
|
|
|
func (this dWNTable) Update(ctx context.Context, dWN *DWN) error {
|
|
return this.table.Update(ctx, dWN)
|
|
}
|
|
|
|
func (this dWNTable) Save(ctx context.Context, dWN *DWN) error {
|
|
return this.table.Save(ctx, dWN)
|
|
}
|
|
|
|
func (this dWNTable) Delete(ctx context.Context, dWN *DWN) error {
|
|
return this.table.Delete(ctx, dWN)
|
|
}
|
|
|
|
func (this dWNTable) InsertReturningId(ctx context.Context, dWN *DWN) (uint64, error) {
|
|
return this.table.InsertReturningPKey(ctx, dWN)
|
|
}
|
|
|
|
func (this dWNTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
|
return this.table.LastInsertedSequence(ctx)
|
|
}
|
|
|
|
func (this dWNTable) Has(ctx context.Context, id uint64) (found bool, err error) {
|
|
return this.table.PrimaryKey().Has(ctx, id)
|
|
}
|
|
|
|
func (this dWNTable) Get(ctx context.Context, id uint64) (*DWN, error) {
|
|
var dWN DWN
|
|
found, err := this.table.PrimaryKey().Get(ctx, &dWN, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !found {
|
|
return nil, ormerrors.NotFound
|
|
}
|
|
return &dWN, nil
|
|
}
|
|
|
|
func (this dWNTable) HasByAlias(ctx context.Context, alias string) (found bool, err error) {
|
|
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
|
alias,
|
|
)
|
|
}
|
|
|
|
func (this dWNTable) GetByAlias(ctx context.Context, alias string) (*DWN, error) {
|
|
var dWN DWN
|
|
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &dWN,
|
|
alias,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !found {
|
|
return nil, ormerrors.NotFound
|
|
}
|
|
return &dWN, nil
|
|
}
|
|
|
|
func (this dWNTable) HasByCid(ctx context.Context, cid string) (found bool, err error) {
|
|
return this.table.GetIndexByID(2).(ormtable.UniqueIndex).Has(ctx,
|
|
cid,
|
|
)
|
|
}
|
|
|
|
func (this dWNTable) GetByCid(ctx context.Context, cid string) (*DWN, error) {
|
|
var dWN DWN
|
|
found, err := this.table.GetIndexByID(2).(ormtable.UniqueIndex).Get(ctx, &dWN,
|
|
cid,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !found {
|
|
return nil, ormerrors.NotFound
|
|
}
|
|
return &dWN, nil
|
|
}
|
|
|
|
func (this dWNTable) List(ctx context.Context, prefixKey DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error) {
|
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
|
return DWNIterator{it}, err
|
|
}
|
|
|
|
func (this dWNTable) ListRange(ctx context.Context, from, to DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error) {
|
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
|
return DWNIterator{it}, err
|
|
}
|
|
|
|
func (this dWNTable) DeleteBy(ctx context.Context, prefixKey DWNIndexKey) error {
|
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
}
|
|
|
|
func (this dWNTable) DeleteRange(ctx context.Context, from, to DWNIndexKey) error {
|
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
}
|
|
|
|
func (this dWNTable) doNotImplement() {}
|
|
|
|
var _ DWNTable = dWNTable{}
|
|
|
|
func NewDWNTable(db ormtable.Schema) (DWNTable, error) {
|
|
table := db.GetTable(&DWN{})
|
|
if table == nil {
|
|
return nil, ormerrors.TableNotFound.Wrap(string((&DWN{}).ProtoReflect().Descriptor().FullName()))
|
|
}
|
|
return dWNTable{table.(ormtable.AutoIncrementTable)}, nil
|
|
}
|
|
|
|
type StateStore interface {
|
|
DWNTable() DWNTable
|
|
|
|
doNotImplement()
|
|
}
|
|
|
|
type stateStore struct {
|
|
dWN DWNTable
|
|
}
|
|
|
|
func (x stateStore) DWNTable() DWNTable {
|
|
return x.dWN
|
|
}
|
|
|
|
func (stateStore) doNotImplement() {}
|
|
|
|
var _ StateStore = stateStore{}
|
|
|
|
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
|
dWNTable, err := NewDWNTable(db)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return stateStore{
|
|
dWNTable,
|
|
}, nil
|
|
}
|