types

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// NodeVersion is the version of geth we are using.
	NodeVersion = "1.9.24"

	// Symbol is the symbol value
	// used in Currency.
	Symbol = "ETH"

	// Decimals is the decimals value
	// used in Currency.
	Decimals = 18

	// MinerRewardOpType is used to describe
	// a miner block reward.
	MinerRewardOpType = "MINER_REWARD"

	// UncleRewardOpType is used to describe
	// an uncle block reward.
	UncleRewardOpType = "UNCLE_REWARD"

	// FeeOpType is used to represent fee operations.
	FeeOpType = "FEE"

	// CallOpType is used to represent CALL trace operations.
	CallOpType = "CALL"

	// CreateOpType is used to represent CREATE trace operations.
	CreateOpType = "CREATE"

	// Create2OpType is used to represent CREATE2 trace operations.
	Create2OpType = "CREATE2"

	// InvalidOpType is used to represent operations outside EVM.
	InvalidOpType = "INVALID"

	// SelfDestructOpType is used to represent SELFDESTRUCT trace operations.
	SelfDestructOpType = "SELFDESTRUCT"

	// CallCodeOpType is used to represent CALLCODE trace operations.
	CallCodeOpType = "CALLCODE"

	// DelegateCallOpType is used to represent DELEGATECALL trace operations.
	DelegateCallOpType = "DELEGATECALL"

	// StaticCallOpType is used to represent STATICCALL trace operations.
	StaticCallOpType = "STATICCALL"

	// DestructOpType is a synthetic operation used to represent the
	// deletion of suicided accounts that still have funds at the end
	// of a transaction.
	DestructOpType = "DESTRUCT"

	OpErc20Transfer = "ERC20_TRANSFER"

	OpErc20Mint = "ERC20_MINT"

	OpErc20Burn = "ERC20_BURN"

	// SuccessStatus is the status of any
	// Ethereum operation considered successful.
	SuccessStatus = "SUCCESS"

	// FailureStatus is the status of any
	// Ethereum operation considered unsuccessful.
	FailureStatus = "FAILURE"

	// HistoricalBalanceSupported is whether
	// historical balance is supported.
	HistoricalBalanceSupported = true

	// UnclesRewardMultiplier is the uncle reward
	// multiplier.
	UnclesRewardMultiplier = 32

	// MaxUncleDepth is the maximum depth for
	// an uncle to be rewarded.
	MaxUncleDepth = 8

	// GenesisBlockIndex is the index of the
	// genesis block.
	GenesisBlockIndex = int64(0)

	// TransferGasLimit is the gas limit
	// of a transfer.
	TransferGasLimit = int64(21000) //nolint:gomnd

	// MainnetGethArguments are the arguments to start a mainnet geth instance.
	MainnetGethArguments = `--config=/app/ethereum/geth.toml --gcmode=archive --graphql`

	// IncludeMempoolCoins does not apply to rosetta-ethereum as it is not UTXO-based.
	IncludeMempoolCoins = false

	Online = "ONLINE"

	Offline = "OFFLINE"
)

Variables

