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

Commit

Permalink
rpc: fix default signer (#769)
Browse files Browse the repository at this point in the history
* rpc: fix default signer

* changelog
  • Loading branch information
fedekunze authored Nov 22, 2021
1 parent 93020f8 commit be8fd86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit be8fd86

Please sign in to comment.