Skip to content

Commit

Permalink
add more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown unknown committed Oct 30, 2023
1 parent b8c03d2 commit d977173
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions x/accounts/internal/implementation/api_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions x/accounts/internal/implementation/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion x/accounts/internal/implementation/protoaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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](),
}
Expand Down

0 comments on commit d977173

Please sign in to comment.