fix: (pkg) revert to untrimmed address, panic on failed dial

- TODO: cicnet should be initialized at job handler level
This commit is contained in:
Mohamed Sohail 2022-05-05 14:58:47 +03:00
parent 659007e563
commit 4f868d8d94
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D
2 changed files with 7 additions and 6 deletions

View File

@ -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 {

View File

@ -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
} }