Documentation
¶
Overview ¶
Package 'isc' defines fundamental types used in the Wasp.
The core types are mostly based on the fundamental data types of Goshimmer
Index ¶
- Constants
- Variables
- func AddressFromAgentID(a AgentID) (iotago.Address, bool)
- func AddressFromBytes(bytes []byte) (address iotago.Address, consumedBytes int, err error)
- func AddressFromMarshalUtil(mu *marshalutil.MarshalUtil) (iotago.Address, error)
- func AliasOutputsEqual(ao1, ao2 *iotago.AliasOutput) bool
- func BytesFromAddress(address iotago.Address) []byte
- func DecodeOutputID(b []byte, def ...iotago.OutputID) (iotago.OutputID, error)
- func EncodeOutputID(value iotago.OutputID) []byte
- func FindNativeTokenBalance(nts iotago.NativeTokens, id *iotago.NativeTokenID) *big.Int
- func GetErrorIDFromMessageFormat(messageFormat string) uint16
- func IsBaseToken(tokenID []byte) bool
- func MustNativeTokenIDFromBytes(data []byte) iotago.NativeTokenID
- func NativeTokenIDFromBytes(data []byte) (iotago.NativeTokenID, error)
- func OID(o *iotago.UTXOInput) string
- func OutputSetToOutputIDs(outputSet iotago.OutputSet) iotago.OutputIDs
- func RequestHash(req Request) hashing.HashValue
- func RequestIsExpired(req OnLedgerRequest, currentTime time.Time) bool
- func RequestIsUnlockable(req OnLedgerRequest, chainAddress iotago.Address, currentTime time.Time) bool
- func RequestsInTransaction(tx *iotago.Transaction) (map[ChainID][]Request, error)
- func ShortRequestIDs(ids []RequestID) []string
- func ShortRequestIDsFromRequests(reqs []Request) []string
- func TxID(txID iotago.TransactionID) string
- func UTXOInputFromMarshalUtil(mu *marshalutil.MarshalUtil) (*iotago.UTXOInput, error)
- func UTXOInputIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (*iotago.UTXOInput, error)
- func UTXOInputToMarshalUtil(id *iotago.UTXOInput, mu *marshalutil.MarshalUtil)
- func VMErrorIs(err error, expected VMErrorBase) bool
- func VMErrorMustBe(err error, expected VMErrorBase)
- type AddressAgentID
- type AgentID
- type AgentIDKind
- type AgentIDWithL1Address
- type AliasOutputWithID
- func (a *AliasOutputWithID) GetAliasID() iotago.AliasID
- func (a *AliasOutputWithID) GetAliasOutput() *iotago.AliasOutput
- func (a *AliasOutputWithID) GetStateAddress() iotago.Address
- func (a *AliasOutputWithID) GetStateIndex() uint32
- func (a *AliasOutputWithID) GetStateMetadata() []byte
- func (a *AliasOutputWithID) ID() *iotago.UTXOInput
- func (a *AliasOutputWithID) OutputID() iotago.OutputID
- type Allowance
- func AllowanceFromBytes(b []byte) (*Allowance, error)
- func AllowanceFromMarshalUtil(mu *marshalutil.MarshalUtil) (*Allowance, error)
- func NewAllowance(baseTokens uint64, tokens iotago.NativeTokens, nfts []iotago.NFTID) *Allowance
- func NewAllowanceBaseTokens(baseTokens uint64) *Allowance
- func NewAllowanceFungibleTokens(ftokens *FungibleTokens) *Allowance
- func NewEmptyAllowance() *Allowance
- func (a *Allowance) Add(b *Allowance) *Allowance
- func (a *Allowance) AddBaseTokens(amount uint64) *Allowance
- func (a *Allowance) AddNFTs(nfts ...iotago.NFTID) *Allowance
- func (a *Allowance) AddNativeTokens(tokenID iotago.NativeTokenID, amount interface{}) *Allowance
- func (a *Allowance) Bytes() []byte
- func (a *Allowance) Clone() *Allowance
- func (a *Allowance) IsEmpty() bool
- func (a *Allowance) NFTSet() map[iotago.NFTID]bool
- func (a *Allowance) SpendFromBudget(toSpend *Allowance) bool
- func (a *Allowance) String() string
- func (a *Allowance) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
- type Authorize
- type BLS
- type Balance
- type CallTarget
- type Calldata
- type ChainID
- func ChainIDFromAddress(addr *iotago.AliasAddress) ChainID
- func ChainIDFromAliasID(addr iotago.AliasID) ChainID
- func ChainIDFromBytes(data []byte) (*ChainID, error)
- func ChainIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (*ChainID, error)
- func ChainIDFromString(s string) (*ChainID, error)
- func RandomChainID(seed ...[]byte) *ChainID
- func (chid *ChainID) AsAddress() iotago.Address
- func (chid *ChainID) AsAliasAddress() *iotago.AliasAddress
- func (chid *ChainID) AsAliasID() *iotago.AliasID
- func (chid *ChainID) Bytes() []byte
- func (chid *ChainID) CommonAccount() AgentID
- func (chid *ChainID) Equals(chid1 *ChainID) bool
- func (chid *ChainID) IsSameChain(aid AgentID) bool
- func (chid *ChainID) Key() string
- func (chid *ChainID) String() string
- type ContractAgentID
- func (a *ContractAgentID) Address() iotago.Address
- func (a *ContractAgentID) Bytes() []byte
- func (a *ContractAgentID) ChainID() *ChainID
- func (a *ContractAgentID) Equals(other AgentID) bool
- func (a *ContractAgentID) Hname() Hname
- func (a *ContractAgentID) Kind() AgentIDKind
- func (a *ContractAgentID) String() string
- type ED25519
- type EthereumAddressAgentID
- type Expiration
- type Features
- type FungibleTokens
- func FungibleTokensFromDict(d dict.Dict) (*FungibleTokens, error)
- func FungibleTokensFromMarshalUtil(mu *marshalutil.MarshalUtil) (*FungibleTokens, error)
- func FungibleTokensFromNativeTokenSum(baseTokens uint64, tokens iotago.NativeTokenSum) *FungibleTokens
- func FungibleTokensFromOutput(o iotago.Output) *FungibleTokens
- func FungibleTokensFromOutputMap(outs map[iotago.OutputID]iotago.Output) *FungibleTokens
- func NewEmptyFungibleTokens() *FungibleTokens
- func NewFungibleBaseTokens(amount uint64) *FungibleTokens
- func NewFungibleTokens(baseTokens uint64, tokens iotago.NativeTokens) *FungibleTokens
- func NewFungibleTokensForGasFee(p *gas.GasFeePolicy, feeAmount uint64) *FungibleTokens
- func (a *FungibleTokens) Add(b *FungibleTokens) *FungibleTokens
- func (a *FungibleTokens) AddBaseTokens(amount uint64) *FungibleTokens
- func (a *FungibleTokens) AddNativeTokens(tokenID iotago.NativeTokenID, amount interface{}) *FungibleTokens
- func (a *FungibleTokens) AmountNativeToken(tokenID *iotago.NativeTokenID) *big.Int
- func (a *FungibleTokens) Bytes() []byte
- func (a *FungibleTokens) Clone() *FungibleTokens
- func (a *FungibleTokens) Equals(b *FungibleTokens) bool
- func (a *FungibleTokens) IsEmpty() bool
- func (a *FungibleTokens) SpendFromFungibleTokenBudget(toSpend *FungibleTokens) bool
- func (a *FungibleTokens) String() string
- func (a *FungibleTokens) ToDict() dict.Dict
- func (a *FungibleTokens) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
- type Gas
- type Hashing
- type Helpers
- type Hname
- func (hn Hname) Bytes() []byte
- func (hn Hname) Clone() Hname
- func (hn *Hname) Read(r io.Reader) error
- func (hn *Hname) ReadFromMarshalUtil(mu *marshalutil.MarshalUtil) error
- func (hn Hname) String() string
- func (hn *Hname) Write(w io.Writer) error
- func (hn *Hname) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
- type KVDecoder
- type LogInterface
- type NFT
- type NilAgentID
- type OffLedgerRequest
- type OffLedgerRequestData
- type OnLedgerRequest
- type Params
- type Privileged
- type PrivilegedView
- type Receipt
- type Request
- type RequestID
- func NewRequestID(txid iotago.TransactionID, index uint16) RequestID
- func RequestIDFromBytes(data []byte) (RequestID, error)
- func RequestIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (RequestID, error)
- func RequestIDFromString(s string) (ret RequestID, err error)
- func TakeRequestIDs(reqs ...Request) []RequestID
- func (rid RequestID) Bytes() []byte
- func (rid RequestID) Equals(reqID2 RequestID) bool
- func (rid RequestID) LookupDigest() RequestLookupDigest
- func (rid RequestID) OutputID() iotago.OutputID
- func (rid RequestID) Short() string
- func (rid RequestID) String() string
- func (rid RequestID) UTXOInput() *iotago.UTXOInput
- type RequestLookupDigest
- type RequestMetadata
- type RequestParameters
- type ReturnAmountOptions
- type Sandbox
- type SandboxBase
- type SandboxView
- type SendMetadata
- type SendOptions
- type StateAnchor
- type UnresolvedVMError
- type UnsignedOffLedgerRequest
- type Utils
- type VMError
- func (e *VMError) AsGoError() error
- func (e *VMError) AsTemplate() *VMErrorTemplate
- func (e *VMError) AsUnresolvedError() *UnresolvedVMError
- func (e *VMError) Bytes() []byte
- func (e *VMError) Code() VMErrorCode
- func (e *VMError) Error() string
- func (e *VMError) Hash() uint32
- func (e *VMError) MessageFormat() string
- func (e *VMError) Params() []interface{}
- type VMErrorBase
- type VMErrorCode
- type VMErrorTemplate
- func (e *VMErrorTemplate) Bytes() []byte
- func (e *VMErrorTemplate) Code() VMErrorCode
- func (e *VMErrorTemplate) Create(params ...interface{}) *VMError
- func (e *VMErrorTemplate) Error() string
- func (e *VMErrorTemplate) MessageFormat() string
- func (e *VMErrorTemplate) Serialize(mu *marshalutil.MarshalUtil)
- type VMProcessor
- type VMProcessorEntryPoint
Constants ¶
const ChainIDLength = iotago.AliasIDLength
const FuncInit = "init"
FuncInit is a name of the init function for any smart contract
const HnameLength = 4
const Million = uint64(1_000_000)
const RequestConsideredExpiredWindow = time.Minute * 1
don't process any request which deadline will expire within 1 minute
const RequestIDDigestLen = 6
const RequestIDSeparator = "-"
const VMCoreErrorContractID = math.MaxUint32
VMCoreErrorContractID defines that all errors with a MaxUint32 contract id will be considered as core errors.
const VMErrorMessageLimit = math.MaxUint16
Variables ¶
var BaseTokenID = []byte{}
var (
EntryPointInit = Hn(FuncInit)
)
well known hnames
var ErrWrongTypeEntryPoint = xerrors.New("wrong type of the entry point")
var NativeAssetsSerializationArrayRules = iotago.NativeTokenArrayRules()
Functions ¶
func AddressFromAgentID ¶
AddressFromAgentID returns the L1 address of the AgentID, if applicable.
func AddressFromBytes ¶
AddressFromBytes unmarshals an Address from a sequence of bytes.
func AddressFromMarshalUtil ¶
func AddressFromMarshalUtil(mu *marshalutil.MarshalUtil) (iotago.Address, error)
func AliasOutputsEqual ¶
func AliasOutputsEqual(ao1, ao2 *iotago.AliasOutput) bool
func BytesFromAddress ¶
func DecodeOutputID ¶
func EncodeOutputID ¶
func FindNativeTokenBalance ¶
func FindNativeTokenBalance(nts iotago.NativeTokens, id *iotago.NativeTokenID) *big.Int
TODO this could be refactored to use `AmountNativeToken`
func IsBaseToken ¶
IsBaseToken return whether a given tokenID represents the base token
func MustNativeTokenIDFromBytes ¶
func MustNativeTokenIDFromBytes(data []byte) iotago.NativeTokenID
func NativeTokenIDFromBytes ¶
func NativeTokenIDFromBytes(data []byte) (iotago.NativeTokenID, error)
func RequestHash ¶
func RequestIsExpired ¶
func RequestIsExpired(req OnLedgerRequest, currentTime time.Time) bool
func RequestIsUnlockable ¶
func RequestsInTransaction ¶
func RequestsInTransaction(tx *iotago.Transaction) (map[ChainID][]Request, error)
RequestsInTransaction parses the transaction and extracts those outputs which are interpreted as a request to a chain
func ShortRequestIDs ¶
func TxID ¶
func TxID(txID iotago.TransactionID) string
func UTXOInputFromMarshalUtil ¶
func UTXOInputFromMarshalUtil(mu *marshalutil.MarshalUtil) (*iotago.UTXOInput, error)
func UTXOInputIDFromMarshalUtil ¶
func UTXOInputIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (*iotago.UTXOInput, error)
func UTXOInputToMarshalUtil ¶
func UTXOInputToMarshalUtil(id *iotago.UTXOInput, mu *marshalutil.MarshalUtil)
func VMErrorIs ¶
func VMErrorIs(err error, expected VMErrorBase) bool
VMErrorIs returns true if the error includes a VMErrorCode in its chain that matches the given code
func VMErrorMustBe ¶
func VMErrorMustBe(err error, expected VMErrorBase)
VMErrorMustBe panics unless the error includes a VMErrorCode in its chain that matches the given code
Types ¶
type AddressAgentID ¶
type AddressAgentID struct {
// contains filtered or unexported fields
}
AddressAgentID is an AgentID backed by a non-alias address.
func (*AddressAgentID) Address ¶
func (a *AddressAgentID) Address() iotago.Address
func (*AddressAgentID) Bytes ¶
func (a *AddressAgentID) Bytes() []byte
func (*AddressAgentID) Equals ¶
func (a *AddressAgentID) Equals(other AgentID) bool
func (*AddressAgentID) Kind ¶
func (a *AddressAgentID) Kind() AgentIDKind
func (*AddressAgentID) String ¶
func (a *AddressAgentID) String() string
type AgentID ¶
type AgentID interface {
Kind() AgentIDKind
String() string
Bytes() []byte
Equals(other AgentID) bool
}
AgentID represents any entity that can hold assets on L2 and/or call contracts.
func AgentIDFromBytes ¶
func AgentIDFromMarshalUtil ¶
func AgentIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (AgentID, error)
func NewAgentID ¶
NewAgentID creates an AddressAgentID if the address is not an AliasAddress; otherwise a ContractAgentID with hname = 0.
func NewAgentIDFromString ¶
NewAgentIDFromString parses the human-readable string representation
type AgentIDKind ¶
type AgentIDKind uint8
const ( AgentIDKindNil AgentIDKind = iota AgentIDKindAddress AgentIDKindContract AgentIDKindEthereumAddress )
type AgentIDWithL1Address ¶
AgentIDWithL1Address is an AgentID backed by an L1 address (either AddressAgentID or ContractAgentID).
type AliasOutputWithID ¶
type AliasOutputWithID struct {
// contains filtered or unexported fields
}
func NewAliasOutputWithID ¶
func NewAliasOutputWithID(output *iotago.AliasOutput, id *iotago.UTXOInput) *AliasOutputWithID
func (*AliasOutputWithID) GetAliasID ¶
func (a *AliasOutputWithID) GetAliasID() iotago.AliasID
func (*AliasOutputWithID) GetAliasOutput ¶
func (a *AliasOutputWithID) GetAliasOutput() *iotago.AliasOutput
func (*AliasOutputWithID) GetStateAddress ¶
func (a *AliasOutputWithID) GetStateAddress() iotago.Address
func (*AliasOutputWithID) GetStateIndex ¶
func (a *AliasOutputWithID) GetStateIndex() uint32
func (*AliasOutputWithID) GetStateMetadata ¶
func (a *AliasOutputWithID) GetStateMetadata() []byte
func (*AliasOutputWithID) ID ¶
func (a *AliasOutputWithID) ID() *iotago.UTXOInput
func (*AliasOutputWithID) OutputID ¶
func (a *AliasOutputWithID) OutputID() iotago.OutputID
type Allowance ¶
type Allowance struct {
Assets *FungibleTokens
NFTs []iotago.NFTID
}
func AllowanceFromBytes ¶
func AllowanceFromMarshalUtil ¶
func AllowanceFromMarshalUtil(mu *marshalutil.MarshalUtil) (*Allowance, error)
func NewAllowance ¶
func NewAllowanceBaseTokens ¶
func NewAllowanceFungibleTokens ¶
func NewAllowanceFungibleTokens(ftokens *FungibleTokens) *Allowance
func NewEmptyAllowance ¶
func NewEmptyAllowance() *Allowance
func (*Allowance) AddBaseTokens ¶
func (*Allowance) AddNativeTokens ¶
func (a *Allowance) AddNativeTokens(tokenID iotago.NativeTokenID, amount interface{}) *Allowance
func (*Allowance) SpendFromBudget ¶
func (*Allowance) WriteToMarshalUtil ¶
func (a *Allowance) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
type Balance ¶
type Balance interface {
// BalanceBaseTokens returns number of base tokens in the balance of the smart contract
BalanceBaseTokens() uint64
// BalanceNativeToken returns number of native token or nil if it is empty
BalanceNativeToken(id *iotago.NativeTokenID) *big.Int
// BalanceFungibleTokens returns all fungible tokens: base tokens and native tokens
BalanceFungibleTokens() *FungibleTokens
// OwnedNFTs returns the NFTIDs of NFTs owned by the smart contract
OwnedNFTs() []iotago.NFTID
// returns whether a given user owns a given amount of tokens
HasInAccount(AgentID, *FungibleTokens) bool
}
type CallTarget ¶
CallTarget the target representation of the request
func NewCallTarget ¶
func NewCallTarget(contract, entryPoint Hname) CallTarget
func (CallTarget) Equals ¶
func (t CallTarget) Equals(otherTarget CallTarget) bool
type Calldata ¶
type Calldata interface {
ID() RequestID
Params() dict.Dict
SenderAccount() AgentID
CallTarget() CallTarget
TargetAddress() iotago.Address // TODO implement properly. Target depends on time assumptions and UTXO type
FungibleTokens() *FungibleTokens // attached assets for the UTXO request, nil for off-ledger. All goes to sender
NFT() *NFT // Not nil if the request is an NFT request
Allowance() *Allowance // transfer of assets to the smart contract. Debited from sender account
GasBudget() (gas uint64, isEVM bool)
}
type ChainID ¶
ChainID represents the global identifier of the chain It is wrapped AliasAddress, an address without a private key behind
func ChainIDFromAddress ¶
func ChainIDFromAddress(addr *iotago.AliasAddress) ChainID
func ChainIDFromAliasID ¶
ChainIDFromAliasID creates new chain ID from alias address
func ChainIDFromBytes ¶
ChainIDFromBytes reconstructs a ChainID from its binary representation.
func ChainIDFromMarshalUtil ¶
func ChainIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (*ChainID, error)
ChainIDFromMarshalUtil reads from Marshalutil
func ChainIDFromString ¶
func RandomChainID ¶
RandomChainID creates a random chain ID. Used for testing only
func (*ChainID) AsAliasAddress ¶
func (chid *ChainID) AsAliasAddress() *iotago.AliasAddress
func (*ChainID) CommonAccount ¶
func (*ChainID) IsSameChain ¶
type ContractAgentID ¶
type ContractAgentID struct {
// contains filtered or unexported fields
}
ContractAgentID is an AgentID formed by a ChainID and a contract Hname.
func NewContractAgentID ¶
func NewContractAgentID(chainID *ChainID, hname Hname) *ContractAgentID
func (*ContractAgentID) Address ¶
func (a *ContractAgentID) Address() iotago.Address
func (*ContractAgentID) Bytes ¶
func (a *ContractAgentID) Bytes() []byte
func (*ContractAgentID) ChainID ¶
func (a *ContractAgentID) ChainID() *ChainID
func (*ContractAgentID) Equals ¶
func (a *ContractAgentID) Equals(other AgentID) bool
func (*ContractAgentID) Hname ¶
func (a *ContractAgentID) Hname() Hname
func (*ContractAgentID) Kind ¶
func (a *ContractAgentID) Kind() AgentIDKind
func (*ContractAgentID) String ¶
func (a *ContractAgentID) String() string
type EthereumAddressAgentID ¶
type EthereumAddressAgentID struct {
// contains filtered or unexported fields
}
EthereumAddressAgentID is an AgentID formed by an Ethereum address
func NewEthereumAddressAgentID ¶
func NewEthereumAddressAgentID(eth common.Address) *EthereumAddressAgentID
func (*EthereumAddressAgentID) Bytes ¶
func (a *EthereumAddressAgentID) Bytes() []byte
func (*EthereumAddressAgentID) Equals ¶
func (a *EthereumAddressAgentID) Equals(other AgentID) bool
func (*EthereumAddressAgentID) EthAddress ¶
func (a *EthereumAddressAgentID) EthAddress() common.Address
func (*EthereumAddressAgentID) Kind ¶
func (a *EthereumAddressAgentID) Kind() AgentIDKind
func (*EthereumAddressAgentID) String ¶
func (a *EthereumAddressAgentID) String() string
type Features ¶
type Features interface {
// TimeLock returns the timelock feature, or a zero time if not present
TimeLock() time.Time
// Expiry returns the expiry time and sender address, or a zero time if not present
Expiry() (time.Time, iotago.Address) // return expiry time data and sender address or nil, nil if does not exist
ReturnAmount() (uint64, bool)
}
type FungibleTokens ¶
type FungibleTokens struct {
BaseTokens uint64
Tokens iotago.NativeTokens
}
FungibleTokens is used as assets in the UTXO and as tokens in transfer
func FungibleTokensFromDict ¶
func FungibleTokensFromDict(d dict.Dict) (*FungibleTokens, error)
func FungibleTokensFromMarshalUtil ¶
func FungibleTokensFromMarshalUtil(mu *marshalutil.MarshalUtil) (*FungibleTokens, error)
func FungibleTokensFromNativeTokenSum ¶
func FungibleTokensFromNativeTokenSum(baseTokens uint64, tokens iotago.NativeTokenSum) *FungibleTokens
func FungibleTokensFromOutput ¶
func FungibleTokensFromOutput(o iotago.Output) *FungibleTokens
func FungibleTokensFromOutputMap ¶
func FungibleTokensFromOutputMap(outs map[iotago.OutputID]iotago.Output) *FungibleTokens
func NewEmptyFungibleTokens ¶ added in v0.3.5
func NewEmptyFungibleTokens() *FungibleTokens
func NewFungibleBaseTokens ¶
func NewFungibleBaseTokens(amount uint64) *FungibleTokens
func NewFungibleTokens ¶
func NewFungibleTokens(baseTokens uint64, tokens iotago.NativeTokens) *FungibleTokens
func NewFungibleTokensForGasFee ¶
func NewFungibleTokensForGasFee(p *gas.GasFeePolicy, feeAmount uint64) *FungibleTokens
func (*FungibleTokens) Add ¶
func (a *FungibleTokens) Add(b *FungibleTokens) *FungibleTokens
func (*FungibleTokens) AddBaseTokens ¶
func (a *FungibleTokens) AddBaseTokens(amount uint64) *FungibleTokens
func (*FungibleTokens) AddNativeTokens ¶
func (a *FungibleTokens) AddNativeTokens(tokenID iotago.NativeTokenID, amount interface{}) *FungibleTokens
func (*FungibleTokens) AmountNativeToken ¶
func (a *FungibleTokens) AmountNativeToken(tokenID *iotago.NativeTokenID) *big.Int
func (*FungibleTokens) Bytes ¶
func (a *FungibleTokens) Bytes() []byte
func (*FungibleTokens) Clone ¶
func (a *FungibleTokens) Clone() *FungibleTokens
func (*FungibleTokens) Equals ¶
func (a *FungibleTokens) Equals(b *FungibleTokens) bool
func (*FungibleTokens) IsEmpty ¶
func (a *FungibleTokens) IsEmpty() bool
func (*FungibleTokens) SpendFromFungibleTokenBudget ¶
func (a *FungibleTokens) SpendFromFungibleTokenBudget(toSpend *FungibleTokens) bool
SpendFromFungibleTokenBudget subtracts fungible tokens from budget. Mutates receiver `a` ! If budget is not enough, returns false and leaves receiver untouched
func (*FungibleTokens) String ¶
func (a *FungibleTokens) String() string
func (*FungibleTokens) ToDict ¶
func (a *FungibleTokens) ToDict() dict.Dict
func (*FungibleTokens) WriteToMarshalUtil ¶
func (a *FungibleTokens) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
type Hname ¶
type Hname uint32
Hname is 4 bytes of blake2b hash of any string interpreted as little-endian uint32. 0 and not ^0 are reserved values and the isc.Hn ensures it is not returned
func HnameFromAgentID ¶
HnameFromAgentID returns the hname of the AgentID, if applicable.
func HnameFromBytes ¶
func HnameFromMarshalUtil ¶
func HnameFromMarshalUtil(mu *marshalutil.MarshalUtil) (ret Hname, err error)
HnameFromBytes constructor, unmarshalling
func HnameFromString ¶
func (*Hname) ReadFromMarshalUtil ¶
func (hn *Hname) ReadFromMarshalUtil(mu *marshalutil.MarshalUtil) error
func (*Hname) WriteToMarshalUtil ¶
func (hn *Hname) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
type KVDecoder ¶
type KVDecoder interface {
kv.KVStoreReader
GetInt16(key kv.Key, def ...int16) (int16, error)
MustGetInt16(key kv.Key, def ...int16) int16
GetUint16(key kv.Key, def ...uint16) (uint16, error)
MustGetUint16(key kv.Key, def ...uint16) uint16
GetInt32(key kv.Key, def ...int32) (int32, error)
MustGetInt32(key kv.Key, def ...int32) int32
GetUint32(key kv.Key, def ...uint32) (uint32, error)
MustGetUint32(key kv.Key, def ...uint32) uint32
GetInt64(key kv.Key, def ...int64) (int64, error)
MustGetInt64(key kv.Key, def ...int64) int64
GetUint64(key kv.Key, def ...uint64) (uint64, error)
MustGetUint64(key kv.Key, def ...uint64) uint64
GetBool(key kv.Key, def ...bool) (bool, error)
MustGetBool(key kv.Key, def ...bool) bool
GetTime(key kv.Key, def ...time.Time) (time.Time, error)
MustGetTime(key kv.Key, def ...time.Time) time.Time
GetString(key kv.Key, def ...string) (string, error)
MustGetString(key kv.Key, def ...string) string
GetHname(key kv.Key, def ...Hname) (Hname, error)
MustGetHname(key kv.Key, def ...Hname) Hname
GetHashValue(key kv.Key, def ...hashing.HashValue) (hashing.HashValue, error)
MustGetHashValue(key kv.Key, def ...hashing.HashValue) hashing.HashValue
GetAddress(key kv.Key, def ...iotago.Address) (iotago.Address, error)
MustGetAddress(key kv.Key, def ...iotago.Address) iotago.Address
GetRequestID(key kv.Key, def ...RequestID) (RequestID, error)
MustGetRequestID(key kv.Key, def ...RequestID) RequestID
GetAgentID(key kv.Key, def ...AgentID) (AgentID, error)
MustGetAgentID(key kv.Key, def ...AgentID) AgentID
GetChainID(key kv.Key, def ...*ChainID) (*ChainID, error)
MustGetChainID(key kv.Key, def ...*ChainID) *ChainID
GetBytes(key kv.Key, def ...[]byte) ([]byte, error)
MustGetBytes(key kv.Key, def ...[]byte) []byte
GetTokenScheme(key kv.Key, def ...iotago.TokenScheme) (iotago.TokenScheme, error)
MustGetTokenScheme(key kv.Key, def ...iotago.TokenScheme) iotago.TokenScheme
GetBigInt(key kv.Key, def ...*big.Int) (*big.Int, error)
MustGetBigInt(key kv.Key, def ...*big.Int) *big.Int
GetNativeTokenID(key kv.Key, def ...iotago.NativeTokenID) (iotago.NativeTokenID, error)
MustGetNativeTokenID(key kv.Key, def ...iotago.NativeTokenID) iotago.NativeTokenID
}
KVDecoder is interface with all kind of utility functions extracting and decoding values from the key/value map
type LogInterface ¶
type NFT ¶
type NFT struct {
ID iotago.NFTID
Issuer iotago.Address
Metadata []byte // (ImmutableMetadata)
Owner AgentID // can be nil
}
func NFTFromMarshalUtil ¶
func NFTFromMarshalUtil(mu *marshalutil.MarshalUtil, withID ...bool) (*NFT, error)
type NilAgentID ¶
type NilAgentID struct{}
func (*NilAgentID) Bytes ¶
func (a *NilAgentID) Bytes() []byte
func (*NilAgentID) Equals ¶
func (a *NilAgentID) Equals(other AgentID) bool
func (*NilAgentID) Kind ¶
func (a *NilAgentID) Kind() AgentIDKind
func (*NilAgentID) String ¶
func (a *NilAgentID) String() string
type OffLedgerRequest ¶
type OffLedgerRequest interface {
Request
OffLedgerRequestData
VerifySignature() error
}
func NewEVMOffLedgerEstimateGasRequest ¶
func NewEVMOffLedgerEstimateGasRequest(chainID *ChainID, callMsg ethereum.CallMsg) OffLedgerRequest
func NewEVMOffLedgerRequest ¶
func NewEVMOffLedgerRequest(chainID *ChainID, tx *types.Transaction) (OffLedgerRequest, error)
type OffLedgerRequestData ¶
type OnLedgerRequest ¶
type OnLedgerRequest interface {
Request
Output() iotago.Output
IsInternalUTXO(*ChainID) bool
UTXOInput() iotago.UTXOInput
Features() Features
}
func OnLedgerFromUTXO ¶
type Privileged ¶
type Privileged interface {
TryLoadContract(programHash hashing.HashValue) error
CreateNewFoundry(scheme iotago.TokenScheme, metadata []byte) (uint32, uint64)
DestroyFoundry(uint32) uint64
ModifyFoundrySupply(serNum uint32, delta *big.Int) int64
GasBurnEnable(enable bool)
MustMoveBetweenAccounts(fromAgentID, toAgentID AgentID, fungibleTokens *FungibleTokens, nfts []iotago.NFTID)
DebitFromAccount(AgentID, *FungibleTokens)
CreditToAccount(AgentID, *FungibleTokens)
SubscribeBlockContext(openFunc Hname, closeFunc Hname)
SetBlockContext(bctx interface{})
BlockContext() interface{}
// the amount of tokens available to pay for the gas of the current request
TotalGasTokens() *FungibleTokens
}
Privileged is a sub-interface for core contracts. Should not be called by VM plugins
type PrivilegedView ¶
type PrivilegedView interface {
GasBurnEnable(enable bool)
}
PrivilegedView is a sub-interface for core contracts. Should not be called by VM plugins
type Receipt ¶
type Receipt struct {
Request []byte `json:"request"`
Error *UnresolvedVMError `json:"error"`
GasBudget uint64 `json:"gasBudget"`
GasBurned uint64 `json:"gasBurned"`
GasFeeCharged uint64 `json:"gasFeeCharged"`
BlockIndex uint32 `json:"blockIndex"`
RequestIndex uint16 `json:"requestIndex"`
ResolvedError string `json:"resolvedError"`
GasBurnLog *gas.BurnLog `json:"-"`
}
Receipt represents a blocklog.RequestReceipt with a resolved error string
func (Receipt) DeserializedRequest ¶
type Request ¶
type Request interface {
Calldata
IsOffLedger() bool
WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
Bytes() []byte
String() string
// contains filtered or unexported methods
}
Request wraps any data which can be potentially be interpreted as a request
func NewRequestFromBytes ¶
func NewRequestFromMarshalUtil ¶
func NewRequestFromMarshalUtil(mu *marshalutil.MarshalUtil) (Request, error)
type RequestID ¶
func NewRequestID ¶
func NewRequestID(txid iotago.TransactionID, index uint16) RequestID
func RequestIDFromBytes ¶
func RequestIDFromMarshalUtil ¶
func RequestIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (RequestID, error)
func RequestIDFromString ¶
func TakeRequestIDs ¶
func (RequestID) LookupDigest ¶
func (rid RequestID) LookupDigest() RequestLookupDigest
type RequestLookupDigest ¶
type RequestLookupDigest [RequestIDDigestLen + 2]byte
RequestLookupDigest is shortened version of the request id. It is guaranteed to be unique within one block, however it may collide globally. Used for quick checking for most requests if it was never seen
type RequestMetadata ¶
type RequestMetadata struct {
SenderContract Hname
// ID of the target smart contract
TargetContract Hname
// entry point code
EntryPoint Hname
// request arguments
Params dict.Dict
// Allowance intended to the target contract to take. Nil means zero allowance
Allowance *Allowance
// gas budget
GasBudget uint64
}
func RequestMetadataFromBytes ¶
func RequestMetadataFromBytes(data []byte) (*RequestMetadata, error)
func RequestMetadataFromFeatureSet ¶
func RequestMetadataFromFeatureSet(set iotago.FeatureSet) (*RequestMetadata, error)
func (*RequestMetadata) Bytes ¶
func (p *RequestMetadata) Bytes() []byte
func (*RequestMetadata) ReadFromMarshalUtil ¶
func (p *RequestMetadata) ReadFromMarshalUtil(mu *marshalutil.MarshalUtil) error
func (*RequestMetadata) WriteToMarshalUtil ¶
func (p *RequestMetadata) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)
type RequestParameters ¶
type RequestParameters struct {
// TargetAddress is the target address. It may represent another chain or L1 address
TargetAddress iotago.Address
// FungibleTokens attached to the output, always taken from the caller's account.
// It expected to contain base tokens at least the amount required for storage deposit
// It depends on the context how it is handled when base tokens are not enough for storage deposit
FungibleTokens *FungibleTokens
// AdjustToMinimumStorageDeposit if true base tokens in attached fungible tokens will be added to meet minimum storage deposit requirements
AdjustToMinimumStorageDeposit bool
// Metadata is a request metadata. It may be nil if the output is just sending assets to L1 address
Metadata *SendMetadata
// SendOptions includes options of the output, such as time lock or expiry parameters
Options SendOptions
}
RequestParameters represents parameters of the on-ledger request. The output is build from these parameters
type ReturnAmountOptions ¶
type Sandbox ¶
type Sandbox interface {
SandboxBase
Authorize
// State k/v store of the current call (in the context of the smart contract)
State() kv.KVStore
// Request return the request in the context of which the smart contract is called
Request() Calldata
// Call calls the entry point of the contract with parameters and allowance.
// If the entry point is full entry point, allowance tokens are available to be moved from the caller's
// accounts (if enough). If the entry point is view, 'allowance' has no effect
Call(target, entryPoint Hname, params dict.Dict, allowance *Allowance) dict.Dict
// Caller is the agentID of the caller.
Caller() AgentID
// DeployContract deploys contract on the same chain. 'initParams' are passed to the 'init' entry point
DeployContract(programHash hashing.HashValue, name string, description string, initParams dict.Dict)
// Event emits an event
Event(msg string)
// RegisterError registers an error
RegisterError(messageFormat string) *VMErrorTemplate
// GetEntropy 32 random bytes based on the hash of the current state transaction
GetEntropy() hashing.HashValue
// AllowanceAvailable specifies max remaining (after transfers) budget of assets the smart contract can take
// from the caller with TransferAllowedFunds. Nil means no allowance left (zero budget)
AllowanceAvailable() *Allowance
// TransferAllowedFunds moves assets from the caller's account to specified account within the budget set by Allowance.
// Skipping 'assets' means transfer all Allowance().
// The TransferAllowedFunds call mutates AllowanceAvailable
// Returns remaining budget
// TransferAllowedFunds fails if target does not exist
TransferAllowedFunds(target AgentID, transfer ...*Allowance) *Allowance
// TransferAllowedFundsForceCreateTarget does not fail when target does not exist.
// If it is a random target, funds may be inaccessible (less safe)
TransferAllowedFundsForceCreateTarget(target AgentID, transfer ...*Allowance) *Allowance
// Send sends an on-ledger request (or a regular transaction to any L1 Address)
Send(metadata RequestParameters)
// SendAsNFT sends an on-ledger request as an NFTOutput
SendAsNFT(metadata RequestParameters, nftID iotago.NFTID)
// EstimateRequiredStorageDeposit returns the amount of base tokens needed to cover for a given request's storage deposit
EstimateRequiredStorageDeposit(r RequestParameters) uint64
// StateAnchor properties of the anchor output
StateAnchor() *StateAnchor
// Privileged is a sub-interface of the sandbox which should not be called by VM plugins
Privileged() Privileged
}
Sandbox is an interface given to the processor to access the VMContext and virtual state, transaction builder and request parameters through it.
type SandboxBase ¶
type SandboxBase interface {
Helpers
Balance
// Params returns the parameters of the current call
Params() *Params
// ChainID returns the chain ID
ChainID() *ChainID
// ChainOwnerID returns the AgentID of the current owner of the chain
ChainOwnerID() AgentID
// Contract returns the Hname of the current contract in the context
Contract() Hname
// AccountID returns the agentID of the current contract (i.e. chainID + contract hname)
AccountID() AgentID
// Timestamp returns the Unix timestamp of the current state in seconds
Timestamp() time.Time
// Log returns a logger that outputs on the local machine. It includes Panicf method
Log() LogInterface
// Utils provides access to common necessary functionality
Utils() Utils
// Gas returns sub-interface for gas related functions. It is stateful but does not modify chain's state
Gas() Gas
// GetNFTInfo returns information about a NFTID (issuer and metadata)
GetNFTData(nftID iotago.NFTID) NFT
// CallView calls another contract. Only calls view entry points
CallView(contractHname Hname, entryPoint Hname, params dict.Dict) dict.Dict
// StateR returns the immutable k/v store of the current call (in the context of the smart contract)
StateR() kv.KVStoreReader
}
SandboxBase is the common interface of Sandbox and SandboxView
type SandboxView ¶
type SandboxView interface {
SandboxBase
// Privileged is a sub-interface of the sandbox that should never be called by VM plugins
Privileged() PrivilegedView
}
SandboxView is an interface for read only call
type SendMetadata ¶
type SendMetadata struct {
TargetContract Hname
EntryPoint Hname
Params dict.Dict
Allowance *Allowance
GasBudget uint64
}
SendMetadata represents content of the data payload of the output
type SendOptions ¶
type SendOptions struct {
Timelock time.Time
Expiration *Expiration
}
type StateAnchor ¶
type StateAnchor struct {
ChainID ChainID
Sender iotago.Address
OutputID iotago.OutputID
IsOrigin bool
StateController iotago.Address
GovernanceController iotago.Address
StateIndex uint32
StateData []byte
Deposit uint64
NativeTokens iotago.NativeTokens
}
StateAnchor contains properties of the anchor output/transaction in the current context
type UnresolvedVMError ¶
type UnresolvedVMError struct {
ErrorCode VMErrorCode `json:"code"`
Params []interface{} `json:"params"`
Hash uint32 `json:"hash"`
}
func UnresolvedVMErrorFromMarshalUtil ¶
func UnresolvedVMErrorFromMarshalUtil(mu *marshalutil.MarshalUtil) (*UnresolvedVMError, error)
func (*UnresolvedVMError) AsGoError ¶
func (e *UnresolvedVMError) AsGoError() error
func (*UnresolvedVMError) Bytes ¶
func (e *UnresolvedVMError) Bytes() []byte
func (*UnresolvedVMError) Code ¶
func (e *UnresolvedVMError) Code() VMErrorCode
func (*UnresolvedVMError) Error ¶
func (e *UnresolvedVMError) Error() string
type UnsignedOffLedgerRequest ¶
type UnsignedOffLedgerRequest interface {
WithNonce(nonce uint64) UnsignedOffLedgerRequest
WithGasBudget(gasBudget uint64) UnsignedOffLedgerRequest
WithAllowance(allowance *Allowance) UnsignedOffLedgerRequest
Sign(key *cryptolib.KeyPair) OffLedgerRequest
}
func NewOffLedgerRequest ¶
type Utils ¶
Utils implement various utilities which are faster on host side than on wasm VM Implement deterministic stateless computations
type VMError ¶
type VMError struct {
// contains filtered or unexported fields
}
func (*VMError) AsTemplate ¶
func (e *VMError) AsTemplate() *VMErrorTemplate
func (*VMError) AsUnresolvedError ¶
func (e *VMError) AsUnresolvedError() *UnresolvedVMError
func (*VMError) Code ¶
func (e *VMError) Code() VMErrorCode
func (*VMError) MessageFormat ¶
type VMErrorBase ¶
type VMErrorBase interface {
error
Code() VMErrorCode
}
VMErrorBase is the common interface of UnresolvedVMError and VMError
type VMErrorCode ¶
func NewCoreVMErrorCode ¶
func NewCoreVMErrorCode(id uint16) VMErrorCode
func NewVMErrorCode ¶
func NewVMErrorCode(contractID Hname, id uint16) VMErrorCode
func VMErrorCodeFromBytes ¶
func VMErrorCodeFromBytes(b []byte) (code VMErrorCode, err error)
func VMErrorCodeFromMarshalUtil ¶
func VMErrorCodeFromMarshalUtil(mu *marshalutil.MarshalUtil) (code VMErrorCode, err error)
func (VMErrorCode) Bytes ¶
func (c VMErrorCode) Bytes() []byte
func (VMErrorCode) Serialize ¶
func (c VMErrorCode) Serialize(mu *marshalutil.MarshalUtil)
func (VMErrorCode) String ¶
func (c VMErrorCode) String() string
type VMErrorTemplate ¶
type VMErrorTemplate struct {
// contains filtered or unexported fields
}
func NewVMErrorTemplate ¶
func NewVMErrorTemplate(code VMErrorCode, messageFormat string) *VMErrorTemplate
func VMErrorTemplateFromMarshalUtil ¶
func VMErrorTemplateFromMarshalUtil(mu *marshalutil.MarshalUtil) (*VMErrorTemplate, error)
func (*VMErrorTemplate) Bytes ¶
func (e *VMErrorTemplate) Bytes() []byte
func (*VMErrorTemplate) Code ¶
func (e *VMErrorTemplate) Code() VMErrorCode
func (*VMErrorTemplate) Create ¶
func (e *VMErrorTemplate) Create(params ...interface{}) *VMError
func (*VMErrorTemplate) Error ¶
func (e *VMErrorTemplate) Error() string
VMErrorTemplate implements error just in case someone panics with VMErrorTemplate by mistake, so that we don't crash the VM because of that.
func (*VMErrorTemplate) MessageFormat ¶
func (e *VMErrorTemplate) MessageFormat() string
func (*VMErrorTemplate) Serialize ¶
func (e *VMErrorTemplate) Serialize(mu *marshalutil.MarshalUtil)
type VMProcessor ¶
type VMProcessor interface {
GetEntryPoint(code Hname) (VMProcessorEntryPoint, bool)
GetDescription() string
}
VMProcessor is an interface to the VM processor instance.
type VMProcessorEntryPoint ¶
VMProcessorEntryPoint is an abstract interface by which VM is called by passing the Sandbox interface
Source Files
¶
- addressutil.go
- agentid.go
- agentid_address.go
- agentid_contract.go
- agentid_eth.go
- agentid_nil.go
- allowance.go
- chainid.go
- doc.go
- ftokens.go
- hname.go
- iotago.go
- kvdecoder.go
- loginterface.go
- nft.go
- output.go
- receipt.go
- request.go
- request_evm.go
- request_target.go
- requestimpl.go
- sandbox_interface.go
- sandboxview_interface.go
- vmerror.go
- vmprocessor.go