sdk

package module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2020 License: LGPL-3.0 Imports: 22 Imported by: 78

README

Documentation Build Status

Conflux Golang API

The Conflux Golang API allows any Golang client to interact with a local or remote Conflux node based on JSON-RPC 2.0 protocol. With Conflux Golang API, user can easily manage accounts, send transactions, deploy smart contracts and query blockchain information.

Install

go get github.com/Conflux-Chain/go-conflux-sdk

You can also add the Conflux Golang API into vendor folder.

govendor fetch github.com/Conflux-Chain/go-conflux-sdk

Usage

api document

Manage Accounts

Use AccountManager struct to manage accounts at local machine.

  • Create/Import/Update/Delete an account.
  • List all accounts.
  • Unlock/Lock an account.
  • Sign a transaction.

Query Conflux Information

Use Client struct to query Conflux blockchain information, such as block, epoch, transaction, receipt. Following is an example to query the current epoch number:

package main

import (
	"fmt"

	conflux "github.com/Conflux-Chain/go-conflux-sdk"
)

func main() {
	client, err := conflux.NewClient("http://52.175.52.111:12537")
	if err != nil {
		fmt.Println("failed to create client:", err)
		return
	}
	defer client.Close()

	epoch, err := client.GetEpochNumber()
	if err != nil {
		fmt.Println("failed to get epoch number:", err)
		return
	}

	fmt.Println("Current epoch number:", epoch)
}

Send Transaction

To send a transaction, you need to sign the transaction at local machine, and send the signed transaction to local or remote Conflux node.

  • Sign a transaction with unlocked account:

    AccountManager.SignTransaction(tx UnsignedTransaction)

  • Sign a transaction with passphrase for locked account:

    AccountManager.SignTransactionWithPassphrase(tx UnsignedTransaction, passphrase string)

  • Send a unsigned transaction

    Client.SendTransaction(tx *types.UnsignedTransaction)

  • Send a encoded transaction

    Client.SendRawTransaction(rawData []byte)

  • Encode a encoded unsigned transaction with signature and send transaction

    Client.SignEncodedTransactionAndSend(encodedTx []byte, v byte, r, s []byte)

To send multiple transactions at a time, you can unlock the account at first, then send multiple transactions without passphrase. To send a single transaction, you can just only send the transaction with passphrase.

Deploy/Call Smart Contract

You can use Client.DeployContract to deploy a contract or use Client.GetContract to get a contract by deployed address. Then you can use the contract instance to operate contract, there are GetData/Call/SendTransaction. Please see api document for detail.

Contract Example

Please reference contract example for all source code

package main

import (
	"encoding/hex"
	"fmt"
	"io/ioutil"
	"math/big"
	"time"

	sdk "github.com/Conflux-Chain/go-conflux-sdk"
	"github.com/Conflux-Chain/go-conflux-sdk/types"
	"github.com/ethereum/go-ethereum/common"
)

func main() {

	//unlock account
	am := sdk.NewAccountManager("../keystore")
	err := am.TimedUnlockDefault("hello", 300*time.Second)
	if err != nil {
		panic(err)
	}

	//init client
	client, err := sdk.NewClient("http://testnet-jsonrpc.conflux-chain.org:12537")
	if err != nil {
		panic(err)
	}
	client.SetAccountManager(am)

	//deploy contract
	fmt.Println("start deploy contract...")
	abiPath := "./contract/erc20.abi"
	bytecodePath := "./contract/erc20.bytecode"
	var contract *sdk.Contract

	abi, err := ioutil.ReadFile(abiPath)
	if err != nil {
		panic(err)
	}

	bytecodeHexStr, err := ioutil.ReadFile(bytecodePath)
	if err != nil {
		panic(err)
	}

	bytecode, err := hex.DecodeString(string(bytecodeHexStr))
	if err != nil {
		panic(err)
	}

	result := client.DeployContract(nil, abi, bytecode, big.NewInt(100000), "biu", uint8(10), "BIU")
	_ = <-result.DoneChannel
	if result.Error != nil {
		panic(result.Error)
	}
	contract = result.DeployedContract
	fmt.Printf("deploy contract by client.DeployContract done\ncontract address: %+v\ntxhash:%v\n\n", contract.Address, result.TransactionHash)

	time.Sleep(10 * time.Second)

	// or get contract by deployed address
	// deployedAt := types.Address("0x8d1089f00c40dcc290968b366889e85e67024662")
	// contract, err := client.GetContract(string(abi), &deployedAt)
	// if err != nil {
	// 	panic(err)
	// }

	//get data for send/call contract method
	user := types.Address("0x19f4bcf113e0b896d9b34294fd3da86b4adf0302")
	data, err := contract.GetData("balanceOf", user.ToCommonAddress())
	if err != nil {
		panic(err)
	}
	fmt.Printf("get data of method balanceOf result: 0x%x\n\n", data)

	//call contract method
	//Note: the output struct type need match method output type of ABI, go type "*big.Int" match abi type "uint256", go type "struct{Balance *big.Int}" match abi tuple type "(balance uint256)"
	balance := &struct{ Balance *big.Int }{}
	err = contract.Call(nil, balance, "balanceOf", user.ToCommonAddress())
	if err != nil {
		panic(err)
	}
	fmt.Printf("balance of address %v in contract is: %+v\n\n", user, balance)

	//send transction for contract method
	to := types.Address("0x160ebef20c1f739957bf9eecd040bce699cc42c6")
	txhash, err := contract.SendTransaction(nil, "transfer", to.ToCommonAddress(), big.NewInt(10))
	if err != nil {
		panic(err)
	}

	fmt.Printf("transfer %v erc20 token to %v done, tx hash: %v\n\n", 10, to, txhash)

	fmt.Println("wait for transaction be packed...")
	for {
		time.Sleep(time.Duration(1) * time.Second)
		tx, err := client.GetTransactionByHash(*txhash)
		if err != nil {
			panic(err)
		}
		if tx.Status != nil {
			fmt.Printf("transaction is packed.")
			break
		}
	}
	time.Sleep(10 * time.Second)

	//get event log and decode it
	receipt, err := client.GetTransactionReceipt(*txhash)
	if err != nil {
		panic(err)
	}
	fmt.Printf("get receipt: %+v\n\n", receipt)

	// decode Transfer Event
	var Transfer struct {
		From  common.Address
		To    common.Address
		Value *big.Int
	}

	err = contract.DecodeEvent(&Transfer, "Transfer", receipt.Logs[0])
	if err != nil {
		panic(err)
	}
	fmt.Printf("decoded transfer event: {From: 0x%x, To: 0x%x, Value: %v} ", Transfer.From, Transfer.To, Transfer.Value)
}

Appendix

Mapping of solidity types to go types

This is a mapping table for map solidity types to go types when using contract methods GetData/Call/SendTransaction/DecodeEvent

solidity types go types
address common.Address
uint8,uint16,uint32,uint64 uint8,uint16,uint32,uint64
uint24,uint40,uint48,uint56,uint72...uint256 *big.Int
int8,int16,int32,int64 int8,int16,int32,int64
int24,int40,int48,int56,int72...int256 *big.Int
fixed bytes (bytes1,bytes2...bytes32) [length]byte
fixed type T array (T[length]) [length]TG (TG is go type matched with solidty type T)
bytes []byte
dynamic type T array T[] []TG ((TG is go type matched with solidty type T))
function [24]byte
string string
bool bool
tuple struct eg:[{"name": "balance","type": "uint256"}] => struct {Balance *big.Int}

