2022-01-28 10:43:24 -08:00
|
|
|
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
|
|
|
|
|
|
|
package testpb
|
|
|
|
|
|
|
|
import (
|
|
|
|
context "context"
|
2022-01-31 16:23:15 -08:00
|
|
|
|
2022-01-28 10:43:24 -08:00
|
|
|
ormlist "github.com/cosmos/cosmos-sdk/orm/model/ormlist"
|
|
|
|
ormtable "github.com/cosmos/cosmos-sdk/orm/model/ormtable"
|
|
|
|
ormerrors "github.com/cosmos/cosmos-sdk/orm/types/ormerrors"
|
|
|
|
)
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
type BalanceTable interface {
|
2022-01-28 10:43:24 -08:00
|
|
|
Insert(ctx context.Context, balance *Balance) error
|
|
|
|
Update(ctx context.Context, balance *Balance) error
|
|
|
|
Save(ctx context.Context, balance *Balance) error
|
|
|
|
Delete(ctx context.Context, balance *Balance) error
|
|
|
|
Has(ctx context.Context, address string, denom string) (found bool, err error)
|
2022-02-04 08:07:36 -08:00
|
|
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
2022-01-28 10:43:24 -08:00
|
|
|
Get(ctx context.Context, address string, denom string) (*Balance, error)
|
|
|
|
List(ctx context.Context, prefixKey BalanceIndexKey, opts ...ormlist.Option) (BalanceIterator, error)
|
|
|
|
ListRange(ctx context.Context, from, to BalanceIndexKey, opts ...ormlist.Option) (BalanceIterator, error)
|
2022-02-03 02:04:02 -08:00
|
|
|
DeleteBy(ctx context.Context, prefixKey BalanceIndexKey) error
|
|
|
|
DeleteRange(ctx context.Context, from, to BalanceIndexKey) error
|
2022-01-28 10:43:24 -08:00
|
|
|
|
|
|
|
doNotImplement()
|
|
|
|
}
|
|
|
|
|
|
|
|
type BalanceIterator struct {
|
|
|
|
ormtable.Iterator
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i BalanceIterator) Value() (*Balance, error) {
|
|
|
|
var balance Balance
|
|
|
|
err := i.UnmarshalMessage(&balance)
|
|
|
|
return &balance, err
|
|
|
|
}
|
|
|
|
|
|
|
|
type BalanceIndexKey interface {
|
|
|
|
id() uint32
|
|
|
|
values() []interface{}
|
|
|
|
balanceIndexKey()
|
|
|
|
}
|
|
|
|
|
|
|
|
// primary key starting index..
|
2022-01-31 16:23:15 -08:00
|
|
|
type BalancePrimaryKey = BalanceAddressDenomIndexKey
|
|
|
|
|
2022-01-28 10:43:24 -08:00
|
|
|
type BalanceAddressDenomIndexKey struct {
|
|
|
|
vs []interface{}
|
|
|
|
}
|
|
|
|
|
2022-01-31 16:23:15 -08:00
|
|
|
func (x BalanceAddressDenomIndexKey) id() uint32 { return 0 }
|
2022-01-28 10:43:24 -08:00
|
|
|
func (x BalanceAddressDenomIndexKey) values() []interface{} { return x.vs }
|
|
|
|
func (x BalanceAddressDenomIndexKey) balanceIndexKey() {}
|
|
|
|
|
|
|
|
func (this BalanceAddressDenomIndexKey) WithAddress(address string) BalanceAddressDenomIndexKey {
|
|
|
|
this.vs = []interface{}{address}
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this BalanceAddressDenomIndexKey) WithAddressDenom(address string, denom string) BalanceAddressDenomIndexKey {
|
|
|
|
this.vs = []interface{}{address, denom}
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
type BalanceDenomIndexKey struct {
|
|
|
|
vs []interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x BalanceDenomIndexKey) id() uint32 { return 1 }
|
|
|
|
func (x BalanceDenomIndexKey) values() []interface{} { return x.vs }
|
|
|
|
func (x BalanceDenomIndexKey) balanceIndexKey() {}
|
|
|
|
|
|
|
|
func (this BalanceDenomIndexKey) WithDenom(denom string) BalanceDenomIndexKey {
|
|
|
|
this.vs = []interface{}{denom}
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
type balanceTable struct {
|
2022-01-28 10:43:24 -08:00
|
|
|
table ormtable.Table
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) Insert(ctx context.Context, balance *Balance) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Insert(ctx, balance)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) Update(ctx context.Context, balance *Balance) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Update(ctx, balance)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) Save(ctx context.Context, balance *Balance) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Save(ctx, balance)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) Delete(ctx context.Context, balance *Balance) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Delete(ctx, balance)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) Has(ctx context.Context, address string, denom string) (found bool, err error) {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.PrimaryKey().Has(ctx, address, denom)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) Get(ctx context.Context, address string, denom string) (*Balance, error) {
|
2022-01-28 10:43:24 -08:00
|
|
|
var balance Balance
|
|
|
|
found, err := this.table.PrimaryKey().Get(ctx, &balance, address, denom)
|
2022-02-04 08:07:36 -08:00
|
|
|
if err != nil {
|
2022-01-28 10:43:24 -08:00
|
|
|
return nil, err
|
|
|
|
}
|
2022-02-04 08:07:36 -08:00
|
|
|
if !found {
|
|
|
|
return nil, ormerrors.NotFound
|
|
|
|
}
|
|
|
|
return &balance, nil
|
2022-01-28 10:43:24 -08:00
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) List(ctx context.Context, prefixKey BalanceIndexKey, opts ...ormlist.Option) (BalanceIterator, error) {
|
2022-02-02 13:12:11 -08:00
|
|
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
2022-01-28 10:43:24 -08:00
|
|
|
return BalanceIterator{it}, err
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) ListRange(ctx context.Context, from, to BalanceIndexKey, opts ...ormlist.Option) (BalanceIterator, error) {
|
2022-02-02 13:12:11 -08:00
|
|
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
2022-01-28 10:43:24 -08:00
|
|
|
return BalanceIterator{it}, err
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) DeleteBy(ctx context.Context, prefixKey BalanceIndexKey) error {
|
2022-02-03 02:04:02 -08:00
|
|
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) DeleteRange(ctx context.Context, from, to BalanceIndexKey) error {
|
2022-02-03 02:04:02 -08:00
|
|
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this balanceTable) doNotImplement() {}
|
2022-01-28 10:43:24 -08:00
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
var _ BalanceTable = balanceTable{}
|
2022-01-28 10:43:24 -08:00
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func NewBalanceTable(db ormtable.Schema) (BalanceTable, error) {
|
2022-01-28 10:43:24 -08:00
|
|
|
table := db.GetTable(&Balance{})
|
|
|
|
if table == nil {
|
|
|
|
return nil, ormerrors.TableNotFound.Wrap(string((&Balance{}).ProtoReflect().Descriptor().FullName()))
|
|
|
|
}
|
2022-02-14 07:23:52 -08:00
|
|
|
return balanceTable{table}, nil
|
2022-01-28 10:43:24 -08:00
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
type SupplyTable interface {
|
2022-01-28 10:43:24 -08:00
|
|
|
Insert(ctx context.Context, supply *Supply) error
|
|
|
|
Update(ctx context.Context, supply *Supply) error
|
|
|
|
Save(ctx context.Context, supply *Supply) error
|
|
|
|
Delete(ctx context.Context, supply *Supply) error
|
|
|
|
Has(ctx context.Context, denom string) (found bool, err error)
|
2022-02-04 08:07:36 -08:00
|
|
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
2022-01-28 10:43:24 -08:00
|
|
|
Get(ctx context.Context, denom string) (*Supply, error)
|
|
|
|
List(ctx context.Context, prefixKey SupplyIndexKey, opts ...ormlist.Option) (SupplyIterator, error)
|
|
|
|
ListRange(ctx context.Context, from, to SupplyIndexKey, opts ...ormlist.Option) (SupplyIterator, error)
|
2022-02-03 02:04:02 -08:00
|
|
|
DeleteBy(ctx context.Context, prefixKey SupplyIndexKey) error
|
|
|
|
DeleteRange(ctx context.Context, from, to SupplyIndexKey) error
|
2022-01-28 10:43:24 -08:00
|
|
|
|
|
|
|
doNotImplement()
|
|
|
|
}
|
|
|
|
|
|
|
|
type SupplyIterator struct {
|
|
|
|
ormtable.Iterator
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i SupplyIterator) Value() (*Supply, error) {
|
|
|
|
var supply Supply
|
|
|
|
err := i.UnmarshalMessage(&supply)
|
|
|
|
return &supply, err
|
|
|
|
}
|
|
|
|
|
|
|
|
type SupplyIndexKey interface {
|
|
|
|
id() uint32
|
|
|
|
values() []interface{}
|
|
|
|
supplyIndexKey()
|
|
|
|
}
|
|
|
|
|
|
|
|
// primary key starting index..
|
2022-01-31 16:23:15 -08:00
|
|
|
type SupplyPrimaryKey = SupplyDenomIndexKey
|
|
|
|
|
2022-01-28 10:43:24 -08:00
|
|
|
type SupplyDenomIndexKey struct {
|
|
|
|
vs []interface{}
|
|
|
|
}
|
|
|
|
|
2022-01-31 16:23:15 -08:00
|
|
|
func (x SupplyDenomIndexKey) id() uint32 { return 0 }
|
2022-01-28 10:43:24 -08:00
|
|
|
func (x SupplyDenomIndexKey) values() []interface{} { return x.vs }
|
|
|
|
func (x SupplyDenomIndexKey) supplyIndexKey() {}
|
|
|
|
|
|
|
|
func (this SupplyDenomIndexKey) WithDenom(denom string) SupplyDenomIndexKey {
|
|
|
|
this.vs = []interface{}{denom}
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
type supplyTable struct {
|
2022-01-28 10:43:24 -08:00
|
|
|
table ormtable.Table
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) Insert(ctx context.Context, supply *Supply) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Insert(ctx, supply)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) Update(ctx context.Context, supply *Supply) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Update(ctx, supply)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) Save(ctx context.Context, supply *Supply) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Save(ctx, supply)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) Delete(ctx context.Context, supply *Supply) error {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.Delete(ctx, supply)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) Has(ctx context.Context, denom string) (found bool, err error) {
|
2022-01-28 10:43:24 -08:00
|
|
|
return this.table.PrimaryKey().Has(ctx, denom)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) Get(ctx context.Context, denom string) (*Supply, error) {
|
2022-01-28 10:43:24 -08:00
|
|
|
var supply Supply
|
|
|
|
found, err := this.table.PrimaryKey().Get(ctx, &supply, denom)
|
2022-02-04 08:07:36 -08:00
|
|
|
if err != nil {
|
2022-01-28 10:43:24 -08:00
|
|
|
return nil, err
|
|
|
|
}
|
2022-02-04 08:07:36 -08:00
|
|
|
if !found {
|
|
|
|
return nil, ormerrors.NotFound
|
|
|
|
}
|
|
|
|
return &supply, nil
|
2022-01-28 10:43:24 -08:00
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) List(ctx context.Context, prefixKey SupplyIndexKey, opts ...ormlist.Option) (SupplyIterator, error) {
|
2022-02-02 13:12:11 -08:00
|
|
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
2022-01-28 10:43:24 -08:00
|
|
|
return SupplyIterator{it}, err
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) ListRange(ctx context.Context, from, to SupplyIndexKey, opts ...ormlist.Option) (SupplyIterator, error) {
|
2022-02-02 13:12:11 -08:00
|
|
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
2022-01-28 10:43:24 -08:00
|
|
|
return SupplyIterator{it}, err
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) DeleteBy(ctx context.Context, prefixKey SupplyIndexKey) error {
|
2022-02-03 02:04:02 -08:00
|
|
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) DeleteRange(ctx context.Context, from, to SupplyIndexKey) error {
|
2022-02-03 02:04:02 -08:00
|
|
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (this supplyTable) doNotImplement() {}
|
2022-01-28 10:43:24 -08:00
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
var _ SupplyTable = supplyTable{}
|
2022-01-28 10:43:24 -08:00
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func NewSupplyTable(db ormtable.Schema) (SupplyTable, error) {
|
2022-01-28 10:43:24 -08:00
|
|
|
table := db.GetTable(&Supply{})
|
|
|
|
if table == nil {
|
|
|
|
return nil, ormerrors.TableNotFound.Wrap(string((&Supply{}).ProtoReflect().Descriptor().FullName()))
|
|
|
|
}
|
2022-02-14 07:23:52 -08:00
|
|
|
return supplyTable{table}, nil
|
2022-01-28 10:43:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
type BankStore interface {
|
2022-02-14 07:23:52 -08:00
|
|
|
BalanceTable() BalanceTable
|
|
|
|
SupplyTable() SupplyTable
|
2022-01-28 10:43:24 -08:00
|
|
|
|
|
|
|
doNotImplement()
|
|
|
|
}
|
|
|
|
|
|
|
|
type bankStore struct {
|
2022-02-14 07:23:52 -08:00
|
|
|
balance BalanceTable
|
|
|
|
supply SupplyTable
|
2022-01-28 10:43:24 -08:00
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (x bankStore) BalanceTable() BalanceTable {
|
2022-01-28 10:43:24 -08:00
|
|
|
return x.balance
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
func (x bankStore) SupplyTable() SupplyTable {
|
2022-01-28 10:43:24 -08:00
|
|
|
return x.supply
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bankStore) doNotImplement() {}
|
|
|
|
|
|
|
|
var _ BankStore = bankStore{}
|
|
|
|
|
2022-02-03 20:36:21 -08:00
|
|
|
func NewBankStore(db ormtable.Schema) (BankStore, error) {
|
2022-02-14 07:23:52 -08:00
|
|
|
balanceTable, err := NewBalanceTable(db)
|
2022-01-28 10:43:24 -08:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-02-14 07:23:52 -08:00
|
|
|
supplyTable, err := NewSupplyTable(db)
|
2022-01-28 10:43:24 -08:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return bankStore{
|
2022-02-14 07:23:52 -08:00
|
|
|
balanceTable,
|
|
|
|
supplyTable,
|
2022-01-28 10:43:24 -08:00
|
|
|
}, nil
|
|
|
|
}
|