starknet 4.6.0 → 4.8.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 (94) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/CONTRIBUTING.md +2 -2
  3. package/__mocks__/l1l2_compiled.json +10107 -0
  4. package/__tests__/account.test.ts +2 -5
  5. package/__tests__/contract.test.ts +0 -1
  6. package/__tests__/defaultProvider.test.ts +5 -3
  7. package/__tests__/fixtures.ts +2 -0
  8. package/__tests__/sequencerProvider.test.ts +50 -9
  9. package/__tests__/utils/ellipticalCurve.test.ts +7 -8
  10. package/__tests__/utils/merkle.test.ts +15 -0
  11. package/account/default.d.ts +3 -2
  12. package/account/default.js +22 -29
  13. package/account/interface.d.ts +2 -1
  14. package/contract/contractFactory.d.ts +1 -2
  15. package/contract/default.d.ts +2 -2
  16. package/contract/default.js +7 -3
  17. package/dist/account/default.d.ts +3 -2
  18. package/dist/account/default.js +22 -29
  19. package/dist/account/interface.d.ts +2 -1
  20. package/dist/contract/contractFactory.d.ts +1 -2
  21. package/dist/contract/default.d.ts +2 -2
  22. package/dist/contract/default.js +7 -3
  23. package/dist/provider/default.d.ts +4 -3
  24. package/dist/provider/default.js +9 -3
  25. package/dist/provider/interface.d.ts +10 -3
  26. package/dist/provider/rpc.d.ts +12 -10
  27. package/dist/provider/rpc.js +80 -72
  28. package/dist/provider/sequencer.d.ts +6 -4
  29. package/dist/provider/sequencer.js +36 -7
  30. package/dist/signer/default.d.ts +2 -2
  31. package/dist/signer/default.js +2 -2
  32. package/dist/signer/interface.d.ts +2 -2
  33. package/dist/types/api/openrpc.d.ts +17 -27
  34. package/dist/types/api/rpc.d.ts +4 -128
  35. package/dist/types/api/sequencer.d.ts +36 -20
  36. package/dist/types/lib.d.ts +10 -4
  37. package/dist/types/provider.d.ts +7 -2
  38. package/dist/utils/hash.d.ts +8 -2
  39. package/dist/utils/hash.js +20 -5
  40. package/dist/utils/merkle.js +2 -1
  41. package/dist/utils/number.d.ts +5 -0
  42. package/dist/utils/number.js +29 -1
  43. package/dist/utils/responseParser/rpc.d.ts +2 -5
  44. package/dist/utils/responseParser/rpc.js +2 -38
  45. package/dist/utils/responseParser/sequencer.js +7 -19
  46. package/package.json +1 -1
  47. package/provider/default.d.ts +4 -3
  48. package/provider/default.js +9 -3
  49. package/provider/interface.d.ts +10 -3
  50. package/provider/rpc.d.ts +12 -10
  51. package/provider/rpc.js +80 -72
  52. package/provider/sequencer.d.ts +6 -4
  53. package/provider/sequencer.js +36 -7
  54. package/signer/default.d.ts +2 -2
  55. package/signer/default.js +2 -2
  56. package/signer/interface.d.ts +2 -2
  57. package/src/account/default.ts +21 -20
  58. package/src/account/interface.ts +2 -1
  59. package/src/contract/contractFactory.ts +1 -2
  60. package/src/contract/default.ts +16 -8
  61. package/src/provider/default.ts +12 -5
  62. package/src/provider/interface.ts +15 -4
  63. package/src/provider/rpc.ts +89 -73
  64. package/src/provider/sequencer.ts +47 -11
  65. package/src/signer/default.ts +8 -8
  66. package/src/signer/interface.ts +2 -2
  67. package/src/types/api/openrpc.ts +20 -25
  68. package/src/types/api/rpc.ts +4 -128
  69. package/src/types/api/sequencer.ts +39 -20
  70. package/src/types/lib.ts +7 -5
  71. package/src/types/provider.ts +7 -2
  72. package/src/utils/hash.ts +32 -8
  73. package/src/utils/merkle.ts +2 -1
  74. package/src/utils/number.ts +27 -0
  75. package/src/utils/responseParser/rpc.ts +7 -25
  76. package/src/utils/responseParser/sequencer.ts +12 -7
  77. package/types/api/openrpc.d.ts +17 -27
  78. package/types/api/rpc.d.ts +4 -128
  79. package/types/api/sequencer.d.ts +36 -20
  80. package/types/lib.d.ts +10 -4
  81. package/types/provider.d.ts +7 -2
  82. package/utils/hash.d.ts +8 -2
  83. package/utils/hash.js +20 -5
  84. package/utils/merkle.js +2 -1
  85. package/utils/number.d.ts +5 -0
  86. package/utils/number.js +29 -1
  87. package/utils/responseParser/rpc.d.ts +2 -5
  88. package/utils/responseParser/rpc.js +2 -38
  89. package/utils/responseParser/sequencer.js +7 -19
  90. package/www/docs/API/account.md +3 -3
  91. package/www/docs/API/contract.md +2 -2
  92. package/www/docs/API/provider.md +20 -6
  93. package/www/docs/API/utils.md +2 -2
  94. package/www/guides/account.md +1 -1
