From be8fd869ff9197b9c2e4467b5398dc3a3255b531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:39:25 +0100 Subject: [PATCH] rpc: fix default signer (#769) * rpc: fix default signer * changelog --- CHANGELOG.md | 6 ++++++ rpc/ethereum/namespaces/eth/api.go | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9500c32bd..e1eb6abc1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## Unreleased + +### Bug Fixes + +* (rpc) [tharsis#769](https://github.com/tharsis/ethermint/pull/769) Fix default Ethereum signer for JSON-RPC. + ## [v0.8.0] - 2021-11-17 ### State Machine Breaking diff --git a/rpc/ethereum/namespaces/eth/api.go b/rpc/ethereum/namespaces/eth/api.go index d52ea534c3..d46b4edcd4 100644 --- a/rpc/ethereum/namespaces/eth/api.go +++ b/rpc/ethereum/namespaces/eth/api.go @@ -56,7 +56,7 @@ func NewPublicAPI( backend backend.Backend, nonceLock *rpctypes.AddrLocker, ) *PublicAPI { - epoch, err := ethermint.ParseChainID(clientCtx.ChainID) + eip155ChainID, err := ethermint.ParseChainID(clientCtx.ChainID) if err != nil { panic(err) } @@ -80,13 +80,18 @@ func NewPublicAPI( // The signer used by the API should always be the 'latest' known one because we expect // signers to be backwards-compatible with old transactions. - signer := ethtypes.LatestSigner(backend.ChainConfig()) + cfg := backend.ChainConfig() + if cfg == nil { + cfg = evmtypes.DefaultChainConfig().EthereumConfig(eip155ChainID) + } + + signer := ethtypes.LatestSigner(cfg) api := &PublicAPI{ ctx: context.Background(), clientCtx: clientCtx, queryClient: rpctypes.NewQueryClient(clientCtx), - chainIDEpoch: epoch, + chainIDEpoch: eip155ChainID, logger: logger.With("client", "json-rpc"), backend: backend, nonceLock: nonceLock,