mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
a8ec9eb471
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
25 lines
730 B
Go
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
|
|
}
|