mirror of
https://github.com/grassrootseconomics/cic-go.git
synced 2024-11-21 21:56:45 +01:00
Mohamed Sohail
79634affb8
module: - cic-go packages: - cic/meta - cic/net other fixes: - nonce is now a settable value - package init outside test runner scope
50 lines
884 B
Go
50 lines
884 B
Go
package 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
|
|
nonce 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
|
|
}
|