Documentation ¶
Overview ¶
Package accountstd exports the types and functions that are used by developers to implement smart accounts.
Index ¶
- Variables
- func ExecModule[MsgResp, Msg transaction.Msg](ctx context.Context, msg Msg) (resp MsgResp, err error)
- func ExecModuleAnys(ctx context.Context, msgs []*implementation.Any) ([]*implementation.Any, error)
- func Funds(ctx context.Context) sdk.Coins
- func HasSender(ctx context.Context, wantSender []byte) bool
- func NewMockContext(accNumber uint64, accountAddr []byte, sender []byte, funds sdk.Coins, ...) (context.Context, store.KVStoreService)
- func PackAny(msg transaction.Msg) (*implementation.Any, error)
- func QueryModule[Resp, Req transaction.Msg](ctx context.Context, req Req) (resp Resp, err error)
- func RegisterExecuteHandler[Req any, ProtoReq implementation.ProtoMsgG[Req], Resp any, ...](router *ExecuteBuilder, ...)
- func RegisterInitHandler[Req any, ProtoReq implementation.ProtoMsgG[Req], Resp any, ...](router *InitBuilder, ...)
- func RegisterQueryHandler[Req any, ProtoReq implementation.ProtoMsgG[Req], Resp any, ...](router *QueryBuilder, ...)
- func Sender(ctx context.Context) []byte
- func SenderIsAccountsModule(ctx context.Context) bool
- func SenderIsSelf(ctx context.Context) bool
- func SetSender(ctx context.Context, sender []byte) context.Context
- func UnpackAny[Msg any, ProtoMsg implementation.ProtoMsgG[Msg]](any *implementation.Any) (*Msg, error)
- func Whoami(ctx context.Context) []byte
- type AccountCreatorFunc
- type Dependencies
- type DepinjectAccount
- type ExecuteBuilder
- type InitBuilder
- type Interface
- type QueryBuilder
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidType = errors.New("invalid type")
)
Functions ¶
func ExecModule ¶
func ExecModule[MsgResp, Msg transaction.Msg](ctx context.Context, msg Msg) (resp MsgResp, err error)
func ExecModuleAnys ¶
func ExecModuleAnys(ctx context.Context, msgs []*implementation.Any) ([]*implementation.Any, error)
ExecModuleAnys can be used to execute a list of messages towards a module when those messages are packed in Any messages. The function returns a list of responses packed in Any messages.
func Funds ¶
Funds returns if any funds were sent during the execute or init request. In queries this returns nil.
func NewMockContext ¶
func NewMockContext( accNumber uint64, accountAddr []byte, sender []byte, funds sdk.Coins, moduleExec implementation.ModuleExecFunc, moduleQuery implementation.ModuleQueryFunc, ) (context.Context, store.KVStoreService)
func PackAny ¶
func PackAny(msg transaction.Msg) (*implementation.Any, error)
PackAny packs a protobuf Any message generically.
func QueryModule ¶
func QueryModule[Resp, Req transaction.Msg](ctx context.Context, req Req) (resp Resp, err error)
QueryModule can be used by an account to execute a module query.
func RegisterExecuteHandler ¶
func RegisterExecuteHandler[ Req any, ProtoReq implementation.ProtoMsgG[Req], Resp any, ProtoResp implementation.ProtoMsgG[Resp], ](router *ExecuteBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error), )
func RegisterInitHandler ¶
func RegisterInitHandler[ Req any, ProtoReq implementation.ProtoMsgG[Req], Resp any, ProtoResp implementation.ProtoMsgG[Resp], ](router *InitBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error), )
RegisterInitHandler registers an initialisation handler for a smart account that uses protobuf.
func RegisterQueryHandler ¶
func RegisterQueryHandler[ Req any, ProtoReq implementation.ProtoMsgG[Req], Resp any, ProtoResp implementation.ProtoMsgG[Resp], ](router *QueryBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error), )
RegisterQueryHandler registers a query handler for a smart account that uses protobuf.
func SenderIsAccountsModule ¶
SenderIsAccountsModule returns true if the sender of the execution request is the accounts module.
func SenderIsSelf ¶
SenderIsSelf checks if the sender of the request is the account itself.
func UnpackAny ¶
func UnpackAny[Msg any, ProtoMsg implementation.ProtoMsgG[Msg]](any *implementation.Any) (*Msg, error)
UnpackAny unpacks a protobuf Any message generically.
Types ¶
type AccountCreatorFunc ¶
type AccountCreatorFunc = implementation.AccountCreatorFunc
AccountCreatorFunc is the exported type of AccountCreatorFunc.
func AddAccount ¶
func AddAccount[A Interface](name string, constructor func(deps Dependencies) (A, error)) AccountCreatorFunc
AddAccount is a helper function to add a smart account to the list of smart accounts.
type Dependencies ¶
type Dependencies = implementation.Dependencies
Dependencies is the exported type of Dependencies.
type DepinjectAccount ¶
type DepinjectAccount struct {
MakeAccount AccountCreatorFunc
}
func DIAccount ¶
func DIAccount[A Interface](name string, constructor func(deps Dependencies) (A, error)) DepinjectAccount
func (DepinjectAccount) IsManyPerContainerType ¶
func (DepinjectAccount) IsManyPerContainerType()
type ExecuteBuilder ¶
type ExecuteBuilder = implementation.ExecuteBuilder
ExecuteBuilder is the exported type of ExecuteBuilder.
type InitBuilder ¶
type InitBuilder = implementation.InitBuilder
InitBuilder is the exported type of InitBuilder.
type Interface ¶
type Interface = implementation.Account
Interface is the exported interface of an Account.
type QueryBuilder ¶
type QueryBuilder = implementation.QueryBuilder
QueryBuilder is the exported type of QueryBuilder.