types

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: LGPL-3.0 Imports: 11 Imported by: 88

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBigInt

func NewBigInt(x int64) *hexutil.Big

NewBigInt creates a big number with specified int64 value.

func NewBigIntByRaw added in v0.1.1

func NewBigIntByRaw(x *big.Int) *hexutil.Big

NewBigIntByRaw creates a hexutil.big with specified big.int value.

func WrapError

func WrapError(err error, msg string) error

WrapError creates a WrappedError

func WrapErrorf

func WrapErrorf(err error, msgPattern string, values ...interface{}) error

WrapErrorf creates a WrappedError with formated message

Types

type AccountNotFoundError added in v0.3.2

type AccountNotFoundError struct {
	Account Address
}

AccountNotFoundError represents error of account not found.

func NewAccountNotFoundError added in v0.3.2

func NewAccountNotFoundError(address Address) *AccountNotFoundError

NewAccountNotFoundError creates a new AccountNotFoundError instance

func (*AccountNotFoundError) Error added in v0.3.2

func (e *AccountNotFoundError) Error() string

Error implements error interface

type Address

type Address string

Address represents the 20 byte address of an Conflux account in HEX format.

func NewAddress

func NewAddress(hexAddress string) *Address

NewAddress creates a address with specified HEX string.

func (*Address) IsZero added in v0.3.0

func (address *Address) IsZero() bool

IsZero returns true if the address is "0x0000000000000000000000000000000000000000" or "0X0000000000000000000000000000000000000000", otherwise returns false

func (*Address) String

func (address *Address) String() string

String implements the interface stringer

func (*Address) ToCommonAddress

func (address *Address) ToCommonAddress() *common.Address

ToCommonAddress converts address to common.Address

type Block

type Block struct {
	BlockHeader
	Transactions []Transaction `json:"transactions"`
}

Block represents a block in Conflux, including block header and a list of detailed transactions.

type BlockHeader

type BlockHeader struct {
	Hash                  Hash            `json:"hash"`
	ParentHash            Hash            `json:"parentHash"`
	Height                *hexutil.Big    `json:"height"`
	Miner                 Address         `json:"miner"`
	DeferredStateRoot     Hash            `json:"deferredStateRoot"`
	DeferredReceiptsRoot  Hash            `json:"deferredReceiptsRoot"`
	DeferredLogsBloomHash Hash            `json:"deferredLogsBloomHash"`
	Blame                 uint32          `json:"blame"`
	TransactionsRoot      Hash            `json:"transactionsRoot"`
	EpochNumber           *hexutil.Big    `json:"epochNumber,omitempty"`
	GasLimit              *hexutil.Big    `json:"gasLimit"`
	Timestamp             *hexutil.Uint64 `json:"timestamp"`
	Difficulty            *hexutil.Big    `json:"difficulty"`
	RefereeHashes         []Hash          `json:"refereeHashes"`
	Stable                *bool           `json:"stable,omitempty"`
	Adaptive              bool            `json:"adaptive"`
	Nonce                 *hexutil.Big    `json:"nonce"`
	Size                  *hexutil.Big    `json:"size,omitempty"`
}

BlockHeader represents a block header in Conflux.

type BlockSummary

type BlockSummary struct {
	BlockHeader
	Transactions []Hash `json:"transactions"`
}

BlockSummary includes block header and a list of transaction hashes

type Bloom

type Bloom string

Bloom is a hash type with 256 bytes.

type CallRequest

type CallRequest struct {
	From         *Address     `json:"from,omitempty"`
	To           *Address     `json:"to,omitempty"`
	GasPrice     *hexutil.Big `json:"gasPrice,omitempty"`
	Gas          *hexutil.Big `json:"gas,omitempty"`
	Value        *hexutil.Big `json:"value,omitempty"`
	Data         string       `json:"data,omitempty"`
	Nonce        *hexutil.Big `json:"nonce,omitempty"`
	StorageLimit *hexutil.Big `json:"storageLimit,omitempty"`
}

CallRequest represents a request to execute contract.

func (*CallRequest) FillByCallOption added in v0.1.1

func (request *CallRequest) FillByCallOption(option *ContractMethodCallOption)

FillByCallOption fills CallRequest fields by

func (*CallRequest) FillByUnsignedTx

func (request *CallRequest) FillByUnsignedTx(tx *UnsignedTransaction)

