cic-go/cic_net/cic_net.go
Mohamed Sohail 7731a23e35
update: (cic_net) add new methods and tests (#1)
* update: (cic_net) add new methods and tests

* add: write tx methods and tests

- add ci for testing
- coveralls for coverage

* ci: add test environment

* ci: expose secrets to env

* docs: add badges
2022-05-08 14:13:45 +03:00

49 lines
869 B
Go

package cic_net
import (
"crypto/ecdsa"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/lmittmann/w3"
"math/big"
)
const (
kitabuMainnetChainId = 6060
)
type CicNet struct {
ethClient *w3.Client
tokenIndex common.Address
kitabuSigner types.Signer
}
type WriteTx struct {
from common.Address
to common.Address
gasLimit uint64
privateKey ecdsa.PrivateKey
}
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,
kitabuSigner: types.NewEIP155Signer(big.NewInt(kitabuMainnetChainId)),
}, nil
}
func (c *CicNet) Close() error {
err := c.ethClient.Close()
if err != nil {
return err
}
return nil
}