1use super::*;
2
3use alloc::vec::Vec;
4use multiversx_chain_core::types::{
5 Address, BLSKey, BLSSignature, BoxedBytes, CodeMetadata, DurationMillis, DurationSeconds,
6 EsdtLocalRole, EsdtTokenType, H256, TimestampMillis, TimestampSeconds,
7};
8
9impl TypeAbiFrom<Self> for H256 {}
10
11impl TypeAbi for H256 {
12 type Unmanaged = Self;
13
14 fn type_name() -> TypeName {
15 "H256".into()
16 }
17
18 fn type_name_rust() -> TypeName {
19 "H256".into()
20 }
21}
22
23impl TypeAbiFrom<Self> for Address {}
24
25impl TypeAbi for Address {
26 type Unmanaged = Self;
27
28 fn type_name() -> TypeName {
29 "Address".into()
30 }
31
32 fn type_name_rust() -> TypeName {
33 "Address".into()
34 }
35}
36
37impl TypeAbiFrom<Self> for BoxedBytes {}
38
39impl TypeAbi for BoxedBytes {
40 type Unmanaged = Self;
41
42 fn type_name() -> TypeName {
43 "bytes".into()
44 }
45
46 fn type_name_rust() -> TypeName {
47 "BoxedBytes".into()
48 }
49}
50
51impl TypeAbiFrom<Self> for CodeMetadata {}
52impl TypeAbi for CodeMetadata {
53 type Unmanaged = Self;
54
55 fn type_name() -> TypeName {
56 "CodeMetadata".into()
57 }
58
59 fn type_name_rust() -> TypeName {
60 "CodeMetadata".into()
61 }
62}
63
64impl TypeAbiFrom<Self> for BLSKey {}
65impl TypeAbi for BLSKey {
66 type Unmanaged = Self;
67
68 fn type_name() -> TypeName {
69 <[u8; BLSKey::len()]>::type_name()
70 }
71
72 fn type_name_rust() -> TypeName {
73 "BLSKey".into()
74 }
75}
76
77impl TypeAbiFrom<Self> for BLSSignature {}
78impl TypeAbiFrom<[u8; BLSSignature::len()]> for BLSSignature {}
79impl TypeAbiFrom<BLSSignature> for [u8; BLSSignature::len()] {}
80impl TypeAbi for BLSSignature {
81 type Unmanaged = Self;
82
83 fn type_name() -> TypeName {
84 <[u8; BLSSignature::len()]>::type_name()
85 }
86
87 fn type_name_rust() -> TypeName {
88 "BLSSignature".into()
89 }
90}
91
92impl TypeAbiFrom<Self> for EsdtTokenType {}
93impl TypeAbiFrom<&Self> for EsdtTokenType {}
94
95impl TypeAbi for EsdtTokenType {
97 type Unmanaged = Self;
98 fn type_name() -> TypeName {
99 "EsdtTokenType".into()
100 }
101
102 #[allow(clippy::vec_init_then_push)]
103 fn provide_type_descriptions<TDC: TypeDescriptionContainer>(accumulator: &mut TDC) {
104 let type_names = Self::type_names();
105 if !accumulator.contains_type(&type_names.abi) {
106 accumulator.reserve_type_name(type_names.clone());
107 let mut variant_descriptions = Vec::new();
108 variant_descriptions.push(EnumVariantDescription::new(
109 &[],
110 "Fungible",
111 0usize,
112 Vec::new(),
113 ));
114 variant_descriptions.push(EnumVariantDescription::new(
115 &[],
116 "NonFungible",
117 1usize,
118 Vec::new(),
119 ));
120 variant_descriptions.push(EnumVariantDescription::new(
121 &[],
122 "SemiFungible",
123 2usize,
124 Vec::new(),
125 ));
126 variant_descriptions.push(EnumVariantDescription::new(&[], "Meta", 3usize, Vec::new()));
127 variant_descriptions.push(EnumVariantDescription::new(
128 &[],
129 "Invalid",
130 4usize,
131 Vec::new(),
132 ));
133 accumulator.insert(
134 type_names.clone(),
135 TypeDescription::new(
136 &[],
137 type_names,
138 TypeContents::Enum(variant_descriptions),
139 &[
140 "TopDecode",
141 "TopEncode",
142 "NestedDecode",
143 "NestedEncode",
144 "Clone",
145 "PartialEq",
146 "Eq",
147 "Debug",
148 "ManagedVecItem",
149 ],
150 ),
151 );
152 }
153 }
154}
155
156impl TypeAbiFrom<Self> for EsdtLocalRole {}
157impl TypeAbiFrom<&Self> for EsdtLocalRole {}
158
159impl TypeAbi for EsdtLocalRole {
161 type Unmanaged = Self;
162
163 fn type_name() -> TypeName {
164 "EsdtLocalRole".into()
165 }
166
167 #[allow(clippy::vec_init_then_push)]
168 fn provide_type_descriptions<TDC: TypeDescriptionContainer>(accumulator: &mut TDC) {
169 let type_names = Self::type_names();
170 if !accumulator.contains_type(&type_names.abi) {
171 accumulator.reserve_type_name(type_names.clone());
172 let mut variant_descriptions = Vec::new();
173 variant_descriptions.push(EnumVariantDescription::new(&[], "None", 0usize, Vec::new()));
174 variant_descriptions.push(EnumVariantDescription::new(&[], "Mint", 1usize, Vec::new()));
175 variant_descriptions.push(EnumVariantDescription::new(&[], "Burn", 2usize, Vec::new()));
176 variant_descriptions.push(EnumVariantDescription::new(
177 &[],
178 "NftCreate",
179 3usize,
180 Vec::new(),
181 ));
182 variant_descriptions.push(EnumVariantDescription::new(
183 &[],
184 "NftAddQuantity",
185 4usize,
186 Vec::new(),
187 ));
188 variant_descriptions.push(EnumVariantDescription::new(
189 &[],
190 "NftBurn",
191 5usize,
192 Vec::new(),
193 ));
194 variant_descriptions.push(EnumVariantDescription::new(
195 &[],
196 "NftAddUri",
197 6usize,
198 Vec::new(),
199 ));
200 variant_descriptions.push(EnumVariantDescription::new(
201 &[],
202 "NftUpdateAttributes",
203 7usize,
204 Vec::new(),
205 ));
206 variant_descriptions.push(EnumVariantDescription::new(
207 &[],
208 "Transfer",
209 8usize,
210 Vec::new(),
211 ));
212 accumulator.insert(
213 type_names.clone(),
214 TypeDescription::new(
215 &[],
216 type_names,
217 TypeContents::Enum(variant_descriptions),
218 &[
219 "TopDecode",
220 "TopEncode",
221 "NestedDecode",
222 "NestedEncode",
223 "Clone",
224 "PartialEq",
225 "Eq",
226 "Debug",
227 "Copy",
228 ],
229 ),
230 );
231 }
232 }
233}
234
235impl TypeAbiFrom<Self> for DurationMillis {}
236
237impl TypeAbi for DurationMillis {
238 type Unmanaged = Self;
239
240 fn type_name() -> TypeName {
241 "u64".into()
242 }
243
244 fn type_name_rust() -> TypeName {
245 "DurationMillis".into()
246 }
247
248 fn type_name_specific() -> Option<TypeName> {
249 Some("DurationMillis".into())
250 }
251}
252
253impl TypeAbiFrom<Self> for DurationSeconds {}
254
255impl TypeAbi for DurationSeconds {
256 type Unmanaged = Self;
257
258 fn type_name() -> TypeName {
259 "u64".into()
260 }
261
262 fn type_name_rust() -> TypeName {
263 "DurationSeconds".into()
264 }
265
266 fn type_name_specific() -> Option<TypeName> {
267 Some("DurationSeconds".into())
268 }
269}
270
271impl TypeAbiFrom<Self> for TimestampMillis {}
272
273impl TypeAbi for TimestampMillis {
274 type Unmanaged = Self;
275
276 fn type_name() -> TypeName {
277 "u64".into()
278 }
279
280 fn type_name_rust() -> TypeName {
281 "TimestampMillis".into()
282 }
283
284 fn type_name_specific() -> Option<TypeName> {
285 Some("TimestampMillis".into())
286 }
287}
288
289impl TypeAbiFrom<Self> for TimestampSeconds {}
290
291impl TypeAbi for TimestampSeconds {
292 type Unmanaged = Self;
293
294 fn type_name() -> TypeName {
295 "u64".into()
296 }
297
298 fn type_name_rust() -> TypeName {
299 "TimestampSeconds".into()
300 }
301
302 fn type_name_specific() -> Option<TypeName> {
303 Some("TimestampSeconds".into())
304 }
305}