@@ -123,7 +123,12 @@ var SequencerProvider = /** @class */ (function () {
123
123
  return gatewayUrlEndpoints.includes(endpoint) ? this.gatewayUrl : this.feederGatewayUrl;
124
124
  };
125
125
  SequencerProvider.prototype.getFetchMethod = function (endpoint) {
126
- var postMethodEndpoints = ['add_transaction', 'call_contract', 'estimate_fee'];
126
+ var postMethodEndpoints = [
127
+ 'add_transaction',
128
+ 'call_contract',
129
+ 'estimate_fee',
130
+ 'estimate_message_fee',
131
+ ];
127
132
  return postMethodEndpoints.includes(endpoint) ? 'POST' : 'GET';
128
133
  };
129
134
  SequencerProvider.prototype.getQueryString = function (query) {
@@ -257,6 +262,14 @@ var SequencerProvider = /** @class */ (function () {
257
262
  });
258
263
  });
259
264
  };
265
+ SequencerProvider.prototype.getNonce = function (contractAddress, blockIdentifier) {
266
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
267
+ return __awaiter(this, void 0, void 0, function () {
268
+ return __generator(this, function (_a) {
269
+ return [2 /*return*/, this.fetchEndpoint('get_nonce', { contractAddress: contractAddress, blockIdentifier: blockIdentifier })];
270
+ });
271
+ });
272
+ };
260
273
  SequencerProvider.prototype.getStorageAt = function (contractAddress, key, blockIdentifier) {
261
274
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
262
275
  return __awaiter(this, void 0, void 0, function () {
@@ -307,11 +320,11 @@ var SequencerProvider = /** @class */ (function () {
307
320
  return [2 /*return*/, this.fetchEndpoint('add_transaction', undefined, {
308
321
  type: 'INVOKE_FUNCTION',
309
322
  contract_address: functionInvocation.contractAddress,
310
- entry_point_selector: (0, hash_1.getSelectorFromName)(functionInvocation.entrypoint),
311
323
  calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)((_a = functionInvocation.calldata) !== null && _a !== void 0 ? _a : []),
312
324
  signature: (0, number_1.bigNumberishArrayToDecimalStringArray)((_b = functionInvocation.signature) !== null && _b !== void 0 ? _b : []),
325
+ nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
313
326
  max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
314
- version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
327
+ version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 1)),
315
328
  }).then(this.responseParser.parseInvokeFunctionResponse)];
316
329
  });
317
330
  });
@@ -347,18 +360,18 @@ var SequencerProvider = /** @class */ (function () {
347
360
  });
348
361
  });
349
362
  };
