Skip to content

Commit

Permalink
Problem: invalid chain id for signer
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jul 23, 2024
1 parent d874df7 commit e295477
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 1029 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L1029

Added line #L1029 was not covered by tests
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
Expand Down
9 changes: 7 additions & 2 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e295477

Please sign in to comment.