Skip to content

Commit 4dfa15d

Browse files
author
janniksam
committed
currentstate
1 parent 6ff9b3b commit 4dfa15d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1071
-182
lines changed

β€Žxsuite/cli.js

100644100755
File mode changed.

β€Žxsuite/contracts/datatypes/output/datatypes.abi.json

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
]
119119
},
120120
{
121-
"name": "setArrayrDataTypes",
121+
"name": "setArrayDataTypes",
122122
"mutability": "mutable",
123123
"inputs": [
124124
{
@@ -164,6 +164,25 @@
164164
}
165165
]
166166
},
167+
{
168+
"name": "getPrimitiveMultiValue2",
169+
"mutability": "readonly",
170+
"inputs": [
171+
{
172+
"name": "multivalue",
173+
"type": "multi<u8,Address>",
174+
"multi_arg": true
175+
}
176+
],
177+
"outputs": [
178+
{
179+
"type": "u8"
180+
},
181+
{
182+
"type": "Address"
183+
}
184+
]
185+
},
167186
{
168187
"name": "getOptionalValue2ndArg",
169188
"mutability": "readonly",
@@ -188,6 +207,111 @@
188207
}
189208
]
190209
},
210+
{
211+
"name": "getOptionalMultiValueEncoded",
212+
"mutability": "readonly",
213+
"inputs": [
214+
{
215+
"name": "_id",
216+
"type": "u64"
217+
},
218+
{
219+
"name": "value",
220+
"type": "optional<variadic<tuple<Address,u64>>>",
221+
"multi_arg": true
222+
}
223+
],
224+
"outputs": [
225+
{
226+
"type": "optional<variadic<tuple<Address,u64>>>",
227+
"multi_result": true
228+
}
229+
]
230+
},
231+
{
232+
"name": "getOptionalMultiValue3",
233+
"mutability": "readonly",
234+
"inputs": [
235+
{
236+
"name": "_id",
237+
"type": "u64"
238+
},
239+
{
240+
"name": "value",
241+
"type": "optional<multi<u32,BigUint,u8>>",
242+
"multi_arg": true
243+
}
244+
],
245+
"outputs": [
246+
{
247+
"type": "optional<multi<u32,BigUint,u8>>",
248+
"multi_result": true
249+
}
250+
]
251+
},
252+
{
253+
"name": "getMultiValueEncoded",
254+
"mutability": "readonly",
255+
"inputs": [
256+
{
257+
"name": "_id",
258+
"type": "u64"
259+
},
260+
{
261+
"name": "value",
262+
"type": "variadic<Address>",
263+
"multi_arg": true
264+
}
265+
],
266+
"outputs": [
267+
{
268+
"type": "variadic<Address>",
269+
"multi_result": true
270+
}
271+
]
272+
},
273+
{
274+
"name": "getMultiValueEncodedWithMultiValue2",
275+
"mutability": "readonly",
276+
"inputs": [
277+
{
278+
"name": "_id",
279+
"type": "u64"
280+
},
281+
{
282+
"name": "value",
283+
"type": "variadic<multi<u8,Address>>",
284+
"multi_arg": true
285+
}
286+
],
287+
"outputs": [
288+
{
289+
"type": "variadic<multi<u8,Address>>",
290+
"multi_result": true
291+
}
292+
]
293+
},
294+
{
295+
"name": "getIgnoreValue",
296+
"mutability": "readonly",
297+
"inputs": [
298+
{
299+
"name": "_id",
300+
"type": "u64"
301+
},
302+
{
303+
"name": "value",
304+
"type": "ignore",
305+
"multi_arg": true
306+
}
307+
],
308+
"outputs": [
309+
{
310+
"type": "ignore",
311+
"multi_result": true
312+
}
313+
]
314+
},
191315
{
192316
"name": "getSingleValueMapper",
193317
"mutability": "readonly",
@@ -266,6 +390,22 @@
266390
"multi_result": true
267391
}
268392
]
393+
},
394+
{
395+
"name": "getMapMapperComplex",
396+
"mutability": "readonly",
397+
"inputs": [
398+
{
399+
"name": "input",
400+
"type": "u8"
401+
}
402+
],
403+
"outputs": [
404+
{
405+
"type": "variadic<multi<u8,tuple<u16,BigUint,u8>>>",
406+
"multi_result": true
407+
}
408+
]
269409
}
270410
],
271411
"esdtAttributes": [],
@@ -415,6 +555,10 @@
415555
{
416556
"name": "custom_type",
417557
"type": "SubType"
558+
},
559+
{
560+
"name": "code_metadata",
561+
"type": "CodeMetadata"
418562
}
419563
]
420564
},
Binary file not shown.

