Skip to content

Commit

Permalink
rename TxOptions to TxConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Jun 28, 2024
1 parent ce38ba4 commit 1596439
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 167 deletions.
4 changes: 2 additions & 2 deletions api/docgen/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ func init() {
}
addToExampleValues(libhead.Hash(hash))

txOptions := state.NewTxOptions(
txConfig := state.NewTxConfig(
state.WithGasPrice(0.002),
state.WithGas(142225),
state.WithKeyName("my_celes_key"),
state.WithSignerAddress("celestia1pjcmwj8w6hyr2c4wehakc5g8cfs36aysgucx66"),
state.WithFeeGranterAddress("celestia1hakc56ax66ypjcmwj8w6hyr2c4g8cfs3wesguc"),
)
addToExampleValues(txOptions)
addToExampleValues(txConfig)
}

func addToExampleValues(v interface{}) {
Expand Down
4 changes: 2 additions & 2 deletions api/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ func TestAuthedRPC(t *testing.T) {
server.State.EXPECT().Delegate(gomock.Any(), gomock.Any(),
gomock.Any(), gomock.Any()).Return(expectedResp, nil)
txResp, err := rpcClient.State.Delegate(ctx,
state.ValAddress{}, state.Int{}, state.NewTxOptions())
state.ValAddress{}, state.Int{}, state.NewTxConfig())
require.NoError(t, err)
require.Equal(t, expectedResp, txResp)
} else {
_, err := rpcClient.State.Delegate(ctx,
state.ValAddress{}, state.Int{}, state.NewTxOptions())
state.ValAddress{}, state.Int{}, state.NewTxConfig())
require.Error(t, err)
require.ErrorContains(t, err, "missing permission")
}
Expand Down
6 changes: 3 additions & 3 deletions blob/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
// avoid a circular dependency between the blob and the state package, since the state package needs
// the blob.Blob type for this signature.
type Submitter interface {
SubmitPayForBlob(context.Context, []*state.Blob, *state.TxOptions) (*types.TxResponse, error)
SubmitPayForBlob(context.Context, []*state.Blob, *state.TxConfig) (*types.TxResponse, error)
}

