Documentation ¶
Index ¶
- Constants
- Variables
- func AccountNonce(state kv.KVStoreReader, callerAgentID isc.AgentID, chainID isc.ChainID) uint64
- func AdjustAccountBaseTokens(v isc.SchemaVersion, state kv.KVStore, account isc.AgentID, adjustment int64, ...)
- func AgentIDFromKey(key kv.Key, chainID isc.ChainID) (isc.AgentID, error)
- func AllAccountsAsDict(state kv.KVStoreReader) dict.Dict
- func AllAccountsMapR(state kv.KVStoreReader) *collections.ImmutableMap
- func AllFoundriesMap(state kv.KVStore) *collections.Map
- func BaseTokensKey(accountKey kv.Key) kv.Key
- func CommonAccount() isc.AgentID
- func CreditNFTToAccount(state kv.KVStore, agentID isc.AgentID, nftOutput *iotago.NFTOutput, ...)
- func CreditToAccount(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, assets *isc.Assets, ...)
- func CreditToAccountFullDecimals(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, amount *big.Int, ...)
- func DebitFromAccount(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, assets *isc.Assets, ...)
- func DebitFromAccountFullDecimals(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, amount *big.Int, ...)
- func DebitNFTFromAccount(state kv.KVStore, agentID isc.AgentID, nftID iotago.NFTID, chainID isc.ChainID)
- func DeleteFoundryOutput(state kv.KVStore, sn uint32)
- func DeleteNFTOutput(state kv.KVStore, nftID iotago.NFTID)
- func DeleteNativeTokenOutput(state kv.KVStore, nativeTokenID iotago.NativeTokenID)
- func GetAccountFungibleTokens(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, ...) *isc.Assets
- func GetAccountNFTs(state kv.KVStoreReader, agentID isc.AgentID) []iotago.NFTID
- func GetBaseTokensBalance(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, ...) uint64
- func GetBaseTokensBalanceFullDecimals(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, ...) *big.Int
- func GetFoundryOutput(state kv.KVStoreReader, sn uint32, chainID isc.ChainID) (*iotago.FoundryOutput, iotago.OutputID)
- func GetNFTData(state kv.KVStoreReader, nftID iotago.NFTID) *isc.NFT
- func GetNFTOutput(state kv.KVStoreReader, nftID iotago.NFTID) (*iotago.NFTOutput, iotago.OutputID)
- func GetNativeTokenBalance(state kv.KVStoreReader, agentID isc.AgentID, ...) *big.Int
- func GetNativeTokenBalanceTotal(state kv.KVStoreReader, nativeTokenID iotago.NativeTokenID) *big.Int
- func GetNativeTokenOutput(state kv.KVStoreReader, nativeTokenID iotago.NativeTokenID, ...) (*iotago.BasicOutput, iotago.OutputID)
- func GetNativeTokens(state kv.KVStoreReader, agentID isc.AgentID, chainID isc.ChainID) iotago.NativeTokens
- func GetTotalL2FungibleTokens(v isc.SchemaVersion, state kv.KVStoreReader) *isc.Assets
- func GetTotalL2NFTs(state kv.KVStoreReader) []iotago.NFTID
- func HasEnoughForAllowance(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, ...) bool
- func IncrementNonce(state kv.KVStore, callerAgentID isc.AgentID, chainID isc.ChainID)
- func MoveBetweenAccounts(v isc.SchemaVersion, state kv.KVStore, fromAgentID, toAgentID isc.AgentID, ...) error
- func MoveFoundryBetweenAccounts(state kv.KVStore, agentIDFrom, agentIDTo isc.AgentID, sn uint32)
- func MustMoveBetweenAccounts(v isc.SchemaVersion, state kv.KVStore, fromAgentID, toAgentID isc.AgentID, ...)
- func NFTOutputMap(state kv.KVStore) *collections.Map
- func NativeTokenOutputMap(state kv.KVStore) *collections.Map
- func NativeTokensMapR(state kv.KVStoreReader, accountKey kv.Key) *collections.ImmutableMap
- func SaveFoundryOutput(state kv.KVStore, f *iotago.FoundryOutput, outputIndex uint16)
- func SaveMintedNFTOutput(state kv.KVStore, positionInMintedList, outputIndex uint16)
- func SaveNFTOutput(state kv.KVStore, out *iotago.NFTOutput, outputIndex uint16)
- func SaveNativeTokenOutput(state kv.KVStore, out *iotago.BasicOutput, outputIndex uint16)
- func SetInitialState(v isc.SchemaVersion, state kv.KVStore, baseTokensOnAnchor uint64)
- func UpdateLatestOutputID(state kv.KVStore, anchorTxID iotago.TransactionID, blockIndex uint32) []iotago.NFTID
- type GetBaseTokensFullDecimalsFn
- type NFTOutputRec
- type StateAccess
Constants ¶
const ( ParamAccountNonce = "n" ParamAgentID = "a" ParamBalance = "B" ParamCollectionID = "C" ParamDestroyTokens = "y" ParamForceMinimumBaseTokens = "f" ParamFoundryOutputBin = "b" ParamFoundrySN = "s" ParamTokenName = "tn" ParamTokenTickerSymbol = "ts" ParamTokenDecimals = "td" ParamGasReserve = "g" ParamNFTAmount = "A" ParamNFTData = "e" ParamNFTID = "z" ParamNFTIDs = "i" ParamNFTImmutableData = "I" ParamNFTWithdrawOnMint = "w" ParamMintID = "D" ParamNativeTokenID = "N" ParamSupplyDeltaAbs = "d" ParamTokenScheme = "t" )
request parameters
const ( // prefixBaseTokens | <accountID> stores a map of <nativeTokenID> => big.Int // Covered in: TestFoundries PrefixNativeTokens = "t" // L2TotalsAccount is the special <accountID> storing the total fungible tokens // controlled by the chain // Covered in: TestFoundries L2TotalsAccount = "*" // PrefixNFTs | <agentID> stores a map of <NFTID> => true // Covered in: TestDepositNFTWithMinStorageDeposit PrefixNFTs = "n" // PrefixNFTsByCollection | <agentID> | <collectionID> stores a map of <nftID> => true // Covered in: TestNFTMint // Covered in: TestDepositNFTWithMinStorageDeposit PrefixNFTsByCollection = "c" // PrefixFoundries + <agentID> stores a map of <foundrySN> (uint32) => true // Covered in: TestFoundries PrefixFoundries = "f" )
Variables ¶
var ( // Funcs FuncDeposit = coreutil.Func("deposit") // Kept for compatibility reasons FuncFoundryCreateNew = coreutil.Func("foundryCreateNew") // FuncNativeTokenCreate = coreutil.Func("nativeTokenCreate") FuncNativeTokenModifySupply = coreutil.Func("nativeTokenModifySupply") FuncNativeTokenDestroy = coreutil.Func("nativeTokenDestroy") FuncMintNFT = coreutil.Func("mintNFT") FuncTransferAccountToChain = coreutil.Func("transferAccountToChain") FuncTransferAllowanceTo = coreutil.Func("transferAllowanceTo") FuncWithdraw = coreutil.Func("withdraw") // Views ViewAccountFoundries = coreutil.ViewFunc("accountFoundries") ViewAccountNFTAmount = coreutil.ViewFunc("accountNFTAmount") ViewAccountNFTAmountInCollection = coreutil.ViewFunc("accountNFTAmountInCollection") ViewAccountNFTs = coreutil.ViewFunc("accountNFTs") ViewAccountNFTsInCollection = coreutil.ViewFunc("accountNFTsInCollection") ViewNFTIDbyMintID = coreutil.ViewFunc("NFTIDbyMintID") ViewAccounts = coreutil.ViewFunc("accounts") ViewBalance = coreutil.ViewFunc("balance") ViewBalanceBaseToken = coreutil.ViewFunc("balanceBaseToken") ViewBalanceBaseTokenEVM = coreutil.ViewFunc("balanceBaseTokenEVM") ViewBalanceNativeToken = coreutil.ViewFunc("balanceNativeToken") ViewNativeToken = coreutil.ViewFunc("nativeToken") ViewGetAccountNonce = coreutil.ViewFunc("getAccountNonce") ViewGetNativeTokenIDRegistry = coreutil.ViewFunc("getNativeTokenIDRegistry") ViewNFTData = coreutil.ViewFunc("nftData") ViewTotalAssets = coreutil.ViewFunc("totalAssets") )
var ( ErrNotEnoughFunds = coreerrors.Register("not enough funds").Create() ErrNotEnoughBaseTokensForStorageDeposit = coreerrors.Register("not enough base tokens for storage deposit").Create() ErrNotEnoughAllowance = coreerrors.Register("not enough allowance").Create() ErrBadAmount = coreerrors.Register("bad native asset amount").Create() ErrRepeatingFoundrySerialNumber = coreerrors.Register("repeating serial number of the foundry").Create() ErrFoundryNotFound = coreerrors.Register("foundry not found").Create() ErrOverflow = coreerrors.Register("overflow in token arithmetics").Create() ErrTooManyNFTsInAllowance = coreerrors.Register("expected at most 1 NFT in allowance").Create() ErrNFTIDNotFound = coreerrors.Register("NFTID not found").Create() ErrImmutableMetadataInvalid = coreerrors.Register("IRC27 metadata is invalid: '%s'") )
var Contract = coreutil.NewContract(coreutil.CoreContractAccounts)
var Processor = Contract.Processor(nil, FuncDeposit.WithHandler(deposit), FuncMintNFT.WithHandler(mintNFT), FuncTransferAccountToChain.WithHandler(transferAccountToChain), FuncTransferAllowanceTo.WithHandler(transferAllowanceTo), FuncWithdraw.WithHandler(withdraw), FuncFoundryCreateNew.WithHandler(foundryCreateNew), FuncNativeTokenCreate.WithHandler(nativeTokenCreate), FuncNativeTokenModifySupply.WithHandler(nativeTokenModifySupply), FuncNativeTokenDestroy.WithHandler(nativeTokenDestroy), ViewAccountNFTs.WithHandler(viewAccountNFTs), ViewAccountNFTAmount.WithHandler(viewAccountNFTAmount), ViewAccountNFTsInCollection.WithHandler(viewAccountNFTsInCollection), ViewAccountNFTAmountInCollection.WithHandler(viewAccountNFTAmountInCollection), ViewNFTIDbyMintID.WithHandler(viewNFTIDbyMintID), ViewAccountFoundries.WithHandler(viewAccountFoundries), ViewAccounts.WithHandler(viewAccounts), ViewBalance.WithHandler(viewBalance), ViewBalanceBaseToken.WithHandler(viewBalanceBaseToken), ViewBalanceBaseTokenEVM.WithHandler(viewBalanceBaseTokenEVM), ViewBalanceNativeToken.WithHandler(viewBalanceNativeToken), ViewNativeToken.WithHandler(viewFoundryOutput), ViewGetAccountNonce.WithHandler(viewGetAccountNonce), ViewGetNativeTokenIDRegistry.WithHandler(viewGetNativeTokenIDRegistry), ViewNFTData.WithHandler(viewNFTData), ViewTotalAssets.WithHandler(viewTotalAssets), )
Functions ¶
func AccountNonce ¶ added in v1.0.3
Nonce returns the "total request count" for an account (it's the AccountNonce that is expected in the next request)
func AdjustAccountBaseTokens ¶ added in v0.3.0
func AgentIDFromKey ¶ added in v1.0.3
converts an account key from the accounts contract (shortform without chainID) to an AgentID
func AllAccountsAsDict ¶ added in v1.0.3
func AllAccountsAsDict(state kv.KVStoreReader) dict.Dict
func AllAccountsMapR ¶ added in v1.0.3
func AllAccountsMapR(state kv.KVStoreReader) *collections.ImmutableMap
func AllFoundriesMap ¶ added in v1.0.3
func AllFoundriesMap(state kv.KVStore) *collections.Map
func CommonAccount ¶ added in v1.0.3
func CreditNFTToAccount ¶ added in v0.3.0
func CreditNFTToAccount(state kv.KVStore, agentID isc.AgentID, nftOutput *iotago.NFTOutput, chainID isc.ChainID)
CreditNFTToAccount credits an NFT to the on chain ledger
func CreditToAccount ¶
func CreditToAccount(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, assets *isc.Assets, chainID isc.ChainID)
CreditToAccount brings new funds to the on chain ledger NOTE: this function does not take NFTs into account
func CreditToAccountFullDecimals ¶ added in v1.0.3
func DebitFromAccount ¶
func DebitFromAccount(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, assets *isc.Assets, chainID isc.ChainID)
DebitFromAccount takes out assets balance the on chain ledger. If not enough it panics NOTE: this function does not take NFTs into account
func DebitFromAccountFullDecimals ¶ added in v1.0.3
func DebitFromAccountFullDecimals(v isc.SchemaVersion, state kv.KVStore, agentID isc.AgentID, amount *big.Int, chainID isc.ChainID)
DebitFromAccountFullDecimals removes the amount from the chain ledger. If not enough it panics
func DebitNFTFromAccount ¶ added in v0.3.0
func DebitNFTFromAccount(state kv.KVStore, agentID isc.AgentID, nftID iotago.NFTID, chainID isc.ChainID)
DebitNFTFromAccount removes an NFT from an account. If the account does not own the nft, it panics.
func DeleteFoundryOutput ¶ added in v0.3.0
DeleteFoundryOutput deletes foundry output from the map of all foundries
func DeleteNativeTokenOutput ¶ added in v0.3.0
func DeleteNativeTokenOutput(state kv.KVStore, nativeTokenID iotago.NativeTokenID)
func GetAccountFungibleTokens ¶ added in v1.0.3
func GetAccountFungibleTokens(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, chainID isc.ChainID) *isc.Assets
GetAccountFungibleTokens returns all fungible tokens belonging to the agentID on the state
func GetAccountNFTs ¶ added in v0.3.0
GetAccountNFTs returns all NFTs belonging to the agentID on the state
func GetBaseTokensBalance ¶ added in v0.3.0
func GetBaseTokensBalance(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, chainID isc.ChainID) uint64
func GetBaseTokensBalanceFullDecimals ¶ added in v1.0.3
func GetBaseTokensBalanceFullDecimals(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, chainID isc.ChainID) *big.Int
func GetFoundryOutput ¶ added in v0.3.0
func GetFoundryOutput(state kv.KVStoreReader, sn uint32, chainID isc.ChainID) (*iotago.FoundryOutput, iotago.OutputID)
GetFoundryOutput returns foundry output, its block number and output index
func GetNFTData ¶ added in v0.3.0
func GetNFTOutput ¶ added in v0.3.0
func GetNativeTokenBalance ¶ added in v0.3.0
func GetNativeTokenBalance(state kv.KVStoreReader, agentID isc.AgentID, nativeTokenID iotago.NativeTokenID, chainID isc.ChainID) *big.Int
func GetNativeTokenBalanceTotal ¶ added in v0.3.0
func GetNativeTokenBalanceTotal(state kv.KVStoreReader, nativeTokenID iotago.NativeTokenID) *big.Int
func GetNativeTokenOutput ¶ added in v0.3.0
func GetNativeTokenOutput(state kv.KVStoreReader, nativeTokenID iotago.NativeTokenID, chainID isc.ChainID) (*iotago.BasicOutput, iotago.OutputID)
func GetNativeTokens ¶ added in v1.0.3
func GetNativeTokens(state kv.KVStoreReader, agentID isc.AgentID, chainID isc.ChainID) iotago.NativeTokens
func GetTotalL2FungibleTokens ¶ added in v1.0.3
func GetTotalL2FungibleTokens(v isc.SchemaVersion, state kv.KVStoreReader) *isc.Assets
func GetTotalL2NFTs ¶ added in v0.3.0
func GetTotalL2NFTs(state kv.KVStoreReader) []iotago.NFTID
func HasEnoughForAllowance ¶ added in v0.3.0
func HasEnoughForAllowance(v isc.SchemaVersion, state kv.KVStoreReader, agentID isc.AgentID, allowance *isc.Assets, chainID isc.ChainID) bool
HasEnoughForAllowance checks whether an account has enough balance to cover for the allowance
func IncrementNonce ¶ added in v1.0.3
func MoveBetweenAccounts ¶
func MoveBetweenAccounts(v isc.SchemaVersion, state kv.KVStore, fromAgentID, toAgentID isc.AgentID, assets *isc.Assets, chainID isc.ChainID) error
MoveBetweenAccounts moves assets between on-chain accounts
func MoveFoundryBetweenAccounts ¶ added in v0.3.0
MoveFoundryBetweenAccounts changes ownership of the foundry
func MustMoveBetweenAccounts ¶ added in v0.3.0
func NFTOutputMap ¶ added in v1.0.3
func NFTOutputMap(state kv.KVStore) *collections.Map
func NativeTokenOutputMap ¶ added in v1.0.3
func NativeTokenOutputMap(state kv.KVStore) *collections.Map
func NativeTokensMapR ¶ added in v1.0.3
func NativeTokensMapR(state kv.KVStoreReader, accountKey kv.Key) *collections.ImmutableMap
func SaveFoundryOutput ¶ added in v0.3.0
func SaveFoundryOutput(state kv.KVStore, f *iotago.FoundryOutput, outputIndex uint16)
SaveFoundryOutput stores foundry output into the map of all foundry outputs (compressed form)
func SaveMintedNFTOutput ¶ added in v1.0.3
func SaveNFTOutput ¶ added in v0.3.0
func SaveNativeTokenOutput ¶ added in v0.3.0
func SaveNativeTokenOutput(state kv.KVStore, out *iotago.BasicOutput, outputIndex uint16)
SaveNativeTokenOutput map nativeTokenID -> foundryRec
func SetInitialState ¶ added in v1.0.3
func SetInitialState(v isc.SchemaVersion, state kv.KVStore, baseTokensOnAnchor uint64)
this expects the origin amount minus SD
func UpdateLatestOutputID ¶ added in v1.0.3
Types ¶
type GetBaseTokensFullDecimalsFn ¶ added in v1.0.3
func GetBaseTokensFullDecimals ¶ added in v1.0.3
func GetBaseTokensFullDecimals(v isc.SchemaVersion) GetBaseTokensFullDecimalsFn
type NFTOutputRec ¶ added in v0.3.0
func (*NFTOutputRec) Bytes ¶ added in v0.3.0
func (rec *NFTOutputRec) Bytes() []byte
func (*NFTOutputRec) String ¶ added in v0.3.0
func (rec *NFTOutputRec) String() string
type StateAccess ¶ added in v1.0.3
type StateAccess struct {
// contains filtered or unexported fields
}
func NewStateAccess ¶ added in v1.0.3
func NewStateAccess(store kv.KVStoreReader) *StateAccess