Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/slick-pianos-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#bugfix fix block number nil issue in fake evm
11 changes: 9 additions & 2 deletions core/capabilities/fakes/evm_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fakes
import (
"context"
"crypto/ecdsa"
"errors"
"fmt"
"math/big"
"strings"
Expand Down Expand Up @@ -300,12 +301,18 @@ func (fc *FakeEVMChain) FilterLogs(ctx context.Context, metadata commonCap.Reque
func (fc *FakeEVMChain) BalanceAt(ctx context.Context, metadata commonCap.RequestMetadata, input *evmcappb.BalanceAtRequest) (*commonCap.ResponseAndMetadata[*evmcappb.BalanceAtReply], error) {
fc.eng.Infow("EVM Chain BalanceAt Started", "input", input)

if input == nil {
return nil, errors.New("BalanceAtRequest is nil")
}

// Prepare balance at request
address := common.Address(input.Account)
blockNumber := new(big.Int).SetBytes(input.BlockNumber.AbsVal)

// Convert proto big-int to *big.Int; nil ⇒ latest (handled by geth toBlockNumArg)
blockArg := pb.NewIntFromBigInt(input.BlockNumber)

// Get balance at block number
balance, err := fc.gethClient.BalanceAt(ctx, address, blockNumber)
balance, err := fc.gethClient.BalanceAt(ctx, address, blockArg)
if err != nil {
return nil, err
}
Expand Down
Loading