starknet 6.7.0 → 6.9.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.
- package/CHANGELOG.md +30 -0
- package/README.md +2 -0
- package/dist/index.d.ts +1064 -1420
- package/dist/index.global.js +1335 -964
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +529 -518
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +512 -489
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -4
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -60,14 +61,13 @@ __export(src_exports, {
|
|
|
60
61
|
ReceiptTx: () => ReceiptTx,
|
|
61
62
|
RpcChannel: () => RpcChannel2,
|
|
62
63
|
RpcProvider: () => RpcProvider2,
|
|
63
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
64
64
|
Signer: () => Signer,
|
|
65
65
|
SignerInterface: () => SignerInterface,
|
|
66
66
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
67
67
|
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
68
68
|
TransactionStatus: () => TransactionStatus,
|
|
69
69
|
TransactionType: () => TransactionType,
|
|
70
|
-
TypedDataRevision: () =>
|
|
70
|
+
TypedDataRevision: () => import_starknet_types_07.TypedDataRevision,
|
|
71
71
|
UINT_128_MAX: () => UINT_128_MAX,
|
|
72
72
|
UINT_128_MIN: () => UINT_128_MIN,
|
|
73
73
|
UINT_256_HIGH_MAX: () => UINT_256_HIGH_MAX,
|
|
@@ -104,6 +104,7 @@ __export(src_exports, {
|
|
|
104
104
|
merkle: () => merkle_exports,
|
|
105
105
|
num: () => num_exports,
|
|
106
106
|
number: () => number,
|
|
107
|
+
parseCalldataField: () => parseCalldataField,
|
|
107
108
|
parseUDCEvent: () => parseUDCEvent,
|
|
108
109
|
provider: () => provider_exports,
|
|
109
110
|
selector: () => selector_exports,
|
|
@@ -141,7 +142,7 @@ __export(constants_exports, {
|
|
|
141
142
|
RPC_NODES: () => RPC_NODES,
|
|
142
143
|
StarknetChainId: () => StarknetChainId,
|
|
143
144
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
144
|
-
TRANSACTION_VERSION: () =>
|
|
145
|
+
TRANSACTION_VERSION: () => api_exports.ETransactionVersion,
|
|
145
146
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
146
147
|
UDC: () => UDC,
|
|
147
148
|
ZERO: () => ZERO,
|
|
@@ -151,22 +152,9 @@ __export(constants_exports, {
|
|
|
151
152
|
// src/types/api/index.ts
|
|
152
153
|
var api_exports = {};
|
|
153
154
|
__export(api_exports, {
|
|
154
|
-
EBlockTag: () => EBlockTag2,
|
|
155
|
-
EDAMode: () => EDAMode2,
|
|
156
|
-
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
157
|
-
ESimulationFlag: () => ESimulationFlag2,
|
|
158
|
-
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
159
|
-
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
160
|
-
ETransactionStatus: () => ETransactionStatus2,
|
|
161
|
-
ETransactionType: () => ETransactionType2,
|
|
162
|
-
ETransactionVersion: () => ETransactionVersion4,
|
|
163
|
-
ETransactionVersion2: () => ETransactionVersion22,
|
|
164
|
-
ETransactionVersion3: () => ETransactionVersion32,
|
|
165
|
-
Errors: () => errors_exports2,
|
|
166
155
|
JRPC: () => jsonrpc_exports,
|
|
167
156
|
RPCSPEC06: () => rpcspec_0_6_exports,
|
|
168
|
-
RPCSPEC07: () =>
|
|
169
|
-
SPEC: () => components_exports2
|
|
157
|
+
RPCSPEC07: () => RPCSPEC07
|
|
170
158
|
});
|
|
171
159
|
|
|
172
160
|
// src/types/api/jsonrpc/index.ts
|
|
@@ -197,40 +185,40 @@ var errors_exports = {};
|
|
|
197
185
|
var components_exports = {};
|
|
198
186
|
|
|
199
187
|
// src/types/api/rpcspec_0_6/nonspec.ts
|
|
200
|
-
var ETransactionType = /* @__PURE__ */ ((
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return
|
|
188
|
+
var ETransactionType = /* @__PURE__ */ ((ETransactionType2) => {
|
|
189
|
+
ETransactionType2["DECLARE"] = "DECLARE";
|
|
190
|
+
ETransactionType2["DEPLOY"] = "DEPLOY";
|
|
191
|
+
ETransactionType2["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
192
|
+
ETransactionType2["INVOKE"] = "INVOKE";
|
|
193
|
+
ETransactionType2["L1_HANDLER"] = "L1_HANDLER";
|
|
194
|
+
return ETransactionType2;
|
|
207
195
|
})(ETransactionType || {});
|
|
208
|
-
var ESimulationFlag = /* @__PURE__ */ ((
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return
|
|
196
|
+
var ESimulationFlag = /* @__PURE__ */ ((ESimulationFlag2) => {
|
|
197
|
+
ESimulationFlag2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
198
|
+
ESimulationFlag2["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
|
|
199
|
+
return ESimulationFlag2;
|
|
212
200
|
})(ESimulationFlag || {});
|
|
213
|
-
var ETransactionStatus = /* @__PURE__ */ ((
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return
|
|
201
|
+
var ETransactionStatus = /* @__PURE__ */ ((ETransactionStatus2) => {
|
|
202
|
+
ETransactionStatus2["RECEIVED"] = "RECEIVED";
|
|
203
|
+
ETransactionStatus2["REJECTED"] = "REJECTED";
|
|
204
|
+
ETransactionStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
205
|
+
ETransactionStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
206
|
+
return ETransactionStatus2;
|
|
219
207
|
})(ETransactionStatus || {});
|
|
220
|
-
var ETransactionFinalityStatus = /* @__PURE__ */ ((
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return
|
|
208
|
+
var ETransactionFinalityStatus = /* @__PURE__ */ ((ETransactionFinalityStatus2) => {
|
|
209
|
+
ETransactionFinalityStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
210
|
+
ETransactionFinalityStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
211
|
+
return ETransactionFinalityStatus2;
|
|
224
212
|
})(ETransactionFinalityStatus || {});
|
|
225
|
-
var ETransactionExecutionStatus = /* @__PURE__ */ ((
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return
|
|
213
|
+
var ETransactionExecutionStatus = /* @__PURE__ */ ((ETransactionExecutionStatus2) => {
|
|
214
|
+
ETransactionExecutionStatus2["SUCCEEDED"] = "SUCCEEDED";
|
|
215
|
+
ETransactionExecutionStatus2["REVERTED"] = "REVERTED";
|
|
216
|
+
return ETransactionExecutionStatus2;
|
|
229
217
|
})(ETransactionExecutionStatus || {});
|
|
230
|
-
var EBlockTag = /* @__PURE__ */ ((
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return
|
|
218
|
+
var EBlockTag = /* @__PURE__ */ ((EBlockTag2) => {
|
|
219
|
+
EBlockTag2["LATEST"] = "latest";
|
|
220
|
+
EBlockTag2["PENDING"] = "pending";
|
|
221
|
+
return EBlockTag2;
|
|
234
222
|
})(EBlockTag || {});
|
|
235
223
|
var EDataAvailabilityMode = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
|
|
236
224
|
EDataAvailabilityMode3["L1"] = "L1";
|
|
@@ -242,127 +230,35 @@ var EDAMode = /* @__PURE__ */ ((EDAMode4) => {
|
|
|
242
230
|
EDAMode4[EDAMode4["L2"] = 1] = "L2";
|
|
243
231
|
return EDAMode4;
|
|
244
232
|
})(EDAMode || {});
|
|
245
|
-
var ETransactionVersion = /* @__PURE__ */ ((
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return
|
|
233
|
+
var ETransactionVersion = /* @__PURE__ */ ((ETransactionVersion10) => {
|
|
234
|
+
ETransactionVersion10["V0"] = "0x0";
|
|
235
|
+
ETransactionVersion10["V1"] = "0x1";
|
|
236
|
+
ETransactionVersion10["V2"] = "0x2";
|
|
237
|
+
ETransactionVersion10["V3"] = "0x3";
|
|
238
|
+
ETransactionVersion10["F0"] = "0x100000000000000000000000000000000";
|
|
239
|
+
ETransactionVersion10["F1"] = "0x100000000000000000000000000000001";
|
|
240
|
+
ETransactionVersion10["F2"] = "0x100000000000000000000000000000002";
|
|
241
|
+
ETransactionVersion10["F3"] = "0x100000000000000000000000000000003";
|
|
242
|
+
return ETransactionVersion10;
|
|
255
243
|
})(ETransactionVersion || {});
|
|
256
|
-
var ETransactionVersion2 = /* @__PURE__ */ ((
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return
|
|
244
|
+
var ETransactionVersion2 = /* @__PURE__ */ ((ETransactionVersion25) => {
|
|
245
|
+
ETransactionVersion25["V0"] = "0x0";
|
|
246
|
+
ETransactionVersion25["V1"] = "0x1";
|
|
247
|
+
ETransactionVersion25["V2"] = "0x2";
|
|
248
|
+
ETransactionVersion25["F0"] = "0x100000000000000000000000000000000";
|
|
249
|
+
ETransactionVersion25["F1"] = "0x100000000000000000000000000000001";
|
|
250
|
+
ETransactionVersion25["F2"] = "0x100000000000000000000000000000002";
|
|
251
|
+
return ETransactionVersion25;
|
|
264
252
|
})(ETransactionVersion2 || {});
|
|
265
|
-
var ETransactionVersion3 = /* @__PURE__ */ ((
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return
|
|
253
|
+
var ETransactionVersion3 = /* @__PURE__ */ ((ETransactionVersion36) => {
|
|
254
|
+
ETransactionVersion36["V3"] = "0x3";
|
|
255
|
+
ETransactionVersion36["F3"] = "0x100000000000000000000000000000003";
|
|
256
|
+
return ETransactionVersion36;
|
|
269
257
|
})(ETransactionVersion3 || {});
|
|
270
258
|
|
|
271
|
-
// src/types/api/
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
EBlockTag: () => EBlockTag2,
|
|
275
|
-
EDAMode: () => EDAMode2,
|
|
276
|
-
EDataAvailabilityMode: () => EDataAvailabilityMode2,
|
|
277
|
-
ESimulationFlag: () => ESimulationFlag2,
|
|
278
|
-
ETransactionExecutionStatus: () => ETransactionExecutionStatus2,
|
|
279
|
-
ETransactionFinalityStatus: () => ETransactionFinalityStatus2,
|
|
280
|
-
ETransactionStatus: () => ETransactionStatus2,
|
|
281
|
-
ETransactionType: () => ETransactionType2,
|
|
282
|
-
ETransactionVersion: () => ETransactionVersion4,
|
|
283
|
-
ETransactionVersion2: () => ETransactionVersion22,
|
|
284
|
-
ETransactionVersion3: () => ETransactionVersion32,
|
|
285
|
-
Errors: () => errors_exports2,
|
|
286
|
-
SPEC: () => components_exports2
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// src/types/api/rpcspec_0_7/errors.ts
|
|
290
|
-
var errors_exports2 = {};
|
|
291
|
-
|
|
292
|
-
// src/types/api/rpcspec_0_7/components.ts
|
|
293
|
-
var components_exports2 = {};
|
|
294
|
-
|
|
295
|
-
// src/types/api/rpcspec_0_7/nonspec.ts
|
|
296
|
-
var ETransactionType2 = /* @__PURE__ */ ((ETransactionType3) => {
|
|
297
|
-
ETransactionType3["DECLARE"] = "DECLARE";
|
|
298
|
-
ETransactionType3["DEPLOY"] = "DEPLOY";
|
|
299
|
-
ETransactionType3["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
300
|
-
ETransactionType3["INVOKE"] = "INVOKE";
|
|
301
|
-
ETransactionType3["L1_HANDLER"] = "L1_HANDLER";
|
|
302
|
-
return ETransactionType3;
|
|
303
|
-
})(ETransactionType2 || {});
|
|
304
|
-
var ESimulationFlag2 = /* @__PURE__ */ ((ESimulationFlag3) => {
|
|
305
|
-
ESimulationFlag3["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
306
|
-
ESimulationFlag3["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
|
|
307
|
-
return ESimulationFlag3;
|
|
308
|
-
})(ESimulationFlag2 || {});
|
|
309
|
-
var ETransactionStatus2 = /* @__PURE__ */ ((ETransactionStatus3) => {
|
|
310
|
-
ETransactionStatus3["RECEIVED"] = "RECEIVED";
|
|
311
|
-
ETransactionStatus3["REJECTED"] = "REJECTED";
|
|
312
|
-
ETransactionStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
313
|
-
ETransactionStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
314
|
-
return ETransactionStatus3;
|
|
315
|
-
})(ETransactionStatus2 || {});
|
|
316
|
-
var ETransactionFinalityStatus2 = /* @__PURE__ */ ((ETransactionFinalityStatus3) => {
|
|
317
|
-
ETransactionFinalityStatus3["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
318
|
-
ETransactionFinalityStatus3["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
319
|
-
return ETransactionFinalityStatus3;
|
|
320
|
-
})(ETransactionFinalityStatus2 || {});
|
|
321
|
-
var ETransactionExecutionStatus2 = /* @__PURE__ */ ((ETransactionExecutionStatus3) => {
|
|
322
|
-
ETransactionExecutionStatus3["SUCCEEDED"] = "SUCCEEDED";
|
|
323
|
-
ETransactionExecutionStatus3["REVERTED"] = "REVERTED";
|
|
324
|
-
return ETransactionExecutionStatus3;
|
|
325
|
-
})(ETransactionExecutionStatus2 || {});
|
|
326
|
-
var EBlockTag2 = /* @__PURE__ */ ((EBlockTag3) => {
|
|
327
|
-
EBlockTag3["LATEST"] = "latest";
|
|
328
|
-
EBlockTag3["PENDING"] = "pending";
|
|
329
|
-
return EBlockTag3;
|
|
330
|
-
})(EBlockTag2 || {});
|
|
331
|
-
var EDataAvailabilityMode2 = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
|
|
332
|
-
EDataAvailabilityMode3["L1"] = "L1";
|
|
333
|
-
EDataAvailabilityMode3["L2"] = "L2";
|
|
334
|
-
return EDataAvailabilityMode3;
|
|
335
|
-
})(EDataAvailabilityMode2 || {});
|
|
336
|
-
var EDAMode2 = /* @__PURE__ */ ((EDAMode4) => {
|
|
337
|
-
EDAMode4[EDAMode4["L1"] = 0] = "L1";
|
|
338
|
-
EDAMode4[EDAMode4["L2"] = 1] = "L2";
|
|
339
|
-
return EDAMode4;
|
|
340
|
-
})(EDAMode2 || {});
|
|
341
|
-
var ETransactionVersion4 = /* @__PURE__ */ ((ETransactionVersion5) => {
|
|
342
|
-
ETransactionVersion5["V0"] = "0x0";
|
|
343
|
-
ETransactionVersion5["V1"] = "0x1";
|
|
344
|
-
ETransactionVersion5["V2"] = "0x2";
|
|
345
|
-
ETransactionVersion5["V3"] = "0x3";
|
|
346
|
-
ETransactionVersion5["F0"] = "0x100000000000000000000000000000000";
|
|
347
|
-
ETransactionVersion5["F1"] = "0x100000000000000000000000000000001";
|
|
348
|
-
ETransactionVersion5["F2"] = "0x100000000000000000000000000000002";
|
|
349
|
-
ETransactionVersion5["F3"] = "0x100000000000000000000000000000003";
|
|
350
|
-
return ETransactionVersion5;
|
|
351
|
-
})(ETransactionVersion4 || {});
|
|
352
|
-
var ETransactionVersion22 = /* @__PURE__ */ ((ETransactionVersion24) => {
|
|
353
|
-
ETransactionVersion24["V0"] = "0x0";
|
|
354
|
-
ETransactionVersion24["V1"] = "0x1";
|
|
355
|
-
ETransactionVersion24["V2"] = "0x2";
|
|
356
|
-
ETransactionVersion24["F0"] = "0x100000000000000000000000000000000";
|
|
357
|
-
ETransactionVersion24["F1"] = "0x100000000000000000000000000000001";
|
|
358
|
-
ETransactionVersion24["F2"] = "0x100000000000000000000000000000002";
|
|
359
|
-
return ETransactionVersion24;
|
|
360
|
-
})(ETransactionVersion22 || {});
|
|
361
|
-
var ETransactionVersion32 = /* @__PURE__ */ ((ETransactionVersion34) => {
|
|
362
|
-
ETransactionVersion34["V3"] = "0x3";
|
|
363
|
-
ETransactionVersion34["F3"] = "0x100000000000000000000000000000003";
|
|
364
|
-
return ETransactionVersion34;
|
|
365
|
-
})(ETransactionVersion32 || {});
|
|
259
|
+
// src/types/api/index.ts
|
|
260
|
+
var RPCSPEC07 = __toESM(require("starknet-types-07"));
|
|
261
|
+
__reExport(api_exports, require("starknet-types-07"));
|
|
366
262
|
|
|
367
263
|
// src/utils/encode.ts
|
|
368
264
|
var encode_exports = {};
|
|
@@ -453,19 +349,16 @@ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
|
|
|
453
349
|
var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
|
|
454
350
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
455
351
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
456
|
-
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
457
352
|
BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
|
|
458
353
|
return BaseUrl2;
|
|
459
354
|
})(BaseUrl || {});
|
|
460
355
|
var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
461
356
|
NetworkName2["SN_MAIN"] = "SN_MAIN";
|
|
462
|
-
NetworkName2["SN_GOERLI"] = "SN_GOERLI";
|
|
463
357
|
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
464
358
|
return NetworkName2;
|
|
465
359
|
})(NetworkName || {});
|
|
466
360
|
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
|
|
467
361
|
StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
|
|
468
|
-
StarknetChainId6["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
469
362
|
StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
470
363
|
return StarknetChainId6;
|
|
471
364
|
})(StarknetChainId || {});
|
|
@@ -489,10 +382,6 @@ var UDC = {
|
|
|
489
382
|
};
|
|
490
383
|
var RPC_DEFAULT_VERSION = "v0_7";
|
|
491
384
|
var RPC_NODES = {
|
|
492
|
-
SN_GOERLI: [
|
|
493
|
-
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
494
|
-
`https://free-rpc.nethermind.io/goerli-juno/${RPC_DEFAULT_VERSION}`
|
|
495
|
-
],
|
|
496
385
|
SN_MAIN: [
|
|
497
386
|
`https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
498
387
|
`https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`
|
|
@@ -503,6 +392,16 @@ var RPC_NODES = {
|
|
|
503
392
|
]
|
|
504
393
|
};
|
|
505
394
|
|
|
395
|
+
// src/provider/rpc.ts
|
|
396
|
+
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
397
|
+
var import_sha3 = require("@noble/hashes/sha3");
|
|
398
|
+
|
|
399
|
+
// src/channel/rpc_0_6.ts
|
|
400
|
+
var rpc_0_6_exports = {};
|
|
401
|
+
__export(rpc_0_6_exports, {
|
|
402
|
+
RpcChannel: () => RpcChannel
|
|
403
|
+
});
|
|
404
|
+
|
|
506
405
|
// src/provider/errors.ts
|
|
507
406
|
function fixStack(target, fn = target.constructor) {
|
|
508
407
|
const { captureStackTrace } = Error;
|
|
@@ -540,12 +439,6 @@ var HttpError = class extends LibraryError {
|
|
|
540
439
|
}
|
|
541
440
|
};
|
|
542
441
|
|
|
543
|
-
// src/channel/rpc_0_6.ts
|
|
544
|
-
var rpc_0_6_exports = {};
|
|
545
|
-
__export(rpc_0_6_exports, {
|
|
546
|
-
RpcChannel: () => RpcChannel
|
|
547
|
-
});
|
|
548
|
-
|
|
549
442
|
// src/types/index.ts
|
|
550
443
|
var types_exports = {};
|
|
551
444
|
__export(types_exports, {
|
|
@@ -554,23 +447,15 @@ __export(types_exports, {
|
|
|
554
447
|
EntryPointType: () => EntryPointType,
|
|
555
448
|
Literal: () => Literal,
|
|
556
449
|
RPC: () => api_exports,
|
|
557
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
558
450
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
559
451
|
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
560
452
|
TransactionStatus: () => TransactionStatus,
|
|
561
453
|
TransactionType: () => TransactionType,
|
|
562
|
-
TypedDataRevision: () =>
|
|
454
|
+
TypedDataRevision: () => import_starknet_types_07.TypedDataRevision,
|
|
563
455
|
Uint: () => Uint,
|
|
564
456
|
ValidateType: () => ValidateType
|
|
565
457
|
});
|
|
566
458
|
|
|
567
|
-
// src/types/account.ts
|
|
568
|
-
var SIMULATION_FLAG = /* @__PURE__ */ ((SIMULATION_FLAG2) => {
|
|
569
|
-
SIMULATION_FLAG2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
570
|
-
SIMULATION_FLAG2["SKIP_EXECUTE"] = "SKIP_EXECUTE";
|
|
571
|
-
return SIMULATION_FLAG2;
|
|
572
|
-
})(SIMULATION_FLAG || {});
|
|
573
|
-
|
|
574
459
|
// src/types/calldata.ts
|
|
575
460
|
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
576
461
|
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
@@ -647,7 +532,7 @@ var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
|
|
|
647
532
|
})(BlockTag || {});
|
|
648
533
|
|
|
649
534
|
// src/types/typedData.ts
|
|
650
|
-
var
|
|
535
|
+
var import_starknet_types_07 = require("starknet-types-07");
|
|
651
536
|
|
|
652
537
|
// src/utils/assert.ts
|
|
653
538
|
function assert(condition, message) {
|
|
@@ -1389,46 +1274,49 @@ var guard = {
|
|
|
1389
1274
|
}
|
|
1390
1275
|
};
|
|
1391
1276
|
function formatter(data, type, sameType) {
|
|
1392
|
-
return Object.entries(data).reduce(
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
}
|
|
1398
|
-
if (elType === "string") {
|
|
1399
|
-
if (Array.isArray(data[key])) {
|
|
1400
|
-
const arrayStr = formatter(
|
|
1401
|
-
data[key],
|
|
1402
|
-
data[key].map((_) => elType)
|
|
1403
|
-
);
|
|
1404
|
-
acc[key] = Object.values(arrayStr).join("");
|
|
1277
|
+
return Object.entries(data).reduce(
|
|
1278
|
+
(acc, [key, value]) => {
|
|
1279
|
+
const elType = sameType ?? type[key];
|
|
1280
|
+
if (!(key in type) && !sameType) {
|
|
1281
|
+
acc[key] = value;
|
|
1405
1282
|
return acc;
|
|
1406
1283
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1284
|
+
if (elType === "string") {
|
|
1285
|
+
if (Array.isArray(data[key])) {
|
|
1286
|
+
const arrayStr = formatter(
|
|
1287
|
+
data[key],
|
|
1288
|
+
data[key].map((_) => elType)
|
|
1289
|
+
);
|
|
1290
|
+
acc[key] = Object.values(arrayStr).join("");
|
|
1291
|
+
return acc;
|
|
1292
|
+
}
|
|
1293
|
+
guard.isBN(data, type, key);
|
|
1294
|
+
acc[key] = decodeShortString(value);
|
|
1295
|
+
return acc;
|
|
1296
|
+
}
|
|
1297
|
+
if (elType === "number") {
|
|
1298
|
+
guard.isBN(data, type, key);
|
|
1299
|
+
acc[key] = Number(value);
|
|
1300
|
+
return acc;
|
|
1301
|
+
}
|
|
1302
|
+
if (typeof elType === "function") {
|
|
1303
|
+
acc[key] = elType(value);
|
|
1304
|
+
return acc;
|
|
1305
|
+
}
|
|
1306
|
+
if (Array.isArray(elType)) {
|
|
1307
|
+
const arrayObj = formatter(data[key], elType, elType[0]);
|
|
1308
|
+
acc[key] = Object.values(arrayObj);
|
|
1309
|
+
return acc;
|
|
1310
|
+
}
|
|
1311
|
+
if (typeof elType === "object") {
|
|
1312
|
+
acc[key] = formatter(data[key], elType);
|
|
1313
|
+
return acc;
|
|
1314
|
+
}
|
|
1315
|
+
guard.unknown(data, type, key);
|
|
1427
1316
|
return acc;
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
}, {});
|
|
1317
|
+
},
|
|
1318
|
+
{}
|
|
1319
|
+
);
|
|
1432
1320
|
}
|
|
1433
1321
|
|
|
1434
1322
|
// src/utils/calldata/parser/parser-0-1.1.0.ts
|
|
@@ -1483,7 +1371,9 @@ var AbiParser2 = class {
|
|
|
1483
1371
|
* @returns FunctionAbi | undefined
|
|
1484
1372
|
*/
|
|
1485
1373
|
getMethod(name) {
|
|
1486
|
-
const intf = this.abi.find(
|
|
1374
|
+
const intf = this.abi.find(
|
|
1375
|
+
(it) => it.type === "interface"
|
|
1376
|
+
);
|
|
1487
1377
|
return intf.items.find((it) => it.name === name);
|
|
1488
1378
|
}
|
|
1489
1379
|
/**
|
|
@@ -2453,7 +2343,7 @@ var CallData = class _CallData {
|
|
|
2453
2343
|
* Compile contract callData with abi
|
|
2454
2344
|
* Parse the calldata by using input fields from the abi for that method
|
|
2455
2345
|
* @param method string - method name
|
|
2456
|
-
* @param
|
|
2346
|
+
* @param argsCalldata RawArgs - arguments passed to the method. Can be an array of arguments (in the order of abi definition), or an object constructed in conformity with abi (in this case, the parameter can be in a wrong order).
|
|
2457
2347
|
* @return Calldata - parsed arguments in format that contract is expecting
|
|
2458
2348
|
* @example
|
|
2459
2349
|
* ```typescript
|
|
@@ -2855,7 +2745,7 @@ function calculateInvokeTransactionHash(senderAddress, version, compiledCalldata
|
|
|
2855
2745
|
|
|
2856
2746
|
// src/utils/hash/transactionHash/index.ts
|
|
2857
2747
|
function isV3InvokeTx(args) {
|
|
2858
|
-
return [
|
|
2748
|
+
return [api_exports.ETransactionVersion.V3, api_exports.ETransactionVersion.F3].includes(
|
|
2859
2749
|
args.version
|
|
2860
2750
|
);
|
|
2861
2751
|
}
|
|
@@ -2885,7 +2775,7 @@ function calculateInvokeTransactionHash2(args) {
|
|
|
2885
2775
|
);
|
|
2886
2776
|
}
|
|
2887
2777
|
function isV3DeclareTx(args) {
|
|
2888
|
-
return [
|
|
2778
|
+
return [api_exports.ETransactionVersion.V3, api_exports.ETransactionVersion.F3].includes(
|
|
2889
2779
|
args.version
|
|
2890
2780
|
);
|
|
2891
2781
|
}
|
|
@@ -2917,7 +2807,7 @@ function calculateDeclareTransactionHash3(args) {
|
|
|
2917
2807
|
);
|
|
2918
2808
|
}
|
|
2919
2809
|
function isV3DeployAccountTx(args) {
|
|
2920
|
-
return [
|
|
2810
|
+
return [api_exports.ETransactionVersion.V3, api_exports.ETransactionVersion.F3].includes(
|
|
2921
2811
|
args.version
|
|
2922
2812
|
);
|
|
2923
2813
|
}
|
|
@@ -3212,19 +3102,19 @@ function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUN
|
|
|
3212
3102
|
};
|
|
3213
3103
|
}
|
|
3214
3104
|
function intDAM(dam) {
|
|
3215
|
-
if (dam ===
|
|
3216
|
-
return
|
|
3217
|
-
if (dam ===
|
|
3218
|
-
return
|
|
3105
|
+
if (dam === api_exports.EDataAvailabilityMode.L1)
|
|
3106
|
+
return api_exports.EDAMode.L1;
|
|
3107
|
+
if (dam === api_exports.EDataAvailabilityMode.L2)
|
|
3108
|
+
return api_exports.EDAMode.L2;
|
|
3219
3109
|
throw Error("EDAM conversion");
|
|
3220
3110
|
}
|
|
3221
3111
|
function toTransactionVersion(defaultVersion, providedVersion) {
|
|
3222
3112
|
const providedVersion0xs = providedVersion ? toHex(providedVersion) : void 0;
|
|
3223
3113
|
const defaultVersion0xs = toHex(defaultVersion);
|
|
3224
|
-
if (providedVersion && !Object.values(
|
|
3114
|
+
if (providedVersion && !Object.values(api_exports.ETransactionVersion).includes(providedVersion0xs)) {
|
|
3225
3115
|
throw Error(`providedVersion ${providedVersion} is not ETransactionVersion`);
|
|
3226
3116
|
}
|
|
3227
|
-
if (!Object.values(
|
|
3117
|
+
if (!Object.values(api_exports.ETransactionVersion).includes(defaultVersion0xs)) {
|
|
3228
3118
|
throw Error(`defaultVersion ${defaultVersion} is not ETransactionVersion`);
|
|
3229
3119
|
}
|
|
3230
3120
|
return providedVersion ? providedVersion0xs : defaultVersion0xs;
|
|
@@ -3233,14 +3123,14 @@ function toFeeVersion(providedVersion) {
|
|
|
3233
3123
|
if (!providedVersion)
|
|
3234
3124
|
return void 0;
|
|
3235
3125
|
const version = toHex(providedVersion);
|
|
3236
|
-
if (version ===
|
|
3237
|
-
return
|
|
3238
|
-
if (version ===
|
|
3239
|
-
return
|
|
3240
|
-
if (version ===
|
|
3241
|
-
return
|
|
3242
|
-
if (version ===
|
|
3243
|
-
return
|
|
3126
|
+
if (version === api_exports.ETransactionVersion.V0)
|
|
3127
|
+
return api_exports.ETransactionVersion.F0;
|
|
3128
|
+
if (version === api_exports.ETransactionVersion.V1)
|
|
3129
|
+
return api_exports.ETransactionVersion.F1;
|
|
3130
|
+
if (version === api_exports.ETransactionVersion.V2)
|
|
3131
|
+
return api_exports.ETransactionVersion.F2;
|
|
3132
|
+
if (version === api_exports.ETransactionVersion.V3)
|
|
3133
|
+
return api_exports.ETransactionVersion.F3;
|
|
3244
3134
|
throw Error(`toFeeVersion: ${version} is not supported`);
|
|
3245
3135
|
}
|
|
3246
3136
|
function v3Details(details) {
|
|
@@ -3248,16 +3138,16 @@ function v3Details(details) {
|
|
|
3248
3138
|
tip: details.tip || 0,
|
|
3249
3139
|
paymasterData: details.paymasterData || [],
|
|
3250
3140
|
accountDeploymentData: details.accountDeploymentData || [],
|
|
3251
|
-
nonceDataAvailabilityMode: details.nonceDataAvailabilityMode ||
|
|
3252
|
-
feeDataAvailabilityMode: details.feeDataAvailabilityMode ||
|
|
3141
|
+
nonceDataAvailabilityMode: details.nonceDataAvailabilityMode || api_exports.EDataAvailabilityMode.L1,
|
|
3142
|
+
feeDataAvailabilityMode: details.feeDataAvailabilityMode || api_exports.EDataAvailabilityMode.L1,
|
|
3253
3143
|
resourceBounds: details.resourceBounds ?? estimateFeeToBounds(ZERO)
|
|
3254
3144
|
};
|
|
3255
3145
|
}
|
|
3256
3146
|
function reduceV2(providedVersion) {
|
|
3257
|
-
if (providedVersion ===
|
|
3258
|
-
return
|
|
3259
|
-
if (providedVersion ===
|
|
3260
|
-
return
|
|
3147
|
+
if (providedVersion === api_exports.ETransactionVersion.F2)
|
|
3148
|
+
return api_exports.ETransactionVersion.F1;
|
|
3149
|
+
if (providedVersion === api_exports.ETransactionVersion.V2)
|
|
3150
|
+
return api_exports.ETransactionVersion.V1;
|
|
3261
3151
|
return providedVersion;
|
|
3262
3152
|
}
|
|
3263
3153
|
|
|
@@ -3303,7 +3193,7 @@ function ethRandomPrivateKey() {
|
|
|
3303
3193
|
function validateAndParseEthAddress(address) {
|
|
3304
3194
|
assertInRange(address, ZERO, 2n ** 160n - 1n, "Ethereum Address ");
|
|
3305
3195
|
const result = addHexPrefix(removeHexPrefix(toHex(address)).padStart(40, "0"));
|
|
3306
|
-
assert(result.match(/^(0x)?[0-9a-f]{40}$/), "Invalid Ethereum Address Format");
|
|
3196
|
+
assert(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
|
|
3307
3197
|
return result;
|
|
3308
3198
|
}
|
|
3309
3199
|
|
|
@@ -3355,9 +3245,10 @@ function parseContract(contract) {
|
|
|
3355
3245
|
return createSierraContractClass(parsedContract);
|
|
3356
3246
|
}
|
|
3357
3247
|
var getDefaultNodeUrl = (networkName, mute = false) => {
|
|
3358
|
-
if (!mute)
|
|
3248
|
+
if (!mute) {
|
|
3359
3249
|
console.warn("Using default public node url, please provide nodeUrl in provider options!");
|
|
3360
|
-
|
|
3250
|
+
}
|
|
3251
|
+
const nodes = RPC_NODES[networkName ?? "SN_SEPOLIA" /* SN_SEPOLIA */];
|
|
3361
3252
|
const randIdx = Math.floor(Math.random() * nodes.length);
|
|
3362
3253
|
return nodes[randIdx];
|
|
3363
3254
|
};
|
|
@@ -3380,10 +3271,14 @@ var Block = class {
|
|
|
3380
3271
|
tag = null;
|
|
3381
3272
|
setIdentifier(__identifier) {
|
|
3382
3273
|
if (isString(__identifier)) {
|
|
3383
|
-
if (
|
|
3274
|
+
if (isDecimalString(__identifier)) {
|
|
3275
|
+
this.number = parseInt(__identifier, 10);
|
|
3276
|
+
} else if (isHex(__identifier)) {
|
|
3384
3277
|
this.hash = __identifier;
|
|
3385
3278
|
} else if (validBlockTags.includes(__identifier)) {
|
|
3386
3279
|
this.tag = __identifier;
|
|
3280
|
+
} else {
|
|
3281
|
+
throw TypeError(`Block identifier unmanaged: ${__identifier}`);
|
|
3387
3282
|
}
|
|
3388
3283
|
} else if (isBigInt(__identifier)) {
|
|
3389
3284
|
this.hash = toHex(__identifier);
|
|
@@ -3392,6 +3287,9 @@ var Block = class {
|
|
|
3392
3287
|
} else {
|
|
3393
3288
|
this.tag = "pending" /* pending */;
|
|
3394
3289
|
}
|
|
3290
|
+
if (isNumber(this.number) && this.number < 0) {
|
|
3291
|
+
throw TypeError(`Block number (${this.number}) can't be negative`);
|
|
3292
|
+
}
|
|
3395
3293
|
}
|
|
3396
3294
|
constructor(_identifier) {
|
|
3397
3295
|
this.setIdentifier(_identifier);
|
|
@@ -3421,15 +3319,10 @@ var Block = class {
|
|
|
3421
3319
|
}
|
|
3422
3320
|
valueOf = () => this.number;
|
|
3423
3321
|
toString = () => this.hash;
|
|
3424
|
-
/* get sequencerIdentifier(): SequencerIdentifier {
|
|
3425
|
-
return this.hash !== null
|
|
3426
|
-
? { blockHash: this.hash as string }
|
|
3427
|
-
: { blockNumber: (this.number ?? this.tag) as BlockNumber };
|
|
3428
|
-
} */
|
|
3429
3322
|
};
|
|
3430
3323
|
function isV3Tx(details) {
|
|
3431
|
-
const version = details.version ? toHex(details.version) :
|
|
3432
|
-
return version ===
|
|
3324
|
+
const version = details.version ? toHex(details.version) : api_exports.ETransactionVersion.V3;
|
|
3325
|
+
return version === api_exports.ETransactionVersion.V3 || version === api_exports.ETransactionVersion.F3;
|
|
3433
3326
|
}
|
|
3434
3327
|
function isVersion(version, response) {
|
|
3435
3328
|
const [majorS, minorS] = version.split(".");
|
|
@@ -3544,10 +3437,10 @@ function buildUDCCall(payload, address) {
|
|
|
3544
3437
|
}
|
|
3545
3438
|
function getVersionsByType(versionType) {
|
|
3546
3439
|
return versionType === "fee" ? {
|
|
3547
|
-
v1:
|
|
3548
|
-
v2:
|
|
3549
|
-
v3:
|
|
3550
|
-
} : { v1:
|
|
3440
|
+
v1: api_exports.ETransactionVersion.F1,
|
|
3441
|
+
v2: api_exports.ETransactionVersion.F2,
|
|
3442
|
+
v3: api_exports.ETransactionVersion.F3
|
|
3443
|
+
} : { v1: api_exports.ETransactionVersion.V1, v2: api_exports.ETransactionVersion.V2, v3: api_exports.ETransactionVersion.V3 };
|
|
3551
3444
|
}
|
|
3552
3445
|
|
|
3553
3446
|
// src/channel/rpc_0_6.ts
|
|
@@ -3708,11 +3601,12 @@ var RpcChannel = class {
|
|
|
3708
3601
|
* - skipValidate (default false)<br/>
|
|
3709
3602
|
* - skipFeeCharge (default true)<br/>
|
|
3710
3603
|
*/
|
|
3711
|
-
simulateTransaction(invocations, {
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3604
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
3605
|
+
const {
|
|
3606
|
+
blockIdentifier = this.blockIdentifier,
|
|
3607
|
+
skipValidate = true,
|
|
3608
|
+
skipFeeCharge = true
|
|
3609
|
+
} = simulateTransactionOptions;
|
|
3716
3610
|
const block_id = new Block(blockIdentifier).identifier;
|
|
3717
3611
|
const simulationFlags = [];
|
|
3718
3612
|
if (skipValidate)
|
|
@@ -4035,7 +3929,6 @@ var RpcChannel = class {
|
|
|
4035
3929
|
return {
|
|
4036
3930
|
// v0 v1 v3
|
|
4037
3931
|
type: rpcspec_0_6_exports.ETransactionType.INVOKE,
|
|
4038
|
-
// TODO: Diff between sequencer and rpc invoke type
|
|
4039
3932
|
sender_address: invocation.contractAddress,
|
|
4040
3933
|
calldata: CallData.toHex(invocation.calldata),
|
|
4041
3934
|
version: toHex(invocation.version || defaultVersions.v3),
|
|
@@ -4098,10 +3991,20 @@ var RpcChannel2 = class {
|
|
|
4098
3991
|
blockIdentifier;
|
|
4099
3992
|
chainId;
|
|
4100
3993
|
specVersion;
|
|
3994
|
+
transactionRetryIntervalFallback;
|
|
4101
3995
|
waitMode;
|
|
4102
3996
|
// behave like web2 rpc and return when tx is processed
|
|
4103
3997
|
constructor(optionsOrProvider) {
|
|
4104
|
-
const {
|
|
3998
|
+
const {
|
|
3999
|
+
nodeUrl,
|
|
4000
|
+
retries,
|
|
4001
|
+
headers,
|
|
4002
|
+
blockIdentifier,
|
|
4003
|
+
chainId,
|
|
4004
|
+
specVersion,
|
|
4005
|
+
waitMode,
|
|
4006
|
+
transactionRetryIntervalFallback
|
|
4007
|
+
} = optionsOrProvider || {};
|
|
4105
4008
|
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
4106
4009
|
this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
|
|
4107
4010
|
} else if (nodeUrl) {
|
|
@@ -4116,6 +4019,10 @@ var RpcChannel2 = class {
|
|
|
4116
4019
|
this.specVersion = specVersion;
|
|
4117
4020
|
this.waitMode = waitMode || false;
|
|
4118
4021
|
this.requestId = 0;
|
|
4022
|
+
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
4023
|
+
}
|
|
4024
|
+
get transactionRetryIntervalDefault() {
|
|
4025
|
+
return this.transactionRetryIntervalFallback ?? 5e3;
|
|
4119
4026
|
}
|
|
4120
4027
|
setChainId(chainId) {
|
|
4121
4028
|
this.chainId = chainId;
|
|
@@ -4246,17 +4153,18 @@ var RpcChannel2 = class {
|
|
|
4246
4153
|
* - skipValidate (default false)<br/>
|
|
4247
4154
|
* - skipFeeCharge (default true)<br/>
|
|
4248
4155
|
*/
|
|
4249
|
-
simulateTransaction(invocations, {
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4156
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
4157
|
+
const {
|
|
4158
|
+
blockIdentifier = this.blockIdentifier,
|
|
4159
|
+
skipValidate = true,
|
|
4160
|
+
skipFeeCharge = true
|
|
4161
|
+
} = simulateTransactionOptions;
|
|
4254
4162
|
const block_id = new Block(blockIdentifier).identifier;
|
|
4255
4163
|
const simulationFlags = [];
|
|
4256
4164
|
if (skipValidate)
|
|
4257
|
-
simulationFlags.push(
|
|
4165
|
+
simulationFlags.push(RPCSPEC07.ESimulationFlag.SKIP_VALIDATE);
|
|
4258
4166
|
if (skipFeeCharge)
|
|
4259
|
-
simulationFlags.push(
|
|
4167
|
+
simulationFlags.push(RPCSPEC07.ESimulationFlag.SKIP_FEE_CHARGE);
|
|
4260
4168
|
return this.fetchEndpoint("starknet_simulateTransactions", {
|
|
4261
4169
|
block_id,
|
|
4262
4170
|
transactions: invocations.map((it) => this.buildTransaction(it)),
|
|
@@ -4268,17 +4176,17 @@ var RpcChannel2 = class {
|
|
|
4268
4176
|
let { retries } = this;
|
|
4269
4177
|
let onchain = false;
|
|
4270
4178
|
let isErrorState = false;
|
|
4271
|
-
const retryInterval = options?.retryInterval ??
|
|
4179
|
+
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
4272
4180
|
const errorStates = options?.errorStates ?? [
|
|
4273
|
-
|
|
4181
|
+
RPCSPEC07.ETransactionStatus.REJECTED
|
|
4274
4182
|
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
4275
4183
|
// should decide which behavior to keep in the future
|
|
4276
4184
|
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
4277
4185
|
];
|
|
4278
4186
|
const successStates = options?.successStates ?? [
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4187
|
+
RPCSPEC07.ETransactionExecutionStatus.SUCCEEDED,
|
|
4188
|
+
RPCSPEC07.ETransactionStatus.ACCEPTED_ON_L2,
|
|
4189
|
+
RPCSPEC07.ETransactionStatus.ACCEPTED_ON_L1
|
|
4282
4190
|
];
|
|
4283
4191
|
let txStatus;
|
|
4284
4192
|
while (!onchain) {
|
|
@@ -4363,7 +4271,7 @@ var RpcChannel2 = class {
|
|
|
4363
4271
|
let flags = {};
|
|
4364
4272
|
if (!isVersion("0.5", await this.getSpecVersion())) {
|
|
4365
4273
|
flags = {
|
|
4366
|
-
simulation_flags: skipValidate ? [
|
|
4274
|
+
simulation_flags: skipValidate ? [RPCSPEC07.ESimulationFlag.SKIP_VALIDATE] : []
|
|
4367
4275
|
};
|
|
4368
4276
|
}
|
|
4369
4277
|
return this.fetchEndpoint("starknet_estimateFee", {
|
|
@@ -4379,9 +4287,9 @@ var RpcChannel2 = class {
|
|
|
4379
4287
|
invoke_transaction: {
|
|
4380
4288
|
sender_address: functionInvocation.contractAddress,
|
|
4381
4289
|
calldata: CallData.toHex(functionInvocation.calldata),
|
|
4382
|
-
type:
|
|
4290
|
+
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
4383
4291
|
max_fee: toHex(details.maxFee || 0),
|
|
4384
|
-
version:
|
|
4292
|
+
version: RPCSPEC07.ETransactionVersion.V1,
|
|
4385
4293
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
4386
4294
|
nonce: toHex(details.nonce)
|
|
4387
4295
|
}
|
|
@@ -4389,10 +4297,10 @@ var RpcChannel2 = class {
|
|
|
4389
4297
|
} else {
|
|
4390
4298
|
promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
4391
4299
|
invoke_transaction: {
|
|
4392
|
-
type:
|
|
4300
|
+
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
4393
4301
|
sender_address: functionInvocation.contractAddress,
|
|
4394
4302
|
calldata: CallData.toHex(functionInvocation.calldata),
|
|
4395
|
-
version:
|
|
4303
|
+
version: RPCSPEC07.ETransactionVersion.V3,
|
|
4396
4304
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
4397
4305
|
nonce: toHex(details.nonce),
|
|
4398
4306
|
resource_bounds: details.resourceBounds,
|
|
@@ -4411,13 +4319,13 @@ var RpcChannel2 = class {
|
|
|
4411
4319
|
if (!isSierra(contract) && !isV3Tx(details)) {
|
|
4412
4320
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4413
4321
|
declare_transaction: {
|
|
4414
|
-
type:
|
|
4322
|
+
type: RPCSPEC07.ETransactionType.DECLARE,
|
|
4415
4323
|
contract_class: {
|
|
4416
4324
|
program: contract.program,
|
|
4417
4325
|
entry_points_by_type: contract.entry_points_by_type,
|
|
4418
4326
|
abi: contract.abi
|
|
4419
4327
|
},
|
|
4420
|
-
version:
|
|
4328
|
+
version: RPCSPEC07.ETransactionVersion.V1,
|
|
4421
4329
|
max_fee: toHex(details.maxFee || 0),
|
|
4422
4330
|
signature: signatureToHexArray(signature),
|
|
4423
4331
|
sender_address: senderAddress,
|
|
@@ -4427,7 +4335,7 @@ var RpcChannel2 = class {
|
|
|
4427
4335
|
} else if (isSierra(contract) && !isV3Tx(details)) {
|
|
4428
4336
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4429
4337
|
declare_transaction: {
|
|
4430
|
-
type:
|
|
4338
|
+
type: RPCSPEC07.ETransactionType.DECLARE,
|
|
4431
4339
|
contract_class: {
|
|
4432
4340
|
sierra_program: decompressProgram(contract.sierra_program),
|
|
4433
4341
|
contract_class_version: contract.contract_class_version,
|
|
@@ -4435,7 +4343,7 @@ var RpcChannel2 = class {
|
|
|
4435
4343
|
abi: contract.abi
|
|
4436
4344
|
},
|
|
4437
4345
|
compiled_class_hash: compiledClassHash || "",
|
|
4438
|
-
version:
|
|
4346
|
+
version: RPCSPEC07.ETransactionVersion.V2,
|
|
4439
4347
|
max_fee: toHex(details.maxFee || 0),
|
|
4440
4348
|
signature: signatureToHexArray(signature),
|
|
4441
4349
|
sender_address: senderAddress,
|
|
@@ -4445,10 +4353,10 @@ var RpcChannel2 = class {
|
|
|
4445
4353
|
} else if (isSierra(contract) && isV3Tx(details)) {
|
|
4446
4354
|
promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
4447
4355
|
declare_transaction: {
|
|
4448
|
-
type:
|
|
4356
|
+
type: RPCSPEC07.ETransactionType.DECLARE,
|
|
4449
4357
|
sender_address: senderAddress,
|
|
4450
4358
|
compiled_class_hash: compiledClassHash || "",
|
|
4451
|
-
version:
|
|
4359
|
+
version: RPCSPEC07.ETransactionVersion.V3,
|
|
4452
4360
|
signature: signatureToHexArray(signature),
|
|
4453
4361
|
nonce: toHex(details.nonce),
|
|
4454
4362
|
contract_class: {
|
|
@@ -4478,9 +4386,9 @@ var RpcChannel2 = class {
|
|
|
4478
4386
|
constructor_calldata: CallData.toHex(constructorCalldata || []),
|
|
4479
4387
|
class_hash: toHex(classHash),
|
|
4480
4388
|
contract_address_salt: toHex(addressSalt || 0),
|
|
4481
|
-
type:
|
|
4389
|
+
type: RPCSPEC07.ETransactionType.DEPLOY_ACCOUNT,
|
|
4482
4390
|
max_fee: toHex(details.maxFee || 0),
|
|
4483
|
-
version:
|
|
4391
|
+
version: RPCSPEC07.ETransactionVersion.V1,
|
|
4484
4392
|
signature: signatureToHexArray(signature),
|
|
4485
4393
|
nonce: toHex(details.nonce)
|
|
4486
4394
|
}
|
|
@@ -4488,8 +4396,8 @@ var RpcChannel2 = class {
|
|
|
4488
4396
|
} else {
|
|
4489
4397
|
promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
4490
4398
|
deploy_account_transaction: {
|
|
4491
|
-
type:
|
|
4492
|
-
version:
|
|
4399
|
+
type: RPCSPEC07.ETransactionType.DEPLOY_ACCOUNT,
|
|
4400
|
+
version: RPCSPEC07.ETransactionVersion.V3,
|
|
4493
4401
|
signature: signatureToHexArray(signature),
|
|
4494
4402
|
nonce: toHex(details.nonce),
|
|
4495
4403
|
contract_address_salt: toHex(addressSalt || 0),
|
|
@@ -4572,8 +4480,7 @@ var RpcChannel2 = class {
|
|
|
4572
4480
|
if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
|
|
4573
4481
|
return {
|
|
4574
4482
|
// v0 v1 v3
|
|
4575
|
-
type:
|
|
4576
|
-
// TODO: Diff between sequencer and rpc invoke type
|
|
4483
|
+
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
4577
4484
|
sender_address: invocation.contractAddress,
|
|
4578
4485
|
calldata: CallData.toHex(invocation.calldata),
|
|
4579
4486
|
version: toHex(invocation.version || defaultVersions.v3),
|
|
@@ -4689,6 +4596,9 @@ var RPCResponseParser = class {
|
|
|
4689
4596
|
abi: isString(res.abi) ? JSON.parse(res.abi) : res.abi
|
|
4690
4597
|
};
|
|
4691
4598
|
}
|
|
4599
|
+
parseL1GasPriceResponse(res) {
|
|
4600
|
+
return res.l1_gas_price.price_in_wei;
|
|
4601
|
+
}
|
|
4692
4602
|
};
|
|
4693
4603
|
|
|
4694
4604
|
// src/utils/transactionReceipt.ts
|
|
@@ -4787,6 +4697,63 @@ var RpcProvider = class {
|
|
|
4787
4697
|
async getBlockWithTxs(blockIdentifier) {
|
|
4788
4698
|
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
4789
4699
|
}
|
|
4700
|
+
/**
|
|
4701
|
+
* Pause the execution of the script until a specified block is created.
|
|
4702
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
4703
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
4704
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
4705
|
+
* @example
|
|
4706
|
+
* ```typescript
|
|
4707
|
+
* await myProvider.waitForBlock();
|
|
4708
|
+
* // wait the creation of the pending block
|
|
4709
|
+
* ```
|
|
4710
|
+
*/
|
|
4711
|
+
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
4712
|
+
if (blockIdentifier === "latest" /* latest */)
|
|
4713
|
+
return;
|
|
4714
|
+
const currentBlock = await this.getBlockNumber();
|
|
4715
|
+
const targetBlock = blockIdentifier === "pending" /* pending */ ? currentBlock + 1 : Number(toHex(blockIdentifier));
|
|
4716
|
+
if (targetBlock <= currentBlock)
|
|
4717
|
+
return;
|
|
4718
|
+
const { retries } = this.channel;
|
|
4719
|
+
let retriesCount = retries;
|
|
4720
|
+
let isTargetBlock = false;
|
|
4721
|
+
while (!isTargetBlock) {
|
|
4722
|
+
const currBlock = await this.getBlockNumber();
|
|
4723
|
+
if (currBlock === targetBlock) {
|
|
4724
|
+
isTargetBlock = true;
|
|
4725
|
+
} else {
|
|
4726
|
+
await wait(retryInterval);
|
|
4727
|
+
}
|
|
4728
|
+
retriesCount -= 1;
|
|
4729
|
+
if (retriesCount <= 0) {
|
|
4730
|
+
throw new Error(`waitForBlock() timed-out after ${retries} tries.`);
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4734
|
+
async getL1GasPrice(blockIdentifier) {
|
|
4735
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseL1GasPriceResponse);
|
|
4736
|
+
}
|
|
4737
|
+
async getL1MessageHash(l2TxHash) {
|
|
4738
|
+
const transaction = await this.channel.getTransactionByHash(l2TxHash);
|
|
4739
|
+
assert(transaction.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
4740
|
+
const { calldata, contract_address, entry_point_selector, nonce } = transaction;
|
|
4741
|
+
const params = [
|
|
4742
|
+
calldata[0],
|
|
4743
|
+
contract_address,
|
|
4744
|
+
nonce,
|
|
4745
|
+
entry_point_selector,
|
|
4746
|
+
calldata.length - 1,
|
|
4747
|
+
...calldata.slice(1)
|
|
4748
|
+
];
|
|
4749
|
+
const myEncode = addHexPrefix(
|
|
4750
|
+
params.reduce(
|
|
4751
|
+
(res, par) => res + removeHexPrefix(toHex(par)).padStart(64, "0"),
|
|
4752
|
+
""
|
|
4753
|
+
)
|
|
4754
|
+
);
|
|
4755
|
+
return addHexPrefix((0, import_utils2.bytesToHex)((0, import_sha3.keccak_256)(hexToBytes(myEncode))));
|
|
4756
|
+
}
|
|
4790
4757
|
async getBlockWithReceipts(blockIdentifier) {
|
|
4791
4758
|
if (this.channel instanceof rpc_0_6_exports.RpcChannel)
|
|
4792
4759
|
throw new LibraryError("Unsupported method for RPC version");
|
|
@@ -4838,7 +4805,7 @@ var RpcProvider = class {
|
|
|
4838
4805
|
}
|
|
4839
4806
|
/**
|
|
4840
4807
|
* @param invocations AccountInvocations
|
|
4841
|
-
* @param
|
|
4808
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
4842
4809
|
* - blockIdentifier<br/>
|
|
4843
4810
|
* - skipValidate (default false)<br/>
|
|
4844
4811
|
* - skipFeeCharge (default true)<br/>
|
|
@@ -5079,7 +5046,6 @@ function useEncoded(decoded) {
|
|
|
5079
5046
|
}
|
|
5080
5047
|
var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
|
|
5081
5048
|
StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
|
|
5082
|
-
StarknetIdContract2["TESTNET"] = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
|
|
5083
5049
|
StarknetIdContract2["TESTNET_SEPOLIA"] = "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7";
|
|
5084
5050
|
return StarknetIdContract2;
|
|
5085
5051
|
})(StarknetIdContract || {});
|
|
@@ -5087,8 +5053,6 @@ function getStarknetIdContract(chainId) {
|
|
|
5087
5053
|
switch (chainId) {
|
|
5088
5054
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5089
5055
|
return "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678" /* MAINNET */;
|
|
5090
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5091
|
-
return "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce" /* TESTNET */;
|
|
5092
5056
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5093
5057
|
return "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7" /* TESTNET_SEPOLIA */;
|
|
5094
5058
|
default:
|
|
@@ -5097,7 +5061,6 @@ function getStarknetIdContract(chainId) {
|
|
|
5097
5061
|
}
|
|
5098
5062
|
var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
|
|
5099
5063
|
StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
|
|
5100
|
-
StarknetIdIdentityContract2["TESTNET"] = "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d";
|
|
5101
5064
|
StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90";
|
|
5102
5065
|
return StarknetIdIdentityContract2;
|
|
5103
5066
|
})(StarknetIdIdentityContract || {});
|
|
@@ -5105,8 +5068,6 @@ function getStarknetIdIdentityContract(chainId) {
|
|
|
5105
5068
|
switch (chainId) {
|
|
5106
5069
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5107
5070
|
return "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af" /* MAINNET */;
|
|
5108
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5109
|
-
return "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d" /* TESTNET */;
|
|
5110
5071
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5111
5072
|
return "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90" /* TESTNET_SEPOLIA */;
|
|
5112
5073
|
default:
|
|
@@ -5118,8 +5079,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5118
5079
|
switch (chainId) {
|
|
5119
5080
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5120
5081
|
return StarknetIdMulticallContract;
|
|
5121
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5122
|
-
return StarknetIdMulticallContract;
|
|
5123
5082
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5124
5083
|
return StarknetIdMulticallContract;
|
|
5125
5084
|
default:
|
|
@@ -5128,7 +5087,6 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5128
5087
|
}
|
|
5129
5088
|
var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
|
|
5130
5089
|
StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
|
|
5131
|
-
StarknetIdVerifierContract2["TESTNET"] = "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11";
|
|
5132
5090
|
StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184";
|
|
5133
5091
|
return StarknetIdVerifierContract2;
|
|
5134
5092
|
})(StarknetIdVerifierContract || {});
|
|
@@ -5136,8 +5094,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
5136
5094
|
switch (chainId) {
|
|
5137
5095
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5138
5096
|
return "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf" /* MAINNET */;
|
|
5139
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5140
|
-
return "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11" /* TESTNET */;
|
|
5141
5097
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5142
5098
|
return "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184" /* TESTNET_SEPOLIA */;
|
|
5143
5099
|
default:
|
|
@@ -5146,7 +5102,6 @@ function getStarknetIdVerifierContract(chainId) {
|
|
|
5146
5102
|
}
|
|
5147
5103
|
var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
|
|
5148
5104
|
StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
|
|
5149
|
-
StarknetIdPfpContract2["TESTNET"] = "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698";
|
|
5150
5105
|
StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2";
|
|
5151
5106
|
return StarknetIdPfpContract2;
|
|
5152
5107
|
})(StarknetIdPfpContract || {});
|
|
@@ -5154,8 +5109,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
5154
5109
|
switch (chainId) {
|
|
5155
5110
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5156
5111
|
return "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7" /* MAINNET */;
|
|
5157
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5158
|
-
return "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698" /* TESTNET */;
|
|
5159
5112
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5160
5113
|
return "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2" /* TESTNET_SEPOLIA */;
|
|
5161
5114
|
default:
|
|
@@ -5166,7 +5119,6 @@ function getStarknetIdPfpContract(chainId) {
|
|
|
5166
5119
|
}
|
|
5167
5120
|
var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
|
|
5168
5121
|
StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
|
|
5169
|
-
StarknetIdPopContract2["TESTNET"] = "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106";
|
|
5170
5122
|
StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49";
|
|
5171
5123
|
return StarknetIdPopContract2;
|
|
5172
5124
|
})(StarknetIdPopContract || {});
|
|
@@ -5174,8 +5126,6 @@ function getStarknetIdPopContract(chainId) {
|
|
|
5174
5126
|
switch (chainId) {
|
|
5175
5127
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5176
5128
|
return "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4" /* MAINNET */;
|
|
5177
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
5178
|
-
return "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106" /* TESTNET */;
|
|
5179
5129
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5180
5130
|
return "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49" /* TESTNET_SEPOLIA */;
|
|
5181
5131
|
default:
|
|
@@ -5240,13 +5190,7 @@ var StarknetId = class _StarknetId {
|
|
|
5240
5190
|
const chainId = await provider.getChainId();
|
|
5241
5191
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
5242
5192
|
try {
|
|
5243
|
-
const hexDomain = await
|
|
5244
|
-
contractAddress: contract,
|
|
5245
|
-
entrypoint: "address_to_domain",
|
|
5246
|
-
calldata: CallData.compile({
|
|
5247
|
-
address
|
|
5248
|
-
})
|
|
5249
|
-
});
|
|
5193
|
+
const hexDomain = await this.executeStarkName(provider, address, contract);
|
|
5250
5194
|
const decimalDomain = hexDomain.map((element) => BigInt(element)).slice(1);
|
|
5251
5195
|
const stringDomain = useDecoded(decimalDomain);
|
|
5252
5196
|
if (!stringDomain) {
|
|
@@ -5260,6 +5204,26 @@ var StarknetId = class _StarknetId {
|
|
|
5260
5204
|
throw Error("Could not get stark name");
|
|
5261
5205
|
}
|
|
5262
5206
|
}
|
|
5207
|
+
static async executeStarkName(provider, address, contract) {
|
|
5208
|
+
try {
|
|
5209
|
+
return await provider.callContract({
|
|
5210
|
+
contractAddress: contract,
|
|
5211
|
+
entrypoint: "address_to_domain",
|
|
5212
|
+
calldata: CallData.compile({
|
|
5213
|
+
address,
|
|
5214
|
+
hint: []
|
|
5215
|
+
})
|
|
5216
|
+
});
|
|
5217
|
+
} catch (initialError) {
|
|
5218
|
+
return await provider.callContract({
|
|
5219
|
+
contractAddress: contract,
|
|
5220
|
+
entrypoint: "address_to_domain",
|
|
5221
|
+
calldata: CallData.compile({
|
|
5222
|
+
address
|
|
5223
|
+
})
|
|
5224
|
+
});
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5263
5227
|
static async getAddressFromStarkName(provider, name, StarknetIdContract2) {
|
|
5264
5228
|
const chainId = await provider.getChainId();
|
|
5265
5229
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
@@ -5284,100 +5248,111 @@ var StarknetId = class _StarknetId {
|
|
|
5284
5248
|
const popContract = StarknetIdPopContract2 ?? getStarknetIdPopContract(chainId);
|
|
5285
5249
|
const multicallAddress = StarknetIdMulticallContract2 ?? getStarknetIdMulticallContract(chainId);
|
|
5286
5250
|
try {
|
|
5287
|
-
const
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
to: dynamicFelt(contract),
|
|
5301
|
-
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5302
|
-
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5303
|
-
},
|
|
5304
|
-
{
|
|
5305
|
-
execution: execution({}),
|
|
5306
|
-
to: dynamicFelt(identityContract),
|
|
5307
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5308
|
-
calldata: [
|
|
5309
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5310
|
-
dynamicCallData(encodeShortString("twitter")),
|
|
5311
|
-
dynamicCallData(verifierContract),
|
|
5312
|
-
dynamicCallData("0")
|
|
5313
|
-
]
|
|
5314
|
-
},
|
|
5315
|
-
{
|
|
5316
|
-
execution: execution({}),
|
|
5317
|
-
to: dynamicFelt(identityContract),
|
|
5318
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5319
|
-
calldata: [
|
|
5320
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5321
|
-
dynamicCallData(encodeShortString("github")),
|
|
5322
|
-
dynamicCallData(verifierContract),
|
|
5323
|
-
dynamicCallData("0")
|
|
5324
|
-
]
|
|
5325
|
-
},
|
|
5326
|
-
{
|
|
5327
|
-
execution: execution({}),
|
|
5328
|
-
to: dynamicFelt(identityContract),
|
|
5329
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5330
|
-
calldata: [
|
|
5331
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5332
|
-
dynamicCallData(encodeShortString("discord")),
|
|
5333
|
-
dynamicCallData(verifierContract),
|
|
5334
|
-
dynamicCallData("0")
|
|
5335
|
-
]
|
|
5336
|
-
},
|
|
5337
|
-
{
|
|
5338
|
-
execution: execution({}),
|
|
5339
|
-
to: dynamicFelt(identityContract),
|
|
5340
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5341
|
-
calldata: [
|
|
5342
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5343
|
-
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5344
|
-
dynamicCallData(popContract),
|
|
5345
|
-
dynamicCallData("0")
|
|
5346
|
-
]
|
|
5347
|
-
},
|
|
5348
|
-
// PFP
|
|
5349
|
-
{
|
|
5350
|
-
execution: execution({}),
|
|
5351
|
-
to: dynamicFelt(identityContract),
|
|
5352
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5353
|
-
calldata: [
|
|
5354
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5355
|
-
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5356
|
-
dynamicCallData(pfpContract),
|
|
5357
|
-
dynamicCallData("0")
|
|
5358
|
-
]
|
|
5359
|
-
},
|
|
5360
|
-
{
|
|
5361
|
-
execution: execution({}),
|
|
5362
|
-
to: dynamicFelt(identityContract),
|
|
5363
|
-
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5364
|
-
calldata: [
|
|
5365
|
-
dynamicCallData(void 0, [1, 0]),
|
|
5366
|
-
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5367
|
-
dynamicCallData("2"),
|
|
5368
|
-
dynamicCallData(pfpContract),
|
|
5369
|
-
dynamicCallData("0")
|
|
5370
|
-
]
|
|
5371
|
-
},
|
|
5372
|
-
{
|
|
5373
|
-
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5374
|
-
to: dynamicFelt(void 0, [6, 0]),
|
|
5375
|
-
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5376
|
-
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5377
|
-
}
|
|
5378
|
-
]
|
|
5379
|
-
})
|
|
5251
|
+
const initialCalldata = [];
|
|
5252
|
+
const fallbackCalldata = [];
|
|
5253
|
+
initialCalldata.push({
|
|
5254
|
+
execution: execution({}),
|
|
5255
|
+
to: dynamicCallData(contract),
|
|
5256
|
+
selector: dynamicCallData(getSelectorFromName("address_to_domain")),
|
|
5257
|
+
calldata: [dynamicCallData(address), dynamicCallData("0")]
|
|
5258
|
+
});
|
|
5259
|
+
fallbackCalldata.push({
|
|
5260
|
+
execution: execution({}),
|
|
5261
|
+
to: dynamicCallData(contract),
|
|
5262
|
+
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
5263
|
+
calldata: [dynamicCallData(address)]
|
|
5380
5264
|
});
|
|
5265
|
+
const calls = [
|
|
5266
|
+
{
|
|
5267
|
+
execution: execution({}),
|
|
5268
|
+
to: dynamicFelt(contract),
|
|
5269
|
+
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
5270
|
+
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
5271
|
+
},
|
|
5272
|
+
{
|
|
5273
|
+
execution: execution({}),
|
|
5274
|
+
to: dynamicFelt(identityContract),
|
|
5275
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5276
|
+
calldata: [
|
|
5277
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5278
|
+
dynamicCallData(encodeShortString("twitter")),
|
|
5279
|
+
dynamicCallData(verifierContract),
|
|
5280
|
+
dynamicCallData("0")
|
|
5281
|
+
]
|
|
5282
|
+
},
|
|
5283
|
+
{
|
|
5284
|
+
execution: execution({}),
|
|
5285
|
+
to: dynamicFelt(identityContract),
|
|
5286
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5287
|
+
calldata: [
|
|
5288
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5289
|
+
dynamicCallData(encodeShortString("github")),
|
|
5290
|
+
dynamicCallData(verifierContract),
|
|
5291
|
+
dynamicCallData("0")
|
|
5292
|
+
]
|
|
5293
|
+
},
|
|
5294
|
+
{
|
|
5295
|
+
execution: execution({}),
|
|
5296
|
+
to: dynamicFelt(identityContract),
|
|
5297
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5298
|
+
calldata: [
|
|
5299
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5300
|
+
dynamicCallData(encodeShortString("discord")),
|
|
5301
|
+
dynamicCallData(verifierContract),
|
|
5302
|
+
dynamicCallData("0")
|
|
5303
|
+
]
|
|
5304
|
+
},
|
|
5305
|
+
{
|
|
5306
|
+
execution: execution({}),
|
|
5307
|
+
to: dynamicFelt(identityContract),
|
|
5308
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5309
|
+
calldata: [
|
|
5310
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5311
|
+
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
5312
|
+
dynamicCallData(popContract),
|
|
5313
|
+
dynamicCallData("0")
|
|
5314
|
+
]
|
|
5315
|
+
},
|
|
5316
|
+
// PFP
|
|
5317
|
+
{
|
|
5318
|
+
execution: execution({}),
|
|
5319
|
+
to: dynamicFelt(identityContract),
|
|
5320
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
5321
|
+
calldata: [
|
|
5322
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5323
|
+
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
5324
|
+
dynamicCallData(pfpContract),
|
|
5325
|
+
dynamicCallData("0")
|
|
5326
|
+
]
|
|
5327
|
+
},
|
|
5328
|
+
{
|
|
5329
|
+
execution: execution({}),
|
|
5330
|
+
to: dynamicFelt(identityContract),
|
|
5331
|
+
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
5332
|
+
calldata: [
|
|
5333
|
+
dynamicCallData(void 0, [1, 0]),
|
|
5334
|
+
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
5335
|
+
dynamicCallData("2"),
|
|
5336
|
+
dynamicCallData(pfpContract),
|
|
5337
|
+
dynamicCallData("0")
|
|
5338
|
+
]
|
|
5339
|
+
},
|
|
5340
|
+
{
|
|
5341
|
+
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
5342
|
+
to: dynamicFelt(void 0, [6, 0]),
|
|
5343
|
+
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
5344
|
+
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
5345
|
+
}
|
|
5346
|
+
];
|
|
5347
|
+
initialCalldata.push(...calls);
|
|
5348
|
+
fallbackCalldata.push(...calls);
|
|
5349
|
+
const data = await this.executeStarkProfile(
|
|
5350
|
+
provider,
|
|
5351
|
+
multicallAddress,
|
|
5352
|
+
"aggregate",
|
|
5353
|
+
initialCalldata,
|
|
5354
|
+
fallbackCalldata
|
|
5355
|
+
);
|
|
5381
5356
|
if (Array.isArray(data)) {
|
|
5382
5357
|
const size = parseInt(data[0], 16);
|
|
5383
5358
|
const finalArray = [];
|
|
@@ -5417,6 +5392,25 @@ var StarknetId = class _StarknetId {
|
|
|
5417
5392
|
throw Error("Could not get user stark profile data from address");
|
|
5418
5393
|
}
|
|
5419
5394
|
}
|
|
5395
|
+
static async executeStarkProfile(provider, contract, functionName, initialCalldata, fallbackCalldata) {
|
|
5396
|
+
try {
|
|
5397
|
+
return await provider.callContract({
|
|
5398
|
+
contractAddress: contract,
|
|
5399
|
+
entrypoint: functionName,
|
|
5400
|
+
calldata: CallData.compile({
|
|
5401
|
+
calls: initialCalldata
|
|
5402
|
+
})
|
|
5403
|
+
});
|
|
5404
|
+
} catch (initialError) {
|
|
5405
|
+
return await provider.callContract({
|
|
5406
|
+
contractAddress: contract,
|
|
5407
|
+
entrypoint: functionName,
|
|
5408
|
+
calldata: CallData.compile({
|
|
5409
|
+
calls: fallbackCalldata
|
|
5410
|
+
})
|
|
5411
|
+
});
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5420
5414
|
};
|
|
5421
5415
|
|
|
5422
5416
|
// src/provider/extensions/default.ts
|
|
@@ -5437,7 +5431,7 @@ var SignerInterface = class {
|
|
|
5437
5431
|
// src/utils/typedData.ts
|
|
5438
5432
|
var typedData_exports = {};
|
|
5439
5433
|
__export(typedData_exports, {
|
|
5440
|
-
TypedDataRevision: () =>
|
|
5434
|
+
TypedDataRevision: () => import_starknet_types_07.TypedDataRevision,
|
|
5441
5435
|
encodeData: () => encodeData,
|
|
5442
5436
|
encodeType: () => encodeType,
|
|
5443
5437
|
encodeValue: () => encodeValue,
|
|
@@ -5541,14 +5535,14 @@ var presetTypes = {
|
|
|
5541
5535
|
)
|
|
5542
5536
|
};
|
|
5543
5537
|
var revisionConfiguration = {
|
|
5544
|
-
[
|
|
5538
|
+
[import_starknet_types_07.TypedDataRevision.Active]: {
|
|
5545
5539
|
domain: "StarknetDomain",
|
|
5546
5540
|
hashMethod: computePoseidonHashOnElements,
|
|
5547
5541
|
hashMerkleMethod: computePoseidonHash,
|
|
5548
5542
|
escapeTypeString: (s) => `"${s}"`,
|
|
5549
5543
|
presetTypes
|
|
5550
5544
|
},
|
|
5551
|
-
[
|
|
5545
|
+
[import_starknet_types_07.TypedDataRevision.Legacy]: {
|
|
5552
5546
|
domain: "StarkNetDomain",
|
|
5553
5547
|
hashMethod: computePedersenHashOnElements,
|
|
5554
5548
|
hashMerkleMethod: computePedersenHash,
|
|
@@ -5561,10 +5555,10 @@ function assertRange(data, type, { min, max }) {
|
|
|
5561
5555
|
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
5562
5556
|
}
|
|
5563
5557
|
function identifyRevision({ types, domain }) {
|
|
5564
|
-
if (revisionConfiguration[
|
|
5565
|
-
return
|
|
5566
|
-
if (revisionConfiguration[
|
|
5567
|
-
return
|
|
5558
|
+
if (revisionConfiguration[import_starknet_types_07.TypedDataRevision.Active].domain in types && domain.revision === import_starknet_types_07.TypedDataRevision.Active)
|
|
5559
|
+
return import_starknet_types_07.TypedDataRevision.Active;
|
|
5560
|
+
if (revisionConfiguration[import_starknet_types_07.TypedDataRevision.Legacy].domain in types && (domain.revision ?? import_starknet_types_07.TypedDataRevision.Legacy) === import_starknet_types_07.TypedDataRevision.Legacy)
|
|
5561
|
+
return import_starknet_types_07.TypedDataRevision.Legacy;
|
|
5568
5562
|
return void 0;
|
|
5569
5563
|
}
|
|
5570
5564
|
function getHex(value) {
|
|
@@ -5589,10 +5583,10 @@ function prepareSelector(selector) {
|
|
|
5589
5583
|
function isMerkleTreeType(type) {
|
|
5590
5584
|
return type.type === "merkletree";
|
|
5591
5585
|
}
|
|
5592
|
-
function getDependencies(types, type, dependencies = [], contains = "", revision =
|
|
5586
|
+
function getDependencies(types, type, dependencies = [], contains = "", revision = import_starknet_types_07.TypedDataRevision.Legacy) {
|
|
5593
5587
|
if (type[type.length - 1] === "*") {
|
|
5594
5588
|
type = type.slice(0, -1);
|
|
5595
|
-
} else if (revision ===
|
|
5589
|
+
} else if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5596
5590
|
if (type === "enum") {
|
|
5597
5591
|
type = contains;
|
|
5598
5592
|
} else if (type.match(/^\(.*\)$/)) {
|
|
@@ -5630,8 +5624,8 @@ function getMerkleTreeType(types, ctx) {
|
|
|
5630
5624
|
}
|
|
5631
5625
|
return "raw";
|
|
5632
5626
|
}
|
|
5633
|
-
function encodeType(types, type, revision =
|
|
5634
|
-
const allTypes = revision ===
|
|
5627
|
+
function encodeType(types, type, revision = import_starknet_types_07.TypedDataRevision.Legacy) {
|
|
5628
|
+
const allTypes = revision === import_starknet_types_07.TypedDataRevision.Active ? { ...types, ...revisionConfiguration[revision].presetTypes } : types;
|
|
5635
5629
|
const [primary, ...dependencies] = getDependencies(
|
|
5636
5630
|
allTypes,
|
|
5637
5631
|
type,
|
|
@@ -5643,17 +5637,17 @@ function encodeType(types, type, revision = import_starknet_types.TypedDataRevis
|
|
|
5643
5637
|
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
5644
5638
|
return newTypes.map((dependency) => {
|
|
5645
5639
|
const dependencyElements = allTypes[dependency].map((t) => {
|
|
5646
|
-
const targetType = t.type === "enum" && revision ===
|
|
5640
|
+
const targetType = t.type === "enum" && revision === import_starknet_types_07.TypedDataRevision.Active ? t.contains : t.type;
|
|
5647
5641
|
const typeString = targetType.match(/^\(.*\)$/) ? `(${targetType.slice(1, -1).split(",").map((e) => e ? esc(e) : e).join(",")})` : esc(targetType);
|
|
5648
5642
|
return `${esc(t.name)}:${typeString}`;
|
|
5649
5643
|
});
|
|
5650
5644
|
return `${esc(dependency)}(${dependencyElements})`;
|
|
5651
5645
|
}).join("");
|
|
5652
5646
|
}
|
|
5653
|
-
function getTypeHash(types, type, revision =
|
|
5647
|
+
function getTypeHash(types, type, revision = import_starknet_types_07.TypedDataRevision.Legacy) {
|
|
5654
5648
|
return getSelectorFromName(encodeType(types, type, revision));
|
|
5655
5649
|
}
|
|
5656
|
-
function encodeValue(types, type, data, ctx = {}, revision =
|
|
5650
|
+
function encodeValue(types, type, data, ctx = {}, revision = import_starknet_types_07.TypedDataRevision.Legacy) {
|
|
5657
5651
|
if (types[type]) {
|
|
5658
5652
|
return [type, getStructHash(types, type, data, revision)];
|
|
5659
5653
|
}
|
|
@@ -5676,7 +5670,7 @@ function encodeValue(types, type, data, ctx = {}, revision = import_starknet_typ
|
|
|
5676
5670
|
}
|
|
5677
5671
|
switch (type) {
|
|
5678
5672
|
case "enum": {
|
|
5679
|
-
if (revision ===
|
|
5673
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5680
5674
|
const [variantKey, variantData] = Object.entries(data)[0];
|
|
5681
5675
|
const parentType = types[ctx.parent][0];
|
|
5682
5676
|
const enumType = types[parentType.contains];
|
|
@@ -5710,7 +5704,7 @@ function encodeValue(types, type, data, ctx = {}, revision = import_starknet_typ
|
|
|
5710
5704
|
return ["felt", prepareSelector(data)];
|
|
5711
5705
|
}
|
|
5712
5706
|
case "string": {
|
|
5713
|
-
if (revision ===
|
|
5707
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5714
5708
|
const byteArray = byteArrayFromString(data);
|
|
5715
5709
|
const elements = [
|
|
5716
5710
|
byteArray.data.length,
|
|
@@ -5723,7 +5717,7 @@ function encodeValue(types, type, data, ctx = {}, revision = import_starknet_typ
|
|
|
5723
5717
|
return [type, getHex(data)];
|
|
5724
5718
|
}
|
|
5725
5719
|
case "i128": {
|
|
5726
|
-
if (revision ===
|
|
5720
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5727
5721
|
const value = BigInt(data);
|
|
5728
5722
|
assertRange(value, type, RANGE_I128);
|
|
5729
5723
|
return [type, getHex(value < 0n ? PRIME + value : value)];
|
|
@@ -5732,40 +5726,40 @@ function encodeValue(types, type, data, ctx = {}, revision = import_starknet_typ
|
|
|
5732
5726
|
}
|
|
5733
5727
|
case "timestamp":
|
|
5734
5728
|
case "u128": {
|
|
5735
|
-
if (revision ===
|
|
5729
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5736
5730
|
assertRange(data, type, RANGE_U128);
|
|
5737
5731
|
}
|
|
5738
5732
|
return [type, getHex(data)];
|
|
5739
5733
|
}
|
|
5740
5734
|
case "felt":
|
|
5741
5735
|
case "shortstring": {
|
|
5742
|
-
if (revision ===
|
|
5736
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5743
5737
|
assertRange(getHex(data), type, RANGE_FELT);
|
|
5744
5738
|
}
|
|
5745
5739
|
return [type, getHex(data)];
|
|
5746
5740
|
}
|
|
5747
5741
|
case "ClassHash":
|
|
5748
5742
|
case "ContractAddress": {
|
|
5749
|
-
if (revision ===
|
|
5743
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5750
5744
|
assertRange(data, type, RANGE_FELT);
|
|
5751
5745
|
}
|
|
5752
5746
|
return [type, getHex(data)];
|
|
5753
5747
|
}
|
|
5754
5748
|
case "bool": {
|
|
5755
|
-
if (revision ===
|
|
5749
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5756
5750
|
assert(typeof data === "boolean", `Type mismatch for ${type} ${data}`);
|
|
5757
5751
|
}
|
|
5758
5752
|
return [type, getHex(data)];
|
|
5759
5753
|
}
|
|
5760
5754
|
default: {
|
|
5761
|
-
if (revision ===
|
|
5755
|
+
if (revision === import_starknet_types_07.TypedDataRevision.Active) {
|
|
5762
5756
|
throw new Error(`Unsupported type: ${type}`);
|
|
5763
5757
|
}
|
|
5764
5758
|
return [type, getHex(data)];
|
|
5765
5759
|
}
|
|
5766
5760
|
}
|
|
5767
5761
|
}
|
|
5768
|
-
function encodeData(types, type, data, revision =
|
|
5762
|
+
function encodeData(types, type, data, revision = import_starknet_types_07.TypedDataRevision.Legacy) {
|
|
5769
5763
|
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
5770
5764
|
const [returnTypes, values] = targetType.reduce(
|
|
5771
5765
|
([ts, vs], field) => {
|
|
@@ -5784,7 +5778,7 @@ function encodeData(types, type, data, revision = import_starknet_types.TypedDat
|
|
|
5784
5778
|
);
|
|
5785
5779
|
return [returnTypes, values];
|
|
5786
5780
|
}
|
|
5787
|
-
function getStructHash(types, type, data, revision =
|
|
5781
|
+
function getStructHash(types, type, data, revision = import_starknet_types_07.TypedDataRevision.Legacy) {
|
|
5788
5782
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
5789
5783
|
}
|
|
5790
5784
|
function getMessageHash(typedData, account) {
|
|
@@ -5818,7 +5812,7 @@ var Signer = class {
|
|
|
5818
5812
|
async signTransaction(transactions, details) {
|
|
5819
5813
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
5820
5814
|
let msgHash;
|
|
5821
|
-
if (Object.values(
|
|
5815
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5822
5816
|
const det = details;
|
|
5823
5817
|
msgHash = calculateInvokeTransactionHash2({
|
|
5824
5818
|
...det,
|
|
@@ -5826,7 +5820,7 @@ var Signer = class {
|
|
|
5826
5820
|
compiledCalldata,
|
|
5827
5821
|
version: det.version
|
|
5828
5822
|
});
|
|
5829
|
-
} else if (Object.values(
|
|
5823
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5830
5824
|
const det = details;
|
|
5831
5825
|
msgHash = calculateInvokeTransactionHash2({
|
|
5832
5826
|
...det,
|
|
@@ -5844,7 +5838,7 @@ var Signer = class {
|
|
|
5844
5838
|
async signDeployAccountTransaction(details) {
|
|
5845
5839
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
5846
5840
|
let msgHash;
|
|
5847
|
-
if (Object.values(
|
|
5841
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5848
5842
|
const det = details;
|
|
5849
5843
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5850
5844
|
...det,
|
|
@@ -5852,7 +5846,7 @@ var Signer = class {
|
|
|
5852
5846
|
constructorCalldata: compiledConstructorCalldata,
|
|
5853
5847
|
version: det.version
|
|
5854
5848
|
});
|
|
5855
|
-
} else if (Object.values(
|
|
5849
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5856
5850
|
const det = details;
|
|
5857
5851
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5858
5852
|
...det,
|
|
@@ -5869,13 +5863,13 @@ var Signer = class {
|
|
|
5869
5863
|
}
|
|
5870
5864
|
async signDeclareTransaction(details) {
|
|
5871
5865
|
let msgHash;
|
|
5872
|
-
if (Object.values(
|
|
5866
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5873
5867
|
const det = details;
|
|
5874
5868
|
msgHash = calculateDeclareTransactionHash3({
|
|
5875
5869
|
...det,
|
|
5876
5870
|
version: det.version
|
|
5877
5871
|
});
|
|
5878
|
-
} else if (Object.values(
|
|
5872
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5879
5873
|
const det = details;
|
|
5880
5874
|
msgHash = calculateDeclareTransactionHash3({
|
|
5881
5875
|
...det,
|
|
@@ -5942,7 +5936,7 @@ var EthSigner = class {
|
|
|
5942
5936
|
async signTransaction(transactions, details) {
|
|
5943
5937
|
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
5944
5938
|
let msgHash;
|
|
5945
|
-
if (Object.values(
|
|
5939
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5946
5940
|
const det = details;
|
|
5947
5941
|
msgHash = calculateInvokeTransactionHash2({
|
|
5948
5942
|
...det,
|
|
@@ -5950,7 +5944,7 @@ var EthSigner = class {
|
|
|
5950
5944
|
compiledCalldata,
|
|
5951
5945
|
version: det.version
|
|
5952
5946
|
});
|
|
5953
|
-
} else if (Object.values(
|
|
5947
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5954
5948
|
const det = details;
|
|
5955
5949
|
msgHash = calculateInvokeTransactionHash2({
|
|
5956
5950
|
...det,
|
|
@@ -5972,7 +5966,7 @@ var EthSigner = class {
|
|
|
5972
5966
|
async signDeployAccountTransaction(details) {
|
|
5973
5967
|
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
5974
5968
|
let msgHash;
|
|
5975
|
-
if (Object.values(
|
|
5969
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
5976
5970
|
const det = details;
|
|
5977
5971
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5978
5972
|
...det,
|
|
@@ -5980,7 +5974,7 @@ var EthSigner = class {
|
|
|
5980
5974
|
constructorCalldata: compiledConstructorCalldata,
|
|
5981
5975
|
version: det.version
|
|
5982
5976
|
});
|
|
5983
|
-
} else if (Object.values(
|
|
5977
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
5984
5978
|
const det = details;
|
|
5985
5979
|
msgHash = calculateDeployAccountTransactionHash3({
|
|
5986
5980
|
...det,
|
|
@@ -6001,13 +5995,13 @@ var EthSigner = class {
|
|
|
6001
5995
|
}
|
|
6002
5996
|
async signDeclareTransaction(details) {
|
|
6003
5997
|
let msgHash;
|
|
6004
|
-
if (Object.values(
|
|
5998
|
+
if (Object.values(api_exports.ETransactionVersion2).includes(details.version)) {
|
|
6005
5999
|
const det = details;
|
|
6006
6000
|
msgHash = calculateDeclareTransactionHash3({
|
|
6007
6001
|
...det,
|
|
6008
6002
|
version: det.version
|
|
6009
6003
|
});
|
|
6010
|
-
} else if (Object.values(
|
|
6004
|
+
} else if (Object.values(api_exports.ETransactionVersion3).includes(details.version)) {
|
|
6011
6005
|
const det = details;
|
|
6012
6006
|
msgHash = calculateDeclareTransactionHash3({
|
|
6013
6007
|
...det,
|
|
@@ -6071,7 +6065,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6071
6065
|
address;
|
|
6072
6066
|
cairoVersion;
|
|
6073
6067
|
transactionVersion;
|
|
6074
|
-
constructor(providerOrOptions, address, pkOrSigner, cairoVersion, transactionVersion =
|
|
6068
|
+
constructor(providerOrOptions, address, pkOrSigner, cairoVersion, transactionVersion = api_exports.ETransactionVersion.V2) {
|
|
6075
6069
|
super(providerOrOptions);
|
|
6076
6070
|
this.address = address.toLowerCase();
|
|
6077
6071
|
this.signer = isString(pkOrSigner) || pkOrSigner instanceof Uint8Array ? new Signer(pkOrSigner) : pkOrSigner;
|
|
@@ -6082,11 +6076,11 @@ var Account = class extends RpcProvider2 {
|
|
|
6082
6076
|
}
|
|
6083
6077
|
// provided version or contract based preferred transactionVersion
|
|
6084
6078
|
getPreferredVersion(type12, type3) {
|
|
6085
|
-
if (this.transactionVersion ===
|
|
6079
|
+
if (this.transactionVersion === api_exports.ETransactionVersion.V3)
|
|
6086
6080
|
return type3;
|
|
6087
|
-
if (this.transactionVersion ===
|
|
6081
|
+
if (this.transactionVersion === api_exports.ETransactionVersion.V2)
|
|
6088
6082
|
return type12;
|
|
6089
|
-
return
|
|
6083
|
+
return api_exports.ETransactionVersion.V3;
|
|
6090
6084
|
}
|
|
6091
6085
|
async getNonce(blockIdentifier) {
|
|
6092
6086
|
return super.getNonceForAddress(this.address, blockIdentifier);
|
|
@@ -6099,7 +6093,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6099
6093
|
}
|
|
6100
6094
|
}
|
|
6101
6095
|
/**
|
|
6102
|
-
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor
|
|
6096
|
+
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor.
|
|
6103
6097
|
* @param classHash if provided detects Cairo version from classHash, otherwise from the account address
|
|
6104
6098
|
*/
|
|
6105
6099
|
async getCairoVersion(classHash) {
|
|
@@ -6122,7 +6116,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6122
6116
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
6123
6117
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
6124
6118
|
const version = toTransactionVersion(
|
|
6125
|
-
this.getPreferredVersion(
|
|
6119
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.F1, api_exports.ETransactionVersion.F3),
|
|
6126
6120
|
toFeeVersion(providedVersion)
|
|
6127
6121
|
);
|
|
6128
6122
|
const chainId = await this.getChainId();
|
|
@@ -6153,7 +6147,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6153
6147
|
} = details;
|
|
6154
6148
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
6155
6149
|
const version = toTransactionVersion(
|
|
6156
|
-
!isSierra(payload.contract) ?
|
|
6150
|
+
!isSierra(payload.contract) ? api_exports.ETransactionVersion.F1 : this.getPreferredVersion(api_exports.ETransactionVersion.F2, api_exports.ETransactionVersion.F3),
|
|
6157
6151
|
toFeeVersion(providedVersion)
|
|
6158
6152
|
);
|
|
6159
6153
|
const chainId = await this.getChainId();
|
|
@@ -6183,7 +6177,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6183
6177
|
}, details = {}) {
|
|
6184
6178
|
const { blockIdentifier, version: providedVersion, skipValidate = true } = details;
|
|
6185
6179
|
const version = toTransactionVersion(
|
|
6186
|
-
this.getPreferredVersion(
|
|
6180
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.F1, api_exports.ETransactionVersion.F3),
|
|
6187
6181
|
toFeeVersion(providedVersion)
|
|
6188
6182
|
);
|
|
6189
6183
|
const nonce = ZERO;
|
|
@@ -6219,10 +6213,10 @@ var Account = class extends RpcProvider2 {
|
|
|
6219
6213
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
6220
6214
|
...v3Details(details),
|
|
6221
6215
|
versions: [
|
|
6222
|
-
|
|
6216
|
+
api_exports.ETransactionVersion.F1,
|
|
6223
6217
|
// non-sierra
|
|
6224
6218
|
toTransactionVersion(
|
|
6225
|
-
this.getPreferredVersion(
|
|
6219
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.F2, api_exports.ETransactionVersion.F3),
|
|
6226
6220
|
version
|
|
6227
6221
|
)
|
|
6228
6222
|
// sierra
|
|
@@ -6241,10 +6235,10 @@ var Account = class extends RpcProvider2 {
|
|
|
6241
6235
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
6242
6236
|
...v3Details(details),
|
|
6243
6237
|
versions: [
|
|
6244
|
-
|
|
6238
|
+
api_exports.ETransactionVersion.V1,
|
|
6245
6239
|
// non-sierra
|
|
6246
6240
|
toTransactionVersion(
|
|
6247
|
-
this.getPreferredVersion(
|
|
6241
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.V2, api_exports.ETransactionVersion.V3),
|
|
6248
6242
|
version
|
|
6249
6243
|
)
|
|
6250
6244
|
],
|
|
@@ -6263,7 +6257,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6263
6257
|
const calls = Array.isArray(transactions) ? transactions : [transactions];
|
|
6264
6258
|
const nonce = toBigInt(details.nonce ?? await this.getNonce());
|
|
6265
6259
|
const version = toTransactionVersion(
|
|
6266
|
-
this.getPreferredVersion(
|
|
6260
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.V1, api_exports.ETransactionVersion.V3),
|
|
6267
6261
|
// TODO: does this depend on cairo version ?
|
|
6268
6262
|
details.version
|
|
6269
6263
|
);
|
|
@@ -6321,7 +6315,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6321
6315
|
const declareContractPayload = extractContractHashes(payload);
|
|
6322
6316
|
const { nonce, version: providedVersion } = details;
|
|
6323
6317
|
const version = toTransactionVersion(
|
|
6324
|
-
!isSierra(payload.contract) ?
|
|
6318
|
+
!isSierra(payload.contract) ? api_exports.ETransactionVersion.V1 : this.getPreferredVersion(api_exports.ETransactionVersion.V2, api_exports.ETransactionVersion.V3),
|
|
6325
6319
|
providedVersion
|
|
6326
6320
|
);
|
|
6327
6321
|
const estimate = await this.getUniversalSuggestedFee(
|
|
@@ -6385,7 +6379,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6385
6379
|
contractAddress: providedContractAddress
|
|
6386
6380
|
}, details = {}) {
|
|
6387
6381
|
const version = toTransactionVersion(
|
|
6388
|
-
this.getPreferredVersion(
|
|
6382
|
+
this.getPreferredVersion(api_exports.ETransactionVersion.V1, api_exports.ETransactionVersion.V3),
|
|
6389
6383
|
details.version
|
|
6390
6384
|
);
|
|
6391
6385
|
const nonce = ZERO;
|
|
@@ -6434,32 +6428,64 @@ var Account = class extends RpcProvider2 {
|
|
|
6434
6428
|
async hashMessage(typedData) {
|
|
6435
6429
|
return getMessageHash(typedData, this.address);
|
|
6436
6430
|
}
|
|
6437
|
-
async verifyMessageHash(hash, signature) {
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6431
|
+
async verifyMessageHash(hash, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6432
|
+
const knownSigVerificationFName = signatureVerificationFunctionName ? [signatureVerificationFunctionName] : ["isValidSignature", "is_valid_signature"];
|
|
6433
|
+
const knownSignatureResponse = signatureVerificationResponse || {
|
|
6434
|
+
okResponse: [
|
|
6435
|
+
// any non-nok response is true
|
|
6436
|
+
],
|
|
6437
|
+
nokResponse: [
|
|
6438
|
+
"0x0",
|
|
6439
|
+
// Devnet
|
|
6440
|
+
"0x00"
|
|
6441
|
+
// OpenZeppelin 0.7.0 to 0.9.0 invalid signature
|
|
6442
|
+
],
|
|
6443
|
+
error: [
|
|
6444
|
+
"argent/invalid-signature",
|
|
6445
|
+
// ArgentX 0.3.0 to 0.3.1
|
|
6446
|
+
"is invalid, with respect to the public key",
|
|
6447
|
+
// OpenZeppelin until 0.6.1, Braavos 0.0.11
|
|
6448
|
+
"INVALID_SIG"
|
|
6449
|
+
// Braavos 1.0.0
|
|
6450
|
+
]
|
|
6451
|
+
};
|
|
6452
|
+
let error;
|
|
6453
|
+
for (const SigVerificationFName of knownSigVerificationFName) {
|
|
6454
|
+
try {
|
|
6455
|
+
const resp = await this.callContract({
|
|
6456
|
+
contractAddress: this.address,
|
|
6457
|
+
entrypoint: SigVerificationFName,
|
|
6458
|
+
calldata: CallData.compile({
|
|
6459
|
+
hash: toBigInt(hash).toString(),
|
|
6460
|
+
signature: formatSignature(signature)
|
|
6461
|
+
})
|
|
6462
|
+
});
|
|
6463
|
+
if (knownSignatureResponse.nokResponse.includes(resp[0].toString())) {
|
|
6464
|
+
return false;
|
|
6465
|
+
}
|
|
6466
|
+
if (knownSignatureResponse.okResponse.length === 0 || knownSignatureResponse.okResponse.includes(resp[0].toString())) {
|
|
6467
|
+
return true;
|
|
6468
|
+
}
|
|
6469
|
+
throw Error("signatureVerificationResponse Error: response is not part of known responses");
|
|
6470
|
+
} catch (err) {
|
|
6471
|
+
if (knownSignatureResponse.error.some(
|
|
6472
|
+
(errMessage) => err.message.includes(errMessage)
|
|
6473
|
+
)) {
|
|
6474
|
+
return false;
|
|
6475
|
+
}
|
|
6476
|
+
error = err;
|
|
6456
6477
|
}
|
|
6457
|
-
throw Error(`Signature verification request is rejected by the network: ${err}`);
|
|
6458
6478
|
}
|
|
6479
|
+
throw Error(`Signature verification Error: ${error}`);
|
|
6459
6480
|
}
|
|
6460
|
-
async verifyMessage(typedData, signature) {
|
|
6481
|
+
async verifyMessage(typedData, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
6461
6482
|
const hash = await this.hashMessage(typedData);
|
|
6462
|
-
return this.verifyMessageHash(
|
|
6483
|
+
return this.verifyMessageHash(
|
|
6484
|
+
hash,
|
|
6485
|
+
signature,
|
|
6486
|
+
signatureVerificationFunctionName,
|
|
6487
|
+
signatureVerificationResponse
|
|
6488
|
+
);
|
|
6463
6489
|
}
|
|
6464
6490
|
/*
|
|
6465
6491
|
* Support methods
|
|
@@ -6467,7 +6493,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6467
6493
|
async getUniversalSuggestedFee(version, { type, payload }, details) {
|
|
6468
6494
|
let maxFee = 0;
|
|
6469
6495
|
let resourceBounds = estimateFeeToBounds(ZERO);
|
|
6470
|
-
if (version ===
|
|
6496
|
+
if (version === api_exports.ETransactionVersion.V3) {
|
|
6471
6497
|
resourceBounds = details.resourceBounds ?? (await this.getSuggestedFee({ type, payload }, details)).resourceBounds;
|
|
6472
6498
|
} else {
|
|
6473
6499
|
maxFee = details.maxFee ?? (await this.getSuggestedFee({ type, payload }, details)).suggestedMaxFee;
|
|
@@ -6520,7 +6546,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6520
6546
|
async buildDeclarePayload(payload, details) {
|
|
6521
6547
|
const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
|
|
6522
6548
|
const compressedCompiledContract = parseContract(contract);
|
|
6523
|
-
if (typeof compiledClassHash === "undefined" && (details.version ===
|
|
6549
|
+
if (typeof compiledClassHash === "undefined" && (details.version === api_exports.ETransactionVersion3.F3 || details.version === api_exports.ETransactionVersion3.V3)) {
|
|
6524
6550
|
throw Error("V3 Transaction work with Cairo1 Contracts and require compiledClassHash");
|
|
6525
6551
|
}
|
|
6526
6552
|
const signature = !details.skipValidate ? await this.signer.signDeclareTransaction({
|
|
@@ -6673,7 +6699,6 @@ var AccountInterface = class extends ProviderInterface {
|
|
|
6673
6699
|
var connect_exports = {};
|
|
6674
6700
|
__export(connect_exports, {
|
|
6675
6701
|
addDeclareTransaction: () => addDeclareTransaction,
|
|
6676
|
-
addDeployAccountTransaction: () => addDeployAccountTransaction,
|
|
6677
6702
|
addInvokeTransaction: () => addInvokeTransaction,
|
|
6678
6703
|
addStarknetChain: () => addStarknetChain,
|
|
6679
6704
|
deploymentData: () => deploymentData,
|
|
@@ -6687,11 +6712,11 @@ __export(connect_exports, {
|
|
|
6687
6712
|
switchStarknetChain: () => switchStarknetChain,
|
|
6688
6713
|
watchAsset: () => watchAsset
|
|
6689
6714
|
});
|
|
6690
|
-
function requestAccounts(swo,
|
|
6715
|
+
function requestAccounts(swo, silent_mode = false) {
|
|
6691
6716
|
return swo.request({
|
|
6692
6717
|
type: "wallet_requestAccounts",
|
|
6693
6718
|
params: {
|
|
6694
|
-
|
|
6719
|
+
silent_mode
|
|
6695
6720
|
}
|
|
6696
6721
|
});
|
|
6697
6722
|
}
|
|
@@ -6726,30 +6751,24 @@ function deploymentData(swo) {
|
|
|
6726
6751
|
}
|
|
6727
6752
|
function addInvokeTransaction(swo, params) {
|
|
6728
6753
|
return swo.request({
|
|
6729
|
-
type: "
|
|
6754
|
+
type: "wallet_addInvokeTransaction",
|
|
6730
6755
|
params
|
|
6731
6756
|
});
|
|
6732
6757
|
}
|
|
6733
6758
|
function addDeclareTransaction(swo, params) {
|
|
6734
6759
|
return swo.request({
|
|
6735
|
-
type: "
|
|
6736
|
-
params
|
|
6737
|
-
});
|
|
6738
|
-
}
|
|
6739
|
-
function addDeployAccountTransaction(swo, params) {
|
|
6740
|
-
return swo.request({
|
|
6741
|
-
type: "starknet_addDeployAccountTransaction",
|
|
6760
|
+
type: "wallet_addDeclareTransaction",
|
|
6742
6761
|
params
|
|
6743
6762
|
});
|
|
6744
6763
|
}
|
|
6745
6764
|
function signMessage(swo, typedData) {
|
|
6746
6765
|
return swo.request({
|
|
6747
|
-
type: "
|
|
6766
|
+
type: "wallet_signTypedData",
|
|
6748
6767
|
params: typedData
|
|
6749
6768
|
});
|
|
6750
6769
|
}
|
|
6751
6770
|
function supportedSpecs(swo) {
|
|
6752
|
-
return swo.request({ type: "
|
|
6771
|
+
return swo.request({ type: "wallet_supportedSpecs" });
|
|
6753
6772
|
}
|
|
6754
6773
|
function onAccountChange(swo, callback) {
|
|
6755
6774
|
swo.on("accountsChanged", callback);
|
|
@@ -6778,7 +6797,7 @@ var WalletAccount = class extends Account {
|
|
|
6778
6797
|
walletProvider.request({
|
|
6779
6798
|
type: "wallet_requestAccounts",
|
|
6780
6799
|
params: {
|
|
6781
|
-
|
|
6800
|
+
silent_mode: false
|
|
6782
6801
|
}
|
|
6783
6802
|
}).then((res) => {
|
|
6784
6803
|
this.address = res[0].toLowerCase();
|
|
@@ -6819,7 +6838,7 @@ var WalletAccount = class extends Account {
|
|
|
6819
6838
|
const { contractAddress, entrypoint, calldata } = it;
|
|
6820
6839
|
return {
|
|
6821
6840
|
contract_address: contractAddress,
|
|
6822
|
-
entrypoint,
|
|
6841
|
+
entry_point: entrypoint,
|
|
6823
6842
|
calldata
|
|
6824
6843
|
};
|
|
6825
6844
|
});
|
|
@@ -6852,14 +6871,6 @@ var WalletAccount = class extends Account {
|
|
|
6852
6871
|
contract_address: addresses
|
|
6853
6872
|
};
|
|
6854
6873
|
}
|
|
6855
|
-
deployAccount(payload) {
|
|
6856
|
-
const params = {
|
|
6857
|
-
contract_address_salt: payload.addressSalt?.toString() || "0",
|
|
6858
|
-
constructor_calldata: payload.constructorCalldata ? CallData.compile(payload.constructorCalldata) : [],
|
|
6859
|
-
class_hash: payload.classHash
|
|
6860
|
-
};
|
|
6861
|
-
return addDeployAccountTransaction(this.walletProvider, params);
|
|
6862
|
-
}
|
|
6863
6874
|
signMessage(typedData) {
|
|
6864
6875
|
return signMessage(this.walletProvider, typedData);
|
|
6865
6876
|
}
|
|
@@ -7258,7 +7269,7 @@ var ContractFactory = class {
|
|
|
7258
7269
|
};
|
|
7259
7270
|
|
|
7260
7271
|
// src/utils/address.ts
|
|
7261
|
-
var
|
|
7272
|
+
var import_utils3 = require("@noble/curves/abstract/utils");
|
|
7262
7273
|
function addAddressPadding(address) {
|
|
7263
7274
|
return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, "0"));
|
|
7264
7275
|
}
|
|
@@ -7273,7 +7284,7 @@ function validateAndParseAddress(address) {
|
|
|
7273
7284
|
function getChecksumAddress(address) {
|
|
7274
7285
|
const chars = removeHexPrefix(validateAndParseAddress(address)).toLowerCase().split("");
|
|
7275
7286
|
const hex = removeHexPrefix(keccakBn(address));
|
|
7276
|
-
const hashed = (0,
|
|
7287
|
+
const hashed = (0, import_utils3.hexToBytes)(hex.padStart(64, "0"));
|
|
7277
7288
|
for (let i = 0; i < chars.length; i += 2) {
|
|
7278
7289
|
if (hashed[i >> 1] >> 4 >= 8) {
|
|
7279
7290
|
chars[i] = chars[i].toUpperCase();
|
|
@@ -7351,7 +7362,6 @@ var number = num_exports;
|
|
|
7351
7362
|
ReceiptTx,
|
|
7352
7363
|
RpcChannel,
|
|
7353
7364
|
RpcProvider,
|
|
7354
|
-
SIMULATION_FLAG,
|
|
7355
7365
|
Signer,
|
|
7356
7366
|
SignerInterface,
|
|
7357
7367
|
TransactionExecutionStatus,
|
|
@@ -7395,6 +7405,7 @@ var number = num_exports;
|
|
|
7395
7405
|
merkle,
|
|
7396
7406
|
num,
|
|
7397
7407
|
number,
|
|
7408
|
+
parseCalldataField,
|
|
7398
7409
|
parseUDCEvent,
|
|
7399
7410
|
provider,
|
|
7400
7411
|
selector,
|