Documentation ¶
Index ¶
- Constants
- Variables
- func GetContractNativeMinterStatus(stateDB contract.StateDB, address common.Address) allowlist.Role
- func PackMintNativeCoin(address common.Address, amount *big.Int) ([]byte, error)
- func PackNativeCoinMintedEvent(sender common.Address, recipient common.Address, amount *big.Int) ([]common.Hash, []byte, error)
- func SetContractNativeMinterStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role)
- func UnpackMintNativeCoinInput(input []byte, useStrictMode bool) (common.Address, *big.Int, error)
- func UnpackNativeCoinMintedEventData(dataBytes []byte) (*big.Int, error)
- type Config
- type MintNativeCoinInput
Constants ¶
const ConfigKey = "contractNativeMinterConfig"
ConfigKey is the key used in json config files to specify this precompile config. must be unique across all precompiles.
const (
MintGasCost = 30_000
)
const ( // NativeCoinMintedEventGasCost is the gas cost of the NativeCoinMinted event. // It is the base gas cost + the gas cost of the topics (signature, sender, recipient) // and the gas cost of the non-indexed data (32 bytes for amount). NativeCoinMintedEventGasCost = contract.LogGas + contract.LogTopicGas*3 + contract.LogDataGas*common.HashLength )
Variables ¶
var ( // Singleton StatefulPrecompiledContract for minting native assets by permissioned callers. ContractNativeMinterPrecompile contract.StatefulPrecompiledContract = createNativeMinterPrecompile() ErrCannotMint = errors.New("non-enabled cannot mint") ErrInvalidLen = errors.New("invalid input length for minting") // NativeMinterRawABI contains the raw ABI of NativeMinter contract. //go:embed contract.abi NativeMinterRawABI string NativeMinterABI = contract.ParseABI(NativeMinterRawABI) )
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000001")
var Module = modules.Module{ ConfigKey: ConfigKey, Address: ContractAddress, Contract: ContractNativeMinterPrecompile, Configurator: &configurator{}, }
Module is the precompile module. It is used to register the precompile contract.
Functions ¶
func GetContractNativeMinterStatus ¶
GetContractNativeMinterStatus returns the role of [address] for the minter list.
func PackMintNativeCoin ¶
PackMintNativeCoin packs [address] and [amount] into the appropriate arguments for mintNativeCoin.
func PackNativeCoinMintedEvent ¶
func PackNativeCoinMintedEvent(sender common.Address, recipient common.Address, amount *big.Int) ([]common.Hash, []byte, error)
PackNativeCoinMintedEvent packs the event into the appropriate arguments for NativeCoinMinted. It returns topic hashes and the encoded non-indexed data.
func SetContractNativeMinterStatus ¶
func SetContractNativeMinterStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role)
SetContractNativeMinterStatus sets the permissions of [address] to [role] for the minter list. assumes [role] has already been verified as valid.
func UnpackMintNativeCoinInput ¶
UnpackMintNativeCoinInput attempts to unpack [input] as address and amount. assumes that [input] does not include selector (omits first 4 func signature bytes) if [useStrictMode] is true, it will return an error if the length of [input] is not [mintInputLen]
Types ¶
type Config ¶
type Config struct { allowlist.AllowListConfig precompileconfig.Upgrade InitialMint map[common.Address]*math.HexOrDecimal256 `json:"initialMint,omitempty"` // addresses to receive the initial mint mapped to the amount to mint }
Config implements the precompileconfig.Config interface while adding in the ContractNativeMinter specific precompile config.
func NewConfig ¶
func NewConfig(blockTimestamp *uint64, admins []common.Address, enableds []common.Address, managers []common.Address, initialMint map[common.Address]*math.HexOrDecimal256) *Config
NewConfig returns a config for a network upgrade at [blockTimestamp] that enables ContractNativeMinter with the given [admins], [enableds] and [managers] as members of the allowlist. Also mints balances according to [initialMint] when the upgrade activates.
func NewDisableConfig ¶
NewDisableConfig returns config for a network upgrade at [blockTimestamp] that disables ContractNativeMinter.
func (*Config) Equal ¶
func (c *Config) Equal(cfg precompileconfig.Config) bool
Equal returns true if [cfg] is a [*ContractNativeMinterConfig] and it has been configured identical to [c].
func (*Config) Key ¶
Key returns the key for the ContractNativeMinter precompileconfig. This should be the same key as used in the precompile module.
func (*Config) Verify ¶
func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error