Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#192: Insert dummy message if args or return are empty in ABI #193

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions internal/cli/contract_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func (c *RegisterCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)

// Iterate through the methods and construct the commands
for name, method := range abi.Methods {
if len(method.Argument) == 0 {
method.Argument = "koinos.chain.nop_arguments"
}
d, err := files.FindDescriptorByName(protoreflect.FullName(method.Argument))
if err != nil {
return nil, fmt.Errorf("%w: could not find type %s", cliutil.ErrInvalidABI, method.Argument)
Expand All @@ -105,14 +108,17 @@ func (c *RegisterCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
return nil, fmt.Errorf("%w: %s", cliutil.ErrInvalidABI, err)
}

if len(method.Return) == 0 {
method.Return = "koinos.chain.nop_result"
}
d, err = files.FindDescriptorByName(protoreflect.FullName(method.Return))
if err != nil {
return nil, fmt.Errorf("%w: could not find type %s", cliutil.ErrInvalidABI, method.Argument)
return nil, fmt.Errorf("%w: could not find type %s", cliutil.ErrInvalidABI, method.Return)
}

_, ok = d.(protoreflect.MessageDescriptor)
if !ok {
return nil, fmt.Errorf("%w: %s is not a message", cliutil.ErrInvalidABI, method.Argument)
return nil, fmt.Errorf("%w: %s is not a message", cliutil.ErrInvalidABI, method.Return)
}

commandName := fmt.Sprintf("%s.%s", c.Name, name)
Expand Down