4
4
BigNumberish ,
5
5
CallData ,
6
6
Calldata ,
7
+ CompiledSierra ,
7
8
Contract ,
8
9
DeclareDeployUDCResponse ,
9
10
RawArgsArray ,
@@ -13,11 +14,10 @@ import {
13
14
ec ,
14
15
hash ,
15
16
num ,
17
+ selector ,
16
18
shortString ,
17
19
stark ,
18
20
} from '../src' ;
19
- import { isCairo1Abi } from '../src/utils/calldata/cairo' ;
20
- import { starknetKeccak } from '../src/utils/selector' ;
21
21
import {
22
22
compiledC1Account ,
23
23
compiledC1AccountCasm ,
@@ -32,6 +32,10 @@ import {
32
32
} from './fixtures' ;
33
33
import { initializeMatcher } from './schema' ;
34
34
35
+ const { uint256, tuple, isCairo1Abi } = cairo ;
36
+ const { toHex } = num ;
37
+ const { starknetKeccak } = selector ;
38
+
35
39
describeIfDevnet ( 'Cairo 1 Devnet' , ( ) => {
36
40
describe ( 'API & Contract interactions' , ( ) => {
37
41
const provider = getTestProvider ( ) ;
@@ -55,6 +59,21 @@ describeIfDevnet('Cairo 1 Devnet', () => {
55
59
expect ( cairo1Contract ) . toBeInstanceOf ( Contract ) ;
56
60
} ) ;
57
61
62
+ xtest ( 'validate TS for redeclare - skip testing' , async ( ) => {
63
+ const cc0 = await account . getClassAt ( dd . deploy . address ) ;
64
+ const cc0_1 = await account . getClassByHash ( toHex ( dd . declare . class_hash ) ) ;
65
+
66
+ await account . declare ( {
67
+ contract : cc0 as CompiledSierra ,
68
+ casm : compiledHelloSierraCasm ,
69
+ } ) ;
70
+
71
+ await account . declare ( {
72
+ contract : cc0_1 as CompiledSierra ,
73
+ casm : compiledHelloSierraCasm ,
74
+ } ) ;
75
+ } ) ;
76
+
58
77
test ( 'deployContract Cairo1' , async ( ) => {
59
78
const deploy = await account . deployContract ( {
60
79
classHash : dd . deploy . classHash ,
@@ -123,7 +142,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
123
142
expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
124
143
125
144
// defined as struct
126
- const result1 = await cairo1Contract . test_u256 ( cairo . uint256 ( 2n ** 256n - 2n ) ) ;
145
+ const result1 = await cairo1Contract . test_u256 ( uint256 ( 2n ** 256n - 2n ) ) ;
127
146
expect ( result1 ) . toBe ( 2n ** 256n - 1n ) ;
128
147
} ) ;
129
148
@@ -200,7 +219,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
200
219
} ) ;
201
220
202
221
test ( 'Cairo 1 Contract Interaction - echo flat un-named un-nested tuple' , async ( ) => {
203
- const status = await cairo1Contract . echo_un_tuple ( cairo . tuple ( 77 , 123 ) ) ;
222
+ const status = await cairo1Contract . echo_un_tuple ( tuple ( 77 , 123 ) ) ;
204
223
expect ( Object . values ( status ) ) . toEqual ( [ 77n , 123n ] ) ;
205
224
} ) ;
206
225
@@ -214,10 +233,10 @@ describeIfDevnet('Cairo 1 Devnet', () => {
214
233
215
234
// uint256 defined as struct
216
235
const status11 = await cairo1Contract . echo_array_u256 ( [
217
- cairo . uint256 ( 123 ) ,
218
- cairo . uint256 ( 55 ) ,
219
- cairo . uint256 ( 77 ) ,
220
- cairo . uint256 ( 255 ) ,
236
+ uint256 ( 123 ) ,
237
+ uint256 ( 55 ) ,
238
+ uint256 ( 77 ) ,
239
+ uint256 ( 255 ) ,
221
240
] ) ;
222
241
expect ( status11 ) . toEqual ( [ 123n , 55n , 77n , 255n ] ) ;
223
242
@@ -305,7 +324,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
305
324
1 : true ,
306
325
} ) ;
307
326
308
- const res1 = await cairo1Contract . tuple_echo ( cairo . tuple ( [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ) ) ;
327
+ const res1 = await cairo1Contract . tuple_echo ( tuple ( [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ) ) ;
309
328
expect ( res1 ) . toEqual ( {
310
329
0 : [ 1n , 2n , 3n ] ,
311
330
1 : [ 4n , 5n , 6n ] ,
@@ -331,7 +350,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
331
350
initial_supply : myFalseUint256 ,
332
351
recipient : '0x7e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a' ,
333
352
decimals : 18 ,
334
- tupoftup : cairo . tuple ( cairo . tuple ( 34 , '0x5e' ) , myFalseUint256 ) ,
353
+ tupoftup : tuple ( tuple ( 34 , '0x5e' ) , myFalseUint256 ) ,
335
354
card : myOrder2bis ,
336
355
longText : 'Bug is back, for ever, here and everywhere' ,
337
356
array1 : [ 100 , 101 , 102 ] ,
@@ -342,9 +361,9 @@ describeIfDevnet('Cairo 1 Devnet', () => {
342
361
] ,
343
362
array3 : [ myOrder2bis , myOrder2bis ] ,
344
363
array4 : [ myFalseUint256 , myFalseUint256 ] ,
345
- tuple1 : cairo . tuple ( 40000n , myOrder2bis , [ 54 , 55n , '0xae' ] , 'texte' ) ,
364
+ tuple1 : tuple ( 40000n , myOrder2bis , [ 54 , 55n , '0xae' ] , 'texte' ) ,
346
365
name : 'niceToken' ,
347
- array5 : [ cairo . tuple ( 251 , 40000n ) , cairo . tuple ( 252 , 40001n ) ] ,
366
+ array5 : [ tuple ( 251 , 40000n ) , tuple ( 252 , 40001n ) ] ,
348
367
} ;
349
368
const myRawArgsArray : RawArgsArray = [
350
369
'niceToken' ,
@@ -503,7 +522,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
503
522
entrypoint : 'transfer' ,
504
523
calldata : {
505
524
recipient : toBeAccountAddress ,
506
- amount : cairo . uint256 ( 1_000_000_000_000_000 ) ,
525
+ amount : uint256 ( 1_000_000_000_000_000 ) ,
507
526
} ,
508
527
} ) ;
509
528
await account . waitForTransaction ( transaction_hash ) ;
@@ -575,7 +594,7 @@ describeIfSequencerTestnet2('Cairo1 Testnet2', () => {
575
594
} ) ;
576
595
577
596
test ( 'Cairo 1 - uint256 struct' , async ( ) => {
578
- const myUint256 = cairo . uint256 ( 2n ** 256n - 2n ) ;
597
+ const myUint256 = uint256 ( 2n ** 256n - 2n ) ;
579
598
const result = await cairo1Contract . test_u256 ( myUint256 ) ;
580
599
expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
581
600
} ) ;
0 commit comments