mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-12-22 10:57: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
|
||||
}
|
||||
|
||||
func NewCicNet(rpcEndpoint string, tokenIndex common.Address) *CicNet {
|
||||
ethClient := w3.MustDial(rpcEndpoint)
|
||||
func NewCicNet(rpcEndpoint string, tokenIndex common.Address) (*CicNet, error) {
|
||||
ethClient, err := w3.Dial(rpcEndpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &CicNet{
|
||||
ethClient: ethClient,
|
||||
tokenIndex: tokenIndex,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *CicNet) Close() error {
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"github.com/lmittmann/w3"
|
||||
"github.com/lmittmann/w3/module/eth"
|
||||
"math/big"
|
||||
"strings"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// strip 0x at pkg level
|
||||
return strings.Trim(address.String(), "0x"), nil
|
||||
return address.String(), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user