builtInFunctions

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetadataPaused is the location of paused flag in the mec global meta data
	MetadataPaused = 1
	// MetadataLimitedTransfer is the location of limited transfer flag in the mec global meta data
	MetadataLimitedTransfer = 2
)
View Source
const (
	// MetadataFrozen is the location of frozen flag in the mec user meta data
	MetadataFrozen = 1
)

Variables

View Source
var ErrAccountNotPayable = errors.New("sending value to non payable contract")

ErrAccountNotPayable will be sent when trying to send money to a non-payable account

View Source
var ErrActionNotAllowed = errors.New("action is not allowed")

ErrActionNotAllowed signals that action is not allowed

View Source
var ErrAddressIsNotMECSystemSC = errors.New("destination is not system sc address")

ErrAddressIsNotMECSystemSC signals that destination is not a system sc address

View Source
var ErrBuiltInFunctionCalledWithValue = errors.New("built in function called with tx value is not allowed")

ErrBuiltInFunctionCalledWithValue signals that builtin function was called with value that is not allowed

View Source
var ErrCallerIsNotTheDNSAddress = errors.New("not a dns address")

ErrCallerIsNotTheDNSAddress signals that called address is not the DNS address

View Source
var ErrCannotWipeAccountNotFrozen = errors.New("cannot wipe because the account is not frozen for this mec token")

ErrCannotWipeAccountNotFrozen signals that account isn't frozen so the wipe is not possible

View Source
var ErrContainerKeyAlreadyExists = errors.New("provided key already exists in container")

ErrContainerKeyAlreadyExists signals that an element was already set in the container's map

View Source
var ErrEmptyFunctionName = errors.New("empty function name")

ErrEmptyFunctionName signals that an empty function name has been provided

View Source
var ErrHigherNonceInBlock = errors.New("higher nonce in block")

ErrHigherNonceInBlock signals that a block with higher nonce than permitted has been provided

View Source
var ErrHigherRoundInBlock = errors.New("higher round in block")

ErrHigherRoundInBlock signals that a block with higher round than permitted has been provided

View Source
var ErrInsufficientFunds = errors.New("insufficient funds")

ErrInsufficientFunds signals the funds are insufficient for the move balance operation but the transaction fee is covered by the current balance

View Source
var ErrInsufficientQuantityMEC = errors.New("insufficient quantity")

ErrInsufficientQuantityMEC signals the funds are insufficient for the MEC transfer

View Source
var ErrInvalidAddressLength = errors.New("invalid address length")

ErrInvalidAddressLength signals that address length is invalid

View Source
var ErrInvalidArguments = errors.New("invalid arguments to process built-in function")

ErrInvalidArguments signals that invalid arguments were given to process built-in function

View Source
var ErrInvalidContainerKey = errors.New("element does not exist in container")

ErrInvalidContainerKey signals that an element does not exist in the container's map

View Source
var ErrInvalidNFTQuantity = errors.New("invalid NFT quantity")

ErrInvalidNFTQuantity signals that invalid NFT quantity was provided

View Source
var ErrInvalidPeerAccount = errors.New("invalid peer account")

ErrInvalidPeerAccount signals that a peer account is invalid

View Source
var ErrInvalidRcvAddr = errors.New("invalid receiver address")

ErrInvalidRcvAddr signals that an invalid receiver address was provided

View Source
var ErrInvalidShardCacherIdentifier = errors.New("invalid identifier for shard cacher")

ErrInvalidShardCacherIdentifier signals an invalid identifier

View Source
var ErrInvalidSndAddr = errors.New("invalid sender address")

ErrInvalidSndAddr signals that an invalid sender address was provided

View Source
var ErrMECIsFrozenForAccount = errors.New("account is frozen for this mec token")

ErrMECIsFrozenForAccount signals that account is frozen for given mec token

View Source
var ErrMECTokenIsPaused = errors.New("mec token is paused")

ErrMECTokenIsPaused signals that mec token is paused

View Source
var ErrNFTDoesNotHaveMetadata = errors.New("NFT does not have metadata")

ErrNFTDoesNotHaveMetadata signals that NFT does not have metadata

