optional block param

This commit is contained in:
Sina Mahmoodi 2023-09-20 17:06:21 +02:00
parent ed4cbaf20f
commit 32312912c9
2 changed files with 7 additions and 3 deletions

View file

@ -1243,8 +1243,12 @@ type multicallOpts struct {
//
// Note, this function doesn't make any changes in the state/blockchain and is
// useful to execute and retrieve values.
func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blockNrOrHash rpc.BlockNumberOrHash) ([]blockResult, error) {
state, header, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]blockResult, error) {
if blockNrOrHash == nil {
n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
blockNrOrHash = &n
}
state, header, err := s.b.StateAndHeaderByNumberOrHash(ctx, *blockNrOrHash)
if state == nil || err != nil {
return nil, err
}

View file

@ -1659,7 +1659,7 @@ func TestMulticallV1(t *testing.T) {
if tc.validation != nil && *tc.validation {
opts.Validation = true
}
result, err := api.MulticallV1(context.Background(), opts, tc.tag)
result, err := api.MulticallV1(context.Background(), opts, &tc.tag)
if tc.expectErr != nil {
if err == nil {
t.Fatalf("test %s: want error %v, have nothing", tc.name, tc.expectErr)