sonr/api/did/v1/state.cosmos_orm.go
Prad Nukala 6d8bd8fc85
feature/implement did state (#15)
* refactor: update model proto

* feat: add status field to Controller

* feat: add Verification.Kind field to state protobuf to support different verification types

* fix: remove QueryService and QueryResolve RPCs from query.proto
2024-09-18 17:27:30 -04:00

591 lines
19 KiB
Go

// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
package didv1
import (
context "context"
ormlist "cosmossdk.io/orm/model/ormlist"
ormtable "cosmossdk.io/orm/model/ormtable"
ormerrors "cosmossdk.io/orm/types/ormerrors"
)
type AliasTable interface {
Insert(ctx context.Context, alias *Alias) error
Update(ctx context.Context, alias *Alias) error
Save(ctx context.Context, alias *Alias) error
Delete(ctx context.Context, alias *Alias) error
Has(ctx context.Context, id string) (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 string) (*Alias, error)
HasByDidAlias(ctx context.Context, did string, alias string) (found bool, err error)
// GetByDidAlias returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByDidAlias(ctx context.Context, did string, alias string) (*Alias, error)
List(ctx context.Context, prefixKey AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error)
ListRange(ctx context.Context, from, to AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error)
DeleteBy(ctx context.Context, prefixKey AliasIndexKey) error
DeleteRange(ctx context.Context, from, to AliasIndexKey) error
doNotImplement()
}
type AliasIterator struct {
ormtable.Iterator
}
func (i AliasIterator) Value() (*Alias, error) {
var alias Alias
err := i.UnmarshalMessage(&alias)
return &alias, err
}
type AliasIndexKey interface {
id() uint32
values() []interface{}
aliasIndexKey()
}
// primary key starting index..
type AliasPrimaryKey = AliasIdIndexKey
type AliasIdIndexKey struct {
vs []interface{}
}
func (x AliasIdIndexKey) id() uint32 { return 0 }
func (x AliasIdIndexKey) values() []interface{} { return x.vs }
func (x AliasIdIndexKey) aliasIndexKey() {}
func (this AliasIdIndexKey) WithId(id string) AliasIdIndexKey {
this.vs = []interface{}{id}
return this
}
type AliasDidAliasIndexKey struct {
vs []interface{}
}
func (x AliasDidAliasIndexKey) id() uint32 { return 1 }
func (x AliasDidAliasIndexKey) values() []interface{} { return x.vs }
func (x AliasDidAliasIndexKey) aliasIndexKey() {}
func (this AliasDidAliasIndexKey) WithDid(did string) AliasDidAliasIndexKey {
this.vs = []interface{}{did}
return this
}
func (this AliasDidAliasIndexKey) WithDidAlias(did string, alias string) AliasDidAliasIndexKey {
this.vs = []interface{}{did, alias}
return this
}
type aliasTable struct {
table ormtable.Table
}
func (this aliasTable) Insert(ctx context.Context, alias *Alias) error {
return this.table.Insert(ctx, alias)
}
func (this aliasTable) Update(ctx context.Context, alias *Alias) error {
return this.table.Update(ctx, alias)
}
func (this aliasTable) Save(ctx context.Context, alias *Alias) error {
return this.table.Save(ctx, alias)
}
func (this aliasTable) Delete(ctx context.Context, alias *Alias) error {
return this.table.Delete(ctx, alias)
}
func (this aliasTable) Has(ctx context.Context, id string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, id)
}
func (this aliasTable) Get(ctx context.Context, id string) (*Alias, error) {
var alias Alias
found, err := this.table.PrimaryKey().Get(ctx, &alias, id)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &alias, nil
}
func (this aliasTable) HasByDidAlias(ctx context.Context, did string, alias string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
did,
alias,
)
}
func (this aliasTable) GetByDidAlias(ctx context.Context, did string, alias string) (*Alias, error) {
var alias Alias
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &alias,
did,
alias,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &alias, nil
}
func (this aliasTable) List(ctx context.Context, prefixKey AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return AliasIterator{it}, err
}
func (this aliasTable) ListRange(ctx context.Context, from, to AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return AliasIterator{it}, err
}
func (this aliasTable) DeleteBy(ctx context.Context, prefixKey AliasIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this aliasTable) DeleteRange(ctx context.Context, from, to AliasIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this aliasTable) doNotImplement() {}
var _ AliasTable = aliasTable{}
func NewAliasTable(db ormtable.Schema) (AliasTable, error) {
table := db.GetTable(&Alias{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Alias{}).ProtoReflect().Descriptor().FullName()))
}
return aliasTable{table}, nil
}
type ControllerTable interface {
Insert(ctx context.Context, controller *Controller) error
Update(ctx context.Context, controller *Controller) error
Save(ctx context.Context, controller *Controller) error
Delete(ctx context.Context, controller *Controller) error
Has(ctx context.Context, id string) (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 string) (*Controller, error)
HasByAddress(ctx context.Context, address string) (found bool, err error)
// GetByAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByAddress(ctx context.Context, address string) (*Controller, error)
HasByVaultCid(ctx context.Context, vault_cid string) (found bool, err error)
// GetByVaultCid returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByVaultCid(ctx context.Context, vault_cid string) (*Controller, error)
List(ctx context.Context, prefixKey ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error)
ListRange(ctx context.Context, from, to ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error)
DeleteBy(ctx context.Context, prefixKey ControllerIndexKey) error
DeleteRange(ctx context.Context, from, to ControllerIndexKey) error
doNotImplement()
}
type ControllerIterator struct {
ormtable.Iterator
}
func (i ControllerIterator) Value() (*Controller, error) {
var controller Controller
err := i.UnmarshalMessage(&controller)
return &controller, err
}
type ControllerIndexKey interface {
id() uint32
values() []interface{}
controllerIndexKey()
}
// primary key starting index..
type ControllerPrimaryKey = ControllerIdIndexKey
type ControllerIdIndexKey struct {
vs []interface{}
}
func (x ControllerIdIndexKey) id() uint32 { return 0 }
func (x ControllerIdIndexKey) values() []interface{} { return x.vs }
func (x ControllerIdIndexKey) controllerIndexKey() {}
func (this ControllerIdIndexKey) WithId(id string) ControllerIdIndexKey {
this.vs = []interface{}{id}
return this
}
type ControllerAddressIndexKey struct {
vs []interface{}
}
func (x ControllerAddressIndexKey) id() uint32 { return 1 }
func (x ControllerAddressIndexKey) values() []interface{} { return x.vs }
func (x ControllerAddressIndexKey) controllerIndexKey() {}
func (this ControllerAddressIndexKey) WithAddress(address string) ControllerAddressIndexKey {
this.vs = []interface{}{address}
return this
}
type ControllerVaultCidIndexKey struct {
vs []interface{}
}
func (x ControllerVaultCidIndexKey) id() uint32 { return 2 }
func (x ControllerVaultCidIndexKey) values() []interface{} { return x.vs }
func (x ControllerVaultCidIndexKey) controllerIndexKey() {}
func (this ControllerVaultCidIndexKey) WithVaultCid(vault_cid string) ControllerVaultCidIndexKey {
this.vs = []interface{}{vault_cid}
return this
}
type ControllerStatusIndexKey struct {
vs []interface{}
}
func (x ControllerStatusIndexKey) id() uint32 { return 3 }
func (x ControllerStatusIndexKey) values() []interface{} { return x.vs }
func (x ControllerStatusIndexKey) controllerIndexKey() {}
func (this ControllerStatusIndexKey) WithStatus(status string) ControllerStatusIndexKey {
this.vs = []interface{}{status}
return this
}
type controllerTable struct {
table ormtable.Table
}
func (this controllerTable) Insert(ctx context.Context, controller *Controller) error {
return this.table.Insert(ctx, controller)
}
func (this controllerTable) Update(ctx context.Context, controller *Controller) error {
return this.table.Update(ctx, controller)
}
func (this controllerTable) Save(ctx context.Context, controller *Controller) error {
return this.table.Save(ctx, controller)
}
func (this controllerTable) Delete(ctx context.Context, controller *Controller) error {
return this.table.Delete(ctx, controller)
}
func (this controllerTable) Has(ctx context.Context, id string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, id)
}
func (this controllerTable) Get(ctx context.Context, id string) (*Controller, error) {
var controller Controller
found, err := this.table.PrimaryKey().Get(ctx, &controller, id)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &controller, nil
}
func (this controllerTable) HasByAddress(ctx context.Context, address string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
address,
)
}
func (this controllerTable) GetByAddress(ctx context.Context, address string) (*Controller, error) {
var controller Controller
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &controller,
address,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &controller, nil
}
func (this controllerTable) HasByVaultCid(ctx context.Context, vault_cid string) (found bool, err error) {
return this.table.GetIndexByID(2).(ormtable.UniqueIndex).Has(ctx,
vault_cid,
)
}
func (this controllerTable) GetByVaultCid(ctx context.Context, vault_cid string) (*Controller, error) {
var controller Controller
found, err := this.table.GetIndexByID(2).(ormtable.UniqueIndex).Get(ctx, &controller,
vault_cid,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &controller, nil
}
func (this controllerTable) List(ctx context.Context, prefixKey ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ControllerIterator{it}, err
}
func (this controllerTable) ListRange(ctx context.Context, from, to ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ControllerIterator{it}, err
}
func (this controllerTable) DeleteBy(ctx context.Context, prefixKey ControllerIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this controllerTable) DeleteRange(ctx context.Context, from, to ControllerIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this controllerTable) doNotImplement() {}
var _ ControllerTable = controllerTable{}
func NewControllerTable(db ormtable.Schema) (ControllerTable, error) {
table := db.GetTable(&Controller{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Controller{}).ProtoReflect().Descriptor().FullName()))
}
return controllerTable{table}, nil
}
type VerificationTable interface {
Insert(ctx context.Context, verification *Verification) error
Update(ctx context.Context, verification *Verification) error
Save(ctx context.Context, verification *Verification) error
Delete(ctx context.Context, verification *Verification) error
Has(ctx context.Context, id string) (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 string) (*Verification, error)
HasByControllerMethodIssuerSubject(ctx context.Context, controller string, method DIDNamespace, issuer string, subject string) (found bool, err error)
// GetByControllerMethodIssuerSubject returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByControllerMethodIssuerSubject(ctx context.Context, controller string, method DIDNamespace, issuer string, subject string) (*Verification, error)
List(ctx context.Context, prefixKey VerificationIndexKey, opts ...ormlist.Option) (VerificationIterator, error)
ListRange(ctx context.Context, from, to VerificationIndexKey, opts ...ormlist.Option) (VerificationIterator, error)
DeleteBy(ctx context.Context, prefixKey VerificationIndexKey) error
DeleteRange(ctx context.Context, from, to VerificationIndexKey) error
doNotImplement()
}
type VerificationIterator struct {
ormtable.Iterator
}
func (i VerificationIterator) Value() (*Verification, error) {
var verification Verification
err := i.UnmarshalMessage(&verification)
return &verification, err
}
type VerificationIndexKey interface {
id() uint32
values() []interface{}
verificationIndexKey()
}
// primary key starting index..
type VerificationPrimaryKey = VerificationIdIndexKey
type VerificationIdIndexKey struct {
vs []interface{}
}
func (x VerificationIdIndexKey) id() uint32 { return 0 }
func (x VerificationIdIndexKey) values() []interface{} { return x.vs }
func (x VerificationIdIndexKey) verificationIndexKey() {}
func (this VerificationIdIndexKey) WithId(id string) VerificationIdIndexKey {
this.vs = []interface{}{id}
return this
}
type VerificationControllerMethodIssuerSubjectIndexKey struct {
vs []interface{}
}
func (x VerificationControllerMethodIssuerSubjectIndexKey) id() uint32 { return 1 }
func (x VerificationControllerMethodIssuerSubjectIndexKey) values() []interface{} { return x.vs }
func (x VerificationControllerMethodIssuerSubjectIndexKey) verificationIndexKey() {}
func (this VerificationControllerMethodIssuerSubjectIndexKey) WithController(controller string) VerificationControllerMethodIssuerSubjectIndexKey {
this.vs = []interface{}{controller}
return this
}
func (this VerificationControllerMethodIssuerSubjectIndexKey) WithControllerMethod(controller string, method DIDNamespace) VerificationControllerMethodIssuerSubjectIndexKey {
this.vs = []interface{}{controller, method}
return this
}
func (this VerificationControllerMethodIssuerSubjectIndexKey) WithControllerMethodIssuer(controller string, method DIDNamespace, issuer string) VerificationControllerMethodIssuerSubjectIndexKey {
this.vs = []interface{}{controller, method, issuer}
return this
}
func (this VerificationControllerMethodIssuerSubjectIndexKey) WithControllerMethodIssuerSubject(controller string, method DIDNamespace, issuer string, subject string) VerificationControllerMethodIssuerSubjectIndexKey {
this.vs = []interface{}{controller, method, issuer, subject}
return this
}
type verificationTable struct {
table ormtable.Table
}
func (this verificationTable) Insert(ctx context.Context, verification *Verification) error {
return this.table.Insert(ctx, verification)
}
func (this verificationTable) Update(ctx context.Context, verification *Verification) error {
return this.table.Update(ctx, verification)
}
func (this verificationTable) Save(ctx context.Context, verification *Verification) error {
return this.table.Save(ctx, verification)
}
func (this verificationTable) Delete(ctx context.Context, verification *Verification) error {
return this.table.Delete(ctx, verification)
}
func (this verificationTable) Has(ctx context.Context, id string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, id)
}
func (this verificationTable) Get(ctx context.Context, id string) (*Verification, error) {
var verification Verification
found, err := this.table.PrimaryKey().Get(ctx, &verification, id)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &verification, nil
}
func (this verificationTable) HasByControllerMethodIssuerSubject(ctx context.Context, controller string, method DIDNamespace, issuer string, subject string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
controller,
method,
issuer,
subject,
)
}
func (this verificationTable) GetByControllerMethodIssuerSubject(ctx context.Context, controller string, method DIDNamespace, issuer string, subject string) (*Verification, error) {
var verification Verification
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &verification,
controller,
method,
issuer,
subject,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &verification, nil
}
func (this verificationTable) List(ctx context.Context, prefixKey VerificationIndexKey, opts ...ormlist.Option) (VerificationIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return VerificationIterator{it}, err
}
func (this verificationTable) ListRange(ctx context.Context, from, to VerificationIndexKey, opts ...ormlist.Option) (VerificationIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return VerificationIterator{it}, err
}
func (this verificationTable) DeleteBy(ctx context.Context, prefixKey VerificationIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this verificationTable) DeleteRange(ctx context.Context, from, to VerificationIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this verificationTable) doNotImplement() {}
var _ VerificationTable = verificationTable{}
func NewVerificationTable(db ormtable.Schema) (VerificationTable, error) {
table := db.GetTable(&Verification{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Verification{}).ProtoReflect().Descriptor().FullName()))
}
return verificationTable{table}, nil
}
type StateStore interface {
AliasTable() AliasTable
ControllerTable() ControllerTable
VerificationTable() VerificationTable
doNotImplement()
}
type stateStore struct {
alias AliasTable
controller ControllerTable
verification VerificationTable
}
func (x stateStore) AliasTable() AliasTable {
return x.alias
}
func (x stateStore) ControllerTable() ControllerTable {
return x.controller
}
func (x stateStore) VerificationTable() VerificationTable {
return x.verification
}
func (stateStore) doNotImplement() {}
var _ StateStore = stateStore{}
func NewStateStore(db ormtable.Schema) (StateStore, error) {
aliasTable, err := NewAliasTable(db)
if err != nil {
return nil, err
}
controllerTable, err := NewControllerTable(db)
if err != nil {
return nil, err
}
verificationTable, err := NewVerificationTable(db)
if err != nil {
return nil, err
}
return stateStore{
aliasTable,
controllerTable,
verificationTable,
}, nil
}