nativeminter

package
v0.6.3-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: GPL-3.0, LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigKey = "contractNativeMinterConfig"

ConfigKey is the key used in json config files to specify this precompile config. must be unique across all precompiles.

View Source
const (
	MintGasCost = 30_000
)
View Source
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

View Source
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)
)
View Source
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000001")
View Source
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

func GetContractNativeMinterStatus(stateDB contract.StateDB, address common.Address) allowlist.Role

GetContractNativeMinterStatus returns the role of [address] for the minter list.

func PackMintNativeCoin

func PackMintNativeCoin(address common.Address, amount *big.Int) ([]byte, error)

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

func UnpackMintNativeCoinInput(input []byte, useStrictMode bool) (common.Address, *big.Int, error)

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]

func UnpackNativeCoinMintedEventData

func UnpackNativeCoinMintedEventData(dataBytes []byte) (*big.Int, error)

UnpackNativeCoinMintedEventData attempts to unpack non-indexed [dataBytes].

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

func NewDisableConfig(blockTimestamp *uint64) *Config

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

func (*Config) Key() string

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

type MintNativeCoinInput

type MintNativeCoinInput struct {
	Addr   common.Address
	Amount *big.Int
}

Jump to

Keyboard shortcuts

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