Documentation

Overview

Package sdk is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManager

type AccountManager struct {
	// contains filtered or unexported fields
}

AccountManager manages Conflux accounts.

func NewAccountManager

func NewAccountManager(keydir string) *AccountManager

NewAccountManager creates an instance of AccountManager based on the keystore directory "keydir".

func (*AccountManager) Create

func (m *AccountManager) Create(passphrase string) (types.Address, error)

Create creates a new account and puts the keystore file into keystore directory

func (*AccountManager) Delete

func (m *AccountManager) Delete(address types.Address, passphrase string) error

Delete deletes the specified account and remove the keystore file from keystore directory.

func (*AccountManager) GetDefault

func (m *AccountManager) GetDefault() (*types.Address, error)

GetDefault return first account in keystore directory

func (*AccountManager) Import

func (m *AccountManager) Import(keyFile, passphrase, newPassphrase string) (types.Address, error)

Import imports account from external key file to keystore directory. Returns error if the account already exists.

func (*AccountManager) List

func (m *AccountManager) List() []types.Address

List lists all accounts in keystore directory.

func (*AccountManager) Lock

func (m *AccountManager) Lock(address types.Address) error

Lock locks the specified account.

func (*AccountManager) Sign

func (m *AccountManager) Sign(tx types.UnsignedTransaction, passphrase string) (v byte, r, s []byte, err error)

Sign signs tx by passphrase and returns the signature

func (*AccountManager) SignAndEcodeTransactionWithPassphrase

func (m *AccountManager) SignAndEcodeTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) ([]byte, error)

SignAndEcodeTransactionWithPassphrase signs tx with given passphrase and return its RLP encoded data.

func (*AccountManager) SignTransaction

func (m *AccountManager) SignTransaction(tx types.UnsignedTransaction) ([]byte, error)

SignTransaction signs tx and returns its RLP encoded data.

func (*AccountManager) SignTransactionWithPassphrase

func (m *AccountManager) SignTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) (*types.SignedTransaction, error)

SignTransactionWithPassphrase signs tx with given passphrase and returns a transction with signature

func (*AccountManager) TimedUnlock

func (m *AccountManager) TimedUnlock(address types.Address, passphrase string, timeout time.Duration) error

TimedUnlock unlocks the specified account for a period of time.

func (*AccountManager) TimedUnlockDefault

func (m *AccountManager) TimedUnlockDefault(passphrase string, timeout time.Duration) error

TimedUnlockDefault unlocks the specified account for a period of time.

func (*AccountManager) Unlock

func (m *AccountManager) Unlock(address types.Address, passphrase string) error

Unlock unlocks the specified account indefinitely.

func (*AccountManager) UnlockDefault

func (m *AccountManager) UnlockDefault(passphrase string) error

UnlockDefault unlocks the default account indefinitely.

func (*AccountManager) Update

func (m *AccountManager) Update(address types.Address, passphrase, newPassphrase string) error

Update updates the passphrase of specified account.

type AccountManagerOperator added in v0.1.1

type AccountManagerOperator interface {
	Create(passphrase string) (types.Address, error)
	Import(keyFile, passphrase, newPassphrase string) (types.Address, error)
	Delete(address types.Address, passphrase string) error
	Update(address types.Address, passphrase, newPassphrase string) error
	List() []types.Address
	GetDefault() (*types.Address, error)
	Unlock(address types.Address, passphrase string) error
	UnlockDefault(passphrase string) error
	TimedUnlock(address types.Address, passphrase string, timeout time.Duration) error
	TimedUnlockDefault(passphrase string, timeout time.Duration) error
	Lock(address types.Address) error
	SignTransaction(tx types.UnsignedTransaction) ([]byte, error)
	SignAndEcodeTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) ([]byte, error)
	SignTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) (*types.SignedTransaction, error)
	Sign(tx types.UnsignedTransaction, passphrase string) (v byte, r, s []byte, err error)
}

AccountManagerOperator is interface of operate actions on account manager

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a client to interact with Conflux blockchain.

func NewClient

func NewClient(nodeURL string) (*Client, error)

NewClient creates a new instance of Client with specified conflux node url.

func NewClientWithRPCRequester added in v0.1.1

func NewClientWithRPCRequester(rpcRequester rpcRequester) (*Client, error)

NewClientWithRPCRequester creates client with specified rpcRequester

func NewClientWithRetry added in v0.3.1

func NewClientWithRetry(nodeURL string, retryCount int, retryInterval time.Duration) (*Client, error)

NewClientWithRetry creates a retryable new instance of Client with specified conflux node url and retry options.

the retryInterval will be set to 1 second if pass 0

func (*Client) ApplyUnsignedTransactionDefault

func (client *Client) ApplyUnsignedTransactionDefault(tx *types.UnsignedTransaction) error

ApplyUnsignedTransactionDefault set empty fields to value fetched from conflux node.

func (*Client) BatchCallRPC added in v0.1.1

func (client *Client) BatchCallRPC(b []rpc.BatchElem) error

BatchCallRPC sends all given requests as a single batch and waits for the server to return a response for all of them.

In contrast to Call, BatchCall only returns I/O errors. Any error specific to a request is reported through the Error field of the corresponding BatchElem.

Note that batch calls may not be executed atomically on the server side.

func (*Client) BatchGetBlockConfirmationRisk added in v0.1.1

func (client *Client) BatchGetBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Float, error)

BatchGetBlockConfirmationRisk acquires confirmation risk informations in bulk by blockhashes

func (*Client) BatchGetBlockSummarys added in v0.1.1

func (client *Client) BatchGetBlockSummarys(blockhashes []types.Hash) (map[types.Hash]*types.BlockSummary, error)

BatchGetBlockSummarys requests block summary informations in bulk by blockhashes

func (*Client) BatchGetRawBlockConfirmationRisk added in v0.1.1

func (client *Client) BatchGetRawBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Int, error)

BatchGetRawBlockConfirmationRisk requests raw confirmation risk informations in bulk by blockhashes

func (*Client) BatchGetTxByHashes added in v0.1.1

func (client *Client) BatchGetTxByHashes(txhashes []types.Hash) (map[types.Hash]*types.Transaction, error)

BatchGetTxByHashes requests transaction informations in bulk by txhashes

func (*Client) Call

func (client *Client) Call(request types.CallRequest, epoch *types.Epoch) (*string, error)

Call executes a message call transaction "request" at specified epoch, which is directly executed in the VM of the node, but never mined into the block chain and returns the contract execution result.

func (*Client) CallRPC

func (client *Client) CallRPC(result interface{}, method string, args ...interface{}) error

CallRPC performs a JSON-RPC call with the given arguments and unmarshals into result if no error occurred.

The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.

func (*Client) CheckBalanceAgainstTransaction added in v0.1.1

func (client *Client) CheckBalanceAgainstTransaction(accountAddress types.Address,
	contractAddress types.Address,
	gasLimit *hexutil.Big,
	gasPrice *hexutil.Big,
	storageLimit *hexutil.Big,
	epoch ...*types.Epoch) (response types.CheckBalanceAgainstTransactionResponse, err error)

CheckBalanceAgainstTransaction checks if user balance is enough for the transaction.

func (*Client) Close

func (client *Client) Close()

Close closes the client, aborting any in-flight requests.

func (*Client) CreateUnsignedTransaction

