nativeminter

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: GPL-3.0, LGPL-3.0 Imports: 11 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
)

Variables

View Source
var (
	// Singleton StatefulPrecompiledContract for minting native assets by permissioned callers.
	ContractNativeMinterPrecompile contract.StatefulPrecompiledContract = createNativeMinterPrecompile()

	ErrCannotMint = errors.New("non-enabled cannot mint")
)
View Source
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000001")
View Source
var Module = modules.Module{
	ConfigKey:    ConfigKey,
	Address:      ContractAddress,
	Contract:     ContractNativeMinterPrecompile,
	Configurator: &configurator{},
}

Functions

func GetContractNativeMinterStatus

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

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

func PackMintInput

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

PackMintInput packs [address] and [amount] into the appropriate arguments for minting operation. Assumes that [amount] can be represented by 32 bytes.

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 UnpackMintInput

func UnpackMintInput(input []byte) (common.Address, *big.Int, error)

UnpackMintInput attempts to unpack [input] into the arguments to the mint precompile assumes that [input] does not include selector (omits first 4 bytes in PackMintInput)

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 StatefulPrecompileConfig 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

func (*Config) Verify

func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error

Jump to

Keyboard shortcuts

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