Documentation ¶
Overview ¶
Package 'iscp' defines fundamental types used in the Wasp.
The core types are mostly based on the fundamental data types of Goshimmer
Index ¶
- Constants
- Variables
- func OID(o ledgerstate.OutputID) string
- func ShortRequestIDs(ids []RequestID) []string
- type AgentID
- func AgentIDFromBytes(data []byte) (*AgentID, error)
- func AgentIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (*AgentID, error)
- func NewAgentID(addr ledgerstate.Address, hname Hname) *AgentID
- func NewAgentIDFromBase58EncodedString(s string) (*AgentID, error)
- func NewAgentIDFromString(s string) (*AgentID, error)
- func NewRandomAgentID() *AgentID
- type BLS
- type Base58
- type ChainID
- func ChainIDFromAddress(addr ledgerstate.Address) (*ChainID, error)
- func ChainIDFromBase58(b58 string) (*ChainID, error)
- func ChainIDFromBytes(data []byte) (*ChainID, error)
- func ChainIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (*ChainID, error)
- func NewChainID(addr *ledgerstate.AliasAddress) *ChainID
- func RandomChainID(seed ...[]byte) *ChainID
- func (chid *ChainID) AsAddress() ledgerstate.Address
- func (chid *ChainID) AsAliasAddress() *ledgerstate.AliasAddress
- func (chid *ChainID) Base58() string
- func (chid *ChainID) Clone() (ret *ChainID)
- func (chid *ChainID) Equals(chid1 *ChainID) bool
- func (chid *ChainID) Read(r io.Reader) error
- func (chid *ChainID) String() string
- func (chid *ChainID) Write(w io.Writer) error
- type ED25519
- type Hashing
- 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 InMemoryBlobCache
- type LogInterface
- type Request
- type RequestID
- func NewRequestID(txid ledgerstate.TransactionID, index uint16) RequestID
- func RequestIDFromBase58(b58 string) (ret RequestID, err error)
- func RequestIDFromBytes(data []byte) (RequestID, error)
- func RequestIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (RequestID, error)
- func TakeRequestIDs(reqs ...Request) []RequestID
- type RequestLookupDigest
- type Sandbox
- type SandboxBase
- type SandboxView
- type SendMetadata
- type SendOptions
- type StateAnchor
- type Utils
- type VMProcessor
- type VMProcessorEntryPoint
Constants ¶
const FuncInit = "init"
FuncInit is a name of the init function for any smart contract
const HnameLength = 4
const RequestIDDigestLen = 6
Variables ¶
var ( ErrInternalWrongTypeEntryPoint = xerrors.New("internal error: wrong type of the entry point") ErrWrongTypeEntryPoint = xerrors.New("wrong type of the entry point") )
var (
EntryPointInit = Hn(FuncInit)
)
well known hnames
Functions ¶
func OID ¶
func OID(o ledgerstate.OutputID) string
func ShortRequestIDs ¶
Types ¶
type AgentID ¶
type AgentID struct {
// contains filtered or unexported fields
}
AgentID represents address on the ledger with optional hname If address is and alias address and hname is != 0 the agent id is interpreted as ad contract id
var NilAgentID AgentID
func AgentIDFromBytes ¶
func AgentIDFromMarshalUtil ¶
func AgentIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (*AgentID, error)
func NewAgentID ¶
func NewAgentID(addr ledgerstate.Address, hname Hname) *AgentID
NewAgentID makes new AgentID
func NewAgentIDFromString ¶
NewAgentIDFromString parses the human-readable string representation
func (*AgentID) Address ¶
func (a *AgentID) Address() ledgerstate.Address
type ChainID ¶
type ChainID struct {
*ledgerstate.AliasAddress
}
ChainID represents the global identifier of the chain It is wrapped AliasAddress, an address without a private key behind
func ChainIDFromAddress ¶
func ChainIDFromAddress(addr ledgerstate.Address) (*ChainID, error)
ChainIDFromAddress creates a chainIDD from alias address. Returns and error if not an alias address type
func ChainIDFromBase58 ¶
ChainIDFromBase58 constructor decodes base58 string to the ChainID
func ChainIDFromBytes ¶
ChainIDFromBytes reconstructs a ChainID from its binary representation.
func ChainIDFromMarshalUtil ¶
func ChainIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (*ChainID, error)
func NewChainID ¶
func NewChainID(addr *ledgerstate.AliasAddress) *ChainID
NewChainID creates new chain ID from alias address
func RandomChainID ¶
RandomChainID creates a random chain ID.
func (*ChainID) AsAddress ¶
func (chid *ChainID) AsAddress() ledgerstate.Address
func (*ChainID) AsAliasAddress ¶
func (chid *ChainID) AsAliasAddress() *ledgerstate.AliasAddress
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 iscp.Hn ensures it is not returned
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 InMemoryBlobCache ¶
type InMemoryBlobCache struct {
// contains filtered or unexported fields
}
InMemoryBlobCache is supposed to be used as BlobCache in tests through factory method NewInMemoryBlobCache NOTE: Implements registry.BlobCache
func NewInMemoryBlobCache ¶
func NewInMemoryBlobCache() *InMemoryBlobCache
NewInMemoryBlobCache is a factory method for inMemoryBlobCache
type LogInterface ¶
type Request ¶
type Request interface { // index == 0 for off ledger requests ID() RequestID // is request on transaction of not IsOffLedger() bool // true or false for on-ledger requests, always true for off-ledger IsFeePrepaid() bool // arguments of the call with the flag if they are ready. No arguments mean empty dictionary and true Params() (dict.Dict, bool) // account of the sender SenderAccount() *AgentID // address of the sender for all requests, SenderAddress() ledgerstate.Address // returns contract/entry point pair Target() (Hname, Hname) // Timestamp returns a request TX timestamp, if such TX exist, otherwise zero is returned. Timestamp() time.Time // Bytes returns binary representation of the request Bytes() []byte // Hash returns the hash of the request (used for consensus) Hash() [32]byte }
region Request ////////////////////////////////////////////////////// Request has two main implementations - RequestOnLedger - RequestOffLedger
type RequestID ¶
type RequestID ledgerstate.OutputID
region RequestID ///////////////////////////////////////////////////////////////
func NewRequestID ¶
func NewRequestID(txid ledgerstate.TransactionID, index uint16) RequestID
func RequestIDFromBase58 ¶
func RequestIDFromBytes ¶
func RequestIDFromMarshalUtil ¶
func RequestIDFromMarshalUtil(mu *marshalutil.MarshalUtil) (RequestID, error)
func TakeRequestIDs ¶
func (RequestID) LookupDigest ¶
func (rid RequestID) LookupDigest() RequestLookupDigest
func (RequestID) OutputID ¶
func (rid RequestID) OutputID() ledgerstate.OutputID
type RequestLookupDigest ¶
type RequestLookupDigest [RequestIDDigestLen + 2]byte
RequestLookupDigest is shortened version of the request id. It is guaranteed to be uniques within one block, however it may collide globally. Used for quick checking for most requests if it was never seen
type Sandbox ¶
type Sandbox interface { SandboxBase // 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() Request // Balance return number of tokens of specific color in the balance of the smart contract Balance(col colored.Color) uint64 // Call calls the entry point of the contract with parameters and transfer. // If the entry point is full entry point, transfer tokens are moved between caller's and // target contract's accounts (if enough). If the entry point is view, 'transfer' has no effect Call(target, entryPoint Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) // 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) error // Event publishes "vmmsg" message through Publisher on nanomsg. It also logs locally, but it is not the same thing Event(msg string) // GetEntropy 32 random bytes based on the hash of the current state transaction GetEntropy() hashing.HashValue // 32 bytes of deterministic and unpredictably random data // IncomingTransfer return colored balances transferred by the call. They are already accounted into the Balances() IncomingTransfer() colored.Balances // Minted represents new colored tokens which has been minted in the request transaction // Note that the minted tokens can be sent to any addresses, not necessarily the chain address Minted() colored.Balances // Send one generic method for sending assets with ledgerstate.ExtendedLockedOutput // replaces TransferToAddress and Post1Request Send(target ledgerstate.Address, tokens colored.Balances, metadata *SendMetadata, options ...SendOptions) bool // Internal for use in native hardcoded contracts BlockContext(construct func(sandbox Sandbox) interface{}, onClose func(interface{})) interface{} // properties of the anchor output StateAnchor() StateAnchor }
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 { // AccountID returns the agentID of the current contract AccountID() *AgentID // Params returns the parameters of the current call Params() dict.Dict // Balances returns the colored balances owned by the contract Balances() colored.Balances // 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 contract in the current chain Contract() Hname // ContractCreator returns the agentID that deployed the contract ContractCreator() *AgentID // GetTimestamp returns the timestamp of the current state GetTimestamp() int64 // Log returns a logger that ouputs on the local machine. It includes Panicf method Log() LogInterface // Utils provides access to common necessary functionality Utils() Utils }
SandboxBase is the common interface of Sandbox and SandboxView
type SandboxView ¶
type SandboxView interface { SandboxBase // State immutable k/v store of the current call (in the context of the smart contract) State() kv.KVStoreReader // Call calls another contract. Only calls view entry points Call(contractHname Hname, entryPoint Hname, params dict.Dict) (dict.Dict, error) }
SandboxView is an interface for read only call
type SendMetadata ¶
RequestMetadata represents content of the data payload of the output
type SendOptions ¶
type SendOptions struct { TimeLock uint32 // unix seconds FallbackAddress ledgerstate.Address FallbackDeadline uint32 // unix seconds }
func (*SendOptions) ToGoshimmerSendOptions ¶
func (opt *SendOptions) ToGoshimmerSendOptions() *sendoptions.SendFundsOptions
type StateAnchor ¶
type StateAnchor interface { StateAddress() ledgerstate.Address GoverningAddress() ledgerstate.Address StateIndex() uint32 StateHash() hashing.HashValue OutputID() ledgerstate.OutputID }
properties of the anchor output/transaction in the current context
type Utils ¶
Utils implement various utilities which are faster on host side than on wasm VM Implement deterministic stateless computations
type VMProcessor ¶
type VMProcessor interface { GetEntryPoint(code Hname) (VMProcessorEntryPoint, bool) GetDefaultEntryPoint() VMProcessorEntryPoint // return EP which can only be called with Sandbox GetDescription() string }
VMProcessor is a abstract interface to the VM processor instance.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
package coreutil provides functions to describe interface of the core contract in a compact way
|
package coreutil provides functions to describe interface of the core contract in a compact way |
Package requestargs implements special encoding of the dict.Dict which allows optimized transfer of big data through SC request.
|
Package requestargs implements special encoding of the dict.Dict which allows optimized transfer of big data through SC request. |