Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Browse files Browse the repository at this point in the history
# Conflicts:
#	integration/plugin/testdata/example-plugin/go.mod
#	integration/plugin/testdata/example-plugin/go.sum
  • Loading branch information
Pantani authored and Pantani committed Nov 14, 2023
2 parents d01e2e4 + 0691e0d commit c0297e5
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 345 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Changes

- [#3529](https://github.com/ignite/cli/pull/3529) Refactor plugin system to use gRPC
- [#3745](https://github.com/ignite/cli/pull/3745) Set tx fee amount as option

## [`v0.27.1`](https://github.com/ignite/cli/releases/tag/v0.27.1)

Expand Down
333 changes: 333 additions & 0 deletions go.sum

Large diffs are not rendered by default.

30 changes: 25 additions & 5 deletions ignite/pkg/chaincmd/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/ignite/cli/ignite/pkg/cmdrunner/step"
"github.com/ignite/cli/ignite/pkg/cosmosver"
Expand Down Expand Up @@ -34,6 +35,7 @@ const (
optionRecover = "--recover"
optionAddress = "--address"
optionAmount = "--amount"
optionFees = "--fees"
optionValidatorMoniker = "--moniker"
optionValidatorCommissionRate = "--commission-rate"
optionValidatorCommissionMaxRate = "--commission-max-rate"
Expand Down Expand Up @@ -102,8 +104,8 @@ func (c ChainCmd) Copy(options ...Option) ChainCmd {
type Option func(*ChainCmd)

func applyOptions(c *ChainCmd, options []Option) {
for _, applyOption := range options {
applyOption(c)
for _, apply := range options {
apply(c)
}
}

Expand Down Expand Up @@ -418,8 +420,8 @@ func (c ChainCmd) GentxCommand(
}

// Apply the options provided by the user
for _, applyOption := range options {
command = applyOption(command)
for _, apply := range options {
command = apply(command)
}

command = c.attachChainID(command)
Expand Down Expand Up @@ -476,8 +478,21 @@ func (c ChainCmd) ExportCommand() step.Option {
return c.daemonCommand(command)
}

// BankSendOption for the BankSendCommand.
type BankSendOption func([]string) []string

// BankSendWithFees sets fees to pay along with transaction for the bank send command.
func BankSendWithFees(fee sdk.Coin) BankSendOption {
return func(command []string) []string {
if !fee.IsNil() {
return append(command, optionFees, fee.String())
}
return command
}
}

// BankSendCommand returns the command for transferring tokens.
func (c ChainCmd) BankSendCommand(fromAddress, toAddress, amount string) step.Option {
func (c ChainCmd) BankSendCommand(fromAddress, toAddress, amount string, options ...BankSendOption) step.Option {
command := []string{
commandTx,
}
Expand All @@ -492,6 +507,11 @@ func (c ChainCmd) BankSendCommand(fromAddress, toAddress, amount string) step.Op
optionYes,
)

// Apply the options provided by the user
for _, apply := range options {
command = apply(command)
}

command = c.attachChainID(command)
command = c.attachKeyringBackend(command)
command = c.attachNode(command)
Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/chaincmd/runner/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ func (r Runner) Status(ctx context.Context) (NodeStatus, error) {
}

// BankSend sends amount from fromAccount to toAccount.
func (r Runner) BankSend(ctx context.Context, fromAccount, toAccount, amount string) (string, error) {
func (r Runner) BankSend(ctx context.Context, fromAccount, toAccount, amount string, options ...chaincmd.BankSendOption) (string, error) {
b := newBuffer()
opt := []step.Option{
r.chainCmd.BankSendCommand(fromAccount, toAccount, amount),
r.chainCmd.BankSendCommand(fromAccount, toAccount, amount, options...),
}

if r.chainCmd.KeyringPassword() != "" {
Expand Down
10 changes: 10 additions & 0 deletions ignite/pkg/cosmosfaucet/cosmosfaucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type Faucet struct {
// it holds the maximum amounts of coins that can be sent to a single account.
coinsMax map[string]sdkmath.Int

// fee to pay along with the transaction
feeAmount sdk.Coin

limitRefreshWindow time.Duration

// openAPIData holds template data customizations for serving OpenAPI page & spec.
Expand Down Expand Up @@ -102,6 +105,13 @@ func ChainID(id string) Option {
}
}

// FeeAmount sets a fee that it will be paid during the transaction.
func FeeAmount(amount sdkmath.Int, denom string) Option {
return func(f *Faucet) {
f.feeAmount = sdk.NewCoin(denom, amount)
}
}

// OpenAPI configures how to serve Open API page and spec.
func OpenAPI(apiAddress string) Option {
return func(f *Faucet) {
Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/cosmosfaucet/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/ignite/cli/ignite/pkg/chaincmd"
chaincmdrunner "github.com/ignite/cli/ignite/pkg/chaincmd/runner"
)

Expand Down Expand Up @@ -92,7 +92,7 @@ func (f *Faucet) Transfer(ctx context.Context, toAccountAddress string, coins sd
if err != nil {
return err
}
txHash, err := f.runner.BankSend(ctx, fromAccount.Address, toAccountAddress, strings.Join(coinsStr, ","))
txHash, err := f.runner.BankSend(ctx, fromAccount.Address, toAccountAddress, strings.Join(coinsStr, ","), chaincmd.BankSendWithFees(f.feeAmount))
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit c0297e5

Please sign in to comment.