2022-05-17 19:33:03 +02:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/lmittmann/w3"
|
|
|
|
"github.com/lmittmann/w3/module/eth"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *BatchBalance) TokensBalance(ctx context.Context, owner common.Address, tokens []common.Address) ([]*big.Int, error) {
|
|
|
|
var balancesResults []*big.Int
|
|
|
|
|
2022-05-18 11:52:50 +02:00
|
|
|
err := c.provider.EthClient.CallCtx(
|
2022-05-17 19:33:03 +02:00
|
|
|
ctx,
|
|
|
|
eth.CallFunc(w3.MustNewFunc("tokensBalance(address owner, address[] contracts)", "uint256[]"), c.batchContract, owner, tokens).Returns(&balancesResults),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return balancesResults, nil
|
|
|
|
}
|