starknet 6.1.5 → 6.2.1
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.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +3324 -499
- package/dist/index.global.js +879 -189
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +881 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +879 -189
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53,7 +53,9 @@ __export(src_exports, {
|
|
|
53
53
|
Provider: () => RpcProvider2,
|
|
54
54
|
ProviderInterface: () => ProviderInterface,
|
|
55
55
|
RPC: () => api_exports,
|
|
56
|
-
|
|
56
|
+
RPC06: () => rpc_0_6_exports,
|
|
57
|
+
RPC07: () => rpc_0_7_exports,
|
|
58
|
+
RpcChannel: () => RpcChannel2,
|
|
57
59
|
RpcProvider: () => RpcProvider2,
|
|
58
60
|
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
59
61
|
Signer: () => Signer,
|
|
@@ -120,7 +122,7 @@ __export(constants_exports, {
|
|
|
120
122
|
RPC_NODES: () => RPC_NODES,
|
|
121
123
|
StarknetChainId: () => StarknetChainId,
|
|
122
124
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
123
|
-
TRANSACTION_VERSION: () =>
|
|
125
|
+
TRANSACTION_VERSION: () => ETransactionVersion4,
|
|
124
126
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
125
127
|
UDC: () => UDC,
|
|
126
128
|
ZERO: () => ZERO
|
|
@@ -129,6 +131,30 @@ __export(constants_exports, {
|
|
|
129
131
|
// src/types/api/index.ts
|
|
130
132
|
var api_exports = {};
|
|
131
133
|
__export(api_exports, {
|
|
134
|
+
EBlockTag: () => EBlockTag2,
|
|
135
|
+
EDAMode: () => EDAMode2,
|
|
136
|
+
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
137
|
+
ESimulationFlag: () => ESimulationFlag2,
|
|
138
|
+
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
139
|
+
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
140
|
+
ETransactionStatus: () => ETransactionStatus2,
|
|
141
|
+
ETransactionType: () => ETransactionType2,
|
|
142
|
+
ETransactionVersion: () => ETransactionVersion4,
|
|
143
|
+
ETransactionVersion2: () => ETransactionVersion22,
|
|
144
|
+
ETransactionVersion3: () => ETransactionVersion32,
|
|
145
|
+
Errors: () => errors_exports2,
|
|
146
|
+
JRPC: () => jsonrpc_exports,
|
|
147
|
+
RPCSPEC06: () => rpcspec_0_6_exports,
|
|
148
|
+
RPCSPEC07: () => rpcspec_0_7_exports,
|
|
149
|
+
SPEC: () => components_exports2
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// src/types/api/jsonrpc/index.ts
|
|
153
|
+
var jsonrpc_exports = {};
|
|
154
|
+
|
|
155
|
+
// src/types/api/rpcspec_0_6/index.ts
|
|
156
|
+
var rpcspec_0_6_exports = {};
|
|
157
|
+
__export(rpcspec_0_6_exports, {
|
|
132
158
|
EBlockTag: () => EBlockTag,
|
|
133
159
|
EDAMode: () => EDAMode,
|
|
134
160
|
EDataAvailabilityMode: () => EDataAvailabilityMode,
|
|
@@ -141,13 +167,9 @@ __export(api_exports, {
|
|
|
141
167
|
ETransactionVersion2: () => ETransactionVersion2,
|
|
142
168
|
ETransactionVersion3: () => ETransactionVersion3,
|
|
143
169
|
Errors: () => errors_exports,
|
|
144
|
-
JRPC: () => jsonrpc_exports,
|
|
145
170
|
SPEC: () => components_exports
|
|
146
171
|
});
|
|
147
172
|
|
|
148
|
-
// src/types/api/jsonrpc/index.ts
|
|
149
|
-
var jsonrpc_exports = {};
|
|
150
|
-
|
|
151
173
|
// src/types/api/rpcspec_0_6/errors.ts
|
|
152
174
|
var errors_exports = {};
|
|
153
175
|
|
|
@@ -155,77 +177,173 @@ var errors_exports = {};
|
|
|
155
177
|
var components_exports = {};
|
|
156
178
|
|
|
157
179
|
// src/types/api/rpcspec_0_6/nonspec.ts
|
|
158
|
-
var ETransactionType = /* @__PURE__ */ ((
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
180
|
+
var ETransactionType = /* @__PURE__ */ ((ETransactionType3) => {
|
|
181
|
+
ETransactionType3["DECLARE"] = "DECLARE";
|
|
182
|
+
ETransactionType3["DEPLOY"] = "DEPLOY";
|
|
183
|
+
ETransactionType3["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
184
|
+
ETransactionType3["INVOKE"] = "INVOKE";
|
|
185
|
+
ETransactionType3["L1_HANDLER"] = "L1_HANDLER";
|
|
186
|
+
return ETransactionType3;
|
|
165
187
|
})(ETransactionType || {});
|
|
166
|
-
var ESimulationFlag = /* @__PURE__ */ ((
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return
|
|
188
|
+
var ESimulationFlag = /* @__PURE__ */ ((ESimulationFlag3) => {
|
|
189
|
+
ESimulationFlag3["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
190
|
+
ESimulationFlag3["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
|
|
191
|
+
return ESimulationFlag3;
|
|
170
192
|
})(ESimulationFlag || {});
|
|
171
|
-
var ETransactionStatus = /* @__PURE__ */ ((
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return
|
|
193
|
+
var ETransactionStatus = /* @__PURE__ */ ((ETransactionStatus3) => {
|
|
194
|
+
ETransactionStatus3["RECEIVED"] = "RECEIVED";
|
|
195
|
+
ETransactionStatus3["REJECTED"] = "REJECTED";
|
|
196
|
+
ETransactionStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
197
|
+
ETransactionStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
198
|
+
return ETransactionStatus3;
|
|
177
199
|
})(ETransactionStatus || {});
|
|
178
|
-
var ETransactionFinalityStatus = /* @__PURE__ */ ((
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return
|
|
200
|
+
var ETransactionFinalityStatus = /* @__PURE__ */ ((ETransactionFinalityStatus3) => {
|
|
201
|
+
ETransactionFinalityStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
202
|
+
ETransactionFinalityStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
203
|
+
return ETransactionFinalityStatus3;
|
|
182
204
|
})(ETransactionFinalityStatus || {});
|
|
183
|
-
var ETransactionExecutionStatus = /* @__PURE__ */ ((
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return
|
|
205
|
+
var ETransactionExecutionStatus = /* @__PURE__ */ ((ETransactionExecutionStatus3) => {
|
|
206
|
+
ETransactionExecutionStatus3["SUCCEEDED"] = "SUCCEEDED";
|
|
207
|
+
ETransactionExecutionStatus3["REVERTED"] = "REVERTED";
|
|
208
|
+
return ETransactionExecutionStatus3;
|
|
187
209
|
})(ETransactionExecutionStatus || {});
|
|
188
|
-
var EBlockTag = /* @__PURE__ */ ((
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return
|
|
210
|
+
var EBlockTag = /* @__PURE__ */ ((EBlockTag3) => {
|
|
211
|
+
EBlockTag3["LATEST"] = "latest";
|
|
212
|
+
EBlockTag3["PENDING"] = "pending";
|
|
213
|
+
return EBlockTag3;
|
|
192
214
|
})(EBlockTag || {});
|
|
193
|
-
var EDataAvailabilityMode = /* @__PURE__ */ ((
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return
|
|
215
|
+
var EDataAvailabilityMode = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
|
|
216
|
+
EDataAvailabilityMode3["L1"] = "L1";
|
|
217
|
+
EDataAvailabilityMode3["L2"] = "L2";
|
|
218
|
+
return EDataAvailabilityMode3;
|
|
197
219
|
})(EDataAvailabilityMode || {});
|
|
198
|
-
var EDAMode = /* @__PURE__ */ ((
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return
|
|
220
|
+
var EDAMode = /* @__PURE__ */ ((EDAMode4) => {
|
|
221
|
+
EDAMode4[EDAMode4["L1"] = 0] = "L1";
|
|
222
|
+
EDAMode4[EDAMode4["L2"] = 1] = "L2";
|
|
223
|
+
return EDAMode4;
|
|
202
224
|
})(EDAMode || {});
|
|
203
|
-
var ETransactionVersion = /* @__PURE__ */ ((
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return
|
|
225
|
+
var ETransactionVersion = /* @__PURE__ */ ((ETransactionVersion5) => {
|
|
226
|
+
ETransactionVersion5["V0"] = "0x0";
|
|
227
|
+
ETransactionVersion5["V1"] = "0x1";
|
|
228
|
+
ETransactionVersion5["V2"] = "0x2";
|
|
229
|
+
ETransactionVersion5["V3"] = "0x3";
|
|
230
|
+
ETransactionVersion5["F0"] = "0x100000000000000000000000000000000";
|
|
231
|
+
ETransactionVersion5["F1"] = "0x100000000000000000000000000000001";
|
|
232
|
+
ETransactionVersion5["F2"] = "0x100000000000000000000000000000002";
|
|
233
|
+
ETransactionVersion5["F3"] = "0x100000000000000000000000000000003";
|
|
234
|
+
return ETransactionVersion5;
|
|
213
235
|
})(ETransactionVersion || {});
|
|
214
|
-
var ETransactionVersion2 = /* @__PURE__ */ ((
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return
|
|
236
|
+
var ETransactionVersion2 = /* @__PURE__ */ ((ETransactionVersion24) => {
|
|
237
|
+
ETransactionVersion24["V0"] = "0x0";
|
|
238
|
+
ETransactionVersion24["V1"] = "0x1";
|
|
239
|
+
ETransactionVersion24["V2"] = "0x2";
|
|
240
|
+
ETransactionVersion24["F0"] = "0x100000000000000000000000000000000";
|
|
241
|
+
ETransactionVersion24["F1"] = "0x100000000000000000000000000000001";
|
|
242
|
+
ETransactionVersion24["F2"] = "0x100000000000000000000000000000002";
|
|
243
|
+
return ETransactionVersion24;
|
|
222
244
|
})(ETransactionVersion2 || {});
|
|
223
|
-
var ETransactionVersion3 = /* @__PURE__ */ ((
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return
|
|
245
|
+
var ETransactionVersion3 = /* @__PURE__ */ ((ETransactionVersion34) => {
|
|
246
|
+
ETransactionVersion34["V3"] = "0x3";
|
|
247
|
+
ETransactionVersion34["F3"] = "0x100000000000000000000000000000003";
|
|
248
|
+
return ETransactionVersion34;
|
|
227
249
|
})(ETransactionVersion3 || {});
|
|
228
250
|
|
|
251
|
+
// src/types/api/rpcspec_0_7/index.ts
|
|
252
|
+
var rpcspec_0_7_exports = {};
|
|
253
|
+
__export(rpcspec_0_7_exports, {
|
|
254
|
+
EBlockTag: () => EBlockTag2,
|
|
255
|
+
EDAMode: () => EDAMode2,
|
|
256
|
+
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
257
|
+
ESimulationFlag: () => ESimulationFlag2,
|
|
258
|
+
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
259
|
+
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
260
|
+
ETransactionStatus: () => ETransactionStatus2,
|
|
261
|
+
ETransactionType: () => ETransactionType2,
|
|
262
|
+
ETransactionVersion: () => ETransactionVersion4,
|
|
263
|
+
ETransactionVersion2: () => ETransactionVersion22,
|
|
264
|
+
ETransactionVersion3: () => ETransactionVersion32,
|
|
265
|
+
Errors: () => errors_exports2,
|
|
266
|
+
SPEC: () => components_exports2
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// src/types/api/rpcspec_0_7/errors.ts
|
|
270
|
+
var errors_exports2 = {};
|
|
271
|
+
|
|
272
|
+
// src/types/api/rpcspec_0_7/components.ts
|
|
273
|
+
var components_exports2 = {};
|
|
274
|
+
|
|
275
|
+
// src/types/api/rpcspec_0_7/nonspec.ts
|
|
276
|
+
var ETransactionType2 = /* @__PURE__ */ ((ETransactionType3) => {
|
|
277
|
+
ETransactionType3["DECLARE"] = "DECLARE";
|
|
278
|
+
ETransactionType3["DEPLOY"] = "DEPLOY";
|
|
279
|
+
ETransactionType3["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
280
|
+
ETransactionType3["INVOKE"] = "INVOKE";
|
|
281
|
+
ETransactionType3["L1_HANDLER"] = "L1_HANDLER";
|
|
282
|
+
return ETransactionType3;
|
|
283
|
+
})(ETransactionType2 || {});
|
|
284
|
+
var ESimulationFlag2 = /* @__PURE__ */ ((ESimulationFlag3) => {
|
|
285
|
+
ESimulationFlag3["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
286
|
+
ESimulationFlag3["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
|
|
287
|
+
return ESimulationFlag3;
|
|
288
|
+
})(ESimulationFlag2 || {});
|
|
289
|
+
var ETransactionStatus2 = /* @__PURE__ */ ((ETransactionStatus3) => {
|
|
290
|
+
ETransactionStatus3["RECEIVED"] = "RECEIVED";
|
|
291
|
+
ETransactionStatus3["REJECTED"] = "REJECTED";
|
|
292
|
+
ETransactionStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
293
|
+
ETransactionStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
294
|
+
return ETransactionStatus3;
|
|
295
|
+
})(ETransactionStatus2 || {});
|
|
296
|
+
var ETransactionFinalityStatus2 = /* @__PURE__ */ ((ETransactionFinalityStatus3) => {
|
|
297
|
+
ETransactionFinalityStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
298
|
+
ETransactionFinalityStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
299
|
+
return ETransactionFinalityStatus3;
|
|
300
|
+
})(ETransactionFinalityStatus2 || {});
|
|
301
|
+
var ETransactionExecutionStatus2 = /* @__PURE__ */ ((ETransactionExecutionStatus3) => {
|
|
302
|
+
ETransactionExecutionStatus3["SUCCEEDED"] = "SUCCEEDED";
|
|
303
|
+
ETransactionExecutionStatus3["REVERTED"] = "REVERTED";
|
|
304
|
+
return ETransactionExecutionStatus3;
|
|
305
|
+
})(ETransactionExecutionStatus2 || {});
|
|
306
|
+
var EBlockTag2 = /* @__PURE__ */ ((EBlockTag3) => {
|
|
307
|
+
EBlockTag3["LATEST"] = "latest";
|
|
308
|
+
EBlockTag3["PENDING"] = "pending";
|
|
309
|
+
return EBlockTag3;
|
|
310
|
+
})(EBlockTag2 || {});
|
|
311
|
+
var EDataAvailabilityMode2 = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
|
|
312
|
+
EDataAvailabilityMode3["L1"] = "L1";
|
|
313
|
+
EDataAvailabilityMode3["L2"] = "L2";
|
|
314
|
+
return EDataAvailabilityMode3;
|
|
315
|
+
})(EDataAvailabilityMode2 || {});
|
|
316
|
+
var EDAMode2 = /* @__PURE__ */ ((EDAMode4) => {
|
|
317
|
+
EDAMode4[EDAMode4["L1"] = 0] = "L1";
|
|
318
|
+
EDAMode4[EDAMode4["L2"] = 1] = "L2";
|
|
319
|
+
return EDAMode4;
|
|
320
|
+
})(EDAMode2 || {});
|
|
321
|
+
var ETransactionVersion4 = /* @__PURE__ */ ((ETransactionVersion5) => {
|
|
322
|
+
ETransactionVersion5["V0"] = "0x0";
|
|
323
|
+
ETransactionVersion5["V1"] = "0x1";
|
|
324
|
+
ETransactionVersion5["V2"] = "0x2";
|
|
325
|
+
ETransactionVersion5["V3"] = "0x3";
|
|
326
|
+
ETransactionVersion5["F0"] = "0x100000000000000000000000000000000";
|
|
327
|
+
ETransactionVersion5["F1"] = "0x100000000000000000000000000000001";
|
|
328
|
+
ETransactionVersion5["F2"] = "0x100000000000000000000000000000002";
|
|
329
|
+
ETransactionVersion5["F3"] = "0x100000000000000000000000000000003";
|
|
330
|
+
return ETransactionVersion5;
|
|
331
|
+
})(ETransactionVersion4 || {});
|
|
332
|
+
var ETransactionVersion22 = /* @__PURE__ */ ((ETransactionVersion24) => {
|
|
333
|
+
ETransactionVersion24["V0"] = "0x0";
|
|
334
|
+
ETransactionVersion24["V1"] = "0x1";
|
|
335
|
+
ETransactionVersion24["V2"] = "0x2";
|
|
336
|
+
ETransactionVersion24["F0"] = "0x100000000000000000000000000000000";
|
|
337
|
+
ETransactionVersion24["F1"] = "0x100000000000000000000000000000001";
|
|
338
|
+
ETransactionVersion24["F2"] = "0x100000000000000000000000000000002";
|
|
339
|
+
return ETransactionVersion24;
|
|
340
|
+
})(ETransactionVersion22 || {});
|
|
341
|
+
var ETransactionVersion32 = /* @__PURE__ */ ((ETransactionVersion34) => {
|
|
342
|
+
ETransactionVersion34["V3"] = "0x3";
|
|
343
|
+
ETransactionVersion34["F3"] = "0x100000000000000000000000000000003";
|
|
344
|
+
return ETransactionVersion34;
|
|
345
|
+
})(ETransactionVersion32 || {});
|
|
346
|
+
|
|
229
347
|
// src/utils/encode.ts
|
|
230
348
|
var encode_exports = {};
|
|
231
349
|
__export(encode_exports, {
|
|
@@ -320,11 +438,11 @@ var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
|
320
438
|
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
321
439
|
return NetworkName2;
|
|
322
440
|
})(NetworkName || {});
|
|
323
|
-
var StarknetChainId = /* @__PURE__ */ ((
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return
|
|
441
|
+
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
|
|
442
|
+
StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
|
|
443
|
+
StarknetChainId6["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
444
|
+
StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
445
|
+
return StarknetChainId6;
|
|
328
446
|
})(StarknetChainId || {});
|
|
329
447
|
var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
|
|
330
448
|
TransactionHashPrefix2["DECLARE"] = "0x6465636c617265";
|
|
@@ -391,6 +509,12 @@ var HttpError = class extends LibraryError {
|
|
|
391
509
|
}
|
|
392
510
|
};
|
|
393
511
|
|
|
512
|
+
// src/channel/rpc_0_6.ts
|
|
513
|
+
var rpc_0_6_exports = {};
|
|
514
|
+
__export(rpc_0_6_exports, {
|
|
515
|
+
RpcChannel: () => RpcChannel
|
|
516
|
+
});
|
|
517
|
+
|
|
394
518
|
// src/types/index.ts
|
|
395
519
|
var types_exports = {};
|
|
396
520
|
__export(types_exports, {
|
|
@@ -1291,13 +1415,40 @@ function extractCairo0Tuple(type) {
|
|
|
1291
1415
|
}
|
|
1292
1416
|
return recomposed;
|
|
1293
1417
|
}
|
|
1418
|
+
function getClosureOffset(input, open, close) {
|
|
1419
|
+
for (let i = 0, counter = 0; i < input.length; i++) {
|
|
1420
|
+
if (input[i] === open) {
|
|
1421
|
+
counter++;
|
|
1422
|
+
} else if (input[i] === close && --counter === 0) {
|
|
1423
|
+
return i;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return Number.POSITIVE_INFINITY;
|
|
1427
|
+
}
|
|
1294
1428
|
function extractCairo1Tuple(type) {
|
|
1295
|
-
const
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1429
|
+
const input = type.slice(1, -1);
|
|
1430
|
+
const result = [];
|
|
1431
|
+
let currentIndex = 0;
|
|
1432
|
+
let limitIndex;
|
|
1433
|
+
while (currentIndex < input.length) {
|
|
1434
|
+
switch (true) {
|
|
1435
|
+
case input[currentIndex] === "(": {
|
|
1436
|
+
limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "(", ")") + 1;
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
case (input.startsWith("core::result::Result::<", currentIndex) || input.startsWith("core::array::Array::<", currentIndex) || input.startsWith("core::option::Option::<", currentIndex)): {
|
|
1440
|
+
limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "<", ">") + 1;
|
|
1441
|
+
break;
|
|
1442
|
+
}
|
|
1443
|
+
default: {
|
|
1444
|
+
const commaIndex = input.indexOf(",", currentIndex);
|
|
1445
|
+
limitIndex = commaIndex !== -1 ? commaIndex : Number.POSITIVE_INFINITY;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
result.push(input.slice(currentIndex, limitIndex));
|
|
1449
|
+
currentIndex = limitIndex + 2;
|
|
1450
|
+
}
|
|
1451
|
+
return result;
|
|
1301
1452
|
}
|
|
1302
1453
|
function extractTupleMemberTypes(type) {
|
|
1303
1454
|
if (isCairo1Type(type)) {
|
|
@@ -2825,10 +2976,10 @@ function intDAM(dam) {
|
|
|
2825
2976
|
function toTransactionVersion(defaultVersion, providedVersion) {
|
|
2826
2977
|
const providedVersion0xs = providedVersion ? toHex(providedVersion) : void 0;
|
|
2827
2978
|
const defaultVersion0xs = toHex(defaultVersion);
|
|
2828
|
-
if (providedVersion && !Object.values(
|
|
2979
|
+
if (providedVersion && !Object.values(ETransactionVersion4).includes(providedVersion0xs)) {
|
|
2829
2980
|
throw Error(`providedVersion ${providedVersion} is not ETransactionVersion`);
|
|
2830
2981
|
}
|
|
2831
|
-
if (!Object.values(
|
|
2982
|
+
if (!Object.values(ETransactionVersion4).includes(defaultVersion0xs)) {
|
|
2832
2983
|
throw Error(`defaultVersion ${defaultVersion} is not ETransactionVersion`);
|
|
2833
2984
|
}
|
|
2834
2985
|
return providedVersion ? providedVersion0xs : defaultVersion0xs;
|
|
@@ -3262,9 +3413,9 @@ var RpcChannel = class {
|
|
|
3262
3413
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3263
3414
|
const simulationFlags = [];
|
|
3264
3415
|
if (skipValidate)
|
|
3265
|
-
simulationFlags.push(
|
|
3416
|
+
simulationFlags.push(rpcspec_0_6_exports.ESimulationFlag.SKIP_VALIDATE);
|
|
3266
3417
|
if (skipFeeCharge)
|
|
3267
|
-
simulationFlags.push(
|
|
3418
|
+
simulationFlags.push(rpcspec_0_6_exports.ESimulationFlag.SKIP_FEE_CHARGE);
|
|
3268
3419
|
return this.fetchEndpoint("starknet_simulateTransactions", {
|
|
3269
3420
|
block_id,
|
|
3270
3421
|
transactions: invocations.map((it) => this.buildTransaction(it)),
|
|
@@ -3278,15 +3429,15 @@ var RpcChannel = class {
|
|
|
3278
3429
|
let isErrorState = false;
|
|
3279
3430
|
const retryInterval = options?.retryInterval ?? 5e3;
|
|
3280
3431
|
const errorStates = options?.errorStates ?? [
|
|
3281
|
-
|
|
3432
|
+
rpcspec_0_6_exports.ETransactionStatus.REJECTED
|
|
3282
3433
|
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
3283
3434
|
// should decide which behavior to keep in the future
|
|
3284
3435
|
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
3285
3436
|
];
|
|
3286
3437
|
const successStates = options?.successStates ?? [
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3438
|
+
rpcspec_0_6_exports.ETransactionExecutionStatus.SUCCEEDED,
|
|
3439
|
+
rpcspec_0_6_exports.ETransactionStatus.ACCEPTED_ON_L2,
|
|
3440
|
+
rpcspec_0_6_exports.ETransactionStatus.ACCEPTED_ON_L1
|
|
3290
3441
|
];
|
|
3291
3442
|
let txStatus;
|
|
3292
3443
|
while (!onchain) {
|
|
@@ -3369,9 +3520,9 @@ var RpcChannel = class {
|
|
|
3369
3520
|
async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true }) {
|
|
3370
3521
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3371
3522
|
let flags = {};
|
|
3372
|
-
if (isVersion("0.
|
|
3523
|
+
if (!isVersion("0.5", await this.getSpecVersion())) {
|
|
3373
3524
|
flags = {
|
|
3374
|
-
simulation_flags: skipValidate ? [
|
|
3525
|
+
simulation_flags: skipValidate ? [rpcspec_0_6_exports.ESimulationFlag.SKIP_VALIDATE] : []
|
|
3375
3526
|
};
|
|
3376
3527
|
}
|
|
3377
3528
|
return this.fetchEndpoint("starknet_estimateFee", {
|
|
@@ -3387,9 +3538,9 @@ var RpcChannel = class {
|
|
|
3387
3538
|
invoke_transaction: {
|
|
3388
3539
|
sender_address: functionInvocation.contractAddress,
|
|
3389
3540
|
calldata: CallData.toHex(functionInvocation.calldata),
|
|
3390
|
-
type:
|
|
3541
|
+
type: rpcspec_0_6_exports.ETransactionType.INVOKE,
|
|
3391
3542
|
max_fee: toHex(details.maxFee || 0),
|
|
3392
|
-
version:
|
|
3543
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V1,
|
|
3393
3544
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
3394
3545
|
nonce: toHex(details.nonce)
|
|
3395
3546
|
}
|
|
@@ -3397,10 +3548,10 @@ var RpcChannel = class {
|
|
|
3397
3548
|
} else {
|
|
3398
3549
|
promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
3399
3550
|
invoke_transaction: {
|
|
3400
|
-
type:
|
|
3551
|
+
type: rpcspec_0_6_exports.ETransactionType.INVOKE,
|
|
3401
3552
|
sender_address: functionInvocation.contractAddress,
|
|
3402
3553
|
calldata: CallData.toHex(functionInvocation.calldata),
|
|
3403
|
-
version:
|
|
3554
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V3,
|
|
3404
3555
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
3405
3556
|
nonce: toHex(details.nonce),
|
|
3406
3557
|
resource_bounds: details.resourceBounds,
|
|
@@ -3419,13 +3570,13 @@ var RpcChannel = class {
|
|
|
3419
3570
|
if (!isSierra(contract) && !isV3Tx(details)) {
|
|
3420
3571
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
3421
3572
|
declare_transaction: {
|
|
3422
|
-
type:
|
|
3573
|
+
type: rpcspec_0_6_exports.ETransactionType.DECLARE,
|
|
3423
3574
|
contract_class: {
|
|
3424
3575
|
program: contract.program,
|
|
3425
3576
|
entry_points_by_type: contract.entry_points_by_type,
|
|
3426
3577
|
abi: contract.abi
|
|
3427
3578
|
},
|
|
3428
|
-
version:
|
|
3579
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V1,
|
|
3429
3580
|
max_fee: toHex(details.maxFee || 0),
|
|
3430
3581
|
signature: signatureToHexArray(signature),
|
|
3431
3582
|
sender_address: senderAddress,
|
|
@@ -3435,7 +3586,7 @@ var RpcChannel = class {
|
|
|
3435
3586
|
} else if (isSierra(contract) && !isV3Tx(details)) {
|
|
3436
3587
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
3437
3588
|
declare_transaction: {
|
|
3438
|
-
type:
|
|
3589
|
+
type: rpcspec_0_6_exports.ETransactionType.DECLARE,
|
|
3439
3590
|
contract_class: {
|
|
3440
3591
|
sierra_program: decompressProgram(contract.sierra_program),
|
|
3441
3592
|
contract_class_version: contract.contract_class_version,
|
|
@@ -3443,7 +3594,7 @@ var RpcChannel = class {
|
|
|
3443
3594
|
abi: contract.abi
|
|
3444
3595
|
},
|
|
3445
3596
|
compiled_class_hash: compiledClassHash || "",
|
|
3446
|
-
version:
|
|
3597
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V2,
|
|
3447
3598
|
max_fee: toHex(details.maxFee || 0),
|
|
3448
3599
|
signature: signatureToHexArray(signature),
|
|
3449
3600
|
sender_address: senderAddress,
|
|
@@ -3453,10 +3604,10 @@ var RpcChannel = class {
|
|
|
3453
3604
|
} else if (isSierra(contract) && isV3Tx(details)) {
|
|
3454
3605
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
3455
3606
|
declare_transaction: {
|
|
3456
|
-
type:
|
|
3607
|
+
type: rpcspec_0_6_exports.ETransactionType.DECLARE,
|
|
3457
3608
|
sender_address: senderAddress,
|
|
3458
3609
|
compiled_class_hash: compiledClassHash || "",
|
|
3459
|
-
version:
|
|
3610
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V3,
|
|
3460
3611
|
signature: signatureToHexArray(signature),
|
|
3461
3612
|
nonce: toHex(details.nonce),
|
|
3462
3613
|
contract_class: {
|
|
@@ -3486,9 +3637,9 @@ var RpcChannel = class {
|
|
|
3486
3637
|
constructor_calldata: CallData.toHex(constructorCalldata || []),
|
|
3487
3638
|
class_hash: toHex(classHash),
|
|
3488
3639
|
contract_address_salt: toHex(addressSalt || 0),
|
|
3489
|
-
type:
|
|
3640
|
+
type: rpcspec_0_6_exports.ETransactionType.DEPLOY_ACCOUNT,
|
|
3490
3641
|
max_fee: toHex(details.maxFee || 0),
|
|
3491
|
-
version:
|
|
3642
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V1,
|
|
3492
3643
|
signature: signatureToHexArray(signature),
|
|
3493
3644
|
nonce: toHex(details.nonce)
|
|
3494
3645
|
}
|
|
@@ -3496,8 +3647,8 @@ var RpcChannel = class {
|
|
|
3496
3647
|
} else {
|
|
3497
3648
|
promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
3498
3649
|
deploy_account_transaction: {
|
|
3499
|
-
type:
|
|
3500
|
-
version:
|
|
3650
|
+
type: rpcspec_0_6_exports.ETransactionType.DEPLOY_ACCOUNT,
|
|
3651
|
+
version: rpcspec_0_6_exports.ETransactionVersion.V3,
|
|
3501
3652
|
signature: signatureToHexArray(signature),
|
|
3502
3653
|
nonce: toHex(details.nonce),
|
|
3503
3654
|
contract_address_salt: toHex(addressSalt || 0),
|
|
@@ -3580,7 +3731,7 @@ var RpcChannel = class {
|
|
|
3580
3731
|
if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
|
|
3581
3732
|
return {
|
|
3582
3733
|
// v0 v1 v3
|
|
3583
|
-
type:
|
|
3734
|
+
type: rpcspec_0_6_exports.ETransactionType.INVOKE,
|
|
3584
3735
|
// TODO: Diff between sequencer and rpc invoke type
|
|
3585
3736
|
sender_address: invocation.contractAddress,
|
|
3586
3737
|
calldata: CallData.toHex(invocation.calldata),
|
|
@@ -3626,106 +3777,645 @@ var RpcChannel = class {
|
|
|
3626
3777
|
}
|
|
3627
3778
|
};
|
|
3628
3779
|
|
|
3629
|
-
// src/
|
|
3630
|
-
var
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3780
|
+
// src/channel/rpc_0_7.ts
|
|
3781
|
+
var rpc_0_7_exports = {};
|
|
3782
|
+
__export(rpc_0_7_exports, {
|
|
3783
|
+
RpcChannel: () => RpcChannel2
|
|
3784
|
+
});
|
|
3785
|
+
var defaultOptions2 = {
|
|
3786
|
+
headers: { "Content-Type": "application/json" },
|
|
3787
|
+
blockIdentifier: "pending" /* pending */,
|
|
3788
|
+
retries: 200
|
|
3789
|
+
};
|
|
3790
|
+
var RpcChannel2 = class {
|
|
3791
|
+
nodeUrl;
|
|
3792
|
+
headers;
|
|
3793
|
+
retries;
|
|
3794
|
+
requestId;
|
|
3795
|
+
blockIdentifier;
|
|
3796
|
+
chainId;
|
|
3797
|
+
speckVersion;
|
|
3798
|
+
waitMode;
|
|
3799
|
+
// behave like web2 rpc and return when tx is processed
|
|
3800
|
+
constructor(optionsOrProvider) {
|
|
3801
|
+
const { nodeUrl, retries, headers, blockIdentifier, chainId, waitMode } = optionsOrProvider || {};
|
|
3802
|
+
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
3803
|
+
this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
|
|
3804
|
+
} else if (nodeUrl) {
|
|
3805
|
+
this.nodeUrl = nodeUrl;
|
|
3806
|
+
} else {
|
|
3807
|
+
this.nodeUrl = getDefaultNodeUrl(void 0, optionsOrProvider?.default);
|
|
3643
3808
|
}
|
|
3644
|
-
|
|
3809
|
+
this.retries = retries || defaultOptions2.retries;
|
|
3810
|
+
this.headers = { ...defaultOptions2.headers, ...headers };
|
|
3811
|
+
this.blockIdentifier = blockIdentifier || defaultOptions2.blockIdentifier;
|
|
3812
|
+
this.chainId = chainId;
|
|
3813
|
+
this.waitMode = waitMode || false;
|
|
3814
|
+
this.requestId = 0;
|
|
3645
3815
|
}
|
|
3646
|
-
|
|
3647
|
-
const
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
unit: val.unit,
|
|
3653
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
3654
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
3816
|
+
fetch(method, params, id = 0) {
|
|
3817
|
+
const rpcRequestBody = {
|
|
3818
|
+
id,
|
|
3819
|
+
jsonrpc: "2.0",
|
|
3820
|
+
method,
|
|
3821
|
+
...params && { params }
|
|
3655
3822
|
};
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
gas_consumed: toBigInt(val.gas_consumed),
|
|
3661
|
-
gas_price: toBigInt(val.gas_price),
|
|
3662
|
-
unit: val.unit,
|
|
3663
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
3664
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
3665
|
-
}));
|
|
3666
|
-
}
|
|
3667
|
-
parseSimulateTransactionResponse(res) {
|
|
3668
|
-
return res.map((it) => {
|
|
3669
|
-
return {
|
|
3670
|
-
...it,
|
|
3671
|
-
suggestedMaxFee: estimatedFeeToMaxFee(BigInt(it.fee_estimation.overall_fee)),
|
|
3672
|
-
resourceBounds: estimateFeeToBounds(it.fee_estimation)
|
|
3673
|
-
};
|
|
3823
|
+
return fetchPonyfill_default(this.nodeUrl, {
|
|
3824
|
+
method: "POST",
|
|
3825
|
+
body: stringify2(rpcRequestBody),
|
|
3826
|
+
headers: this.headers
|
|
3674
3827
|
});
|
|
3675
3828
|
}
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
}
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
this.channel = optionsOrProvider.channel;
|
|
3691
|
-
} else {
|
|
3692
|
-
this.channel = new RpcChannel({ ...optionsOrProvider, waitMode: false });
|
|
3829
|
+
errorHandler(method, params, rpcError, otherError) {
|
|
3830
|
+
if (rpcError) {
|
|
3831
|
+
const { code, message, data } = rpcError;
|
|
3832
|
+
throw new LibraryError(
|
|
3833
|
+
`RPC: ${method} with params ${stringify2(params, null, 2)}
|
|
3834
|
+
|
|
3835
|
+
${code}: ${message}: ${stringify2(data)}`
|
|
3836
|
+
);
|
|
3837
|
+
}
|
|
3838
|
+
if (otherError instanceof LibraryError) {
|
|
3839
|
+
throw otherError;
|
|
3840
|
+
}
|
|
3841
|
+
if (otherError) {
|
|
3842
|
+
throw Error(otherError.message);
|
|
3693
3843
|
}
|
|
3694
3844
|
}
|
|
3695
|
-
|
|
3696
|
-
|
|
3845
|
+
async fetchEndpoint(method, params) {
|
|
3846
|
+
try {
|
|
3847
|
+
const rawResult = await this.fetch(method, params, this.requestId += 1);
|
|
3848
|
+
const { error, result } = await rawResult.json();
|
|
3849
|
+
this.errorHandler(method, params, error);
|
|
3850
|
+
return result;
|
|
3851
|
+
} catch (error) {
|
|
3852
|
+
this.errorHandler(method, params, error?.response?.data, error);
|
|
3853
|
+
throw error;
|
|
3854
|
+
}
|
|
3697
3855
|
}
|
|
3698
3856
|
async getChainId() {
|
|
3699
|
-
|
|
3857
|
+
this.chainId ??= await this.fetchEndpoint("starknet_chainId");
|
|
3858
|
+
return this.chainId;
|
|
3700
3859
|
}
|
|
3701
3860
|
async getSpecVersion() {
|
|
3702
|
-
|
|
3861
|
+
this.speckVersion ??= await this.fetchEndpoint("starknet_specVersion");
|
|
3862
|
+
return this.speckVersion;
|
|
3703
3863
|
}
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3864
|
+
getNonceForAddress(contractAddress, blockIdentifier = this.blockIdentifier) {
|
|
3865
|
+
const contract_address = toHex(contractAddress);
|
|
3866
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3867
|
+
return this.fetchEndpoint("starknet_getNonce", {
|
|
3868
|
+
contract_address,
|
|
3869
|
+
block_id
|
|
3870
|
+
});
|
|
3709
3871
|
}
|
|
3710
3872
|
/**
|
|
3711
3873
|
* Get the most recent accepted block hash and number
|
|
3712
3874
|
*/
|
|
3713
|
-
|
|
3714
|
-
return this.
|
|
3875
|
+
getBlockLatestAccepted() {
|
|
3876
|
+
return this.fetchEndpoint("starknet_blockHashAndNumber");
|
|
3715
3877
|
}
|
|
3716
3878
|
/**
|
|
3717
3879
|
* Get the most recent accepted block number
|
|
3718
3880
|
* redundant use getBlockLatestAccepted();
|
|
3719
3881
|
* @returns Number of the latest block
|
|
3720
3882
|
*/
|
|
3721
|
-
|
|
3722
|
-
return this.
|
|
3883
|
+
getBlockNumber() {
|
|
3884
|
+
return this.fetchEndpoint("starknet_blockNumber");
|
|
3723
3885
|
}
|
|
3724
|
-
|
|
3725
|
-
|
|
3886
|
+
getBlockWithTxHashes(blockIdentifier = this.blockIdentifier) {
|
|
3887
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3888
|
+
return this.fetchEndpoint("starknet_getBlockWithTxHashes", { block_id });
|
|
3726
3889
|
}
|
|
3727
|
-
|
|
3728
|
-
|
|
3890
|
+
getBlockWithTxs(blockIdentifier = this.blockIdentifier) {
|
|
3891
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3892
|
+
return this.fetchEndpoint("starknet_getBlockWithTxs", { block_id });
|
|
3893
|
+
}
|
|
3894
|
+
getBlockWithReceipts(blockIdentifier = this.blockIdentifier) {
|
|
3895
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3896
|
+
return this.fetchEndpoint("starknet_getBlockWithReceipts", { block_id });
|
|
3897
|
+
}
|
|
3898
|
+
getBlockStateUpdate(blockIdentifier = this.blockIdentifier) {
|
|
3899
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3900
|
+
return this.fetchEndpoint("starknet_getStateUpdate", { block_id });
|
|
3901
|
+
}
|
|
3902
|
+
getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier) {
|
|
3903
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3904
|
+
return this.fetchEndpoint("starknet_traceBlockTransactions", { block_id });
|
|
3905
|
+
}
|
|
3906
|
+
getBlockTransactionCount(blockIdentifier = this.blockIdentifier) {
|
|
3907
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3908
|
+
return this.fetchEndpoint("starknet_getBlockTransactionCount", { block_id });
|
|
3909
|
+
}
|
|
3910
|
+
getTransactionByHash(txHash) {
|
|
3911
|
+
const transaction_hash = toHex(txHash);
|
|
3912
|
+
return this.fetchEndpoint("starknet_getTransactionByHash", {
|
|
3913
|
+
transaction_hash
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3916
|
+
getTransactionByBlockIdAndIndex(blockIdentifier, index) {
|
|
3917
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3918
|
+
return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex", { block_id, index });
|
|
3919
|
+
}
|
|
3920
|
+
getTransactionReceipt(txHash) {
|
|
3921
|
+
const transaction_hash = toHex(txHash);
|
|
3922
|
+
return this.fetchEndpoint("starknet_getTransactionReceipt", { transaction_hash });
|
|
3923
|
+
}
|
|
3924
|
+
getTransactionTrace(txHash) {
|
|
3925
|
+
const transaction_hash = toHex(txHash);
|
|
3926
|
+
return this.fetchEndpoint("starknet_traceTransaction", { transaction_hash });
|
|
3927
|
+
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Get the status of a transaction
|
|
3930
|
+
*/
|
|
3931
|
+
getTransactionStatus(transactionHash) {
|
|
3932
|
+
const transaction_hash = toHex(transactionHash);
|
|
3933
|
+
return this.fetchEndpoint("starknet_getTransactionStatus", { transaction_hash });
|
|
3934
|
+
}
|
|
3935
|
+
/**
|
|
3936
|
+
* @param invocations AccountInvocations
|
|
3937
|
+
* @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
|
|
3938
|
+
* - blockIdentifier<br/>
|
|
3939
|
+
* - skipValidate (default false)<br/>
|
|
3940
|
+
* - skipFeeCharge (default true)<br/>
|
|
3941
|
+
*/
|
|
3942
|
+
simulateTransaction(invocations, {
|
|
3943
|
+
blockIdentifier = this.blockIdentifier,
|
|
3944
|
+
skipValidate = true,
|
|
3945
|
+
skipFeeCharge = true
|
|
3946
|
+
} = {}) {
|
|
3947
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
3948
|
+
const simulationFlags = [];
|
|
3949
|
+
if (skipValidate)
|
|
3950
|
+
simulationFlags.push(rpcspec_0_7_exports.ESimulationFlag.SKIP_VALIDATE);
|
|
3951
|
+
if (skipFeeCharge)
|
|
3952
|
+
simulationFlags.push(rpcspec_0_7_exports.ESimulationFlag.SKIP_FEE_CHARGE);
|
|
3953
|
+
return this.fetchEndpoint("starknet_simulateTransactions", {
|
|
3954
|
+
block_id,
|
|
3955
|
+
transactions: invocations.map((it) => this.buildTransaction(it)),
|
|
3956
|
+
simulation_flags: simulationFlags
|
|
3957
|
+
});
|
|
3958
|
+
}
|
|
3959
|
+
async waitForTransaction(txHash, options) {
|
|
3960
|
+
const transactionHash = toHex(txHash);
|
|
3961
|
+
let { retries } = this;
|
|
3962
|
+
let onchain = false;
|
|
3963
|
+
let isErrorState = false;
|
|
3964
|
+
const retryInterval = options?.retryInterval ?? 5e3;
|
|
3965
|
+
const errorStates = options?.errorStates ?? [
|
|
3966
|
+
rpcspec_0_7_exports.ETransactionStatus.REJECTED
|
|
3967
|
+
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
3968
|
+
// should decide which behavior to keep in the future
|
|
3969
|
+
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
3970
|
+
];
|
|
3971
|
+
const successStates = options?.successStates ?? [
|
|
3972
|
+
rpcspec_0_7_exports.ETransactionExecutionStatus.SUCCEEDED,
|
|
3973
|
+
rpcspec_0_7_exports.ETransactionStatus.ACCEPTED_ON_L2,
|
|
3974
|
+
rpcspec_0_7_exports.ETransactionStatus.ACCEPTED_ON_L1
|
|
3975
|
+
];
|
|
3976
|
+
let txStatus;
|
|
3977
|
+
while (!onchain) {
|
|
3978
|
+
await wait(retryInterval);
|
|
3979
|
+
try {
|
|
3980
|
+
txStatus = await this.getTransactionStatus(transactionHash);
|
|
3981
|
+
const executionStatus = txStatus.execution_status;
|
|
3982
|
+
const finalityStatus = txStatus.finality_status;
|
|
3983
|
+
if (!finalityStatus) {
|
|
3984
|
+
const error = new Error("waiting for transaction status");
|
|
3985
|
+
throw error;
|
|
3986
|
+
}
|
|
3987
|
+
if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
|
|
3988
|
+
const message = `${executionStatus}: ${finalityStatus}`;
|
|
3989
|
+
const error = new Error(message);
|
|
3990
|
+
error.response = txStatus;
|
|
3991
|
+
isErrorState = true;
|
|
3992
|
+
throw error;
|
|
3993
|
+
} else if (successStates.includes(executionStatus) || successStates.includes(finalityStatus)) {
|
|
3994
|
+
onchain = true;
|
|
3995
|
+
}
|
|
3996
|
+
} catch (error) {
|
|
3997
|
+
if (error instanceof Error && isErrorState) {
|
|
3998
|
+
throw error;
|
|
3999
|
+
}
|
|
4000
|
+
if (retries <= 0) {
|
|
4001
|
+
throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
retries -= 1;
|
|
4005
|
+
}
|
|
4006
|
+
let txReceipt = null;
|
|
4007
|
+
while (txReceipt === null) {
|
|
4008
|
+
try {
|
|
4009
|
+
txReceipt = await this.getTransactionReceipt(transactionHash);
|
|
4010
|
+
} catch (error) {
|
|
4011
|
+
if (retries <= 0) {
|
|
4012
|
+
throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
retries -= 1;
|
|
4016
|
+
await wait(retryInterval);
|
|
4017
|
+
}
|
|
4018
|
+
return txReceipt;
|
|
4019
|
+
}
|
|
4020
|
+
getStorageAt(contractAddress, key, blockIdentifier = this.blockIdentifier) {
|
|
4021
|
+
const contract_address = toHex(contractAddress);
|
|
4022
|
+
const parsedKey = toStorageKey(key);
|
|
4023
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4024
|
+
return this.fetchEndpoint("starknet_getStorageAt", {
|
|
4025
|
+
contract_address,
|
|
4026
|
+
key: parsedKey,
|
|
4027
|
+
block_id
|
|
4028
|
+
});
|
|
4029
|
+
}
|
|
4030
|
+
getClassHashAt(contractAddress, blockIdentifier = this.blockIdentifier) {
|
|
4031
|
+
const contract_address = toHex(contractAddress);
|
|
4032
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4033
|
+
return this.fetchEndpoint("starknet_getClassHashAt", {
|
|
4034
|
+
block_id,
|
|
4035
|
+
contract_address
|
|
4036
|
+
});
|
|
4037
|
+
}
|
|
4038
|
+
getClass(classHash, blockIdentifier = this.blockIdentifier) {
|
|
4039
|
+
const class_hash = toHex(classHash);
|
|
4040
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4041
|
+
return this.fetchEndpoint("starknet_getClass", {
|
|
4042
|
+
class_hash,
|
|
4043
|
+
block_id
|
|
4044
|
+
});
|
|
4045
|
+
}
|
|
4046
|
+
getClassAt(contractAddress, blockIdentifier = this.blockIdentifier) {
|
|
4047
|
+
const contract_address = toHex(contractAddress);
|
|
4048
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4049
|
+
return this.fetchEndpoint("starknet_getClassAt", {
|
|
4050
|
+
block_id,
|
|
4051
|
+
contract_address
|
|
4052
|
+
});
|
|
4053
|
+
}
|
|
4054
|
+
async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true }) {
|
|
4055
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4056
|
+
let flags = {};
|
|
4057
|
+
if (!isVersion("0.5", await this.getSpecVersion())) {
|
|
4058
|
+
flags = {
|
|
4059
|
+
simulation_flags: skipValidate ? [rpcspec_0_7_exports.ESimulationFlag.SKIP_VALIDATE] : []
|
|
4060
|
+
};
|
|
4061
|
+
}
|
|
4062
|
+
return this.fetchEndpoint("starknet_estimateFee", {
|
|
4063
|
+
request: invocations.map((it) => this.buildTransaction(it, "fee")),
|
|
4064
|
+
block_id,
|
|
4065
|
+
...flags
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
4068
|
+
async invoke(functionInvocation, details) {
|
|
4069
|
+
let promise;
|
|
4070
|
+
if (!isV3Tx(details)) {
|
|
4071
|
+
promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
4072
|
+
invoke_transaction: {
|
|
4073
|
+
sender_address: functionInvocation.contractAddress,
|
|
4074
|
+
calldata: CallData.toHex(functionInvocation.calldata),
|
|
4075
|
+
type: rpcspec_0_7_exports.ETransactionType.INVOKE,
|
|
4076
|
+
max_fee: toHex(details.maxFee || 0),
|
|
4077
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V1,
|
|
4078
|
+
signature: signatureToHexArray(functionInvocation.signature),
|
|
4079
|
+
nonce: toHex(details.nonce)
|
|
4080
|
+
}
|
|
4081
|
+
});
|
|
4082
|
+
} else {
|
|
4083
|
+
promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
4084
|
+
invoke_transaction: {
|
|
4085
|
+
type: rpcspec_0_7_exports.ETransactionType.INVOKE,
|
|
4086
|
+
sender_address: functionInvocation.contractAddress,
|
|
4087
|
+
calldata: CallData.toHex(functionInvocation.calldata),
|
|
4088
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V3,
|
|
4089
|
+
signature: signatureToHexArray(functionInvocation.signature),
|
|
4090
|
+
nonce: toHex(details.nonce),
|
|
4091
|
+
resource_bounds: details.resourceBounds,
|
|
4092
|
+
tip: toHex(details.tip),
|
|
4093
|
+
paymaster_data: details.paymasterData.map((it) => toHex(it)),
|
|
4094
|
+
account_deployment_data: details.accountDeploymentData.map((it) => toHex(it)),
|
|
4095
|
+
nonce_data_availability_mode: details.nonceDataAvailabilityMode,
|
|
4096
|
+
fee_data_availability_mode: details.feeDataAvailabilityMode
|
|
4097
|
+
}
|
|
4098
|
+
});
|
|
4099
|
+
}
|
|
4100
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
4101
|
+
}
|
|
4102
|
+
async declare({ contract, signature, senderAddress, compiledClassHash }, details) {
|
|
4103
|
+
let promise;
|
|
4104
|
+
if (!isSierra(contract) && !isV3Tx(details)) {
|
|
4105
|
+
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4106
|
+
declare_transaction: {
|
|
4107
|
+
type: rpcspec_0_7_exports.ETransactionType.DECLARE,
|
|
4108
|
+
contract_class: {
|
|
4109
|
+
program: contract.program,
|
|
4110
|
+
entry_points_by_type: contract.entry_points_by_type,
|
|
4111
|
+
abi: contract.abi
|
|
4112
|
+
},
|
|
4113
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V1,
|
|
4114
|
+
max_fee: toHex(details.maxFee || 0),
|
|
4115
|
+
signature: signatureToHexArray(signature),
|
|
4116
|
+
sender_address: senderAddress,
|
|
4117
|
+
nonce: toHex(details.nonce)
|
|
4118
|
+
}
|
|
4119
|
+
});
|
|
4120
|
+
} else if (isSierra(contract) && !isV3Tx(details)) {
|
|
4121
|
+
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4122
|
+
declare_transaction: {
|
|
4123
|
+
type: rpcspec_0_7_exports.ETransactionType.DECLARE,
|
|
4124
|
+
contract_class: {
|
|
4125
|
+
sierra_program: decompressProgram(contract.sierra_program),
|
|
4126
|
+
contract_class_version: contract.contract_class_version,
|
|
4127
|
+
entry_points_by_type: contract.entry_points_by_type,
|
|
4128
|
+
abi: contract.abi
|
|
4129
|
+
},
|
|
4130
|
+
compiled_class_hash: compiledClassHash || "",
|
|
4131
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V2,
|
|
4132
|
+
max_fee: toHex(details.maxFee || 0),
|
|
4133
|
+
signature: signatureToHexArray(signature),
|
|
4134
|
+
sender_address: senderAddress,
|
|
4135
|
+
nonce: toHex(details.nonce)
|
|
4136
|
+
}
|
|
4137
|
+
});
|
|
4138
|
+
} else if (isSierra(contract) && isV3Tx(details)) {
|
|
4139
|
+
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4140
|
+
declare_transaction: {
|
|
4141
|
+
type: rpcspec_0_7_exports.ETransactionType.DECLARE,
|
|
4142
|
+
sender_address: senderAddress,
|
|
4143
|
+
compiled_class_hash: compiledClassHash || "",
|
|
4144
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V3,
|
|
4145
|
+
signature: signatureToHexArray(signature),
|
|
4146
|
+
nonce: toHex(details.nonce),
|
|
4147
|
+
contract_class: {
|
|
4148
|
+
sierra_program: decompressProgram(contract.sierra_program),
|
|
4149
|
+
contract_class_version: contract.contract_class_version,
|
|
4150
|
+
entry_points_by_type: contract.entry_points_by_type,
|
|
4151
|
+
abi: contract.abi
|
|
4152
|
+
},
|
|
4153
|
+
resource_bounds: details.resourceBounds,
|
|
4154
|
+
tip: toHex(details.tip),
|
|
4155
|
+
paymaster_data: details.paymasterData.map((it) => toHex(it)),
|
|
4156
|
+
account_deployment_data: details.accountDeploymentData.map((it) => toHex(it)),
|
|
4157
|
+
nonce_data_availability_mode: details.nonceDataAvailabilityMode,
|
|
4158
|
+
fee_data_availability_mode: details.feeDataAvailabilityMode
|
|
4159
|
+
}
|
|
4160
|
+
});
|
|
4161
|
+
} else {
|
|
4162
|
+
throw Error("declare unspotted parameters");
|
|
4163
|
+
}
|
|
4164
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
4165
|
+
}
|
|
4166
|
+
async deployAccount({ classHash, constructorCalldata, addressSalt, signature }, details) {
|
|
4167
|
+
let promise;
|
|
4168
|
+
if (!isV3Tx(details)) {
|
|
4169
|
+
promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
4170
|
+
deploy_account_transaction: {
|
|
4171
|
+
constructor_calldata: CallData.toHex(constructorCalldata || []),
|
|
4172
|
+
class_hash: toHex(classHash),
|
|
4173
|
+
contract_address_salt: toHex(addressSalt || 0),
|
|
4174
|
+
type: rpcspec_0_7_exports.ETransactionType.DEPLOY_ACCOUNT,
|
|
4175
|
+
max_fee: toHex(details.maxFee || 0),
|
|
4176
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V1,
|
|
4177
|
+
signature: signatureToHexArray(signature),
|
|
4178
|
+
nonce: toHex(details.nonce)
|
|
4179
|
+
}
|
|
4180
|
+
});
|
|
4181
|
+
} else {
|
|
4182
|
+
promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
4183
|
+
deploy_account_transaction: {
|
|
4184
|
+
type: rpcspec_0_7_exports.ETransactionType.DEPLOY_ACCOUNT,
|
|
4185
|
+
version: rpcspec_0_7_exports.ETransactionVersion.V3,
|
|
4186
|
+
signature: signatureToHexArray(signature),
|
|
4187
|
+
nonce: toHex(details.nonce),
|
|
4188
|
+
contract_address_salt: toHex(addressSalt || 0),
|
|
4189
|
+
constructor_calldata: CallData.toHex(constructorCalldata || []),
|
|
4190
|
+
class_hash: toHex(classHash),
|
|
4191
|
+
resource_bounds: details.resourceBounds,
|
|
4192
|
+
tip: toHex(details.tip),
|
|
4193
|
+
paymaster_data: details.paymasterData.map((it) => toHex(it)),
|
|
4194
|
+
nonce_data_availability_mode: details.nonceDataAvailabilityMode,
|
|
4195
|
+
fee_data_availability_mode: details.feeDataAvailabilityMode
|
|
4196
|
+
}
|
|
4197
|
+
});
|
|
4198
|
+
}
|
|
4199
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
4200
|
+
}
|
|
4201
|
+
callContract(call, blockIdentifier = this.blockIdentifier) {
|
|
4202
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4203
|
+
return this.fetchEndpoint("starknet_call", {
|
|
4204
|
+
request: {
|
|
4205
|
+
contract_address: call.contractAddress,
|
|
4206
|
+
entry_point_selector: getSelectorFromName(call.entrypoint),
|
|
4207
|
+
calldata: CallData.toHex(call.calldata)
|
|
4208
|
+
},
|
|
4209
|
+
block_id
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
/**
|
|
4213
|
+
* NEW: Estimate the fee for a message from L1
|
|
4214
|
+
* @param message Message From L1
|
|
4215
|
+
*/
|
|
4216
|
+
estimateMessageFee(message, blockIdentifier = this.blockIdentifier) {
|
|
4217
|
+
const { from_address, to_address, entry_point_selector, payload } = message;
|
|
4218
|
+
const formattedMessage = {
|
|
4219
|
+
from_address: toHex(from_address),
|
|
4220
|
+
to_address: toHex(to_address),
|
|
4221
|
+
entry_point_selector: getSelector(entry_point_selector),
|
|
4222
|
+
payload: getHexStringArray(payload)
|
|
4223
|
+
};
|
|
4224
|
+
const block_id = new Block(blockIdentifier).identifier;
|
|
4225
|
+
return this.fetchEndpoint("starknet_estimateMessageFee", {
|
|
4226
|
+
message: formattedMessage,
|
|
4227
|
+
block_id
|
|
4228
|
+
});
|
|
4229
|
+
}
|
|
4230
|
+
/**
|
|
4231
|
+
* Returns an object about the sync status, or false if the node is not synching
|
|
4232
|
+
* @returns Object with the stats data
|
|
4233
|
+
*/
|
|
4234
|
+
getSyncingStats() {
|
|
4235
|
+
return this.fetchEndpoint("starknet_syncing");
|
|
4236
|
+
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Returns all events matching the given filter
|
|
4239
|
+
* @returns events and the pagination of the events
|
|
4240
|
+
*/
|
|
4241
|
+
getEvents(eventFilter) {
|
|
4242
|
+
return this.fetchEndpoint("starknet_getEvents", { filter: eventFilter });
|
|
4243
|
+
}
|
|
4244
|
+
buildTransaction(invocation, versionType) {
|
|
4245
|
+
const defaultVersions = getVersionsByType(versionType);
|
|
4246
|
+
let details;
|
|
4247
|
+
if (!isV3Tx(invocation)) {
|
|
4248
|
+
details = {
|
|
4249
|
+
signature: signatureToHexArray(invocation.signature),
|
|
4250
|
+
nonce: toHex(invocation.nonce),
|
|
4251
|
+
max_fee: toHex(invocation.maxFee || 0)
|
|
4252
|
+
};
|
|
4253
|
+
} else {
|
|
4254
|
+
details = {
|
|
4255
|
+
signature: signatureToHexArray(invocation.signature),
|
|
4256
|
+
nonce: toHex(invocation.nonce),
|
|
4257
|
+
resource_bounds: invocation.resourceBounds,
|
|
4258
|
+
tip: toHex(invocation.tip),
|
|
4259
|
+
paymaster_data: invocation.paymasterData.map((it) => toHex(it)),
|
|
4260
|
+
nonce_data_availability_mode: invocation.nonceDataAvailabilityMode,
|
|
4261
|
+
fee_data_availability_mode: invocation.feeDataAvailabilityMode,
|
|
4262
|
+
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
|
|
4263
|
+
};
|
|
4264
|
+
}
|
|
4265
|
+
if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
|
|
4266
|
+
return {
|
|
4267
|
+
// v0 v1 v3
|
|
4268
|
+
type: rpcspec_0_7_exports.ETransactionType.INVOKE,
|
|
4269
|
+
// TODO: Diff between sequencer and rpc invoke type
|
|
4270
|
+
sender_address: invocation.contractAddress,
|
|
4271
|
+
calldata: CallData.toHex(invocation.calldata),
|
|
4272
|
+
version: toHex(invocation.version || defaultVersions.v3),
|
|
4273
|
+
...details
|
|
4274
|
+
};
|
|
4275
|
+
}
|
|
4276
|
+
if (invocation.type === "DECLARE" /* DECLARE */) {
|
|
4277
|
+
if (!isSierra(invocation.contract)) {
|
|
4278
|
+
return {
|
|
4279
|
+
type: invocation.type,
|
|
4280
|
+
contract_class: invocation.contract,
|
|
4281
|
+
sender_address: invocation.senderAddress,
|
|
4282
|
+
version: toHex(invocation.version || defaultVersions.v1),
|
|
4283
|
+
...details
|
|
4284
|
+
};
|
|
4285
|
+
}
|
|
4286
|
+
return {
|
|
4287
|
+
// Cairo 1 - v2 v3
|
|
4288
|
+
type: invocation.type,
|
|
4289
|
+
contract_class: {
|
|
4290
|
+
...invocation.contract,
|
|
4291
|
+
sierra_program: decompressProgram(invocation.contract.sierra_program)
|
|
4292
|
+
},
|
|
4293
|
+
compiled_class_hash: invocation.compiledClassHash || "",
|
|
4294
|
+
sender_address: invocation.senderAddress,
|
|
4295
|
+
version: toHex(invocation.version || defaultVersions.v3),
|
|
4296
|
+
...details
|
|
4297
|
+
};
|
|
4298
|
+
}
|
|
4299
|
+
if (invocation.type === "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */) {
|
|
4300
|
+
const { account_deployment_data, ...restDetails } = details;
|
|
4301
|
+
return {
|
|
4302
|
+
type: invocation.type,
|
|
4303
|
+
constructor_calldata: CallData.toHex(invocation.constructorCalldata || []),
|
|
4304
|
+
class_hash: toHex(invocation.classHash),
|
|
4305
|
+
contract_address_salt: toHex(invocation.addressSalt || 0),
|
|
4306
|
+
version: toHex(invocation.version || defaultVersions.v3),
|
|
4307
|
+
...restDetails
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
throw Error("RPC buildTransaction received unknown TransactionType");
|
|
4311
|
+
}
|
|
4312
|
+
};
|
|
4313
|
+
|
|
4314
|
+
// src/utils/responseParser/rpc.ts
|
|
4315
|
+
var RPCResponseParser = class {
|
|
4316
|
+
parseGetBlockResponse(res) {
|
|
4317
|
+
return { status: "PENDING", ...res };
|
|
4318
|
+
}
|
|
4319
|
+
parseTransactionReceipt(res) {
|
|
4320
|
+
if ("actual_fee" in res && typeof res.actual_fee === "string") {
|
|
4321
|
+
return {
|
|
4322
|
+
...res,
|
|
4323
|
+
actual_fee: {
|
|
4324
|
+
amount: res.actual_fee,
|
|
4325
|
+
unit: "FRI"
|
|
4326
|
+
}
|
|
4327
|
+
};
|
|
4328
|
+
}
|
|
4329
|
+
return res;
|
|
4330
|
+
}
|
|
4331
|
+
parseFeeEstimateResponse(res) {
|
|
4332
|
+
const val = res[0];
|
|
4333
|
+
return {
|
|
4334
|
+
overall_fee: toBigInt(val.overall_fee),
|
|
4335
|
+
gas_consumed: toBigInt(val.gas_consumed),
|
|
4336
|
+
gas_price: toBigInt(val.gas_price),
|
|
4337
|
+
unit: val.unit,
|
|
4338
|
+
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
4339
|
+
resourceBounds: estimateFeeToBounds(val)
|
|
4340
|
+
};
|
|
4341
|
+
}
|
|
4342
|
+
parseFeeEstimateBulkResponse(res) {
|
|
4343
|
+
return res.map((val) => ({
|
|
4344
|
+
overall_fee: toBigInt(val.overall_fee),
|
|
4345
|
+
gas_consumed: toBigInt(val.gas_consumed),
|
|
4346
|
+
gas_price: toBigInt(val.gas_price),
|
|
4347
|
+
unit: val.unit,
|
|
4348
|
+
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
4349
|
+
resourceBounds: estimateFeeToBounds(val)
|
|
4350
|
+
}));
|
|
4351
|
+
}
|
|
4352
|
+
parseSimulateTransactionResponse(res) {
|
|
4353
|
+
return res.map((it) => {
|
|
4354
|
+
return {
|
|
4355
|
+
...it,
|
|
4356
|
+
suggestedMaxFee: estimatedFeeToMaxFee(BigInt(it.fee_estimation.overall_fee)),
|
|
4357
|
+
resourceBounds: estimateFeeToBounds(it.fee_estimation)
|
|
4358
|
+
};
|
|
4359
|
+
});
|
|
4360
|
+
}
|
|
4361
|
+
parseContractClassResponse(res) {
|
|
4362
|
+
return {
|
|
4363
|
+
...res,
|
|
4364
|
+
abi: typeof res.abi === "string" ? JSON.parse(res.abi) : res.abi
|
|
4365
|
+
};
|
|
4366
|
+
}
|
|
4367
|
+
};
|
|
4368
|
+
|
|
4369
|
+
// src/provider/rpc.ts
|
|
4370
|
+
var RpcProvider = class {
|
|
4371
|
+
responseParser = new RPCResponseParser();
|
|
4372
|
+
channel;
|
|
4373
|
+
constructor(optionsOrProvider) {
|
|
4374
|
+
if (optionsOrProvider && "channel" in optionsOrProvider) {
|
|
4375
|
+
this.channel = optionsOrProvider.channel;
|
|
4376
|
+
} else {
|
|
4377
|
+
this.channel = new RpcChannel2({ ...optionsOrProvider, waitMode: false });
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
fetch(method, params, id = 0) {
|
|
4381
|
+
return this.channel.fetch(method, params, id);
|
|
4382
|
+
}
|
|
4383
|
+
async getChainId() {
|
|
4384
|
+
return this.channel.getChainId();
|
|
4385
|
+
}
|
|
4386
|
+
async getSpecVersion() {
|
|
4387
|
+
return this.channel.getSpecVersion();
|
|
4388
|
+
}
|
|
4389
|
+
async getNonceForAddress(contractAddress, blockIdentifier) {
|
|
4390
|
+
return this.channel.getNonceForAddress(contractAddress, blockIdentifier);
|
|
4391
|
+
}
|
|
4392
|
+
async getBlock(blockIdentifier) {
|
|
4393
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseGetBlockResponse);
|
|
4394
|
+
}
|
|
4395
|
+
/**
|
|
4396
|
+
* Get the most recent accepted block hash and number
|
|
4397
|
+
*/
|
|
4398
|
+
async getBlockLatestAccepted() {
|
|
4399
|
+
return this.channel.getBlockLatestAccepted();
|
|
4400
|
+
}
|
|
4401
|
+
/**
|
|
4402
|
+
* Get the most recent accepted block number
|
|
4403
|
+
* redundant use getBlockLatestAccepted();
|
|
4404
|
+
* @returns Number of the latest block
|
|
4405
|
+
*/
|
|
4406
|
+
async getBlockNumber() {
|
|
4407
|
+
return this.channel.getBlockNumber();
|
|
4408
|
+
}
|
|
4409
|
+
async getBlockWithTxHashes(blockIdentifier) {
|
|
4410
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier);
|
|
4411
|
+
}
|
|
4412
|
+
async getBlockWithTxs(blockIdentifier) {
|
|
4413
|
+
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
4414
|
+
}
|
|
4415
|
+
async getBlockWithReceipts(blockIdentifier) {
|
|
4416
|
+
if (this.channel instanceof rpc_0_6_exports.RpcChannel)
|
|
4417
|
+
throw new LibraryError("Unsupported method for RPC version");
|
|
4418
|
+
return this.channel.getBlockWithReceipts(blockIdentifier);
|
|
3729
4419
|
}
|
|
3730
4420
|
getStateUpdate = this.getBlockStateUpdate;
|
|
3731
4421
|
async getBlockStateUpdate(blockIdentifier) {
|
|
@@ -4443,7 +5133,7 @@ var Signer = class {
|
|
|
4443
5133
|
async signTransaction(transactions, details) {
|
|
4444
5134
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
4445
5135
|
let msgHash;
|
|
4446
|
-
if (Object.values(
|
|
5136
|
+
if (Object.values(ETransactionVersion22).includes(details.version)) {
|
|
4447
5137
|
const det = details;
|
|
4448
5138
|
msgHash = calculateInvokeTransactionHash2({
|
|
4449
5139
|
...det,
|
|
@@ -4451,7 +5141,7 @@ var Signer = class {
|
|
|
4451
5141
|
compiledCalldata,
|
|
4452
5142
|
version: det.version
|
|
4453
5143
|
});
|
|
4454
|
-
} else if (Object.values(
|
|
5144
|
+
} else if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
4455
5145
|
const det = details;
|
|
4456
5146
|
msgHash = calculateInvokeTransactionHash2({
|
|
4457
5147
|
...det,
|
|
@@ -4469,7 +5159,7 @@ var Signer = class {
|
|
|
4469
5159
|
async signDeployAccountTransaction(details) {
|
|
4470
5160
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
4471
5161
|
let msgHash;
|
|
4472
|
-
if (Object.values(
|
|
5162
|
+
if (Object.values(ETransactionVersion22).includes(details.version)) {
|
|
4473
5163
|
const det = details;
|
|
4474
5164
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
4475
5165
|
...det,
|
|
@@ -4477,7 +5167,7 @@ var Signer = class {
|
|
|
4477
5167
|
constructorCalldata: compiledConstructorCalldata,
|
|
4478
5168
|
version: det.version
|
|
4479
5169
|
});
|
|
4480
|
-
} else if (Object.values(
|
|
5170
|
+
} else if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
4481
5171
|
const det = details;
|
|
4482
5172
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
4483
5173
|
...det,
|
|
@@ -4494,13 +5184,13 @@ var Signer = class {
|
|
|
4494
5184
|
}
|
|
4495
5185
|
async signDeclareTransaction(details) {
|
|
4496
5186
|
let msgHash;
|
|
4497
|
-
if (Object.values(
|
|
5187
|
+
if (Object.values(ETransactionVersion22).includes(details.version)) {
|
|
4498
5188
|
const det = details;
|
|
4499
5189
|
msgHash = calculateDeclareTransactionHash3({
|
|
4500
5190
|
...det,
|
|
4501
5191
|
version: det.version
|
|
4502
5192
|
});
|
|
4503
|
-
} else if (Object.values(
|
|
5193
|
+
} else if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
4504
5194
|
const det = details;
|
|
4505
5195
|
msgHash = calculateDeclareTransactionHash3({
|
|
4506
5196
|
...det,
|
|
@@ -4548,7 +5238,7 @@ var EthSigner = class {
|
|
|
4548
5238
|
async signTransaction(transactions, details) {
|
|
4549
5239
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
4550
5240
|
let msgHash;
|
|
4551
|
-
if (Object.values(
|
|
5241
|
+
if (Object.values(ETransactionVersion22).includes(details.version)) {
|
|
4552
5242
|
const det = details;
|
|
4553
5243
|
msgHash = calculateInvokeTransactionHash2({
|
|
4554
5244
|
...det,
|
|
@@ -4556,7 +5246,7 @@ var EthSigner = class {
|
|
|
4556
5246
|
compiledCalldata,
|
|
4557
5247
|
version: det.version
|
|
4558
5248
|
});
|
|
4559
|
-
} else if (Object.values(
|
|
5249
|
+
} else if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
4560
5250
|
const det = details;
|
|
4561
5251
|
msgHash = calculateInvokeTransactionHash2({
|
|
4562
5252
|
...det,
|
|
@@ -4574,7 +5264,7 @@ var EthSigner = class {
|
|
|
4574
5264
|
async signDeployAccountTransaction(details) {
|
|
4575
5265
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
4576
5266
|
let msgHash;
|
|
4577
|
-
if (Object.values(
|
|
5267
|
+
if (Object.values(ETransactionVersion22).includes(details.version)) {
|
|
4578
5268
|
const det = details;
|
|
4579
5269
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
4580
5270
|
...det,
|
|
@@ -4582,7 +5272,7 @@ var EthSigner = class {
|
|
|
4582
5272
|
constructorCalldata: compiledConstructorCalldata,
|
|
4583
5273
|
version: det.version
|
|
4584
5274
|
});
|
|
4585
|
-
} else if (Object.values(
|
|
5275
|
+
} else if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
4586
5276
|
const det = details;
|
|
4587
5277
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
4588
5278
|
...det,
|
|
@@ -4599,13 +5289,13 @@ var EthSigner = class {
|
|
|
4599
5289
|
}
|
|
4600
5290
|
async signDeclareTransaction(details) {
|
|
4601
5291
|
let msgHash;
|
|
4602
|
-
if (Object.values(
|
|
5292
|
+
if (Object.values(ETransactionVersion22).includes(details.version)) {
|
|
4603
5293
|
const det = details;
|
|
4604
5294
|
msgHash = calculateDeclareTransactionHash3({
|
|
4605
5295
|
...det,
|
|
4606
5296
|
version: det.version
|
|
4607
5297
|
});
|
|
4608
|
-
} else if (Object.values(
|
|
5298
|
+
} else if (Object.values(ETransactionVersion32).includes(details.version)) {
|
|
4609
5299
|
const det = details;
|
|
4610
5300
|
msgHash = calculateDeclareTransactionHash3({
|
|
4611
5301
|
...det,
|
|
@@ -5755,6 +6445,8 @@ var number = num_exports;
|
|
|
5755
6445
|
Provider,
|
|
5756
6446
|
ProviderInterface,
|
|
5757
6447
|
RPC,
|
|
6448
|
+
RPC06,
|
|
6449
|
+
RPC07,
|
|
5758
6450
|
RpcChannel,
|
|
5759
6451
|
RpcProvider,
|
|
5760
6452
|
SIMULATION_FLAG,
|