Documentation ¶
Overview ¶
Copyright (c) 2023-2024 Nibi, Inc.
Copyright (c) 2023-2024 Nibi, Inc.
Copyright (c) 2023-2024 Nibi, Inc.
Copyright (c) 2023-2024 Nibi, Inc.
Copyright (c) 2023-2024 Nibi, Inc.
Copyright (c) 2023-2024 Nibi, Inc.
Copyright (c) 2023-2024 Nibi, Inc.
Index ¶
- Constants
- Variables
- func BlockGasLimit(ctx sdk.Context) (gasLimit uint64)
- func BloomFromHex(bloomHex string) (gethcore.Bloom, error)
- func BloomToHex(bloom gethcore.Bloom) string
- func BytesToHex(bz []byte) string
- func EthAddrToNibiruAddr(ethAddr gethcommon.Address) sdk.AccAddress
- func EthTxHashToString(hash gethcommon.Hash) string
- func IsEmptyHash(hash string) bool
- func IsValidChainID(chainID string) bool
- func IsValidInt256(i *big.Int) bool
- func IsZeroAddress(address string) bool
- func NewInfiniteGasMeter() sdk.GasMeter
- func NewInfiniteGasMeterWithLimit(limit sdk.Gas) sdk.GasMeter
- func NibiruAddrToEthAddr(nibiruAddr sdk.AccAddress) gethcommon.Address
- func ParseEthChainID(chainID string) *big.Int
- func ParseEthChainIDStrict(chainID string) (*big.Int, error)
- func ProtoBaseAccount() authtypes.AccountI
- func RegisterInterfaces(registry codectypes.InterfaceRegistry)
- func SafeInt64(value uint64) (int64, error)
- func SafeNewIntFromBigInt(i *big.Int) (sdkmath.Int, error)
- func TmTxHashToString(tmTxHash []byte) string
- func ValidateAddress(address string) error
- func ValidateNonZeroAddress(address string) error
- type EIP55Addr
- type EVMTxIndexer
- type ErrorGasOverflow
- type ErrorNegativeGasConsumed
- type EthAccType
- type EthAccount
- func (*EthAccount) Descriptor() ([]byte, []int)
- func (acc EthAccount) EthAddress() gethcommon.Address
- func (acc EthAccount) GetBaseAccount() *authtypes.BaseAccount
- func (acc EthAccount) GetCodeHash() gethcommon.Hash
- func (m *EthAccount) Marshal() (dAtA []byte, err error)
- func (m *EthAccount) MarshalTo(dAtA []byte) (int, error)
- func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EthAccount) ProtoMessage()
- func (m *EthAccount) Reset()
- func (acc *EthAccount) SetCodeHash(codeHash gethcommon.Hash) error
- func (m *EthAccount) Size() (n int)
- func (m *EthAccount) String() string
- func (acc EthAccount) Type() EthAccType
- func (m *EthAccount) Unmarshal(dAtA []byte) error
- func (m *EthAccount) XXX_DiscardUnknown()
- func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EthAccount) XXX_Merge(src proto.Message)
- func (m *EthAccount) XXX_Size() int
- func (m *EthAccount) XXX_Unmarshal(b []byte) error
- type EthAccountI
- type HDPathIterator
- type InfiniteGasMeter
- func (g *InfiniteGasMeter) ConsumeGas(amount sdk.Gas, descriptor string)
- func (g *InfiniteGasMeter) GasConsumed() sdk.Gas
- func (g *InfiniteGasMeter) GasConsumedToLimit() sdk.Gas
- func (g *InfiniteGasMeter) GasRemaining() sdk.Gas
- func (g *InfiniteGasMeter) IsOutOfGas() bool
- func (g *InfiniteGasMeter) IsPastLimit() bool
- func (g *InfiniteGasMeter) Limit() sdk.Gas
- func (g *InfiniteGasMeter) RefundGas(amount sdk.Gas, descriptor string)
- func (g *InfiniteGasMeter) String() string
- type TxResult
- func (*TxResult) Descriptor() ([]byte, []int)
- func (m *TxResult) Marshal() (dAtA []byte, err error)
- func (m *TxResult) MarshalTo(dAtA []byte) (int, error)
- func (m *TxResult) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*TxResult) ProtoMessage()
- func (m *TxResult) Reset()
- func (m *TxResult) Size() (n int)
- func (m *TxResult) String() string
- func (m *TxResult) Unmarshal(dAtA []byte) error
- func (m *TxResult) XXX_DiscardUnknown()
- func (m *TxResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TxResult) XXX_Merge(src proto.Message)
- func (m *TxResult) XXX_Size() int
- func (m *TxResult) XXX_Unmarshal(b []byte) error
Constants ¶
const ( EthBaseDenom = appconst.BondDenom // EIP155ChainID_Testnet: Chain ID for a testnet Nibiru following the // format proposed by Vitalik in EIP155. EIP155ChainID_Testnet = "nibirutest_420-1" DefaultGasPrice = 20 // ProtocolVersion: Latest supported version of the Ethereum protocol. // Matches the message types and expected APIs. // As of April, 2024, the highest protocol version on Ethereum mainnet is // "eth/68". // See https://github.com/ethereum/devp2p/blob/master/caps/eth.md#change-log // for the historical summary of each version. ProtocolVersion = 65 )
Variables ¶
var ( ErrInvalidLengthAccount = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowAccount = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupAccount = fmt.Errorf("proto: unexpected end of group") )
var ( // Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info. Bip44CoinType uint32 = 60 // BIP44HDPath is the default BIP44 HD path used on Ethereum. BIP44HDPath = ethaccounts.DefaultBaseDerivationPath.String() )
var ( ErrInvalidLengthIndexer = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowIndexer = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupIndexer = fmt.Errorf("proto: unexpected end of group") )
var ( // Implements a `collections.ValueEncoder` for the `[]byte` type ValueEncoderBytes collections.ValueEncoder[[]byte] = veBytes{} KeyEncoderBytes collections.KeyEncoder[[]byte] = keBytes{} // Implements a `collections.ValueEncoder` for an Ethereum address. ValueEncoderEthAddr collections.ValueEncoder[gethcommon.Address] = veEthAddr{} // keEthHash: Implements a `collections.KeyEncoder` for an Ethereum address. KeyEncoderEthAddr collections.KeyEncoder[gethcommon.Address] = keEthAddr{} // keEthHash: Implements a `collections.KeyEncoder` for an Ethereum hash. KeyEncoderEthHash collections.KeyEncoder[gethcommon.Hash] = keEthHash{} )
var (
ErrInvalidChainID = registerError("invalid Ethereum chain ID")
)
Module "sentinel" errors
Functions ¶
func BlockGasLimit ¶
BlockGasLimit: Gas (limit) as defined by the block gas meter. Gas limit is derived from the consensus params if the block gas meter is nil.
func BloomFromHex ¶
BloomFromHex converts a hex-encoded bloom filter to a gethcore.Bloom.
func BloomToHex ¶
BloomToHex returns the bloom filter as a string.
func BytesToHex ¶
BytesToHex converts a byte array to a hexadecimal string
func EthAddrToNibiruAddr ¶
func EthAddrToNibiruAddr(ethAddr gethcommon.Address) sdk.AccAddress
func EthTxHashToString ¶
func EthTxHashToString(hash gethcommon.Hash) string
EthTxHashToString returns the EVM transaction hash as a string.
func IsEmptyHash ¶
IsEmptyHash returns true if the hash corresponds to an empty ethereum hex hash.
func IsValidChainID ¶
IsValidChainID returns false if the given chain identifier is incorrectly formatted.
func IsValidInt256 ¶
IsValidInt256 check the bound of 256 bit number
func IsZeroAddress ¶
IsZeroAddress returns true if the address corresponds to an empty ethereum hex address.
func NewInfiniteGasMeter ¶
NewInfiniteGasMeter: Alias for an infinite gas meter ([NewInfiniteGasMeterWithLimitla)] with a tracked but unenforced gas limit.
func NewInfiniteGasMeterWithLimit ¶
NewInfiniteGasMeterWithLimit returns a reference to a new infiniteGasMeter.
func NibiruAddrToEthAddr ¶
func NibiruAddrToEthAddr(nibiruAddr sdk.AccAddress) gethcommon.Address
func ParseEthChainID ¶
ParseEthChainID parses a string chain identifier's to an Ethereum-compatible chain-id in *big.Int format.
This function uses Nibiru's map of chain IDs defined in Nibiru/app/appconst rather than the regex of EIP155, which is implemented by ParseEthChainIDStrict.
func ParseEthChainIDStrict ¶
ParseEthChainIDStrict parses a string chain identifier's epoch to an Ethereum-compatible chain-id in *big.Int format. The function returns an error if the chain-id has an invalid format
func ProtoBaseAccount ¶
ProtoBaseAccount: Implementation of `BaseAccount` for the `AccountI` interface used in the AccountKeeper from the Auth Module. ProtoBaseAccount is a drop-in replacement for the `auth.ProtoBaseAccount` from "cosmos-sdk/auth/types" extended to fit the the `EthAccountI` interface for Ethereum accounts.
func RegisterInterfaces ¶
func RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces registers the tendermint concrete client-related implementations and interfaces.
func SafeNewIntFromBigInt ¶
SafeNewIntFromBigInt constructs Int from big.Int, return error if more than 256bits
func TmTxHashToString ¶
TmTxHashToString returns the consensus transaction hash as a string. Transactions are hex-encoded and capitlized. Reference: Tx.String function from comet-bft/types/tx.go
func ValidateAddress ¶
ValidateAddress returns an error if the provided string is either not a hex formatted string address
func ValidateNonZeroAddress ¶
ValidateNonZeroAddress returns an error if the provided string is not a hex formatted string address or is equal to zero
Types ¶
type EIP55Addr ¶
type EIP55Addr struct {
gethcommon.Address
}
EIP55Addr is a wrapper around gethcommon.Address that provides JSON marshaling and unmarshalling as well as Protobuf serialization and deserialization. The constructors ensure that the input string is a valid 20 byte hex address.
func NewEIP55AddrFromStr ¶
Checks input length, but not case-sensitive hex.
func (EIP55Addr) Marshal ¶
Marshal implements the gogo proto custom type interface. Ref: https://github.com/cosmos/gogoproto/blob/v1.5.0/custom_types.md
func (EIP55Addr) MarshalJSON ¶
MarshalJSON returns the EIP55Addr as JSON bytes. Implements the gogo proto custom type interface. Ref: https://github.com/cosmos/gogoproto/blob/v1.5.0/custom_types.md
func (*EIP55Addr) MarshalTo ¶
MarshalTo serializes a EIP55Addr directly into a pre-allocated byte slice ("data"). MarshalTo implements the gogo proto custom type interface. Implements the gogo proto custom type interface. Ref: https://github.com/cosmos/gogoproto/blob/v1.5.0/custom_types.md
func (EIP55Addr) Size ¶
Size implements the gogo proto custom type interface. Ref: https://github.com/cosmos/gogoproto/blob/v1.5.0/custom_types.md
func (*EIP55Addr) Unmarshal ¶
Unmarshal implements the gogo proto custom type interface. Ref: https://github.com/cosmos/gogoproto/blob/v1.5.0/custom_types.md
func (*EIP55Addr) UnmarshalJSON ¶
UnmarshalJSON implements the gogo proto custom type interface. Ref: https://github.com/cosmos/gogoproto/blob/v1.5.0/custom_types.md
type EVMTxIndexer ¶
type EVMTxIndexer interface { // LastIndexedBlock returns -1 if indexer db is empty LastIndexedBlock() (int64, error) IndexBlock(*tmtypes.Block, []*abci.ResponseDeliverTx) error // GetByTxHash returns nil if tx not found. GetByTxHash(common.Hash) (*TxResult, error) // GetByBlockAndIndex returns nil if tx not found. GetByBlockAndIndex(int64, int32) (*TxResult, error) }
EVMTxIndexer defines the interface of custom eth tx indexer.
type ErrorGasOverflow ¶
type ErrorGasOverflow struct {
Descriptor string
}
ErrorGasOverflow defines an error thrown when an action results gas consumption unsigned integer overflow.
type ErrorNegativeGasConsumed ¶
type ErrorNegativeGasConsumed struct {
Descriptor string
}
ErrorNegativeGasConsumed defines an error thrown when the amount of gas refunded results in a negative gas consumed amount.
type EthAccType ¶
type EthAccType = int8
EthAccType: Enum for Ethereum account types.
const ( // EthAccType_EOA: For externally owned accounts (EOAs) EthAccType_EOA EthAccType = iota + 1 // EthAccType_Contract: For smart contracts accounts. EthAccType_Contract )
type EthAccount ¶
type EthAccount struct { // base_account is an authtypes.BaseAccount *types.BaseAccount `` /* 136-byte string literal not displayed */ // code_hash is the hash calculated from the code contents CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty" yaml:"code_hash"` }
EthAccount implements the authtypes.AccountI interface and embeds an authtypes.BaseAccount type. It is compatible with the auth AccountKeeper.
func (*EthAccount) Descriptor ¶
func (*EthAccount) Descriptor() ([]byte, []int)
func (EthAccount) EthAddress ¶
func (acc EthAccount) EthAddress() gethcommon.Address
EthAddress returns the account address ethereum format.
func (EthAccount) GetBaseAccount ¶
func (acc EthAccount) GetBaseAccount() *authtypes.BaseAccount
func (EthAccount) GetCodeHash ¶
func (acc EthAccount) GetCodeHash() gethcommon.Hash
func (*EthAccount) Marshal ¶
func (m *EthAccount) Marshal() (dAtA []byte, err error)
func (*EthAccount) MarshalToSizedBuffer ¶
func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*EthAccount) ProtoMessage ¶
func (*EthAccount) ProtoMessage()
func (*EthAccount) Reset ¶
func (m *EthAccount) Reset()
func (*EthAccount) SetCodeHash ¶
func (acc *EthAccount) SetCodeHash(codeHash gethcommon.Hash) error
func (*EthAccount) Size ¶
func (m *EthAccount) Size() (n int)
func (*EthAccount) String ¶
func (m *EthAccount) String() string
func (EthAccount) Type ¶
func (acc EthAccount) Type() EthAccType
Type returns the type of Ethereum Account (EOA or Contract)
func (*EthAccount) Unmarshal ¶
func (m *EthAccount) Unmarshal(dAtA []byte) error
func (*EthAccount) XXX_DiscardUnknown ¶
func (m *EthAccount) XXX_DiscardUnknown()
func (*EthAccount) XXX_Marshal ¶
func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EthAccount) XXX_Merge ¶
func (m *EthAccount) XXX_Merge(src proto.Message)
func (*EthAccount) XXX_Size ¶
func (m *EthAccount) XXX_Size() int
func (*EthAccount) XXX_Unmarshal ¶
func (m *EthAccount) XXX_Unmarshal(b []byte) error
type EthAccountI ¶
type EthAccountI interface { authtypes.AccountI // EthAddress returns the ethereum Address representation of the AccAddress EthAddress() gethcommon.Address // CodeHash is the keccak256 hash of the contract code (if any) GetCodeHash() gethcommon.Hash // SetCodeHash sets the code hash to the account fields SetCodeHash(code gethcommon.Hash) error // Type returns the type of Ethereum Account (EOA or Contract) Type() EthAccType }
EthAccountI represents the interface of an EVM compatible account
type HDPathIterator ¶
type HDPathIterator func() ethaccounts.DerivationPath
func NewHDPathIterator ¶
func NewHDPathIterator(basePath string, ledgerIter bool) (HDPathIterator, error)
HDPathIterator receives a base path as a string and a boolean for the desired iterator type and returns a function that iterates over the base HD path, returning the string.
type InfiniteGasMeter ¶
type InfiniteGasMeter struct {
// contains filtered or unexported fields
}
InfiniteGasMeter: A special impl of `sdk.GasMeter` that ignores any gas limits, allowing an unlimited amount of gas to be consumed. This is especially useful for scenarios where gas consumption needs to be monitored but not restricted, such as during testing or in parts of the chain where constraints are meant to be set differently.
func (*InfiniteGasMeter) ConsumeGas ¶
func (g *InfiniteGasMeter) ConsumeGas(amount sdk.Gas, descriptor string)
ConsumeGas adds the given amount of gas to the gas consumed and panics if it overflows the limit or out of gas.
func (*InfiniteGasMeter) GasConsumed ¶
func (g *InfiniteGasMeter) GasConsumed() sdk.Gas
GasConsumed returns the gas consumed from the GasMeter.
func (*InfiniteGasMeter) GasConsumedToLimit ¶
func (g *InfiniteGasMeter) GasConsumedToLimit() sdk.Gas
GasConsumedToLimit returns the gas limit if gas consumed is past the limit, otherwise it returns the consumed gas.
Note that This function is used when recovering from a panic in "BlockGasMeter" when the consumed gas passes the limit.
func (*InfiniteGasMeter) GasRemaining ¶
func (g *InfiniteGasMeter) GasRemaining() sdk.Gas
GasRemaining returns MaxUint64 since limit is not confined in infiniteGasMeter.
func (*InfiniteGasMeter) IsOutOfGas ¶
func (g *InfiniteGasMeter) IsOutOfGas() bool
IsOutOfGas returns true if gas consumed is greater than or equal to gas limit, otherwise it returns false. In the case of the the InfiniteGasMeter, this always returns false for unrestricted gas consumption.
func (*InfiniteGasMeter) IsPastLimit ¶
func (g *InfiniteGasMeter) IsPastLimit() bool
IsPastLimit returns true if gas consumed is past limit, otherwise it returns false. In the case of the the InfiniteGasMeter, this always returns false.
func (*InfiniteGasMeter) Limit ¶
func (g *InfiniteGasMeter) Limit() sdk.Gas
Limit returns the gas limit of the GasMeter.
func (*InfiniteGasMeter) RefundGas ¶
func (g *InfiniteGasMeter) RefundGas(amount sdk.Gas, descriptor string)
RefundGas will deduct the given amount from the gas consumed. If the amount is greater than the gas consumed, the function will panic.
Use case: This functionality enables refunding gas to the trasaction or block gas pools so that EVM-compatible chains can fully support the go-ethereum StateDb interface. See https://github.com/cosmos/cosmos-sdk/pull/9403 for reference.
func (*InfiniteGasMeter) String ¶
func (g *InfiniteGasMeter) String() string
String returns the BasicGasMeter's gas limit and gas consumed.
type TxResult ¶
type TxResult struct { // height of the blockchain Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` // tx_index of the cosmos transaction TxIndex uint32 `protobuf:"varint,2,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` // msg_index in a batch transaction MsgIndex uint32 `protobuf:"varint,3,opt,name=msg_index,json=msgIndex,proto3" json:"msg_index,omitempty"` // eth_tx_index is the index in the list of valid eth tx in the block, // aka. the transaction list returned by eth_getBlock api. EthTxIndex int32 `protobuf:"varint,4,opt,name=eth_tx_index,json=ethTxIndex,proto3" json:"eth_tx_index,omitempty"` // failed is true if the eth transaction did not go succeed Failed bool `protobuf:"varint,5,opt,name=failed,proto3" json:"failed,omitempty"` // gas_used by the transaction. If it exceeds the block gas limit, // it's set to gas limit, which is what's actually deducted by ante handler. GasUsed uint64 `protobuf:"varint,6,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` // cumulative_gas_used specifies the cumulated amount of gas used for all // processed messages within the current batch transaction. CumulativeGasUsed uint64 `protobuf:"varint,7,opt,name=cumulative_gas_used,json=cumulativeGasUsed,proto3" json:"cumulative_gas_used,omitempty"` }
TxResult is the value stored in eth tx indexer
func (*TxResult) Descriptor ¶
func (*TxResult) MarshalToSizedBuffer ¶
func (*TxResult) ProtoMessage ¶
func (*TxResult) ProtoMessage()
func (*TxResult) XXX_DiscardUnknown ¶
func (m *TxResult) XXX_DiscardUnknown()