View Source
var ErrNFTTokenDoesNotExist = errors.New("NFT token does not exist")

ErrNFTTokenDoesNotExist signals that NFT token does not exist

View Source
var ErrNegativeValue = errors.New("negative value")

ErrNegativeValue signals that a negative value has been detected and it is not allowed

View Source
var ErrNewNFTDataOnSenderAddress = errors.New("new NFT data on sender")

ErrNewNFTDataOnSenderAddress signals that a new NFT data was found on the sender address

View Source
var ErrNilAccountsAdapter = errors.New("nil AccountsAdapter")

ErrNilAccountsAdapter defines the error when trying to use a nil AccountsAddapter

View Source
var ErrNilBadTxHandler = errors.New("nil bad tx handler")

ErrNilBadTxHandler signals that bad tx handler is nil

View Source
var ErrNilBalanceComputationHandler = errors.New("nil balance computation handler")

ErrNilBalanceComputationHandler signals that a nil balance computation handler has been provided

View Source
var ErrNilBlockHeader = errors.New("nil block header")

ErrNilBlockHeader signals that an operation has been attempted to or with a nil block header

View Source
var ErrNilBlockTracker = errors.New("nil block tracker")

ErrNilBlockTracker signals that a nil block tracker was provided

View Source
var ErrNilContainerElement = errors.New("element cannot be nil")

ErrNilContainerElement signals when trying to add a nil element in the container

View Source
var ErrNilDataToProcess = errors.New("nil data to process")

ErrNilDataToProcess signals that nil data was provided

View Source
var ErrNilDnsAddresses = errors.New("nil dns addresses map")

ErrNilDnsAddresses signals that nil dns addresses map was provided

View Source
var ErrNilEpochHandler = errors.New("nil epoch handler")

ErrNilEpochHandler signals that a nil epoch handler was provided

View Source
var ErrNilFallbackHeaderValidator = errors.New("nil fallback header validator")

ErrNilFallbackHeaderValidator signals that a nil fallback header validator has been provided

View Source
var ErrNilForkDetector = errors.New("nil fork detector")

ErrNilForkDetector signals that the fork detector is nil

View Source
var ErrNilGlobalSettingsHandler = errors.New("nil pause handler")

ErrNilGlobalSettingsHandler signals that nil pause handler has been provided

View Source
var ErrNilHdrValidator = errors.New("nil header validator")

ErrNilHdrValidator signals that a nil header validator has been provided

View Source
var ErrNilHeaderIntegrityVerifier = errors.New("nil header integrity verifier")

ErrNilHeaderIntegrityVerifier signals that a nil header integrity verifier has been provided

View Source
var ErrNilMECNFTStorageHandler = errors.New("nil mec nft storage handler")

ErrNilMECNFTStorageHandler signals that a nil nft storage handler has been provided

View Source
var ErrNilMarshalizer = errors.New("nil Marshalizer")

ErrNilMarshalizer signals that an operation has been attempted to or with a nil Marshalizer implementation

View Source
var ErrNilOrEmptyList = errors.New("nil or empty provided list")

ErrNilOrEmptyList signals that a nil or empty list was provided

View Source
var ErrNilPayableHandler = errors.New("nil payableHandler was provided")

ErrNilPayableHandler signals that nil payableHandler was provided

View Source
var ErrNilPoolsHolder = errors.New("nil pools holder")

ErrNilPoolsHolder signals that an operation has been attempted to or with a nil pools holder object

View Source
var ErrNilPreProcessor = errors.New("preprocessor is nil")

ErrNilPreProcessor signals that preprocessors is nil

View Source
var ErrNilRolesHandler = errors.New("nil roles handler")

ErrNilRolesHandler signals that nil roles handler has been provided

View Source
var ErrNilSCDestAccount = errors.New("nil destination SC account")

ErrNilSCDestAccount signals that destination account is nil

View Source
var ErrNilScAddress = errors.New("nil SC address")

ErrNilScAddress signals that a nil smart contract address has been provided

View Source
var ErrNilShardCoordinator = errors.New("nil shard coordinator")

