Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 8 additions & 4 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,19 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
return hexutil.Uint64(api.e.Miner().HashRate())
}

// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
// ChainId is the chain id for the current ethereum chain config.
func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 {
chainID := new(big.Int)
if config := api.e.blockchain.Config(); config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) {
chainID = config.ChainID
}
chainID = api.e.blockchain.Config().ChainID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify it to return (hexutil.Uint64)(api.e.blockchain.Config().ChainID.Uint64())

return (hexutil.Uint64)(chainID.Uint64())
}

// IsEIP155 returns whether the current chain is on or past the
// EIP-155 replay-protection fork block.
func (api *PublicEthereumAPI) IsEIP155() bool {
return api.e.blockchain.Config().IsEIP155(api.e.blockchain.CurrentBlock().Number())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this method

}

// PublicMinerAPI provides an API to control the miner.
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
type PublicMinerAPI struct {
Expand Down
5 changes: 5 additions & 0 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ web3._extend({
call: 'eth_chainId',
params: 0
}),
new web3._extend.Method({
name: 'isEIP155',
call: 'eth_isEIP155',
params: 0
}),
new web3._extend.Method({
name: 'sign',
call: 'eth_sign',
Expand Down