Skip to content

Commit

Permalink
Problem: tx evm raw doesn't work under offline mode
Browse files Browse the repository at this point in the history
add evm_denom
  • Loading branch information
mmsqe committed Sep 13, 2024
1 parent 56f8a5b commit eea9eeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (block-stm) [#510](https://github.com/crypto-org-chain/ethermint/pull/510) Include a fix to avoid nondeterministic account set when stm workers execute in parallel.
* (rpc) [#521](https://github.com/crypto-org-chain/ethermint/pull/521) Align hash and miner in subscribe newHeads with eth_getBlockByNumber.
* (rpc) [#516](https://github.com/crypto-org-chain/ethermint/pull/516) Avoid method eth_chainId crashed due to nil pointer on IsEIP155 check.
* (cli) [#524](https://github.com/crypto-org-chain/ethermint/pull/524) Allow tx evm raw run under offline mode with evm_denom flag.

### Improvements

Expand Down
15 changes: 13 additions & 2 deletions x/evm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
"github.com/evmos/ethermint/x/evm/types"
)

const FlagEvmDenom = "evm_denom"

// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -77,12 +79,20 @@ func NewRawTxCmd() *cobra.Command {
return err
}

rsp, err := rpctypes.NewQueryClient(clientCtx).Params(cmd.Context(), &types.QueryParamsRequest{})
evmDenom, err := cmd.Flags().GetString(FlagEvmDenom)

Check warning on line 82 in x/evm/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/evm/client/cli/tx.go#L82

Added line #L82 was not covered by tests
if err != nil {
return err
}

tx, err := msg.BuildTx(clientCtx.TxConfig.NewTxBuilder(), rsp.Params.EvmDenom)
if evmDenom == "" {
rsp, err := rpctypes.NewQueryClient(clientCtx).Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err

Check warning on line 90 in x/evm/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/evm/client/cli/tx.go#L87-L90

Added lines #L87 - L90 were not covered by tests
}
evmDenom = rsp.Params.EvmDenom

Check warning on line 92 in x/evm/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/evm/client/cli/tx.go#L92

Added line #L92 was not covered by tests
}

tx, err := msg.BuildTx(clientCtx.TxConfig.NewTxBuilder(), evmDenom)

Check warning on line 95 in x/evm/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/evm/client/cli/tx.go#L95

Added line #L95 was not covered by tests
if err != nil {
return err
}
Expand Down Expand Up @@ -129,5 +139,6 @@ func NewRawTxCmd() *cobra.Command {
}

flags.AddTxFlagsToCmd(cmd)
cmd.Flags().String(FlagEvmDenom, types.DefaultEVMDenom, "defines the default EVM denomination")

Check warning on line 142 in x/evm/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/evm/client/cli/tx.go#L142

Added line #L142 was not covered by tests
return cmd
}

0 comments on commit eea9eeb

Please sign in to comment.