ErrNilShardCoordinator signals that an operation has been attempted to or with a nil shard coordinator

View Source
var ErrNilShardedDataCacherNotifier = errors.New("nil sharded data cacher notifier")

ErrNilShardedDataCacherNotifier signals that a nil sharded data cacher notifier has been provided

View Source
var ErrNilSingleSigner = errors.New("nil single signer")

ErrNilSingleSigner signals that a nil single signer is used

View Source
var ErrNilTransactionHandler = errors.New("nil transaction handler")

ErrNilTransactionHandler signals that a nil transaction handler has been provided

View Source
var ErrNilTransactionVersionChecker = errors.New("nil transaction version checker")

ErrNilTransactionVersionChecker signals that provided transaction version checker is nil

View Source
var ErrNilTxProcessor = errors.New("nil transactions processor")

ErrNilTxProcessor signals that a nil transactions processor was used

View Source
var ErrNilTxValidator = errors.New("nil transaction validator")

ErrNilTxValidator signals that a nil tx validator has been provided

View Source
var ErrNilUserAccount = errors.New("nil user account")

ErrNilUserAccount signals that nil user account was provided

View Source
var ErrNilValue = errors.New("nil value")

ErrNilValue signals the value is nil

View Source
var ErrNilVmInput = errors.New("nil vm input")

ErrNilVmInput signals that provided vm input is nil

View Source
var ErrNotEnoughGas = errors.New("not enough gas was sent in the transaction")

ErrNotEnoughGas signals that not enough gas has been provided

View Source
var ErrNotEpochStartBlock = errors.New("not epoch start block")

ErrNotEpochStartBlock signals that block is not of type epoch start

View Source
var ErrOnlyFungibleTokensHaveBalanceTransfer = errors.New("only fungible tokens have balance transfer")

ErrOnlyFungibleTokensHaveBalanceTransfer signals that only fungible tokens have balance transfer

View Source
var ErrOnlySystemAccountAccepted = errors.New("only system account is accepted")

ErrOnlySystemAccountAccepted signals that only system account is accepted

View Source
var ErrOperationNotPermitted = errors.New("operation in account not permitted")

ErrOperationNotPermitted signals that operation is not permitted

View Source
var ErrUserNameChangeIsDisabled = errors.New("user name change is disabled")

ErrUserNameChangeIsDisabled signals the user name change is not allowed

View Source
var ErrWrongTypeAssertion = errors.New("wrong type assertion")

ErrWrongTypeAssertion signals that an type assertion failed

View Source
var ErrWrongTypeInContainer = errors.New("wrong type of object inside container")

ErrWrongTypeInContainer signals that a wrong type of object was found in container

Functions

func NewBuiltInFunctionContainer

func NewBuiltInFunctionContainer() *functionContainer

NewBuiltInFunctionContainer will create a new instance of a container

func NewBuiltInFunctionsCreator

func NewBuiltInFunctionsCreator(args ArgsCreateBuiltInFunctionContainer) (*builtInFuncCreator, error)

NewBuiltInFunctionsCreator creates a component which will instantiate the built in functions contracts

func NewChangeOwnerAddressFunc

func NewChangeOwnerAddressFunc(gasCost uint64) *changeOwnerAddress

NewChangeOwnerAddressFunc create a new change owner built in function

func NewClaimDeveloperRewardsFunc

func NewClaimDeveloperRewardsFunc(gasCost uint64) *claimDeveloperRewards

NewClaimDeveloperRewardsFunc returns a new developer rewards implementation

func NewMECBurnFunc

func NewMECBurnFunc(
	funcGasCost uint64,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	disableEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecBurn, error)

NewMECBurnFunc returns the mec burn built-in function component

func NewMECDataStorage

func NewMECDataStorage(args ArgsNewMECDataStorage) (*mecDataStorage, error)

NewMECDataStorage creates a new mec data storage handler

func NewMECFreezeWipeFunc

func NewMECFreezeWipeFunc(
	marshalizer vmcommon.Marshalizer,
	freeze bool,
	wipe bool,
) (*mecFreezeWipe, error)

