Module scrypto::prelude::radix_engine_common::prelude
source · Expand description
Each module should have its own prelude, which:
- Adds preludes of upstream crates
- Exports types with specific-enough names which mean they can safely be used downstream.
The idea is that we can just include the current crate’s prelude and avoid messing around with tons of includes. This makes refactors easier, and makes integration into the node less painful.
Modules§
- SBOR basic, no custom types
- SBOR Categorize trait
- SBOR codec for core Rust types.
- SBOR constants
- SBOR decode trait.
- SBOR decoding.
- SBOR encode trait.
- SBOR payload wrappers. These are new types around an encoded payload or sub-payload, with helper methods / traits implemented. They can be used as a more efficient wrapper a ScryptoValue if the content of that value is not needed.
- SBOR encoding.
- Utilities for formatting and printing
String
s. - The methods and macros provided directly in this
index_map
module (new
,with_capacity
) work in both std and no-std modes - unlike the corresponding methods onIndexMap
itself. - The methods and macros provided directly in this
index_set
module (new
,with_capacity
) work in both std and no-std modes - unlike the corresponding methods onIndexSet
itself. IndexMap
is a hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.- SBOR paths.
- SBOR payload validation.
- Each module should have its own prelude, which:
- SBOR textual representations
- A facade of Rust types.
- SBOR Schema
- SBOR structured payload traversal.
- SBOR value model and any decoding/encoding.
- SBOR value kinds - ie the types of value that are supported.
- A contiguous growable array type with heap-allocated contents, written
Vec<T>
. - Data model versioning helper macro
Macros§
- This macro is intended for creating a data model which supports versioning. This is useful for creating an SBOR data model which can be updated in future. In future, enum variants can be added, and automatically mapped to.
- This macro is intended for creating a data model which supports versioning. This is useful for creating an SBOR data model which can be updated in future. In future, enum variants can be added, and automatically mapped to.
- Creates a
String
using interpolation of runtime expressions. - Creates a safe integer from literals. You must specify the type of the integer you want to create.
- Creates a
Vec
containing the arguments.
Structs§
- Represents a decoder which understands how to decode Scrypto addresses in Bech32.
- Represents an encoder which understands how to encode Scrypto addresses in Bech32.
- An ordered map based on a B-Tree.
- An ordered set based on a B-Tree.
- Represents a BLS12-381 G1 public key.
- Represents a BLS12-381 G2 signature (variant with 96-byte signature and 48-byte public key)
- An error returned by
RefCell::try_borrow
. - An error returned by
RefCell::try_borrow_mut
. - A pointer type that uniquely owns a heap allocation of type
T
. - Bytes, of length between 1 and 64.
- A mutable memory location.
- Address to a global component
Decimal
represents a 192 bit representation of a fixed-scale decimal number.- Represents an ED25519 public key.
- Represents an ED25519 signature.
- A type-safe consensus epoch number.
- An identifier for a type under a given node’s schema context in the Radix network.
- Address to a global entity
- Represents a 32-byte hash digest.
- Represents a 32-byte hash accumulator.
- Represents an HRP set (typically corresponds to a network).
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Represents a Unix timestamp, capturing the seconds since the unix epoch.
- Unsigned integers, up to u64.
- Address to a local entity
- Represents additional validation that should be performed on the size.
- A doubly-linked list with owned nodes.
- Note - this is quite similar to ManifestDecompilationDisplayContext
- Network Definition is intended to be the actual definition of a network
- The unique identifier of a (stored) node.
- A thin wrapper around a
HashMap
, which guarantees that aHashMap
usage will not result in a non-deterministic execution (simply by disallowing the iteration over its elements). - This is the struct used in the Schema
- Represents additional validation that should be performed on the numeric value.
- A cell which can be written to only once.
- Address to a global package
- The unique identifier of a node module.
- Zero-sized type used to mark things that “act like” they own a
T
. PreciseDecimal
represents a 256 bit representation of a fixed-scale decimal number.- RUID, v4, variant 1, big endian. See https://www.rfc-editor.org/rfc/rfc4122
- A wrapper for a full encoded SBOR payload, including the prefix byte.
- A wrapper for a reference to a valid partial SBOR payload representing a single value.
- A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.
- Wraps a borrowed reference to a value in a
RefCell
box. A wrapper type for an immutably borrowed value from aRefCell<T>
. - A mutable memory location with dynamically checked borrow rules
- A wrapper type for a mutably borrowed value from a
RefCell<T>
. - Address to a global resource
- A type-safe consensus round number within a single epoch.
- A series of indexes which describes some value in the sbor tree
- A wrapper for a full encoded SBOR payload, including the prefix byte.
- A wrapper for a reference to a valid partial SBOR payload representing a single value.
- Represents a particular schema under a package
- An array of custom type kinds, and associated extra information which can attach to the type kinds
- An identifier for a type in the context of a schema.
- Represents an ECDSA Secp256k1 public key.
- Represents an ECDSA Secp256k1 signature.
- A UTF-8–encoded, growable string.
- A string matching
[_0-9a-zA-Z]{1,64}
. - Combines all data about a Type:
- This enables the type to be represented as eg JSON Also used to facilitate type reconstruction
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- The core primitive for interior mutability in Rust.
- A
UtcDateTime
represents a Unix timestamp on the UTC Calendar. - A contiguous growable array type, written as
Vec<T>
, short for ‘vector’. - A
Decoder
abstracts the logic for decoding basic types. - A double-ended queue implemented with a growable ring buffer.
- LazyCellExperimentalA value which is initialized on the first access.
- SyncUnsafeCellExperimental
UnsafeCell
, butSync
. - An
Encoder
abstracts the logic for writing core types into a byte buffer.
Enums§
- A clone-on-write smart pointer.
- Represents an error occurred during decoding.
- Represents an error occurred during encoding.
- An enum which represents the different addressable entities.
- A reference to the type to substitute with for the case of generics.
- The TypeId which is local to a given
Schema
. This is theSchemaTypeLink
used in a linearizedSchema
to linkTypeKind
s. - Any address supported by manifest, both global and local.
- Represents type of non-fungible id
- Represents the local id of a non-fungible.
- The
Option
type. See the module level documentation for more. - Represents an error when retrieving BLS public key from hex or when aggregating.
- Represents an error when retrieving BLS signature from hex or when aggregating.
- Represents an error when parsing Decimal from another type.
- Represents an error when parsing ED25519 public key from hex.
- Represents an error when parsing hash.
- Represents an error when parsing ManifestAddressReservation.
- Represents an error when parsing ManifestBlobRef.
- Represents an error when parsing ManifestBucket.
- Represents an error when parsing ManifestDecimal.
- Represents an error when parsing ManifestExpression.
- Represents an error when parsing ManifestPreciseDecimal.
- Represents an error when parsing ManifestProof.
- Represents an error when decoding non-fungible id.
- Represents an error when parsing PreciseDecimal from another type.
- Represents an error when parsing ED25519 public key from hex.
- Represents any natively supported public key.
- The hash of a given public key.
- Defines the rounding strategy.
- This is a compile-time identifier for a given type, used by the type aggregator to uniquely identify a type.
- Represents any value conforming to the SBOR value model.
- A schema for the values that a codec can decode / views as valid
- The unique identifier of a substate within a node module.
- A schema for the values that a codec can decode / views as valid
- Additional validation to apply to a payload of the given type, beyond validation from the
TypeKind
’s type structure. - Represents any value conforming to the SBOR value model.
Constants§
- The native package for access controllers.
- The non-fungible badge resource which is used for account ownership, if accounts have been set up with simple account creation, or have been securified.
- The native package for accounts.
- The price for adding a single byte to archive storage, in XRD. 1 MB = 6 USD This is primarily for transaction payload, events and logs.
- BLS12-381 ciphersuite v1 It has following parameters
- Depth limit for various types of blueprint payload
- The consensus manager native component - in charge of validators, consensus and epochs.
- The native package for the consensus manager.
- A custom type is an application defined type with special semantics.
- The default tip percentage to use when building a transaction.
- The non-fungible badge resource which is used for virtual proofs of EdDSA Ed25519 transacton signatures in the transaction processor.
- The execution cost unit limit.
- The execution cost units loaned from system
- The price of execution cost unit, in XRD.
- The faucet native component - use this on testnets for getting XRD and locking fee.
- The name of the faucet blueprint under the
FAUCET_PACKAGE
. - The faucet native component - use this on testnets for getting XRD and locking fee.
- The scrypto package for the faucet
- The finalization cost unit limit.
- The price of finalization cost unit, in XRD.
- The genesis helper scrypto component - used for sorting out genesis.
- The name of the genesis helper blueprint under the
GENESIS_HELPER_PACKAGE
. - The scrypto package for the genesis helper.
- The non-fungible badge resource which is used for virtual proofs which represent the global ancestor of the actor which made the latest global call.
- The non-fungible badge resource which is used for identity ownership, if identities have been set up with simple account creation, or have been securified.
- The native package for identities.
- Depth limit for the key and value of an entry in
KeyValueStore
- 0x4d = M in ASCII for Manifest - (77 in decimal)
- The max depth of an access rule, to protect unbounded native stack usage
- The max number of access rule nodes in an access rule
- The max length of a blueprint identifier
- The max call depth, used by transaction executor.
- The max epoch range Should be ~ 1 month. The below is ~30 days given 5 minute epochs.
- The max length of an event name
- The max event size
- The max length of a feature name
- The max length of a function name
- The max total heap substate size.
- The maximum initial table size
- The maximum invoke payload size.
- The max log size
- The maximum memory size (per call frame): 64 * 64KiB = 4MiB
- The max SBOR size of metadata key
- The max SBOR size of metadata value
- The max number of fields a blueprint can have
- The max number of labels of a table jump, excluding the default
- The maximum number of “live” buffers maintained by Scrypto runtime.
- The max number of events
- The max number of functions
- The max number of function local variables
- The max number of function parameters
- The max number of global variables
- The max number of logs
- The max length of an Origin in metadata
- The max panic message size
- The maximum that a package or component owner is allowed to set their method royalty to. 10 USD
- The max number of roles in a Role Specification
- The max length of a role name
- The maximum substate key read and write size
- The maximum substate read and write size.
- The maximum value of tip percentage
- The max total track substate size.
- The max transaction size
- The max length of a registered type name
- The max length of a URL in metadata
- The native package for the metadata module.
- The minimum value of tip percentage
- The proposer’s share of network fees (execution, finalization and storage)
- The validator set’s share of network fees (execution, finalization and storage)
- The non-fungible badge resource which is used for virtual proofs which represent the package of the immediate caller - ie the actor which made the latest (global or internal) call.
- The non-fungible badge resource which is used for package ownership when creating packages with the simple package creation set-up.
- The native package for package deployment.
- The native package for pools.
- The free credit amount used by preview. 1000000 XRD = $60000, which should be enough to cover all sensible preview requests.
- The native package for resource managers, proofs, buckets, vaults etc.
- The ROLA hash which is signed is created as
hash(ROLA_HASHABLE_PAYLOAD_PREFIX || ..)
- The native package for the role assignment module.
- The native package for the royalty module.
- 0x5c for [5c]rypto - (92 in decimal)
- The non-fungible badge resource which is used for virtual proofs of ECDSA Secp256k1 transacton signatures in the transaction processor.
- The price for adding a single byte to state storage, in XRD. 1 MB = 6 USD
- The non-fungible badge resource which is used for virtual proofs representing the fact that the current transaction is a system transaction.
- The native package for test utils.
- The proposer’s share of tips
- The validator set’s share of tips
- The Transaction hash which is signed is created as:
hash(TRANSACTION_HASHABLE_PAYLOAD_PREFIX || version prefix according to type of transaction payload || ..)
- The native package for the transaction processor.
- The intent hash store component
- Depth limit for the default value of a transient substate
- The USD price, in XRD. 1 XRD = 0.06 USD
- The non-fungible badge resource which is used for validator ownership.
- The number of entries in the engine cache
- XRD is the native token of the Radix ledger. It is a fungible token, measured in attos (
10^-18
).
Statics§
Traits§
- Used to do a cheap mutable-to-mutable reference conversion.
- Used to do a cheap reference-to-reference conversion.
- The
Categorize
trait marks a rust type as having a fixed value kind for SBOR encoding/decoding. - A common trait for the ability to explicitly duplicate an object.
- This trait is used where context is required to correctly display a value.
- This trait is used where context is required to correctly serialize a value.
- Types whose values can be duplicated simply by copying bits.
- Represents a custom SBOR value.
?
formatting.- A data structure that can be decoded from a byte array using SBOR.
- A trait for giving a type a useful default value.
- The
Describe
trait allows a type to describe how to interpret and validate a corresponding SBOR payload. - Format trait for an empty format,
{}
. - An iterator able to yield elements from both ends.
- Custom code within the destructor.
- A data structure that can be serialized into a byte array using SBOR.
- Trait for comparisons corresponding to equivalence relations.
- An iterator that knows its exact length.
- Extend a collection with the contents of an iterator.
- The version of the call operator that takes an immutable receiver.
- The version of the call operator that takes a mutable receiver.
- The version of the call operator that takes a by-value receiver.
- Used to do value-to-value conversions while consuming the input value. It is the reciprocal of
Into
. - Conversion from an
Iterator
. - Parse a value from a string
- A marker trait to indicate that the type is versioned. This can be used for type bounds for requiring that types are versioned.
- A value-to-value conversion that consumes the input value. The opposite of
From
. - Conversion into an
Iterator
. - Marks the rust type that represents a non-fungible id, of non-auto-generated kind (i.e. String, Integer and Bytes).
- Marks the rust type that represents a non-fungible id, of any kind (i.e. String, Integer, Bytes and RUID).
- A trait for dealing with iterators.
- Trait for types that form a total order.
- Trait for comparisons using the equality operator.
- Trait for types that form a partial order.
- Represents a custom SBOR value.
- Marker trait for encoding as an Sbor Enum
- Marker trait for encoding as an Sbor Tuple
- Marker trait for a link between
TypeKind
s: - Types that can be transferred across thread boundaries.
- Types with a constant size known at compile time.
- Types for which it is safe to share references between threads.
- A generalization of
Clone
to borrowed data. - A trait for converting a value to a
String
. - Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of
TryInto
. - An attempted conversion that consumes
self
, which may or may not be expensive. - Types that do not require any pinning guarantees.
Functions§
- Performs BLS12-381 G2 aggregated signature verification of multiple messages each signed with different key. Domain specifier tag: BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
- Decode an instance of
T
from a slice. - Encode a
T
into byte array. - Creates a payload traverser from the buffer
- NOTE: The below code is copied with minor alterations from the bech32 crate. These alterations are to avoid using std for allocations, and fit with the sbor no-alloc options.
- Combines a u8 with a u8 slice.
- Copies a slice to a fixed-sized array.
- Disposes of a value.
- Performs BLS12-381 G2 aggregated signature verification one message signed with multiple keys. Domain specifier tag: BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
- Computes the hash digest of a message.
- Creates an empty map with capacity 0 and default Hasher
- Creates an empty map with given capacity and default Hasher
- Creates an empty set with capacity 0 and default Hasher
- Creates an empty set with given capacity and default Hasher
- This is safe for std and no-std use cases (unlike
IndexMap::new
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexMap::with_capacity
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexSet::new
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexSet::with_capacity
which disappears when std is not in the toolchain - see this article for deep technical reasons) - Decodes a data structure from a byte array.
- Encodes a data structure into byte array.
- ============================================== (DEPRECATED) TRAVERSAL
- Performs BLS12-381 G2 signature verification. Domain specifier tag: BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
Type Aliases§
- An index of a specific validator within the current validator set. To be exact: a
ValidatorIndex
equal tok
references thek-th
element returned by the iterator of theIndexMap<ComponentAddress, Validator>
in this epoch’s active validator set (which is expected to be sorted by stake, descending). This uniquely identifies the validator, while being shorter thanComponentAddress
(we do care about the constant factor of the space taken byLeaderProposalHistory
under prolonged liveness break scenarios).
Derive Macros§
- Derive code that returns the value kind - specifically for Basic SBOR.
- Derive code that decodes this data structure from a byte array - specifically for Basic SBOR.
- Derive code that describes the type - specifically for Basic SBOR.
- Derive code that encodes this data structure - specifically for Basic SBOR.
- Derive code that returns the value kind.
- Derive macro generating an impl of the trait
Clone
. - Derive macro generating an impl of the trait
Copy
. - Derive macro generating an impl of the trait
Debug
. - Derive code that decodes this data structure from a byte array.
- Derive macro generating an impl of the trait
Default
. - Derive code that describes this type.
- Derive code that encodes this data structure
- Derive macro generating an impl of the trait
Eq
. - Derives code for categorizing a struct or enum with Manifest value model.
- Derives code for decoding a struct or enum with Manifest value model.
- Derives code for encoding a struct or enum with Manifest value model.
- Derive macro generating an impl of the trait
PartialOrd
. The behavior of this macro is described in detail here. - Derives code for categorizing a struct or enum with Scrypto value model.
- Derives code for decoding a struct or enum with Scrypto value model.
- Derives code for encoding a struct or enum with Scrypto value model.
- Derive code for implementing the required logic to mark a type as being an event.