starknet 4.5.0 → 4.6.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.
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { BlockNumber } from '../types';
3
2
  import { BigNumberish } from '../utils/number';
4
3
  /**
@@ -17,38 +16,15 @@ export declare function formatHash(hashValue: BigNumberish): string;
17
16
  */
18
17
  export declare function txIdentifier(txHash?: BigNumberish, txId?: BigNumberish): string;
19
18
  export declare type BlockIdentifier = BlockNumber | BigNumberish;
20
- declare type BlockIdentifierObject = {
21
- type: 'BLOCK_NUMBER';
22
- data: BlockNumber;
23
- } | {
24
- type: 'BLOCK_HASH';
25
- data: BigNumberish;
26
- };
27
- export declare class BlockIdentifierClass {
28
- blockIdentifier: BlockIdentifier;
29
- constructor(blockIdentifier: BlockIdentifier);
30
- getIdentifier(): string | import("bn.js") | {
31
- block_hash: string;
32
- block_number?: undefined;
33
- } | {
34
- block_number: number;
35
- block_hash?: undefined;
36
- } | null;
19
+ export declare class Block {
20
+ hash: BlockIdentifier;
21
+ number: BlockIdentifier;
22
+ tag: BlockIdentifier;
23
+ private setIdentifier;
24
+ constructor(_identifier: BlockIdentifier);
25
+ get queryIdentifier(): any;
26
+ get identifier(): any;
27
+ set identifier(_identifier: BlockIdentifier);
28
+ valueOf: () => BlockIdentifier;
29
+ toString: () => BlockIdentifier;
37
30
  }
38
- /**
39
- * Identifies the block to be queried.
40
- *
41
- * @param blockIdentifier - block identifier
42
- * @returns block identifier object
43
- */
44
- export declare function getBlockIdentifier(blockIdentifier: BlockIdentifier): BlockIdentifierObject;
45
- /**
46
- * Gets the block identifier for API request
47
- *
48
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L164-L173)
49
- *
50
- * @param blockIdentifier
51
- * @returns block identifier for API request
52
- */
53
- export declare function getFormattedBlockIdentifier(blockIdentifier?: BlockIdentifier): string;
54
- export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFormattedBlockIdentifier = exports.getBlockIdentifier = exports.BlockIdentifierClass = exports.txIdentifier = exports.formatHash = void 0;
3
+ exports.Block = exports.txIdentifier = exports.formatHash = void 0;
4
4
  var number_1 = require("../utils/number");
5
5
  /**
6
6
  *
@@ -29,67 +29,56 @@ function txIdentifier(txHash, txId) {
29
29
  return "transactionHash=".concat(hashString);
30
30
  }
31
31
  exports.txIdentifier = txIdentifier;
32
- var BlockIdentifierClass = /** @class */ (function () {
33
- function BlockIdentifierClass(blockIdentifier) {
34
- this.blockIdentifier = blockIdentifier;
32
+ var Block = /** @class */ (function () {
33
+ function Block(_identifier) {
34
+ var _this = this;
35
+ this.hash = null;
36
+ this.number = null;
37
+ this.tag = null;
38
+ this.valueOf = function () { return _this.number; };
39
+ this.toString = function () { return _this.hash; };
40
+ this.setIdentifier = function (__identifier) {
41
+ if (typeof __identifier === 'string' && (0, number_1.isHex)(__identifier)) {
42
+ this.hash = __identifier;
43
+ }
44
+ else if (typeof __identifier === 'number') {
45
+ this.number = __identifier;
46
+ }
47
+ else {
48
+ this.tag = __identifier;
49
+ }
50
+ };
51
+ this.setIdentifier(_identifier);
35
52
  }
36
- BlockIdentifierClass.prototype.getIdentifier = function () {
37
- if (typeof this.blockIdentifier === 'string' && (0, number_1.isHex)(this.blockIdentifier)) {
38
- return { block_hash: this.blockIdentifier };
39
- }
40
- if (typeof this.blockIdentifier === 'number') {
41
- return { block_number: this.blockIdentifier };
42
- }
43
- return this.blockIdentifier;
44
- };
45
- return BlockIdentifierClass;
53
+ Object.defineProperty(Block.prototype, "queryIdentifier", {
54
+ get: function () {
55
+ if (this.number !== null) {
56
+ return "blockNumber=".concat(this.number);
57
+ }
58
+ if (this.hash !== null) {
59
+ return "blockHash=".concat(this.hash);
60
+ }
61
+ return "blockNumber=".concat(this.tag);
62
+ },
63
+ enumerable: false,
64
+ configurable: true
65
+ });
66
+ Object.defineProperty(Block.prototype, "identifier", {
67
+ get: function () {
68
+ if (this.number !== null) {
69
+ return { block_number: this.number };
70
+ }
71
+ if (this.hash !== null) {
72
+ return { block_hash: this.hash };
73
+ }
74
+ return this.tag;
75
+ },
76
+ set: function (_identifier) {
77
+ this.setIdentifier(_identifier);
78
+ },
79
+ enumerable: false,
80
+ configurable: true
81
+ });
82
+ return Block;
46
83
  }());
47
- exports.BlockIdentifierClass = BlockIdentifierClass;
48
- /**
49
- * Identifies the block to be queried.
50
- *
51
- * @param blockIdentifier - block identifier
52
- * @returns block identifier object
53
- */
54
- function getBlockIdentifier(blockIdentifier) {
55
- if (blockIdentifier === null || blockIdentifier === 'latest') {
56
- return { type: 'BLOCK_NUMBER', data: 'latest' }; // default to latest block
57
- }
58
- if (blockIdentifier === 'pending') {
59
- return { type: 'BLOCK_NUMBER', data: 'pending' };
60
- }
61
- if (typeof blockIdentifier === 'number' || typeof blockIdentifier === 'bigint') {
62
- return { type: 'BLOCK_NUMBER', data: blockIdentifier };
63
- }
64
- if (typeof blockIdentifier === 'string' && blockIdentifier.startsWith('0x')) {
65
- return { type: 'BLOCK_HASH', data: blockIdentifier };
66
- }
67
- if (typeof blockIdentifier === 'string' && !Number.isNaN(parseInt(blockIdentifier, 10))) {
68
- return { type: 'BLOCK_NUMBER', data: parseInt(blockIdentifier, 10) };
69
- }
70
- if (typeof blockIdentifier === 'string') {
71
- throw new Error("Invalid block identifier: ".concat(blockIdentifier));
72
- }
73
- return { type: 'BLOCK_HASH', data: blockIdentifier };
74
- }
75
- exports.getBlockIdentifier = getBlockIdentifier;
76
- /**
77
- * Gets the block identifier for API request
78
- *
79
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L164-L173)
80
- *
81
- * @param blockIdentifier
82
- * @returns block identifier for API request
83
- */
84
- function getFormattedBlockIdentifier(blockIdentifier) {
85
- if (blockIdentifier === void 0) { blockIdentifier = null; }
86
- var blockIdentifierObject = getBlockIdentifier(blockIdentifier);
87
- if (blockIdentifierObject.type === 'BLOCK_NUMBER' && blockIdentifierObject.data === null) {
88
- return '';
89
- }
90
- if (blockIdentifierObject.type === 'BLOCK_NUMBER') {
91
- return "blockNumber=".concat(blockIdentifierObject.data);
92
- }
93
- return "blockHash=".concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
94
- }
95
- exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
84
+ exports.Block = Block;
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * Starknet RPC version 0.1.0
3
- * starknet_api_openrpc version 0.31.0
4
3
  *
5
- * TypeScript Representation of OpenRpc protocol types | results
6
- * errors are not implemented here only results
4
+ * StarkNet Node API 0.31.0
5
+ * StarkNet Node Write API 0.3.0
6
+ * StarkNet Trace API 0.3.0
7
+ *
8
+ * TypeScript Representation of OpenRpc protocol types
7
9
  */
8
10
  /**
9
11
  * "type": "string",
@@ -12,12 +14,32 @@
12
14
  * "description": "A field element. Represented as up to 63 hex digits and leading 4 bits zeroed.",
13
15
  * "pattern": "^0x0[a-fA-F0-9]{1,63}$"
14
16
  */
15
- declare type FELT = string;
17
+ export declare type FELT = string;
18
+ export declare type ADDRESS = FELT;
19
+ /**
20
+ * "title": "An integer number in hex format (0x...)",
21
+ * "pattern": "^0x[a-fA-F0-9]+$"
22
+ */
23
+ declare type NUM_AS_HEX = string;
24
+ declare type SIGNATURE = Array<FELT>;
25
+ declare type ETH_ADDRESS = string;
16
26
  declare type BLOCK_NUMBER = number;
17
27
  declare type BLOCK_HASH = FELT;
18
28
  declare type TXN_HASH = FELT;
29
+ declare type CHAIN_ID = string;
30
+ declare type PROTOCOL_VERSION = string;
19
31
  declare type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
20
32
  declare type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
33
+ declare type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
34
+ declare enum BLOCK_TAG {
35
+ 'latest' = 0,
36
+ 'pending' = 1
37
+ }
38
+ declare type BLOCK_ID = {
39
+ block_hash: BLOCK_HASH;
40
+ } | {
41
+ block_number: BLOCK_NUMBER;
42
+ } | BLOCK_TAG;
21
43
  declare type MSG_TO_L1 = {
22
44
  to_address: FELT;
23
45
  payload: Array<FELT>;
@@ -31,36 +53,29 @@ declare type COMMON_RECEIPT_PROPERTIES = {
31
53
  transaction_hash: TXN_HASH;
32
54
  actual_fee: FELT;
33
55
  status: TXN_STATUS;
56
+ status_data?: string;
34
57
  block_hash: BLOCK_HASH;
35
58
  block_number: BLOCK_NUMBER;
36
- type?: TXN_TYPE;
59
+ };
60
+ declare type MSG_TO_L2 = {
61
+ from_address: ETH_ADDRESS;
62
+ payload: FELT;
37
63
  };
38
64
  declare type INVOKE_TXN_RECEIPT_PROPERTIES = {
39
65
  messages_sent: MSG_TO_L1;
66
+ l1_origin_message?: MSG_TO_L2;
40
67
  events: EVENT;
41
68
  };
42
69
  declare type PENDING_COMMON_RECEIPT_PROPERTIES = {
43
70
  transaction_hash: TXN_HASH;
44
71
  actual_fee: FELT;
45
- type?: TXN_TYPE;
46
72
  };
47
73
  declare type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
48
- declare type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
49
74
  declare type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
50
75
  declare type DEPLOY_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
51
76
  declare type PENDING_INVOKE_TXN_RECEIPT = PENDING_COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
52
77
  declare type PENDING_TXN_RECEIPT = PENDING_INVOKE_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
53
- declare type TXN_RECEIPT = INVOKE_TXN_RECEIPT | L1_HANDLER_TXN_RECEIPT | DECLARE_TXN_RECEIPT | DEPLOY_TXN_RECEIPT | PENDING_TXN_RECEIPT;
54
- export declare namespace RPC_1 {
55
- type GetTransactionReceiptResponse = TXN_RECEIPT;
56
- type Methods = {
57
- starknet_getTransactionReceipt: {
58
- QUERY: never;
59
- REQUEST: any[];
60
- RESPONSE: GetTransactionReceiptResponse;
61
- };
62
- };
63
- }
78
+ declare type TXN_RECEIPT = INVOKE_TXN_RECEIPT | DECLARE_TXN_RECEIPT | DEPLOY_TXN_RECEIPT | PENDING_TXN_RECEIPT;
64
79
  declare type BLOCK_HEADER = {
65
80
  block_hash: BLOCK_HASH;
66
81
  parent_hash: BLOCK_HASH;
@@ -80,13 +95,6 @@ declare type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
80
95
  sequencer_address: FELT;
81
96
  parent_hash: BLOCK_HASH;
82
97
  };
83
- declare type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
84
- /**
85
- * "title": "An integer number in hex format (0x...)",
86
- * "pattern": "^0x[a-fA-F0-9]+$"
87
- */
88
- declare type NUM_AS_HEX = string;
89
- declare type SIGNATURE = Array<FELT>;
90
98
  declare type COMMON_TXN_PROPERTIES = {
91
99
  transaction_hash: TXN_HASH;
92
100
  max_fee: FELT;
@@ -95,7 +103,6 @@ declare type COMMON_TXN_PROPERTIES = {
95
103
  nonce: FELT;
96
104
  type: TXN_TYPE;
97
105
  };
98
- declare type ADDRESS = FELT;
99
106
  declare type FUNCTION_CALL = {
100
107
  contract_address: ADDRESS;
101
108
  entry_point_selector: FELT;
@@ -134,18 +141,371 @@ declare type CONTRACT_CLASS = {
134
141
  EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
135
142
  L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
136
143
  };
144
+ abi?: any;
137
145
  };
138
146
  declare type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
139
147
  declare type CONTRACT_ENTRY_POINT = {
140
148
  offset: NUM_AS_HEX;
141
149
  selector: FELT;
142
150
  };
151
+ declare type STORAGE_DIFF_ITEM = {
152
+ address: FELT;
153
+ key: FELT;
154
+ value: FELT;
155
+ };
156
+ declare type DECLARED_CONTRACT_ITEM = {
157
+ class_hash: FELT;
158
+ };
159
+ declare type DEPLOYED_CONTRACT_ITEM = {
160
+ address: FELT;
161
+ class_hash: FELT;
162
+ };
163
+ declare type STATE_UPDATE = {
164
+ block_hash: BLOCK_HASH;
165
+ new_root: FELT;
166
+ old_root: FELT;
167
+ state_diff: {
168
+ storage_diffs: Array<STORAGE_DIFF_ITEM>;
169
+ declared_contracts: Array<DECLARED_CONTRACT_ITEM>;
170
+ deployed_contracts: Array<DEPLOYED_CONTRACT_ITEM>;
171
+ nonces: Array<{
172
+ contract_address: ADDRESS;
173
+ nonce: FELT;
174
+ }>;
175
+ };
176
+ };
177
+ declare type STORAGE_KEY = string;
178
+ declare type EVENT_FILTER = {
179
+ from_block?: BLOCK_ID;
180
+ to_block?: BLOCK_ID;
181
+ address?: ADDRESS;
182
+ keys?: Array<FELT>;
183
+ };
184
+ declare type RESULT_PAGE_REQUEST = {
185
+ page_size: number;
186
+ page_number: number;
187
+ };
188
+ declare type EMITTED_EVENT = EVENT & {
189
+ block_hash: BLOCK_HASH;
190
+ block_number: BLOCK_NUMBER;
191
+ transaction_hash: TXN_HASH;
192
+ };
193
+ declare type SYNC_STATUS = {
194
+ starting_block_hash: BLOCK_HASH;
195
+ starting_block_num: NUM_AS_HEX;
196
+ current_block_hash: BLOCK_HASH;
197
+ current_block_num: NUM_AS_HEX;
198
+ highest_block_hash: BLOCK_HASH;
199
+ highest_block_num: NUM_AS_HEX;
200
+ };
201
+ declare type FEE_ESTIMATE = {
202
+ gas_consumed: NUM_AS_HEX;
203
+ gas_price: NUM_AS_HEX;
204
+ overall_fee: NUM_AS_HEX;
205
+ };
206
+ declare enum CALL_TYPE {
207
+ 'DELEGATE' = 0,
208
+ 'CALL' = 1
209
+ }
210
+ declare enum ENTRY_POINT_TYPE {
211
+ 'EXTERNAL' = 0,
212
+ 'L1_HANDLER' = 1,
213
+ 'CONSTRUCTOR' = 2
214
+ }
215
+ declare type FUNCTION_INVOCATION = FUNCTION_CALL & {
216
+ caller_address: FELT;
217
+ code_address: FELT;
218
+ entry_point_type: ENTRY_POINT_TYPE;
219
+ call_type: CALL_TYPE;
220
+ result: FELT;
221
+ calls: FUNCTION_INVOCATION;
222
+ events: EVENT;
223
+ messages: MSG_TO_L1;
224
+ };
225
+ declare type TRACE_ROOT = {
226
+ nonce: FELT;
227
+ signature: FELT;
228
+ function_invocation: FUNCTION_INVOCATION;
229
+ };
143
230
  export declare namespace OPENRPC {
144
- type GetBlockWithTxHashesResponse = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
145
- type GetBlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
146
- type GetStorageAtResponse = FELT;
147
- type GetTransactionByHashResponse = TXN;
148
- type GetTransactionByBlockIdAndIndex = TXN;
149
- type GetClassResponse = CONTRACT_CLASS;
231
+ type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
232
+ type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
233
+ type StateUpdate = STATE_UPDATE;
234
+ type Storage = FELT;
235
+ type Transaction = TXN;
236
+ type TransactionReceipt = TXN_RECEIPT;
237
+ type ContractClass = CONTRACT_CLASS;
238
+ type CallResponse = Array<FELT>;
239
+ type EstimatedFee = FEE_ESTIMATE;
240
+ type BlockNumber = BLOCK_NUMBER;
241
+ type BlockHashAndNumber = {
242
+ block_hash: BLOCK_HASH;
243
+ block_number: BLOCK_NUMBER;
244
+ };
245
+ type ChainId = CHAIN_ID;
246
+ type PendingTransactions = Array<TXN>;
247
+ type ProtocolVersion = PROTOCOL_VERSION;
248
+ type SyncingStatus = false | SYNC_STATUS;
249
+ type Events = {
250
+ events: Array<EMITTED_EVENT>;
251
+ page_number: number;
252
+ is_last_page: boolean;
253
+ };
254
+ type Nonce = FELT;
255
+ type Trace = TRACE_ROOT;
256
+ type Traces = Array<{
257
+ transaction_hash: FELT;
258
+ trace_root: TRACE_ROOT;
259
+ }>;
260
+ type TransactionHash = TXN_HASH;
261
+ type BlockHash = BLOCK_HASH;
262
+ type EventFilter = EVENT_FILTER;
263
+ type InvokedTransaction = {
264
+ transaction_hash: TXN_HASH;
265
+ };
266
+ type DeclaredTransaction = {
267
+ transaction_hash: TXN_HASH;
268
+ class_hash: FELT;
269
+ };
270
+ type DeployedTransaction = {
271
+ transaction_hash: TXN_HASH;
272
+ contract_address: FELT;
273
+ };
274
+ type Methods = {
275
+ starknet_getBlockWithTxHashes: {
276
+ params: {
277
+ block_id: BLOCK_ID;
278
+ };
279
+ result: BlockWithTxHashes;
280
+ errors: Errors.INVALID_BLOCK_ID;
281
+ };
282
+ starknet_getBlockWithTxs: {
283
+ params: {
284
+ block_id: BLOCK_ID;
285
+ };
286
+ result: BlockWithTxs;
287
+ errors: Errors.INVALID_BLOCK_ID;
288
+ };
289
+ starknet_getStateUpdate: {
290
+ params: {
291
+ block_id: BLOCK_ID;
292
+ };
293
+ result: StateUpdate;
294
+ errors: Errors.INVALID_BLOCK_ID;
295
+ };
296
+ starknet_getStorageAt: {
297
+ params: {
298
+ contract_address: ADDRESS;
299
+ key: STORAGE_KEY;
300
+ block_id: BLOCK_ID;
301
+ };
302
+ result: Storage;
303
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_BLOCK_ID;
304
+ };
305
+ starknet_getTransactionByHash: {
306
+ params: {
307
+ transaction_hash: TXN_HASH;
308
+ };
309
+ result: Transaction;
310
+ errors: Errors.INVALID_TXN_HASH;
311
+ };
312
+ starknet_getTransactionByBlockIdAndIndex: {
313
+ params: {
314
+ block_id: BLOCK_ID;
315
+ index: number;
316
+ };
317
+ result: Transaction;
318
+ errors: Errors.INVALID_BLOCK_ID | Errors.INVALID_TXN_INDEX;
319
+ };
320
+ starknet_getTransactionReceipt: {
321
+ params: {
322
+ transaction_hash: TXN_HASH;
323
+ };
324
+ result: TransactionReceipt;
325
+ errors: Errors.INVALID_TXN_HASH;
326
+ };
327
+ starknet_getClass: {
328
+ params: {
329
+ class_hash: FELT;
330
+ };
331
+ result: ContractClass;
332
+ errors: Errors.INVALID_CONTRACT_CLASS_HASH;
333
+ };
334
+ starknet_getClassHashAt: {
335
+ params: {
336
+ block_id: BLOCK_ID;
337
+ contract_address: ADDRESS;
338
+ };
339
+ result: FELT;
340
+ errors: Errors.INVALID_BLOCK_ID | Errors.CONTRACT_NOT_FOUND;
341
+ };
342
+ starknet_getClassAt: {
343
+ params: {
344
+ block_id: BLOCK_ID;
345
+ contract_address: ADDRESS;
346
+ };
347
+ result: ContractClass;
348
+ errors: Errors.INVALID_BLOCK_ID | Errors.CONTRACT_NOT_FOUND;
349
+ };
350
+ starknet_getBlockTransactionCount: {
351
+ params: {
352
+ block_id: BLOCK_ID;
353
+ };
354
+ result: number;
355
+ errors: Errors.INVALID_BLOCK_ID;
356
+ };
357
+ starknet_call: {
358
+ params: {
359
+ request: FUNCTION_CALL;
360
+ block_id: BLOCK_ID;
361
+ };
362
+ result: Array<FELT>;
363
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_MESSAGE_SELECTOR | Errors.INVALID_CALL_DATA | Errors.CONTRACT_ERROR | Errors.INVALID_BLOCK_ID;
364
+ };
365
+ starknet_estimateFee: {
366
+ params: {
367
+ request: INVOKE_TXN;
368
+ block_id: BLOCK_ID;
369
+ };
370
+ result: FEE_ESTIMATE;
371
+ errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_MESSAGE_SELECTOR | Errors.INVALID_CALL_DATA | Errors.CONTRACT_ERROR | Errors.INVALID_BLOCK_ID;
372
+ };
373
+ starknet_blockNumber: {
374
+ result: BLOCK_NUMBER;
375
+ errors: Errors.NO_BLOCKS;
376
+ };
377
+ starknet_blockHashAndNumber: {
378
+ result: BLOCK_HASH & BLOCK_NUMBER;
379
+ errors: Errors.NO_BLOCKS;
380
+ };
381
+ starknet_chainId: {
382
+ result: CHAIN_ID;
383
+ };
384
+ starknet_pendingTransactions: {
385
+ result: PendingTransactions;
386
+ };
387
+ starknet_syncing: {
388
+ result: SyncingStatus;
389
+ };
390
+ starknet_getEvents: {
391
+ params: {
392
+ filter: EVENT_FILTER & RESULT_PAGE_REQUEST;
393
+ };
394
+ result: {
395
+ events: EMITTED_EVENT;
396
+ page_number: number;
397
+ is_last_page: boolean;
398
+ };
399
+ errors: Errors.PAGE_SIZE_TOO_BIG;
400
+ };
401
+ starknet_getNonce: {
402
+ params: {
403
+ contract_address: ADDRESS;
404
+ };
405
+ result: FELT;
406
+ errors: Errors.CONTRACT_NOT_FOUND;
407
+ };
408
+ starknet_addInvokeTransaction: {
409
+ params: {
410
+ function_invocation: FUNCTION_CALL;
411
+ signature: SIGNATURE;
412
+ max_fee: NUM_AS_HEX;
413
+ version: NUM_AS_HEX;
414
+ };
415
+ result: InvokedTransaction;
416
+ };
417
+ starknet_addDeclareTransaction: {
418
+ params: {
419
+ contract_class: CONTRACT_CLASS;
420
+ version: NUM_AS_HEX;
421
+ };
422
+ result: DeclaredTransaction;
423
+ errors: Errors.INVALID_CONTRACT_CLASS;
424
+ };
425
+ starknet_addDeployTransaction: {
426
+ params: {
427
+ contract_address_salt: FELT;
428
+ constructor_calldata: FELT;
429
+ contract_definition: CONTRACT_CLASS;
430
+ };
431
+ result: DeployedTransaction;
432
+ errors: Errors.INVALID_CONTRACT_CLASS;
433
+ };
434
+ starknet_traceTransaction: {
435
+ params: {
436
+ transaction_hash: TXN_HASH;
437
+ };
438
+ result: Trace;
439
+ errors: Errors.INVALID_TXN_HASH | Errors.NO_TRACE_AVAILABLE | Errors.INVALID_BLOCK_HASH | Errors.INVALID_TXN_HASH;
440
+ };
441
+ starknet_traceBlockTransactions: {
442
+ params: {
443
+ block_hash: BLOCK_HASH;
444
+ };
445
+ result: Traces;
446
+ errors: Errors.INVALID_BLOCK_HASH;
447
+ };
448
+ };
449
+ }
450
+ export declare namespace Errors {
451
+ interface FAILED_TO_RECEIVE_TXN {
452
+ code: 1;
453
+ message: 'Failed to write transaction';
454
+ }
455
+ interface CONTRACT_NOT_FOUND {
456
+ code: 20;
457
+ message: 'Contract not found';
458
+ }
459
+ interface INVALID_MESSAGE_SELECTOR {
460
+ code: 21;
461
+ message: 'Invalid message selector';
462
+ }
463
+ interface INVALID_CALL_DATA {
464
+ code: 22;
465
+ message: 'Invalid call data';
466
+ }
467
+ interface INVALID_BLOCK_ID {
468
+ code: 24;
469
+ message: 'Invalid block id';
470
+ }
471
+ interface INVALID_TXN_INDEX {
472
+ code: 27;
473
+ message: 'Invalid transaction index in a block';
474
+ }
475
+ interface INVALID_CONTRACT_CLASS_HASH {
476
+ code: 28;
477
+ message: 'The supplied contract class hash is invalid or unknown';
478
+ }
479
+ interface PAGE_SIZE_TOO_BIG {
480
+ code: 31;
481
+ message: 'Requested page size is too big';
482
+ }
483
+ interface NO_BLOCKS {
484
+ code: 32;
485
+ message: 'There are no blocks';
486
+ }
487
+ interface CONTRACT_ERROR {
488
+ code: 40;
489
+ message: 'Contract error';
490
+ }
491
+ interface INVALID_CONTRACT_CLASS {
492
+ code: 50;
493
+ message: 'Invalid contract class';
494
+ }
495
+ interface NO_TRACE_AVAILABLE {
496
+ code: 10;
497
+ message: 'No trace available for transaction';
498
+ data: {
499
+ status: 'RECEIVED' | 'REJECTED';
500
+ };
501
+ }
502
+ interface INVALID_BLOCK_HASH {
503
+ code: 24;
504
+ message: 'Invalid block hash';
505
+ }
506
+ interface INVALID_TXN_HASH {
507
+ code: 25;
508
+ message: 'Invalid transaction hash';
509
+ }
150
510
  }
151
511
  export {};
@@ -1,9 +1,27 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Starknet RPC version 0.1.0
4
- * starknet_api_openrpc version 0.31.0
5
4
  *
6
- * TypeScript Representation of OpenRpc protocol types | results
7
- * errors are not implemented here only results
5
+ * StarkNet Node API 0.31.0
6
+ * StarkNet Node Write API 0.3.0
7
+ * StarkNet Trace API 0.3.0
8
+ *
9
+ * TypeScript Representation of OpenRpc protocol types
8
10
  */
9
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ var BLOCK_TAG;
13
+ (function (BLOCK_TAG) {
14
+ BLOCK_TAG[BLOCK_TAG["latest"] = 0] = "latest";
15
+ BLOCK_TAG[BLOCK_TAG["pending"] = 1] = "pending";
16
+ })(BLOCK_TAG || (BLOCK_TAG = {}));
17
+ var CALL_TYPE;
18
+ (function (CALL_TYPE) {
19
+ CALL_TYPE[CALL_TYPE["DELEGATE"] = 0] = "DELEGATE";
20
+ CALL_TYPE[CALL_TYPE["CALL"] = 1] = "CALL";
21
+ })(CALL_TYPE || (CALL_TYPE = {}));
22
+ var ENTRY_POINT_TYPE;
23
+ (function (ENTRY_POINT_TYPE) {
24
+ ENTRY_POINT_TYPE[ENTRY_POINT_TYPE["EXTERNAL"] = 0] = "EXTERNAL";
25
+ ENTRY_POINT_TYPE[ENTRY_POINT_TYPE["L1_HANDLER"] = 1] = "L1_HANDLER";
26
+ ENTRY_POINT_TYPE[ENTRY_POINT_TYPE["CONSTRUCTOR"] = 2] = "CONSTRUCTOR";
27
+ })(ENTRY_POINT_TYPE || (ENTRY_POINT_TYPE = {}));