2022-05-09 09:58:04 +02:00
|
|
|
package net
|
2022-05-08 13:13:45 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
2022-05-17 15:06:19 +02:00
|
|
|
"math/big"
|
|
|
|
|
2022-05-08 13:13:45 +02:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
"github.com/lmittmann/w3"
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
2022-05-09 09:58:04 +02:00
|
|
|
nonce uint64
|
2022-05-08 13:13:45 +02:00
|
|
|
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
|
|
|
|
}
|