mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-11 13:29:12 +00:00
167 lines
4.4 KiB
Go
167 lines
4.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
|
||
|
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, account []byte) (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, account []byte) (*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 = DWNAccountIndexKey
|
||
|
|
||
|
type DWNAccountIndexKey struct {
|
||
|
vs []interface{}
|
||
|
}
|
||
|
|
||
|
func (x DWNAccountIndexKey) id() uint32 { return 0 }
|
||
|
func (x DWNAccountIndexKey) values() []interface{} { return x.vs }
|
||
|
func (x DWNAccountIndexKey) dWNIndexKey() {}
|
||
|
|
||
|
func (this DWNAccountIndexKey) WithAccount(account []byte) DWNAccountIndexKey {
|
||
|
this.vs = []interface{}{account}
|
||
|
return this
|
||
|
}
|
||
|
|
||
|
type DWNAmountIndexKey struct {
|
||
|
vs []interface{}
|
||
|
}
|
||
|
|
||
|
func (x DWNAmountIndexKey) id() uint32 { return 1 }
|
||
|
func (x DWNAmountIndexKey) values() []interface{} { return x.vs }
|
||
|
func (x DWNAmountIndexKey) dWNIndexKey() {}
|
||
|
|
||
|
func (this DWNAmountIndexKey) WithAmount(amount uint64) DWNAmountIndexKey {
|
||
|
this.vs = []interface{}{amount}
|
||
|
return this
|
||
|
}
|
||
|
|
||
|
type dWNTable struct {
|
||
|
table ormtable.Table
|
||
|
}
|
||
|
|
||
|
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) Has(ctx context.Context, account []byte) (found bool, err error) {
|
||
|
return this.table.PrimaryKey().Has(ctx, account)
|
||
|
}
|
||
|
|
||
|
func (this dWNTable) Get(ctx context.Context, account []byte) (*DWN, error) {
|
||
|
var dWN DWN
|
||
|
found, err := this.table.PrimaryKey().Get(ctx, &dWN, account)
|
||
|
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}, 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
|
||
|
}
|