diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5d495bab..7f58ff534b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#474](https://github.com/crypto-org-chain/ethermint/pull/474), [#476](https://github.com/crypto-org-chain/ethermint/pull/441) Align genesis related cmd. * (rpc) [#480](https://github.com/crypto-org-chain/ethermint/pull/480), [#482](https://github.com/crypto-org-chain/ethermint/pull/482) Fix parsed logs from old events. * (rpc) [#488](https://github.com/crypto-org-chain/ethermint/pull/488) Fix handling of pending transactions related APIs. +* (rpc) [#501](https://github.com/crypto-org-chain/ethermint/pull/501) Avoid invalid chain id for signer error when rpc call before chain id set in BeginBlock. ### Improvements diff --git a/app/app.go b/app/app.go index 40d991e8a3..aacc1cb2d8 100644 --- a/app/app.go +++ b/app/app.go @@ -1026,6 +1026,7 @@ func (app *EthermintApp) SimulationManager() *module.SimulationManager { // API server. func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx + app.EvmKeeper.WithChainIDString(clientCtx.ChainID) // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register new tendermint queries routes from grpc-gateway. diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 56acb834f5..99d12e085e 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -120,9 +120,14 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return sdkCtx.Logger().With("module", "x/"+types.ModuleName) } -// WithChainID sets the chain id to the local variable in the keeper +// WithChainID sets the chain ID for the keeper by extracting it from the provided context func (k *Keeper) WithChainID(ctx sdk.Context) { - chainID, err := ethermint.ParseChainID(ctx.ChainID()) + k.WithChainIDString(ctx.ChainID()) +} + +// WithChainIDString sets the chain ID for the keeper after parsing the provided string value +func (k *Keeper) WithChainIDString(value string) { + chainID, err := ethermint.ParseChainID(value) if err != nil { panic(err) }