types

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthPendingBlockNumber  = BlockNumber(-2)
	EthLatestBlockNumber   = BlockNumber(-1)
	EthEarliestBlockNumber = BlockNumber(0)
)
View Source
const LogRevertedFlag = "transaction reverted"

Variables

This section is empty.

Functions

func BlockMaxGasFromConsensusParams

func BlockMaxGasFromConsensusParams(ctx context.Context, clientCtx client.Context) (int64, error)

BlockMaxGasFromConsensusParams returns the gas limit for the latest block from the chain consensus params.

func ContextWithHeight

func ContextWithHeight(height int64) context.Context

ContextWithHeight wraps a context with the a gRPC block height header. If the provided height is 0, it will return an empty context and the gRPC query will use the latest block height for querying.

func EthBlockFromTendermint

func EthBlockFromTendermint(clientCtx client.Context, queryClient *QueryClient, block *tmtypes.Block) (map[string]interface{}, error)

EthBlockFromTendermint returns a JSON-RPC compatible Ethereum blockfrom a given Tendermint block.

func EthHeaderFromTendermint

func EthHeaderFromTendermint(header tmtypes.Header) *ethtypes.Header

EthHeaderFromTendermint is an util function that returns an Ethereum Header from a tendermint Header.

func EthTransactionsFromTendermint

func EthTransactionsFromTendermint(clientCtx client.Context, txs []tmtypes.Tx) ([]common.Hash, *big.Int, error)

EthTransactionsFromTendermint returns a slice of ethereum transaction hashes and the total gas usage from a set of tendermint block transactions.

func FormatBlock

func FormatBlock(
	header tmtypes.Header, size int, gasLimit int64,
	gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
) map[string]interface{}

FormatBlock creates an ethereum block from a tendermint header and ethereum-formatted transactions.

func RawTxToEthTx

func RawTxToEthTx(clientCtx client.Context, txBz tmtypes.Tx) (*evmtypes.MsgEthereumTx, error)

RawTxToEthTx returns a evm MsgEthereum transaction from raw tx bytes.

Types

type AccountResult

type AccountResult struct {
	Address      common.Address  `json:"address"`
	AccountProof []string        `json:"accountProof"`
	Balance      *hexutil.Big    `json:"balance"`
	CodeHash     common.Hash     `json:"codeHash"`
	Nonce        hexutil.Uint64  `json:"nonce"`
	StorageHash  common.Hash     `json:"storageHash"`
	StorageProof []StorageResult `json:"storageProof"`
}

AccountResult struct for account proof

type AddrLocker

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

AddrLocker is a mutex structure used to avoid querying outdated account data

func (*AddrLocker) LockAddr

func (l *AddrLocker) LockAddr(address common.Address)

LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.

func (*AddrLocker) UnlockAddr

func (l *AddrLocker) UnlockAddr(address common.Address)

UnlockAddr unlocks the mutex of the given account.

type BlockNumber

type BlockNumber int64

BlockNumber represents decoding hex string to block values

func NewBlockNumber

func NewBlockNumber(n *big.Int) BlockNumber

NewBlockNumber creates a new BlockNumber instance.

func (BlockNumber) Int64

func (bn BlockNumber) Int64() int64

Int64 converts block number to primitive type

func (BlockNumber) TmHeight

func (bn BlockNumber) TmHeight() *int64

TmHeight is a util function used for the Tendermint RPC client. It returns nil if the block number is "latest". Otherwise, it returns the pointer of the int64 value of the height.

func (*BlockNumber) UnmarshalJSON

