2022-05-06 13:19:44 +02:00
|
|
|
package cic_net
|
|
|
|
|
|
|
|
import (
|
2022-05-08 12:55:27 +02:00
|
|
|
"crypto/ecdsa"
|
2022-05-06 13:19:44 +02:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2022-05-08 12:55:27 +02:00
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
2022-05-06 13:19:44 +02:00
|
|
|
"github.com/lmittmann/w3"
|
2022-05-08 12:55:27 +02:00
|
|
|
"math/big"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
kitabuMainnetChainId = 6060
|
2022-05-06 13:19:44 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type CicNet struct {
|
2022-05-08 12:55:27 +02:00
|
|
|
ethClient *w3.Client
|
|
|
|
tokenIndex common.Address
|
|
|
|
kitabuSigner types.Signer
|
|
|
|
}
|
|
|
|
|
|
|
|
type WriteTx struct {
|
|
|
|
from common.Address
|
|
|
|
to common.Address
|
|
|
|
gasLimit uint64
|
|
|
|
privateKey ecdsa.PrivateKey
|
2022-05-06 13:19:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewCicNet(rpcEndpoint string, tokenIndex common.Address) (*CicNet, error) {
|
|
|
|
ethClient, err := w3.Dial(rpcEndpoint)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &CicNet{
|
2022-05-08 12:55:27 +02:00
|
|
|
ethClient: ethClient,
|
|
|
|
tokenIndex: tokenIndex,
|
|
|
|
kitabuSigner: types.NewEIP155Signer(big.NewInt(kitabuMainnetChainId)),
|
2022-05-06 13:19:44 +02:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CicNet) Close() error {
|
|
|
|
err := c.ethClient.Close()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|