350
- SequencerProvider.prototype.getEstimateFee = function (invocation, blockIdentifier, invocationDetails) {
363
+ SequencerProvider.prototype.getEstimateFee = function (invocation, invocationDetails, blockIdentifier) {
351
364
  var _a;
352
365
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
353
- if (invocationDetails === void 0) { invocationDetails = {}; }
354
366
  return __awaiter(this, void 0, void 0, function () {
355
367
  return __generator(this, function (_b) {
356
368
  return [2 /*return*/, this.fetchEndpoint('estimate_fee', { blockIdentifier: blockIdentifier }, {
369
+ type: 'INVOKE_FUNCTION',
357
370
  contract_address: invocation.contractAddress,
358
- entry_point_selector: (0, hash_1.getSelectorFromName)(invocation.entrypoint),
359
371
  calldata: (_a = invocation.calldata) !== null && _a !== void 0 ? _a : [],
360
372
  signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(invocation.signature || []),
361
- version: (0, number_1.toHex)((0, number_1.toBN)((invocationDetails === null || invocationDetails === void 0 ? void 0 : invocationDetails.version) || 0)),
373
+ version: (0, number_1.toHex)((0, number_1.toBN)((invocationDetails === null || invocationDetails === void 0 ? void 0 : invocationDetails.version) || 1)),
374
+ nonce: (0, number_1.toHex)((0, number_1.toBN)(invocationDetails.nonce)),
362
375
  }).then(this.responseParser.parseFeeEstimateResponse)];
363
376
  });
364
377
  });
@@ -455,6 +468,22 @@ var SequencerProvider = /** @class */ (function () {
455
468
  });
456
469
  });
457
470
  };
471
+ SequencerProvider.prototype.estimateMessageFee = function (_a, blockIdentifier) {
472
+ var from_address = _a.from_address, to_address = _a.to_address, entry_point_selector = _a.entry_point_selector, payload = _a.payload;
473
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
474
+ return __awaiter(this, void 0, void 0, function () {
475
+ var validCallL1Handler;
476
+ return __generator(this, function (_b) {
477
+ validCallL1Handler = {
478
+ from_address: (0, number_1.getDecimalString)(from_address),
479
+ to_address: (0, number_1.getHexString)(to_address),
480
+ entry_point_selector: (0, hash_1.getSelector)(entry_point_selector),
481
+ payload: (0, number_1.getHexStringArray)(payload),
482
+ };
483
+ return [2 /*return*/, this.fetchEndpoint('estimate_message_fee', { blockIdentifier: blockIdentifier }, validCallL1Handler)];
484
+ });
485
+ });
486
+ };
458
487
  return SequencerProvider;
459
488
  }());
460
489
  exports.SequencerProvider = SequencerProvider;
@@ -1,10 +1,10 @@
1
- import { Abi, Invocation, InvocationsSignerDetails, KeyPair, Signature } from '../types';
1
+ import { Abi, Call, InvocationsSignerDetails, KeyPair, Signature } from '../types';
2
2
  import { TypedData } from '../utils/typedData';
3
3
  import { SignerInterface } from './interface';
4
4
  export declare class Signer implements SignerInterface {
5
5
  protected keyPair: KeyPair;
6
6
  constructor(keyPair?: KeyPair);
7
7
  getPubKey(): Promise<string>;
8
- signTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
8
+ signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
9
9
  signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
10
10
  }
@@ -60,8 +60,8 @@ var Signer = /** @class */ (function () {
60
60
  if (abis && abis.length !== transactions.length) {
61
61
  throw new Error('ABI must be provided for each transaction or no transaction');
62
62
  }
63
- calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, transactionsDetail.nonce);
64
- msgHash = (0, hash_1.calculcateTransactionHash)(transactionsDetail.walletAddress, transactionsDetail.version, (0, hash_1.getSelectorFromName)('__execute__'), calldata, transactionsDetail.maxFee, transactionsDetail.chainId);
63
+ calldata = (0, transaction_1.fromCallsToExecuteCalldata)(transactions);
64
+ msgHash = (0, hash_1.calculateTransactionHash)(transactionsDetail.walletAddress, transactionsDetail.version, calldata, transactionsDetail.maxFee, transactionsDetail.chainId, transactionsDetail.nonce);
65
65
  return [2 /*return*/, (0, ellipticCurve_1.sign)(this.keyPair, msgHash)];
66
66
  });
67
67
  });
@@ -1,4 +1,4 @@
1
- import { Abi, Invocation, InvocationsSignerDetails, Signature } from '../types';
1
+ import { Abi, Call, InvocationsSignerDetails, Signature } from '../types';
2
2
  import { TypedData } from '../utils/typedData';