func (bn *BlockNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports: - "latest", "earliest" or "pending" as string arguments - the block number Returned errors: - an invalid block number error when the given argument isn't a known strings - an out of range error when the given block number is either too little or too large

type CallArgs

type CallArgs struct {
	From       *common.Address      `json:"from"`
	To         *common.Address      `json:"to"`
	Gas        *hexutil.Uint64      `json:"gas"`
	GasPrice   *hexutil.Big         `json:"gasPrice"`
	Value      *hexutil.Big         `json:"value"`
	Data       *hexutil.Bytes       `json:"data"`
	AccessList *ethtypes.AccessList `json:"accessList"`
}

CallArgs represents the arguments for a call.

func (*CallArgs) String

func (args *CallArgs) String() string

String return the struct in a string format

type DataError

type DataError interface {
	Error() string          // returns the message
	ErrorData() interface{} // returns the error data
}

func ErrRevertedWith

func ErrRevertedWith(data []byte) DataError

type OverrideAccount

type OverrideAccount struct {
	Nonce     *hexutil.Uint64              `json:"nonce"`
	Code      *hexutil.Bytes               `json:"code"`
	Balance   **hexutil.Big                `json:"balance"`
	State     *map[common.Hash]common.Hash `json:"state"`
	StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
}

OverrideAccount indicates the overriding fields of account during the execution of a message call. Note, state and stateDiff can't be specified at the same time. If state is set, message execution will only use the data in the given state. Otherwise if statDiff is set, all diff will be applied first and then execute the call message.

type QueryClient

type QueryClient struct {
	tx.ServiceClient
	evmtypes.QueryClient
}

QueryClient defines a gRPC Client used for:

  • Transaction simulation
  • EVM module queries

func NewQueryClient

func NewQueryClient(clientCtx client.Context) *QueryClient

NewQueryClient creates a new gRPC query client

func (QueryClient) GetProof

func (QueryClient) GetProof(clientCtx client.Context, storeKey string, key []byte) ([]byte, *crypto.ProofOps, error)

GetProof performs an ABCI query with the given key and returns a merkle proof. The desired tendermint height to perform the query should be set in the client context. The query will be performed at one below this height (at the IAVL version) in order to obtain the correct merkle proof. Proof queries at height less than or equal to 2 are not supported. Issue: https://github.com/cosmos/cosmos-sdk/issues/6567

type RPCTransaction

type RPCTransaction struct {
	BlockHash        *common.Hash         `json:"blockHash"`
	BlockNumber      *hexutil.Big         `json:"blockNumber"`
	From             common.Address       `json:"from"`
	Gas              hexutil.Uint64       `json:"gas"`
	GasPrice         *hexutil.Big         `json:"gasPrice"`
	Hash             common.Hash          `json:"hash"`
	Input            hexutil.Bytes        `json:"input"`
	Nonce            hexutil.Uint64       `json:"nonce"`
	To               *common.Address      `json:"to"`
	TransactionIndex *hexutil.Uint64      `json:"transactionIndex"`
	Value            *hexutil.Big         `json:"value"`
	Type             hexutil.Uint64       `json:"type"`
	Accesses         *ethtypes.AccessList `json:"accessList,omitempty"`
	ChainID          *hexutil.Big         `json:"chainId,omitempty"`
	V                *hexutil.Big         `json:"v"`
	R                *hexutil.Big         `json:"r"`
	S                *hexutil.Big         `json:"s"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

func NewTransaction

func NewTransaction(tx *ethtypes.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction

NewTransaction returns a transaction that will serialize to the RPC representation, with the given location metadata set (if available).

func NewTransactionFromData

func NewTransactionFromData(
	txData evmtypes.TxData,
	from common.Address,
	txHash, blockHash common.Hash,
	blockNumber, index uint64,
) (*RPCTransaction, error)

NewTransactionFromData returns a transaction that will serialize to the RPC representation, with the given location metadata set (if available).

type SDKTxLogs

type SDKTxLogs struct {
	Log string `json:"log"`
}

type SendTxArgs

type SendTxArgs struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	// We accept "data" and "input" for backwards-compatibility reasons. "input" is the
	// newer name and should be preferred by clients.
	Data  *hexutil.Bytes `json:"data"`
	Input *hexutil.Bytes `json:"input"`
	// For non-legacy transactions
	AccessList *ethtypes.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big         `json:"chainId,omitempty"`
}

SendTxArgs represents the arguments to submit a new transaction into the transaction pool. Duplicate struct definition since geth struct is in internal package Ref: https://github.com/ethereum/go-ethereum/blob/release/1.9/internal/ethapi/api.go#L1346

func (*SendTxArgs) String

func (args *SendTxArgs) String() string

String return the struct in a string format

func (*SendTxArgs) ToTransaction

func (args *SendTxArgs) ToTransaction() *evmtypes.MsgEthereumTx

ToTransaction converts the arguments to an ethereum transaction. This assumes that setTxDefaults has been called.

type StateOverride

type StateOverride map[common.Address]OverrideAccount

StateOverride is the collection of overridden accounts.

type StorageResult

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

StorageResult defines the format for storage proof return

Jump to

Keyboard shortcuts

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