multiversx_sc/api/external_view/
ev_wrapper.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
use core::marker::PhantomData;

use crate::api::{
    BlockchainApi, CallTypeApi, CallValueApi, CryptoApi, EndpointArgumentApi, EndpointFinishApi,
    ErrorApi, HandleTypeInfo, LogApi, ManagedTypeApi, PrintApi, SendApi, StaticVarApi,
    StorageMapperApi, StorageWriteApi, VMApi,
};

#[derive(Clone)]
pub struct ExternalViewApi<A: VMApi> {
    _phantom: PhantomData<A>,
}

impl<A: VMApi> ExternalViewApi<A> {
    pub(super) fn new() -> Self {
        ExternalViewApi {
            _phantom: PhantomData,
        }
    }
}

impl<A> HandleTypeInfo for ExternalViewApi<A>
where
    A: VMApi,
{
    type ManagedBufferHandle = <A as HandleTypeInfo>::ManagedBufferHandle;

    type BigIntHandle = <A as HandleTypeInfo>::BigIntHandle;

    type BigFloatHandle = <A as HandleTypeInfo>::BigFloatHandle;

    type EllipticCurveHandle = <A as HandleTypeInfo>::EllipticCurveHandle;

    type ManagedMapHandle = <A as HandleTypeInfo>::ManagedMapHandle;
}

impl<A> BlockchainApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type BlockchainApiImpl = A::BlockchainApiImpl;

    fn blockchain_api_impl() -> A::BlockchainApiImpl {
        A::blockchain_api_impl()
    }
}

impl<A> CallValueApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type CallValueApiImpl = A::CallValueApiImpl;

    fn call_value_api_impl() -> Self::CallValueApiImpl {
        A::call_value_api_impl()
    }
}

impl<A> CryptoApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type CryptoApiImpl = A::CryptoApiImpl;

    fn crypto_api_impl() -> Self::CryptoApiImpl {
        A::crypto_api_impl()
    }
}

impl<A> EndpointArgumentApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type EndpointArgumentApiImpl = A::EndpointArgumentApiImpl;

    fn argument_api_impl() -> Self::EndpointArgumentApiImpl {
        A::argument_api_impl()
    }
}

impl<A> EndpointFinishApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type EndpointFinishApiImpl = A::EndpointFinishApiImpl;

    fn finish_api_impl() -> Self::EndpointFinishApiImpl {
        A::finish_api_impl()
    }
}

impl<A> ErrorApi for super::ExternalViewApi<A>
where
    A: VMApi,
{
    type ErrorApiImpl = A::ErrorApiImpl;

    fn error_api_impl() -> Self::ErrorApiImpl {
        A::error_api_impl()
    }
}

impl<A> LogApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type LogApiImpl = A::LogApiImpl;

    fn log_api_impl() -> Self::LogApiImpl {
        A::log_api_impl()
    }
}

impl<A> ManagedTypeApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type ManagedTypeApiImpl = A::ManagedTypeApiImpl;

    fn managed_type_impl() -> Self::ManagedTypeApiImpl {
        A::managed_type_impl()
    }
}

impl<A> PrintApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type PrintApiImpl = A::PrintApiImpl;

    fn print_api_impl() -> Self::PrintApiImpl {
        A::print_api_impl()
    }
}

impl<A> SendApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type SendApiImpl = A::SendApiImpl;

    fn send_api_impl() -> Self::SendApiImpl {
        A::send_api_impl()
    }
}

impl<A> StaticVarApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type StaticVarApiImpl = A::StaticVarApiImpl;

    fn static_var_api_impl() -> Self::StaticVarApiImpl {
        A::static_var_api_impl()
    }
}

impl<A> StorageWriteApi for ExternalViewApi<A>
where
    A: VMApi,
{
    type StorageWriteApiImpl = A::StorageWriteApiImpl;

    fn storage_write_api_impl() -> Self::StorageWriteApiImpl {
        A::storage_write_api_impl()
    }
}

impl<A> CallTypeApi for ExternalViewApi<A> where A: VMApi {}

impl<A> StorageMapperApi for ExternalViewApi<A> where A: VMApi {}

impl<A> VMApi for ExternalViewApi<A>
where
    A: VMApi,
{
    fn external_view_init_override() -> bool {
        true
    }
}

impl<A> PartialEq for ExternalViewApi<A>
where
    A: VMApi,
{
    fn eq(&self, _: &Self) -> bool {
        true
    }
}

impl<A> Eq for ExternalViewApi<A> where A: VMApi {}