starknet 6.13.0 → 6.14.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 +12 -0
- package/dist/index.d.ts +205 -185
- package/dist/index.global.js +358 -334
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +358 -334
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +358 -334
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -197,76 +197,65 @@ var errors_exports = {};
|
|
|
197
197
|
var components_exports = {};
|
|
198
198
|
|
|
199
199
|
// src/types/api/rpcspec_0_6/nonspec.ts
|
|
200
|
-
var ETransactionType =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
ETransactionVersion25["V2"] = "0x2";
|
|
260
|
-
ETransactionVersion25["F0"] = "0x100000000000000000000000000000000";
|
|
261
|
-
ETransactionVersion25["F1"] = "0x100000000000000000000000000000001";
|
|
262
|
-
ETransactionVersion25["F2"] = "0x100000000000000000000000000000002";
|
|
263
|
-
return ETransactionVersion25;
|
|
264
|
-
})(ETransactionVersion2 || {});
|
|
265
|
-
var ETransactionVersion3 = /* @__PURE__ */ ((ETransactionVersion37) => {
|
|
266
|
-
ETransactionVersion37["V3"] = "0x3";
|
|
267
|
-
ETransactionVersion37["F3"] = "0x100000000000000000000000000000003";
|
|
268
|
-
return ETransactionVersion37;
|
|
269
|
-
})(ETransactionVersion3 || {});
|
|
200
|
+
var ETransactionType = {
|
|
201
|
+
DECLARE: "DECLARE",
|
|
202
|
+
DEPLOY: "DEPLOY",
|
|
203
|
+
DEPLOY_ACCOUNT: "DEPLOY_ACCOUNT",
|
|
204
|
+
INVOKE: "INVOKE",
|
|
205
|
+
L1_HANDLER: "L1_HANDLER"
|
|
206
|
+
};
|
|
207
|
+
var ESimulationFlag = {
|
|
208
|
+
SKIP_VALIDATE: "SKIP_VALIDATE",
|
|
209
|
+
SKIP_FEE_CHARGE: "SKIP_FEE_CHARGE"
|
|
210
|
+
};
|
|
211
|
+
var ETransactionStatus = {
|
|
212
|
+
RECEIVED: "RECEIVED",
|
|
213
|
+
REJECTED: "REJECTED",
|
|
214
|
+
ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
|
|
215
|
+
ACCEPTED_ON_L1: "ACCEPTED_ON_L1"
|
|
216
|
+
};
|
|
217
|
+
var ETransactionFinalityStatus = {
|
|
218
|
+
ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
|
|
219
|
+
ACCEPTED_ON_L1: "ACCEPTED_ON_L1"
|
|
220
|
+
};
|
|
221
|
+
var ETransactionExecutionStatus = {
|
|
222
|
+
SUCCEEDED: "SUCCEEDED",
|
|
223
|
+
REVERTED: "REVERTED"
|
|
224
|
+
};
|
|
225
|
+
var EBlockTag = {
|
|
226
|
+
PENDING: "pending",
|
|
227
|
+
LATEST: "latest"
|
|
228
|
+
};
|
|
229
|
+
var EDataAvailabilityMode = {
|
|
230
|
+
L1: "L1",
|
|
231
|
+
L2: "L2"
|
|
232
|
+
};
|
|
233
|
+
var EDAMode = {
|
|
234
|
+
L1: 0,
|
|
235
|
+
L2: 1
|
|
236
|
+
};
|
|
237
|
+
var ETransactionVersion = {
|
|
238
|
+
V0: "0x0",
|
|
239
|
+
V1: "0x1",
|
|
240
|
+
V2: "0x2",
|
|
241
|
+
V3: "0x3",
|
|
242
|
+
F0: "0x100000000000000000000000000000000",
|
|
243
|
+
F1: "0x100000000000000000000000000000001",
|
|
244
|
+
F2: "0x100000000000000000000000000000002",
|
|
245
|
+
F3: "0x100000000000000000000000000000003"
|
|
246
|
+
};
|
|
247
|
+
var ETransactionVersion2 = {
|
|
248
|
+
V0: "0x0",
|
|
249
|
+
V1: "0x1",
|
|
250
|
+
V2: "0x2",
|
|
251
|
+
F0: "0x100000000000000000000000000000000",
|
|
252
|
+
F1: "0x100000000000000000000000000000001",
|
|
253
|
+
F2: "0x100000000000000000000000000000002"
|
|
254
|
+
};
|
|
255
|
+
var ETransactionVersion3 = {
|
|
256
|
+
V3: "0x3",
|
|
257
|
+
F3: "0x100000000000000000000000000000003"
|
|
258
|
+
};
|
|
270
259
|
|
|
271
260
|
// src/types/api/index.ts
|
|
272
261
|
var RPCSPEC07 = __toESM(require("starknet-types-07"));
|
|
@@ -483,79 +472,71 @@ __export(types_exports, {
|
|
|
483
472
|
});
|
|
484
473
|
|
|
485
474
|
// src/types/calldata.ts
|
|
486
|
-
var ValidateType =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
var Literal =
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
})(Literal || {});
|
|
475
|
+
var ValidateType = {
|
|
476
|
+
DEPLOY: "DEPLOY",
|
|
477
|
+
CALL: "CALL",
|
|
478
|
+
INVOKE: "INVOKE"
|
|
479
|
+
};
|
|
480
|
+
var Uint = {
|
|
481
|
+
u8: "core::integer::u8",
|
|
482
|
+
u16: "core::integer::u16",
|
|
483
|
+
u32: "core::integer::u32",
|
|
484
|
+
u64: "core::integer::u64",
|
|
485
|
+
u128: "core::integer::u128",
|
|
486
|
+
u256: "core::integer::u256",
|
|
487
|
+
// This one is struct
|
|
488
|
+
u512: "core::integer::u512"
|
|
489
|
+
// This one is struct
|
|
490
|
+
};
|
|
491
|
+
var Literal = {
|
|
492
|
+
ClassHash: "core::starknet::class_hash::ClassHash",
|
|
493
|
+
ContractAddress: "core::starknet::contract_address::ContractAddress",
|
|
494
|
+
Secp256k1Point: "core::starknet::secp256k1::Secp256k1Point"
|
|
495
|
+
};
|
|
508
496
|
|
|
509
497
|
// src/types/lib/contract/index.ts
|
|
510
|
-
var EntryPointType =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
})(EntryPointType || {});
|
|
498
|
+
var EntryPointType = {
|
|
499
|
+
EXTERNAL: "EXTERNAL",
|
|
500
|
+
L1_HANDLER: "L1_HANDLER",
|
|
501
|
+
CONSTRUCTOR: "CONSTRUCTOR"
|
|
502
|
+
};
|
|
516
503
|
|
|
517
504
|
// src/types/lib/index.ts
|
|
518
|
-
var TransactionType =
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
})(BlockStatus || {});
|
|
554
|
-
var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
|
|
555
|
-
BlockTag2["PENDING"] = "pending";
|
|
556
|
-
BlockTag2["LATEST"] = "latest";
|
|
557
|
-
return BlockTag2;
|
|
558
|
-
})(BlockTag || {});
|
|
505
|
+
var TransactionType = {
|
|
506
|
+
DECLARE: "DECLARE",
|
|
507
|
+
DEPLOY: "DEPLOY",
|
|
508
|
+
DEPLOY_ACCOUNT: "DEPLOY_ACCOUNT",
|
|
509
|
+
INVOKE: "INVOKE_FUNCTION"
|
|
510
|
+
};
|
|
511
|
+
var TransactionStatus = {
|
|
512
|
+
NOT_RECEIVED: "NOT_RECEIVED",
|
|
513
|
+
RECEIVED: "RECEIVED",
|
|
514
|
+
ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
|
|
515
|
+
ACCEPTED_ON_L1: "ACCEPTED_ON_L1",
|
|
516
|
+
REJECTED: "REJECTED",
|
|
517
|
+
REVERTED: "REVERTED"
|
|
518
|
+
};
|
|
519
|
+
var TransactionFinalityStatus = {
|
|
520
|
+
NOT_RECEIVED: "NOT_RECEIVED",
|
|
521
|
+
RECEIVED: "RECEIVED",
|
|
522
|
+
ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
|
|
523
|
+
ACCEPTED_ON_L1: "ACCEPTED_ON_L1"
|
|
524
|
+
};
|
|
525
|
+
var TransactionExecutionStatus = {
|
|
526
|
+
REJECTED: "REJECTED",
|
|
527
|
+
REVERTED: "REVERTED",
|
|
528
|
+
SUCCEEDED: "SUCCEEDED"
|
|
529
|
+
};
|
|
530
|
+
var BlockStatus = {
|
|
531
|
+
PENDING: "PENDING",
|
|
532
|
+
ACCEPTED_ON_L1: "ACCEPTED_ON_L1",
|
|
533
|
+
ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
|
|
534
|
+
REJECTED: "REJECTED"
|
|
535
|
+
};
|
|
536
|
+
var BlockTag = {
|
|
537
|
+
PENDING: "pending",
|
|
538
|
+
LATEST: "latest"
|
|
539
|
+
};
|
|
559
540
|
|
|
560
541
|
// src/types/typedData.ts
|
|
561
542
|
var import_starknet_types_07 = require("starknet-types-07");
|
|
@@ -1366,19 +1347,18 @@ var CairoCustomEnum = class {
|
|
|
1366
1347
|
};
|
|
1367
1348
|
|
|
1368
1349
|
// src/utils/calldata/enum/CairoOption.ts
|
|
1369
|
-
var CairoOptionVariant =
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
})(CairoOptionVariant || {});
|
|
1350
|
+
var CairoOptionVariant = {
|
|
1351
|
+
Some: 0,
|
|
1352
|
+
None: 1
|
|
1353
|
+
};
|
|
1374
1354
|
var CairoOption = class {
|
|
1375
1355
|
Some;
|
|
1376
1356
|
None;
|
|
1377
1357
|
constructor(variant, someContent) {
|
|
1378
|
-
if (!(variant in CairoOptionVariant)) {
|
|
1358
|
+
if (!(variant in Object.values(CairoOptionVariant))) {
|
|
1379
1359
|
throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");
|
|
1380
1360
|
}
|
|
1381
|
-
if (variant ===
|
|
1361
|
+
if (variant === CairoOptionVariant.Some) {
|
|
1382
1362
|
if (typeof someContent === "undefined") {
|
|
1383
1363
|
throw new Error(
|
|
1384
1364
|
'The creation of a Cairo Option with "Some" variant needs a content as input.'
|
|
@@ -1419,19 +1399,18 @@ var CairoOption = class {
|
|
|
1419
1399
|
};
|
|
1420
1400
|
|
|
1421
1401
|
// src/utils/calldata/enum/CairoResult.ts
|
|
1422
|
-
var CairoResultVariant =
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
})(CairoResultVariant || {});
|
|
1402
|
+
var CairoResultVariant = {
|
|
1403
|
+
Ok: 0,
|
|
1404
|
+
Err: 1
|
|
1405
|
+
};
|
|
1427
1406
|
var CairoResult = class {
|
|
1428
1407
|
Ok;
|
|
1429
1408
|
Err;
|
|
1430
1409
|
constructor(variant, resultContent) {
|
|
1431
|
-
if (!(variant in CairoResultVariant)) {
|
|
1410
|
+
if (!(variant in Object.values(CairoResultVariant))) {
|
|
1432
1411
|
throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");
|
|
1433
1412
|
}
|
|
1434
|
-
if (variant ===
|
|
1413
|
+
if (variant === CairoResultVariant.Ok) {
|
|
1435
1414
|
this.Ok = resultContent;
|
|
1436
1415
|
this.Err = void 0;
|
|
1437
1416
|
} else {
|
|
@@ -1818,12 +1797,12 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
1818
1797
|
);
|
|
1819
1798
|
if (unorderedResult.isOk()) {
|
|
1820
1799
|
return new CairoResult(
|
|
1821
|
-
|
|
1800
|
+
CairoResultVariant.Ok,
|
|
1822
1801
|
orderInput(unorderedObject2.unwrap(), resultOkType)
|
|
1823
1802
|
);
|
|
1824
1803
|
}
|
|
1825
1804
|
return new CairoResult(
|
|
1826
|
-
|
|
1805
|
+
CairoResultVariant.Err,
|
|
1827
1806
|
orderInput(unorderedObject2.unwrap(), resultErrType)
|
|
1828
1807
|
);
|
|
1829
1808
|
}
|
|
@@ -1835,11 +1814,11 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
1835
1814
|
);
|
|
1836
1815
|
if (unorderedOption.isSome()) {
|
|
1837
1816
|
return new CairoOption(
|
|
1838
|
-
|
|
1817
|
+
CairoOptionVariant.Some,
|
|
1839
1818
|
orderInput(unorderedOption.unwrap(), resultSomeType)
|
|
1840
1819
|
);
|
|
1841
1820
|
}
|
|
1842
|
-
return new CairoOption(
|
|
1821
|
+
return new CairoOption(CairoOptionVariant.None, {});
|
|
1843
1822
|
}
|
|
1844
1823
|
const unorderedCustomEnum = unorderedObject2;
|
|
1845
1824
|
const variants = Object.entries(unorderedCustomEnum.variant);
|
|
@@ -1974,7 +1953,7 @@ function parseCalldataValue(element, type, structs, enums) {
|
|
|
1974
1953
|
}
|
|
1975
1954
|
const typeVariantSome = listTypeVariant2.type;
|
|
1976
1955
|
if (typeVariantSome === "()") {
|
|
1977
|
-
return
|
|
1956
|
+
return CairoOptionVariant.Some.toString();
|
|
1978
1957
|
}
|
|
1979
1958
|
const parsedParameter2 = parseCalldataValue(
|
|
1980
1959
|
myOption.unwrap(),
|
|
@@ -1983,11 +1962,11 @@ function parseCalldataValue(element, type, structs, enums) {
|
|
|
1983
1962
|
enums
|
|
1984
1963
|
);
|
|
1985
1964
|
if (Array.isArray(parsedParameter2)) {
|
|
1986
|
-
return [
|
|
1965
|
+
return [CairoOptionVariant.Some.toString(), ...parsedParameter2];
|
|
1987
1966
|
}
|
|
1988
|
-
return [
|
|
1967
|
+
return [CairoOptionVariant.Some.toString(), parsedParameter2];
|
|
1989
1968
|
}
|
|
1990
|
-
return
|
|
1969
|
+
return CairoOptionVariant.None.toString();
|
|
1991
1970
|
}
|
|
1992
1971
|
if (isTypeResult(type)) {
|
|
1993
1972
|
const myResult = element;
|
|
@@ -1998,7 +1977,7 @@ function parseCalldataValue(element, type, structs, enums) {
|
|
|
1998
1977
|
}
|
|
1999
1978
|
const typeVariantOk = listTypeVariant3.type;
|
|
2000
1979
|
if (typeVariantOk === "()") {
|
|
2001
|
-
return
|
|
1980
|
+
return CairoResultVariant.Ok.toString();
|
|
2002
1981
|
}
|
|
2003
1982
|
const parsedParameter3 = parseCalldataValue(
|
|
2004
1983
|
myResult.unwrap(),
|
|
@@ -2007,9 +1986,9 @@ function parseCalldataValue(element, type, structs, enums) {
|
|
|
2007
1986
|
enums
|
|
2008
1987
|
);
|
|
2009
1988
|
if (Array.isArray(parsedParameter3)) {
|
|
2010
|
-
return [
|
|
1989
|
+
return [CairoResultVariant.Ok.toString(), ...parsedParameter3];
|
|
2011
1990
|
}
|
|
2012
|
-
return [
|
|
1991
|
+
return [CairoResultVariant.Ok.toString(), parsedParameter3];
|
|
2013
1992
|
}
|
|
2014
1993
|
const listTypeVariant2 = variants.find((variant) => variant.name === "Err");
|
|
2015
1994
|
if (typeof listTypeVariant2 === "undefined") {
|
|
@@ -2017,13 +1996,13 @@ function parseCalldataValue(element, type, structs, enums) {
|
|
|
2017
1996
|
}
|
|
2018
1997
|
const typeVariantErr = listTypeVariant2.type;
|
|
2019
1998
|
if (typeVariantErr === "()") {
|
|
2020
|
-
return
|
|
1999
|
+
return CairoResultVariant.Err.toString();
|
|
2021
2000
|
}
|
|
2022
2001
|
const parsedParameter2 = parseCalldataValue(myResult.unwrap(), typeVariantErr, structs, enums);
|
|
2023
2002
|
if (Array.isArray(parsedParameter2)) {
|
|
2024
|
-
return [
|
|
2003
|
+
return [CairoResultVariant.Err.toString(), ...parsedParameter2];
|
|
2025
2004
|
}
|
|
2026
|
-
return [
|
|
2005
|
+
return [CairoResultVariant.Err.toString(), parsedParameter2];
|
|
2027
2006
|
}
|
|
2028
2007
|
const myEnum = element;
|
|
2029
2008
|
const activeVariant = myEnum.activeVariant();
|
|
@@ -2188,12 +2167,12 @@ function parseResponseValue(responseIterator, element, structs, enums) {
|
|
|
2188
2167
|
return acc;
|
|
2189
2168
|
}, {});
|
|
2190
2169
|
if (element.type.startsWith("core::option::Option")) {
|
|
2191
|
-
const content = variantNum ===
|
|
2170
|
+
const content = variantNum === CairoOptionVariant.Some ? rawEnum.Some : void 0;
|
|
2192
2171
|
return new CairoOption(variantNum, content);
|
|
2193
2172
|
}
|
|
2194
2173
|
if (element.type.startsWith("core::result::Result")) {
|
|
2195
2174
|
let content;
|
|
2196
|
-
if (variantNum ===
|
|
2175
|
+
if (variantNum === CairoResultVariant.Ok) {
|
|
2197
2176
|
content = rawEnum.Ok;
|
|
2198
2177
|
} else {
|
|
2199
2178
|
content = rawEnum.Err;
|
|
@@ -2298,70 +2277,70 @@ var validateUint = (parameter, input) => {
|
|
|
2298
2277
|
);
|
|
2299
2278
|
let param;
|
|
2300
2279
|
switch (input.type) {
|
|
2301
|
-
case
|
|
2280
|
+
case Uint.u256:
|
|
2302
2281
|
param = new CairoUint256(parameter).toBigInt();
|
|
2303
2282
|
break;
|
|
2304
|
-
case
|
|
2283
|
+
case Uint.u512:
|
|
2305
2284
|
param = new CairoUint512(parameter).toBigInt();
|
|
2306
2285
|
break;
|
|
2307
2286
|
default:
|
|
2308
2287
|
param = toBigInt(parameter);
|
|
2309
2288
|
}
|
|
2310
2289
|
switch (input.type) {
|
|
2311
|
-
case
|
|
2290
|
+
case Uint.u8:
|
|
2312
2291
|
assert(
|
|
2313
2292
|
param >= 0n && param <= 255n,
|
|
2314
2293
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0 - 255]`
|
|
2315
2294
|
);
|
|
2316
2295
|
break;
|
|
2317
|
-
case
|
|
2296
|
+
case Uint.u16:
|
|
2318
2297
|
assert(
|
|
2319
2298
|
param >= 0n && param <= 65535n,
|
|
2320
2299
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 65535]`
|
|
2321
2300
|
);
|
|
2322
2301
|
break;
|
|
2323
|
-
case
|
|
2302
|
+
case Uint.u32:
|
|
2324
2303
|
assert(
|
|
2325
2304
|
param >= 0n && param <= 4294967295n,
|
|
2326
2305
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 4294967295]`
|
|
2327
2306
|
);
|
|
2328
2307
|
break;
|
|
2329
|
-
case
|
|
2308
|
+
case Uint.u64:
|
|
2330
2309
|
assert(
|
|
2331
2310
|
param >= 0n && param <= 2n ** 64n - 1n,
|
|
2332
2311
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^64-1]`
|
|
2333
2312
|
);
|
|
2334
2313
|
break;
|
|
2335
|
-
case
|
|
2314
|
+
case Uint.u128:
|
|
2336
2315
|
assert(
|
|
2337
2316
|
param >= 0n && param <= 2n ** 128n - 1n,
|
|
2338
2317
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^128-1]`
|
|
2339
2318
|
);
|
|
2340
2319
|
break;
|
|
2341
|
-
case
|
|
2320
|
+
case Uint.u256:
|
|
2342
2321
|
assert(
|
|
2343
2322
|
param >= 0n && param <= 2n ** 256n - 1n,
|
|
2344
2323
|
`Validate: arg ${input.name} is ${input.type} 0 - 2^256-1`
|
|
2345
2324
|
);
|
|
2346
2325
|
break;
|
|
2347
|
-
case
|
|
2326
|
+
case Uint.u512:
|
|
2348
2327
|
assert(CairoUint512.is(param), `Validate: arg ${input.name} is ${input.type} 0 - 2^512-1`);
|
|
2349
2328
|
break;
|
|
2350
|
-
case
|
|
2329
|
+
case Literal.ClassHash:
|
|
2351
2330
|
assert(
|
|
2352
2331
|
// from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1670
|
|
2353
2332
|
param >= 0n && param <= 2n ** 252n - 1n,
|
|
2354
2333
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
|
|
2355
2334
|
);
|
|
2356
2335
|
break;
|
|
2357
|
-
case
|
|
2336
|
+
case Literal.ContractAddress:
|
|
2358
2337
|
assert(
|
|
2359
2338
|
// from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1245
|
|
2360
2339
|
param >= 0n && param <= 2n ** 252n - 1n,
|
|
2361
2340
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
|
|
2362
2341
|
);
|
|
2363
2342
|
break;
|
|
2364
|
-
case
|
|
2343
|
+
case Literal.Secp256k1Point: {
|
|
2365
2344
|
assert(
|
|
2366
2345
|
param >= 0n && param <= 2n ** 512n - 1n,
|
|
2367
2346
|
`Validate: arg ${input.name} must be ${input.type} : a 512 bits number.`
|
|
@@ -2379,7 +2358,7 @@ var validateBool = (parameter, input) => {
|
|
|
2379
2358
|
);
|
|
2380
2359
|
};
|
|
2381
2360
|
var validateStruct = (parameter, input, structs) => {
|
|
2382
|
-
if (input.type ===
|
|
2361
|
+
if (input.type === Uint.u256 || input.type === Uint.u512) {
|
|
2383
2362
|
validateUint(parameter, input);
|
|
2384
2363
|
return;
|
|
2385
2364
|
}
|
|
@@ -2488,7 +2467,7 @@ var validateNonZero = (parameter, input) => {
|
|
|
2488
2467
|
case isTypeUint(baseType):
|
|
2489
2468
|
validateUint(parameter, { name: "", type: baseType });
|
|
2490
2469
|
switch (input.type) {
|
|
2491
|
-
case
|
|
2470
|
+
case Uint.u256:
|
|
2492
2471
|
assert(
|
|
2493
2472
|
new CairoUint256(parameter).toBigInt() > 0,
|
|
2494
2473
|
"Validate: value 0 is not authorized in NonZero uint256 type."
|
|
@@ -2571,19 +2550,19 @@ var CallData = class _CallData {
|
|
|
2571
2550
|
* @param args ArgsOrCalldata - arguments that are passed to the method
|
|
2572
2551
|
*/
|
|
2573
2552
|
validate(type, method, args = []) {
|
|
2574
|
-
if (type !==
|
|
2553
|
+
if (type !== ValidateType.DEPLOY) {
|
|
2575
2554
|
const invocableFunctionNames = this.abi.filter((abi) => {
|
|
2576
2555
|
if (abi.type !== "function") return false;
|
|
2577
2556
|
const isView = abi.stateMutability === "view" || abi.state_mutability === "view";
|
|
2578
|
-
return type ===
|
|
2557
|
+
return type === ValidateType.INVOKE ? !isView : isView;
|
|
2579
2558
|
}).map((abi) => abi.name);
|
|
2580
2559
|
assert(
|
|
2581
2560
|
invocableFunctionNames.includes(method),
|
|
2582
|
-
`${type ===
|
|
2561
|
+
`${type === ValidateType.INVOKE ? "invocable" : "viewable"} method not found in abi`
|
|
2583
2562
|
);
|
|
2584
2563
|
}
|
|
2585
2564
|
const abiMethod = this.abi.find(
|
|
2586
|
-
(abi) => type ===
|
|
2565
|
+
(abi) => type === ValidateType.DEPLOY ? abi.name === method && abi.type === "constructor" : abi.name === method && abi.type === "function"
|
|
2587
2566
|
);
|
|
2588
2567
|
if (isNoConstructorValid(method, args, abiMethod)) {
|
|
2589
2568
|
return;
|
|
@@ -2660,14 +2639,14 @@ var CallData = class _CallData {
|
|
|
2660
2639
|
const keys = [...Object.getOwnPropertyNames(value), ...methodsKeys];
|
|
2661
2640
|
if (keys.includes("isSome") && keys.includes("isNone")) {
|
|
2662
2641
|
const myOption = value;
|
|
2663
|
-
const variantNb = myOption.isSome() ?
|
|
2642
|
+
const variantNb = myOption.isSome() ? CairoOptionVariant.Some : CairoOptionVariant.None;
|
|
2664
2643
|
if (myOption.isSome())
|
|
2665
2644
|
return getEntries({ 0: variantNb, 1: myOption.unwrap() }, `${prefix}${kk}.`);
|
|
2666
2645
|
return [[`${prefix}${kk}`, felt(variantNb)]];
|
|
2667
2646
|
}
|
|
2668
2647
|
if (keys.includes("isOk") && keys.includes("isErr")) {
|
|
2669
2648
|
const myResult = value;
|
|
2670
|
-
const variantNb = myResult.isOk() ?
|
|
2649
|
+
const variantNb = myResult.isOk() ? CairoResultVariant.Ok : CairoResultVariant.Err;
|
|
2671
2650
|
return getEntries({ 0: variantNb, 1: myResult.unwrap() }, `${prefix}${kk}.`);
|
|
2672
2651
|
}
|
|
2673
2652
|
if (keys.includes("variant") && keys.includes("activeVariant")) {
|
|
@@ -3519,7 +3498,7 @@ var Block = class {
|
|
|
3519
3498
|
} else if (isNumber(__identifier)) {
|
|
3520
3499
|
this.number = __identifier;
|
|
3521
3500
|
} else {
|
|
3522
|
-
this.tag =
|
|
3501
|
+
this.tag = BlockTag.PENDING;
|
|
3523
3502
|
}
|
|
3524
3503
|
if (isNumber(this.number) && this.number < 0) {
|
|
3525
3504
|
throw TypeError(`Block number (${this.number}) can't be negative`);
|
|
@@ -3713,7 +3692,7 @@ function getVersionsByType(versionType) {
|
|
|
3713
3692
|
// src/channel/rpc_0_6.ts
|
|
3714
3693
|
var defaultOptions = {
|
|
3715
3694
|
headers: { "Content-Type": "application/json" },
|
|
3716
|
-
blockIdentifier:
|
|
3695
|
+
blockIdentifier: BlockTag.PENDING,
|
|
3717
3696
|
retries: 200
|
|
3718
3697
|
};
|
|
3719
3698
|
var RpcChannel = class {
|
|
@@ -4207,7 +4186,7 @@ var RpcChannel = class {
|
|
|
4207
4186
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
|
|
4208
4187
|
};
|
|
4209
4188
|
}
|
|
4210
|
-
if (invocation.type ===
|
|
4189
|
+
if (invocation.type === TransactionType.INVOKE) {
|
|
4211
4190
|
return {
|
|
4212
4191
|
// v0 v1 v3
|
|
4213
4192
|
type: rpcspec_0_6_exports.ETransactionType.INVOKE,
|
|
@@ -4217,7 +4196,7 @@ var RpcChannel = class {
|
|
|
4217
4196
|
...details
|
|
4218
4197
|
};
|
|
4219
4198
|
}
|
|
4220
|
-
if (invocation.type ===
|
|
4199
|
+
if (invocation.type === TransactionType.DECLARE) {
|
|
4221
4200
|
if (!isSierra(invocation.contract)) {
|
|
4222
4201
|
return {
|
|
4223
4202
|
type: invocation.type,
|
|
@@ -4240,7 +4219,7 @@ var RpcChannel = class {
|
|
|
4240
4219
|
...details
|
|
4241
4220
|
};
|
|
4242
4221
|
}
|
|
4243
|
-
if (invocation.type ===
|
|
4222
|
+
if (invocation.type === TransactionType.DEPLOY_ACCOUNT) {
|
|
4244
4223
|
const { account_deployment_data, ...restDetails } = details;
|
|
4245
4224
|
return {
|
|
4246
4225
|
type: invocation.type,
|
|
@@ -4262,7 +4241,7 @@ __export(rpc_0_7_exports, {
|
|
|
4262
4241
|
});
|
|
4263
4242
|
var defaultOptions2 = {
|
|
4264
4243
|
headers: { "Content-Type": "application/json" },
|
|
4265
|
-
blockIdentifier:
|
|
4244
|
+
blockIdentifier: BlockTag.PENDING,
|
|
4266
4245
|
retries: 200
|
|
4267
4246
|
};
|
|
4268
4247
|
var RpcChannel2 = class {
|
|
@@ -4775,7 +4754,7 @@ var RpcChannel2 = class {
|
|
|
4775
4754
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
|
|
4776
4755
|
};
|
|
4777
4756
|
}
|
|
4778
|
-
if (invocation.type ===
|
|
4757
|
+
if (invocation.type === TransactionType.INVOKE) {
|
|
4779
4758
|
return {
|
|
4780
4759
|
// v0 v1 v3
|
|
4781
4760
|
type: RPCSPEC07.ETransactionType.INVOKE,
|
|
@@ -4785,7 +4764,7 @@ var RpcChannel2 = class {
|
|
|
4785
4764
|
...details
|
|
4786
4765
|
};
|
|
4787
4766
|
}
|
|
4788
|
-
if (invocation.type ===
|
|
4767
|
+
if (invocation.type === TransactionType.DECLARE) {
|
|
4789
4768
|
if (!isSierra(invocation.contract)) {
|
|
4790
4769
|
return {
|
|
4791
4770
|
type: invocation.type,
|
|
@@ -4808,7 +4787,7 @@ var RpcChannel2 = class {
|
|
|
4808
4787
|
...details
|
|
4809
4788
|
};
|
|
4810
4789
|
}
|
|
4811
|
-
if (invocation.type ===
|
|
4790
|
+
if (invocation.type === TransactionType.DEPLOY_ACCOUNT) {
|
|
4812
4791
|
const { account_deployment_data, ...restDetails } = details;
|
|
4813
4792
|
return {
|
|
4814
4793
|
type: invocation.type,
|
|
@@ -4937,13 +4916,13 @@ var ReceiptTx = class _ReceiptTx {
|
|
|
4937
4916
|
return this.statusReceipt === "error";
|
|
4938
4917
|
}
|
|
4939
4918
|
static isSuccess(transactionReceipt) {
|
|
4940
|
-
return transactionReceipt.execution_status ===
|
|
4919
|
+
return transactionReceipt.execution_status === TransactionExecutionStatus.SUCCEEDED;
|
|
4941
4920
|
}
|
|
4942
4921
|
static isReverted(transactionReceipt) {
|
|
4943
|
-
return transactionReceipt.execution_status ===
|
|
4922
|
+
return transactionReceipt.execution_status === TransactionExecutionStatus.REVERTED;
|
|
4944
4923
|
}
|
|
4945
4924
|
static isRejected(transactionReceipt) {
|
|
4946
|
-
return transactionReceipt.status ===
|
|
4925
|
+
return transactionReceipt.status === TransactionExecutionStatus.REJECTED;
|
|
4947
4926
|
}
|
|
4948
4927
|
};
|
|
4949
4928
|
|
|
@@ -5434,9 +5413,9 @@ var RpcProvider = class {
|
|
|
5434
5413
|
* ```
|
|
5435
5414
|
*/
|
|
5436
5415
|
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
5437
|
-
if (blockIdentifier ===
|
|
5416
|
+
if (blockIdentifier === BlockTag.LATEST) return;
|
|
5438
5417
|
const currentBlock = await this.getBlockNumber();
|
|
5439
|
-
const targetBlock = blockIdentifier ===
|
|
5418
|
+
const targetBlock = blockIdentifier === BlockTag.PENDING ? currentBlock + 1 : Number(toHex(blockIdentifier));
|
|
5440
5419
|
if (targetBlock <= currentBlock) return;
|
|
5441
5420
|
const { retries } = this.channel;
|
|
5442
5421
|
let retriesCount = retries;
|
|
@@ -5492,7 +5471,7 @@ var RpcProvider = class {
|
|
|
5492
5471
|
* Utility method, same result can be achieved using getBlockWithTxHashes(BlockTag.pending);
|
|
5493
5472
|
*/
|
|
5494
5473
|
async getPendingTransactions() {
|
|
5495
|
-
const { transactions } = await this.getBlockWithTxHashes(
|
|
5474
|
+
const { transactions } = await this.getBlockWithTxHashes(BlockTag.PENDING).then(
|
|
5496
5475
|
this.responseParser.parseGetBlockResponse
|
|
5497
5476
|
);
|
|
5498
5477
|
return Promise.all(transactions.map((it) => this.getTransactionByHash(it)));
|
|
@@ -5583,7 +5562,7 @@ var RpcProvider = class {
|
|
|
5583
5562
|
return this.channel.getEstimateFee(
|
|
5584
5563
|
[
|
|
5585
5564
|
{
|
|
5586
|
-
type:
|
|
5565
|
+
type: TransactionType.INVOKE,
|
|
5587
5566
|
...invocation,
|
|
5588
5567
|
...invocationDetails
|
|
5589
5568
|
}
|
|
@@ -5595,7 +5574,7 @@ var RpcProvider = class {
|
|
|
5595
5574
|
return this.channel.getEstimateFee(
|
|
5596
5575
|
[
|
|
5597
5576
|
{
|
|
5598
|
-
type:
|
|
5577
|
+
type: TransactionType.DECLARE,
|
|
5599
5578
|
...invocation,
|
|
5600
5579
|
...details
|
|
5601
5580
|
}
|
|
@@ -5607,7 +5586,7 @@ var RpcProvider = class {
|
|
|
5607
5586
|
return this.channel.getEstimateFee(
|
|
5608
5587
|
[
|
|
5609
5588
|
{
|
|
5610
|
-
type:
|
|
5589
|
+
type: TransactionType.DEPLOY_ACCOUNT,
|
|
5611
5590
|
...invocation,
|
|
5612
5591
|
...details
|
|
5613
5592
|
}
|
|
@@ -5730,6 +5709,54 @@ var RpcProvider = class {
|
|
|
5730
5709
|
}
|
|
5731
5710
|
throw Error(`Signature verification Error: ${error}`);
|
|
5732
5711
|
}
|
|
5712
|
+
/**
|
|
5713
|
+
* Test if class is already declared from ContractClassIdentifier
|
|
5714
|
+
* Helper method using getClass
|
|
5715
|
+
* @param ContractClassIdentifier
|
|
5716
|
+
* @param blockIdentifier
|
|
5717
|
+
*/
|
|
5718
|
+
async isClassDeclared(contractClassIdentifier, blockIdentifier) {
|
|
5719
|
+
let classHash;
|
|
5720
|
+
if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
|
|
5721
|
+
const hashes = extractContractHashes(contractClassIdentifier);
|
|
5722
|
+
classHash = hashes.classHash;
|
|
5723
|
+
} else if (contractClassIdentifier.classHash) {
|
|
5724
|
+
classHash = contractClassIdentifier.classHash;
|
|
5725
|
+
} else {
|
|
5726
|
+
throw Error("contractClassIdentifier type not satisfied");
|
|
5727
|
+
}
|
|
5728
|
+
try {
|
|
5729
|
+
const result = await this.getClass(classHash, blockIdentifier);
|
|
5730
|
+
return result instanceof Object;
|
|
5731
|
+
} catch (error) {
|
|
5732
|
+
if (error instanceof LibraryError) {
|
|
5733
|
+
return false;
|
|
5734
|
+
}
|
|
5735
|
+
throw error;
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
/**
|
|
5739
|
+
* Build bulk invocations with auto-detect declared class
|
|
5740
|
+
* 1. Test if class is declared if not declare it preventing already declared class error and not declared class errors
|
|
5741
|
+
* 2. Order declarations first
|
|
5742
|
+
* @param invocations
|
|
5743
|
+
*/
|
|
5744
|
+
async prepareInvocations(invocations) {
|
|
5745
|
+
const bulk = [];
|
|
5746
|
+
for (const invocation of invocations) {
|
|
5747
|
+
if (invocation.type === TransactionType.DECLARE) {
|
|
5748
|
+
const isDeclared = await this.isClassDeclared(
|
|
5749
|
+
"payload" in invocation ? invocation.payload : invocation
|
|
5750
|
+
);
|
|
5751
|
+
if (!isDeclared) {
|
|
5752
|
+
bulk.unshift(invocation);
|
|
5753
|
+
}
|
|
5754
|
+
} else {
|
|
5755
|
+
bulk.push(invocation);
|
|
5756
|
+
}
|
|
5757
|
+
}
|
|
5758
|
+
return bulk;
|
|
5759
|
+
}
|
|
5733
5760
|
};
|
|
5734
5761
|
|
|
5735
5762
|
// src/provider/extensions/default.ts
|
|
@@ -5833,32 +5860,30 @@ function useEncoded(decoded) {
|
|
|
5833
5860
|
}
|
|
5834
5861
|
return encoded;
|
|
5835
5862
|
}
|
|
5836
|
-
var StarknetIdContract =
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
})(StarknetIdContract || {});
|
|
5863
|
+
var StarknetIdContract = {
|
|
5864
|
+
MAINNET: "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",
|
|
5865
|
+
TESTNET_SEPOLIA: "0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474"
|
|
5866
|
+
};
|
|
5841
5867
|
function getStarknetIdContract(chainId) {
|
|
5842
5868
|
switch (chainId) {
|
|
5843
5869
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5844
|
-
return
|
|
5870
|
+
return StarknetIdContract.MAINNET;
|
|
5845
5871
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5846
|
-
return
|
|
5872
|
+
return StarknetIdContract.TESTNET_SEPOLIA;
|
|
5847
5873
|
default:
|
|
5848
5874
|
throw new Error("Starknet.id is not yet deployed on this network");
|
|
5849
5875
|
}
|
|
5850
5876
|
}
|
|
5851
|
-
var StarknetIdIdentityContract =
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
})(StarknetIdIdentityContract || {});
|
|
5877
|
+
var StarknetIdIdentityContract = {
|
|
5878
|
+
MAINNET: "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af",
|
|
5879
|
+
TESTNET_SEPOLIA: "0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda"
|
|
5880
|
+
};
|
|
5856
5881
|
function getStarknetIdIdentityContract(chainId) {
|
|
5857
5882
|
switch (chainId) {
|
|
5858
5883
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5859
|
-
return
|
|
5884
|
+
return StarknetIdIdentityContract.MAINNET;
|
|
5860
5885
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5861
|
-
return
|
|
5886
|
+
return StarknetIdIdentityContract.TESTNET_SEPOLIA;
|
|
5862
5887
|
default:
|
|
5863
5888
|
throw new Error("Starknet.id verifier contract is not yet deployed on this network");
|
|
5864
5889
|
}
|
|
@@ -5874,49 +5899,46 @@ function getStarknetIdMulticallContract(chainId) {
|
|
|
5874
5899
|
throw new Error("Starknet.id multicall contract is not yet deployed on this network");
|
|
5875
5900
|
}
|
|
5876
5901
|
}
|
|
5877
|
-
var StarknetIdVerifierContract =
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
})(StarknetIdVerifierContract || {});
|
|
5902
|
+
var StarknetIdVerifierContract = {
|
|
5903
|
+
MAINNET: "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf",
|
|
5904
|
+
TESTNET_SEPOLIA: "0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566"
|
|
5905
|
+
};
|
|
5882
5906
|
function getStarknetIdVerifierContract(chainId) {
|
|
5883
5907
|
switch (chainId) {
|
|
5884
5908
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5885
|
-
return
|
|
5909
|
+
return StarknetIdVerifierContract.MAINNET;
|
|
5886
5910
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5887
|
-
return
|
|
5911
|
+
return StarknetIdVerifierContract.TESTNET_SEPOLIA;
|
|
5888
5912
|
default:
|
|
5889
5913
|
throw new Error("Starknet.id verifier contract is not yet deployed on this network");
|
|
5890
5914
|
}
|
|
5891
5915
|
}
|
|
5892
|
-
var StarknetIdPfpContract =
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
})(StarknetIdPfpContract || {});
|
|
5916
|
+
var StarknetIdPfpContract = {
|
|
5917
|
+
MAINNET: "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7",
|
|
5918
|
+
TESTNET_SEPOLIA: "0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02"
|
|
5919
|
+
};
|
|
5897
5920
|
function getStarknetIdPfpContract(chainId) {
|
|
5898
5921
|
switch (chainId) {
|
|
5899
5922
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5900
|
-
return
|
|
5923
|
+
return StarknetIdPfpContract.MAINNET;
|
|
5901
5924
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5902
|
-
return
|
|
5925
|
+
return StarknetIdPfpContract.TESTNET_SEPOLIA;
|
|
5903
5926
|
default:
|
|
5904
5927
|
throw new Error(
|
|
5905
5928
|
"Starknet.id profile picture verifier contract is not yet deployed on this network"
|
|
5906
5929
|
);
|
|
5907
5930
|
}
|
|
5908
5931
|
}
|
|
5909
|
-
var StarknetIdPopContract =
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
})(StarknetIdPopContract || {});
|
|
5932
|
+
var StarknetIdPopContract = {
|
|
5933
|
+
MAINNET: "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4",
|
|
5934
|
+
TESTNET_SEPOLIA: "0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a"
|
|
5935
|
+
};
|
|
5914
5936
|
function getStarknetIdPopContract(chainId) {
|
|
5915
5937
|
switch (chainId) {
|
|
5916
5938
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
5917
|
-
return
|
|
5939
|
+
return StarknetIdPopContract.MAINNET;
|
|
5918
5940
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
5919
|
-
return
|
|
5941
|
+
return StarknetIdPopContract.TESTNET_SEPOLIA;
|
|
5920
5942
|
default:
|
|
5921
5943
|
throw new Error(
|
|
5922
5944
|
"Starknet.id proof of personhood verifier contract is not yet deployed on this network"
|
|
@@ -6607,81 +6629,6 @@ function getLedgerPathBuffer(accountId, applicationName) {
|
|
|
6607
6629
|
return pathBuff;
|
|
6608
6630
|
}
|
|
6609
6631
|
|
|
6610
|
-
// src/utils/outsideExecution.ts
|
|
6611
|
-
var outsideExecution_exports = {};
|
|
6612
|
-
__export(outsideExecution_exports, {
|
|
6613
|
-
buildExecuteFromOutsideCallData: () => buildExecuteFromOutsideCallData,
|
|
6614
|
-
getOutsideCall: () => getOutsideCall,
|
|
6615
|
-
getTypedData: () => getTypedData
|
|
6616
|
-
});
|
|
6617
|
-
function getOutsideCall(call) {
|
|
6618
|
-
const callData = call.calldata ?? [];
|
|
6619
|
-
const callDataCompiled = Array.isArray(callData) ? callData : CallData.compile(callData);
|
|
6620
|
-
return {
|
|
6621
|
-
to: call.contractAddress,
|
|
6622
|
-
selector: getSelectorFromName(call.entrypoint),
|
|
6623
|
-
calldata: callDataCompiled
|
|
6624
|
-
};
|
|
6625
|
-
}
|
|
6626
|
-
function callToTypedData(call, version) {
|
|
6627
|
-
const outsideCall = getOutsideCall(call);
|
|
6628
|
-
if (version === "1") {
|
|
6629
|
-
return {
|
|
6630
|
-
...outsideCall,
|
|
6631
|
-
calldata_len: outsideCall.calldata.length,
|
|
6632
|
-
calldata: outsideCall.calldata
|
|
6633
|
-
};
|
|
6634
|
-
}
|
|
6635
|
-
return {
|
|
6636
|
-
To: outsideCall.to,
|
|
6637
|
-
Selector: outsideCall.selector,
|
|
6638
|
-
Calldata: outsideCall.calldata
|
|
6639
|
-
};
|
|
6640
|
-
}
|
|
6641
|
-
function getDomain(chainId, version) {
|
|
6642
|
-
return {
|
|
6643
|
-
name: "Account.execute_from_outside",
|
|
6644
|
-
version,
|
|
6645
|
-
chainId,
|
|
6646
|
-
...version === "2" ? { revision: "1" } : {}
|
|
6647
|
-
};
|
|
6648
|
-
}
|
|
6649
|
-
function getTypedData(chainId, options, nonce, myCalls, version) {
|
|
6650
|
-
if (version === "1") {
|
|
6651
|
-
return {
|
|
6652
|
-
types: OutsideExecutionTypesV1,
|
|
6653
|
-
primaryType: "OutsideExecution",
|
|
6654
|
-
domain: getDomain(chainId, version),
|
|
6655
|
-
message: {
|
|
6656
|
-
...options,
|
|
6657
|
-
nonce,
|
|
6658
|
-
calls_len: myCalls.length,
|
|
6659
|
-
calls: myCalls.map((call) => callToTypedData(call, version))
|
|
6660
|
-
}
|
|
6661
|
-
};
|
|
6662
|
-
}
|
|
6663
|
-
return {
|
|
6664
|
-
types: OutsideExecutionTypesV2,
|
|
6665
|
-
primaryType: "OutsideExecution",
|
|
6666
|
-
domain: getDomain(chainId, version),
|
|
6667
|
-
message: {
|
|
6668
|
-
Caller: options.caller,
|
|
6669
|
-
Nonce: nonce,
|
|
6670
|
-
"Execute After": options.execute_after,
|
|
6671
|
-
"Execute Before": options.execute_before,
|
|
6672
|
-
Calls: myCalls.map((call) => callToTypedData(call, version))
|
|
6673
|
-
}
|
|
6674
|
-
};
|
|
6675
|
-
}
|
|
6676
|
-
function buildExecuteFromOutsideCallData(outsideTransaction) {
|
|
6677
|
-
const execution2 = outsideTransaction.outsideExecution;
|
|
6678
|
-
const formattedSignature = formatSignature(outsideTransaction.signature);
|
|
6679
|
-
return CallData.compile({
|
|
6680
|
-
outside_execution: execution2,
|
|
6681
|
-
signature: formattedSignature
|
|
6682
|
-
});
|
|
6683
|
-
}
|
|
6684
|
-
|
|
6685
6632
|
// src/utils/events/index.ts
|
|
6686
6633
|
var events_exports = {};
|
|
6687
6634
|
__export(events_exports, {
|
|
@@ -6821,6 +6768,81 @@ function parseUDCEvent(txReceipt) {
|
|
|
6821
6768
|
};
|
|
6822
6769
|
}
|
|
6823
6770
|
|
|
6771
|
+
// src/utils/outsideExecution.ts
|
|
6772
|
+
var outsideExecution_exports = {};
|
|
6773
|
+
__export(outsideExecution_exports, {
|
|
6774
|
+
buildExecuteFromOutsideCallData: () => buildExecuteFromOutsideCallData,
|
|
6775
|
+
getOutsideCall: () => getOutsideCall,
|
|
6776
|
+
getTypedData: () => getTypedData
|
|
6777
|
+
});
|
|
6778
|
+
function getOutsideCall(call) {
|
|
6779
|
+
const callData = call.calldata ?? [];
|
|
6780
|
+
const callDataCompiled = Array.isArray(callData) ? callData : CallData.compile(callData);
|
|
6781
|
+
return {
|
|
6782
|
+
to: call.contractAddress,
|
|
6783
|
+
selector: getSelectorFromName(call.entrypoint),
|
|
6784
|
+
calldata: callDataCompiled
|
|
6785
|
+
};
|
|
6786
|
+
}
|
|
6787
|
+
function callToTypedData(call, version) {
|
|
6788
|
+
const outsideCall = getOutsideCall(call);
|
|
6789
|
+
if (version === "1") {
|
|
6790
|
+
return {
|
|
6791
|
+
...outsideCall,
|
|
6792
|
+
calldata_len: outsideCall.calldata.length,
|
|
6793
|
+
calldata: outsideCall.calldata
|
|
6794
|
+
};
|
|
6795
|
+
}
|
|
6796
|
+
return {
|
|
6797
|
+
To: outsideCall.to,
|
|
6798
|
+
Selector: outsideCall.selector,
|
|
6799
|
+
Calldata: outsideCall.calldata
|
|
6800
|
+
};
|
|
6801
|
+
}
|
|
6802
|
+
function getDomain(chainId, version) {
|
|
6803
|
+
return {
|
|
6804
|
+
name: "Account.execute_from_outside",
|
|
6805
|
+
version,
|
|
6806
|
+
chainId,
|
|
6807
|
+
...version === "2" ? { revision: "1" } : {}
|
|
6808
|
+
};
|
|
6809
|
+
}
|
|
6810
|
+
function getTypedData(chainId, options, nonce, myCalls, version) {
|
|
6811
|
+
if (version === "1") {
|
|
6812
|
+
return {
|
|
6813
|
+
types: OutsideExecutionTypesV1,
|
|
6814
|
+
primaryType: "OutsideExecution",
|
|
6815
|
+
domain: getDomain(chainId, version),
|
|
6816
|
+
message: {
|
|
6817
|
+
...options,
|
|
6818
|
+
nonce,
|
|
6819
|
+
calls_len: myCalls.length,
|
|
6820
|
+
calls: myCalls.map((call) => callToTypedData(call, version))
|
|
6821
|
+
}
|
|
6822
|
+
};
|
|
6823
|
+
}
|
|
6824
|
+
return {
|
|
6825
|
+
types: OutsideExecutionTypesV2,
|
|
6826
|
+
primaryType: "OutsideExecution",
|
|
6827
|
+
domain: getDomain(chainId, version),
|
|
6828
|
+
message: {
|
|
6829
|
+
Caller: options.caller,
|
|
6830
|
+
Nonce: nonce,
|
|
6831
|
+
"Execute After": options.execute_after,
|
|
6832
|
+
"Execute Before": options.execute_before,
|
|
6833
|
+
Calls: myCalls.map((call) => callToTypedData(call, version))
|
|
6834
|
+
}
|
|
6835
|
+
};
|
|
6836
|
+
}
|
|
6837
|
+
function buildExecuteFromOutsideCallData(outsideTransaction) {
|
|
6838
|
+
const execution2 = outsideTransaction.outsideExecution;
|
|
6839
|
+
const formattedSignature = formatSignature(outsideTransaction.signature);
|
|
6840
|
+
return CallData.compile({
|
|
6841
|
+
outside_execution: execution2,
|
|
6842
|
+
signature: formattedSignature
|
|
6843
|
+
});
|
|
6844
|
+
}
|
|
6845
|
+
|
|
6824
6846
|
// src/utils/src5.ts
|
|
6825
6847
|
var src5_exports = {};
|
|
6826
6848
|
__export(src5_exports, {
|
|
@@ -6988,6 +7010,7 @@ var Account = class extends RpcProvider2 {
|
|
|
6988
7010
|
return this.estimateInvokeFee(calls, details);
|
|
6989
7011
|
}
|
|
6990
7012
|
async estimateFeeBulk(invocations, details = {}) {
|
|
7013
|
+
if (!invocations.length) throw TypeError("Invocations should be non-empty array");
|
|
6991
7014
|
const { nonce, blockIdentifier, version, skipValidate } = details;
|
|
6992
7015
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
6993
7016
|
...v3Details(details),
|
|
@@ -7010,6 +7033,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7010
7033
|
});
|
|
7011
7034
|
}
|
|
7012
7035
|
async simulateTransaction(invocations, details = {}) {
|
|
7036
|
+
if (!invocations.length) throw TypeError("Invocations should be non-empty array");
|
|
7013
7037
|
const { nonce, blockIdentifier, skipValidate = true, skipExecute, version } = details;
|
|
7014
7038
|
const accountInvocations = await this.accountInvocationsFactory(invocations, {
|
|
7015
7039
|
...v3Details(details),
|
|
@@ -7042,7 +7066,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7042
7066
|
);
|
|
7043
7067
|
const estimate = await this.getUniversalSuggestedFee(
|
|
7044
7068
|
version,
|
|
7045
|
-
{ type:
|
|
7069
|
+
{ type: TransactionType.INVOKE, payload: transactions },
|
|
7046
7070
|
{
|
|
7047
7071
|
...details,
|
|
7048
7072
|
version
|
|
@@ -7100,7 +7124,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7100
7124
|
const estimate = await this.getUniversalSuggestedFee(
|
|
7101
7125
|
version,
|
|
7102
7126
|
{
|
|
7103
|
-
type:
|
|
7127
|
+
type: TransactionType.DECLARE,
|
|
7104
7128
|
payload: declareContractPayload
|
|
7105
7129
|
},
|
|
7106
7130
|
{
|
|
@@ -7168,7 +7192,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7168
7192
|
const estimate = await this.getUniversalSuggestedFee(
|
|
7169
7193
|
version,
|
|
7170
7194
|
{
|
|
7171
|
-
type:
|
|
7195
|
+
type: TransactionType.DEPLOY_ACCOUNT,
|
|
7172
7196
|
payload: {
|
|
7173
7197
|
classHash,
|
|
7174
7198
|
constructorCalldata: compiledCalldata,
|
|
@@ -7410,16 +7434,16 @@ var Account = class extends RpcProvider2 {
|
|
|
7410
7434
|
async getSuggestedFee({ type, payload }, details) {
|
|
7411
7435
|
let feeEstimate;
|
|
7412
7436
|
switch (type) {
|
|
7413
|
-
case
|
|
7437
|
+
case TransactionType.INVOKE:
|
|
7414
7438
|
feeEstimate = await this.estimateInvokeFee(payload, details);
|
|
7415
7439
|
break;
|
|
7416
|
-
case
|
|
7440
|
+
case TransactionType.DECLARE:
|
|
7417
7441
|
feeEstimate = await this.estimateDeclareFee(payload, details);
|
|
7418
7442
|
break;
|
|
7419
|
-
case
|
|
7443
|
+
case TransactionType.DEPLOY_ACCOUNT:
|
|
7420
7444
|
feeEstimate = await this.estimateAccountDeployFee(payload, details);
|
|
7421
7445
|
break;
|
|
7422
|
-
case
|
|
7446
|
+
case TransactionType.DEPLOY:
|
|
7423
7447
|
feeEstimate = await this.estimateDeployFee(payload, details);
|
|
7424
7448
|
break;
|
|
7425
7449
|
default:
|
|
@@ -7521,7 +7545,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7521
7545
|
const chainId = await this.getChainId();
|
|
7522
7546
|
const versions = details.versions.map((it) => toTransactionVersion(it));
|
|
7523
7547
|
const tx0Payload = "payload" in invocations[0] ? invocations[0].payload : invocations[0];
|
|
7524
|
-
const cairoVersion = invocations[0].type ===
|
|
7548
|
+
const cairoVersion = invocations[0].type === TransactionType.DEPLOY_ACCOUNT ? await this.getCairoVersion(tx0Payload.classHash) : await this.getCairoVersion();
|
|
7525
7549
|
return Promise.all(
|
|
7526
7550
|
[].concat(invocations).map(async (transaction, index) => {
|
|
7527
7551
|
const txPayload = "payload" in transaction ? transaction.payload : transaction;
|
|
@@ -7541,7 +7565,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7541
7565
|
blockIdentifier,
|
|
7542
7566
|
version: ""
|
|
7543
7567
|
};
|
|
7544
|
-
if (transaction.type ===
|
|
7568
|
+
if (transaction.type === TransactionType.INVOKE) {
|
|
7545
7569
|
const versionX = reduceV2(versions[1]);
|
|
7546
7570
|
signerDetails.version = versionX;
|
|
7547
7571
|
common.version = versionX;
|
|
@@ -7554,7 +7578,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7554
7578
|
...payload
|
|
7555
7579
|
};
|
|
7556
7580
|
}
|
|
7557
|
-
if (transaction.type ===
|
|
7581
|
+
if (transaction.type === TransactionType.DEPLOY) {
|
|
7558
7582
|
const versionX = reduceV2(versions[1]);
|
|
7559
7583
|
signerDetails.version = versionX;
|
|
7560
7584
|
common.version = versionX;
|
|
@@ -7563,10 +7587,10 @@ var Account = class extends RpcProvider2 {
|
|
|
7563
7587
|
return {
|
|
7564
7588
|
...common,
|
|
7565
7589
|
...payload,
|
|
7566
|
-
type:
|
|
7590
|
+
type: TransactionType.INVOKE
|
|
7567
7591
|
};
|
|
7568
7592
|
}
|
|
7569
|
-
if (transaction.type ===
|
|
7593
|
+
if (transaction.type === TransactionType.DECLARE) {
|
|
7570
7594
|
const versionX = !isSierra(txPayload.contract) ? versions[0] : versions[1];
|
|
7571
7595
|
signerDetails.version = versionX;
|
|
7572
7596
|
common.version = versionX;
|
|
@@ -7576,7 +7600,7 @@ var Account = class extends RpcProvider2 {
|
|
|
7576
7600
|
...payload
|
|
7577
7601
|
};
|
|
7578
7602
|
}
|
|
7579
|
-
if (transaction.type ===
|
|
7603
|
+
if (transaction.type === TransactionType.DEPLOY_ACCOUNT) {
|
|
7580
7604
|
const versionX = reduceV2(versions[1]);
|
|
7581
7605
|
signerDetails.version = versionX;
|
|
7582
7606
|
common.version = versionX;
|
|
@@ -7929,7 +7953,7 @@ var Contract = class {
|
|
|
7929
7953
|
assert(this.address !== null, "contract is not connected to an address");
|
|
7930
7954
|
const calldata = getCalldata(args, () => {
|
|
7931
7955
|
if (parseRequest) {
|
|
7932
|
-
this.callData.validate(
|
|
7956
|
+
this.callData.validate(ValidateType.CALL, method, args);
|
|
7933
7957
|
return this.callData.compile(method, args);
|
|
7934
7958
|
}
|
|
7935
7959
|
console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
|
|
@@ -7956,7 +7980,7 @@ var Contract = class {
|
|
|
7956
7980
|
assert(this.address !== null, "contract is not connected to an address");
|
|
7957
7981
|
const calldata = getCalldata(args, () => {
|
|
7958
7982
|
if (parseRequest) {
|
|
7959
|
-
this.callData.validate(
|
|
7983
|
+
this.callData.validate(ValidateType.INVOKE, method, args);
|
|
7960
7984
|
return this.callData.compile(method, args);
|
|
7961
7985
|
}
|
|
7962
7986
|
console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
|
|
@@ -7988,7 +8012,7 @@ var Contract = class {
|
|
|
7988
8012
|
async estimate(method, args = []) {
|
|
7989
8013
|
assert(this.address !== null, "contract is not connected to an address");
|
|
7990
8014
|
if (!getCalldata(args, () => false)) {
|
|
7991
|
-
this.callData.validate(
|
|
8015
|
+
this.callData.validate(ValidateType.INVOKE, method, args);
|
|
7992
8016
|
}
|
|
7993
8017
|
const invocation = this.populate(method, args);
|
|
7994
8018
|
if ("estimateInvokeFee" in this.providerOrAccount) {
|
|
@@ -8070,7 +8094,7 @@ var ContractFactory = class {
|
|
|
8070
8094
|
const { args: param, options = { parseRequest: true } } = splitArgsAndOptions(args);
|
|
8071
8095
|
const constructorCalldata = getCalldata(param, () => {
|
|
8072
8096
|
if (options.parseRequest) {
|
|
8073
|
-
this.CallData.validate(
|
|
8097
|
+
this.CallData.validate(ValidateType.DEPLOY, "constructor", param);
|
|
8074
8098
|
return this.CallData.compile("constructor", param);
|
|
8075
8099
|
}
|
|
8076
8100
|
console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
|