Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

rpc: fix default signer #769

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions rpc/ethereum/namespaces/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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,
Expand Down