NewMECFreezeWipeFunc returns the mec freeze/un-freeze/wipe built-in function component

func NewMECGlobalSettingsFunc

func NewMECGlobalSettingsFunc(
	accounts vmcommon.AccountsAdapter,
	set bool,
	function string,
	activationEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecGlobalSettings, error)

NewMECGlobalSettingsFunc returns the mec pause/un-pause built-in function component

func NewMECLocalBurnFunc

func NewMECLocalBurnFunc(
	funcGasCost uint64,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
) (*mecLocalBurn, error)

NewMECLocalBurnFunc returns the mec local burn built-in function component

func NewMECLocalMintFunc

func NewMECLocalMintFunc(
	funcGasCost uint64,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
) (*mecLocalMint, error)

NewMECLocalMintFunc returns the mec local mint built-in function component

func NewMECNFTAddQuantityFunc

func NewMECNFTAddQuantityFunc(
	funcGasCost uint64,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
	valueLengthCheckEnableEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecNFTAddQuantity, error)

NewMECNFTAddQuantityFunc returns the mec NFT add quantity built-in function component

func NewMECNFTAddUriFunc

func NewMECNFTAddUriFunc(
	funcGasCost uint64,
	gasConfig vmcommon.BaseOperationCost,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
	activationEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecNFTAddUri, error)

NewMECNFTAddUriFunc returns the mec NFT add URI built-in function component

func NewMECNFTBurnFunc

func NewMECNFTBurnFunc(
	funcGasCost uint64,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
) (*mecNFTBurn, error)

NewMECNFTBurnFunc returns the mec NFT burn built-in function component

func NewMECNFTCreateFunc

func NewMECNFTCreateFunc(
	funcGasCost uint64,
	gasConfig vmcommon.BaseOperationCost,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
	accounts vmcommon.AccountsAdapter,
	valueLengthCheckEnableEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecNFTCreate, error)

NewMECNFTCreateFunc returns the mec NFT create built-in function component

func NewMECNFTCreateRoleTransfer

func NewMECNFTCreateRoleTransfer(
	marshalizer vmcommon.Marshalizer,
	accounts vmcommon.AccountsAdapter,
	shardCoordinator vmcommon.Coordinator,
) (*mecNFTCreateRoleTransfer, error)

NewMECNFTCreateRoleTransfer returns the mec NFT create role transfer built-in function component

func NewMECNFTMultiTransferFunc

func NewMECNFTMultiTransferFunc(
	funcGasCost uint64,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	accounts vmcommon.AccountsAdapter,
	shardCoordinator vmcommon.Coordinator,
	gasConfig vmcommon.BaseOperationCost,
	activationEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
	roleHandler vmcommon.MECRoleHandler,
	transferToMetaEnableEpoch uint32,
	checkCorrectTokenIDEnableEpoch uint32,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
) (*mecNFTMultiTransfer, error)

NewMECNFTMultiTransferFunc returns the mec NFT multi transfer built-in function component

func NewMECNFTTransferFunc

func NewMECNFTTransferFunc(
	funcGasCost uint64,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	accounts vmcommon.AccountsAdapter,
	shardCoordinator vmcommon.Coordinator,
	gasConfig vmcommon.BaseOperationCost,
	rolesHandler vmcommon.MECRoleHandler,
	transferToMetaEnableEpoch uint32,
	checkZeroTransferEnableEpoch uint32,
	checkCorrectTokenIDEnableEpoch uint32,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
	epochNotifier vmcommon.EpochNotifier,
) (*mecNFTTransfer, error)

NewMECNFTTransferFunc returns the mec NFT transfer built-in function component

func NewMECNFTUpdateAttributesFunc

func NewMECNFTUpdateAttributesFunc(
	funcGasCost uint64,
	gasConfig vmcommon.BaseOperationCost,
	mecStorageHandler vmcommon.MECNFTStorageHandler,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	rolesHandler vmcommon.MECRoleHandler,
	activationEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecNFTupdate, error)

NewMECNFTAddUriFunc returns the mec NFT update attribute built-in function component

func NewMECRolesFunc

