multiversx_sc::types

Struct Tx

Source
pub struct Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,
{ pub env: Env, pub from: From, pub to: To, pub payment: Payment, pub gas: Gas, pub data: Data, pub result_handler: RH, }
Expand description

Universal representation of a blockchain transaction.

Uses 7 generic type arguments to encode all aspects of the transaction.

It is future-like, does nothing by itself, it needs a specialized method call to actually run or send it.

Rationale: https://twitter.com/andreimmarinica/status/1777157322155966601

Fields§

§env: Env§from: From§to: To§payment: Payment§gas: Gas§data: Data§result_handler: RH

Implementations§

Source§

impl<Api> Tx<TxScEnv<Api>, (), ManagedAddress<Api>, Egld<BigUint<Api>>, (), FunctionCall<Api>, Option<CallbackClosure<Api>>>
where Api: CallTypeApi,

Source

pub fn with_callback(self, callback_call: CallbackClosure<Api>) -> Self

Source§

impl<Api> Tx<TxScEnv<Api>, (), ManagedAddress<Api>, Egld<BigUint<Api>>, (), FunctionCall<Api>, Option<CallbackClosure<Api>>>

Source§

impl<Env, From, To, Payment, Gas, Data, RH> Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxDataFunctionCall<Env>, RH: TxResultHandler<Env>,

Source

pub fn to_call_data_string(&self) -> ManagedBuffer<Env::Api>

Converts object to a MultiversX transaction data field string.

Source§

impl<Env> Tx<Env, (), (), (), (), (), ()>
where Env: TxEnv,

Source

pub fn new_with_env(env: Env) -> Self

Constructor, needs to take an environment object.

Source§

impl<Env, To, Payment, Gas, Data, RH> Tx<Env, (), To, Payment, Gas, Data, RH>
where Env: TxEnv, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn from<From>(self, from: From) -> Tx<Env, From, To, Payment, Gas, Data, RH>
where From: TxFrom<Env>,

Specifies transaction sender.

Source§

impl<Env, From, Payment, Gas, Data, RH> Tx<Env, From, (), Payment, Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn to<To>(self, to: To) -> Tx<Env, From, To, Payment, Gas, Data, RH>
where To: TxTo<Env>,

Specifies the recipient of the transaction.

Allows argument to also be ().

Source§

impl<Env, From, To, Gas, Data, RH> Tx<Env, From, To, (), Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn payment<Payment>( self, payment: Payment, ) -> Tx<Env, From, To, Payment, Gas, Data, RH>
where Payment: TxPayment<Env>,

Adds any payment to a transaction, if no payment has been added before.

Source

pub fn egld<EgldValue>( self, egld_value: EgldValue, ) -> Tx<Env, From, To, Egld<EgldValue>, Gas, Data, RH>
where EgldValue: TxEgldValue<Env>,

Adds EGLD value to a transaction.

Accepts any type that can represent and EGLD amount: BigUint, &BigUint, etc.

Source

pub fn with_egld_transfer( self, egld_amount: BigUint<Env::Api>, ) -> Tx<Env, From, To, EgldPayment<Env::Api>, Gas, Data, RH>

Backwards compatibility. Use method egld instead.

Source

pub fn esdt<P: Into<EsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, EsdtTokenPayment<Env::Api>, Gas, Data, RH>

Adds the first single, owned ESDT token payment to a transaction.

Since this is the first ESDT payment, a single payment tx is produced.

Can subsequently be called again for multiple payments.

Source

pub fn single_esdt<'a>( self, token_identifier: &'a TokenIdentifier<Env::Api>, token_nonce: u64, amount: &'a BigUint<Env::Api>, ) -> Tx<Env, From, To, EsdtTokenPaymentRefs<'a, Env::Api>, Gas, Data, RH>

Sets a single token payment, with the token identifier and amount kept as references.

This is handy whem we only want one ESDT transfer and we want to avoid unnecessary object clones.

Source

