mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-12-22 19:07:33 +01:00
fix: (pkg) revert to untrimmed address, panic on failed dial
- TODO: cicnet should be initialized at job handler level
This commit is contained in:
parent
659007e563
commit
4f868d8d94
@ -10,13 +10,16 @@ type CicNet struct {
|
|||||||
tokenIndex common.Address
|
tokenIndex common.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCicNet(rpcEndpoint string, tokenIndex common.Address) *CicNet {
|
func NewCicNet(rpcEndpoint string, tokenIndex common.Address) (*CicNet, error) {
|
||||||
ethClient := w3.MustDial(rpcEndpoint)
|
ethClient, err := w3.Dial(rpcEndpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &CicNet{
|
return &CicNet{
|
||||||
ethClient: ethClient,
|
ethClient: ethClient,
|
||||||
tokenIndex: tokenIndex,
|
tokenIndex: tokenIndex,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CicNet) Close() error {
|
func (c *CicNet) Close() error {
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/lmittmann/w3"
|
"github.com/lmittmann/w3"
|
||||||
"github.com/lmittmann/w3/module/eth"
|
"github.com/lmittmann/w3/module/eth"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *CicNet) EntryCount(ctx context.Context) (big.Int, error) {
|
func (c *CicNet) EntryCount(ctx context.Context) (big.Int, error) {
|
||||||
@ -34,6 +33,5 @@ func (c *CicNet) AddressAtIndex(ctx context.Context, index *big.Int) (string, er
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip 0x at pkg level
|
return address.String(), nil
|
||||||
return strings.Trim(address.String(), "0x"), nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user