func (client *Client) CreateUnsignedTransaction(from types.Address, to types.Address, amount *hexutil.Big, data []byte) (*types.UnsignedTransaction, error)

CreateUnsignedTransaction creates an unsigned transaction by parameters, and the other fields will be set to values fetched from conflux node.

func (*Client) Debug

func (client *Client) Debug(method string, args ...interface{}) (interface{}, error)

Debug calls the Conflux debug API.

func (*Client) DeployContract

func (client *Client) DeployContract(option *types.ContractDeployOption, abiJSON []byte,
	bytecode []byte, constroctorParams ...interface{}) *ContractDeployResult

DeployContract deploys a contract by abiJSON, bytecode and consturctor params. It returns a ContractDeployState instance which contains 3 channels for notifying when state changed.

func (*Client) EstimateGasAndCollateral

func (client *Client) EstimateGasAndCollateral(request types.CallRequest) (*types.Estimate, error)

EstimateGasAndCollateral excutes a message call "request" and returns the amount of the gas used and storage for collateral

func (*Client) GetAccountInfo added in v0.1.1

func (client *Client) GetAccountInfo(account types.Address, epoch ...*types.Epoch) (accountInfo types.AccountInfo, err error)

GetAccountInfo returns account related states of the given account

func (*Client) GetAccumulateInterestRate added in v0.1.1

func (client *Client) GetAccumulateInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)

GetAccumulateInterestRate returns accumulate interest rate of the given epoch

func (*Client) GetAdmin added in v0.1.1

func (client *Client) GetAdmin(contractAddress types.Address, epoch ...*types.Epoch) (admin types.Address, err error)

GetAdmin returns admin of the given contract

func (*Client) GetBalance

func (client *Client) GetBalance(address types.Address, epoch ...*types.Epoch) (*big.Int, error)

GetBalance returns the balance of specified address at epoch.

func (*Client) GetBestBlockHash

func (client *Client) GetBestBlockHash() (types.Hash, error)

GetBestBlockHash returns the current best block hash.

func (*Client) GetBlockByEpoch

func (client *Client) GetBlockByEpoch(epoch *types.Epoch) (*types.Block, error)

GetBlockByEpoch returns the block of specified epoch. If the epoch is invalid, return the concrete error.

func (*Client) GetBlockByHash

func (client *Client) GetBlockByHash(blockHash types.Hash) (*types.Block, error)

GetBlockByHash returns the block of specified blockHash If the block is not found, return nil.

func (*Client) GetBlockByHashWithPivotAssumption added in v0.1.1

func (client *Client) GetBlockByHashWithPivotAssumption(blockHash types.Hash, pivotHash types.Hash, epoch hexutil.Uint64) (block types.Block, err error)

GetBlockByHashWithPivotAssumption returns block with given hash and pivot chain assumption.

func (*Client) GetBlockConfirmationRisk added in v0.1.1

func (client *Client) GetBlockConfirmationRisk(blockHash types.Hash) (*big.Float, error)

GetBlockConfirmationRisk indicates the probability that the pivot block of the epoch where the block is located becomes a normal block.

it's (raw confirmation risk coefficient/ (2^256-1))

func (*Client) GetBlockRewardInfo added in v0.1.1

func (client *Client) GetBlockRewardInfo(epoch ...*types.Epoch) (rewardInfo []types.RewardInfo, err error)

GetBlockRewardInfo returns block reward information in an epoch

func (*Client) GetBlockSummaryByEpoch

func (client *Client) GetBlockSummaryByEpoch(epoch *types.Epoch) (*types.BlockSummary, error)

GetBlockSummaryByEpoch returns the block summary of specified epoch. If the epoch is invalid, return the concrete error.

func (*Client) GetBlockSummaryByHash

func (client *Client) GetBlockSummaryByHash(blockHash types.Hash) (*types.BlockSummary, error)

GetBlockSummaryByHash returns the block summary of specified blockHash If the block is not found, return nil.

func (*Client) GetBlocksByEpoch

func (client *Client) GetBlocksByEpoch(epoch *types.Epoch) ([]types.Hash, error)

GetBlocksByEpoch returns the blocks hash in the specified epoch.

func (*Client) GetClientVersion added in v0.1.1

func (client *Client) GetClientVersion() (clientVersion string, err error)

GetClientVersion returns the client version as a string

func (*Client) GetCode

func (client *Client) GetCode(address types.Address, epoch ...*types.Epoch) (string, error)

GetCode returns the bytecode in HEX format of specified address at epoch.

func (*Client) GetCollateralForStorage added in v0.1.1

func (client *Client) GetCollateralForStorage(account types.Address, epoch ...*types.Epoch) (storage *hexutil.Big, err error)

GetCollateralForStorage returns balance of the given account.

func (*Client) GetContract

func (client *Client) GetContract(abiJSON []byte, deployedAt *types.Address) (*Contract, error)

GetContract creates a contract instance according to abi json and it's deployed address

func (*Client) GetEpochNumber

func (client *Client) GetEpochNumber(epoch ...*types.Epoch) (*big.Int, error)

GetEpochNumber returns the highest or specified epoch number.

func (*Client) GetGasPrice

func (client *Client) GetGasPrice() (*big.Int, error)

GetGasPrice returns the recent mean gas price.

func (*Client) GetInterestRate added in v0.1.1

func (client *Client) GetInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)

GetInterestRate returns interest rate of the given epoch

func (*Client) GetLogs

func (client *Client) GetLogs(filter types.LogFilter) ([]types.Log, error)

GetLogs returns logs that matching the specified filter.

func (*Client) GetNextNonce

func (client *Client) GetNextNonce(address types.Address, epoch ...*types.Epoch) (*big.Int, error)

GetNextNonce returns the next transaction nonce of address

func (*Client) GetNodeURL added in v0.1.1

func (client *Client) GetNodeURL() string

GetNodeURL returns node url

func (*Client) GetRawBlockConfirmationRisk added in v0.1.1

func (client *Client) GetRawBlockConfirmationRisk(blockhash types.Hash) (*big.Int, error)

GetRawBlockConfirmationRisk indicates the risk coefficient that the pivot block of the epoch where the block is located becomes a normal block.

func (*Client) GetSkippedBlocksByEpoch added in v0.1.1

func (client *Client) GetSkippedBlocksByEpoch(epoch *types.Epoch) (blockHashs []types.Hash, err error)

GetSkippedBlocksByEpoch returns skipped block hashes of given epoch

func (*Client) GetSponsorInfo added in v0.1.1

func (client *Client) GetSponsorInfo(contractAddress types.Address, epoch ...*types.Epoch) (sponsor types.SponsorInfo, err error)

GetSponsorInfo returns sponsor information of the given contract

func (*Client) GetStakingBalance added in v0.1.1

func (client *Client) GetStakingBalance(account types.Address, epoch ...*types.Epoch) (balance *hexutil.Big, err error)

GetStakingBalance returns balance of the given account.

func (*Client) GetStatus added in v0.1.1

func (client *Client) GetStatus() (*types.Status, error)

GetStatus returns chainID of connecting conflux node

func (*Client) GetStorageAt added in v0.1.1

func (client *Client) GetStorageAt(address types.Address, position types.Hash, epoch ...*types.Epoch) (storageEntries *hexutil.Big, err error)

GetStorageAt returns storage entries from a given contract.

func (*Client) GetStorageRoot added in v0.1.1

func (client *Client) GetStorageRoot(address types.Address, epoch ...*types.Epoch) (storageRoot types.StorageRoot, err error)

