Skip to content

Commit

Permalink
fix(nodebuilder/da): add handling for empty submit options
Browse files Browse the repository at this point in the history
This change ensures that if the options byte slice is empty, the parseOptions function returns an empty slice of ConfigOption without proceeding to unmarshal. This prevents potential errors and enhances the function's robustness.
  • Loading branch information
tzdybal committed Sep 19, 2024
1 parent a5faf32 commit c835b77
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nodebuilder/da/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,23 @@ func (s *Service) SubmitWithOptions(
}

func parseOptions(options []byte) ([]state.ConfigOption, error) {
var opts []state.ConfigOption

parsedOpts := struct {
KeyName string
SignerAddress string
FeeGranterAddress string
}{}

if len(options) == 0 {
return opts, nil
}

err := json.Unmarshal(options, &parsedOpts)
if err != nil {
return nil, err
}

var opts []state.ConfigOption
if parsedOpts.KeyName != "" {
opts = append(opts, state.WithKeyName(parsedOpts.KeyName))
}
Expand Down

0 comments on commit c835b77

Please sign in to comment.