starknet 4.17.0 → 4.18.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 (150) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -10
  3. package/dist/index.d.ts +27 -9
  4. package/dist/index.global.js +30 -13
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +30 -13
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +30 -13
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +5 -1
  11. package/.babelrc +0 -6
  12. package/.commitlintrc +0 -22
  13. package/.eslintignore +0 -2
  14. package/.eslintrc +0 -28
  15. package/.prettierrc +0 -6
  16. package/.releaserc +0 -28
  17. package/CODE_OF_CONDUCT.md +0 -128
  18. package/CONTRIBUTING.md +0 -52
  19. package/__mocks__/Account.json +0 -25486
  20. package/__mocks__/ERC20.json +0 -40027
  21. package/__mocks__/TestDapp.json +0 -12962
  22. package/__mocks__/contract.json +0 -33191
  23. package/__mocks__/l1l2_compiled.json +0 -10107
  24. package/__mocks__/multicall.json +0 -8139
  25. package/__mocks__/naming_compiled.json +0 -53283
  26. package/__mocks__/starknetId_compiled.json +0 -44703
  27. package/__mocks__/typedDataExample.json +0 -35
  28. package/__mocks__/typedDataSessionExample.json +0 -42
  29. package/__mocks__/typedDataStructArrayExample.json +0 -44
  30. package/__tests__/account.test.ts +0 -345
  31. package/__tests__/contract.test.ts +0 -249
  32. package/__tests__/defaultProvider.test.ts +0 -177
  33. package/__tests__/fixtures.ts +0 -84
  34. package/__tests__/jest.setup.ts +0 -30
  35. package/__tests__/rpcProvider.test.ts +0 -132
  36. package/__tests__/sequencerProvider.test.ts +0 -123
  37. package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +0 -5
  38. package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +0 -5
  39. package/__tests__/utils/__snapshots__/utils.test.ts.snap +0 -5
  40. package/__tests__/utils/address.test.ts +0 -45
  41. package/__tests__/utils/ellipticalCurve.test.ts +0 -91
  42. package/__tests__/utils/merkle.test.ts +0 -256
  43. package/__tests__/utils/shortString.test.ts +0 -22
  44. package/__tests__/utils/starknetId.test.ts +0 -53
  45. package/__tests__/utils/transactionHash.test.ts +0 -17
  46. package/__tests__/utils/typedData.test.ts +0 -223
  47. package/__tests__/utils/uint256.test.ts +0 -32
  48. package/__tests__/utils/utils.browser.test.ts +0 -29
  49. package/__tests__/utils/utils.test.ts +0 -141
  50. package/img/logo.svg +0 -17
  51. package/index.d.ts +0 -2683
  52. package/index.global.js +0 -23192
  53. package/index.global.js.map +0 -1
  54. package/index.js +0 -4910
  55. package/index.js.map +0 -1
  56. package/index.mjs +0 -4852
  57. package/index.mjs.map +0 -1
  58. package/src/account/default.ts +0 -501
  59. package/src/account/index.ts +0 -2
  60. package/src/account/interface.ts +0 -309
  61. package/src/constants.ts +0 -2065
  62. package/src/contract/contractFactory.ts +0 -88
  63. package/src/contract/default.ts +0 -425
  64. package/src/contract/index.ts +0 -3
  65. package/src/contract/interface.ts +0 -106
  66. package/src/index.ts +0 -26
  67. package/src/provider/default.ts +0 -187
  68. package/src/provider/errors.ts +0 -14
  69. package/src/provider/index.ts +0 -9
  70. package/src/provider/interface.ts +0 -281
  71. package/src/provider/rpc.ts +0 -482
  72. package/src/provider/sequencer.ts +0 -523
  73. package/src/provider/utils.ts +0 -100
  74. package/src/signer/default.ts +0 -99
  75. package/src/signer/index.ts +0 -2
  76. package/src/signer/interface.ts +0 -77
  77. package/src/types/account.ts +0 -43
  78. package/src/types/api/index.ts +0 -10
  79. package/src/types/api/openrpc.ts +0 -607
  80. package/src/types/api/rpc.ts +0 -45
  81. package/src/types/api/sequencer.ts +0 -369
  82. package/src/types/contract.ts +0 -5
  83. package/src/types/index.ts +0 -8
  84. package/src/types/lib.ts +0 -143
  85. package/src/types/provider.ts +0 -134
  86. package/src/types/signer.ts +0 -24
  87. package/src/utils/address.ts +0 -44
  88. package/src/utils/calldata.ts +0 -250
  89. package/src/utils/ellipticCurve.ts +0 -120
  90. package/src/utils/encode.ts +0 -66
  91. package/src/utils/events.ts +0 -32
  92. package/src/utils/fetchPonyfill.ts +0 -5
  93. package/src/utils/hash.ts +0 -235
  94. package/src/utils/json.ts +0 -15
  95. package/src/utils/merkle.ts +0 -69
  96. package/src/utils/number.ts +0 -98
  97. package/src/utils/provider.ts +0 -28
  98. package/src/utils/responseParser/index.ts +0 -28
  99. package/src/utils/responseParser/rpc.ts +0 -70
  100. package/src/utils/responseParser/sequencer.ts +0 -135
  101. package/src/utils/shortString.ts +0 -21
  102. package/src/utils/stark.ts +0 -57
  103. package/src/utils/starknetId.ts +0 -116
  104. package/src/utils/transaction.ts +0 -56
  105. package/src/utils/typedData/index.ts +0 -247
  106. package/src/utils/typedData/types.ts +0 -37
  107. package/src/utils/typedData/utils.ts +0 -16
  108. package/src/utils/uint256.ts +0 -32
  109. package/src/utils/url.ts +0 -53
  110. package/tsconfig.eslint.json +0 -4
  111. package/tsup.config.ts +0 -9
  112. package/www/README.md +0 -41
  113. package/www/babel.config.js +0 -3
  114. package/www/code-examples/account.js +0 -65
  115. package/www/code-examples/amm.js +0 -44
  116. package/www/code-examples/erc20.js +0 -13
  117. package/www/code-examples/package-lock.json +0 -336
  118. package/www/code-examples/package.json +0 -15
  119. package/www/docs/API/_category_.json +0 -5
  120. package/www/docs/API/account.md +0 -463
  121. package/www/docs/API/changelog.md +0 -15
  122. package/www/docs/API/contract.md +0 -135
  123. package/www/docs/API/contractFactory.md +0 -45
  124. package/www/docs/API/index.md +0 -3
  125. package/www/docs/API/provider.md +0 -725
  126. package/www/docs/API/signer.md +0 -105
  127. package/www/docs/API/utils.md +0 -374
  128. package/www/docusaurus.config.js +0 -130
  129. package/www/guides/account.md +0 -140
  130. package/www/guides/cra.md +0 -3
  131. package/www/guides/erc20.md +0 -163
  132. package/www/guides/intro.md +0 -63
  133. package/www/package-lock.json +0 -20405
  134. package/www/package.json +0 -43
  135. package/www/sidebars.js +0 -31
  136. package/www/src/components/HomepageFeatures/index.tsx +0 -67
  137. package/www/src/components/HomepageFeatures/styles.module.css +0 -10
  138. package/www/src/css/custom.css +0 -39
  139. package/www/src/pages/index.module.css +0 -23
  140. package/www/src/pages/index.tsx +0 -40
  141. package/www/src/pages/markdown-page.md +0 -7
  142. package/www/static/.nojekyll +0 -0
  143. package/www/static/img/docusaurus.png +0 -0
  144. package/www/static/img/favicon.ico +0 -0
  145. package/www/static/img/logo.svg +0 -17
  146. package/www/static/img/starknet-1.png +0 -0
  147. package/www/static/img/starknet-2.png +0 -0
  148. package/www/static/img/starknet-3.png +0 -0
  149. package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
  150. package/www/static/img/tutorial/localeDropdown.png +0 -0
@@ -1,607 +0,0 @@
1
- /**
2
- * Starknet RPC version 0.2.0
3
- *
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
- *
8
- * TypeScript Representation of OpenRpc protocol types
9
- */
10
-
11
- export type FELT = string;
12
- export type ADDRESS = FELT;
13
- type NUM_AS_HEX = string;
14
- type SIGNATURE = Array<FELT>;
15
- // type ETH_ADDRESS = string;
16
- type BLOCK_NUMBER = number;
17
- type BLOCK_HASH = FELT;
18
- type TXN_HASH = FELT;
19
- type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
20
- type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'DEPLOY_ACCOUNT' | 'INVOKE' | 'L1_HANDLER';
21
- type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
22
- enum BLOCK_TAG {
23
- 'latest',
24
- 'pending',
25
- }
26
- type BLOCK_ID = { block_hash: BLOCK_HASH } | { block_number: BLOCK_NUMBER } | BLOCK_TAG;
27
- type MSG_TO_L1 = {
28
- to_address: FELT;
29
- payload: Array<FELT>;
30
- };
31
- type EVENT = {
32
- from_address: FELT;
33
- keys: Array<FELT>;
34
- data: Array<FELT>;
35
- };
36
-
37
- type COMMON_RECEIPT_PROPERTIES = {
38
- transaction_hash: TXN_HASH;
39
- actual_fee: FELT;
40
- status: TXN_STATUS;
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>;
46
- };
47
-
48
- type PENDING_COMMON_RECEIPT_PROPERTIES = {
49
- transaction_hash: TXN_HASH;
50
- actual_fee: FELT;
51
- type?: TXN_TYPE;
52
- messages_sent: Array<MSG_TO_L1>;
53
- events: Array<EVENT>;
54
- };
55
-
56
- type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
57
- type DECLARE_TXN_RECEIPT = 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
-
71
- type TXN_RECEIPT =
72
- | INVOKE_TXN_RECEIPT
73
- | L1_HANDLER_TXN_RECEIPT
74
- | DECLARE_TXN_RECEIPT
75
- | DEPLOY_TXN_RECEIPT
76
- | DEPLOY_ACCOUNT_TXN_RECEIPT
77
- | PENDING_TXN_RECEIPT;
78
-
79
- type BLOCK_HEADER = {
80
- block_hash: BLOCK_HASH;
81
- parent_hash: BLOCK_HASH;
82
- block_number: BLOCK_NUMBER;
83
- new_root: FELT;
84
- timestamp: number;
85
- sequencer_address: FELT;
86
- };
87
- type BLOCK_BODY_WITH_TX_HASHES = {
88
- transactions: Array<TXN_HASH>;
89
- };
90
- type BLOCK_WITH_TX_HASHES = {
91
- status: BLOCK_STATUS;
92
- } & BLOCK_HEADER &
93
- BLOCK_BODY_WITH_TX_HASHES;
94
- type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
95
- timestamp: number;
96
- sequencer_address: FELT;
97
- parent_hash: BLOCK_HASH;
98
- };
99
- // transaction_hash, nonce, type optional because of pathfinder not implemented
100
- type COMMON_TXN_PROPERTIES = {
101
- transaction_hash?: TXN_HASH;
102
- } & BROADCASTED_TXN_COMMON_PROPERTIES;
103
- type FUNCTION_CALL = {
104
- contract_address?: ADDRESS;
105
- entry_point_selector?: FELT;
106
- calldata?: Array<FELT>;
107
- };
108
- type INVOKE_TXN = COMMON_TXN_PROPERTIES & (INVOKE_TXN_V0 | INVOKE_TXN_V1);
109
- type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
110
- class_hash: FELT;
111
- sender_address: ADDRESS;
112
- };
113
- type DEPLOY_TXN = {
114
- transaction_hash: TXN_HASH;
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 = {
121
- contract_address_salt: FELT;
122
- constructor_calldata: Array<FELT>;
123
- class_hash: FELT;
124
- };
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 = {
161
- contract_class: CONTRACT_CLASS;
162
- sender_address: ADDRESS;
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 = {
170
- version: NUM_AS_HEX;
171
- type: TXN_TYPE;
172
- contract_address_salt: FELT;
173
- constructor_calldata: Array<FELT>;
174
- };
175
-
176
- type INVOKE_TXN_V0 = FUNCTION_CALL;
177
-
178
- type INVOKE_TXN_V1 = {
179
- sender_address: ADDRESS;
180
- calldata: Array<FELT>;
181
- };
182
-
183
- type BLOCK_BODY_WITH_TXS = {
184
- transactions: Array<TXN>;
185
- };
186
- type BLOCK_WITH_TXS = {
187
- status: BLOCK_STATUS;
188
- } & BLOCK_HEADER &
189
- BLOCK_BODY_WITH_TXS;
190
- type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
191
- timestamp: number;
192
- sequencer_address: FELT;
193
- parent_hash: BLOCK_HASH;
194
- };
195
-
196
- type CONTRACT_CLASS = {
197
- program: string;
198
- entry_points_by_type: {
199
- CONSTRUCTOR: CONTRACT_ENTRY_POINT_LIST;
200
- EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
201
- L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
202
- };
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>;
243
- };
244
-
245
- type TYPED_PARAMETER = {
246
- name: string;
247
- type: string;
248
- };
249
-
250
- type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
251
- type CONTRACT_ENTRY_POINT = {
252
- offset: NUM_AS_HEX;
253
- selector: FELT;
254
- };
255
- type CONTRACT_STORAGE_DIFF_ITEM = {
256
- address: FELT;
257
- storage_entries: [key: FELT, value: FELT];
258
- };
259
-
260
- type DEPLOYED_CONTRACT_ITEM = {
261
- address: FELT;
262
- class_hash: FELT;
263
- };
264
- type STATE_UPDATE = {
265
- block_hash: BLOCK_HASH;
266
- new_root: FELT;
267
- old_root: FELT;
268
- state_diff: {
269
- storage_diffs: Array<CONTRACT_STORAGE_DIFF_ITEM>;
270
- declared_contract_hashes: Array<FELT>;
271
- deployed_contracts: Array<DEPLOYED_CONTRACT_ITEM>;
272
- nonces: Array<{
273
- contract_address: ADDRESS;
274
- nonce: FELT;
275
- }>;
276
- };
277
- };
278
- type STORAGE_KEY = string;
279
- type EVENT_FILTER = {
280
- from_block?: BLOCK_ID;
281
- to_block?: BLOCK_ID;
282
- address?: ADDRESS;
283
- keys?: Array<FELT>;
284
- };
285
- type RESULT_PAGE_REQUEST = {
286
- continuation_token?: string;
287
- chunk_size: number;
288
- };
289
- type EMITTED_EVENT = EVENT & {
290
- block_hash: BLOCK_HASH;
291
- block_number: BLOCK_NUMBER;
292
- transaction_hash: TXN_HASH;
293
- };
294
- type SYNC_STATUS = {
295
- starting_block_hash: BLOCK_HASH;
296
- starting_block_num: NUM_AS_HEX;
297
- current_block_hash: BLOCK_HASH;
298
- current_block_num: NUM_AS_HEX;
299
- highest_block_hash: BLOCK_HASH;
300
- highest_block_num: NUM_AS_HEX;
301
- };
302
- type FEE_ESTIMATE = {
303
- gas_consumed: NUM_AS_HEX;
304
- gas_price: NUM_AS_HEX;
305
- overall_fee: NUM_AS_HEX;
306
- };
307
-
308
- enum CALL_TYPE {
309
- 'DELEGATE',
310
- 'CALL',
311
- }
312
- enum ENTRY_POINT_TYPE {
313
- 'EXTERNAL',
314
- 'L1_HANDLER',
315
- 'CONSTRUCTOR',
316
- }
317
- type FUNCTION_INVOCATION = FUNCTION_CALL & {
318
- caller_address: FELT;
319
- code_address: FELT;
320
- entry_point_type: ENTRY_POINT_TYPE;
321
- call_type: CALL_TYPE;
322
- result: FELT;
323
- calls: NESTED_CALL;
324
- events: Array<EVENT>;
325
- messages: MSG_TO_L1;
326
- };
327
- type NESTED_CALL = FUNCTION_INVOCATION;
328
-
329
- type TRACE_ROOT = {
330
- nonce: FELT;
331
- signature: FELT;
332
- function_invocation: FUNCTION_INVOCATION;
333
- };
334
-
335
- export namespace OPENRPC {
336
- export type Nonce = FELT;
337
- export type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
338
- export type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
339
- export type StateUpdate = STATE_UPDATE;
340
- export type Storage = FELT;
341
- export type Transaction = TXN;
342
- export type TransactionReceipt = TXN_RECEIPT;
343
- export type ContractClass = CONTRACT_CLASS;
344
- export type CallResponse = Array<FELT>;
345
- export type EstimatedFee = FEE_ESTIMATE;
346
- export type BlockNumber = BLOCK_NUMBER;
347
- export type BlockHashAndNumber = {
348
- block_hash: BLOCK_HASH;
349
- block_number: BLOCK_NUMBER;
350
- };
351
- export type CHAIN_ID = string;
352
- export type PendingTransactions = Array<TXN>;
353
- export type SyncingStatus = false | SYNC_STATUS;
354
- export type Events = {
355
- events: Array<EMITTED_EVENT>;
356
- continuation_token: string;
357
- };
358
- export type Trace = TRACE_ROOT;
359
- export type Traces = Array<{
360
- transaction_hash: FELT;
361
- trace_root: TRACE_ROOT;
362
- }>;
363
- export type TransactionHash = TXN_HASH;
364
- export type BlockHash = BLOCK_HASH;
365
- export type EventFilter = EVENT_FILTER & RESULT_PAGE_REQUEST;
366
- export type InvokedTransaction = { transaction_hash: TXN_HASH };
367
- export type DeclaredTransaction = { transaction_hash: TXN_HASH; class_hash: FELT };
368
- export type DeployedTransaction = { transaction_hash: TXN_HASH; contract_address: FELT };
369
-
370
- // Final Methods
371
- export type Methods = {
372
- // Read API
373
- starknet_getBlockWithTxHashes: {
374
- params: { block_id: BLOCK_ID };
375
- result: BlockWithTxHashes;
376
- errors: Errors.BLOCK_NOT_FOUND;
377
- };
378
- starknet_getBlockWithTxs: {
379
- params: { block_id: BLOCK_ID };
380
- result: BlockWithTxs;
381
- errors: Errors.BLOCK_NOT_FOUND;
382
- };
383
- starknet_getStateUpdate: {
384
- params: { block_id: BLOCK_ID };
385
- result: StateUpdate;
386
- errors: Errors.BLOCK_NOT_FOUND;
387
- };
388
- starknet_getStorageAt: {
389
- params: { contract_address: ADDRESS; key: STORAGE_KEY; block_id: BLOCK_ID };
390
- result: Storage;
391
- errors: Errors.CONTRACT_NOT_FOUND | Errors.BLOCK_NOT_FOUND;
392
- };
393
- starknet_getTransactionByHash: {
394
- params: { transaction_hash: TXN_HASH };
395
- result: Transaction;
396
- errors: Errors.TXN_HASH_NOT_FOUND;
397
- };
398
- starknet_getTransactionByBlockIdAndIndex: {
399
- params: { block_id: BLOCK_ID; index: number };
400
- result: Transaction;
401
- errors: Errors.BLOCK_NOT_FOUND | Errors.INVALID_TXN_INDEX;
402
- };
403
- starknet_getTransactionReceipt: {
404
- params: { transaction_hash: TXN_HASH };
405
- result: TransactionReceipt;
406
- errors: Errors.TXN_HASH_NOT_FOUND;
407
- };
408
- starknet_getClass: {
409
- params: { block_id: BLOCK_ID; class_hash: FELT };
410
- result: ContractClass;
411
- errors: Errors.BLOCK_NOT_FOUND | Errors.CLASS_HASH_NOT_FOUND;
412
- };
413
- starknet_getClassHashAt: {
414
- params: { block_id: BLOCK_ID; contract_address: ADDRESS };
415
- result: FELT;
416
- errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
417
- };
418
- starknet_getClassAt: {
419
- params: { block_id: BLOCK_ID; contract_address: ADDRESS };
420
- result: ContractClass;
421
- errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
422
- };
423
- starknet_getBlockTransactionCount: {
424
- params: { block_id: BLOCK_ID };
425
- result: number;
426
- errors: Errors.BLOCK_NOT_FOUND;
427
- };
428
- starknet_call: {
429
- params: { request: FUNCTION_CALL; block_id: BLOCK_ID };
430
- result: Array<FELT>;
431
- errors:
432
- | Errors.CONTRACT_NOT_FOUND
433
- | Errors.INVALID_MESSAGE_SELECTOR
434
- | Errors.INVALID_CALL_DATA
435
- | Errors.CONTRACT_ERROR
436
- | Errors.BLOCK_NOT_FOUND;
437
- };
438
- starknet_estimateFee: {
439
- params: { request: BROADCASTED_TXN; block_id: BLOCK_ID };
440
- result: FEE_ESTIMATE;
441
- errors:
442
- | Errors.CONTRACT_NOT_FOUND
443
- | Errors.INVALID_MESSAGE_SELECTOR
444
- | Errors.INVALID_CALL_DATA
445
- | Errors.CONTRACT_ERROR
446
- | Errors.BLOCK_NOT_FOUND;
447
- };
448
- starknet_blockNumber: {
449
- params: {};
450
- result: BLOCK_NUMBER;
451
- errors: Errors.NO_BLOCKS;
452
- };
453
- starknet_blockHashAndNumber: {
454
- params: {};
455
- result: BLOCK_HASH & BLOCK_NUMBER;
456
- errors: Errors.NO_BLOCKS;
457
- };
458
- starknet_chainId: {
459
- params: {};
460
- result: CHAIN_ID;
461
- };
462
- starknet_pendingTransactions: {
463
- params: {};
464
- result: PendingTransactions;
465
- };
466
- starknet_syncing: {
467
- params: {};
468
- result: SyncingStatus;
469
- };
470
- starknet_getEvents: {
471
- params: { filter: EVENT_FILTER & RESULT_PAGE_REQUEST };
472
- result: Events;
473
- errors: Errors.PAGE_SIZE_TOO_BIG | Errors.INVALID_CONTINUATION_TOKEN | Errors.BLOCK_NOT_FOUND;
474
- };
475
- starknet_getNonce: {
476
- params: { block_id: BLOCK_ID; contract_address: ADDRESS };
477
- result: FELT;
478
- errors: Errors.BLOCK_NOT_FOUND | Errors.CONTRACT_NOT_FOUND;
479
- };
480
-
481
- // Write API
482
- starknet_addInvokeTransaction: {
483
- params: {
484
- invoke_transaction: BROADCASTED_INVOKE_TXN;
485
- };
486
- result: InvokedTransaction;
487
- };
488
- starknet_addDeclareTransaction: {
489
- params: {
490
- declare_transaction: BROADCASTED_DECLARE_TXN;
491
- };
492
- result: DeclaredTransaction;
493
- errors: Errors.INVALID_CONTRACT_CLASS;
494
- };
495
- starknet_addDeployTransaction: {
496
- params: {
497
- deploy_transaction: BROADCASTED_DEPLOY_TXN;
498
- };
499
- result: DeployedTransaction;
500
- errors: Errors.INVALID_CONTRACT_CLASS;
501
- };
502
- starknet_addDeployAccountTransaction: {
503
- params: BROADCASTED_DEPLOY_ACCOUNT_TXN;
504
- result: {
505
- transaction_hash: TXN_HASH;
506
- contract_address: FELT;
507
- };
508
- errors: Errors.CLASS_HASH_NOT_FOUND;
509
- };
510
-
511
- // Trace API
512
- starknet_traceTransaction: {
513
- params: { transaction_hash: TXN_HASH };
514
- result: Trace;
515
- errors:
516
- | Errors.TXN_HASH_NOT_FOUND
517
- | Errors.NO_TRACE_AVAILABLE
518
- | Errors.INVALID_BLOCK_HASH
519
- | Errors.TXN_HASH_NOT_FOUND;
520
- };
521
- starknet_traceBlockTransactions: {
522
- params: { block_hash: BLOCK_HASH };
523
- result: Traces;
524
- errors: Errors.INVALID_BLOCK_HASH;
525
- };
526
- };
527
- }
528
-
529
- export namespace Errors {
530
- export interface FAILED_TO_RECEIVE_TXN {
531
- code: 1;
532
- message: 'Failed to write transaction';
533
- }
534
-
535
- export interface CONTRACT_NOT_FOUND {
536
- code: 20;
537
- message: 'Contract not found';
538
- }
539
-
540
- export interface INVALID_MESSAGE_SELECTOR {
541
- code: 21;
542
- message: 'Invalid message selector';
543
- }
544
-
545
- export interface INVALID_CALL_DATA {
546
- code: 22;
547
- message: 'Invalid call data';
548
- }
549
-
550
- export interface BLOCK_NOT_FOUND {
551
- code: 24;
552
- message: 'Block not found';
553
- }
554
-
555
- export interface INVALID_TXN_INDEX {
556
- code: 27;
557
- message: 'Invalid transaction index in a block';
558
- }
559
-
560
- export interface CLASS_HASH_NOT_FOUND {
561
- code: 28;
562
- message: 'Class hash not found';
563
- }
564
-
565
- export interface PAGE_SIZE_TOO_BIG {
566
- code: 31;
567
- message: 'Requested page size is too big';
568
- }
569
-
570
- export interface NO_BLOCKS {
571
- code: 32;
572
- message: 'There are no blocks';
573
- }
574
-
575
- export interface INVALID_CONTINUATION_TOKEN {
576
- code: 33;
577
- message: 'The supplied continuation token is invalid or unknown';
578
- }
579
-
580
- export interface CONTRACT_ERROR {
581
- code: 40;
582
- message: 'Contract error';
583
- }
584
-
585
- export interface INVALID_CONTRACT_CLASS {
586
- code: 50;
587
- message: 'Invalid contract class';
588
- }
589
-
590
- export interface NO_TRACE_AVAILABLE {
591
- code: 10;
592
- message: 'No trace available for transaction';
593
- data: {
594
- status: 'RECEIVED' | 'REJECTED';
595
- };
596
- }
597
-
598
- export interface INVALID_BLOCK_HASH {
599
- code: 24;
600
- message: 'Invalid block hash';
601
- }
602
-
603
- export interface TXN_HASH_NOT_FOUND {
604
- code: 25;
605
- message: 'Transaction hash not found';
606
- }
607
- }
@@ -1,45 +0,0 @@
1
- import { ADDRESS, FELT, OPENRPC } from './openrpc';
2
-
3
- export namespace RPC {
4
- export type Response = {
5
- id: number;
6
- jsonrpc: string;
7
- result?: any;
8
- error?: {
9
- code: string;
10
- message: string;
11
- };
12
- };
13
-
14
- export type ChainId = OPENRPC.CHAIN_ID;
15
- export type CallResponse = OPENRPC.CallResponse;
16
- export type ContractAddress = ADDRESS;
17
- export type Felt = FELT;
18
- export type Nonce = OPENRPC.Nonce;
19
- export type ContractClass = OPENRPC.ContractClass;
20
- export type StateUpdate = OPENRPC.StateUpdate;
21
- export type Transaction = OPENRPC.Transaction;
22
- export type PendingTransactions = OPENRPC.PendingTransactions;
23
- export type TransactionHash = OPENRPC.TransactionHash;
24
- export type Trace = OPENRPC.Trace;
25
- export type Traces = OPENRPC.Traces;
26
- export type BlockHash = OPENRPC.BlockHash;
27
- export type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
28
- export type GetClassResponse = OPENRPC.ContractClass;
29
- export type EstimateFeeResponse = OPENRPC.EstimatedFee;
30
- export type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
31
- export type GetBlockWithTxs = OPENRPC.BlockWithTxs;
32
- export type GetStorageAtResponse = OPENRPC.Storage;
33
- export type TransactionReceipt = OPENRPC.TransactionReceipt;
34
- export type GetTransactionByHashResponse = OPENRPC.Transaction;
35
- export type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
36
- export type GetTransactionCountResponse = number;
37
- export type GetBlockNumberResponse = OPENRPC.BlockNumber;
38
- export type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
39
- export type EventFilter = OPENRPC.EventFilter;
40
- export type GetEventsResponse = OPENRPC.Events;
41
- export type InvokedTransaction = OPENRPC.InvokedTransaction;
42
- export type DeclaredTransaction = OPENRPC.DeclaredTransaction;
43
- export type DeployedTransaction = OPENRPC.DeployedTransaction;
44
- export type Methods = OPENRPC.Methods;
45
- }