Skip to content

Commit

Permalink
Merge pull request #315 from forta-network/fix-transaction-count-method
Browse files Browse the repository at this point in the history
Fix block param
  • Loading branch information
dkeysil authored Sep 10, 2024
2 parents 809b59a + 206890a commit 62240fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions ethereum/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Client interface {
BlockNumber(ctx context.Context) (*big.Int, error)
TransactionReceipt(ctx context.Context, txHash string) (*domain.TransactionReceipt, error)
ChainID(ctx context.Context) (*big.Int, error)
GetTransactionCount(ctx context.Context, address string, blockNumber *big.Int) (*big.Int, error)
GetTransactionCount(ctx context.Context, address string, blockNumber any) (*big.Int, error)
TraceBlock(ctx context.Context, number *big.Int) ([]domain.Trace, error)
DebugTraceCall(
ctx context.Context, req *domain.TraceCallTransaction,
Expand Down Expand Up @@ -387,12 +387,20 @@ func (e *streamEthClient) TransactionReceipt(ctx context.Context, txHash string)
}

// GetTransactionCount returns the transaction count for an address
func (e *streamEthClient) GetTransactionCount(ctx context.Context, address string, blockNumber *big.Int) (*big.Int, error) {
name := fmt.Sprintf("%s(%s, %s)", getTransactionCount, address, blockNumber)
func (e *streamEthClient) GetTransactionCount(ctx context.Context, address string, block any) (*big.Int, error) {
name := fmt.Sprintf("%s(%s, %s)", getTransactionCount, address, block)

switch block.(type) {
case string:
case *rpc.BlockNumberOrHash:
default:
return nil, errors.New("invalid block number type")
}

log.Debugf(name)
var result string
err := withBackoff(ctx, name, func(ctx context.Context) error {
err := e.rpcClient.CallContext(ctx, &result, getTransactionCount, address, blockNumber)
err := e.rpcClient.CallContext(ctx, &result, getTransactionCount, address, block)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion ethereum/mocks/mock_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62240fa

Please sign in to comment.