multiversx_sc/contract_base/
universal_contract_obj.rs

1use core::marker::PhantomData;
2
3use crate::api::VMApi;
4
5use super::ContractBase;
6
7/// A unique empty structure that automatically implements all smart contract traits.
8///
9/// The smart contract macros will automatically also generate trait implementations for this type. These include:
10/// - the contract trait
11/// - the `AutoImpl` trait
12/// - the `EndpointWrappers` trait
13///
14/// When generating WASM, this contract implementation is used.
15/// This makes sure no monomorphization-induced code duplication occurs in relation to modules.
16pub struct UniversalContractObj<A>
17where
18    A: VMApi,
19{
20    _phantom: PhantomData<A>,
21}
22
23impl<A> UniversalContractObj<A>
24where
25    A: VMApi,
26{
27    pub fn new() -> Self {
28        Self {
29            _phantom: PhantomData,
30        }
31    }
32}
33
34impl<A> Default for UniversalContractObj<A>
35where
36    A: VMApi,
37{
38    fn default() -> Self {
39        Self::new()
40    }
41}
42
43impl<A> ContractBase for UniversalContractObj<A>
44where
45    A: VMApi,
46{
47    type Api = A;
48}