multiversx_sc/types/interaction/
tx_proxy.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use multiversx_sc_codec::TopEncodeMulti;

use crate::abi::TypeAbiFrom;

use super::{
    DeployCall, FunctionCall, OriginalResultMarker, Tx, TxEnv, TxFrom, TxGas, TxTo, UpgradeCall,
};

/// Defines a proxy object for a smart contract.
pub trait TxProxyTrait<Env, From, To, Gas>
where
    Env: TxEnv,
    From: TxFrom<Env>,
    To: TxTo<Env>,
    Gas: TxGas<Env>,
{
    type TxProxyMethods;

    /// Creates the associated type that contains the proxy methods implementations.
    fn proxy_methods(self, tx: Tx<Env, From, To, (), Gas, (), ()>) -> Self::TxProxyMethods;
}

/// Alias for a `Tx` generated from a proxy, in `init`.
///
/// Replaced by `TxTypedDeploy`.
pub type TxProxyDeploy<Env, From, Gas, Original> =
    Tx<Env, From, (), (), Gas, DeployCall<Env, ()>, OriginalResultMarker<Original>>;

/// Alias for a `Tx` generated from a proxy, in `init`.
pub type TxTypedDeploy<Env, From, Payment, Gas, Original> =
    Tx<Env, From, (), Payment, Gas, DeployCall<Env, ()>, OriginalResultMarker<Original>>;

/// Alias for a `Tx` generated from a proxy, in an endpoint.
///
/// Replaced by `TxTypedCall`.
pub type TxProxyCall<Env, From, To, Gas, Original> =
    Tx<Env, From, To, (), Gas, FunctionCall<<Env as TxEnv>::Api>, OriginalResultMarker<Original>>;

/// Alias for a `Tx` generated from a proxy, in an endpoint.
pub type TxTypedCall<Env, From, To, Payment, Gas, Original> = Tx<
    Env,
    From,
    To,
    Payment,
    Gas,
    FunctionCall<<Env as TxEnv>::Api>,
    OriginalResultMarker<Original>,
>;

/// Alias for a `Tx` generated from a proxy, in `upgrade`.
///
/// Replaced by `TxTypedUpgrade`.
pub type TxProxyUpgrade<Env, From, To, Gas, Original> =
    Tx<Env, From, To, (), Gas, UpgradeCall<Env, ()>, OriginalResultMarker<Original>>;

/// Alias for a `Tx` generated from a proxy, in `upgrade`.
pub type TxTypedUpgrade<Env, From, To, Payment, Gas, Original> =
    Tx<Env, From, To, Payment, Gas, UpgradeCall<Env, ()>, OriginalResultMarker<Original>>;

/// Trait that is automatically implemented for all types that are allowed as proxy inputs.
///
/// Is automatically implemented for all traits that are `TypeAbiInto<O> + TopEncodeMulti`.
pub trait ProxyArg<O>: TopEncodeMulti {}

impl<O, T> ProxyArg<O> for T
where
    O: TypeAbiFrom<T>,
    T: TopEncodeMulti,
{
}