GetStorageRoot returns storage root of given address

func (*Client) GetTransactionByHash

func (client *Client) GetTransactionByHash(txHash types.Hash) (*types.Transaction, error)

GetTransactionByHash returns transaction for the specified txHash. If the transaction is not found, return nil.

func (*Client) GetTransactionReceipt

func (client *Client) GetTransactionReceipt(txHash types.Hash) (*types.TransactionReceipt, error)

GetTransactionReceipt returns the receipt of specified transaction hash. If no receipt is found, return nil.

func (*Client) SendRawTransaction

func (client *Client) SendRawTransaction(rawData []byte) (types.Hash, error)

SendRawTransaction sends signed transaction and returns its hash.

func (*Client) SendTransaction

func (client *Client) SendTransaction(tx *types.UnsignedTransaction) (types.Hash, error)

SendTransaction signs and sends transaction to conflux node and returns the transaction hash.

func (*Client) SetAccountManager

func (client *Client) SetAccountManager(accountManager AccountManagerOperator)

SetAccountManager sets account manager for sign transaction

func (*Client) SignEncodedTransactionAndSend

func (client *Client) SignEncodedTransactionAndSend(encodedTx []byte, v byte, r, s []byte) (*types.Transaction, error)

SignEncodedTransactionAndSend signs RLP encoded transaction "encodedTx" by signature "r,s,v" and sends it to node, and returns responsed transaction.

func (*Client) WaitForTransationBePacked added in v0.1.1

func (client *Client) WaitForTransationBePacked(txhash types.Hash, duration time.Duration) (*types.Transaction, error)

WaitForTransationBePacked returns transaction when it is packed

func (*Client) WaitForTransationReceipt added in v0.1.1

func (client *Client) WaitForTransationReceipt(txhash types.Hash, duration time.Duration) (*types.TransactionReceipt, error)

WaitForTransationReceipt waits for transaction receipt valid

type ClientOperator

type ClientOperator interface {
	GetGasPrice() (*big.Int, error)
	GetNextNonce(address types.Address, epoch ...*types.Epoch) (*big.Int, error)
	GetStatus() (*types.Status, error)
	GetEpochNumber(epoch ...*types.Epoch) (*big.Int, error)
	GetBalance(address types.Address, epoch ...*types.Epoch) (*big.Int, error)
	GetCode(address types.Address, epoch ...*types.Epoch) (string, error)
	GetBlockSummaryByHash(blockHash types.Hash) (*types.BlockSummary, error)
	GetBlockByHash(blockHash types.Hash) (*types.Block, error)
	GetBlockSummaryByEpoch(epoch *types.Epoch) (*types.BlockSummary, error)
	GetBlockByEpoch(epoch *types.Epoch) (*types.Block, error)
	GetBestBlockHash() (types.Hash, error)
	GetRawBlockConfirmationRisk(blockhash types.Hash) (*big.Int, error)
	GetBlockConfirmationRisk(blockHash types.Hash) (*big.Float, error)
	SendRawTransaction(rawData []byte) (types.Hash, error)
	SendTransaction(tx *types.UnsignedTransaction) (types.Hash, error)
	SetAccountManager(accountManager AccountManagerOperator)
	SignEncodedTransactionAndSend(encodedTx []byte, v byte, r, s []byte) (*types.Transaction, error)
	Call(request types.CallRequest, epoch *types.Epoch) (*string, error)
	CallRPC(result interface{}, method string, args ...interface{}) error
	BatchCallRPC(b []rpc.BatchElem) error
	GetLogs(filter types.LogFilter) ([]types.Log, error)
	GetTransactionByHash(txHash types.Hash) (*types.Transaction, error)
	EstimateGasAndCollateral(request types.CallRequest) (*types.Estimate, error)
	GetBlocksByEpoch(epoch *types.Epoch) ([]types.Hash, error)
	GetTransactionReceipt(txHash types.Hash) (*types.TransactionReceipt, error)
	CreateUnsignedTransaction(from types.Address, to types.Address, amount *hexutil.Big, data []byte) (*types.UnsignedTransaction, error)
	ApplyUnsignedTransactionDefault(tx *types.UnsignedTransaction) error
	Debug(method string, args ...interface{}) (interface{}, error)
	Close()
	GetContract(abiJSON []byte, deployedAt *types.Address) (*Contract, error)
	// DeployContract(abiJSON string, bytecode []byte, option *types.ContractDeployOption, timeout time.Duration, callback func(deployedContract Contractor, hash *types.Hash, err error)) <-chan struct{}
	DeployContract(option *types.ContractDeployOption, abiJSON []byte,
		bytecode []byte, constroctorParams ...interface{}) *ContractDeployResult

	BatchGetTxByHashes(txhashes []types.Hash) (map[types.Hash]*types.Transaction, error)
	BatchGetBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Float, error)
	BatchGetRawBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Int, error)
	BatchGetBlockSummarys(blockhashes []types.Hash) (map[types.Hash]*types.BlockSummary, error)
	GetNodeURL() string

	GetAdmin(contractAddress types.Address, epoch ...*types.Epoch) (admin types.Address, err error)
	GetSponsorInfo(contractAddress types.Address, epoch ...*types.Epoch) (sponsor types.SponsorInfo, err error)
	GetStakingBalance(account types.Address, epoch ...*types.Epoch) (balance *hexutil.Big, err error)
	GetCollateralForStorage(account types.Address, epoch ...*types.Epoch) (storage *hexutil.Big, err error)
	GetStorageAt(address types.Address, position types.Hash, epoch ...*types.Epoch) (storageEntries *hexutil.Big, err error)
	GetStorageRoot(address types.Address, epoch ...*types.Epoch) (storageRoot types.StorageRoot, err error)
	GetBlockByHashWithPivotAssumption(blockHash types.Hash, pivotHash types.Hash, epoch hexutil.Uint64) (block types.Block, err error)
	CheckBalanceAgainstTransaction(accountAddress types.Address,
		contractAddress types.Address,
		gasLimit *hexutil.Big,
		gasPrice *hexutil.Big,
		storageLimit *hexutil.Big,
		epoch ...*types.Epoch) (response types.CheckBalanceAgainstTransactionResponse, err error)
	GetSkippedBlocksByEpoch(epoch *types.Epoch) (blockHashs []types.Hash, err error)
	GetAccountInfo(account types.Address, epoch ...*types.Epoch) (accountInfo types.AccountInfo, err error)
	GetInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)
	GetAccumulateInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)
	GetBlockRewardInfo(epoch ...*types.Epoch) (rewardInfo []types.RewardInfo, err error)
	GetClientVersion() (clientVersion string, err error)
	WaitForTransationBePacked(txhash types.Hash, duration time.Duration) (*types.Transaction, error)
	WaitForTransationReceipt(txhash types.Hash, duration time.Duration) (*types.TransactionReceipt, error)
}

ClientOperator is interface of operate actions on client

type Contract

type Contract struct {
	ABI     abi.ABI
	Client  ClientOperator
	Address *types.Address
}

Contract represents a smart contract. You can conveniently create contract by Client.GetContract or Client.DeployContract.

func NewContract added in v0.1.1

func NewContract(abiJSON []byte, client ClientOperator, address *types.Address) (*Contract, error)

NewContract creates contract by abi and deployed address

func (*Contract) Call

func (contract *Contract) Call(option *types.ContractMethodCallOption, resultPtr interface{}, method string, args ...interface{}) error

