multiversx_sc/types/interaction/
tx_proxy.rs

1use multiversx_sc_codec::TopEncodeMulti;
2
3use crate::abi::TypeAbiFrom;
4
5use super::{
6    DeployCall, FunctionCall, OriginalResultMarker, Tx, TxEnv, TxFrom, TxGas, TxTo, UpgradeCall,
7};
8
9/// Defines a proxy object for a smart contract.
10pub trait TxProxyTrait<Env, From, To, Gas>
11where
12    Env: TxEnv,
13    From: TxFrom<Env>,
14    To: TxTo<Env>,
15    Gas: TxGas<Env>,
16{
17    type TxProxyMethods;
18
19    /// Creates the associated type that contains the proxy methods implementations.
20    fn proxy_methods(self, tx: Tx<Env, From, To, (), Gas, (), ()>) -> Self::TxProxyMethods;
21}
22
23/// Alias for a `Tx` generated from a proxy, in `init`.
24///
25/// Replaced by `TxTypedDeploy`.
26pub type TxProxyDeploy<Env, From, Gas, Original> =
27    Tx<Env, From, (), (), Gas, DeployCall<Env, ()>, OriginalResultMarker<Original>>;
28
29/// Alias for a `Tx` generated from a proxy, in `init`.
30pub type TxTypedDeploy<Env, From, Payment, Gas, Original> =
31    Tx<Env, From, (), Payment, Gas, DeployCall<Env, ()>, OriginalResultMarker<Original>>;
32
33/// Alias for a `Tx` generated from a proxy, in an endpoint.
34///
35/// Replaced by `TxTypedCall`.
36pub type TxProxyCall<Env, From, To, Gas, Original> =
37    Tx<Env, From, To, (), Gas, FunctionCall<<Env as TxEnv>::Api>, OriginalResultMarker<Original>>;
38
39/// Alias for a `Tx` generated from a proxy, in an endpoint.
40pub type TxTypedCall<Env, From, To, Payment, Gas, Original> = Tx<
41    Env,
42    From,
43    To,
44    Payment,
45    Gas,
46    FunctionCall<<Env as TxEnv>::Api>,
47    OriginalResultMarker<Original>,
48>;
49
50/// Alias for a `Tx` generated from a proxy, in `upgrade`.
51///
52/// Replaced by `TxTypedUpgrade`.
53pub type TxProxyUpgrade<Env, From, To, Gas, Original> =
54    Tx<Env, From, To, (), Gas, UpgradeCall<Env, ()>, OriginalResultMarker<Original>>;
55
56/// Alias for a `Tx` generated from a proxy, in `upgrade`.
57pub type TxTypedUpgrade<Env, From, To, Payment, Gas, Original> =
58    Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, ()>, OriginalResultMarker<Original>>;
59
60/// Trait that is automatically implemented for all types that are allowed as proxy inputs.
61///
62/// Is automatically implemented for all traits that are `TypeAbiInto<O> + TopEncodeMulti`.
63pub trait ProxyArg<O>: TopEncodeMulti {}
64
65impl<O, T> ProxyArg<O> for T
66where
67    O: TypeAbiFrom<T>,
68    T: TopEncodeMulti,
69{
70}