3
3
  export declare abstract class SignerInterface {
4
4
  /**
@@ -29,5 +29,5 @@ export declare abstract class SignerInterface {
29
29
  *
30
30
  * @returns signature
31
31
  */
32
- abstract signTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
32
+ abstract signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
33
33
  }
@@ -7,26 +7,14 @@
7
7
  *
8
8
  * TypeScript Representation of OpenRpc protocol types
9
9
  */
10
- /**
11
- * "type": "string",
12
- * "title": "Field element",
13
- * "$comment": "A field element, represented as a string of hex digits",
14
- * "description": "A field element. Represented as up to 63 hex digits and leading 4 bits zeroed.",
15
- * "pattern": "^0x0[a-fA-F0-9]{1,63}$"
16
- */
17
10
  export declare type FELT = string;
18
11
  export declare type ADDRESS = FELT;
19
- /**
20
- * "title": "An integer number in hex format (0x...)",
21
- * "pattern": "^0x[a-fA-F0-9]+$"
22
- */
23
12
  declare type NUM_AS_HEX = string;
24
13
  declare type SIGNATURE = Array<FELT>;
25
14
  declare type ETH_ADDRESS = string;
26
15
  declare type BLOCK_NUMBER = number;
27
16
  declare type BLOCK_HASH = FELT;
28
17
  declare type TXN_HASH = FELT;
29
- declare type CHAIN_ID = string;
30
18
  declare type PROTOCOL_VERSION = string;
31
19
  declare type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
32
20
  declare type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
@@ -96,17 +84,17 @@ declare type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
96
84
  parent_hash: BLOCK_HASH;
97
85
  };
98
86
  declare type COMMON_TXN_PROPERTIES = {
99
- transaction_hash: TXN_HASH;
87
+ transaction_hash?: TXN_HASH;
100
88
  max_fee: FELT;
101
89
  version: NUM_AS_HEX;
102
90
  signature: SIGNATURE;
103
- nonce: FELT;
104
- type: TXN_TYPE;
91
+ nonce?: FELT;
92
+ type?: TXN_TYPE;
105
93
  };
106
94
  declare type FUNCTION_CALL = {
107
- contract_address: ADDRESS;
108
- entry_point_selector: FELT;
109
- calldata: Array<FELT>;
95
+ contract_address?: ADDRESS;
96
+ entry_point_selector?: FELT;
97
+ calldata?: Array<FELT>;
110
98
  };
111
99
  declare type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
112
100
  declare type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
@@ -228,6 +216,7 @@ declare type TRACE_ROOT = {
228
216
  function_invocation: FUNCTION_INVOCATION;
229
217
  };
