Skip to content

Commit

Permalink
refactor(nodebuilder/da): introduce SubmitOptions struct
Browse files Browse the repository at this point in the history
Anonymous struct used for parsing submit options was extracted as exported struct for better visibility and documentation.
  • Loading branch information
tzdybal committed Sep 24, 2024
1 parent 4fe47ba commit 4a6442b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions nodebuilder/da/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ type Service struct {
headerGetter func(context.Context, uint64) (*header.ExtendedHeader, error)
}

// SubmitOptions defines options for blob submission using SubmitWithOptions.
//
// SubmitWithOptions expects JSON serialized version of this struct; all fields are optional.
type SubmitOptions struct {
// KeyName is the name of key from the keystore used to sign transactions.
KeyName string

// SignerAddress is the address that signs the transaction.
// This address must be stored locally in the key store.
SignerAddress string

// FeeGranterAddress specifies the account that will pay for the transaction fee.
FeeGranterAddress string
}

func NewService(
blobMod nodeblob.Module,
headerGetter func(context.Context, uint64) (*header.ExtendedHeader, error),
Expand Down Expand Up @@ -155,16 +170,11 @@ 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
}

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

0 comments on commit 4a6442b

Please sign in to comment.