Skip to content

Commit

Permalink
Problem: tx evm raw doesn't work under offline (#524)
Browse files Browse the repository at this point in the history
add evm-denom flag
  • Loading branch information
mmsqe authored Sep 13, 2024
1 parent 56f8a5b commit dbc7eb4
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 for generate only when offline 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)
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
}
evmDenom = rsp.Params.EvmDenom
}

tx, err := msg.BuildTx(clientCtx.TxConfig.NewTxBuilder(), evmDenom)
if err != nil {
return err
}
Expand Down Expand Up @@ -129,5 +139,6 @@ func NewRawTxCmd() *cobra.Command {
}

flags.AddTxFlagsToCmd(cmd)
cmd.Flags().String(FlagEvmDenom, "", "defines the EVM denomination which could be used for generate only when offline")
return cmd
}

0 comments on commit dbc7eb4

Please sign in to comment.