230
218
  export declare namespace OPENRPC {
219
+ type Nonce = FELT;
231
220
  type BlockWithTxHashes = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
232
221
  type BlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
233
222
  type StateUpdate = STATE_UPDATE;
@@ -242,7 +231,7 @@ export declare namespace OPENRPC {
242
231
  block_hash: BLOCK_HASH;
243
232
  block_number: BLOCK_NUMBER;
244
233
  };
245
- type ChainId = CHAIN_ID;
234
+ type CHAIN_ID = string;
246
235
  type PendingTransactions = Array<TXN>;
247
236
  type ProtocolVersion = PROTOCOL_VERSION;
248
237
  type SyncingStatus = false | SYNC_STATUS;
@@ -251,7 +240,6 @@ export declare namespace OPENRPC {
251
240
  page_number: number;
252
241
  is_last_page: boolean;
253
242
  };
254
- type Nonce = FELT;
255
243
  type Trace = TRACE_ROOT;
256
244
  type Traces = Array<{
257
245
  transaction_hash: FELT;
@@ -259,7 +247,7 @@ export declare namespace OPENRPC {
259
247
  }>;
260
248
  type TransactionHash = TXN_HASH;
261
249
  type BlockHash = BLOCK_HASH;
262
- type EventFilter = EVENT_FILTER;
250
+ type EventFilter = EVENT_FILTER & RESULT_PAGE_REQUEST;
263
251
  type InvokedTransaction = {
264
252
  transaction_hash: TXN_HASH;
265
253
  };
@@ -371,36 +359,38 @@ export declare namespace OPENRPC {
371
359
  errors: Errors.CONTRACT_NOT_FOUND | Errors.INVALID_MESSAGE_SELECTOR | Errors.INVALID_CALL_DATA | Errors.CONTRACT_ERROR | Errors.INVALID_BLOCK_ID;
372
360
  };
373
361
  starknet_blockNumber: {
362
+ params: {};
374
363
  result: BLOCK_NUMBER;
375
364
  errors: Errors.NO_BLOCKS;
376
365
  };
377
366
  starknet_blockHashAndNumber: {
367
+ params: {};
378
368
  result: BLOCK_HASH & BLOCK_NUMBER;
379
369
  errors: Errors.NO_BLOCKS;
380
370
  };
381
371
  starknet_chainId: {
372
+ params: {};
382
373
  result: CHAIN_ID;
383
374
  };
384
375
  starknet_pendingTransactions: {
376
+ params: {};
385
377
  result: PendingTransactions;
386
378
  };
387
379
  starknet_syncing: {
380
+ params: {};
388
381
  result: SyncingStatus;
389
382
  };
390
383
  starknet_getEvents: {
391
384
  params: {
392
385
  filter: EVENT_FILTER & RESULT_PAGE_REQUEST;
393
386
  };
394
- result: {
395
- events: EMITTED_EVENT;
396
- page_number: number;
397
- is_last_page: boolean;
398
- };
387
+ result: Events;
399
388
  errors: Errors.PAGE_SIZE_TOO_BIG;
400
389
  };
401
390
  starknet_getNonce: {
402
391
  params: {
403
392
  contract_address: ADDRESS;
393
+ block_id: BLOCK_ID;
404
394
  };
405
395
  result: FELT;
406
396
  errors: Errors.CONTRACT_NOT_FOUND;
@@ -425,7 +415,7 @@ export declare namespace OPENRPC {
425
415
  starknet_addDeployTransaction: {
426
416
  params: {
427
417
  contract_address_salt: FELT;
428
- constructor_calldata: FELT;
418
+ constructor_calldata: Array<FELT>;
429
419
  contract_definition: CONTRACT_CLASS;
430
420
  };
431
421
  result: DeployedTransaction;
@@ -9,9 +9,11 @@ export declare namespace RPC {
9
9
  message: string;
10
10
  };
11
11
  };
12
- type ChainId = OPENRPC.ChainId;
12
+ type ChainId = OPENRPC.CHAIN_ID;
13
+ type CallResponse = OPENRPC.CallResponse;
13
14
  type ContractAddress = ADDRESS;
14
15
  type Felt = FELT;
16
+ type Nonce = OPENRPC.Nonce;
15
17
  type ContractClass = OPENRPC.ContractClass;
16
18
  type StateUpdate = OPENRPC.StateUpdate;
17
19
  type Transaction = OPENRPC.Transaction;
@@ -37,131 +39,5 @@ export declare namespace RPC {
37
39
  type InvokedTransaction = OPENRPC.InvokedTransaction;
38
40
  type DeclaredTransaction = OPENRPC.DeclaredTransaction;
39
41
  type DeployedTransaction = OPENRPC.DeployedTransaction;
40
- type Methods = {
41
- starknet_pendingTransactions: {
42
- QUERY: never;
43
- REQUEST: any[];
44
- RESPONSE: PendingTransactions;
45
- };
46
- starknet_blockHashAndNumber: {
47
- QUERY: never;
48
- REQUEST: any[];
49
- RESPONSE: BlockHashAndNumber;
50
- };
51
- starknet_getClassHashAt: {
52
- QUERY: never;
53
- REQUEST: any[];
54
- RESPONSE: Felt;
55
- };
56
- starknet_getStateUpdate: {
57
- QUERY: never;
58
- REQUEST: any[];
59
- RESPONSE: OPENRPC.StateUpdate;
60
- };
61
- starknet_getClass: {
62
- QUERY: never;
63
- REQUEST: any[];
64
- RESPONSE: OPENRPC.ContractClass;
65
- };
66
- starknet_getBlockWithTxHashes: {
67
- QUERY: never;
68
- REQUEST: any[];
69
- RESPONSE: GetBlockWithTxHashesResponse;
70
- };
71
- starknet_getBlockWithTxs: {
72
- QUERY: never;
73
- REQUEST: any[];
74
- RESPONSE: GetBlockWithTxs;
75
- };
76
- starknet_getNonce: {
77
- QUERY: never;
78
- REQUEST: any[];
79
- RESPONSE: OPENRPC.Nonce;
80
- };
81
- starknet_getStorageAt: {
82
- QUERY: never;
83
- REQUEST: any[];
84
- RESPONSE: GetStorageAtResponse;
85
- };
86
- starknet_getTransactionByHash: {
87
- QUERY: never;
88
- REQUEST: any[];
89
- RESPONSE: GetTransactionByHashResponse;
90
- };
91
- starknet_getTransactionByBlockIdAndIndex: {
92
- QUERY: never;
93
- REQUEST: any[];
94
- RESPONSE: GetTransactionByBlockIdAndIndex;
95
- };
96
- starknet_getTransactionReceipt: {
97
- QUERY: never;
98
- REQUEST: any[];
99
- RESPONSE: TransactionReceipt;
100
- };
101
- starknet_getBlockTransactionCount: {
102
- QUERY: never;
103
- REQUEST: any[];
104
- RESPONSE: GetTransactionCountResponse;
105
- };
106
- starknet_call: {
107
- QUERY: never;
108
- REQUEST: any[];
109
- RESPONSE: string[];
110
- };
111
- starknet_estimateFee: {
112
- QUERY: never;
113
- REQUEST: any[];
114
- RESPONSE: OPENRPC.EstimatedFee;
115
- };
116
- starknet_blockNumber: {
117
- QUERY: never;
118
- REQUEST: any[];
119
- RESPONSE: GetBlockNumberResponse;
120
- };
121
- starknet_chainId: {
122
- QUERY: never;
123
- REQUEST: any[];
124
- RESPONSE: OPENRPC.ChainId;
125
- };
126
- starknet_syncing: {
127
- QUERY: never;
128
- REQUEST: any[];
129
- RESPONSE: GetSyncingStatsResponse;
130
- };
131
- starknet_getEvents: {
132
- QUERY: never;
133
- REQUEST: any[];
134
- RESPONSE: GetEventsResponse;
135
- };
136
- starknet_addInvokeTransaction: {
137
- QUERY: never;
138
- REQUEST: any[];
139
- RESPONSE: OPENRPC.InvokedTransaction;
140
- };
141
- starknet_addDeployTransaction: {
142
- QUERY: never;
143
- REQUEST: any[];
144
- RESPONSE: OPENRPC.DeployedTransaction;
145
- };
146
- starknet_addDeclareTransaction: {
147
- QUERY: never;
148
- REQUEST: any[];
149
- RESPONSE: OPENRPC.DeclaredTransaction;
150
- };
151
- starknet_getClassAt: {
152
- QUERY: never;
153
- REQUEST: any[];
154
- RESPONSE: any;
155
- };
156
- starknet_traceTransaction: {
157
- QUERY: never;
158
- REQUEST: any[];
159
- RESPONSE: any;
160
- };
161
- starknet_traceBlockTransactions: {
162
- QUERY: never;
163
- REQUEST: any[];
164
- RESPONSE: any;
165
- };
166
- };
42
+ type Methods = OPENRPC.Methods;
167
43
  }
@@ -15,15 +15,17 @@ export declare type GetContractAddressesResponse = {
15
15
  Starknet: string;
16
16
  GpsStatementVerifier: string;
17
17
  };
18
- export declare type InvokeFunctionTrace = {
18
+ export declare type FunctionInvocation = {
19
19
  caller_address: string;
20
20
  contract_address: string;
21
- code_address: string;
22
- selector: string;
23
21
  calldata: RawCalldata;
22
+ call_type?: string;
23
+ class_hash?: string;
24
+ selector?: string;
25
+ entry_point_type?: EntryPointType;
24
26
  result: Array<any>;
25
27
  execution_resources: ExecutionResources;
26
- internal_call: Array<InvokeFunctionTrace>;
28
+ internal_calls: Array<FunctionInvocation>;
27
29
  events: Array<any>;
28
30
  messages: Array<any>;
29
31
  };
@@ -40,18 +42,9 @@ export declare type ExecutionResources = {
40
42
  n_memory_holes: number;
41
43
  };
42
44
  export declare type GetTransactionTraceResponse = {
43
- function_invocation: {
44
- caller_address: string;
45
- contract_address: string;
46
- code_address: string;
47
- selector: string;
48
- calldata: RawArgs;
49
- result: Array<any>;
50
- execution_resources: ExecutionResources;
51
- internal_call: Array<any>;
52
- events: Array<any>;
53
- messages: Array<any>;
54
- };
45
+ validate_invocation?: FunctionInvocation;
46
+ function_invocation?: FunctionInvocation;
47
+ fee_transfer_invocation?: FunctionInvocation;
55
48
  signature: Signature;
56
49
  };
57
50
  export declare type RawArgs = {
@@ -60,6 +53,12 @@ export declare type RawArgs = {
60
53
  [k: string]: BigNumberish;
61
54
  };
62
55
  };
56
+ export declare type CallL1Handler = {
57
+ from_address: string;
58
+ to_address: string;
59
+ entry_point_selector: string;
60
+ payload: Array<string>;
61
+ };
63
62
  export declare namespace Sequencer {
64
63
  type DeclareTransaction = {
65
64
  type: 'DECLARE';
@@ -80,9 +79,8 @@ export declare namespace Sequencer {
80
79
  contract_address: string;
81
80
  signature?: Signature;
82
81
  entry_point_type?: EntryPointType;
83
- entry_point_selector: string;
84
82
  calldata?: RawCalldata;
85
- nonce?: BigNumberish;
83
+ nonce: BigNumberish;
86
84
  max_fee?: BigNumberish;
87
85
  version?: BigNumberish;
88
86
  };
@@ -99,6 +97,7 @@ export declare namespace Sequencer {
99
97
  };
100
98
  interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
101
99
  transaction_hash: string;
100
+ entry_point_selector: string;
102
101
  }
103
102
  type TransactionResponse = DeclareTransaction | DeployTransaction | InvokeFunctionTransactionResponse;
104
103
  type SuccessfulTransactionResponse = {
@@ -165,11 +164,15 @@ export declare namespace Sequencer {
165
164
  status: Status;
166
165
  gas_price: string;
167
166
  sequencer_address: string;
167
+ starknet_version: string;
168
+ };
169
+ type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'> & {
170
+ entry_point_selector: string;
168
171
  };
169
- type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'>;
170
172
  type CallContractResponse = {
171
173
  result: string[];
172
174
  };
175
+ type EstimateFeeTransaction = Omit<InvokeFunctionTransaction, 'max_fee' | 'entry_point_type'>;
173
176
  type EstimateFeeResponse = {
174
177
  overall_fee: number;
175
178
  gas_price: number;
@@ -217,6 +220,14 @@ export declare namespace Sequencer {
217
220
  REQUEST: never;
218
221
  RESPONSE: TransactionReceiptResponse;
219
222
  };
223
+ get_nonce: {
224
+ QUERY: {
225
+ contractAddress: string;
226
+ blockIdentifier: BlockIdentifier;
227
+ };
228
+ REQUEST: never;
229
+ RESPONSE: BigNumberish;
230
+ };
220
231
  get_storage_at: {
221
232
  QUERY: {
222
233
  contractAddress: string;
@@ -252,7 +263,7 @@ export declare namespace Sequencer {
252
263
  QUERY: {
253
264
  blockIdentifier: BlockIdentifier;
254
265
  };
255
- REQUEST: CallContractTransaction;
266
+ REQUEST: EstimateFeeTransaction;
256
267
  RESPONSE: EstimateFeeResponse;
257
268
  };
258
269
  get_class_by_hash: {
@@ -285,5 +296,10 @@ export declare namespace Sequencer {
285
296
  REQUEST: never;
286
297
  RESPONSE: any;
287
298
  };
299
+ estimate_message_fee: {
300
+ QUERY: any;
301
+ REQUEST: any;
302
+ RESPONSE: EstimateFeeResponse;
303
+ };
288
304
  };
289
305
  }
@@ -6,24 +6,30 @@ export declare type RawCalldata = BigNumberish[];
6
6
  export declare type DeployContractPayload = {
7
7
  contract: CompiledContract | string;
8
8
  constructorCalldata?: RawCalldata;
9
- addressSalt?: BigNumberish;
9
+ addressSalt?: string;
10
10
  };
11
11
  export declare type DeclareContractPayload = {
12
12
  contract: CompiledContract | string;
13
13
  version?: BigNumberish;
14
14
  };
15
- export declare type Invocation = {
15
+ export declare type CallDetails = {
16
16
  contractAddress: string;
17
- entrypoint: string;
18
17
  calldata?: RawCalldata;
18
+ };
19
+ export declare type Invocation = CallDetails & {
19
20
  signature?: Signature;
20
21
  };
21
- export declare type Call = Omit<Invocation, 'signature'>;
22
+ export declare type Call = CallDetails & {
23
+ entrypoint: string;
24
+ };
22
25
  export declare type InvocationsDetails = {
23
26
  nonce?: BigNumberish;
24
27
  maxFee?: BigNumberish;
25
28
  version?: BigNumberish;
26
29
  };
30
+ export declare type InvocationsDetailsWithNonce = InvocationsDetails & {
31
+ nonce: BigNumberish;
32
+ };
27
33
  export declare type Status = 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
28
34
  export declare type TransactionStatus = 'TRANSACTION_RECEIVED';
29
35
  export declare type Type = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION';
@@ -3,7 +3,8 @@
3
3
  * Intersection (sequencer response ∩ (∪ rpc responses))
4
4
  */
5
5
  import BN from 'bn.js';
6
- import { Abi, CompressedProgram, EntryPointsByType, RawCalldata, Signature, Status } from './lib';
6
+ import { RPC } from './api/rpc';
7
+ import { Abi, CompressedProgram, RawCalldata, Signature, Status } from './lib';
7
8
  export interface GetBlockResponse {
8
9
  timestamp: number;
9
10
  block_hash: string;
@@ -12,6 +13,10 @@ export interface GetBlockResponse {
12
13
  parent_hash: string;
13
14
  status: Status;
14
15
  transactions: Array<string>;
16
+ gas_price?: string;
17
+ sequencer_address?: string;
18
+ starknet_version?: string;
19
+ transaction_receipts?: any;
15
20
  }
16
21
  export interface GetCodeResponse {
17
22
  bytecode: string[];
@@ -35,7 +40,7 @@ export interface ContractEntryPoint {
35
40
  }
36
41
  export interface ContractClass {
37
42
  program: CompressedProgram;
38
- entry_points_by_type: EntryPointsByType;
43
+ entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
39
44
  abi?: Abi;
40
45
  }
41
46
  export interface DeclareTransactionResponse extends CommonTransactionResponse {
@@ -2,7 +2,7 @@ import BN from 'bn.js';
2
2
  import { StarknetChainId, TransactionHashPrefix } from '../constants';
3
3
  import { RawCalldata } from '../types/lib';
4
4
  import { BigNumberish } from './number';
5
- export declare const transactionVersion = 0;
5
+ export declare const transactionVersion = 1;
6
6
  export declare const feeTransactionVersion: BN;
7
7
  export declare function keccakBn(value: BigNumberish): string;
8
8
  /**
@@ -21,9 +21,15 @@ export declare function starknetKeccak(value: string): BN;
21
21
  * @returns hex selector of given abi function name
22
22
  */
23
23
  export declare function getSelectorFromName(funcName: string): string;
24
+ /**
25
+ * Function to get hex selector from function name, decimal string or hex string
26
+ * @param value hex string | decimal string | string
27
+ * @returns Hex selector
28
+ */
29
+ export declare function getSelector(value: string): string;
24
30
  export declare function pedersen(input: [BigNumberish, BigNumberish]): string;
25
31
  export declare function computeHashOnElements(data: BigNumberish[]): string;
26
32
  export declare function calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish, contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, additionalData?: BigNumberish[]): string;
27
33
  export declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: BigNumberish[], version: BigNumberish, chainId: StarknetChainId): string;
28
- export declare function calculcateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId): string;
34
+ export declare function calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
29
35
  export declare function calculateContractAddressFromHash(salt: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, deployerAddress: BigNumberish): string;