Skip to content

Commit ca92121

Browse files
authored
Add ChainConfig to ethclient (#1040)
* add ChainConfig to ethclient * return ChainConfig * return ChainConfig in internal api * Revert "return ChainConfig in internal api" This reverts commit c64d231. * Revert "return ChainConfig" This reverts commit 0071f64.
1 parent 01aa236 commit ca92121

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ethclient/ethclient.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
3939
"github.com/ava-labs/subnet-evm/core/types"
4040
"github.com/ava-labs/subnet-evm/interfaces"
41+
"github.com/ava-labs/subnet-evm/params"
4142
"github.com/ava-labs/subnet-evm/rpc"
4243
"github.com/ethereum/go-ethereum/common"
4344
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -69,6 +70,7 @@ var (
6970
type Client interface {
7071
Client() *rpc.Client
7172
Close()
73+
ChainConfig(context.Context) (*params.ChainConfigWithUpgradesJSON, error)
7274
ChainID(context.Context) (*big.Int, error)
7375
BlockByHash(context.Context, common.Hash) (*types.Block, error)
7476
BlockByNumber(context.Context, *big.Int) (*types.Block, error)
@@ -141,6 +143,16 @@ func (ec *client) Client() *rpc.Client {
141143

142144
// Blockchain Access
143145

146+
// ChainConfig retrieves the current chain config.
147+
func (ec *client) ChainConfig(ctx context.Context) (*params.ChainConfigWithUpgradesJSON, error) {
148+
var result *params.ChainConfigWithUpgradesJSON
149+
err := ec.c.CallContext(ctx, &result, "eth_getChainConfig")
150+
if err != nil {
151+
return nil, err
152+
}
153+
return result, err
154+
}
155+
144156
// ChainID retrieves the current chain ID for transaction replay protection.
145157
func (ec *client) ChainID(ctx context.Context) (*big.Int, error) {
146158
var result hexutil.Big

0 commit comments

Comments
 (0)