Call calls to the contract method with args and fills the excuted result to the "resultPtr".

the resultPtr should be a pointer of the method output struct type.

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

func (*Contract) DecodeEvent added in v0.1.1

func (contract *Contract) DecodeEvent(out interface{}, event string, log types.LogEntry) error

DecodeEvent unpacks a retrieved log into the provided output structure.

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

func (*Contract) GetData

func (contract *Contract) GetData(method string, args ...interface{}) ([]byte, error)

GetData packs the given method name to conform the ABI of the contract. Method call's data will consist of method_id, args0, arg1, ... argN. Method id consists of 4 bytes and arguments are all 32 bytes. Method ids are created from the first 4 bytes of the hash of the methods string signature. (signature = baz(uint32,string32))

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

func (*Contract) SendTransaction

func (contract *Contract) SendTransaction(option *types.ContractMethodSendOption, method string, args ...interface{}) (*types.Hash, error)

SendTransaction sends a transaction to the contract method with args and returns its transaction hash

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

type ContractDeployResult added in v0.1.1

type ContractDeployResult struct {
	//DoneChannel channel for notifying when contract deployed done
	DoneChannel      <-chan struct{}
	TransactionHash  *types.Hash
	Error            error
	DeployedContract *Contract
}

ContractDeployResult for state change notification when deploying contract

type Contractor

type Contractor interface {
	GetData(method string, args ...interface{}) ([]byte, error)
	Call(option *types.ContractMethodCallOption, resultPtr interface{}, method string, args ...interface{}) error
	SendTransaction(option *types.ContractMethodSendOption, method string, args ...interface{}) (*types.Hash, error)
	DecodeEvent(out interface{}, event string, log types.LogEntry) error
}

Contractor is interface of contract operator

type HTTPRequester

type HTTPRequester interface {
	Get(url string) (resp *http.Response, err error)
}

HTTPRequester is interface for emitting a http requester

type MockAccountManagerOperator added in v0.3.2

type MockAccountManagerOperator struct {
	// contains filtered or unexported fields
}

MockAccountManagerOperator is a mock of AccountManagerOperator interface

func NewMockAccountManagerOperator added in v0.3.2

func NewMockAccountManagerOperator(ctrl *gomock.Controller) *MockAccountManagerOperator

NewMockAccountManagerOperator creates a new mock instance

func (*MockAccountManagerOperator) Create added in v0.3.2

func (m *MockAccountManagerOperator) Create(passphrase string) (types.Address, error)

Create mocks base method

func (*MockAccountManagerOperator) Delete added in v0.3.2

func (m *MockAccountManagerOperator) Delete(address types.Address, passphrase string) error

Delete mocks base method

func (*MockAccountManagerOperator) EXPECT added in v0.3.2

EXPECT returns an object that allows the caller to indicate expected use

func (*MockAccountManagerOperator) GetDefault added in v0.3.2

func (m *MockAccountManagerOperator) GetDefault() (*types.Address, error)

GetDefault mocks base method

func (*MockAccountManagerOperator) Import added in v0.3.2

func (m *MockAccountManagerOperator) Import(keyFile, passphrase, newPassphrase string) (types.Address, error)

Import mocks base method

func (*MockAccountManagerOperator) List added in v0.3.2

List mocks base method

func (*MockAccountManagerOperator) Lock added in v0.3.2

func (m *MockAccountManagerOperator) Lock(address types.Address) error

Lock mocks base method

func (*MockAccountManagerOperator) Sign added in v0.3.2

func (m *MockAccountManagerOperator) Sign(tx types.UnsignedTransaction, passphrase string) (byte, []byte, []byte, error)

Sign mocks base method

func (*MockAccountManagerOperator) SignAndEcodeTransactionWithPassphrase added in v0.3.2

func (m *MockAccountManagerOperator) SignAndEcodeTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) ([]byte, error)

SignAndEcodeTransactionWithPassphrase mocks base method

func (*MockAccountManagerOperator) SignTransaction added in v0.3.2

func (m *MockAccountManagerOperator) SignTransaction(tx types.UnsignedTransaction) ([]byte, error)

SignTransaction mocks base method

func (*MockAccountManagerOperator) SignTransactionWithPassphrase added in v0.3.2

func (m *MockAccountManagerOperator) SignTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) (*types.SignedTransaction, error)

SignTransactionWithPassphrase mocks base method

func (*MockAccountManagerOperator) TimedUnlock added in v0.3.2

func (m *MockAccountManagerOperator) TimedUnlock(address types.Address, passphrase string, timeout time.Duration) error

TimedUnlock mocks base method

func (*MockAccountManagerOperator) TimedUnlockDefault added in v0.3.2

func (m *MockAccountManagerOperator) TimedUnlockDefault(passphrase string, timeout time.Duration) error

TimedUnlockDefault mocks base method

func (*MockAccountManagerOperator) Unlock added in v0.3.2

func (m *MockAccountManagerOperator) Unlock(address types.Address, passphrase string) error

Unlock mocks base method

func (*MockAccountManagerOperator) UnlockDefault added in v0.3.2

func (m *MockAccountManagerOperator) UnlockDefault(passphrase string) error

UnlockDefault mocks base method

func (*MockAccountManagerOperator) Update added in v0.3.2

func (m *MockAccountManagerOperator) Update(address types.Address, passphrase, newPassphrase string) error

Update mocks base method

type MockAccountManagerOperatorMockRecorder added in v0.3.2

type MockAccountManagerOperatorMockRecorder struct {
	// contains filtered or unexported fields
}

MockAccountManagerOperatorMockRecorder is the mock recorder for MockAccountManagerOperator

func (*MockAccountManagerOperatorMockRecorder) Create added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Create(passphrase interface{}) *gomock.Call

Create indicates an expected call of Create

func (*MockAccountManagerOperatorMockRecorder) Delete added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Delete(address, passphrase interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockAccountManagerOperatorMockRecorder) GetDefault added in v0.3.2

GetDefault indicates an expected call of GetDefault

func (*MockAccountManagerOperatorMockRecorder) Import added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Import(keyFile, passphrase, newPassphrase interface{}) *gomock.Call

Import indicates an expected call of Import

func (*MockAccountManagerOperatorMockRecorder) List added in v0.3.2

List indicates an expected call of List

func (*MockAccountManagerOperatorMockRecorder) Lock added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Lock(address interface{}) *gomock.Call

Lock indicates an expected call of Lock

func (*MockAccountManagerOperatorMockRecorder) Sign added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Sign(tx, passphrase interface{}) *gomock.Call

Sign indicates an expected call of Sign

func (*MockAccountManagerOperatorMockRecorder) SignAndEcodeTransactionWithPassphrase added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) SignAndEcodeTransactionWithPassphrase(tx, passphrase interface{}) *gomock.Call

SignAndEcodeTransactionWithPassphrase indicates an expected call of SignAndEcodeTransactionWithPassphrase

func (*MockAccountManagerOperatorMockRecorder) SignTransaction added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) SignTransaction(tx interface{}) *gomock.Call

SignTransaction indicates an expected call of SignTransaction

func (*MockAccountManagerOperatorMockRecorder) SignTransactionWithPassphrase added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) SignTransactionWithPassphrase(tx, passphrase interface{}) *gomock.Call

SignTransactionWithPassphrase indicates an expected call of SignTransactionWithPassphrase

func (*MockAccountManagerOperatorMockRecorder) TimedUnlock added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) TimedUnlock(address, passphrase, timeout interface{}) *gomock.Call

TimedUnlock indicates an expected call of TimedUnlock

func (*MockAccountManagerOperatorMockRecorder) TimedUnlockDefault added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) TimedUnlockDefault(passphrase, timeout interface{}) *gomock.Call

TimedUnlockDefault indicates an expected call of TimedUnlockDefault

func (*MockAccountManagerOperatorMockRecorder) Unlock added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Unlock(address, passphrase interface{}) *gomock.Call

Unlock indicates an expected call of Unlock

func (*MockAccountManagerOperatorMockRecorder) UnlockDefault added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) UnlockDefault(passphrase interface{}) *gomock.Call

UnlockDefault indicates an expected call of UnlockDefault

func (*MockAccountManagerOperatorMockRecorder) Update added in v0.3.2

func (mr *MockAccountManagerOperatorMockRecorder) Update(address, passphrase, newPassphrase interface{}) *gomock.Call

Update indicates an expected call of Update

type MockClientOperator added in v0.3.2

type MockClientOperator struct {
	// contains filtered or unexported fields
}

MockClientOperator is a mock of ClientOperator interface

func NewMockClientOperator added in v0.3.2

func NewMockClientOperator(ctrl *gomock.Controller) *MockClientOperator

NewMockClientOperator creates a new mock instance

func (*MockClientOperator) ApplyUnsignedTransactionDefault added in v0.3.2

func (m *MockClientOperator) ApplyUnsignedTransactionDefault(tx *types.UnsignedTransaction) error

ApplyUnsignedTransactionDefault mocks base method

func (*MockClientOperator) BatchCallRPC added in v0.3.2

func (m *MockClientOperator) BatchCallRPC(b []rpc.BatchElem) error

BatchCallRPC mocks base method

func (*MockClientOperator) BatchGetBlockConfirmationRisk added in v0.3.2

func (m *MockClientOperator) BatchGetBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Float, error)

BatchGetBlockConfirmationRisk mocks base method

func (*MockClientOperator) BatchGetBlockSummarys added in v0.3.2

func (m *MockClientOperator) BatchGetBlockSummarys(blockhashes []types.Hash) (map[types.Hash]*types.BlockSummary, error)

BatchGetBlockSummarys mocks base method

func (*MockClientOperator) BatchGetRawBlockConfirmationRisk added in v0.3.2

func (m *MockClientOperator) BatchGetRawBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Int, error)

BatchGetRawBlockConfirmationRisk mocks base method

func (*MockClientOperator) BatchGetTxByHashes added in v0.3.2

func (m *MockClientOperator) BatchGetTxByHashes(txhashes []types.Hash) (map[types.Hash]*types.Transaction, error)

BatchGetTxByHashes mocks base method

func (*MockClientOperator) Call added in v0.3.2

func (m *MockClientOperator) Call(request types.CallRequest, epoch *types.Epoch) (*string, error)

Call mocks base method

func (*MockClientOperator) CallRPC added in v0.3.2

func (m *MockClientOperator) CallRPC(result interface{}, method string, args ...interface{}) error

CallRPC mocks base method

func (*MockClientOperator) Close added in v0.3.2

func (m *MockClientOperator) Close()

Close mocks base method

func (*MockClientOperator) CreateUnsignedTransaction added in v0.3.2

func (m *MockClientOperator) CreateUnsignedTransaction(from, to types.Address, amount *hexutil.Big, data []byte) (*types.UnsignedTransaction, error)

CreateUnsignedTransaction mocks base method

func (*MockClientOperator) Debug added in v0.3.2

func (m *MockClientOperator) Debug(method string, args ...interface{}) (interface{}, error)

Debug mocks base method

func (*MockClientOperator) DeployContract added in v0.3.2

func (m *MockClientOperator) DeployContract(option *types.ContractDeployOption, abiJSON, bytecode []byte, constroctorParams ...interface{}) *ContractDeployResult

DeployContract mocks base method

func (*MockClientOperator) EXPECT added in v0.3.2

EXPECT returns an object that allows the caller to indicate expected use

func (*MockClientOperator) EstimateGasAndCollateral added in v0.3.2

func (m *MockClientOperator) EstimateGasAndCollateral(request types.CallRequest) (*types.Estimate, error)

EstimateGasAndCollateral mocks base method

func (*MockClientOperator) GetBalance added in v0.3.2

func (m *MockClientOperator) GetBalance(address types.Address, epoch ...*types.Epoch) (*big.Int, error)

GetBalance mocks base method

func (*MockClientOperator) GetBestBlockHash added in v0.3.2

func (m *MockClientOperator) GetBestBlockHash() (types.Hash, error)

GetBestBlockHash mocks base method

func (*MockClientOperator) GetBlockByEpoch added in v0.3.2

func (m *MockClientOperator) GetBlockByEpoch(epoch *types.Epoch) (*types.Block, error)

GetBlockByEpoch mocks base method

func (*MockClientOperator) GetBlockByHash added in v0.3.2

func (m *MockClientOperator) GetBlockByHash(blockHash types.Hash) (*types.Block, error)

GetBlockByHash mocks base method

func (*MockClientOperator) GetBlockConfirmationRisk added in v0.3.2

func (m *MockClientOperator) GetBlockConfirmationRisk(blockHash types.Hash) (*big.Float, error)

GetBlockConfirmationRisk mocks base method

func (*MockClientOperator) GetBlockSummaryByEpoch added in v0.3.2

func (m *MockClientOperator) GetBlockSummaryByEpoch(epoch *types.Epoch) (*types.BlockSummary, error)

GetBlockSummaryByEpoch mocks base method

func (*MockClientOperator) GetBlockSummaryByHash added in v0.3.2

func (m *MockClientOperator) GetBlockSummaryByHash(blockHash types.Hash) (*types.BlockSummary, error)

GetBlockSummaryByHash mocks base method

func (*MockClientOperator) GetBlocksByEpoch added in v0.3.2

func (m *MockClientOperator) GetBlocksByEpoch(epoch *types.Epoch) ([]types.Hash, error)

GetBlocksByEpoch mocks base method

func (*MockClientOperator) GetCode added in v0.3.2

func (m *MockClientOperator) GetCode(address types.Address, epoch ...*types.Epoch) (string, error)

GetCode mocks base method

func (*MockClientOperator) GetContract added in v0.3.2

func (m *MockClientOperator) GetContract(abiJSON []byte, deployedAt *types.Address) (*Contract, error)

GetContract mocks base method

func (*MockClientOperator) GetEpochNumber added in v0.3.2

func (m *MockClientOperator) GetEpochNumber(epoch ...*types.Epoch) (*big.Int, error)

GetEpochNumber mocks base method

func (*MockClientOperator) GetGasPrice added in v0.3.2

func (m *MockClientOperator) GetGasPrice() (*big.Int, error)

GetGasPrice mocks base method

func (*MockClientOperator) GetLogs added in v0.3.2

func (m *MockClientOperator) GetLogs(filter types.LogFilter) ([]types.Log, error)

GetLogs mocks base method

func (*MockClientOperator) GetNodeURL added in v0.3.2

func (m *MockClientOperator) GetNodeURL() string

GetNodeURL mocks base method

func (*MockClientOperator) GetRawBlockConfirmationRisk added in v0.3.2

func (m *MockClientOperator) GetRawBlockConfirmationRisk(blockhash types.Hash) (*big.Int, error)

GetRawBlockConfirmationRisk mocks base method

func (*MockClientOperator) GetTransactionByHash added in v0.3.2

func (m *MockClientOperator) GetTransactionByHash(txHash types.Hash) (*types.Transaction, error)

GetTransactionByHash mocks base method

func (*MockClientOperator) GetTransactionReceipt added in v0.3.2

func (m *MockClientOperator) GetTransactionReceipt(txHash types.Hash) (*types.TransactionReceipt, error)

GetTransactionReceipt mocks base method

func (*MockClientOperator) SendRawTransaction added in v0.3.2

func (m *MockClientOperator) SendRawTransaction(rawData []byte) (types.Hash, error)

SendRawTransaction mocks base method

func (*MockClientOperator) SendTransaction added in v0.3.2

func (m *MockClientOperator) SendTransaction(tx *types.UnsignedTransaction) (types.Hash, error)

SendTransaction mocks base method

func (*MockClientOperator) SetAccountManager added in v0.3.2

func (m *MockClientOperator) SetAccountManager(accountManager AccountManagerOperator)

SetAccountManager mocks base method

func (*MockClientOperator) SignEncodedTransactionAndSend added in v0.3.2

func (m *MockClientOperator) SignEncodedTransactionAndSend(encodedTx []byte, v byte, r, s []byte) (*types.Transaction, error)

SignEncodedTransactionAndSend mocks base method

type MockClientOperatorMockRecorder added in v0.3.2

type MockClientOperatorMockRecorder struct {
	// contains filtered or unexported fields
}

MockClientOperatorMockRecorder is the mock recorder for MockClientOperator

func (*MockClientOperatorMockRecorder) ApplyUnsignedTransactionDefault added in v0.3.2

func (mr *MockClientOperatorMockRecorder) ApplyUnsignedTransactionDefault(tx interface{}) *gomock.Call

ApplyUnsignedTransactionDefault indicates an expected call of ApplyUnsignedTransactionDefault

func (*MockClientOperatorMockRecorder) BatchCallRPC added in v0.3.2

func (mr *MockClientOperatorMockRecorder) BatchCallRPC(b interface{}) *gomock.Call

BatchCallRPC indicates an expected call of BatchCallRPC

func (*MockClientOperatorMockRecorder) BatchGetBlockConfirmationRisk added in v0.3.2

func (mr *MockClientOperatorMockRecorder) BatchGetBlockConfirmationRisk(blockhashes interface{}) *gomock.Call

BatchGetBlockConfirmationRisk indicates an expected call of BatchGetBlockConfirmationRisk

func (*MockClientOperatorMockRecorder) BatchGetBlockSummarys added in v0.3.2

func (mr *MockClientOperatorMockRecorder) BatchGetBlockSummarys(blockhashes interface{}) *gomock.Call

BatchGetBlockSummarys indicates an expected call of BatchGetBlockSummarys

func (*MockClientOperatorMockRecorder) BatchGetRawBlockConfirmationRisk added in v0.3.2

func (mr *MockClientOperatorMockRecorder) BatchGetRawBlockConfirmationRisk(blockhashes interface{}) *gomock.Call

BatchGetRawBlockConfirmationRisk indicates an expected call of BatchGetRawBlockConfirmationRisk

func (*MockClientOperatorMockRecorder) BatchGetTxByHashes added in v0.3.2

func (mr *MockClientOperatorMockRecorder) BatchGetTxByHashes(txhashes interface{}) *gomock.Call

BatchGetTxByHashes indicates an expected call of BatchGetTxByHashes

func (*MockClientOperatorMockRecorder) Call added in v0.3.2

func (mr *MockClientOperatorMockRecorder) Call(request, epoch interface{}) *gomock.Call

Call indicates an expected call of Call

func (*MockClientOperatorMockRecorder) CallRPC added in v0.3.2

func (mr *MockClientOperatorMockRecorder) CallRPC(result, method interface{}, args ...interface{}) *gomock.Call

CallRPC indicates an expected call of CallRPC

func (*MockClientOperatorMockRecorder) Close added in v0.3.2

Close indicates an expected call of Close

func (*MockClientOperatorMockRecorder) CreateUnsignedTransaction added in v0.3.2

func (mr *MockClientOperatorMockRecorder) CreateUnsignedTransaction(from, to, amount, data interface{}) *gomock.Call

CreateUnsignedTransaction indicates an expected call of CreateUnsignedTransaction

func (*MockClientOperatorMockRecorder) Debug added in v0.3.2

func (mr *MockClientOperatorMockRecorder) Debug(method interface{}, args ...interface{}) *gomock.Call

Debug indicates an expected call of Debug

func (*MockClientOperatorMockRecorder) DeployContract added in v0.3.2

func (mr *MockClientOperatorMockRecorder) DeployContract(option, abiJSON, bytecode interface{}, constroctorParams ...interface{}) *gomock.Call

DeployContract indicates an expected call of DeployContract

func (*MockClientOperatorMockRecorder) EstimateGasAndCollateral added in v0.3.2

func (mr *MockClientOperatorMockRecorder) EstimateGasAndCollateral(request interface{}) *gomock.Call

EstimateGasAndCollateral indicates an expected call of EstimateGasAndCollateral

func (*MockClientOperatorMockRecorder) GetBalance added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBalance(address interface{}, epoch ...interface{}) *gomock.Call

GetBalance indicates an expected call of GetBalance

func (*MockClientOperatorMockRecorder) GetBestBlockHash added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBestBlockHash() *gomock.Call

GetBestBlockHash indicates an expected call of GetBestBlockHash

func (*MockClientOperatorMockRecorder) GetBlockByEpoch added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBlockByEpoch(epoch interface{}) *gomock.Call

GetBlockByEpoch indicates an expected call of GetBlockByEpoch

func (*MockClientOperatorMockRecorder) GetBlockByHash added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBlockByHash(blockHash interface{}) *gomock.Call

GetBlockByHash indicates an expected call of GetBlockByHash

func (*MockClientOperatorMockRecorder) GetBlockConfirmationRisk added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBlockConfirmationRisk(blockHash interface{}) *gomock.Call

GetBlockConfirmationRisk indicates an expected call of GetBlockConfirmationRisk

func (*MockClientOperatorMockRecorder) GetBlockSummaryByEpoch added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBlockSummaryByEpoch(epoch interface{}) *gomock.Call

GetBlockSummaryByEpoch indicates an expected call of GetBlockSummaryByEpoch

func (*MockClientOperatorMockRecorder) GetBlockSummaryByHash added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBlockSummaryByHash(blockHash interface{}) *gomock.Call

GetBlockSummaryByHash indicates an expected call of GetBlockSummaryByHash

func (*MockClientOperatorMockRecorder) GetBlocksByEpoch added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetBlocksByEpoch(epoch interface{}) *gomock.Call

GetBlocksByEpoch indicates an expected call of GetBlocksByEpoch

func (*MockClientOperatorMockRecorder) GetCode added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetCode(address interface{}, epoch ...interface{}) *gomock.Call

GetCode indicates an expected call of GetCode

func (*MockClientOperatorMockRecorder) GetContract added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetContract(abiJSON, deployedAt interface{}) *gomock.Call

GetContract indicates an expected call of GetContract

func (*MockClientOperatorMockRecorder) GetEpochNumber added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetEpochNumber(epoch ...interface{}) *gomock.Call

GetEpochNumber indicates an expected call of GetEpochNumber

func (*MockClientOperatorMockRecorder) GetGasPrice added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetGasPrice() *gomock.Call

