types

package
v0.0.0-...-c763619 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LatestBlockNumber mapping from "latest" to 0 for tm query
	LatestBlockNumber = BlockNumber(0)
	// PendingBlockNumber mapping from "pending" to -1 for tm query
	PendingBlockNumber = BlockNumber(-1)
	// EarliestBlockNumber mapping from "earliest" to (genesisHeight + 1) for tm query (earliest query not supported)
	EarliestBlockNumber = BlockNumber(tmtypes.GetStartBlockHeight() + 1)

	ErrResourceNotFound = errors.New("resource not found")
)

Functions

func BlockMaxGasFromConsensusParams

func BlockMaxGasFromConsensusParams(_ context.Context, clientCtx clientcontext.CLIContext) (int64, error)

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

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 clientcontext.CLIContext, txs []tmtypes.Tx, blockHash common.Hash, blockNumber uint64) (*big.Int, []*watcher.Transaction, 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, curBlockHash tmbytes.HexBytes, gasLimit int64,
	gasUsed *big.Int, transactions []*watcher.Transaction, bloom ethtypes.Bloom, fullTx bool,
) *watcher.Block

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

func GetBlockCumulativeGas

func GetBlockCumulativeGas(cdc *codec.Codec, block *tmtypes.Block, idx int) uint64

GetBlockCumulativeGas returns the cumulative gas used on a block up to a given transaction index. The returned gas used includes the gas from both the SDK and EVM module transactions.

func GetEthSender

func GetEthSender(tr *ctypes.ResultTx) (string, error)

func GetKeyByAddress

func GetKeyByAddress(keys []ethsecp256k1.PrivKey, address common.Address) (key *ethsecp256k1.PrivKey, exist bool)

GetKeyByAddress returns the private key matching the given address. If not found it returns false.

func RawTxResultToEthReceipt

func RawTxResultToEthReceipt(chainID *big.Int, tr *ctypes.ResultTx, realTx sdk.Tx,
	blockHash common.Hash) (*watcher.TransactionResult, error)

func RawTxToEthTx

func RawTxToEthTx(clientCtx clientcontext.CLIContext, bz []byte, height int64) (*evmtypes.MsgEthereumTx, error)

RawTxToEthTx returns a evm MsgEthereum transaction from raw tx bytes.

func RawTxToRealTx

func RawTxToRealTx(clientCtx clientcontext.CLIContext, bz tmtypes.Tx,
	blockHash common.Hash, blockNumber, index uint64) (sdk.Tx, error)

func RpcBlockFromTendermint

func RpcBlockFromTendermint(clientCtx clientcontext.CLIContext, block *tmtypes.Block, fullTx bool) (*watcher.Block, error)

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

func ToTransaction

func ToTransaction(tx *evmtypes.MsgEthereumTx, from *common.Address) *watcher.Transaction

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 BlockNumberOrHash

type BlockNumberOrHash struct {
	BlockNumber      *BlockNumber `json:"blockNumber,omitempty"`
	BlockHash        *common.Hash `json:"blockHash,omitempty"`
	RequireCanonical bool         `json:"requireCanonical,omitempty"`
}

func BlockNumberOrHashWithHash

func BlockNumberOrHashWithHash(hash common.Hash, canonical bool) BlockNumberOrHash

func BlockNumberOrHashWithNumber

func BlockNumberOrHashWithNumber(blockNr BlockNumber) BlockNumberOrHash

func (*BlockNumberOrHash) Hash

func (bnh *BlockNumberOrHash) Hash() (common.Hash, bool)

func (*BlockNumberOrHash) Number

func (bnh *BlockNumberOrHash) Number() (BlockNumber, bool)

func (*BlockNumberOrHash) UnmarshalJSON

func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error

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"`
}

CallArgs represents the arguments for a call.

func (CallArgs) String

func (ca CallArgs) String() string

type EthHeaderWithBlockHash

type EthHeaderWithBlockHash struct {
	ParentHash  common.Hash         `json:"parentHash"`
	UncleHash   common.Hash         `json:"sha3Uncles"`
	Coinbase    common.Address      `json:"miner"`
	Root        common.Hash         `json:"stateRoot"`
	TxHash      common.Hash         `json:"transactionsRoot"`
	ReceiptHash common.Hash         `json:"receiptsRoot"`
	Bloom       ethtypes.Bloom      `json:"logsBloom"`
	Difficulty  *hexutil.Big        `json:"difficulty"`
	Number      *hexutil.Big        `json:"number"`
	GasLimit    hexutil.Uint64      `json:"gasLimit"`
	GasUsed     hexutil.Uint64      `json:"gasUsed"`
	Time        hexutil.Uint64      `json:"timestamp"`
	Extra       hexutil.Bytes       `json:"extraData"`
	MixDigest   common.Hash         `json:"mixHash"`
	Nonce       ethtypes.BlockNonce `json:"nonce"`
	Hash        common.Hash         `json:"hash"`
}

EthHeaderWithBlockHash represents a block header in the Ethereum blockchain with block hash generated from Tendermint Block

func EthHeaderWithBlockHashFromTendermint

func EthHeaderWithBlockHashFromTendermint(tmHeader *tmtypes.Header) (header *EthHeaderWithBlockHash, err error)

EthHeaderWithBlockHashFromTendermint gets the eth Header with block hash from Tendermint block inside

type FeeHistoryResult

type FeeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"`
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}

type GPIn3Gears

type GPIn3Gears struct {
	SafeLow *hexutil.Big `json:"safe_low"`
	Average *hexutil.Big `json:"average"`
	Fastest *hexutil.Big `json:"fastest"`
}

func NewGPIn3Gears

func NewGPIn3Gears(safelow, avg, fastest *big.Int) GPIn3Gears

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"`
}

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 (ca SendTxArgs) String() string

type SignTransactionResult

type SignTransactionResult struct {
	Raw hexutil.Bytes        `json:"raw"`
	Tx  *watcher.Transaction `json:"tx"`
}

SignTransactionResult represents a RLP encoded signed transaction.

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