FillByUnsignedTx fills CallRequest fields by tx

type ContractDeployOption

type ContractDeployOption struct {
	UnsignedTransactionBase
	// TimeoutInSecond represents the timeout of deploy contract,
	// default value is 0 which means never timeout
	Timeout time.Duration
}

ContractDeployOption for setting option when deploying contract

type ContractMethodCallOption

type ContractMethodCallOption struct {
	From         *Address
	Nonce        *hexutil.Big
	GasPrice     *hexutil.Big
	Gas          *hexutil.Big
	Value        *hexutil.Big
	StorageLimit *hexutil.Big
	ChainID      *hexutil.Big
	Epoch        *Epoch
}

ContractMethodCallOption for setting option when call contract method

type ContractMethodSendOption

type ContractMethodSendOption UnsignedTransactionBase

ContractMethodSendOption for setting option when call contract method

type Epoch

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

Epoch represents an epoch in Conflux.

var (
	EpochEarliest    *Epoch = &Epoch{"earliest", nil}
	EpochLatestState *Epoch = &Epoch{"latest_state", nil}
	EpochLatestMined *Epoch = &Epoch{"latest_mined", nil}
)

Const epoch definitions

func NewEpochNumber

func NewEpochNumber(number *big.Int) *Epoch

NewEpochNumber creates an instance of Epoch with specified number.

func NewEpochWithBlockHash

func NewEpochWithBlockHash(blockHash Hash) *Epoch

NewEpochWithBlockHash creates an instance of Epoch with specified block hash.

func (*Epoch) MarshalText

func (e *Epoch) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Epoch) String

func (e *Epoch) String() string

String implements the fmt.Stringer interface

type Estimate

type Estimate struct {
	GasUsed               *hexutil.Big `json:"gasUsed"`
	StorageCollateralized *hexutil.Big `json:"storageCollateralized"`
}

Estimate represents estimated gas will be used and storage will be collateralized when transaction excutes

type Hash

type Hash string

Hash represents the 32 byte Keccak256 hash of arbitrary data in HEX format.

func (*Hash) String

func (hash *Hash) String() string

String implements the interface stringer

func (*Hash) ToCommonHash added in v0.1.1

func (hash *Hash) ToCommonHash() *common.Hash

ToCommonHash converts hash to common.Hash

type Log

type Log struct {
	LogEntry
	BlockHash           *Hash        `json:"blockHash,omitempty"`
	EpochNumber         *hexutil.Big `json:"epochNumber,omitempty"`
	TransactionHash     *Hash        `json:"transactionHash,omitempty"`
	TransactionIndex    *hexutil.Big `json:"transactionIndex,omitempty"`
	LogIndex            *hexutil.Big `json:"logIndex,omitempty"`
	TransactionLogIndex *hexutil.Big `json:"transactionLogIndex,omitempty"`
	// Type                string       `json:"type"`
	Removed bool `json:"removed"`
}

Log represents the event in a smart contract

type LogEntry

type LogEntry struct {
	Address Address `json:"address"`
	Topics  []Hash  `json:"topics"`
	Data    string  `json:"data"`
}

LogEntry represents a summary of event in a smart contract.

type LogFilter

type LogFilter struct {
	FromEpoch   *Epoch    `json:"fromEpoch,omitempty"`
	ToEpoch     *Epoch    `json:"toEpoch,omitempty"`
	BlockHashes []Hash    `json:"blockHashes,omitempty"`
	Address     []Address `json:"address,omitempty"`
	Topics      [][]Hash  `json:"topics,omitempty"`
	Limit       *uint8    `json:"limit,omitempty"`
}

LogFilter represents the filter of event in a smart contract.

type SignedTransaction

type SignedTransaction struct {
	UnsignedTransaction UnsignedTransaction
	V                   byte
	R                   hexutil.Bytes
	S                   hexutil.Bytes
}

SignedTransaction represents a transaction with signature, it is the transaction information for sending transaction.

func (*SignedTransaction) Decode

func (tx *SignedTransaction) Decode(data []byte) error

Decode decodes RLP encoded data to tx

func (*SignedTransaction) Encode

func (tx *SignedTransaction) Encode() ([]byte, error)

Encode encodes tx and returns its RLP encoded data

type Status added in v0.1.1

