accountstd

package
v0.0.0-...-397cea1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package accountstd exports the types and functions that are used by developers to implement smart accounts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecModule

func ExecModule[Resp any, RespProto implementation.ProtoMsgG[Resp], Req any, ReqProto implementation.ProtoMsgG[Req]](ctx context.Context, msg ReqProto) (RespProto, error)

ExecModule can be used to execute a message towards a module.

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 ExecModuleUntyped

func ExecModuleUntyped(ctx context.Context, msg implementation.ProtoMsg) (implementation.ProtoMsg, error)

func Funds

func Funds(ctx context.Context) sdk.Coins

Funds returns if any funds were sent during the execute or init request. In queries this returns nil.

func HasSender

func HasSender(ctx context.Context, wantSender []byte) bool

HasSender checks if the execution context was sent from the provided sender

func NewMockContext

func NewMockContext(
	accNumber uint64,
	accountAddr []byte,
	sender []byte,
	funds sdk.Coins,
	moduleExec implementation.ModuleExecFunc,
	moduleExecUntyped implementation.ModuleExecUntypedFunc,
	moduleQuery implementation.ModuleQueryFunc,
) (context.Context, store.KVStoreService)

func PackAny

PackAny packs a protobuf Any message generically.

func QueryModule

func QueryModule[Resp any, RespProto implementation.ProtoMsgG[Resp], Req any, ReqProto implementation.ProtoMsgG[Req]](ctx context.Context, req ReqProto) (RespProto, 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 Sender

func Sender(ctx context.Context) []byte

Sender returns the sender of the execution request.

func SenderIsAccountsModule

func SenderIsAccountsModule(ctx context.Context) bool

SenderIsAccountsModule returns true if the sender of the execution request is the accounts module.

func SenderIsSelf

func SenderIsSelf(ctx context.Context) bool

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.

func Whoami

func Whoami(ctx context.Context) []byte

Whoami returns the address of the account being invoked.

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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL