@@ -2,7 +2,9 @@ import fs from 'fs';
22
33import {
44 CompiledContract ,
5+ Contract ,
56 addTransaction ,
7+ callContract ,
68 deployContract ,
79 getBlock ,
810 getCode ,
@@ -12,6 +14,7 @@ import {
1214 getTransactionStatus ,
1315 utils ,
1416} from '../src' ;
17+ import { getSelectorFromName } from '../src/utils/starknet' ;
1518
1619const {
1720 json : { parse } ,
@@ -28,36 +31,51 @@ describe('starknet endpoints', () => {
2831 return expect ( getContractAddresses ( ) ) . resolves . not . toThrow ( ) ;
2932 } ) ;
3033 test ( 'getBlock()' , ( ) => {
31- return expect ( getBlock ( 46500 ) ) . resolves . not . toThrow ( ) ;
34+ return expect ( getBlock ( 870 ) ) . resolves . not . toThrow ( ) ;
3235 } ) ;
3336 test ( 'getBlock(blockId=null)' , ( ) => {
3437 return expect ( getBlock ( ) ) . resolves . not . toThrow ( ) ;
3538 } ) ;
3639 test ( 'getCode()' , ( ) => {
3740 return expect (
38- getCode ( '0x5f778a983bf8760ad37868f4c869d70247c5546044a7f0386df96d8043d4e9d ' , 46500 )
41+ getCode ( '0x163a1542a64402ffc93e39a4962eec51ce126f2e634631d3f1f6770a76e3a61 ' , 870 )
3942 ) . resolves . not . toThrow ( ) ;
4043 } ) ;
4144 test ( 'getCode(blockId=null)' , ( ) => {
4245 return expect (
43- getCode ( '0x5f778a983bf8760ad37868f4c869d70247c5546044a7f0386df96d8043d4e9d ' )
46+ getCode ( '0x163a1542a64402ffc93e39a4962eec51ce126f2e634631d3f1f6770a76e3a61 ' )
4447 ) . resolves . not . toThrow ( ) ;
4548 } ) ;
4649 test ( 'getStorageAt()' , ( ) => {
4750 return expect (
48- getStorageAt ( '0x5f778a983bf8760ad37868f4c869d70247c5546044a7f0386df96d8043d4e9d ' , 0 , 46500 )
51+ getStorageAt ( '0x163a1542a64402ffc93e39a4962eec51ce126f2e634631d3f1f6770a76e3a61 ' , 0 , 870 )
4952 ) . resolves . not . toThrow ( ) ;
5053 } ) ;
5154 test ( 'getStorageAt(blockId=null)' , ( ) => {
5255 return expect (
53- getStorageAt ( '0x5f778a983bf8760ad37868f4c869d70247c5546044a7f0386df96d8043d4e9d ' , 0 )
56+ getStorageAt ( '0x163a1542a64402ffc93e39a4962eec51ce126f2e634631d3f1f6770a76e3a61 ' , 0 )
5457 ) . resolves . not . toThrow ( ) ;
5558 } ) ;
5659 test ( 'getTransactionStatus()' , ( ) => {
57- return expect ( getTransactionStatus ( 286136 ) ) . resolves . not . toThrow ( ) ;
60+ return expect (
61+ getTransactionStatus ( '0x2086ff26645fb0e31a3e252302f3cb1e7612c60389102e5473dfc89758a3aa9' )
62+ ) . resolves . not . toThrow ( ) ;
5863 } ) ;
5964 test ( 'getTransaction()' , ( ) => {
60- return expect ( getTransaction ( 286136 ) ) . resolves . not . toThrow ( ) ;
65+ return expect (
66+ getTransaction ( '0x2086ff26645fb0e31a3e252302f3cb1e7612c60389102e5473dfc89758a3aa9' )
67+ ) . resolves . not . toThrow ( ) ;
68+ } ) ;
69+ test ( 'callContract()' , ( ) => {
70+ return expect (
71+ callContract ( {
72+ contract_address : '0x58bceda58a83a5a100117ddc893234bad9c84a6833c2008f0f1ca90150149af' ,
73+ entry_point_selector : getSelectorFromName ( 'balance_of' ) ,
74+ calldata : Contract . compileCalldata ( {
75+ user : '0x58bceda58a83a5a100117ddc893234bad9c84a6833c2008f0f1ca90150149af' ,
76+ } ) ,
77+ } )
78+ ) . resolves . not . toThrow ( ) ;
6179 } ) ;
6280 } ) ;
6381
@@ -72,27 +90,43 @@ describe('starknet endpoints', () => {
7290
7391 const response = await addTransaction ( {
7492 type : 'DEPLOY' ,
75- contract_address : randomAddress ( ) ,
93+ contract_address_salt : randomAddress ( ) ,
94+ constructor_calldata : Contract . compileCalldata ( {
95+ signer : randomAddress ( ) ,
96+ guardian : '0' ,
97+ L1_address : '0' ,
98+ } ) ,
7699 contract_definition : contractDefinition ,
77100 } ) ;
101+
78102 expect ( response . code ) . toBe ( 'TRANSACTION_RECEIVED' ) ;
79- expect ( response . tx_id ) . toBeGreaterThan ( 0 ) ;
103+ expect ( response . transaction_hash ) . toBeDefined ( ) ;
104+ expect ( response . address ) . toBeDefined ( ) ;
80105
81106 // I want to show the tx number to the tester, so he/she can trace the transaction in the explorer.
82107 // eslint-disable-next-line no-console
83- console . log ( 'txId :' , response . tx_id ) ;
108+ console . log ( 'txHash :' , response . transaction_hash ) ;
84109 } ) ;
85110
86111 test ( 'deployContract()' , async ( ) => {
87112 const inputContract = compiledArgentAccount as unknown as CompiledContract ;
88113
89- const response = await deployContract ( inputContract ) ;
114+ const response = await deployContract (
115+ inputContract ,
116+ Contract . compileCalldata ( {
117+ signer : randomAddress ( ) ,
118+ guardian : '0' ,
119+ L1_address : '0' ,
120+ } )
121+ ) ;
122+
90123 expect ( response . code ) . toBe ( 'TRANSACTION_RECEIVED' ) ;
91- expect ( response . tx_id ) . toBeGreaterThan ( 0 ) ;
124+ expect ( response . transaction_hash ) . toBeDefined ( ) ;
125+ expect ( response . address ) . toBeDefined ( ) ;
92126
93127 // I want to show the tx number to the tester, so he/she can trace the transaction in the explorer.
94128 // eslint-disable-next-line no-console
95- console . log ( 'txId :' , response . tx_id ) ;
129+ console . log ( 'txHash :' , response . transaction_hash ) ;
96130 } ) ;
97131 } ) ;
98132} ) ;
0 commit comments