erigon-pulse/cmd/devnet/requests/account.go
ledgerwatch a8ec9eb471
[devnet tool] Use logging instead of fmt.Printf (#7560)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2023-05-22 08:46:50 +01:00

25 lines
730 B
Go

package requests
import (
"fmt"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/erigon/cmd/devnet/models"
"github.com/ledgerwatch/erigon/cmd/rpctest/rpctest"
)
func GetBalance(reqId int, address libcommon.Address, blockNum models.BlockNumber, logger log.Logger) (uint64, error) {
reqGen := initialiseRequestGenerator(reqId, logger)
var b rpctest.EthBalance
if res := reqGen.Erigon(models.ETHGetBalance, reqGen.GetBalance(address, blockNum), &b); res.Err != nil {
return 0, fmt.Errorf("failed to get balance: %v", res.Err)
}
if !b.Balance.ToInt().IsUint64() {
return 0, fmt.Errorf("balance is not uint64")
}
return b.Balance.ToInt().Uint64(), nil
}