mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-09 20:41:20 +00:00
f5bd806b84
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
23 lines
638 B
Go
23 lines
638 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"
|
|
)
|
|
|
|
func GetBalance(reqGen *RequestGenerator, address libcommon.Address, blockNum models.BlockNumber, logger log.Logger) (uint64, error) {
|
|
var b models.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
|
|
}
|