Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidChainID(chainID string) bool
- func NewPhotonCoin(amount sdk.Int) sdk.Coin
- func NewPhotonCoinInt64(amount int64) sdk.Coin
- func NewPhotonDecCoin(amount sdk.Int) sdk.SysCoin
- func ParseChainID(chainID string) (*big.Int, error)
- func ProtoAccount() exported.Account
- func RegisterCodec(cdc *codec.Codec)
- func SetBech32Prefixes(config *sdk.Config)
- func SetBip44CoinType(config *sdk.Config)
- type Code
- type EthAccount
- func (acc EthAccount) Balance(denom string) sdk.Dec
- func (acc EthAccount) EthAddress() ethcmn.Address
- func (acc EthAccount) MarshalJSON() ([]byte, error)
- func (acc EthAccount) MarshalYAML() (interface{}, error)
- func (acc *EthAccount) SetBalance(denom string, amt sdk.Dec)
- func (acc EthAccount) String() string
- func (acc *EthAccount) UnmarshalJSON(bz []byte) error
Constants ¶
const ( // NativeToken defines the default coin denomination used in OKExChain in: // // - Staking parameters: denomination used as stake in the dPoS chain // - Mint parameters: denomination minted due to fee distribution rewards // - Governance parameters: denomination used for spam prevention in proposal deposits // - Crisis parameters: constant fee denomination used for spam prevention to check broken invariant // - EVM parameters: denomination used for running EVM state transitions in OKExChain. NativeToken string = sdk.DefaultBondDenom // BaseDenomUnit defines the base denomination unit for Photons. // 1 photon = 1x10^{BaseDenomUnit} aphoton BaseDenomUnit = 18 )
const ( // EthBech32Prefix defines the Bech32 prefix used for EthAccounts EthBech32Prefix = "de" // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address Bech32PrefixAccAddr = EthBech32Prefix // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key Bech32PrefixAccPub = EthBech32Prefix + sdk.PrefixPublic // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address Bech32PrefixValAddr = EthBech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key Bech32PrefixValPub = EthBech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address Bech32PrefixConsAddr = EthBech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key Bech32PrefixConsPub = EthBech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic // Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info. Bip44CoinType = 996 BIP44HDPathOKExChain = "m/44'/996'/0'/0/0" )
const ( // DefaultGasPrice is default gas price for evm transactions DefaultGasPrice = 1 // DefaultRPCGasLimit is default gas limit for RPC call operations DefaultRPCGasLimit = 30000000 )
const (
// EthAccountName is the amino encoding name for EthAccount
EthAccountName = "okexchain/EthAccount"
)
const (
// ProtocolVersion is the latest supported version of the eth protocol.
ProtocolVersion = eth65
)
Constants to match up protocol versions and messages
const (
// RootCodespace is the codespace for all errors defined in this package
RootCodespace = "okexchain"
)
Variables ¶
var ( // ErrInvalidValue returns an error resulting from an invalid value. ErrInvalidValue = sdkerrors.Register(RootCodespace, 2, "invalid value") // ErrInvalidChainID returns an error resulting from an invalid chain ID. ErrInvalidChainID = sdkerrors.Register(RootCodespace, 3, "invalid chain ID") // ErrVMExecution returns an error resulting from an error in EVM execution. ErrVMExecution = sdkerrors.Register(RootCodespace, 4, "error while executing evm transaction") ErrInvalidMsgType = sdkerrors.Register(RootCodespace, 5, "invalid message type") )
var ( // BIP44HDPath is the BIP44 HD path used on Ethereum. BIP44HDPath = ethaccounts.DefaultBaseDerivationPath.String() )
Functions ¶
func IsValidChainID ¶
IsValidChainID returns false if the given chain identifier is incorrectly formatted.
func NewPhotonCoin ¶
NewPhotonCoin is a utility function that returns an "aphoton" coin with the given sdk.Int amount. The function will panic if the provided amount is negative.
func NewPhotonCoinInt64 ¶
NewPhotonCoinInt64 is a utility function that returns an "aphoton" coin with the given int64 amount. The function will panic if the provided amount is negative.
func NewPhotonDecCoin ¶
NewPhotonDecCoin is a utility function that returns an "aphoton" decimal coin with the given sdk.Int amount. The function will panic if the provided amount is negative.
func ParseChainID ¶
ParseChainID 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 ProtoAccount ¶
ProtoAccount defines the prototype function for BaseAccount used for an AccountKeeper.
func RegisterCodec ¶
RegisterCodec registers the account interfaces and concrete types on the provided Amino codec.
func SetBech32Prefixes ¶
SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
func SetBip44CoinType ¶
SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
Types ¶
type EthAccount ¶
type EthAccount struct { *authtypes.BaseAccount `json:"base_account" yaml:"base_account"` CodeHash []byte `json:"code_hash" yaml:"code_hash"` }
EthAccount implements the auth.Account interface and embeds an auth.BaseAccount type. It is compatible with the auth.AccountKeeper.
func (EthAccount) Balance ¶
func (acc EthAccount) Balance(denom string) sdk.Dec
Balance returns the balance of an account.
func (EthAccount) EthAddress ¶
func (acc EthAccount) EthAddress() ethcmn.Address
EthAddress returns the account address ethereum format.
func (EthAccount) MarshalJSON ¶
func (acc EthAccount) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of an EthAccount.
func (EthAccount) MarshalYAML ¶
func (acc EthAccount) MarshalYAML() (interface{}, error)
MarshalYAML returns the YAML representation of an account.
func (*EthAccount) SetBalance ¶
func (acc *EthAccount) SetBalance(denom string, amt sdk.Dec)
SetBalance sets an account's balance of the given coin denomination.
CONTRACT: assumes the denomination is valid.
func (EthAccount) String ¶
func (acc EthAccount) String() string
String implements the fmt.Stringer interface
func (*EthAccount) UnmarshalJSON ¶
func (acc *EthAccount) UnmarshalJSON(bz []byte) error
UnmarshalJSON unmarshals raw JSON bytes into an EthAccount.