Documentation ¶
Overview ¶
Package 'isc' defines fundamental types that are used in Wasp.
The core types are mostly based on the fundamental data types of Shimmer
Index ¶
- Constants
- Variables
- func AddressFromAgentID(a AgentID) (iotago.Address, bool)
- func AddressFromBytes(data []byte) (iotago.Address, error)
- func AddressFromReader(rr *rwutil.Reader) (address iotago.Address)
- func AddressToBytes(address iotago.Address) []byte
- func AddressToWriter(ww *rwutil.Writer, address iotago.Address)
- func AgentIDToWriter(ww *rwutil.Writer, agent AgentID)
- func GetErrorIDFromMessageFormat(messageFormat string) uint16
- func IsBaseToken(tokenID []byte) bool
- func IsEmptyOutputID(outputID iotago.OutputID) bool
- func IsOffledgerKind(b byte) bool
- func MustLogRequestsInTransaction(tx *iotago.Transaction, log func(msg string, args ...interface{}), ...)
- func MustNativeTokenIDFromBytes(data []byte) iotago.NativeTokenID
- func NativeTokenIDFromBytes(data []byte) (ret iotago.NativeTokenID, err error)
- func NativeTokenIDToBytes(tokenID iotago.NativeTokenID) []byte
- 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 RequestToJSON(req Request) ([]byte, error)
- func RequestsInTransaction(tx *iotago.Transaction) (map[ChainID][]Request, error)
- func VMErrorIs(err error, expected VMErrorBase) bool
- func VMErrorMustBe(err error, expected VMErrorBase)
- type AddressAgentID
- func (a *AddressAgentID) Address() iotago.Address
- func (a *AddressAgentID) BelongsToChain(ChainID) bool
- func (a *AddressAgentID) Bytes() []byte
- func (a *AddressAgentID) BytesWithoutChainID() []byte
- func (a *AddressAgentID) Equals(other AgentID) bool
- func (a *AddressAgentID) Kind() AgentIDKind
- func (a *AddressAgentID) Read(r io.Reader) error
- func (a *AddressAgentID) String() string
- func (a *AddressAgentID) Write(w io.Writer) error
- type AgentID
- type AgentIDKind
- type AgentIDWithL1Address
- type AliasOutputWithID
- func AliasOutputWithIDFromBytes(data []byte) (*AliasOutputWithID, error)
- func AliasOutputWithIDFromTx(tx *iotago.Transaction, aliasAddr iotago.Address) (*AliasOutputWithID, error)
- func NewAliasOutputWithID(aliasOutput *iotago.AliasOutput, outputID iotago.OutputID) *AliasOutputWithID
- func RandomAliasOutputWithID() *AliasOutputWithID
- func (a *AliasOutputWithID) Bytes() []byte
- func (a *AliasOutputWithID) Equals(other *AliasOutputWithID) bool
- 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) Hash() hashing.HashValue
- func (a *AliasOutputWithID) OutputID() iotago.OutputID
- func (a *AliasOutputWithID) Read(r io.Reader) error
- func (a *AliasOutputWithID) String() string
- func (a *AliasOutputWithID) TransactionID() iotago.TransactionID
- func (a *AliasOutputWithID) Write(w io.Writer) error
- type Assets
- func AssetsFromBytes(b []byte) (*Assets, error)
- func AssetsFromDict(d dict.Dict) (*Assets, error)
- func AssetsFromNativeTokenSum(baseTokens uint64, tokens iotago.NativeTokenSum) *Assets
- func AssetsFromOutput(o iotago.Output) *Assets
- func AssetsFromOutputMap(outs map[iotago.OutputID]iotago.Output) *Assets
- func MustAssetsFromBytes(b []byte) *Assets
- func NewAssets(baseTokens uint64, tokens iotago.NativeTokens, nfts ...iotago.NFTID) *Assets
- func NewAssetsBaseTokens(amount uint64) *Assets
- func NewEmptyAssets() *Assets
- func (a *Assets) Add(b *Assets) *Assets
- func (a *Assets) AddBaseTokens(amount uint64) *Assets
- func (a *Assets) AddNFTs(nfts ...iotago.NFTID) *Assets
- func (a *Assets) AddNativeTokens(nativeTokenID iotago.NativeTokenID, amount interface{}) *Assets
- func (a *Assets) AmountNativeToken(nativeTokenID iotago.NativeTokenID) *big.Int
- func (a *Assets) Bytes() []byte
- func (a *Assets) Clone() *Assets
- func (a *Assets) Equals(b *Assets) bool
- func (a *Assets) IsEmpty() bool
- func (a *Assets) NFTSet() map[iotago.NFTID]bool
- func (a *Assets) Read(r io.Reader) error
- func (a *Assets) Spend(toSpend *Assets) bool
- func (a *Assets) String() string
- func (a *Assets) ToDict() dict.Dict
- func (a *Assets) Write(w io.Writer) error
- type AssetsJSON
- type Authorize
- type BLS
- type Balance
- type CallTarget
- type CallTargetJSON
- type Calldata
- type ChainID
- func ChainIDFromAddress(addr *iotago.AliasAddress) ChainID
- func ChainIDFromAliasID(aliasID iotago.AliasID) ChainID
- func ChainIDFromBytes(data []byte) (ret ChainID, err error)
- func ChainIDFromKey(key ChainIDKey) ChainID
- func ChainIDFromString(bech32 string) (ChainID, error)
- func EmptyChainID() ChainID
- func RandomChainID(seed ...[]byte) ChainID
- func (id ChainID) AsAddress() iotago.Address
- func (id ChainID) AsAliasAddress() iotago.AliasAddress
- func (id ChainID) AsAliasID() iotago.AliasID
- func (id ChainID) Bytes() []byte
- func (id ChainID) Empty() bool
- func (id ChainID) Equals(other ChainID) bool
- func (id ChainID) IsSameChain(agentID AgentID) bool
- func (id ChainID) Key() ChainIDKey
- func (id *ChainID) Read(r io.Reader) error
- func (id ChainID) ShortString() string
- func (id ChainID) String() string
- func (id *ChainID) Write(w io.Writer) error
- type ChainIDKey
- type ChainInfo
- type ContractAgentID
- func (a *ContractAgentID) Address() iotago.Address
- func (a *ContractAgentID) BelongsToChain(cID ChainID) bool
- func (a *ContractAgentID) Bytes() []byte
- func (a *ContractAgentID) BytesWithoutChainID() []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) Read(r io.Reader) error
- func (a *ContractAgentID) String() string
- func (a *ContractAgentID) Write(w io.Writer) error
- type ContractIdentity
- func (c *ContractIdentity) AgentID(chainID ChainID) AgentID
- func (c *ContractIdentity) EVMAddress() (common.Address, error)
- func (c *ContractIdentity) Empty() bool
- func (c *ContractIdentity) Hname() (Hname, error)
- func (c *ContractIdentity) Read(r io.Reader) error
- func (c *ContractIdentity) String() string
- func (c *ContractIdentity) Write(w io.Writer) error
- type ControlAddresses
- type CoreCallbackFunc
- type ED25519
- type EVMCallData
- type EVMTracer
- type EthereumAddressAgentID
- func (a *EthereumAddressAgentID) BelongsToChain(cID ChainID) bool
- func (a *EthereumAddressAgentID) Bytes() []byte
- func (a *EthereumAddressAgentID) BytesWithoutChainID() []byte
- func (a *EthereumAddressAgentID) ChainID() ChainID
- func (a *EthereumAddressAgentID) Equals(other AgentID) bool
- func (a *EthereumAddressAgentID) EthAddress() common.Address
- func (a *EthereumAddressAgentID) Kind() AgentIDKind
- func (a *EthereumAddressAgentID) Read(r io.Reader) error
- func (a *EthereumAddressAgentID) String() string
- func (a *EthereumAddressAgentID) Write(w io.Writer) error
- type Event
- type EventJSON
- type Expiration
- type Features
- type Gas
- type Hashing
- type Helpers
- type Hname
- type IRC27NFTMetadata
- type KVDecoder
- type LogInterface
- type NFT
- type NFTJSON
- type NativeTokenJSON
- type NilAgentID
- func (a *NilAgentID) BelongsToChain(cID ChainID) bool
- func (a *NilAgentID) Bytes() []byte
- func (a *NilAgentID) BytesWithoutChainID() []byte
- func (a *NilAgentID) Equals(other AgentID) bool
- func (a *NilAgentID) Kind() AgentIDKind
- func (a *NilAgentID) Read(r io.Reader) error
- func (a *NilAgentID) String() string
- func (a *NilAgentID) Write(w io.Writer) error
- type OffLedgerRequest
- type OffLedgerRequestData
- func (req *OffLedgerRequestData) Allowance() *Assets
- func (req *OffLedgerRequestData) Assets() *Assets
- func (req *OffLedgerRequestData) Bytes() []byte
- func (req *OffLedgerRequestData) CallTarget() CallTarget
- func (req *OffLedgerRequestData) ChainID() ChainID
- func (req *OffLedgerRequestData) EVMCallData() *EVMCallData
- func (*OffLedgerRequestData) EVMTransaction() *types.Transaction
- func (req *OffLedgerRequestData) EssenceBytes() []byte
- func (req *OffLedgerRequestData) Expiry() (time.Time, iotago.Address)
- func (req *OffLedgerRequestData) GasBudget() (gasBudget uint64, isEVM bool)
- func (req *OffLedgerRequestData) ID() (requestID RequestID)
- func (req *OffLedgerRequestData) IsOffLedger() bool
- func (req *OffLedgerRequestData) NFT() *NFT
- func (req *OffLedgerRequestData) Nonce() uint64
- func (req *OffLedgerRequestData) Params() dict.Dict
- func (req *OffLedgerRequestData) Read(r io.Reader) error
- func (req *OffLedgerRequestData) ReturnAmount() (uint64, bool)
- func (req *OffLedgerRequestData) SenderAccount() AgentID
- func (req *OffLedgerRequestData) Sign(key *cryptolib.KeyPair) OffLedgerRequest
- func (req *OffLedgerRequestData) String() string
- func (req *OffLedgerRequestData) TargetAddress() iotago.Address
- func (req *OffLedgerRequestData) TimeLock() time.Time
- func (req *OffLedgerRequestData) Timestamp() time.Time
- func (req *OffLedgerRequestData) TxValue() *big.Int
- func (req *OffLedgerRequestData) VerifySignature() error
- func (req *OffLedgerRequestData) WithAllowance(allowance *Assets) UnsignedOffLedgerRequest
- func (req *OffLedgerRequestData) WithGasBudget(gasBudget uint64) UnsignedOffLedgerRequest
- func (req *OffLedgerRequestData) WithNonce(nonce uint64) UnsignedOffLedgerRequest
- func (req *OffLedgerRequestData) WithSender(sender *cryptolib.PublicKey) UnsignedOffLedgerRequest
- func (req *OffLedgerRequestData) Write(w io.Writer) error
- type OnLedgerRequest
- type OutputInfo
- type Params
- type Privileged
- type ProcessorEntryPoint
- type PublicChainMetadata
- type Receipt
- type Request
- type RequestID
- func (rid RequestID) Bytes() []byte
- func (rid RequestID) Equals(other RequestID) bool
- func (rid RequestID) LookupDigest() RequestLookupDigest
- func (rid RequestID) OutputID() iotago.OutputID
- func (rid *RequestID) Read(r io.Reader) error
- func (rid RequestID) Short() string
- func (rid RequestID) String() string
- func (rid *RequestID) Write(w io.Writer) error
- type RequestJSON
- type RequestKind
- type RequestLookupDigest
- type RequestMetadata
- type RequestParameters
- type RequestRef
- type RequestRefKey
- type RetryOnLedgerRequest
- type ReturnAmountOptions
- type Sandbox
- type SandboxBase
- type SandboxView
- type SendMetadata
- type SendOptions
- type StateAnchor
- type UnresolvedVMError
- func (e *UnresolvedVMError) AsGoError() error
- func (e *UnresolvedVMError) Bytes() []byte
- func (e *UnresolvedVMError) Code() VMErrorCode
- func (e *UnresolvedVMError) Error() string
- func (e *UnresolvedVMError) Read(r io.Reader) error
- func (e *UnresolvedVMError) ToJSONStruct() *UnresolvedVMErrorJSON
- func (e *UnresolvedVMError) Write(w io.Writer) error
- type UnresolvedVMErrorJSON
- 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) MessageFormat() string
- func (e *VMError) Params() []any
- func (e *VMError) Read(r io.Reader) error
- func (e *VMError) Write(w io.Writer) error
- type VMErrorBase
- type VMErrorCode
- type VMErrorTemplate
- func (e *VMErrorTemplate) Bytes() []byte
- func (e *VMErrorTemplate) Code() VMErrorCode
- func (e *VMErrorTemplate) Create(params ...any) *VMError
- func (e *VMErrorTemplate) Error() string
- func (e *VMErrorTemplate) MessageFormat() string
- func (e *VMErrorTemplate) Read(r io.Reader) error
- func (e *VMErrorTemplate) Write(w io.Writer) error
- type VMProcessor
- type VMProcessorEntryPoint
Constants ¶
const AgentIDStringSeparator = "@"
const ChainIDLength = iotago.AliasIDLength
const FuncInit = "init"
FuncInit is a name of the init function for any smart contract
const HnameLength = 4
const HnameNil = Hname(0)
HnameNil is the value used to represent a non-existent Hname.
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 RequestRefKeyLen = iotago.OutputIDLength + 32
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
Functions ¶
func AddressFromAgentID ¶
AddressFromAgentID returns the L1 address of the AgentID, if applicable.
func AddressFromReader ¶ added in v1.0.3
func AddressToBytes ¶ added in v1.0.3
func AddressToWriter ¶ added in v1.0.3
func AgentIDToWriter ¶ added in v1.0.3
func IsBaseToken ¶
IsBaseToken return whether a given tokenID represents the base token
func IsEmptyOutputID ¶ added in v1.0.3
func IsOffledgerKind ¶ added in v1.0.3
func MustLogRequestsInTransaction ¶ added in v1.0.3
func MustLogRequestsInTransaction(tx *iotago.Transaction, log func(msg string, args ...interface{}), prefix string)
func MustNativeTokenIDFromBytes ¶
func MustNativeTokenIDFromBytes(data []byte) iotago.NativeTokenID
func NativeTokenIDFromBytes ¶
func NativeTokenIDFromBytes(data []byte) (ret iotago.NativeTokenID, err error)
func NativeTokenIDToBytes ¶ added in v1.0.3
func NativeTokenIDToBytes(tokenID iotago.NativeTokenID) []byte
func RequestHash ¶
func RequestIsExpired ¶
func RequestIsExpired(req OnLedgerRequest, currentTime time.Time) bool
func RequestIsUnlockable ¶
func RequestToJSON ¶ added in v1.0.3
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 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 NewAddressAgentID ¶ added in v1.0.3
func NewAddressAgentID(addr iotago.Address) *AddressAgentID
func (*AddressAgentID) Address ¶
func (a *AddressAgentID) Address() iotago.Address
func (*AddressAgentID) BelongsToChain ¶ added in v1.0.3
func (a *AddressAgentID) BelongsToChain(ChainID) bool
func (*AddressAgentID) Bytes ¶
func (a *AddressAgentID) Bytes() []byte
func (*AddressAgentID) BytesWithoutChainID ¶ added in v1.0.3
func (a *AddressAgentID) BytesWithoutChainID() []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 { Bytes() []byte BelongsToChain(ChainID) bool BytesWithoutChainID() []byte Equals(other AgentID) bool Kind() AgentIDKind Read(r io.Reader) error String() string Write(w io.Writer) error }
AgentID represents any entity that can hold assets on L2 and/or call contracts.
func AgentIDFromBytes ¶
func AgentIDFromReader ¶ added in v1.0.3
func AgentIDFromString ¶ added in v1.0.3
AgentIDFromString parses the human-readable string representation
func NewAgentID ¶
NewAgentID creates an AddressAgentID if the address is not an AliasAddress; otherwise a ContractAgentID with hname = HnameNil.
type AgentIDKind ¶
const ( AgentIDKindNil AgentIDKind = iota AgentIDKindAddress AgentIDKindContract AgentIDKindEthereumAddress AgentIDIsNil AgentIDKind = 0x80 )
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 AliasOutputWithIDFromBytes ¶ added in v1.0.3
func AliasOutputWithIDFromBytes(data []byte) (*AliasOutputWithID, error)
func AliasOutputWithIDFromTx ¶ added in v1.0.3
func AliasOutputWithIDFromTx(tx *iotago.Transaction, aliasAddr iotago.Address) (*AliasOutputWithID, error)
func NewAliasOutputWithID ¶
func NewAliasOutputWithID(aliasOutput *iotago.AliasOutput, outputID iotago.OutputID) *AliasOutputWithID
func RandomAliasOutputWithID ¶ added in v1.0.3
func RandomAliasOutputWithID() *AliasOutputWithID
only for testing
func (*AliasOutputWithID) Bytes ¶ added in v1.0.3
func (a *AliasOutputWithID) Bytes() []byte
func (*AliasOutputWithID) Equals ¶ added in v1.0.3
func (a *AliasOutputWithID) Equals(other *AliasOutputWithID) bool
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) Hash ¶ added in v1.0.3
func (a *AliasOutputWithID) Hash() hashing.HashValue
func (*AliasOutputWithID) OutputID ¶
func (a *AliasOutputWithID) OutputID() iotago.OutputID
func (*AliasOutputWithID) Read ¶ added in v1.0.3
func (a *AliasOutputWithID) Read(r io.Reader) error
func (*AliasOutputWithID) String ¶ added in v1.0.3
func (a *AliasOutputWithID) String() string
func (*AliasOutputWithID) TransactionID ¶ added in v1.0.3
func (a *AliasOutputWithID) TransactionID() iotago.TransactionID
type Assets ¶ added in v1.0.3
type Assets struct { BaseTokens uint64 `json:"baseTokens"` NativeTokens iotago.NativeTokens `json:"nativeTokens"` NFTs []iotago.NFTID `json:"nfts"` }
func AssetsFromBytes ¶ added in v1.0.3
func AssetsFromNativeTokenSum ¶ added in v1.0.3
func AssetsFromNativeTokenSum(baseTokens uint64, tokens iotago.NativeTokenSum) *Assets
func AssetsFromOutput ¶ added in v1.0.3
func AssetsFromOutputMap ¶ added in v1.0.3
func MustAssetsFromBytes ¶ added in v1.0.3
func NewAssetsBaseTokens ¶ added in v1.0.3
func NewEmptyAssets ¶
func NewEmptyAssets() *Assets
func (*Assets) AddBaseTokens ¶ added in v1.0.3
func (*Assets) AddNativeTokens ¶ added in v1.0.3
func (a *Assets) AddNativeTokens(nativeTokenID iotago.NativeTokenID, amount interface{}) *Assets
func (*Assets) AmountNativeToken ¶ added in v1.0.3
func (a *Assets) AmountNativeToken(nativeTokenID iotago.NativeTokenID) *big.Int
type AssetsJSON ¶ added in v1.0.3
type AssetsJSON struct { BaseTokens string `json:"baseTokens" swagger:"required,desc(The base tokens (uint64 as string))"` NativeTokens []*NativeTokenJSON `json:"nativeTokens" swagger:"required"` NFTs []string `json:"nfts" swagger:"required"` }
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(iotago.NativeTokenID) *big.Int // BalanceNativeTokens returns all native tokens owned by the smart contract BalanceNativeTokens() iotago.NativeTokens // 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, *Assets) 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 CallTargetJSON ¶ added in v1.0.3
type Calldata ¶
type Calldata interface { Allowance() *Assets // transfer of assets to the smart contract. Debited from sender account Assets() *Assets // attached assets for the UTXO request, nil for off-ledger. All goes to sender CallTarget() CallTarget GasBudget() (gas uint64, isEVM bool) ID() RequestID NFT() *NFT // Not nil if the request is an NFT request Params() dict.Dict SenderAccount() AgentID TargetAddress() iotago.Address // TODO implement properly. Target depends on time assumptions and UTXO type TxValue() *big.Int EVMCallData() *EVMCallData }
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 ChainIDFromKey ¶ added in v1.0.3
func ChainIDFromKey(key ChainIDKey) ChainID
func ChainIDFromString ¶
func EmptyChainID ¶ added in v1.0.3
func EmptyChainID() ChainID
EmptyChainID returns an empty ChainID.
func RandomChainID ¶
RandomChainID creates a random chain ID. Used for testing only
func (ChainID) AsAliasAddress ¶
func (id ChainID) AsAliasAddress() iotago.AliasAddress
func (ChainID) IsSameChain ¶
func (ChainID) Key ¶
func (id ChainID) Key() ChainIDKey
func (ChainID) ShortString ¶ added in v1.0.3
type ChainIDKey ¶ added in v1.0.3
type ChainIDKey string
ChainID represents the global identifier of the chain It is wrapped AliasAddress, an address without a private key behind
type ChainInfo ¶ added in v1.0.3
type ChainInfo struct { ChainID ChainID ChainOwnerID AgentID GasFeePolicy *gas.FeePolicy GasLimits *gas.Limits BlockKeepAmount int32 PublicURL string Metadata *PublicChainMetadata }
ChainInfo is an API structure containing the main parameters of the chain
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) BelongsToChain ¶ added in v1.0.3
func (a *ContractAgentID) BelongsToChain(cID ChainID) bool
func (*ContractAgentID) Bytes ¶
func (a *ContractAgentID) Bytes() []byte
func (*ContractAgentID) BytesWithoutChainID ¶ added in v1.0.3
func (a *ContractAgentID) BytesWithoutChainID() []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 ContractIdentity ¶ added in v1.0.3
type ContractIdentity struct {
// contains filtered or unexported fields
}
func ContractIdentityFromEVMAddress ¶ added in v1.0.3
func ContractIdentityFromEVMAddress(addr common.Address) ContractIdentity
func ContractIdentityFromHname ¶ added in v1.0.3
func ContractIdentityFromHname(hn Hname) ContractIdentity
func EmptyContractIdentity ¶ added in v1.0.3
func EmptyContractIdentity() ContractIdentity
func (*ContractIdentity) AgentID ¶ added in v1.0.3
func (c *ContractIdentity) AgentID(chainID ChainID) AgentID
func (*ContractIdentity) EVMAddress ¶ added in v1.0.3
func (c *ContractIdentity) EVMAddress() (common.Address, error)
func (*ContractIdentity) Empty ¶ added in v1.0.3
func (c *ContractIdentity) Empty() bool
func (*ContractIdentity) Hname ¶ added in v1.0.3
func (c *ContractIdentity) Hname() (Hname, error)
func (*ContractIdentity) String ¶ added in v1.0.3
func (c *ContractIdentity) String() string
type ControlAddresses ¶ added in v1.0.3
type CoreCallbackFunc ¶ added in v1.0.3
type EVMCallData ¶ added in v1.0.3
func EVMCallDataFromCallMsg ¶ added in v1.0.3
func EVMCallDataFromCallMsg(msg ethereum.CallMsg) *EVMCallData
func EVMCallDataFromTx ¶ added in v1.0.3
func EVMCallDataFromTx(tx *types.Transaction) *EVMCallData
type EthereumAddressAgentID ¶
type EthereumAddressAgentID struct {
// contains filtered or unexported fields
}
EthereumAddressAgentID is an AgentID formed by an Ethereum address
func NewEthereumAddressAgentID ¶
func NewEthereumAddressAgentID(chainID ChainID, eth common.Address) *EthereumAddressAgentID
func (*EthereumAddressAgentID) BelongsToChain ¶ added in v1.0.3
func (a *EthereumAddressAgentID) BelongsToChain(cID ChainID) bool
func (*EthereumAddressAgentID) Bytes ¶
func (a *EthereumAddressAgentID) Bytes() []byte
func (*EthereumAddressAgentID) BytesWithoutChainID ¶ added in v1.0.3
func (a *EthereumAddressAgentID) BytesWithoutChainID() []byte
func (*EthereumAddressAgentID) ChainID ¶ added in v1.0.3
func (a *EthereumAddressAgentID) ChainID() ChainID
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) Read ¶ added in v1.0.3
func (a *EthereumAddressAgentID) Read(r io.Reader) error
func (*EthereumAddressAgentID) String ¶
func (a *EthereumAddressAgentID) String() string
type Event ¶ added in v1.0.3
type Event struct { ContractID Hname `json:"contractID"` Topic string `json:"topic"` Timestamp uint64 `json:"timestamp"` Payload []byte `json:"payload"` }
func EventFromBytes ¶ added in v1.0.3
func (*Event) ToJSONStruct ¶ added in v1.0.3
type EventJSON ¶ added in v1.0.3
type EventJSON struct { ContractID Hname `json:"contractID" swagger:"desc(ID of the Contract that issued the event),required,min(1)"` Topic string `json:"topic" swagger:"desc(topic),required"` Timestamp uint64 `json:"timestamp" swagger:"desc(timestamp),required"` Payload string `json:"payload" swagger:"desc(payload),required"` }
type Features ¶
type Features interface { // 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) // TimeLock returns the timelock feature, or a zero time if not present TimeLock() time.Time }
type Hname ¶
type Hname uint32
Hname is calculated as the first 4 bytes of the BLAKE2b hash of a string, interpreted as a little-endian uint32.
func ContractIDFromEventBytes ¶ added in v1.0.3
ContractIDFromEventBytes is used by blocklog to filter out specific events per contract For performance reasons it is working directly with the event bytes.
func Hn ¶
Hn calculates the hname for the given string. For any given string s, it is guaranteed that Hn(s) != HnameNil.
func HnameFromAgentID ¶
HnameFromAgentID returns the hname of the AgentID, or HnameNil if not applicable.
func HnameFromBytes ¶
func HnameFromString ¶
type IRC27NFTMetadata ¶ added in v1.0.3
type IRC27NFTMetadata struct { Standard string `json:"standard"` Version string `json:"version"` MIMEType string `json:"type"` URI string `json:"uri"` Name string `json:"name"` }
IRC27NFTMetadata represents an NFT metadata according to IRC27. See: https://github.com/iotaledger/tips/blob/main/tips/TIP-0027/tip-0027.md
func IRC27NFTMetadataFromBytes ¶ added in v1.0.3
func IRC27NFTMetadataFromBytes(b []byte) (*IRC27NFTMetadata, error)
func NewIRC27NFTMetadata ¶ added in v1.0.3
func NewIRC27NFTMetadata(mimeType, uri, name string) *IRC27NFTMetadata
func (*IRC27NFTMetadata) Bytes ¶ added in v1.0.3
func (m *IRC27NFTMetadata) Bytes() []byte
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 GetNFTID(key kv.Key, def ...iotago.NFTID) (iotago.NFTID, error) MustGetNFTID(key kv.Key, def ...iotago.NFTID) iotago.NFTID }
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 NFTFromBytes ¶
type NFTJSON ¶ added in v1.0.3
type NFTJSON struct { ID string `json:"id" swagger:"required"` Issuer string `json:"issuer" swagger:"required"` Metadata string `json:"metadata" swagger:"required"` Owner string `json:"owner" swagger:"required"` }
func NFTToJSONObject ¶ added in v1.0.3
type NativeTokenJSON ¶ added in v1.0.3
type NativeTokenJSON struct { ID string `json:"id" swagger:"required"` Amount string `json:"amount" swagger:"required"` }
func NativeTokenToJSONObject ¶ added in v1.0.3
func NativeTokenToJSONObject(token *iotago.NativeToken) *NativeTokenJSON
func NativeTokensToJSONObject ¶ added in v1.0.3
func NativeTokensToJSONObject(tokens iotago.NativeTokens) []*NativeTokenJSON
type NilAgentID ¶
type NilAgentID struct{}
func (*NilAgentID) BelongsToChain ¶ added in v1.0.3
func (a *NilAgentID) BelongsToChain(cID ChainID) bool
func (*NilAgentID) Bytes ¶
func (a *NilAgentID) Bytes() []byte
func (*NilAgentID) BytesWithoutChainID ¶ added in v1.0.3
func (a *NilAgentID) BytesWithoutChainID() []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 ChainID() ChainID Nonce() uint64 VerifySignature() error EVMTransaction() *types.Transaction }
func NewEVMOffLedgerCallRequest ¶ added in v1.0.3
func NewEVMOffLedgerCallRequest(chainID ChainID, callMsg ethereum.CallMsg) OffLedgerRequest
func NewEVMOffLedgerTxRequest ¶ added in v1.0.3
func NewEVMOffLedgerTxRequest(chainID ChainID, tx *types.Transaction) (OffLedgerRequest, error)
type OffLedgerRequestData ¶
type OffLedgerRequestData struct {
// contains filtered or unexported fields
}
func (*OffLedgerRequestData) Allowance ¶ added in v1.0.3
func (req *OffLedgerRequestData) Allowance() *Assets
Allowance from the sender's account to the target smart contract. Nil mean no Allowance
func (*OffLedgerRequestData) Assets ¶ added in v1.0.3
func (req *OffLedgerRequestData) Assets() *Assets
Assets is attached assets to the UTXO. Nil for off-ledger
func (*OffLedgerRequestData) Bytes ¶ added in v1.0.3
func (req *OffLedgerRequestData) Bytes() []byte
func (*OffLedgerRequestData) CallTarget ¶ added in v1.0.3
func (req *OffLedgerRequestData) CallTarget() CallTarget
func (*OffLedgerRequestData) ChainID ¶
func (req *OffLedgerRequestData) ChainID() ChainID
func (*OffLedgerRequestData) EVMCallData ¶ added in v1.0.3
func (req *OffLedgerRequestData) EVMCallData() *EVMCallData
func (*OffLedgerRequestData) EVMTransaction ¶ added in v1.0.3
func (*OffLedgerRequestData) EVMTransaction() *types.Transaction
func (*OffLedgerRequestData) EssenceBytes ¶ added in v1.0.3
func (req *OffLedgerRequestData) EssenceBytes() []byte
func (*OffLedgerRequestData) Expiry ¶ added in v1.0.3
func (req *OffLedgerRequestData) Expiry() (time.Time, iotago.Address)
func (*OffLedgerRequestData) GasBudget ¶ added in v1.0.3
func (req *OffLedgerRequestData) GasBudget() (gasBudget uint64, isEVM bool)
func (*OffLedgerRequestData) ID ¶ added in v1.0.3
func (req *OffLedgerRequestData) ID() (requestID RequestID)
ID returns request id for this request index part of request id is always 0 for off ledger requests note that request needs to have been signed before this value is considered valid
func (*OffLedgerRequestData) IsOffLedger ¶ added in v1.0.3
func (req *OffLedgerRequestData) IsOffLedger() bool
func (*OffLedgerRequestData) NFT ¶ added in v1.0.3
func (req *OffLedgerRequestData) NFT() *NFT
func (*OffLedgerRequestData) Nonce ¶
func (req *OffLedgerRequestData) Nonce() uint64
Nonce incremental nonce used for replay protection
func (*OffLedgerRequestData) Params ¶ added in v1.0.3
func (req *OffLedgerRequestData) Params() dict.Dict
func (*OffLedgerRequestData) Read ¶ added in v1.0.3
func (req *OffLedgerRequestData) Read(r io.Reader) error
func (*OffLedgerRequestData) ReturnAmount ¶ added in v1.0.3
func (req *OffLedgerRequestData) ReturnAmount() (uint64, bool)
func (*OffLedgerRequestData) SenderAccount ¶ added in v1.0.3
func (req *OffLedgerRequestData) SenderAccount() AgentID
func (*OffLedgerRequestData) Sign ¶ added in v1.0.3
func (req *OffLedgerRequestData) Sign(key *cryptolib.KeyPair) OffLedgerRequest
Sign signs the essence
func (*OffLedgerRequestData) String ¶ added in v1.0.3
func (req *OffLedgerRequestData) String() string
func (*OffLedgerRequestData) TargetAddress ¶ added in v1.0.3
func (req *OffLedgerRequestData) TargetAddress() iotago.Address
func (*OffLedgerRequestData) TimeLock ¶ added in v1.0.3
func (req *OffLedgerRequestData) TimeLock() time.Time
func (*OffLedgerRequestData) Timestamp ¶ added in v1.0.3
func (req *OffLedgerRequestData) Timestamp() time.Time
func (*OffLedgerRequestData) TxValue ¶ added in v1.0.3
func (req *OffLedgerRequestData) TxValue() *big.Int
func (*OffLedgerRequestData) VerifySignature ¶ added in v1.0.3
func (req *OffLedgerRequestData) VerifySignature() error
VerifySignature verifies essence signature
func (*OffLedgerRequestData) WithAllowance ¶ added in v1.0.3
func (req *OffLedgerRequestData) WithAllowance(allowance *Assets) UnsignedOffLedgerRequest
func (*OffLedgerRequestData) WithGasBudget ¶ added in v1.0.3
func (req *OffLedgerRequestData) WithGasBudget(gasBudget uint64) UnsignedOffLedgerRequest
func (*OffLedgerRequestData) WithNonce ¶ added in v1.0.3
func (req *OffLedgerRequestData) WithNonce(nonce uint64) UnsignedOffLedgerRequest
func (*OffLedgerRequestData) WithSender ¶ added in v1.0.3
func (req *OffLedgerRequestData) WithSender(sender *cryptolib.PublicKey) UnsignedOffLedgerRequest
WithSender can be used to estimate gas, without a signature
type OnLedgerRequest ¶
type OnLedgerRequest interface { Request Clone() OnLedgerRequest Output() iotago.Output IsInternalUTXO(ChainID) bool OutputID() iotago.OutputID Features() Features }
func OnLedgerFromUTXO ¶
type OutputInfo ¶ added in v1.0.3
type OutputInfo struct { OutputID iotago.OutputID Output iotago.Output TransactionIDSpent iotago.TransactionID }
func NewOutputInfo ¶ added in v1.0.3
func NewOutputInfo(outputID iotago.OutputID, output iotago.Output, transactionIDSpent iotago.TransactionID) *OutputInfo
func (*OutputInfo) AliasOutputWithID ¶ added in v1.0.3
func (o *OutputInfo) AliasOutputWithID() *AliasOutputWithID
func (*OutputInfo) Consumed ¶ added in v1.0.3
func (o *OutputInfo) Consumed() bool
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 MintNFT(addr iotago.Address, immutableMetadata []byte, issuer iotago.Address) (uint16, *iotago.NFTOutput) GasBurnEnable(enable bool) GasBurnEnabled() bool MustMoveBetweenAccounts(fromAgentID, toAgentID AgentID, assets *Assets) DebitFromAccount(AgentID, *Assets) CreditToAccount(AgentID, *Assets) RetryUnprocessable(req Request, outputID iotago.OutputID) OnWriteReceipt(CoreCallbackFunc) CallOnBehalfOf(caller AgentID, target, entryPoint Hname, params dict.Dict, allowance *Assets) dict.Dict SendOnBehalfOf(caller ContractIdentity, metadata RequestParameters) }
Privileged is a sub-interface for core contracts. Should not be called by VM plugins
type ProcessorEntryPoint ¶ added in v1.0.3
type ProcessorEntryPoint interface { VMProcessorEntryPoint Name() string Hname() Hname }
type PublicChainMetadata ¶ added in v1.0.3
type PublicChainMetadata struct { EVMJsonRPCURL string EVMWebSocketURL string Name string Description string Website string }
func PublicChainMetadataFromBytes ¶ added in v1.0.3
func PublicChainMetadataFromBytes(data []byte) (*PublicChainMetadata, error)
func (*PublicChainMetadata) Bytes ¶ added in v1.0.3
func (m *PublicChainMetadata) Bytes() []byte
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"` SDCharged uint64 `json:"storageDepositCharged"` 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 Bytes() []byte IsOffLedger() bool String() string Read(r io.Reader) error Write(w io.Writer) error }
Request wraps any data which can be potentially be interpreted as a request
func RequestFromBytes ¶ added in v1.0.3
func RequestFromReader ¶ added in v1.0.3
type RequestID ¶
func NewRequestID ¶
func NewRequestID(txid iotago.TransactionID, index uint16) RequestID
func RequestIDFromBytes ¶
func RequestIDFromEVMTxHash ¶ added in v1.0.3
func RequestIDFromString ¶
func (RequestID) LookupDigest ¶
func (rid RequestID) LookupDigest() RequestLookupDigest
type RequestJSON ¶ added in v1.0.3
type RequestJSON struct { Allowance *AssetsJSON `json:"allowance" swagger:"required"` CallTarget CallTargetJSON `json:"callTarget" swagger:"required"` Assets *AssetsJSON `json:"fungibleTokens" swagger:"required"` GasBudget string `json:"gasBudget,string" swagger:"required,desc(The gas budget (uint64 as string))"` IsEVM bool `json:"isEVM" swagger:"required"` IsOffLedger bool `json:"isOffLedger" swagger:"required"` NFT *NFTJSON `json:"nft" swagger:"required"` Params dict.JSONDict `json:"params" swagger:"required"` RequestID string `json:"requestId" swagger:"required"` SenderAccount string `json:"senderAccount" swagger:"required"` TargetAddress string `json:"targetAddress" swagger:"required"` }
func RequestToJSONObject ¶ added in v1.0.3
func RequestToJSONObject(request Request) RequestJSON
type RequestKind ¶ added in v1.0.3
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 ContractIdentity `json:"senderContract"` // ID of the target smart contract TargetContract Hname `json:"targetContract"` // entry point code EntryPoint Hname `json:"entryPoint"` // request arguments Params dict.Dict `json:"params"` // Allowance intended to the target contract to take. Nil means zero allowance Allowance *Assets `json:"allowance"` // gas budget GasBudget uint64 `json:"gasBudget"` }
func RequestMetadataFromBytes ¶
func RequestMetadataFromBytes(data []byte) (*RequestMetadata, error)
func (*RequestMetadata) Bytes ¶
func (meta *RequestMetadata) Bytes() []byte
func (*RequestMetadata) Clone ¶ added in v1.0.3
func (meta *RequestMetadata) Clone() *RequestMetadata
returns nil if nil pointer receiver is cloned
type RequestParameters ¶
type RequestParameters struct { // TargetAddress is the target address. It may represent another chain or L1 address TargetAddress iotago.Address // Assets 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 Assets *Assets // 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 RequestRef ¶ added in v1.0.3
func RequestRefFromBytes ¶ added in v1.0.3
func RequestRefFromBytes(data []byte) (*RequestRef, error)
func RequestRefFromRequest ¶ added in v1.0.3
func RequestRefFromRequest(req Request) *RequestRef
func RequestRefsFromRequests ¶ added in v1.0.3
func RequestRefsFromRequests(reqs []Request) []*RequestRef
func (*RequestRef) AsKey ¶ added in v1.0.3
func (ref *RequestRef) AsKey() RequestRefKey
func (*RequestRef) Bytes ¶ added in v1.0.3
func (ref *RequestRef) Bytes() []byte
func (*RequestRef) IsFor ¶ added in v1.0.3
func (ref *RequestRef) IsFor(req Request) bool
func (*RequestRef) String ¶ added in v1.0.3
func (ref *RequestRef) String() string
type RequestRefKey ¶ added in v1.0.3
type RequestRefKey [RequestRefKeyLen]byte
func (RequestRefKey) String ¶ added in v1.0.3
func (rrk RequestRefKey) String() string
type RetryOnLedgerRequest ¶ added in v1.0.3
type RetryOnLedgerRequest struct { OnLedgerRequest // contains filtered or unexported fields }
func NewRetryOnLedgerRequest ¶ added in v1.0.3
func NewRetryOnLedgerRequest(req OnLedgerRequest, retryOutput iotago.OutputID) *RetryOnLedgerRequest
func (*RetryOnLedgerRequest) RetryOutputID ¶ added in v1.0.3
func (r *RetryOnLedgerRequest) RetryOutputID() iotago.OutputID
func (*RetryOnLedgerRequest) SetRetryOutputID ¶ added in v1.0.3
func (r *RetryOnLedgerRequest) SetRetryOutputID(oid iotago.OutputID)
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 *Assets) dict.Dict // DeployContract deploys contract on the same chain. 'initParams' are passed to the 'init' entry point DeployContract(programHash hashing.HashValue, name string, initParams dict.Dict) // Event emits an event Event(topic string, payload []byte) // 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() *Assets // 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(target AgentID, transfer ...*Assets) *Assets // Send sends an on-ledger request (or a regular transaction to any L1 Address) Send(metadata RequestParameters) // 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 RequestIndex() uint16 // EVMTracer returns a non-nil tracer if an EVM tx is being traced // (e.g. with the debug_traceTransaction JSONRPC method). EVMTracer() *EVMTracer // TakeStateSnapshot takes a snapshot of the state. This is useful to implement the try/catch // behavior in Solidity, where the state is reverted after a low level call fails. TakeStateSnapshot() int RevertToStateSnapshot(int) // 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 // ChainInfo returns information and configuration parameters of the chain ChainInfo() *ChainInfo // 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 // Caller is the agentID of the caller. Caller() 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 // GetNFTData 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 }
SandboxView is an interface for read only call
type SendMetadata ¶
type SendMetadata struct { TargetContract Hname EntryPoint Hname Params dict.Dict Allowance *Assets 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 []any `json:"params"` }
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
func (*UnresolvedVMError) Read ¶ added in v1.0.3
func (e *UnresolvedVMError) Read(r io.Reader) error
func (*UnresolvedVMError) ToJSONStruct ¶ added in v1.0.3
func (e *UnresolvedVMError) ToJSONStruct() *UnresolvedVMErrorJSON
produce the params as humanly readably json, and the uints as strings
type UnresolvedVMErrorJSON ¶ added in v1.0.3
type UnsignedOffLedgerRequest ¶
type UnsignedOffLedgerRequest interface { Bytes() []byte WithNonce(nonce uint64) UnsignedOffLedgerRequest WithGasBudget(gasBudget uint64) UnsignedOffLedgerRequest WithAllowance(allowance *Assets) UnsignedOffLedgerRequest WithSender(sender *cryptolib.PublicKey) 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) (ret VMErrorCode, err error)
func (VMErrorCode) Bytes ¶
func (c VMErrorCode) Bytes() []byte
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 VMErrorTemplateFromBytes ¶ added in v1.0.3
func VMErrorTemplateFromBytes(data []byte) (*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 ...any) *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
type VMProcessor ¶
type VMProcessor interface { GetEntryPoint(code Hname) (VMProcessorEntryPoint, bool) Entrypoints() map[Hname]ProcessorEntryPoint }
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 ¶
- address.go
- agentid.go
- agentid_address.go
- agentid_contract.go
- agentid_eth.go
- agentid_nil.go
- assets.go
- chainid.go
- chaininfo.go
- contract_identity.go
- control_address.go
- doc.go
- event.go
- hname.go
- irc27nft.go
- kvdecoder.go
- loginterface.go
- nativetokenid.go
- nft.go
- output.go
- outputid.go
- public_chain_metadata.go
- receipt.go
- request.go
- request_evmcall.go
- request_evmtx.go
- request_json.go
- request_offledger.go
- request_onledger.go
- request_target.go
- requestimpl.go
- sandbox_interface.go
- sandboxview_interface.go
- vmerror.go
- vmprocessor.go