type Service struct {
Expand Down Expand Up @@ -61,7 +61,7 @@ func NewService(
// Allows sending multiple Blobs atomically synchronously.
// Uses default wallet registered on the Node.
// Handles gas estimation and fee calculation.
func (s *Service) Submit(ctx context.Context, blobs []*Blob, txOptions *state.TxOptions) (uint64, error) {
func (s *Service) Submit(ctx context.Context, blobs []*Blob, txConfig *state.TxConfig) (uint64, error) {
log.Debugw("submitting blobs", "amount", len(blobs))

appblobs := make([]*state.Blob, len(blobs))
Expand All @@ -72,7 +72,7 @@ func (s *Service) Submit(ctx context.Context, blobs []*Blob, txOptions *state.Tx
appblobs[i] = &blobs[i].Blob
}

resp, err := s.blobSubmitter.SubmitPayForBlob(ctx, appblobs, txOptions)
resp, err := s.blobSubmitter.SubmitPayForBlob(ctx, appblobs, txConfig)
if err != nil {
return 0, err
}
Expand Down
16 changes: 8 additions & 8 deletions docs/adr/adr-009-public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ NetworkHead(ctx context.Context) (*header.ExtendedHeader, error)
ctx context.Context,
nID namespace.ID,
data []byte,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)
// Transfer sends the given amount of coins from default wallet of the node
// to the given account address.
Transfer(
ctx context.Context,
to types.Address,
amount types.Int,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)

// StateModule also provides StakingModule
Expand All @@ -282,23 +282,23 @@ yet.
ctx context.Context,
delAddr state.ValAddress,
amount state.Int,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)
// BeginRedelegate sends a user's delegated tokens to a new validator for redelegation.
BeginRedelegate(
ctx context.Context,
srcValAddr,
dstValAddr state.ValAddress,
amount state.Int,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)
// Undelegate undelegates a user's delegated tokens, unbonding them from the
// current validator.
Undelegate(
ctx context.Context,
delAddr state.ValAddress,
amount state.Int,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)

// CancelUnbondingDelegation cancels a user's pending undelegation from a
Expand All @@ -308,7 +308,7 @@ yet.
valAddr state.ValAddress,
amount types.Int,
height types.Int,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)

// QueryDelegation retrieves the delegation information between a delegator
Expand Down Expand Up @@ -399,15 +399,15 @@ type BankModule interface {
SubmitPayForBlob(
ctx context.Context,
blobs []*state.Blob,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)
// Transfer sends the given amount of coins from default wallet of the node
// to the given account address.
Transfer(
ctx context.Context,
to state.AccAddress,
amount state.Int,
options *state.TxOptions,
options *state.TxConfig,
) (*state.TxResponse, error)
}
```
Expand Down
6 changes: 3 additions & 3 deletions nodebuilder/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Module interface {
// Submit sends Blobs and reports the height in which they were included.
// Allows sending multiple Blobs atomically synchronously.
// Uses default wallet registered on the Node.
Submit(_ context.Context, _ []*blob.Blob, _ *state.TxOptions) (height uint64, _ error)
Submit(_ context.Context, _ []*blob.Blob, _ *state.TxConfig) (height uint64, _ error)
// Get retrieves the blob by commitment under the given namespace and height.
Get(_ context.Context, height uint64, _ share.Namespace, _ blob.Commitment) (*blob.Blob, error)
// GetAll returns all blobs at the given height under the given namespaces.
Expand All @@ -31,15 +31,15 @@ type Module interface {

type API struct {
Internal struct {
Submit func(context.Context, []*blob.Blob, *state.TxOptions) (uint64, error) `perm:"write"`
Submit func(context.Context, []*blob.Blob, *state.TxConfig) (uint64, error) `perm:"write"`
Get func(context.Context, uint64, share.Namespace, blob.Commitment) (*blob.Blob, error) `perm:"read"`
GetAll func(context.Context, uint64, []share.Namespace) ([]*blob.Blob, error) `perm:"read"`
GetProof func(context.Context, uint64, share.Namespace, blob.Commitment) (*blob.Proof, error) `perm:"read"`
Included func(context.Context, uint64, share.Namespace, *blob.Proof, blob.Commitment) (bool, error) `perm:"read"`
}
}

func (api *API) Submit(ctx context.Context, blobs []*blob.Blob, options *state.TxOptions) (uint64, error) {
func (api *API) Submit(ctx context.Context, blobs []*blob.Blob, options *state.TxConfig) (uint64, error) {
return api.Internal.Submit(ctx, blobs, options)
}

Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/blob/cmd/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ var submitCmd = &cobra.Command{
height, err := client.Blob.Submit(
cmd.Context(),
resultBlobs,
state.GetTxOptions(),
state.GetTxConfig(),
)

response := struct {
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/blob/mocks/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nodebuilder/da/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *Service) Submit(
return nil, err
}

opts := state.NewTxOptions(state.WithGasPrice(gasPrice))
opts := state.NewTxConfig(state.WithGasPrice(gasPrice))

height, err := s.blobServ.Submit(ctx, blobs, opts)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions nodebuilder/state/cmd/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func init() {
"The default value is 0 which means the grantee does not have a spend limit.",
)

// apply option flags for all txs that require `TxOptions`.
// apply option flags for all txs that require `TxConfig`.
ApplyFlags(
transferCmd,
cancelUnbondingDelegationCmd,
Expand Down Expand Up @@ -144,7 +144,7 @@ var transferCmd = &cobra.Command{
cmd.Context(),
addr.Address.(state.AccAddress),
math.NewInt(amount),
GetTxOptions(),
GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand Down Expand Up @@ -181,7 +181,7 @@ var cancelUnbondingDelegationCmd = &cobra.Command{
addr.Address.(state.ValAddress),
math.NewInt(amount),
math.NewInt(height),
GetTxOptions(),
GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand Down Expand Up @@ -218,7 +218,7 @@ var beginRedelegateCmd = &cobra.Command{
srcAddr.Address.(state.ValAddress),
dstAddr.Address.(state.ValAddress),
math.NewInt(amount),
GetTxOptions(),
GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand Down Expand Up @@ -249,7 +249,7 @@ var undelegateCmd = &cobra.Command{
cmd.Context(),
addr.Address.(state.ValAddress),
math.NewInt(amount),
GetTxOptions(),
GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand Down Expand Up @@ -280,7 +280,7 @@ var delegateCmd = &cobra.Command{
cmd.Context(),
addr.Address.(state.ValAddress),
math.NewInt(amount),
GetTxOptions(),
GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand Down Expand Up @@ -378,7 +378,7 @@ var grantFeeCmd = &cobra.Command{
txResponse, err := client.State.GrantFee(
cmd.Context(),
granteeAddr.Address.(state.AccAddress),
math.NewInt(int64(amount)), GetTxOptions(),
math.NewInt(int64(amount)), GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand All @@ -403,7 +403,7 @@ var revokeGrantFeeCmd = &cobra.Command{
txResponse, err := client.State.RevokeGrantFee(
cmd.Context(),
granteeAddr.Address.(state.AccAddress),
GetTxOptions(),
GetTxConfig(),
)
return cmdnode.PrintOutput(txResponse, err, nil)
},
Expand Down Expand Up @@ -464,8 +464,8 @@ func ApplyFlags(cmds ...*cobra.Command) {
}
}

func GetTxOptions() *state.TxOptions {
return state.NewTxOptions(
func GetTxConfig() *state.TxConfig {
return state.NewTxConfig(
state.WithGasPrice(gasPrice),
state.WithGas(gas),
state.WithKeyName(keyName),
Expand Down
16 changes: 8 additions & 8 deletions nodebuilder/state/mocks/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1596439

Please sign in to comment.