From d977173c4a9a0f0641f0cacf1974caa54ce41f36 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 30 Oct 2023 21:06:29 +0100 Subject: [PATCH] add more docs --- x/accounts/internal/implementation/api_builder.go | 8 +++++--- x/accounts/internal/implementation/implementation.go | 6 ++++-- x/accounts/internal/implementation/protoaccount.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/x/accounts/internal/implementation/api_builder.go b/x/accounts/internal/implementation/api_builder.go index 2019c9387169..33454a6d549c 100644 --- a/x/accounts/internal/implementation/api_builder.go +++ b/x/accounts/internal/implementation/api_builder.go @@ -44,8 +44,8 @@ func (i *InitBuilder) makeHandler() (func(ctx context.Context, initRequest any) // NewExecuteBuilder creates a new ExecuteBuilder instance. func NewExecuteBuilder() *ExecuteBuilder { return &ExecuteBuilder{ - handlers: make(map[string]func(ctx context.Context, executeRequest any) (executeResponse any, err error)), - HandlerSchema: make(map[string]HandlerSchema), + handlers: make(map[string]func(ctx context.Context, executeRequest any) (executeResponse any, err error)), + handlersSchema: make(map[string]HandlerSchema), } } @@ -55,7 +55,9 @@ type ExecuteBuilder struct { // handlers is a map of handler functions that will be called when the smart account is executed. handlers map[string]func(ctx context.Context, executeRequest any) (executeResponse any, err error) - HandlerSchema map[string]HandlerSchema + // handlersSchema is a map of schemas for the messages that will be passed to the handler functions + // and the messages that will be returned by the handler functions. + handlersSchema map[string]HandlerSchema // err is the error that occurred before building the handler function. err error diff --git a/x/accounts/internal/implementation/implementation.go b/x/accounts/internal/implementation/implementation.go index 6b622a159e2c..cc114f0d650a 100644 --- a/x/accounts/internal/implementation/implementation.go +++ b/x/accounts/internal/implementation/implementation.go @@ -32,6 +32,8 @@ func AddAccount[A Account](name string, constructor func(deps Dependencies) (A, } } +// MakeAccountsMap creates a map of account names to account implementations +// from a list of account creator functions. func MakeAccountsMap(addressCodec address.Codec, accounts []AccountCreatorFunc) (map[string]Implementation, error) { accountsMap := make(map[string]Implementation, len(accounts)) for _, makeAccount := range accounts { @@ -91,8 +93,8 @@ func NewImplementation(account Account) (Implementation, error) { Query: queryHandler, CollectionsSchema: collections.Schema{}, InitHandlerSchema: ir.schema, - QueryHandlersSchema: qr.er.HandlerSchema, - ExecuteHandlersSchema: er.HandlerSchema, + QueryHandlersSchema: qr.er.handlersSchema, + ExecuteHandlersSchema: er.handlersSchema, DecodeExecuteRequest: er.makeRequestDecoder(), EncodeExecuteResponse: er.makeResponseEncoder(), DecodeQueryRequest: qr.er.makeRequestDecoder(), diff --git a/x/accounts/internal/implementation/protoaccount.go b/x/accounts/internal/implementation/protoaccount.go index 62d8739bd7dc..23b0145f39e9 100644 --- a/x/accounts/internal/implementation/protoaccount.go +++ b/x/accounts/internal/implementation/protoaccount.go @@ -58,7 +58,7 @@ func RegisterExecuteHandler[ return handler(ctx, concrete) } - router.HandlerSchema[string(reqName)] = HandlerSchema{ + router.handlersSchema[string(reqName)] = HandlerSchema{ RequestSchema: *NewProtoMessageSchema[Req, ProtoReq](), ResponseSchema: *NewProtoMessageSchema[Resp, ProtoResp](), }