pub fn egld_or_single_esdt<'a>( self, token_identifier: &'a EgldOrEsdtTokenIdentifier<Env::Api>, token_nonce: u64, amount: &'a BigUint<Env::Api>, ) -> Tx<Env, From, To, EgldOrEsdtTokenPaymentRefs<'a, Env::Api>, Gas, Data, RH>

Syntactic sugar for self.payment(EgldOrEsdtTokenPaymentRefs::new(...). Takes references.

Source

pub fn multi_esdt<IntoMulti>( self, payments: IntoMulti, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>
where IntoMulti: Into<MultiEsdtPayment<Env::Api>>,

Sets a collection of ESDT transfers as the payment of the transaction.

Can be formed from single ESDT payments, but the result will always be a collection.

Always converts the argument into an owned collection of ESDT payments. For work with references, use .payment(&p) instead.

Source

pub fn with_esdt_transfer<P: Into<EsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>

Backwards compatibility.

Source

pub fn with_multi_token_transfer( self, payments: MultiEsdtPayment<Env::Api>, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>

Backwards compatibility.

Source

pub fn with_egld_or_single_esdt_transfer<P: Into<EgldOrEsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, EgldOrEsdtTokenPayment<Env::Api>, Gas, Data, RH>

Backwards compatibility.

Source

pub fn egld_or_multi_esdt<P: Into<EgldOrMultiEsdtPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, EgldOrMultiEsdtPayment<Env::Api>, Gas, Data, RH>

Converts argument to EgldOrMultiEsdtPayment, then sets it as payment.

In most cases, payment should be used instead.

Source§

impl<Env, From, To, Gas, Data, RH> Tx<Env, From, To, EsdtTokenPayment<Env::Api>, Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn esdt<P: Into<EsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>

Adds the second ESDT token transfer to a contract call.

Can be called multiple times on the same call.

When the Tx already contains a single (owned) ESDT payment, adding the second one will convert it to a list.

Source§

impl<Env, From, To, Gas, Data, RH> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn esdt<P: Into<EsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>

Adds a single ESDT token transfer to a contract call.

Can be called multiple times on the same call.

Source

pub fn multi_esdt<P: Into<EsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>

When the Tx already contains an owned collection of ESDT payments, calling multi_esdt is equivalent to esdt, it just adds another payment to the list.

Can be called multiple times.

Source

pub fn with_esdt_transfer<P: Into<EsdtTokenPayment<Env::Api>>>( self, payment: P, ) -> Tx<Env, From, To, MultiEsdtPayment<Env::Api>, Gas, Data, RH>

Backwards compatibility.

Source§

impl<Env, From, To, Payment, Data, RH> Tx<Env, From, To, Payment, (), Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn gas<GasValue>( self, gas_value: GasValue, ) -> Tx<Env, From, To, Payment, ExplicitGas<GasValue>, Data, RH>
where GasValue: TxGasValue<Env>,

Sets an explicit gas limit to the call.

Source

pub fn with_gas_limit( self, gas_limit: u64, ) -> Tx<Env, From, To, Payment, ExplicitGas<u64>, Data, RH>

Backwards compatibility.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, (), RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn raw_call<N: Into<ManagedBuffer<Env::Api>>>( self, function_name: N, ) -> Tx<Env, From, To, Payment, Gas, FunctionCall<Env::Api>, RH>

Starts a contract call, serialized by hand.

Whenever possible, should use proxies instead, since manual serialization is not type-safe.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, FunctionCall<Env::Api>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn into_function_call(self) -> FunctionCall<Env::Api>

Converts tx to a simple FunctionCall, to be used as argument or data in contracts.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, FunctionCall<Env::Api>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxToSpecified<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn normalize( self, ) -> Tx<Env, From, ManagedAddress<Env::Api>, EgldPayment<Env::Api>, Gas, FunctionCall<Env::Api>, RH>

Produces the normalized function call, i.e. with builtin function calls for ESDT transfers.

The resulting transaction can differ from the input in several ways:

  • the recipient is changed (some builtin functions are called with recipient = sender),
  • the function call becomes a builtin function call.
§Important

Do not call this before sending transactions! Normalization is don automatically whenever necessary. Only use when you need the normalized data, e.g. for a multisig.

§Warning

To produce owned values, some clones are performed. It is not optimized for contracts, but can be used nonetheless.

Source§

impl<Env, From, Payment, Gas> Tx<Env, From, (), Payment, Gas, (), ()>
where Env: TxEnv, From: TxFrom<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>,

Source

pub fn legacy_proxy_call<Env2, To, O>( self, call: Tx<Env2, (), To, (), (), FunctionCall<Env::Api>, OriginalResultMarker<O>>, ) -> Tx<Env, From, To, Payment, Gas, FunctionCall<Env::Api>, OriginalResultMarker<O>>
where Env2: TxEnv<Api = Env::Api>, To: TxTo<Env> + TxTo<Env2>,

Merges the argument data into the current tx. Used for function calls originating in legacy proxies.

Different environment in the argument allowed because of compatibility with old proxies.

Method still subject to considerable change.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, FunctionCall<Env::Api>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn argument<T: TopEncodeMulti>(self, arg: &T) -> Self

Adds argument to function call.

Whenever possible, use proxies instead.

It serializes the value, but does not enforce type safety.

Source

pub fn arguments_raw(self, raw: ManagedArgBuffer<Env::Api>) -> Self

Adds serialized argument to function call.

Whenever possible, use proxies instead.

Doesa not serialize, does not enforce type safety.

Source§

impl<Env, From, To, Payment, Gas, Data> Tx<Env, From, To, Payment, Gas, Data, ()>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>,

Source

pub fn original_result<OriginalResult>( self, ) -> Tx<Env, From, To, Payment, Gas, Data, OriginalResultMarker<OriginalResult>>

Type marker to set the original contract or VM function return type.

Only the compile-time type annotation is given.

Source§

impl<Env, From, To, Gas> Tx<Env, From, To, (), Gas, (), ()>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Gas: TxGas<Env>,

Source

pub fn typed<Proxy>(self, proxy: Proxy) -> Proxy::TxProxyMethods
where Proxy: TxProxyTrait<Env, From, To, Gas>,

Starts a proxy call, deploy, or upgrade.

The proxy object will be given, the subsequent call will be from a proxy context, containing all the contract endpoint names.

Source§

impl<Env, From, To, Payment, Gas, Data, ResultList> Tx<Env, From, To, Payment, Gas, Data, ResultList>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>, ResultList: RHList<Env>,

Source

pub fn with_result<ResultHandler>( self, result_handler: ResultHandler, ) -> Tx<Env, From, To, Payment, Gas, Data, ResultList::NoRetOutput>
where ResultHandler: RHListItem<Env, ResultList::OriginalResult, Returns = ()>, ResultList: RHListAppendNoRet<Env, ResultHandler>,

Adds a result handler that doesn’t return anything.

Source

pub fn returns<RH>( self, item: RH, ) -> Tx<Env, From, To, Payment, Gas, Data, ResultList::RetOutput>
where RH: RHListItem<Env, ResultList::OriginalResult>, ResultList: RHListAppendRet<Env, RH>,

Adds a result handler that can also return processed data.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, (), RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn raw_deploy( self, ) -> Tx<Env, From, To, Payment, Gas, DeployCall<Env, ()>, RH>

Starts a contract deploy call, serialized by hand.

Whenever possible, should use proxies instead, since manual serialization is not type-safe.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, ()>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn code<CodeValue>( self, code: CodeValue, ) -> Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, Code<CodeValue>>, RH>
where CodeValue: TxCodeValue<Env>,

Sets upgrade code source as explicit code bytes.

Source

pub fn from_source<FromSourceValue>( self, source_address: FromSourceValue, ) -> Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, FromSource<FromSourceValue>>, RH>
where FromSourceValue: TxFromSourceValue<Env>,

Sets upgrade code source as another deployed contract code.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, DeployCall<Env, ()>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn code<CodeValue>( self, code: CodeValue, ) -> Tx<Env, From, To, Payment, Gas, DeployCall<Env, Code<CodeValue>>, RH>
where CodeValue: TxCodeValue<Env>,

Sets deploy code source as explicit code bytes.

Source

pub fn from_source<FromSourceValue>( self, source_address: FromSourceValue, ) -> Tx<Env, From, To, Payment, Gas, DeployCall<Env, FromSource<FromSourceValue>>, RH>
where FromSourceValue: TxFromSourceValue<Env>,

Sets deploy code source as another deployed contract code.

Source§

impl<Env, From, To, Payment, Gas, CodeSource, RH> Tx<Env, From, To, Payment, Gas, DeployCall<Env, CodeSource>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, CodeSource: TxCodeSource<Env>, RH: TxResultHandler<Env>,

Source

pub fn code_metadata(self, code_metadata: CodeMetadata) -> Self

Sets code metadata to deploy.

Source

pub fn argument<T: TopEncodeMulti>(self, arg: &T) -> Self

Adds argument to a contract deploy.

Whenever possible, use proxies instead.

It serializes the value, but does not enforce type safety.

Source

pub fn arguments_raw(self, raw: ManagedArgBuffer<Env::Api>) -> Self

Adds serialized argument to a contract deploy.

Whenever possible, use proxies instead.

Does not serialize, does not enforce type safety.

Source§

impl<Env, From, To, Payment, Gas, CodeSource, RH> Tx<Env, From, To, Payment, Gas, DeployCall<Env, CodeSource>, RH>
where Env: TxEnvMockDeployAddress, From: TxFromSpecified<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, CodeSource: TxCodeSource<Env>, RH: TxResultHandler<Env>,

Source

pub fn new_address<NA>(self, new_address: NA) -> Self
where NA: AnnotatedValue<Env, ManagedAddress<Env::Api>>,

Sets the new mock address to be used for the newly deployed contract.

Only allowed in tests.

Source§

impl<Env, From, To, Payment, Gas, RH> Tx<Env, From, To, Payment, Gas, (), RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, RH: TxResultHandler<Env>,

Source

pub fn raw_upgrade( self, ) -> Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, ()>, RH>

Starts a contract deploy upgrade, serialized by hand.

Whenever possible, should use proxies instead, since manual serialization is not type-safe.

Source§

impl<Env, From, To, Payment, Gas, CodeSource, RH> Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, CodeSource>, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPaymentEgldOnly<Env>, Gas: TxGas<Env>, CodeSource: TxCodeSource<Env>, RH: TxResultHandler<Env>,

Source

pub fn code_metadata(self, code_metadata: CodeMetadata) -> Self

Source

pub fn argument<T: TopEncodeMulti>(self, arg: &T) -> Self

Adds argument to upgrade call.

Whenever possible, use proxies instead.

It serializes the value, but does not enforce type safety.

Source

pub fn arguments_raw(self, raw: ManagedArgBuffer<Env::Api>) -> Self

Adds serialized argument to an upgrade call.

Whenever possible, use proxies instead.

Doesa not serialize, does not enforce type safety.

Source§

impl<Env, From, To, Payment, Gas, Data, RH> Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: TxEnvWithTxHash, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn tx_hash<H>(self, tx_hash: H) -> Self
where H256: From<H>,

Sets the mock transaction hash to be used in a test.

Only allowed in tests.

Source§

impl<Api> Tx<TxScEnv<Api>, (), (), (), (), (), ()>
where Api: CallTypeApi,

Source

pub fn new_tx_from_sc() -> Self

Source§

impl<Api, To, Payment, Gas, Data, EmptyRH> Tx<TxScEnv<Api>, (), To, Payment, Gas, Data, EmptyRH>
where Api: CallTypeApi, To: TxTo<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, Data: TxData<TxScEnv<Api>>, EmptyRH: TxEmptyResultHandler<TxScEnv<Api>>,

Source

pub fn callback<RH>( self, callback: RH, ) -> Tx<TxScEnv<Api>, (), To, Payment, Gas, Data, RH>
where RH: TxAsyncCallCallback<Api>,

Source§

impl<Api, To, Payment, Gas, FC, EmptyRH> Tx<TxScEnv<Api>, (), To, Payment, Gas, FC, EmptyRH>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, FC: TxDataFunctionCall<TxScEnv<Api>>, EmptyRH: TxEmptyResultHandler<TxScEnv<Api>>,

Source

pub fn with_callback<RH>( self, callback: RH, ) -> Tx<TxScEnv<Api>, (), To, Payment, Gas, FC, RH>
where RH: TxAsyncCallCallback<Api>,

Backwards compatibility.

Source§

impl<Api, To, Payment, FC, RH> Tx<TxScEnv<Api>, (), To, Payment, (), FC, RH>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, FC: TxDataFunctionCall<TxScEnv<Api>>, RH: TxAsyncCallCallback<Api>,

Source

pub fn async_call_and_exit(self) -> !

Source

pub fn call_and_exit(self) -> !

Source§

impl<Env, From, To, Payment, Gas, Data, RH> Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: TxEnv, From: TxFrom<Env>, To: TxTo<Env>, Payment: TxPayment<Env>, Gas: TxGas<Env>, Data: TxData<Env>, RH: TxResultHandler<Env>,

Source

pub fn async_call(self) -> Tx<Env, From, To, Payment, Gas, Data, RH>

👎Deprecated since 0.50.2: Backwards compatibility only, does nothing. Just delete. Use async_call_and_exit to launch asynchronous calls.

Backwards compatibility only.

Source§

impl<Api, To, Payment, Gas> Tx<TxScEnv<Api>, (), To, Payment, Gas, FunctionCall<Api>, CallbackClosure<Api>>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>,

Source

pub fn gas_for_callback( self, gas: u64, ) -> Tx<TxScEnv<Api>, (), To, Payment, Gas, FunctionCall<Api>, CallbackClosureWithGas<Api>>

Source

pub fn with_extra_gas_for_callback( self, gas: u64, ) -> Tx<TxScEnv<Api>, (), To, Payment, Gas, FunctionCall<Api>, CallbackClosureWithGas<Api>>

Backwards compatibility.

Source§

impl<Api, To, Payment, GasValue, Callback> Tx<TxScEnv<Api>, (), To, Payment, ExplicitGas<GasValue>, FunctionCall<Api>, Callback>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, GasValue: TxGasValue<TxScEnv<Api>>, Callback: TxPromisesCallback<Api>,

Source

pub fn register_promise(self)

Launches a transaction as an asynchronous promise (async v2 mechanism).

Several such transactions can be launched from a single transaction.

Must set:

  • to
  • gas
  • a function call, ideally via a proxy.

Value-only promises are not supported.

Optionally, can add:

  • any payment
  • a promise callback, which also needs explicit gas for callback.
Source§

impl<Api, To, Payment, GasValue, Callback> Tx<TxScEnv<Api>, (), To, Payment, ExplicitGas<GasValue>, (), Callback>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, GasValue: TxGasValue<TxScEnv<Api>>, Callback: TxPromisesCallback<Api>,

Source

pub fn register_promise(self)

Launches a transaction as an asynchronous promise (async v2 mechanism), but without calling any function on the destination.

Such calls are useful for appending callbacks to simple transfers, mitigating edge cases such as non-payable SCs and frozen assets.

Source§

impl<Api, To, Payment, Callback> Tx<TxScEnv<Api>, (), To, Payment, (), FunctionCall<Api>, Callback>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Callback: TxPromisesCallback<Api>,

Source

pub unsafe fn register_promise(self)

§Incorrect call

Must set gas in order to call register_promise.

§Safety

This version of the method must never be called. It is only here to provide a more readable error.

Source§

impl<Api, To, Payment, Callback> Tx<TxScEnv<Api>, (), To, Payment, (), (), Callback>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Callback: TxPromisesCallback<Api>,

Source

pub unsafe fn register_promise(self)

§Incorrect call

Must set gas in order to call register_promise, even when no SC endpoint is called.

§Safety

This version of the method must never be called. It is only here to provide a more readable error.

Source§

impl<Api, To, Payment, Gas, Callback> Tx<TxScEnv<Api>, (), To, Payment, Gas, FunctionCall<Api>, Callback>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, Callback: TxPromisesCallback<Api>,

Source

pub fn async_call_promise(self) -> Self

👎Deprecated since 0.50.2: Backwards compatibility only, does nothing. Just delete. Use register_promise to launch asynchronous calls.

Backwards compatibility only.

Source§

impl<Api, Payment, Gas, CodeValue, RH> Tx<TxScEnv<Api>, (), (), Payment, Gas, DeployCall<TxScEnv<Api>, Code<CodeValue>>, RH>
where Api: CallTypeApi, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, CodeValue: TxCodeValue<TxScEnv<Api>>, RH: RHListExec<DeployRawResult<Api>, TxScEnv<Api>>, RH::ListReturns: NestedTupleFlatten,

Source

pub fn sync_call(self) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked

Synchronously deploys a contract.

Source§

impl<Api, Payment, Gas, FromSourceValue, RH> Tx<TxScEnv<Api>, (), (), Payment, Gas, DeployCall<TxScEnv<Api>, FromSource<FromSourceValue>>, RH>
where Api: CallTypeApi, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, FromSourceValue: TxFromSourceValue<TxScEnv<Api>>, RH: RHListExec<DeployRawResult<Api>, TxScEnv<Api>>, RH::ListReturns: NestedTupleFlatten,

Source

pub fn sync_call(self) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked

Synchronously deploys a contract from source.

Source§

impl<Api, Payment, Gas, OriginalResult> Tx<TxScEnv<Api>, (), (), Payment, Gas, DeployCall<TxScEnv<Api>, ()>, OriginalResultMarker<OriginalResult>>
where Api: CallTypeApi, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, OriginalResult: TopEncodeMulti,

Source

pub fn deploy_contract<RequestedResult>( self, code: &ManagedBuffer<Api>, code_metadata: CodeMetadata, ) -> (ManagedAddress<Api>, RequestedResult)
where RequestedResult: TopDecodeMulti + TypeAbiFrom<OriginalResult>,

Backwards compatibility, immitates the old API.

Note that the data type (the DeployCall) doesn’t have the code set. This is because the old API was passing it as paramter, so we use it from the code argument.

Also note that the code metadata is taken from the code_metadata argument. If another one was previously set in the Tx object, that one will be ignored.

Source

pub fn deploy_from_source<RequestedResult>( self, source_address: &ManagedAddress<Api>, code_metadata: CodeMetadata, ) -> (ManagedAddress<Api>, RequestedResult)
where RequestedResult: TopDecodeMulti + TypeAbiFrom<OriginalResult>,

Backwards compatibility, immitates the old API.

Note that the data type (the DeployCall) doesn’t have the code set. This is because the old API was passing it as paramter, so we use it from the code argument.

Also note that the code metadata is taken from the code_metadata argument. If another one was previously set in the Tx object, that one will be ignored.

Source§

impl<Api, Payment, Gas, OriginalResult> Tx<TxScEnv<Api>, (), ManagedAddress<Api>, Payment, Gas, DeployCall<TxScEnv<Api>, ()>, OriginalResultMarker<OriginalResult>>
where Api: CallTypeApi, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, OriginalResult: TopEncodeMulti,

Source

pub fn upgrade_contract( self, code: &ManagedBuffer<Api>, code_metadata: CodeMetadata, )

👎Deprecated since 0.49.0: The legacy upgrade method does not correctly take the upgrade constructor into account. Please switch to the new syntax.

Backwards compatibility, immitates the old API.

Should no longer be used, which is why unlike all the rest of the old syntax, was deprecated.

Uses a DeployCall instead of the correct UpgradeCall, because the old syntax did not know about upgrades.

Note that the data type (the DeployCall) doesn’t have the code set. This is because the old API was passing it as paramter, so we use it from the code argument.

Also note that the code metadata is taken from the code_metadata argument. If another one was previously set in the Tx object, that one will be ignored.

Source

pub fn upgrade_from_source( self, source_address: &ManagedAddress<Api>, code_metadata: CodeMetadata, )

👎Deprecated since 0.49.0: The legacy upgrade method does not correctly take the upgrade constructor into account. Please switch to the new syntax.

Backwards compatibility, immitates the old API.

Should no longer be used, which is why unlike all the rest of the old syntax, was deprecated.

Uses a DeployCall instead of the correct UpgradeCall, because the old syntax did not know about upgrades.

Note that the data type (the DeployCall) doesn’t have the code set. This is because the old API was passing it as paramter, so we use it from the code argument.

Also note that the code metadata is taken from the code_metadata argument. If another one was previously set in the Tx object, that one will be ignored.

Source§

impl<Api, To, Payment, Gas, FC, RH> Tx<TxScEnv<Api>, (), To, Payment, Gas, FC, RH>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, FC: TxDataFunctionCall<TxScEnv<Api>>, RH: RHListExec<SyncCallRawResult<Api>, TxScEnv<Api>>, RH::ListReturns: NestedTupleFlatten,

Source

pub fn sync_call(self) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked

Executes transaction synchronously.

Only works with contracts from the same shard.

Source

pub fn sync_call_same_context( self, ) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked

Executes transaction synchronously, in the same context (performed in the name of the caller).

Only works with contracts from the same shard.

Source§

impl<Api, To, Payment, Gas, FC, RH> Tx<TxScEnv<Api>, (), To, Payment, Gas, FC, RH>

Source

pub fn sync_call_readonly( self, ) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked

Executes transaction synchronously, in readonly mode (target contract cannot have its state altered).

Only works with contracts from the same shard.

Source§

impl<Api, To, Payment, Gas, FC, OriginalResult> Tx<TxScEnv<Api>, (), To, Payment, Gas, FC, OriginalResultMarker<OriginalResult>>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, FC: TxDataFunctionCall<TxScEnv<Api>>,

Source

pub fn execute_on_dest_context<RequestedResult>(self) -> RequestedResult
where RequestedResult: TopDecodeMulti,

Backwards compatibility.

Source

pub fn execute_on_dest_context_with_back_transfers<RequestedResult>( self, ) -> (RequestedResult, BackTransfers<Api>)
where RequestedResult: TopDecodeMulti,

Backwards compatibility.

Source§

impl<Api, From, To, Payment, Gas, FC, RH> Tx<TxScEnv<Api>, From, To, Payment, Gas, FC, RH>
where Api: CallTypeApi, From: TxFrom<TxScEnv<Api>>, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, FC: TxData<TxScEnv<Api>> + Into<FunctionCall<Api>>, RH: TxEmptyResultHandler<TxScEnv<Api>>,

Source

pub fn transfer_execute(self)

Sends transaction asynchronously, and doesn’t wait for callback (“fire and forget”.)

Source§

impl<Api, From, To, Payment> Tx<TxScEnv<Api>, From, To, Payment, (), (), ()>
where Api: CallTypeApi, From: TxFrom<TxScEnv<Api>>, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>,

Source

pub fn transfer(self)

Only allowed for simple transfers.

Source

pub fn transfer_if_not_empty(self)

Transfers funds, if amount is greater than zero. Does nothing otherwise.

Can only used for simple transfers.

Source§

impl<Api, Payment, Gas, CodeValue, RH> Tx<TxScEnv<Api>, (), ManagedAddress<Api>, Payment, Gas, UpgradeCall<TxScEnv<Api>, Code<CodeValue>>, RH>
where Api: CallTypeApi, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, CodeValue: TxCodeValue<TxScEnv<Api>>, RH: TxEmptyResultHandler<TxScEnv<Api>>,

Source

pub fn upgrade_async_call_and_exit(self)

Launches the upgrade async call.

TODO: change return type to !.

Source§

impl<Api, Payment, Gas, FromSourceValue, RH> Tx<TxScEnv<Api>, (), ManagedAddress<Api>, Payment, Gas, UpgradeCall<TxScEnv<Api>, FromSource<FromSourceValue>>, RH>
where Api: CallTypeApi, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, FromSourceValue: TxFromSourceValue<TxScEnv<Api>>, RH: TxEmptyResultHandler<TxScEnv<Api>>,

Source

pub fn upgrade_async_call_and_exit(self)

Launches the upgrade from source async call.

TODO: change return type to !.

Source§

impl<Api, To, Payment, Gas, RH> Tx<TxScEnv<Api>, (), To, Payment, Gas, UpgradeCall<TxScEnv<Api>, ()>, RH>
where Api: CallTypeApi, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, Gas: TxGas<TxScEnv<Api>>, RH: TxEmptyResultHandler<TxScEnv<Api>>,

Source

pub fn upgrade_contract( self, code: &ManagedBuffer<Api>, code_metadata: CodeMetadata, )

👎Deprecated since 0.49.0: This is a transition syntax, it would not have been reachable before 0.49.0. Use [upgrade_async_call_and_exit] instead.

Transition syntax, immitates the old API.

Note that the data type (the UpgradeCall) doesn’t have the code set. This is because the old API was passing it as paramter, so we use it from the code argument.

Also note that the code metadata is taken from the code_metadata argument. If another one was previously set in the Tx object, that one will be ignored.

Source

pub fn upgrade_from_source( self, source_address: &ManagedAddress<Api>, code_metadata: CodeMetadata, )

👎Deprecated since 0.49.0: This is a transition syntax, it would not have been reachable before 0.49.0. Use [upgrade_async_call_and_exit] instead.

Transition syntax, immitates the old API.

Note that the data type (the UpgradeCall) doesn’t have the code set. This is because the old API was passing it as paramter, so we use it from the code argument.

Also note that the code metadata is taken from the code_metadata argument. If another one was previously set in the Tx object, that one will be ignored.

Trait Implementations§

Source§

impl<Api, To, Payment, OriginalResult> ContractCallBase<Api> for Tx<TxScEnv<Api>, (), To, Payment, (), FunctionCall<Api>, OriginalResultMarker<OriginalResult>>
where Api: CallTypeApi + 'static, To: TxToSpecified<TxScEnv<Api>>, Payment: TxPayment<TxScEnv<Api>>, OriginalResult: TopEncodeMulti,

Source§

type OriginalResult = OriginalResult

👎Deprecated since 0.49.0: Please use the unified transaction syntax instead.
Source§

impl<Api, To, Payment, OriginalResult> From<Tx<TxScEnv<Api>, (), To, Payment, (), DeployCall<TxScEnv<Api>, ()>, OriginalResultMarker<OriginalResult>>> for ContractDeploy<Api, OriginalResult>
where Api: CallTypeApi + 'static, To: TxTo<TxScEnv<Api>>, Payment: TxPaymentEgldOnly<TxScEnv<Api>>, OriginalResult: TopEncodeMulti,

Source§

fn from( value: Tx<TxScEnv<Api>, (), To, Payment, (), DeployCall<TxScEnv<Api>, ()>, OriginalResultMarker<OriginalResult>>, ) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Env, From, To, Payment, Gas, Data, RH> Freeze for Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: Freeze, From: Freeze, To: Freeze, Payment: Freeze, Gas: Freeze, Data: Freeze, RH: Freeze,

§

impl<Env, From, To, Payment, Gas, Data, RH> RefUnwindSafe for Tx<Env, From, To, Payment, Gas, Data, RH>

§

impl<Env, From, To, Payment, Gas, Data, RH> Send for Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: Send, From: Send, To: Send, Payment: Send, Gas: Send, Data: Send, RH: Send,

§

impl<Env, From, To, Payment, Gas, Data, RH> Sync for Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: Sync, From: Sync, To: Sync, Payment: Sync, Gas: Sync, Data: Sync, RH: Sync,

§

impl<Env, From, To, Payment, Gas, Data, RH> Unpin for Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: Unpin, From: Unpin, To: Unpin, Payment: Unpin, Gas: Unpin, Data: Unpin, RH: Unpin,

§

impl<Env, From, To, Payment, Gas, Data, RH> UnwindSafe for Tx<Env, From, To, Payment, Gas, Data, RH>
where Env: UnwindSafe, From: UnwindSafe, To: UnwindSafe, Payment: UnwindSafe, Gas: UnwindSafe, Data: UnwindSafe, RH: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.