func NewMECRolesFunc(
	marshalizer vmcommon.Marshalizer,
	set bool,
) (*mecRoles, error)

NewMECRolesFunc returns the mec change roles built-in function component

func NewMECTransferFunc

func NewMECTransferFunc(
	funcGasCost uint64,
	marshalizer vmcommon.Marshalizer,
	globalSettingsHandler vmcommon.MECGlobalSettingsHandler,
	shardCoordinator vmcommon.Coordinator,
	rolesHandler vmcommon.MECRoleHandler,
	transferToMetaEnableEpoch uint32,
	checkCorrectTokenIDEnableEpoch uint32,
	epochNotifier vmcommon.EpochNotifier,
) (*mecTransfer, error)

NewMECTransferFunc returns the mec transfer built-in function component

func NewSaveKeyValueStorageFunc

func NewSaveKeyValueStorageFunc(
	gasConfig vmcommon.BaseOperationCost,
	funcGasCost uint64,
) (*saveKeyValueStorage, error)

NewSaveKeyValueStorageFunc returns the save key-value storage built in function

func NewSaveUserNameFunc

func NewSaveUserNameFunc(
	gasCost uint64,
	mapDnsAddresses map[string]struct{},
	enableChange bool,
) (*saveUserName, error)

NewSaveUserNameFunc returns a username built in function implementation

func SetPayableHandler

func SetPayableHandler(container vmcommon.BuiltInFunctionContainer, payableHandler vmcommon.PayableHandler) error

SetPayableHandler sets the payable interface to the needed functions

Types

type ArgsCreateBuiltInFunctionContainer

type ArgsCreateBuiltInFunctionContainer struct {
	GasMap                             map[string]map[string]uint64
	MapDNSAddresses                    map[string]struct{}
	EnableUserNameChange               bool
	Marshalizer                        vmcommon.Marshalizer
	Accounts                           vmcommon.AccountsAdapter
	ShardCoordinator                   vmcommon.Coordinator
	EpochNotifier                      vmcommon.EpochNotifier
	MECNFTImprovementV1ActivationEpoch uint32
	MECTransferRoleEnableEpoch         uint32
	GlobalMintBurnDisableEpoch         uint32
	MECTransferToMetaEnableEpoch       uint32
	NFTCreateMultiShardEnableEpoch     uint32
	SaveNFTToSystemAccountEnableEpoch  uint32
	CheckCorrectTokenIDEnableEpoch     uint32
}

ArgsCreateBuiltInFunctionContainer defines the input arguments to create built in functions container

type ArgsNewMECDataStorage

type ArgsNewMECDataStorage struct {
	Accounts                vmcommon.AccountsAdapter
	GlobalSettingsHandler   vmcommon.MECGlobalSettingsHandler
	Marshalizer             vmcommon.Marshalizer
	SaveToSystemEnableEpoch uint32
	EpochNotifier           vmcommon.EpochNotifier
	ShardCoordinator        vmcommon.Coordinator
}

ArgsNewMECDataStorage defines the argument list for new mec data storage handler

type MECGlobalMetadata

type MECGlobalMetadata struct {
	Paused          bool
	LimitedTransfer bool
}

MECGlobalMetadata represents mec global metadata saved on system account

func MECGlobalMetadataFromBytes

func MECGlobalMetadataFromBytes(bytes []byte) MECGlobalMetadata

MECGlobalMetadataFromBytes creates a metadata object from bytes

func (*MECGlobalMetadata) ToBytes

func (metadata *MECGlobalMetadata) ToBytes() []byte

ToBytes converts the metadata to bytes

type MECUserMetadata

type MECUserMetadata struct {
	Frozen bool
}

MECUserMetadata represents mec user metadata saved on every account

func MECUserMetadataFromBytes

func MECUserMetadataFromBytes(bytes []byte) MECUserMetadata

MECUserMetadataFromBytes creates a metadata object from bytes

func (*MECUserMetadata) ToBytes

func (metadata *MECUserMetadata) ToBytes() []byte

ToBytes converts the metadata to bytes

Jump to

Keyboard shortcuts

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