β€Žxsuite/contracts/datatypes/src/lib.rs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ pub trait DataTypes {
3333
self.map_mapper(0).insert(1, 2);
3434
self.map_mapper(1).insert(1, 10);
3535
self.map_mapper(1).insert(2, 11);
36+
self.map_mapper_complex(0)
37+
.insert(0, (0, BigUint::from(12u16), 4));
38+
self.map_mapper_complex(0)
39+
.insert(1, (1, BigUint::from(24u16), 5));
40+
self.map_mapper_complex(1)
41+
.insert(0, (2, BigUint::from(48u16), 6));
42+
self.map_mapper_complex(1)
43+
.insert(1, (3, BigUint::from(72u16), 7));
3644
}
3745

3846
#[view(getPrimitiveDataTypes)]
@@ -131,6 +139,7 @@ pub trait DataTypes {
131139
address: self.blockchain().get_sc_address(),
132140
big_unsigned_integer: BigUint::from(100000000u64),
133141
},
142+
code_metadata: CodeMetadata::UPGRADEABLE,
134143
};
135144
return types;
136145
}
@@ -153,7 +162,7 @@ pub trait DataTypes {
153162
data
154163
}
155164

156-
#[endpoint(setArrayrDataTypes)]
165+
#[endpoint(setArrayDataTypes)]
157166
fn set_array_datatypes(&self, data: ArrayDataTypes<Self::Api>) -> ArrayDataTypes<Self::Api> {
158167
data
159168
}
@@ -171,6 +180,14 @@ pub trait DataTypes {
171180
optional_value_arg
172181
}
173182

183+
#[view(getPrimitiveMultiValue2)]
184+
fn get_primitive_mutlivalue2(
185+
&self,
186+
multivalue: MultiValue2<u8, ManagedAddress>,
187+
) -> MultiValue2<u8, ManagedAddress> {
188+
multivalue
189+
}
190+
174191
#[view(getOptionalValue2ndArg)]
175192
fn get_optional_value_2nd_arg(
176193
&self,
@@ -181,6 +198,47 @@ pub trait DataTypes {
181198
result
182199
}
183200

201+
#[view(getOptionalMultiValueEncoded)]
202+
fn get_optional_multi_value_encoded(
203+
&self,
204+
_id: u64,
205+
value: OptionalValue<MultiValueEncoded<(ManagedAddress, u64)>>,
206+
) -> OptionalValue<MultiValueEncoded<(ManagedAddress, u64)>> {
207+
value
208+
}
209+
210+
#[view(getOptionalMultiValue3)]
211+
fn get_optional_multi_value_3(
212+
&self,
213+
_id: u64,
214+
value: OptionalValue<MultiValue3<u32, BigUint, u8>>,
215+
) -> OptionalValue<MultiValue3<u32, BigUint, u8>> {
216+
value
217+
}
218+
219+
#[view(getMultiValueEncoded)]
220+
fn get_multi_value_encoded(
221+
&self,
222+
_id: u64,
223+
value: MultiValueEncoded<ManagedAddress>,
224+
) -> MultiValueEncoded<ManagedAddress> {
225+
value
226+
}
227+
228+
#[view(getMultiValueEncodedWithMultiValue2)]
229+
fn get_multi_value_encoded_with_multivalue2(
230+
&self,
231+
_id: u64,
232+
value: MultiValueEncoded<MultiValue2<u8, ManagedAddress>>,
233+
) -> MultiValueEncoded<MultiValue2<u8, ManagedAddress>> {
234+
value
235+
}
236+
237+
#[view(getIgnoreValue)]
238+
fn get_ignore_value(&self, _id: u64, value: IgnoreValue) -> IgnoreValue {
239+
value
240+
}
241+
184242
#[view(getSingleValueMapper)]
185243
#[storage_mapper("single_value_mapper")]
186244
fn single_value_mapper(&self, input: u8) -> SingleValueMapper<u64>;
@@ -201,6 +259,10 @@ pub trait DataTypes {
201259
#[storage_mapper("map_mapper")]
202260
fn map_mapper(&self, input: u8) -> MapMapper<u8, u16>;
203261

262+
#[view(getMapMapperComplex)]
263+
#[storage_mapper("map_mapper_complex")]
264+
fn map_mapper_complex(&self, input: u8) -> MapMapper<u8, (u16, BigUint, u8)>;
265+
204266
fn get_sample_mvec(&self) -> ManagedVec<u16> {
205267
let mut vec = ManagedVec::new();
206268
vec.push(12u16);

β€Žxsuite/contracts/datatypes/src/types/data_types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use multiversx_sc::{
22
api::ManagedTypeApi,
33
types::{
4-
BigInt, BigUint, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, EsdtTokenPayment,
5-
ManagedAddress, ManagedBuffer, ManagedVec, TokenIdentifier,
4+
BigInt, BigUint, CodeMetadata, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment,
5+
EsdtTokenPayment, ManagedAddress, ManagedBuffer, ManagedVec, TokenIdentifier,
66
},
77
};
88

@@ -73,4 +73,5 @@ pub struct ArrayDataTypes<M: ManagedTypeApi> {
7373
pub struct OtherDataTypes<M: ManagedTypeApi> {
7474
pub custom_type: SubType<M>,
7575
// pub complex_enum: ComplexEnum<M>,
76+
pub code_metadata: CodeMetadata,
7677
}

β€Žxsuite/src/cli/cmd.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { rustToolchain, rustTarget, rustKey } from "./helpers";
1414
const cwd = process.cwd();
1515
let tmpDir: string;
1616
const pemPath = path.resolve("wallets", "wallet.pem");
17-
1817
const keyKeystorePath = path.resolve("wallets", "keystore_key.json");
1918
const mneKeystorePath = path.resolve("wallets", "keystore_mnemonic.json");
2019

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
export interface AbiDefinition {
2+
types: ContractTypeDefinition;
3+
endpoints?: EndpointDefinition[];
4+
}
5+
6+
export interface EndpointDefinition {
7+
name: string;
8+
mutability?: EndpointMutability;
9+
onlyOwner?: boolean;
10+
docs?: string[];
11+
inputs: InputDefinition[];
12+
outputs: OutputDefinition[];
13+
payableInTokens?: string[];
14+
}
15+
16+
export interface InputDefinition {
17+
name: string;
18+
type: string;
19+
multi_arg?: boolean;
20+
}
21+
22+
export enum EndpointMutability {
23+
mutable = "mutable",
24+
readonly = "readonly",
25+
}
26+
27+
export interface OutputDefinition {
28+
type: string;
29+
multi_result?: boolean;
30+
}
31+
32+
export interface FieldDefinition {
33+
name: string;
34+
type: string;
35+
docs?: string[];
36+
}
37+
38+
export interface ContractTypeDefinition {
39+
[key: string]: TypeDefinition;
40+
}
41+
42+
export enum ContractType {
43+
struct = "struct",
44+
enum = "enum",
45+
explicitEnum = "explicit-enum",
46+
}
47+
48+
export interface TypeDefinition {
49+
type: ContractType;
50+
fields?: FieldDefinition[];
51+
variants?: {
52+
name: string;
53+
discriminant: string | number;
54+
fields?: FieldDefinition[];
55+
docs?: string[];
56+
}[];
57+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "NotSupportedType",
3+
"constructor": {},
4+
"endpoints": [
5+
{
6+
"name": "ping",
7+
"mutability": "mutable",
8+
"inputs": [
9+
{
10+
"name": "_data",
11+
"type": "NOTSUPPORTEDTYPE",
12+
"multi_arg": true
13+
}
14+
],
15+
"outputs": []
16+
}
17+
],
18+
"types": {}
19+
}

0 commit comments

Comments
Β (0)