Documentation ¶
Index ¶
- Constants
- Variables
- func AccountExists(state kv.KVStoreReader, agentID isc.AgentID) bool
- func AddFoundryToAccount(state kv.KVStore, agentID isc.AgentID, sn uint32)
- func AdjustAccountBaseTokens(state kv.KVStore, account isc.AgentID, adjustment int64)
- func CheckLedger(state kv.KVStore, checkpoint string)
- func CreditNFTToAccount(state kv.KVStore, agentID isc.AgentID, nft *isc.NFT)
- func CreditToAccount(state kv.KVStore, agentID isc.AgentID, assets *isc.FungibleTokens)
- func DebitFromAccount(state kv.KVStore, agentID isc.AgentID, assets *isc.FungibleTokens)
- func DebitNFTFromAccount(state kv.KVStore, agentID isc.AgentID, id iotago.NFTID)
- func DeleteFoundryOutput(state kv.KVStore, sn uint32)
- func DeleteNFTOutput(state kv.KVStore, id iotago.NFTID)
- func DeleteNativeTokenOutput(state kv.KVStore, tokenID iotago.NativeTokenID)
- func GetAccountAssets(state kv.KVStoreReader, agentID isc.AgentID) *isc.FungibleTokens
- func GetAccountNFTs(state kv.KVStoreReader, agentID isc.AgentID) []iotago.NFTID
- func GetBaseTokensBalance(state kv.KVStoreReader, agentID isc.AgentID) uint64
- func GetFoundryOutput(state kv.KVStoreReader, sn uint32, chainID *isc.ChainID) (*iotago.FoundryOutput, uint32, uint16)
- func GetMaxAssumedNonce(state kv.KVStoreReader, callerAgentID isc.AgentID) uint64
- func GetNFTData(state kv.KVStoreReader, id iotago.NFTID) isc.NFT
- func GetNFTOutput(state kv.KVStoreReader, id iotago.NFTID, chainID *isc.ChainID) (*iotago.NFTOutput, uint32, uint16)
- func GetNativeTokenBalance(state kv.KVStoreReader, agentID isc.AgentID, tokenID *iotago.NativeTokenID) *big.Int
- func GetNativeTokenBalanceTotal(state kv.KVStoreReader, tokenID *iotago.NativeTokenID) *big.Int
- func GetNativeTokenOutput(state kv.KVStoreReader, tokenID *iotago.NativeTokenID, chainID *isc.ChainID) (*iotago.BasicOutput, uint32, uint16)
- func GetStorageDepositAssumptions(state kv.KVStoreReader) *transaction.StorageDepositAssumption
- func GetTotalL2Assets(state kv.KVStoreReader) *isc.FungibleTokens
- func GetTotalL2NFTs(state kv.KVStoreReader) map[iotago.NFTID]bool
- func HasEnoughForAllowance(state kv.KVStoreReader, agentID isc.AgentID, allowance *isc.Allowance) bool
- func HasFoundry(state kv.KVStoreReader, agentID isc.AgentID, sn uint32) bool
- func MoveBetweenAccounts(state kv.KVStore, fromAgentID, toAgentID isc.AgentID, ...) bool
- func MoveFoundryBetweenAccounts(state kv.KVStore, agentIDFrom, agentIDTo isc.AgentID, sn uint32)
- func MustMoveBetweenAccounts(state kv.KVStore, fromAgentID, toAgentID isc.AgentID, ...)
- func NFTMapEqual(a, b map[iotago.NFTID]bool) bool
- func SaveFoundryOutput(state kv.KVStore, f *iotago.FoundryOutput, blockIndex uint32, ...)
- func SaveMaxAssumedNonce(state kv.KVStore, callerAgentID isc.AgentID, nonce uint64)
- func SaveNFTOutput(state kv.KVStore, out *iotago.NFTOutput, blockIndex uint32, outputIndex uint16)
- func SaveNativeTokenOutput(state kv.KVStore, out *iotago.BasicOutput, blockIndex uint32, ...)
- type NFTOutputRec
Constants ¶
const ( // MinimumBaseTokensOnCommonAccount can't harvest the minimum MinimumBaseTokensOnCommonAccount = 3000 ParamAgentID = "a" ParamAccountNonce = "n" ParamForceMinimumBaseTokens = "f" ParamFoundrySN = "s" ParamFoundryOutputBin = "b" ParamTokenScheme = "t" ParamSupplyDeltaAbs = "d" ParamDestroyTokens = "y" ParamStorageDepositAssumptionsBin = "u" ParamForceOpenAccount = "c" ParamNFTIDs = "i" ParamNFTID = "z" ParamNFTData = "e" ParamBalance = "B" ParamNativeTokenID = "N" )
const ConstDepositFeeTmp = 1 * isc.Million
TODO this is just a temporary value, we need to make deposits fee constant across chains.
Variables ¶
var ( // Views ViewBalance = coreutil.ViewFunc("balance") ViewBalanceBaseToken = coreutil.ViewFunc("balanceBaseToken") ViewBalanceNativeToken = coreutil.ViewFunc("balanceNativeToken") ViewTotalAssets = coreutil.ViewFunc("totalAssets") ViewAccounts = coreutil.ViewFunc("accounts") ViewGetAccountNonce = coreutil.ViewFunc("getAccountNonce") ViewGetNativeTokenIDRegistry = coreutil.ViewFunc("getNativeTokenIDRegistry") ViewFoundryOutput = coreutil.ViewFunc("foundryOutput") ViewAccountNFTs = coreutil.ViewFunc("accountNFTs") ViewNFTData = coreutil.ViewFunc("nftData") // Funcs FuncDeposit = coreutil.Func("deposit") FuncTransferAllowanceTo = coreutil.Func("transferAllowanceTo") FuncWithdraw = coreutil.Func("withdraw") FuncHarvest = coreutil.Func("harvest") FuncFoundryCreateNew = coreutil.Func("foundryCreateNew") FuncFoundryDestroy = coreutil.Func("foundryDestroy") FuncFoundryModifySupply = coreutil.Func("foundryModifySupply") )
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() ErrInvalidNFTID = coreerrors.Register("invalid NFT ID").Create() ErrTooManyNFTsInAllowance = coreerrors.Register("expected at most 1 NFT in allowance").Create() ErrNFTIDNotFound = coreerrors.Register("NFTID not found: %s") )
var Contract = coreutil.NewContract(coreutil.CoreContractAccounts, "Chain account ledger contract")
var ErrStorageDepositAssumptionsWrong = xerrors.New("'storage deposit assumptions' parameter not specified or wrong")
var Processor = Contract.Processor(initialize, FuncDeposit.WithHandler(deposit), FuncFoundryCreateNew.WithHandler(foundryCreateNew), FuncFoundryDestroy.WithHandler(foundryDestroy), FuncFoundryModifySupply.WithHandler(foundryModifySupply), FuncHarvest.WithHandler(harvest), FuncTransferAllowanceTo.WithHandler(transferAllowanceTo), FuncWithdraw.WithHandler(withdraw), ViewAccountNFTs.WithHandler(viewAccountNFTs), ViewAccounts.WithHandler(viewAccounts), ViewBalance.WithHandler(viewBalance), ViewBalanceBaseToken.WithHandler(viewBalanceBaseToken), ViewBalanceNativeToken.WithHandler(viewBalanceNativeToken), ViewFoundryOutput.WithHandler(viewFoundryOutput), ViewGetAccountNonce.WithHandler(viewGetAccountNonce), ViewGetNativeTokenIDRegistry.WithHandler(viewGetNativeTokenIDRegistry), ViewNFTData.WithHandler(viewNFTData), ViewTotalAssets.WithHandler(viewTotalAssets), )
Functions ¶
func AccountExists ¶ added in v0.3.0
func AccountExists(state kv.KVStoreReader, agentID isc.AgentID) bool
func AddFoundryToAccount ¶ added in v0.3.0
AddFoundryToAccount ads new foundry to the foundries controlled by the account
func AdjustAccountBaseTokens ¶ added in v0.3.0
func CheckLedger ¶ added in v0.3.7
func CreditNFTToAccount ¶ added in v0.3.0
CreditNFTToAccount credits an NFT to the on chain ledger
func CreditToAccount ¶
CreditToAccount brings new funds to the on chain ledger
func DebitFromAccount ¶
DebitFromAccount takes out assets balance the on chain ledger. If not enough it panics
func DebitNFTFromAccount ¶ added in v0.3.0
DebitNFTFromAccount removes an NFT from an account. if that account doesn't own the nft, it panics this will also delete the NFT data, as the NFT will be leaving the chain
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, tokenID iotago.NativeTokenID)
func GetAccountAssets ¶ added in v0.3.0
func GetAccountAssets(state kv.KVStoreReader, agentID isc.AgentID) *isc.FungibleTokens
GetAccountAssets returns all assets 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(state kv.KVStoreReader, agentID isc.AgentID) uint64
GetBaseTokensBalance return base tokens balance. 0 means it does not exist
func GetFoundryOutput ¶ added in v0.3.0
func GetFoundryOutput(state kv.KVStoreReader, sn uint32, chainID *isc.ChainID) (*iotago.FoundryOutput, uint32, uint16)
GetFoundryOutput returns foundry output, its block number and output index
func GetMaxAssumedNonce ¶ added in v0.2.0
func GetMaxAssumedNonce(state kv.KVStoreReader, callerAgentID isc.AgentID) uint64
GetMaxAssumedNonce is maintained for each caller with the purpose of replay protection of off-ledger requests
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, tokenID *iotago.NativeTokenID) *big.Int
GetNativeTokenBalance returns balance or nil if it does not exist
func GetNativeTokenBalanceTotal ¶ added in v0.3.0
func GetNativeTokenBalanceTotal(state kv.KVStoreReader, tokenID *iotago.NativeTokenID) *big.Int
func GetNativeTokenOutput ¶ added in v0.3.0
func GetNativeTokenOutput(state kv.KVStoreReader, tokenID *iotago.NativeTokenID, chainID *isc.ChainID) (*iotago.BasicOutput, uint32, uint16)
func GetStorageDepositAssumptions ¶ added in v0.3.0
func GetStorageDepositAssumptions(state kv.KVStoreReader) *transaction.StorageDepositAssumption
func GetTotalL2Assets ¶ added in v0.3.0
func GetTotalL2Assets(state kv.KVStoreReader) *isc.FungibleTokens
func GetTotalL2NFTs ¶ added in v0.3.0
func GetTotalL2NFTs(state kv.KVStoreReader) map[iotago.NFTID]bool
func HasEnoughForAllowance ¶ added in v0.3.0
func HasEnoughForAllowance(state kv.KVStoreReader, agentID isc.AgentID, allowance *isc.Allowance) bool
GetNativeTokenBalance returns balance or nil if it does not exist
func HasFoundry ¶ added in v0.3.0
HasFoundry checks if specific account owns the foundry
func MoveBetweenAccounts ¶
func MoveBetweenAccounts(state kv.KVStore, fromAgentID, toAgentID isc.AgentID, fungibleTokens *isc.FungibleTokens, nfts []iotago.NFTID) bool
MoveBetweenAccounts moves assets between on-chain accounts. Returns if it was a success (= enough funds in the source)
func MoveFoundryBetweenAccounts ¶ added in v0.3.0
MoveFoundryBetweenAccounts changes ownership of the foundry
func MustMoveBetweenAccounts ¶ added in v0.3.0
func SaveFoundryOutput ¶ added in v0.3.0
func SaveFoundryOutput(state kv.KVStore, f *iotago.FoundryOutput, blockIndex uint32, outputIndex uint16)
SaveFoundryOutput stores foundry output into the map of all foundry outputs (compressed form)
func SaveMaxAssumedNonce ¶ added in v0.3.0
func SaveNFTOutput ¶ added in v0.3.0
SaveNFTOutput map tokenID -> foundryRec
func SaveNativeTokenOutput ¶ added in v0.3.0
func SaveNativeTokenOutput(state kv.KVStore, out *iotago.BasicOutput, blockIndex uint32, outputIndex uint16)
SaveNativeTokenOutput map tokenID -> foundryRec
Types ¶
type NFTOutputRec ¶ added in v0.3.0
region NFT outputs /////////////////////////////////
func NFTOutputRecFromMarshalUtil ¶ added in v0.3.0
func NFTOutputRecFromMarshalUtil(mu *marshalutil.MarshalUtil) (*NFTOutputRec, error)
func (*NFTOutputRec) Bytes ¶ added in v0.3.0
func (r *NFTOutputRec) Bytes() []byte
func (*NFTOutputRec) String ¶ added in v0.3.0
func (r *NFTOutputRec) String() string