GetGasPrice indicates an expected call of GetGasPrice

func (*MockClientOperatorMockRecorder) GetLogs added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetLogs(filter interface{}) *gomock.Call

GetLogs indicates an expected call of GetLogs

func (*MockClientOperatorMockRecorder) GetNodeURL added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetNodeURL() *gomock.Call

GetNodeURL indicates an expected call of GetNodeURL

func (*MockClientOperatorMockRecorder) GetRawBlockConfirmationRisk added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetRawBlockConfirmationRisk(blockhash interface{}) *gomock.Call

GetRawBlockConfirmationRisk indicates an expected call of GetRawBlockConfirmationRisk

func (*MockClientOperatorMockRecorder) GetTransactionByHash added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetTransactionByHash(txHash interface{}) *gomock.Call

GetTransactionByHash indicates an expected call of GetTransactionByHash

func (*MockClientOperatorMockRecorder) GetTransactionReceipt added in v0.3.2

func (mr *MockClientOperatorMockRecorder) GetTransactionReceipt(txHash interface{}) *gomock.Call

GetTransactionReceipt indicates an expected call of GetTransactionReceipt

func (*MockClientOperatorMockRecorder) SendRawTransaction added in v0.3.2

func (mr *MockClientOperatorMockRecorder) SendRawTransaction(rawData interface{}) *gomock.Call

SendRawTransaction indicates an expected call of SendRawTransaction

func (*MockClientOperatorMockRecorder) SendTransaction added in v0.3.2

func (mr *MockClientOperatorMockRecorder) SendTransaction(tx interface{}) *gomock.Call

SendTransaction indicates an expected call of SendTransaction

func (*MockClientOperatorMockRecorder) SetAccountManager added in v0.3.2

func (mr *MockClientOperatorMockRecorder) SetAccountManager(accountManager interface{}) *gomock.Call

SetAccountManager indicates an expected call of SetAccountManager

func (*MockClientOperatorMockRecorder) SignEncodedTransactionAndSend added in v0.3.2

func (mr *MockClientOperatorMockRecorder) SignEncodedTransactionAndSend(encodedTx, v, r, s interface{}) *gomock.Call

SignEncodedTransactionAndSend indicates an expected call of SignEncodedTransactionAndSend

type MockContractor added in v0.3.2

type MockContractor struct {
	// contains filtered or unexported fields
}

MockContractor is a mock of Contractor interface

func NewMockContractor added in v0.3.2

func NewMockContractor(ctrl *gomock.Controller) *MockContractor

NewMockContractor creates a new mock instance

func (*MockContractor) Call added in v0.3.2

func (m *MockContractor) Call(option *types.ContractMethodCallOption, resultPtr interface{}, method string, args ...interface{}) error

Call mocks base method

func (*MockContractor) DecodeEvent added in v0.3.2

func (m *MockContractor) DecodeEvent(out interface{}, event string, log types.LogEntry) error

DecodeEvent mocks base method

func (*MockContractor) EXPECT added in v0.3.2

EXPECT returns an object that allows the caller to indicate expected use

func (*MockContractor) GetData added in v0.3.2

func (m *MockContractor) GetData(method string, args ...interface{}) ([]byte, error)

GetData mocks base method

func (*MockContractor) SendTransaction added in v0.3.2

func (m *MockContractor) SendTransaction(option *types.ContractMethodSendOption, method string, args ...interface{}) (*types.Hash, error)

SendTransaction mocks base method

type MockContractorMockRecorder added in v0.3.2

type MockContractorMockRecorder struct {
	// contains filtered or unexported fields
}

MockContractorMockRecorder is the mock recorder for MockContractor

func (*MockContractorMockRecorder) Call added in v0.3.2

func (mr *MockContractorMockRecorder) Call(option, resultPtr, method interface{}, args ...interface{}) *gomock.Call

Call indicates an expected call of Call

func (*MockContractorMockRecorder) DecodeEvent added in v0.3.2

func (mr *MockContractorMockRecorder) DecodeEvent(out, event, log interface{}) *gomock.Call

DecodeEvent indicates an expected call of DecodeEvent

func (*MockContractorMockRecorder) GetData added in v0.3.2

func (mr *MockContractorMockRecorder) GetData(method interface{}, args ...interface{}) *gomock.Call

GetData indicates an expected call of GetData

func (*MockContractorMockRecorder) SendTransaction added in v0.3.2

func (mr *MockContractorMockRecorder) SendTransaction(option, method interface{}, args ...interface{}) *gomock.Call

SendTransaction indicates an expected call of SendTransaction

type MockHTTPRequester added in v0.3.2

type MockHTTPRequester struct {
	// contains filtered or unexported fields
}

MockHTTPRequester is a mock of HTTPRequester interface

func NewMockHTTPRequester added in v0.3.2

func NewMockHTTPRequester(ctrl *gomock.Controller) *MockHTTPRequester

NewMockHTTPRequester creates a new mock instance

func (*MockHTTPRequester) EXPECT added in v0.3.2

EXPECT returns an object that allows the caller to indicate expected use

func (*MockHTTPRequester) Get added in v0.3.2

func (m *MockHTTPRequester) Get(url string) (*http.Response, error)

Get mocks base method

type MockHTTPRequesterMockRecorder added in v0.3.2

type MockHTTPRequesterMockRecorder struct {
	// contains filtered or unexported fields
}

MockHTTPRequesterMockRecorder is the mock recorder for MockHTTPRequester

func (*MockHTTPRequesterMockRecorder) Get added in v0.3.2

func (mr *MockHTTPRequesterMockRecorder) Get(url interface{}) *gomock.Call

Get indicates an expected call of Get

type MockrpcRequester added in v0.3.2

type MockrpcRequester struct {
	// contains filtered or unexported fields
}

MockrpcRequester is a mock of rpcRequester interface

func NewMockrpcRequester added in v0.3.2

func NewMockrpcRequester(ctrl *gomock.Controller) *MockrpcRequester

NewMockrpcRequester creates a new mock instance

func (*MockrpcRequester) BatchCall added in v0.3.2

func (m *MockrpcRequester) BatchCall(b []rpc.BatchElem) error

BatchCall mocks base method

func (*MockrpcRequester) Call added in v0.3.2

func (m *MockrpcRequester) Call(resultPtr interface{}, method string, args ...interface{}) error

Call mocks base method

func (*MockrpcRequester) Close added in v0.3.2

func (m *MockrpcRequester) Close()

Close mocks base method

func (*MockrpcRequester) EXPECT added in v0.3.2

EXPECT returns an object that allows the caller to indicate expected use

type MockrpcRequesterMockRecorder added in v0.3.2

type MockrpcRequesterMockRecorder struct {
	// contains filtered or unexported fields
}

MockrpcRequesterMockRecorder is the mock recorder for MockrpcRequester

func (*MockrpcRequesterMockRecorder) BatchCall added in v0.3.2

func (mr *MockrpcRequesterMockRecorder) BatchCall(b interface{}) *gomock.Call

BatchCall indicates an expected call of BatchCall

func (*MockrpcRequesterMockRecorder) Call added in v0.3.2

func (mr *MockrpcRequesterMockRecorder) Call(resultPtr, method interface{}, args ...interface{}) *gomock.Call

Call indicates an expected call of Call

func (*MockrpcRequesterMockRecorder) Close added in v0.3.2

Close indicates an expected call of Close

Directories

Path Synopsis
example
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL