starknet 4.9.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -3
  3. package/__tests__/account.test.ts +5 -1
  4. package/__tests__/defaultProvider.test.ts +97 -210
  5. package/__tests__/fixtures.ts +2 -2
  6. package/__tests__/rpcProvider.test.ts +7 -4
  7. package/__tests__/udc.test.ts +41 -0
  8. package/account/default.d.ts +3 -1
  9. package/account/default.js +53 -3
  10. package/account/interface.d.ts +24 -7
  11. package/constants.d.ts +7 -1
  12. package/constants.js +7 -1
  13. package/contract/default.d.ts +11 -27
  14. package/contract/default.js +104 -120
  15. package/contract/interface.d.ts +5 -2
  16. package/dist/account/default.d.ts +3 -1
  17. package/dist/account/default.js +53 -3
  18. package/dist/account/interface.d.ts +24 -7
  19. package/dist/constants.d.ts +7 -1
  20. package/dist/constants.js +7 -1
  21. package/dist/contract/default.d.ts +11 -27
  22. package/dist/contract/default.js +104 -120
  23. package/dist/contract/interface.d.ts +5 -2
  24. package/dist/provider/default.d.ts +4 -2
  25. package/dist/provider/default.js +13 -2
  26. package/dist/provider/interface.d.ts +18 -3
  27. package/dist/provider/rpc.d.ts +15 -10
  28. package/dist/provider/rpc.js +71 -31
  29. package/dist/provider/sequencer.d.ts +6 -2
  30. package/dist/provider/sequencer.js +33 -5
  31. package/dist/signer/default.d.ts +2 -2
  32. package/dist/signer/default.js +15 -15
  33. package/dist/signer/interface.d.ts +2 -0
  34. package/dist/types/api/index.d.ts +0 -6
  35. package/dist/types/api/openrpc.d.ts +147 -98
  36. package/dist/types/api/openrpc.js +22 -4
  37. package/dist/types/index.d.ts +1 -1
  38. package/dist/types/lib.d.ts +22 -2
  39. package/dist/types/lib.js +6 -0
  40. package/dist/utils/number.d.ts +1 -0
  41. package/dist/utils/number.js +3 -1
  42. package/package.json +1 -1
  43. package/provider/default.d.ts +4 -2
  44. package/provider/default.js +13 -2
  45. package/provider/interface.d.ts +18 -3
  46. package/provider/rpc.d.ts +15 -10
  47. package/provider/rpc.js +71 -31
  48. package/provider/sequencer.d.ts +6 -2
  49. package/provider/sequencer.js +33 -5
  50. package/signer/default.d.ts +2 -2
  51. package/signer/default.js +15 -15
  52. package/signer/interface.d.ts +2 -0
  53. package/src/account/default.ts +51 -7
  54. package/src/account/interface.ts +34 -7
  55. package/src/constants.ts +7 -0
  56. package/src/contract/default.ts +123 -140
  57. package/src/contract/interface.ts +5 -2
  58. package/src/provider/default.ts +21 -3
  59. package/src/provider/interface.ts +26 -2
  60. package/src/provider/rpc.ts +73 -45
  61. package/src/provider/sequencer.ts +24 -4
  62. package/src/signer/default.ts +18 -18
  63. package/src/signer/interface.ts +2 -0
  64. package/src/types/api/index.ts +0 -4
  65. package/src/types/api/openrpc.ts +193 -105
  66. package/src/types/api/rpc.ts +0 -1
  67. package/src/types/index.ts +1 -1
  68. package/src/types/lib.ts +23 -2
  69. package/src/utils/number.ts +2 -0
  70. package/types/api/index.d.ts +0 -6
  71. package/types/api/openrpc.d.ts +147 -98
  72. package/types/api/openrpc.js +22 -4
  73. package/types/index.d.ts +1 -1
  74. package/types/lib.d.ts +22 -2
  75. package/types/lib.js +6 -0
  76. package/utils/number.d.ts +1 -0
  77. package/utils/number.js +3 -1
  78. package/www/docs/API/account.md +122 -22
  79. package/www/docs/API/contract.md +39 -3
  80. package/www/docs/API/provider.md +4 -0
  81. package/www/docs/API/signer.md +56 -2
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Starknet RPC version 0.1.0
2
+ * Starknet RPC version 0.2.0
3
3
  *
4
- * StarkNet Node API 0.31.0
5
- * StarkNet Node Write API 0.3.0
6
- * StarkNet Trace API 0.3.0
4
+ * StarkNet Node API 0.45.0 - rpc 0.2.1
5
+ * StarkNet Node Write API 0.3.0 - rpc 0.2.1
6
+ * StarkNet Trace API 0.4.0 - rpc 0.2.1
7
7
  *
8
8
  * TypeScript Representation of OpenRpc protocol types
9
9
  */
@@ -12,11 +12,10 @@ export type FELT = string;
12
12
  export type ADDRESS = FELT;
13
13
  type NUM_AS_HEX = string;
14
14
  type SIGNATURE = Array<FELT>;
15
- type ETH_ADDRESS = string;
15
+ // type ETH_ADDRESS = string;
16
16
  type BLOCK_NUMBER = number;
17
17
  type BLOCK_HASH = FELT;
18
18
  type TXN_HASH = FELT;
19
- type PROTOCOL_VERSION = string;
20
19
  type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
21
20
  type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'DEPLOY_ACCOUNT' | 'INVOKE' | 'L1_HANDLER';
22
21
  type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
@@ -34,37 +33,49 @@ type EVENT = {
34
33
  keys: Array<FELT>;
35
34
  data: Array<FELT>;
36
35
  };
36
+
37
37
  type COMMON_RECEIPT_PROPERTIES = {
38
38
  transaction_hash: TXN_HASH;
39
39
  actual_fee: FELT;
40
40
  status: TXN_STATUS;
41
- status_data?: string;
42
- block_hash: BLOCK_HASH;
43
- block_number: BLOCK_NUMBER;
44
- };
45
- type MSG_TO_L2 = {
46
- from_address: ETH_ADDRESS;
47
- payload: FELT;
48
- };
49
- type INVOKE_TXN_RECEIPT_PROPERTIES = {
50
- messages_sent: MSG_TO_L1;
51
- l1_origin_message?: MSG_TO_L2;
52
- events: EVENT;
41
+ block_hash?: BLOCK_HASH;
42
+ block_number?: BLOCK_NUMBER;
43
+ type: TXN_TYPE;
44
+ messages_sent: Array<MSG_TO_L1>;
45
+ events: Array<EVENT>;
53
46
  };
47
+
54
48
  type PENDING_COMMON_RECEIPT_PROPERTIES = {
55
49
  transaction_hash: TXN_HASH;
56
50
  actual_fee: FELT;
51
+ type?: TXN_TYPE;
52
+ messages_sent: Array<MSG_TO_L1>;
53
+ events: Array<EVENT>;
57
54
  };
58
- type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
55
+
56
+ type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
59
57
  type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
60
- type DEPLOY_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
61
- type PENDING_INVOKE_TXN_RECEIPT = PENDING_COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
62
- type PENDING_TXN_RECEIPT = PENDING_INVOKE_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
58
+
59
+ type DEPLOY_TXN_RECEIPT = {
60
+ contract_address: FELT;
61
+ } & COMMON_RECEIPT_PROPERTIES;
62
+
63
+ type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
64
+
65
+ type PENDING_DEPLOY_TXN_RECEIPT = {
66
+ contract_address: FELT;
67
+ } & PENDING_COMMON_RECEIPT_PROPERTIES;
68
+
69
+ type PENDING_TXN_RECEIPT = PENDING_DEPLOY_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
70
+
63
71
  type TXN_RECEIPT =
64
72
  | INVOKE_TXN_RECEIPT
73
+ | L1_HANDLER_TXN_RECEIPT
65
74
  | DECLARE_TXN_RECEIPT
66
75
  | DEPLOY_TXN_RECEIPT
76
+ | DEPLOY_ACCOUNT_TXN_RECEIPT
67
77
  | PENDING_TXN_RECEIPT;
78
+
68
79
  type BLOCK_HEADER = {
69
80
  block_hash: BLOCK_HASH;
70
81
  parent_hash: BLOCK_HASH;
@@ -77,7 +88,7 @@ type BLOCK_BODY_WITH_TX_HASHES = {
77
88
  transactions: Array<TXN_HASH>;
78
89
  };
79
90
  type BLOCK_WITH_TX_HASHES = {
80
- status: TXN_STATUS;
91
+ status: BLOCK_STATUS;
81
92
  } & BLOCK_HEADER &
82
93
  BLOCK_BODY_WITH_TX_HASHES;
83
94
  type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
@@ -88,41 +99,87 @@ type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
88
99
  // transaction_hash, nonce, type optional because of pathfinder not implemented
89
100
  type COMMON_TXN_PROPERTIES = {
90
101
  transaction_hash?: TXN_HASH;
91
- max_fee: FELT;
92
- version: NUM_AS_HEX;
93
- signature: SIGNATURE;
94
- nonce?: FELT;
95
- type?: TXN_TYPE;
96
- };
102
+ } & BROADCASTED_TXN_COMMON_PROPERTIES;
97
103
  type FUNCTION_CALL = {
98
104
  contract_address?: ADDRESS;
99
105
  entry_point_selector?: FELT;
100
106
  calldata?: Array<FELT>;
101
107
  };
102
- type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
108
+ type INVOKE_TXN = COMMON_TXN_PROPERTIES & (INVOKE_TXN_V0 | INVOKE_TXN_V1);
103
109
  type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
104
110
  class_hash: FELT;
105
111
  sender_address: ADDRESS;
106
112
  };
107
- type DEPLOY_ACCOUNT_TXN_REQUEST = COMMON_TXN_PROPERTIES & {
113
+ type DEPLOY_TXN = {
114
+ transaction_hash: TXN_HASH;
108
115
  class_hash: FELT;
116
+ } & DEPLOY_TXN_PROPERTIES;
117
+
118
+ type DEPLOY_ACCOUNT_TXN = COMMON_TXN_PROPERTIES & DEPLOY_ACCOUNT_TXN_PROPERTIES;
119
+
120
+ type DEPLOY_ACCOUNT_TXN_PROPERTIES = {
109
121
  contract_address_salt: FELT;
110
122
  constructor_calldata: Array<FELT>;
123
+ class_hash: FELT;
111
124
  };
112
- type DECLARE_TXN_REQUEST = COMMON_TXN_PROPERTIES & {
125
+
126
+ type DEPLOY_ACCOUNT_TXN_RECEIPT = DEPLOY_TXN_RECEIPT;
127
+
128
+ type TXN = INVOKE_TXN | L1_HANDLER_TXN | DECLARE_TXN | DEPLOY_TXN | DEPLOY_ACCOUNT_TXN;
129
+
130
+ enum L1_HANDLER {
131
+ 'L1_HANDLER',
132
+ }
133
+
134
+ type L1_HANDLER_TXN = {
135
+ transaction_hash: TXN_HASH;
136
+ version: NUM_AS_HEX;
137
+ type: L1_HANDLER;
138
+ nonce: NUM_AS_HEX;
139
+ } & FUNCTION_CALL;
140
+
141
+ type BROADCASTED_DEPLOY_ACCOUNT_TXN = BROADCASTED_TXN_COMMON_PROPERTIES &
142
+ DEPLOY_ACCOUNT_TXN_PROPERTIES;
143
+
144
+ type BROADCASTED_TXN =
145
+ | BROADCASTED_INVOKE_TXN
146
+ | BROADCASTED_DECLARE_TXN
147
+ | BROADCASTED_DEPLOY_TXN
148
+ | BROADCASTED_DEPLOY_ACCOUNT_TXN;
149
+
150
+ type BROADCASTED_INVOKE_TXN = BROADCASTED_TXN_COMMON_PROPERTIES & (INVOKE_TXN_V0 | INVOKE_TXN_V1);
151
+
152
+ type BROADCASTED_TXN_COMMON_PROPERTIES = {
153
+ type: TXN_TYPE;
154
+ max_fee: FELT;
155
+ version: NUM_AS_HEX;
156
+ signature: SIGNATURE;
157
+ nonce: FELT;
158
+ };
159
+
160
+ type BROADCASTED_DECLARE_TXN = {
113
161
  contract_class: CONTRACT_CLASS;
114
162
  sender_address: ADDRESS;
115
- };
116
- type DEPLOY_TXN = {
117
- transaction_hash: TXN_HASH;
118
- class_hash: FELT;
163
+ } & BROADCASTED_TXN_COMMON_PROPERTIES;
164
+
165
+ type BROADCASTED_DEPLOY_TXN = {
166
+ contract_class: CONTRACT_CLASS;
167
+ } & DEPLOY_TXN_PROPERTIES;
168
+
169
+ type DEPLOY_TXN_PROPERTIES = {
119
170
  version: NUM_AS_HEX;
120
171
  type: TXN_TYPE;
121
- contract_address: FELT;
122
172
  contract_address_salt: FELT;
123
173
  constructor_calldata: Array<FELT>;
124
174
  };
125
- type TXN = INVOKE_TXN | DECLARE_TXN | DEPLOY_TXN;
175
+
176
+ type INVOKE_TXN_V0 = FUNCTION_CALL;
177
+
178
+ type INVOKE_TXN_V1 = {
179
+ sender_address: ADDRESS;
180
+ calldata: Array<FELT>;
181
+ };
182
+
126
183
  type BLOCK_BODY_WITH_TXS = {
127
184
  transactions: Array<TXN>;
128
185
  };
@@ -137,27 +194,69 @@ type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
137
194
  };
138
195
 
139
196
  type CONTRACT_CLASS = {
140
- program: string; // A base64 representation of the compressed program code
197
+ program: string;
141
198
  entry_points_by_type: {
142
199
  CONSTRUCTOR: CONTRACT_ENTRY_POINT_LIST;
143
200
  EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
144
201
  L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
145
202
  };
146
- abi?: any; // Pathfinder exception from rpc 0.1.0
203
+ abi?: CONTRACT_ABI;
204
+ };
205
+
206
+ type CONTRACT_ABI = Array<CONTRACT_ABI_ENTRY>;
207
+
208
+ type CONTRACT_ABI_ENTRY = FUNCTION_ABI_ENTRY | EVENT_ABI_ENTRY | STRUCT_ABI_ENTRY;
209
+
210
+ enum STRUCT_ABI_TYPE {
211
+ 'struct',
212
+ }
213
+ enum EVENT_ABI_TYPE {
214
+ 'event',
215
+ }
216
+ enum FUNCTION_ABI_TYPE {
217
+ 'function',
218
+ 'l1_handler',
219
+ 'constructor',
220
+ }
221
+
222
+ type STRUCT_ABI_ENTRY = STRUCT_ABI_TYPE & {
223
+ name: string;
224
+ size: number;
225
+ members: Array<STRUCT_MEMBER>;
226
+ };
227
+
228
+ type STRUCT_MEMBER = {
229
+ offset: number;
230
+ } & TYPED_PARAMETER;
231
+
232
+ type EVENT_ABI_ENTRY = {
233
+ name: string;
234
+ keys: Array<TYPED_PARAMETER>;
235
+ data: Array<TYPED_PARAMETER>;
236
+ } & EVENT_ABI_TYPE;
237
+
238
+ type FUNCTION_ABI_ENTRY = {
239
+ type: FUNCTION_ABI_TYPE;
240
+ name: string;
241
+ inputs: Array<TYPED_PARAMETER>;
242
+ outputs: Array<TYPED_PARAMETER>;
147
243
  };
244
+
245
+ type TYPED_PARAMETER = {
246
+ name: string;
247
+ type: string;
248
+ };
249
+
148
250
  type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
149
251
  type CONTRACT_ENTRY_POINT = {
150
252
  offset: NUM_AS_HEX;
151
253
  selector: FELT;
152
254
  };
153
- type STORAGE_DIFF_ITEM = {
255
+ type CONTRACT_STORAGE_DIFF_ITEM = {
154
256
  address: FELT;
155
- key: FELT;
156
- value: FELT;
157
- };
158
- type DECLARED_CONTRACT_ITEM = {
159
- class_hash: FELT;
257
+ storage_entries: [key: FELT, value: FELT];
160
258
  };
259
+
161
260
  type DEPLOYED_CONTRACT_ITEM = {
162
261
  address: FELT;
163
262
  class_hash: FELT;
@@ -167,8 +266,8 @@ type STATE_UPDATE = {
167
266
  new_root: FELT;
168
267
  old_root: FELT;
169
268
  state_diff: {
170
- storage_diffs: Array<STORAGE_DIFF_ITEM>;
171
- declared_contracts: Array<DECLARED_CONTRACT_ITEM>;
269
+ storage_diffs: Array<CONTRACT_STORAGE_DIFF_ITEM>;
270
+ declared_contract_hashes: Array<FELT>;
172
271
  deployed_contracts: Array<DEPLOYED_CONTRACT_ITEM>;
173
272
  nonces: Array<{
174
273
  contract_address: ADDRESS;
@@ -184,8 +283,8 @@ type EVENT_FILTER = {
184
283
  keys?: Array<FELT>;
185
284
  };
186
285
  type RESULT_PAGE_REQUEST = {
187
- page_size: number;
188
- page_number: number;
286
+ continuation_token?: string;
287
+ chunk_size: number;
189
288
  };
190
289
  type EMITTED_EVENT = EVENT & {
191
290
  block_hash: BLOCK_HASH;
@@ -221,10 +320,12 @@ type FUNCTION_INVOCATION = FUNCTION_CALL & {
221
320
  entry_point_type: ENTRY_POINT_TYPE;
222
321
  call_type: CALL_TYPE;
223
322
  result: FELT;
224
- calls: FUNCTION_INVOCATION;
225
- events: EVENT;
323
+ calls: NESTED_CALL;
324
+ events: Array<EVENT>;
226
325
  messages: MSG_TO_L1;
227
326
  };
327
+ type NESTED_CALL = FUNCTION_INVOCATION;
328
+
228
329
  type TRACE_ROOT = {
229
330
  nonce: FELT;
230
331
  signature: FELT;
@@ -249,12 +350,10 @@ export namespace OPENRPC {
249
350
  };
250
351
  export type CHAIN_ID = string;
251
352
  export type PendingTransactions = Array<TXN>;
252
- export type ProtocolVersion = PROTOCOL_VERSION;
253
353
  export type SyncingStatus = false | SYNC_STATUS;
254
354
  export type Events = {
255
355
  events: Array<EMITTED_EVENT>;
256
- page_number: number;
257
- is_last_page: boolean;
356
+ continuation_token: string;
258
357
  };
259
358
  export type Trace = TRACE_ROOT;
260
359
  export type Traces = Array<{
@@ -274,57 +373,57 @@ export namespace OPENRPC {
274
373
  starknet_getBlockWithTxHashes: {
275
374
  params: { block_id: BLOCK_ID };
276
375
  result: BlockWithTxHashes;
277
- errors: Errors.INVALID_BLOCK_ID;
376
+ errors: Errors.BLOCK_NOT_FOUND;
278
377
  };
279
378
  starknet_getBlockWithTxs: {
280
379
  params: { block_id: BLOCK_ID };
281
380
  result: BlockWithTxs;
282
- errors: Errors.INVALID_BLOCK_ID;
381
+ errors: Errors.BLOCK_NOT_FOUND;
283
382
  };
284
383
  starknet_getStateUpdate: {
285
384
  params: { block_id: BLOCK_ID };
286
385
  result: StateUpdate;
287
- errors: Errors.INVALID_BLOCK_ID;
386
+ errors: Errors.BLOCK_NOT_FOUND;
288
387
  };
289
388
  starknet_getStorageAt: {
290
389
  params: { contract_address: ADDRESS; key: STORAGE_KEY; block_id: BLOCK_ID };
291
390
  result: Storage;
292
- errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_BLOCK_ID;
391
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.BLOCK_NOT_FOUND;
293
392
  };
294
393
  starknet_getTransactionByHash: {
295
394
  params: { transaction_hash: TXN_HASH };
296
395
  result: Transaction;
297
- errors: Errors.INVALID_TXN_HASH;
396
+ errors: Errors.TXN_HASH_NOT_FOUND;
298
397
  };
299
398
  starknet_getTransactionByBlockIdAndIndex: {
300
399
  params: { block_id: BLOCK_ID; index: number };
301
400
  result: Transaction;
302
- errors: Errors.INVALID_BLOCK_ID | Errors.INVALID_TXN_INDEX;
401
+ errors: Errors.BLOCK_NOT_FOUND | Errors.INVALID_TXN_INDEX;
303
402
  };
304
403
  starknet_getTransactionReceipt: {
305
404
  params: { transaction_hash: TXN_HASH };
306
405
  result: TransactionReceipt;
307
- errors: Errors.INVALID_TXN_HASH;
406
+ errors: Errors.TXN_HASH_NOT_FOUND;
308
407
  };
309
408
  starknet_getClass: {
310
- params: { class_hash: FELT };
409
+ params: { block_id: BLOCK_ID; class_hash: FELT };
311
410
  result: ContractClass;
312
- errors: Errors.INVALID_CONTRACT_CLASS_HASH;
411
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CLASS_HASH_NOT_FOUND;
313
412
  };
314
413
  starknet_getClassHashAt: {
315
414
  params: { block_id: BLOCK_ID; contract_address: ADDRESS };
316
415
  result: FELT;
317
- errors: Errors.INVALID_BLOCK_ID | Errors.CONTRACT_NOT_FOUND;
416
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
318
417
  };
319
418
  starknet_getClassAt: {
320
419
  params: { block_id: BLOCK_ID; contract_address: ADDRESS };
321
420
  result: ContractClass;
322
- errors: Errors.INVALID_BLOCK_ID | Errors.CONTRACT_NOT_FOUND;
421
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
323
422
  };
324
423
  starknet_getBlockTransactionCount: {
325
424
  params: { block_id: BLOCK_ID };
326
425
  result: number;
327
- errors: Errors.INVALID_BLOCK_ID;
426
+ errors: Errors.BLOCK_NOT_FOUND;
328
427
  };
329
428
  starknet_call: {
330
429
  params: { request: FUNCTION_CALL; block_id: BLOCK_ID };
@@ -334,20 +433,17 @@ export namespace OPENRPC {
334
433
  | Errors.INVALID_MESSAGE_SELECTOR
335
434
  | Errors.INVALID_CALL_DATA
336
435
  | Errors.CONTRACT_ERROR
337
- | Errors.INVALID_BLOCK_ID;
436
+ | Errors.BLOCK_NOT_FOUND;
338
437
  };
339
438
  starknet_estimateFee: {
340
- params: {
341
- request: INVOKE_TXN | DECLARE_TXN_REQUEST | DEPLOY_ACCOUNT_TXN_REQUEST;
342
- block_id: BLOCK_ID;
343
- };
439
+ params: { request: BROADCASTED_TXN; block_id: BLOCK_ID };
344
440
  result: FEE_ESTIMATE;
345
441
  errors:
346
442
  | Errors.CONTRACT_NOT_FOUND
347
443
  | Errors.INVALID_MESSAGE_SELECTOR
348
444
  | Errors.INVALID_CALL_DATA
349
445
  | Errors.CONTRACT_ERROR
350
- | Errors.INVALID_BLOCK_ID;
446
+ | Errors.BLOCK_NOT_FOUND;
351
447
  };
352
448
  starknet_blockNumber: {
353
449
  params: {};
@@ -374,55 +470,42 @@ export namespace OPENRPC {
374
470
  starknet_getEvents: {
375
471
  params: { filter: EVENT_FILTER & RESULT_PAGE_REQUEST };
376
472
  result: Events;
377
- errors: Errors.PAGE_SIZE_TOO_BIG;
473
+ errors: Errors.PAGE_SIZE_TOO_BIG | Errors.INVALID_CONTINUATION_TOKEN | Errors.BLOCK_NOT_FOUND;
378
474
  };
379
- // FROM RPC 0.2.0 Pathfinder exception
380
475
  starknet_getNonce: {
381
- params: { contract_address: ADDRESS; block_id: BLOCK_ID };
476
+ params: { block_id: BLOCK_ID; contract_address: ADDRESS };
382
477
  result: FELT;
383
- errors: Errors.CONTRACT_NOT_FOUND;
478
+ errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
384
479
  };
385
480
 
386
481
  // Write API
387
482
  starknet_addInvokeTransaction: {
388
483
  params: {
389
- function_invocation: FUNCTION_CALL;
390
- signature: SIGNATURE;
391
- max_fee: NUM_AS_HEX;
392
- version: NUM_AS_HEX;
484
+ invoke_transaction: BROADCASTED_INVOKE_TXN;
393
485
  };
394
486
  result: InvokedTransaction;
395
487
  };
396
488
  starknet_addDeclareTransaction: {
397
489
  params: {
398
- contract_class: CONTRACT_CLASS;
399
- sender_address: ADDRESS;
400
- signature: SIGNATURE;
401
- max_fee: NUM_AS_HEX;
402
- version: NUM_AS_HEX;
403
- nonce: FELT;
490
+ declare_transaction: BROADCASTED_DECLARE_TXN;
404
491
  };
405
492
  result: DeclaredTransaction;
406
493
  errors: Errors.INVALID_CONTRACT_CLASS;
407
494
  };
408
495
  starknet_addDeployTransaction: {
409
496
  params: {
410
- contract_address_salt: FELT;
411
- constructor_calldata: Array<FELT>;
412
- contract_definition: CONTRACT_CLASS;
497
+ deploy_transaction: BROADCASTED_DEPLOY_TXN;
413
498
  };
414
499
  result: DeployedTransaction;
415
500
  errors: Errors.INVALID_CONTRACT_CLASS;
416
501
  };
417
-
418
502
  starknet_addDeployAccountTransaction: {
419
- params: {
420
- contract_address_salt: FELT;
421
- constructor_calldata: Array<FELT>;
422
- class_hash: FELT;
503
+ params: BROADCASTED_DEPLOY_ACCOUNT_TXN;
504
+ result: {
505
+ transaction_hash: TXN_HASH;
506
+ contract_address: FELT;
423
507
  };
424
- result: DeployedTransaction;
425
- errors: Errors.INVALID_CONTRACT_CLASS;
508
+ errors: Errors.CLASS_HASH_NOT_FOUND;
426
509
  };
427
510
 
428
511
  // Trace API
@@ -430,10 +513,10 @@ export namespace OPENRPC {
430
513
  params: { transaction_hash: TXN_HASH };
431
514
  result: Trace;
432
515
  errors:
433
- | Errors.INVALID_TXN_HASH
516
+ | Errors.TXN_HASH_NOT_FOUND
434
517
  | Errors.NO_TRACE_AVAILABLE
435
518
  | Errors.INVALID_BLOCK_HASH
436
- | Errors.INVALID_TXN_HASH;
519
+ | Errors.TXN_HASH_NOT_FOUND;
437
520
  };
438
521
  starknet_traceBlockTransactions: {
439
522
  params: { block_hash: BLOCK_HASH };
@@ -464,9 +547,9 @@ export namespace Errors {
464
547
  message: 'Invalid call data';
465
548
  }
466
549
 
467
- export interface INVALID_BLOCK_ID {
550
+ export interface BLOCK_NOT_FOUND {
468
551
  code: 24;
469
- message: 'Invalid block id';
552
+ message: 'Block not found';
470
553
  }
471
554
 
472
555
  export interface INVALID_TXN_INDEX {
@@ -474,9 +557,9 @@ export namespace Errors {
474
557
  message: 'Invalid transaction index in a block';
475
558
  }
476
559
 
477
- export interface INVALID_CONTRACT_CLASS_HASH {
560
+ export interface CLASS_HASH_NOT_FOUND {
478
561
  code: 28;
479
- message: 'The supplied contract class hash is invalid or unknown';
562
+ message: 'Class hash not found';
480
563
  }
481
564
 
482
565
  export interface PAGE_SIZE_TOO_BIG {
@@ -489,6 +572,11 @@ export namespace Errors {
489
572
  message: 'There are no blocks';
490
573
  }
491
574
 
575
+ export interface INVALID_CONTINUATION_TOKEN {
576
+ code: 33;
577
+ message: 'The supplied continuation token is invalid or unknown';
578
+ }
579
+
492
580
  export interface CONTRACT_ERROR {
493
581
  code: 40;
494
582
  message: 'Contract error';
@@ -512,8 +600,8 @@ export namespace Errors {
512
600
  message: 'Invalid block hash';
513
601
  }
514
602
 
515
- export interface INVALID_TXN_HASH {
603
+ export interface TXN_HASH_NOT_FOUND {
516
604
  code: 25;
517
- message: 'Invalid transaction hash';
605
+ message: 'Transaction hash not found';
518
606
  }
519
607
  }
@@ -41,6 +41,5 @@ export namespace RPC {
41
41
  export type InvokedTransaction = OPENRPC.InvokedTransaction;
42
42
  export type DeclaredTransaction = OPENRPC.DeclaredTransaction;
43
43
  export type DeployedTransaction = OPENRPC.DeployedTransaction;
44
-
45
44
  export type Methods = OPENRPC.Methods;
46
45
  }
@@ -1,6 +1,6 @@
1
1
  export * from './lib';
2
2
  export * as api from './api';
3
- export { Calldata, Overrides, RawArgs } from './api';
3
+ export { Calldata, Overrides } from './api';
4
4
  export * from './signer';
5
5
  export * from './contract';
6
6
  export * from './account';
package/src/types/lib.ts CHANGED
@@ -7,6 +7,11 @@ export type KeyPair = EC.KeyPair;
7
7
  export type Signature = string[];
8
8
  export type RawCalldata = BigNumberish[];
9
9
  export type AllowArray<T> = T | T[];
10
+ export type RawArgs =
11
+ | {
12
+ [inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
13
+ }
14
+ | string[];
10
15
 
11
16
  export interface ContractClass {
12
17
  program: CompressedProgram;
@@ -14,6 +19,14 @@ export interface ContractClass {
14
19
  abi?: Abi;
15
20
  }
16
21
 
22
+ export type UniversalDeployerContractPayload = {
23
+ classHash: BigNumberish;
24
+ salt: string;
25
+ unique: boolean;
26
+ constructorCalldata?: RawArgs;
27
+ isDevnet?: boolean;
28
+ };
29
+
17
30
  export type DeployContractPayload = {
18
31
  contract: CompiledContract | string;
19
32
  constructorCalldata?: RawCalldata;
@@ -81,9 +94,15 @@ export type FunctionAbi = {
81
94
  name: string;
82
95
  outputs: AbiEntry[];
83
96
  stateMutability?: 'view';
84
- type: 'function' | 'constructor';
97
+ type: FunctionAbiType;
85
98
  };
86
99
 
100
+ enum FunctionAbiType {
101
+ 'function',
102
+ 'l1_handler',
103
+ 'constructor',
104
+ }
105
+
87
106
  export type StructAbi = {
88
107
  members: (AbiEntry & { offset: number })[];
89
108
  name: string;
@@ -91,7 +110,9 @@ export type StructAbi = {
91
110
  type: 'struct';
92
111
  };
93
112
 
94
- export type Abi = Array<FunctionAbi | StructAbi>;
113
+ export type Abi = Array<FunctionAbi | EventAbi | StructAbi>;
114
+
115
+ type EventAbi = any;
95
116
 
96
117
  export type EntryPointsByType = object;
97
118
  export type Program = Record<any, any>;
@@ -88,3 +88,5 @@ export function getHexString(value: string) {
88
88
  export function getHexStringArray(value: Array<string>) {
89
89
  return value.map((el) => getHexString(el));
90
90
  }
91
+
92
+ export const toCairoBool = (value: boolean): string => (+value).toString();
@@ -1,11 +1,5 @@
1
1
  import { BigNumberish } from '../../utils/number';
2
2
  import { Signature } from '../lib';
3
- export declare type RawArgs = {
4
- [inputName: string]: string | string[] | {
5
- type: 'struct';
6
- [k: string]: BigNumberish;
7
- };
8
- };
9
3
  export declare type Calldata = string[];
10
4
  export declare type Overrides = {
11
5
  maxFee?: BigNumberish;