mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-12-22 19:07:33 +01:00
38 lines
786 B
Go
38 lines
786 B
Go
package cicnet
|
|
|
|
import (
|
|
"context"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/lmittmann/w3"
|
|
"github.com/lmittmann/w3/module/eth"
|
|
"math/big"
|
|
)
|
|
|
|
func (c *CicNet) EntryCount(ctx context.Context) (big.Int, error) {
|
|
var tokenCount big.Int
|
|
|
|
err := c.ethClient.CallCtx(
|
|
ctx,
|
|
eth.CallFunc(w3.MustNewFunc("entryCount()", "uint256"), c.tokenIndex).Returns(&tokenCount),
|
|
)
|
|
if err != nil {
|
|
return big.Int{}, err
|
|
}
|
|
|
|
return tokenCount, nil
|
|
}
|
|
|
|
func (c *CicNet) AddressAtIndex(ctx context.Context, index *big.Int) (string, error) {
|
|
var address common.Address
|
|
|
|
err := c.ethClient.CallCtx(
|
|
ctx,
|
|
eth.CallFunc(w3.MustNewFunc("entry(uint256 _idx)", "address"), c.tokenIndex, index).Returns(&address),
|
|
)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return address.String(), nil
|
|
}
|