multiversx_sc_modules/token_merge/
custom_merged_token_attributes.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
71
72
73
74
75
multiversx_sc::imports!();

use core::marker::PhantomData;

use multiversx_sc::codec::Empty;

use super::merged_token_instances::MergedTokenInstances;

pub trait AllMergeScTraits:
    super::merged_token_setup::MergedTokenSetupModule
    + crate::default_issue_callbacks::DefaultIssueCallbacksModule
    + crate::pause::PauseModule
{
}

impl<T> AllMergeScTraits for T where
    T: super::merged_token_setup::MergedTokenSetupModule
        + crate::default_issue_callbacks::DefaultIssueCallbacksModule
        + crate::pause::PauseModule
{
}

pub trait MergedTokenAttributesCreator {
    type ScType: AllMergeScTraits;
    type AttributesType: TopEncode + TopDecode;

    fn get_merged_token_attributes(
        &self,
        sc: &Self::ScType,
        merged_token_id: &TokenIdentifier<<Self::ScType as ContractBase>::Api>,
        merged_token_raw_attributes: &MergedTokenInstances<<Self::ScType as ContractBase>::Api>,
    ) -> Self::AttributesType;
}

pub struct DefaultMergedAttributesWrapper<Sc: AllMergeScTraits> {
    _phantom: PhantomData<Sc>,
}

impl<Sc> DefaultMergedAttributesWrapper<Sc>
where
    Sc: AllMergeScTraits,
{
    #[inline]
    pub fn new() -> Self {
        Self {
            _phantom: PhantomData,
        }
    }
}

impl<Sc> Default for DefaultMergedAttributesWrapper<Sc>
where
    Sc: AllMergeScTraits,
{
    fn default() -> Self {
        Self::new()
    }
}

impl<Sc> MergedTokenAttributesCreator for DefaultMergedAttributesWrapper<Sc>
where
    Sc: AllMergeScTraits,
{
    type ScType = Sc;
    type AttributesType = Empty;

    fn get_merged_token_attributes(
        &self,
        _sc: &Self::ScType,
        _merged_token_id: &TokenIdentifier<<Self::ScType as ContractBase>::Api>,
        _merged_token_raw_attributes: &MergedTokenInstances<<Self::ScType as ContractBase>::Api>,
    ) -> Self::AttributesType {
        Empty
    }
}