mirror of
https://github.com/grassrootseconomics/cic-go.git
synced 2024-11-24 14:46:47 +01:00
Mohamed Sohail
7eba3182ed
- provider now lives on its own - existing modules need the provider as a param
25 lines
594 B
Go
25 lines
594 B
Go
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
|
|
|
|
err := c.provider.EthClient.CallCtx(
|
|
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
|
|
}
|