type Status struct {
	BestHash        *Hash        `json:"bestHash"`
	BlockNumber     *hexutil.Big `json:"blockNumber"`
	ChainID         *hexutil.Big `json:"chainId"`
	EpochNumber     *hexutil.Big `json:"epochNumber"`
	PendingTxNumber int          `json:"pendingTxNumber"`
}

Status represents current blockchain status

type Transaction

type Transaction struct {
	Hash             Hash         `json:"hash"`
	Nonce            *hexutil.Big `json:"nonce"`
	BlockHash        *Hash        `json:"blockHash,omitempty"`
	TransactionIndex *hexutil.Big `json:"transactionIndex,omitempty"`
	From             Address      `json:"from"`
	To               *Address     `json:"to,omitempty"`
	Value            *hexutil.Big `json:"value"`
	GasPrice         *hexutil.Big `json:"gasPrice"`
	Gas              *hexutil.Big `json:"gas"`
	ContractCreated  *Address     `json:"contractCreated,omitempty"`
	Data             string       `json:"data"`
	Status           *hexutil.Big `json:"status,omitempty"`
	ChainID          *hexutil.Big `json:"chainId,omitempty"`
	EpochHeight      *hexutil.Big `json:"epochHeight,omitempty"`
	StorageLimit     *hexutil.Big `json:"storageLimit,omitempty"`

	//signature
	V *hexutil.Big `json:"v"`
	R *hexutil.Big `json:"r"`
	S *hexutil.Big `json:"s"`
}

Transaction represents a transaction with signature in Conflux. it is the response from conflux node when sending rpc request, such as cfx_getTransactionByHash

type TransactionReceipt

type TransactionReceipt struct {
	TransactionHash Hash         `json:"transactionHash"`
	Index           uint         `json:"index"`
	BlockHash       Hash         `json:"blockHash"`
	EpochNumber     *uint64      `json:"epochNumber,omitempty"`
	From            Address      `json:"from"`
	To              *Address     `json:"to,omitempty"`
	GasUsed         *hexutil.Big `json:"gasUsed"`
	ContractCreated *Address     `json:"contractCreated,omitempty"`
	Logs            []LogEntry   `json:"logs"`
	LogsBloom       Bloom        `json:"logsBloom"`
	StateRoot       Hash         `json:"stateRoot"`
	OutcomeStatus   uint8        `json:"outcomeStatus"`
}

TransactionReceipt represents the transaction execution result in Conflux. it is the response from conflux node when sending rpc request, such as cfx_getTransactionReceipt

type UnsignedTransaction

type UnsignedTransaction struct {
	UnsignedTransactionBase
	To   *Address
	Data hexutil.Bytes
}

UnsignedTransaction represents a transaction without signature, it is the transaction information for sending transaction.

func (*UnsignedTransaction) ApplyDefault

func (tx *UnsignedTransaction) ApplyDefault()

ApplyDefault applys default value for these fields if they are empty

func (*UnsignedTransaction) Decode

func (tx *UnsignedTransaction) Decode(data []byte) error

Decode decodes RLP encoded data to tx

func (*UnsignedTransaction) Encode

func (tx *UnsignedTransaction) Encode() ([]byte, error)

Encode encodes tx and returns its RLP encoded data

func (*UnsignedTransaction) EncodeWithSignature

func (tx *UnsignedTransaction) EncodeWithSignature(v byte, r, s []byte) ([]byte, error)

EncodeWithSignature encodes tx with signature and return its RLP encoded data

func (*UnsignedTransaction) Hash

func (tx *UnsignedTransaction) Hash() ([]byte, error)

Hash hashes the tx by keccak256 and returns the result

type UnsignedTransactionBase

type UnsignedTransactionBase struct {
	From         *Address
	Nonce        *hexutil.Big
	GasPrice     *hexutil.Big
	Gas          *hexutil.Big
	Value        *hexutil.Big
	StorageLimit *hexutil.Big
	EpochHeight  *hexutil.Big
	ChainID      *hexutil.Big
}

UnsignedTransactionBase represents a transaction without To, Data and signature

type WrappedError

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

WrappedError for wrapping old error and new error message

func (WrappedError) Error

func (e WrappedError) Error() string

Error returns error description

func (WrappedError) Unwrap

func (e WrappedError) Unwrap() error

Unwrap for getting internal error by errors.Unwrap(wrappedError)

Jump to

Keyboard shortcuts

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