View Source
var (
	// Errors contains all errors that could be returned
	// by this Rosetta implementation.
	Errors = []*types.Error{
		ErrUnimplemented,
		ErrUnavailableOffline,
		ErrGeth,
		ErrUnableToDecompressPubkey,
		ErrUnclearIntent,
		ErrUnableToParseIntermediateResult,
		ErrSignatureInvalid,
		ErrBroadcastFailed,
		ErrCallParametersInvalid,
		ErrCallOutputMarshal,
		ErrCallMethodInvalid,
		ErrBlockOrphaned,
		ErrInvalidAddress,
		ErrGethNotReady,
		ErrInvalidInput,
		ErrInternalError,
		ErrNonceError,
		ErrGasPriceError,
		ErrNativeGasLimitError,
		ErrERC20GasLimitError,
		ErrGasTipCapError,
		ErrGasFeeCapError,
		ErrL1DataFeeError,
	}

	// ErrUnimplemented is returned when an endpoint
	// is called that is not implemented.
	ErrUnimplemented = &types.Error{
		Code:    0,
		Message: "Endpoint not implemented",
	}

	// ErrUnavailableOffline is returned when an endpoint
	// is called that is not available offline.
	ErrUnavailableOffline = &types.Error{
		Code:    1,
		Message: "Endpoint unavailable offline",
	}

	// ErrGeth is returned when geth
	// errors on a request.
	ErrGeth = &types.Error{
		Code:    2,
		Message: "geth error",
	}

	// ErrUnableToDecompressPubkey is returned when
	// the *types.PublicKey provided in /construction/derive
	// cannot be decompressed.
	ErrUnableToDecompressPubkey = &types.Error{
		Code:    3,
		Message: "unable to decompress public key",
	}

	// ErrUnclearIntent is returned when operations
	// provided in /construction/preprocess or /construction/payloads
	// are not valid.
	ErrUnclearIntent = &types.Error{
		Code:    4,
		Message: "Unable to parse intent",
	}

	// ErrUnableToParseIntermediateResult is returned
	// when a data structure passed between Construction
	// API calls is not valid.
	ErrUnableToParseIntermediateResult = &types.Error{
		Code:    5,
		Message: "Unable to parse intermediate result",
	}

	// ErrSignatureInvalid is returned when a signature
	// cannot be parsed.
	ErrSignatureInvalid = &types.Error{
		Code:    6,
		Message: "Signature invalid",
	}

	// ErrBroadcastFailed is returned when transaction
	// broadcast fails.
	ErrBroadcastFailed = &types.Error{
		Code:    7,
		Message: "Unable to broadcast transaction",
	}

	// ErrCallParametersInvalid is returned when
	// the parameters for a particular call method
	// are considered invalid.
	ErrCallParametersInvalid = &types.Error{
		Code:    8,
		Message: "Call parameters invalid",
	}

	// ErrCallOutputMarshal is returned when the output
	// for /call cannot be marshaled.
	ErrCallOutputMarshal = &types.Error{
		Code:    9,
		Message: "Call output marshal failed",
	}

	// ErrCallMethodInvalid is returned when a /call
	// method is invalid.
	ErrCallMethodInvalid = &types.Error{
		Code:    10,
		Message: "Call method invalid",
	}

	// ErrBlockOrphaned is returned when a block being
	// processed is orphaned and it is not possible
	// to gather all receipts. At some point in the future,
	// it may become possible to gather all receipts if the
	// block becomes part of the canonical chain again.
	ErrBlockOrphaned = &types.Error{
		Code:      11,
		Message:   "Block orphaned",
		Retriable: true,
	}

	// ErrInvalidAddress is returned when an address
	// is not valid.
	ErrInvalidAddress = &types.Error{
		Code:    12,
		Message: "Invalid address",
	}

	// ErrGethNotReady is returned when geth
	// cannot yet serve any queries.
	ErrGethNotReady = &types.Error{
		Code:      13,
		Message:   "geth not ready",
		Retriable: true,
	}

	// ErrInvalidInput is returned when client
	// has provided invalid input
	ErrInvalidInput = &types.Error{
		Code:    14,
		Message: "invalid input",
	}

	// ErrInternalError is returned when we have an
	// internal error
	ErrInternalError = &types.Error{
		Code:    15,
		Message: "internal error",
	}

	// ErrNonceError is returned when we are unable to get nonce
	ErrNonceError = &types.Error{
		Code:    16,
		Message: "error getting nonce",
	}

	// ErrGasPriceError is returned when we have an
	// error to get gas price
	ErrGasPriceError = &types.Error{
		Code:    17,
		Message: "error getting gas price",
	}

	// ErrNativeGasLimitError is returned when we have an
	// error to get native gas limit
	ErrNativeGasLimitError = &types.Error{
		Code:    18,
		Message: "error getting gas limit for native transfer",
	}

	// ErrERC20GasLimitError is returned when we have an
	// error to get ERC20 gas limit
	ErrERC20GasLimitError = &types.Error{
		Code:    19,
		Message: "error getting gas limit for erc20 transfer",
	}

	// ErrGasTipCapError is returned when we have an
	// error to get tip cap
	ErrGasTipCapError = &types.Error{
		Code:    20,
		Message: "error getting gas tip cap",
	}

	// ErrGasFeeCapError is returned when we have an
	// error to get fee cap
	ErrGasFeeCapError = &types.Error{
		Code:    21,
		Message: "error getting gas fee cap",
	}

	// ErrL1DataFeeError is returned when we have an
	// error to get l1 data fee
	ErrL1DataFeeError = &types.Error{
		Code:    22,
		Message: "error getting l1 data fee",
	}

	ErrClientBlockOrphaned         = errors.New("block orphaned")
	ErrClientCallParametersInvalid = errors.New("call parameters invalid")
	ErrClientCallOutputMarshal     = errors.New("call output marshal")
	ErrClientCallMethodInvalid     = errors.New("call method invalid")
)
View Source
var (
	// OperationTypes are all suppoorted operation types.
	OperationTypes = []string{
		MinerRewardOpType,
		UncleRewardOpType,
		FeeOpType,
		CallOpType,
		CreateOpType,
		Create2OpType,
		OpErc20Transfer,
		SelfDestructOpType,
		CallCodeOpType,
		DelegateCallOpType,
		StaticCallOpType,
		DestructOpType,
		OpErc20Mint,
		OpErc20Burn,
	}

	// OperationStatuses are all supported operation statuses.
	OperationStatuses = []*RosettaTypes.OperationStatus{
		{
			Status:     SuccessStatus,
			Successful: true,
		},
		{
			Status:     FailureStatus,
			Successful: false,
		},
	}

	// CallMethods are all supported call methods.
	CallMethods = []string{
		"eth_getBlockByNumber",
		"eth_getTransactionReceipt",
		"eth_call",
		"eth_estimateGas",
	}

	Currency = &RosettaTypes.Currency{
		Symbol:   Symbol,
		Decimals: Decimals,
	}
)

Functions

func CallType

func CallType(t string) bool

CallType returns a boolean indicating if the provided trace type is a call type.

func CreateType

func CreateType(t string) bool

CreateType returns a boolean indicating if the provided trace type is a create type.

func WrapErr

func WrapErr(rErr *types.Error, err error) *types.Error

WrapErr adds details to the types.Error provided. We use a function to do this so that we don't accidentally override the standard errors.

Types

type Types

type Types struct {
	// OperationTypes are all supported operation types.
	OperationTypes []string

	// OperationStatuses are all supported operation statuses.
	OperationStatuses []*RosettaTypes.OperationStatus

	// CallMethods are all supported call methods.
	CallMethods []string

	Currency *RosettaTypes.Currency

	HistoricalBalanceSupported bool
	NodeVersion                string
}

func LoadTypes

func LoadTypes() *Types

Jump to

Keyboard shortcuts

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