2022-04-29 10:09:10 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-05-03 17:54:51 +02:00
|
|
|
func (c *CicNet) AddressAtIndex(ctx context.Context, index *big.Int) (string, error) {
|
2022-04-29 10:09:10 +02:00
|
|
|
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 {
|
2022-05-03 17:54:51 +02:00
|
|
|
return "", err
|
2022-04-29 10:09:10 +02:00
|
|
|
}
|
|
|
|
|
2022-05-05 13:58:47 +02:00
|
|
|
return address.String(), nil
|
2022-04-29 10:09:10 +02:00
|
|
|
}
|