multiversx_sc/contract_base/
proxy_obj_base.rs

1use crate::{
2    api::VMApi,
3    types::{ManagedAddress, ManagedOption, TxScEnv, TxTo},
4};
5
6pub trait ProxyObjBase {
7    type Api: VMApi;
8    type To: TxTo<TxScEnv<Self::Api>>;
9
10    /// Extracts the address contained in the proxy object and replaces it with None.
11    ///
12    /// Will just return `ManagedOption::none()` if no address was specified.
13    #[doc(hidden)]
14    fn extract_opt_address(&mut self) -> ManagedOption<Self::Api, ManagedAddress<Self::Api>>;
15
16    /// Extracts the address contained in the proxy object and replaces it with None.
17    ///
18    /// Will crash if no address was specified.
19    #[doc(hidden)]
20    fn extract_address(&mut self) -> ManagedAddress<Self::Api>;
21
22    #[doc(hidden)]
23    fn extract_proxy_to(&mut self) -> Self::To;
24}
25
26pub trait ProxyObjNew: ProxyObjBase {
27    type ProxyTo: ProxyObjBase;
28
29    #[doc(hidden)]
30    fn new_proxy_obj() -> Self;
31
32    /// Specify the target contract to call.
33    /// Not taken into account for deploys.
34    #[must_use]
35    fn contract(self, address: ManagedAddress<Self::Api>) -> Self::ProxyTo;
36}