avoid use map point

This commit is contained in:
maskpp 2024-06-28 20:46:15 +08:00
parent 045b9718d5
commit ca0813a7b7
2 changed files with 5 additions and 5 deletions

View file

@ -135,7 +135,7 @@ func (ec *Client) GetProof(ctx context.Context, account common.Address, keys []s
// overrides specifies a map of contract states that should be overwritten before executing // overrides specifies a map of contract states that should be overwritten before executing
// the message call. // the message call.
// Please use ethclient.CallContract instead if you don't need the override functionality. // Please use ethclient.CallContract instead if you don't need the override functionality.
func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides *map[common.Address]OverrideAccount) ([]byte, error) { func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides map[common.Address]OverrideAccount) ([]byte, error) {
var hex hexutil.Bytes var hex hexutil.Bytes
err := ec.c.CallContext( err := ec.c.CallContext(
ctx, &hex, "eth_call", toCallArg(msg), ctx, &hex, "eth_call", toCallArg(msg),
@ -157,7 +157,7 @@ func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockN
// blockOverrides specifies block fields exposed to the EVM that can be overridden for the call. // blockOverrides specifies block fields exposed to the EVM that can be overridden for the call.
// //
// Please use ethclient.CallContract instead if you don't need the override functionality. // Please use ethclient.CallContract instead if you don't need the override functionality.
func (ec *Client) CallContractWithBlockOverrides(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides *map[common.Address]OverrideAccount, blockOverrides BlockOverrides) ([]byte, error) { func (ec *Client) CallContractWithBlockOverrides(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, overrides map[common.Address]OverrideAccount, blockOverrides BlockOverrides) ([]byte, error) {
var hex hexutil.Bytes var hex hexutil.Bytes
err := ec.c.CallContext( err := ec.c.CallContext(
ctx, &hex, "eth_call", toCallArg(msg), ctx, &hex, "eth_call", toCallArg(msg),

View file

@ -442,7 +442,7 @@ func testCallContract(t *testing.T, client *rpc.Client) {
} }
mapAcc := make(map[common.Address]OverrideAccount) mapAcc := make(map[common.Address]OverrideAccount)
mapAcc[testAddr] = override mapAcc[testAddr] = override
if _, err := ec.CallContract(context.Background(), msg, big.NewInt(0), &mapAcc); err != nil { if _, err := ec.CallContract(context.Background(), msg, big.NewInt(0), mapAcc); err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
} }
@ -548,7 +548,7 @@ func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
} }
mapAcc := make(map[common.Address]OverrideAccount) mapAcc := make(map[common.Address]OverrideAccount)
mapAcc[common.Address{}] = override mapAcc[common.Address{}] = override
res, err := ec.CallContract(context.Background(), msg, big.NewInt(0), &mapAcc) res, err := ec.CallContract(context.Background(), msg, big.NewInt(0), mapAcc)
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
@ -560,7 +560,7 @@ func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
bo := BlockOverrides{ bo := BlockOverrides{
Coinbase: common.HexToAddress("0x1111111111111111111111111111111111111111"), Coinbase: common.HexToAddress("0x1111111111111111111111111111111111111111"),
} }
res, err = ec.CallContractWithBlockOverrides(context.Background(), msg, big.NewInt(0), &mapAcc, bo) res, err = ec.CallContractWithBlockOverrides(context.Background(), msg, big.NewInt(0), mapAcc, bo)
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }