Module multiversx_sc_scenario::imports
source · Expand description
Imports normally needed in integration tests, grouped together.
Re-exports§
pub use crate::api::DebugApi;
pub use crate::api::StaticApi;
pub use crate::bech32;
pub use crate::scenario::model::Account;
pub use crate::scenario::model::AddressValue;
pub use crate::scenario::model::BytesValue;
pub use crate::scenario::model::CheckAccount;
pub use crate::scenario::model::CheckStateStep;
pub use crate::scenario::model::ScCallStep;
pub use crate::scenario::model::ScDeployStep;
pub use crate::scenario::model::ScQueryStep;
pub use crate::scenario::model::Scenario;
pub use crate::scenario::model::SetStateStep;
pub use crate::scenario::model::TransferStep;
pub use crate::scenario::model::TxESDT;
pub use crate::scenario::model::TxExpect;
pub use crate::scenario::model::TypedResponse;
pub use crate::scenario::model::TypedScDeploy;
pub use crate::scenario::ScenarioRunner;
pub use crate::standalone::retrieve_account_as_scenario_set_state;
pub use crate::test_wallets;
pub use crate::ScenarioTxRun;
pub use crate::num_bigint;
pub use crate::whitebox_legacy::*;
Modules§
Macros§
- Converts usize to NonZeroUsize or returns SCError.
- Allows us to write Solidity style
require!(<condition>, <error_msg>)
and avoid if statements.
Structs§
- An Address is just a H256 with a different name. Has a different ABI name than H256.
- Helper structure for providing arguments to all SC call functions other than async_call_raw. It keeps argument lengths separately from the argument data itself. Argument data is concatenated into a single byte buffer.
- Adapter from the API to the TopDecodeInput trait. Allows objects to be deserialized directly from the API as arguments.
- Some info to display in endpoint argument deserialization error messages, to help users identify the faulty argument. Generated automatically. Current version uses argument names, but in principle it could be changed to argument index to save some bytes from the wasm output.
- A vector with a fixed capacity.
- AsyncCallPromisesDeprecatedWill be renamed to
AsyncCall
andAsyncCall
toAsyncCallLegacy
when the promises end up on the mainnet. - Holding back-transfer data, as retrieved from the VM.
- Wraps and address, and presents it as a bech32 expression wherever possible.
- A bi-directional map, from values to ids and viceversa. The mapper is based on UnorderedSetMapper, reason why the remove is done by swap_remove
- A pointer type that uniquely owns a heap allocation of type
T
. - Simple wrapper around a boxed byte slice, but with a lot of optimized methods for manipulating it. The focus is on reducing code size rather improving speed.
- Consumes a vector of
BoxedBytes
and deserializes from the vector one by one. - Object that encodes full async callback data.
- Similar object to
CallbackClosure
, but only used for deserializing from storage the callback data with the old async call mechanism. - Helps the callback macro expansion to perform callback name matching more efficiently. The current implementation hashes by callback name length, but in principle further optimizations are possible.
- Contains code for a deploy or upgrade.
- Handlers that return nothing.
- ContractCallNoPaymentDeprecatedHolds metadata for calling another contract, without payments.
- ContractCallWithAnyPaymentDeprecatedHolds data for calling another contract, with any type of payment: none, EGLD, Multi-ESDT.
- ContractCallWithEgldDeprecatedHolds data for calling another contract, with EGLD payment only.
- ContractCallWithEgldOrSingleEsdtDeprecatedHolds data for calling another contract, with a single payment, either EGLD or a single ESDT token.
- ContractCallWithMultiEsdtDeprecated
- ContractDeployDeprecated
- Bundles a representation of a contract with the contract proxy, so that it can be easily called in the context of a blockchain mock.
- Holds deploy data: code, code metadata, and arguments.
- Indicates the system SC address, which is the same on any MultiversX blockchain.
- Proxy for the ESDT system smart contract.
- Method container of the ESDT system smart contract proxy.
- ESDTSystemSmartContractProxyDeprecatedProxy for the ESDT system smart contract. Unlike other contract proxies, this one has a fixed address, so the proxy object doesn’t really contain any data, it is more of a placeholder.
- Indicates the EGLD payment in a transaction.
- Specialized type for handling either EGLD or ESDT token identifiers.
- Similar to
EgldOrEsdtTokenPayment
, but only contains references. - Empty structure with an empty bytes representation. Equivalent to
false
,0
or[u8; 0]
, but more explicit. - Thin wrapper around EsdtTokenPayment, which has different I/O behaviour:
- The version of
EsdtTokenPayment
that contains referrences instead of owned fields. - Verifies that transaction result error matches the given one.
- Verifies that transaction result message matches the given one.
- Verifies that transaction result status matches the given one.
- Verifies that transaction result matches the given value.
- Indicates the source of a “deploy from source” or “upgrade from source”.
- Encodes a function call on the blockchain, composed of a function name and its encoded arguments.
- Indicates that all remaining gas should be sent to a transaction.
- Type that holds 32 bytes of data. Data is kept on the heap to keep wasm size low and avoid copies.
- Structure that allows taking a variable number of arguments, but does nothing with them, not even deserialization.
- A byte buffer managed by an external API.
- Basic implementation of a ManagedBuffer builder, no caching.
- A ManagedBuffer builder implementation that caches data to the static cache locally in the contract.
- Nested decode buffer based on a managed buffer. Uses the load/copy slice API to extract pieces of the managed buffer for deserialization.
- A list of items that lives inside a managed buffer. Items can be either stored there in full (e.g.
u32
), or just via handle (e.g.BigUint<M>
). - A byte buffer managed by an external API.
- A very efficient optional managed type.
- A very efficient reference to a managed type, with copy semantics.
- Smart contract error that can concatenate multiple message pieces. The message is kept as a managed buffer in the VM.
- A list of items that lives inside a managed buffer. Items can be either stored there in full (e.g.
u32
), or just via handle (e.g.BigUint<M>
). - Empty ManagedVecItem.
- The main ManagedVecItemPayload implementation. Uses an array in its implementation.
- A multi-value container, that keeps raw values as ManagedBuffer It allows encoding and decoding of multi-values.
- Argument or result that is made up of the argument count, followed by the arguments themselves. Think of it as a
VarArgs
preceded by the count. UnlikeMultiValueManagedVec
it deserializes eagerly. - Structure that allows taking a variable number of arguments or returning a variable number of results in a smart contract endpoint.
- Iterator that can give us a range of NonZeroUsize.
- Transaction marker, which indicates that a transaction should never have any payment added to it.
- Contains no data.
- Temporary value used for any kind of templates.
- Temporary value used for any kind of templates.
- A simple queue struct that is able to push and pop without moving elements. New items are pushed at the end, just like for a regular Vec. When popping, instead of performing a regular Vec remove that would shift items, a start index is moved up 1 position. When serializing, items before the start index are ignored.
- A queue with owned nodes.
- Indicates that back-transfers will be returned.
- Indicates that the error status will be returned.
- Indicates that the newly deployed address will be returned after a deploy.
- Indicates that the newly deployed address will be returned after a deploy.
- Indicates that the newly deployed address will be returned after a deploy as a ManagedAddress.
- Indicates that the raw result data will be returned.
- Indicates that result will be returned.
- Indicates that result will be returned.
- Indicates that the unmanaged version of the result will be returned.
- Indicates that the error status will be returned.
- A big unsigned integer type.
- Environment for executing transactions.
- The actual data required to run a scenario locally. This is the minimal environment needed to run txs.
- A facade for contracts tests.
- Intermediary type for deserializing the result of an endpoint that returns a
SingleValueMapper
. - Manages a single serializable item in storage.
- A special type of array that initially holds the values from 0 to N If array[i] == i, then the default value (0) is stored instead
- Contains a smart contract execution error message.
- A UTF-8–encoded, growable string.
- Encodes a dummy address, to be used for tests.
- Encodes a dummy SC address, to be used for tests.
- Encodes a dummy address, to be used for tests.
- Indicates that transaction should be sent to the caller (the sender of the current transaction).
- Indicates that transaction should be sent to itself.
- Specialized type for handling token identifiers. It wraps a BoxedBytes with the full ASCII name of the token. EGLD is stored as an empty name.
- Represents property arguments to be sent to the system SC.
- Universal representation of a blockchain transaction.
- The transaction environment used in calls launched from a SC.
- TypedFunctionCallDeprecatedOld attempt at grouping FunctionCall + OriginalTypeMarker.
- Holds the values from 1 to N with as little storage interaction as possible If Mapper[i] = i, then it stores nothing, i.e. “0” If Mapper[i] is equal to another value, then it stores the value
- Holds deploy data: code, code metadata, and arguments.
- Proxy describing the user builtin function signatures.
- Very widely used mapper, that manages the users of a smart contract. It holds a bi-directional map, from addresses to ids and viceversa. This is so we can easily iterate over all users, using their ids. Also holds the user count in sync. This is also necessary for iteration.
- A contiguous growable array type, written as
Vec<T>
, short for ‘vector’. - Manages a list of items of the same type. Saves each of the items under a separate key in storage. To produce each individual key, it concatenates the main key with a serialized 4-byte index. Indexes start from 1, instead of 0. (We avoid 0-value indexes to prevent confusion between an uninitialized variable and zero.) It also stores the count separately, at what would be index 0. The count is always kept in sync automatically.
- Wraps a contract that is supposed to be used in whitebox tests.
- A non-iterable whitelist mapper. Very efficient for storing a whitelist, as each item requires only one storage key. If you need to iterate over the keys, use UnorderedSetMapper or SetMapper instead.
- Defines a lambda function to be called on the newly deployed address, after a deploy.
- Defines a lambda function to be called on the raw result of the transaction.
- Wraps a closure that handles a
TxResponse
object. - Defines a lambda function to be called on the decoded result.
- Defines a lambda function to be called on the decoded result.
Enums§
- Used internally between the
callback
andcallback_selector
methods. It is likely to be removed in the future. - Encodes any type of payment, which either:
- The version of
EgldOrMultiEsdtPayment
that contains referrences instead of owned fields. - Message hash type for the
verifyCustomSecp256k1
CryptoApi function - Standard way of signalling that an operation was interrupted early, before running out of gas. An endpoint that performs a longer operation can check from time to time if it is running low on gas and can decide to save its state and exit, so that it can continue the same operation later.
- A smart contract argument or result that can be missing.
- SCResultDeprecatedDefault way to optionally return an error from a smart contract endpoint.
Constants§
Traits§
- The addition operator
+
. - The addition assignment operator
+=
. - Describes a value can also have a custom representation in a mandos scenario.
- Models an argument tree of the form
(arg1, (arg2, ... (argn, ())))
, used for retrieving endpoint arguments. - The bitwise AND operator
&
. - The bitwise AND assignment operator
&=
. - The bitwise OR operator
|
. - The bitwise OR assignment operator
|=
. - The bitwise XOR operator
^
. - The bitwise XOR assignment operator
^=
. - Interface to be used by the actual smart contract code.
- Defines a contract call object, which is the basis for all calls to other contracts.
- ContractCallBaseDeprecatedConverts into a legacy contract call.
- The division operator
/
. - The division assignment operator
/=
. - Used when merging is done through an external SC call. Generally, these only need to have the same token ID, with different nonces.
- Defines conversion of a type to its multi-value representation.
- Commonalities between all managed types.
- Types that implement this trait can be items inside a
ManagedVec
. All these types need a payload, i.e a representation that gets stored in the underlying managed buffer. Not all data needs to be stored as payload, for instance for most managed types the payload is just the handle, whereas the mai ndata is kept by the VM. - Syntactic sugar, that allows us to more easily represent composite payloads as nested tuples.
- Describes the binary represetnation of a ManagedVecItem.
- Describes concatantion of smaller payloads into a larger one.
- Used for types that can be merged locally.
- The multiplication operator
*
. - The multiplication assignment operator
*=
. - Trait that allows zero-copy read of value-references from slices in LE format.
- Trait that allows zero-copy write of value-references to slices in LE format.
- Trait that is automatically implemented for all types that are allowed as proxy inputs.
- Indicates how result processing will undergo for an ensemble of result handlers.
- Result handler list item.
- Indicates how result processing will undergo for one specific result handler.
- Used when registering a contract for debugging.
- The remainder operator
%
. - The remainder assignment operator
%=
. - Any type that implements this trait can be used to signal errors when returning from a SC endpoint.
- Designates a tx environment suitable for running scenarios locally.
- Provides a
run
method for transactions and steps. - The left shift operator
<<
. Note that because this trait is implemented for all integer types with multiple right-hand-side types, Rust’s type checker has special handling for_ << _
, setting the result type for integer operations to the type of the left-hand-side operand. This means that thougha << b
anda.shl(b)
are one and the same from an evaluation standpoint, they are different when it comes to type inference. - The left shift assignment operator
<<=
. - The right shift operator
>>
. Note that because this trait is implemented for all integer types with multiple right-hand-side types, Rust’s type checker has special handling for_ >> _
, setting the result type for integer operations to the type of the left-hand-side operand. This means that thougha >> b
anda.shr(b)
are one and the same from an evaluation standpoint, they are different when it comes to type inference. - The right shift assignment operator
>>=
. - The subtraction operator
-
. - The subtraction assignment operator
-=
. - Trait that allows zero-copy read of values from an underlying API in big endian format.
- Marks the data field of a transaction in
Tx
. - Indicates that given result handler is empty, i.e. doesn’t cause any side effects and returns nothing.
- Marks the sender of any transaction.
- Marks the non-empty sender of a transaction.
- Marker trait that indicates that payment field contains no payment.
- Describes a payment that is part of a transaction.
- Marks a payment object that only contains EGLD or nothing at all.
- Indicates that a payment object contains a multi-ESDT payment.
- Defines a proxy object for a smart contract.
- Marks a general result handler, to be used in the transaction unified syntax.
- Marks the recipient of any transaction.
- Marks the non-empty recipient of a transaction.
- Implemented for all types that can end up in the ABI:
Functions§
- Calls both the fast exit and the regular dep-decode, compares that the outputs are equal, then returns the result. To be used in serialization tests.
- Calls both the fast exit and the regular dep-encode, compares that the outputs are equal, then returns the result. To be used in serialization tests.
- Calls both the fast exit and the regular top-decode, compares that the outputs are equal, then returns the result. To be used in serialization tests.
- Calls both the fast exit and the regular top-encode, compares that the outputs are equal, then returns the result. To be used in serialization tests.
- Calls nested decode and panics if an encoding error occurs. Do not use in smart contracts!
- Calls nested encode and panics if an encoding error occurs. Do not use in smart contracts!
- Used for loading all regular endpoint arguments. A call to this gets generated for all endpoints and callbacks.
- Currently used for the callback closure. No distinction there for single values.
- Syntactical sugar to help macros to generate code easier. Unlike calling
CallbackClosure::<SA, R>::new
, here types can be inferred from the context. - Syntactical sugar to help macros to generate code easier. Unlike calling
ContractDeploy::<SA>::new
, here types can be inferred from the context. - This is safe because adding 1 to a positive number makes it greater than one.
- This is safe because 1 != 0.
- This is safe because adding a non-zero number with a positive one yields a non-zero number.
- ser_deser_okDeprecatedbackwards compatibility only, will remove in next major release
- Calls top encode and panics if an encoding error occurs. Do not use in smart contracts!
Type Aliases§
- AsyncCallDeprecatedKept as alias for backwards compatibility.
- EsdtTokenPaymentMultiArgDeprecated
- IgnoreVarArgsDeprecatedStructure that allows taking a variable number of arguments, but does nothing with them, not even deserialization.
- The specific
Tx
type produces by the issue operations of the ESDTSystemSCProxy. - ManagedBufferCachedBuilderDeprecated
- ManagedCountedMultiResultVecDeprecated
- ManagedCountedVarArgsDeprecated
- ManagedMultiResultVecDeprecated
- ManagedMultiResultVecEagerDeprecated
- ManagedVarArgsDeprecated
- ManagedVarArgsEagerDeprecated
- MultiArg2Deprecated
- MultiArg3Deprecated
- MultiArg4Deprecated
- MultiArg5Deprecated
- MultiArg6Deprecated
- MultiArg7Deprecated
- MultiArg8Deprecated
- MultiArg9Deprecated
- MultiArg10Deprecated
- MultiArg11Deprecated
- MultiArg12Deprecated
- MultiArg13Deprecated
- MultiArg14Deprecated
- MultiArg15Deprecated
- MultiArg16Deprecated
- MultiArgVecDeprecatedStructure that allows taking a variable number of arguments or returning a variable number of results in a smart contract endpoint.
- Alias for a list of payments.
- MultiResult2Deprecated
- MultiResult3Deprecated
- MultiResult4Deprecated
- MultiResult5Deprecated
- MultiResult6Deprecated
- MultiResult7Deprecated
- MultiResult8Deprecated
- MultiResult9Deprecated
- MultiResult10Deprecated
- MultiResult11Deprecated
- MultiResult12Deprecated
- MultiResult13Deprecated
- MultiResult14Deprecated
- MultiResult15Deprecated
- MultiResult16Deprecated
- MultiResultVecDeprecatedUsed for returning a variable number of results from an endpoint, it is synonymous with
MultiResult
. - OptionalArgDeprecatedA smart contract argument or result that can be missing.
- OptionalResultDeprecatedIt is just an alias for
OptionalArg
. In general we useOptionalArg
for arguments andOptionalResult
for results, but it is the same implementation for both. - Alias for a
Tx
generated from a proxy, in an endpoint. - Alias for a
Tx
generated from a proxy, ininit
. - Alias for a
Tx
generated from a proxy, inupgrade
. - Alias for a
Tx
generated from a proxy, in an endpoint. - Alias for a
Tx
generated from a proxy, ininit
. - Alias for a
Tx
generated from a proxy, inupgrade
. - VarArgsDeprecatedUsed for taking a variable number of arguments in an endpoint, it is synonymous with
MultiResultVec
/MultiArgVec
.