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/dist/index.mjs CHANGED
@@ -81,76 +81,65 @@ var errors_exports = {};
81
81
  var components_exports = {};
82
82
 
83
83
  // src/types/api/rpcspec_0_6/nonspec.ts
84
- var ETransactionType = /* @__PURE__ */ ((ETransactionType2) => {
85
- ETransactionType2["DECLARE"] = "DECLARE";
86
- ETransactionType2["DEPLOY"] = "DEPLOY";
87
- ETransactionType2["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
88
- ETransactionType2["INVOKE"] = "INVOKE";
89
- ETransactionType2["L1_HANDLER"] = "L1_HANDLER";
90
- return ETransactionType2;
91
- })(ETransactionType || {});
92
- var ESimulationFlag = /* @__PURE__ */ ((ESimulationFlag2) => {
93
- ESimulationFlag2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
94
- ESimulationFlag2["SKIP_FEE_CHARGE"] = "SKIP_FEE_CHARGE";
95
- return ESimulationFlag2;
96
- })(ESimulationFlag || {});
97
- var ETransactionStatus = /* @__PURE__ */ ((ETransactionStatus2) => {
98
- ETransactionStatus2["RECEIVED"] = "RECEIVED";
99
- ETransactionStatus2["REJECTED"] = "REJECTED";
100
- ETransactionStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
101
- ETransactionStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
102
- return ETransactionStatus2;
103
- })(ETransactionStatus || {});
104
- var ETransactionFinalityStatus = /* @__PURE__ */ ((ETransactionFinalityStatus2) => {
105
- ETransactionFinalityStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
106
- ETransactionFinalityStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
107
- return ETransactionFinalityStatus2;
108
- })(ETransactionFinalityStatus || {});
109
- var ETransactionExecutionStatus = /* @__PURE__ */ ((ETransactionExecutionStatus2) => {
110
- ETransactionExecutionStatus2["SUCCEEDED"] = "SUCCEEDED";
111
- ETransactionExecutionStatus2["REVERTED"] = "REVERTED";
112
- return ETransactionExecutionStatus2;
113
- })(ETransactionExecutionStatus || {});
114
- var EBlockTag = /* @__PURE__ */ ((EBlockTag2) => {
115
- EBlockTag2["PENDING"] = "pending";
116
- EBlockTag2["LATEST"] = "latest";
117
- return EBlockTag2;
118
- })(EBlockTag || {});
119
- var EDataAvailabilityMode = /* @__PURE__ */ ((EDataAvailabilityMode3) => {
120
- EDataAvailabilityMode3["L1"] = "L1";
121
- EDataAvailabilityMode3["L2"] = "L2";
122
- return EDataAvailabilityMode3;
123
- })(EDataAvailabilityMode || {});
124
- var EDAMode = /* @__PURE__ */ ((EDAMode4) => {
125
- EDAMode4[EDAMode4["L1"] = 0] = "L1";
126
- EDAMode4[EDAMode4["L2"] = 1] = "L2";
127
- return EDAMode4;
128
- })(EDAMode || {});
129
- var ETransactionVersion = /* @__PURE__ */ ((ETransactionVersion10) => {
130
- ETransactionVersion10["V0"] = "0x0";
131
- ETransactionVersion10["V1"] = "0x1";
132
- ETransactionVersion10["V2"] = "0x2";
133
- ETransactionVersion10["V3"] = "0x3";
134
- ETransactionVersion10["F0"] = "0x100000000000000000000000000000000";
135
- ETransactionVersion10["F1"] = "0x100000000000000000000000000000001";
136
- ETransactionVersion10["F2"] = "0x100000000000000000000000000000002";
137
- ETransactionVersion10["F3"] = "0x100000000000000000000000000000003";
138
- return ETransactionVersion10;
139
- })(ETransactionVersion || {});
140
- var ETransactionVersion2 = /* @__PURE__ */ ((ETransactionVersion25) => {
141
- ETransactionVersion25["V0"] = "0x0";
142
- ETransactionVersion25["V1"] = "0x1";
143
- ETransactionVersion25["V2"] = "0x2";
144
- ETransactionVersion25["F0"] = "0x100000000000000000000000000000000";
145
- ETransactionVersion25["F1"] = "0x100000000000000000000000000000001";
146
- ETransactionVersion25["F2"] = "0x100000000000000000000000000000002";
147
- return ETransactionVersion25;
148
- })(ETransactionVersion2 || {});
149
- var ETransactionVersion3 = /* @__PURE__ */ ((ETransactionVersion37) => {
150
- ETransactionVersion37["V3"] = "0x3";
151
- ETransactionVersion37["F3"] = "0x100000000000000000000000000000003";
152
- return ETransactionVersion37;
153
- })(ETransactionVersion3 || {});
84
+ var ETransactionType = {
85
+ DECLARE: "DECLARE",
86
+ DEPLOY: "DEPLOY",
87
+ DEPLOY_ACCOUNT: "DEPLOY_ACCOUNT",
88
+ INVOKE: "INVOKE",
89
+ L1_HANDLER: "L1_HANDLER"
90
+ };
91
+ var ESimulationFlag = {
92
+ SKIP_VALIDATE: "SKIP_VALIDATE",
93
+ SKIP_FEE_CHARGE: "SKIP_FEE_CHARGE"
94
+ };
95
+ var ETransactionStatus = {
96
+ RECEIVED: "RECEIVED",
97
+ REJECTED: "REJECTED",
98
+ ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
99
+ ACCEPTED_ON_L1: "ACCEPTED_ON_L1"
100
+ };
101
+ var ETransactionFinalityStatus = {
102
+ ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
103
+ ACCEPTED_ON_L1: "ACCEPTED_ON_L1"
104
+ };
105
+ var ETransactionExecutionStatus = {
106
+ SUCCEEDED: "SUCCEEDED",
107
+ REVERTED: "REVERTED"
108
+ };
109
+ var EBlockTag = {
110
+ PENDING: "pending",
111
+ LATEST: "latest"
112
+ };
113
+ var EDataAvailabilityMode = {
114
+ L1: "L1",
115
+ L2: "L2"
116
+ };
117
+ var EDAMode = {
118
+ L1: 0,
119
+ L2: 1
120
+ };
121
+ var ETransactionVersion = {
122
+ V0: "0x0",
123
+ V1: "0x1",
124
+ V2: "0x2",
125
+ V3: "0x3",
126
+ F0: "0x100000000000000000000000000000000",
127
+ F1: "0x100000000000000000000000000000001",
128
+ F2: "0x100000000000000000000000000000002",
129
+ F3: "0x100000000000000000000000000000003"
130
+ };
131
+ var ETransactionVersion2 = {
132
+ V0: "0x0",
133
+ V1: "0x1",
134
+ V2: "0x2",
135
+ F0: "0x100000000000000000000000000000000",
136
+ F1: "0x100000000000000000000000000000001",
137
+ F2: "0x100000000000000000000000000000002"
138
+ };
139
+ var ETransactionVersion3 = {
140
+ V3: "0x3",
141
+ F3: "0x100000000000000000000000000000003"
142
+ };
154
143
 
155
144
  // src/types/api/index.ts
156
145
  __reExport(api_exports, starknet_types_07_star);
@@ -368,79 +357,71 @@ __export(types_exports, {
368
357
  });
369
358
 
370
359
  // src/types/calldata.ts
371
- var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
372
- ValidateType2["DEPLOY"] = "DEPLOY";
373
- ValidateType2["CALL"] = "CALL";
374
- ValidateType2["INVOKE"] = "INVOKE";
375
- return ValidateType2;
376
- })(ValidateType || {});
377
- var Uint = /* @__PURE__ */ ((Uint2) => {
378
- Uint2["u8"] = "core::integer::u8";
379
- Uint2["u16"] = "core::integer::u16";
380
- Uint2["u32"] = "core::integer::u32";
381
- Uint2["u64"] = "core::integer::u64";
382
- Uint2["u128"] = "core::integer::u128";
383
- Uint2["u256"] = "core::integer::u256";
384
- Uint2["u512"] = "core::integer::u512";
385
- return Uint2;
386
- })(Uint || {});
387
- var Literal = /* @__PURE__ */ ((Literal2) => {
388
- Literal2["ClassHash"] = "core::starknet::class_hash::ClassHash";
389
- Literal2["ContractAddress"] = "core::starknet::contract_address::ContractAddress";
390
- Literal2["Secp256k1Point"] = "core::starknet::secp256k1::Secp256k1Point";
391
- return Literal2;
392
- })(Literal || {});
360
+ var ValidateType = {
361
+ DEPLOY: "DEPLOY",
362
+ CALL: "CALL",
363
+ INVOKE: "INVOKE"
364
+ };
365
+ var Uint = {
366
+ u8: "core::integer::u8",
367
+ u16: "core::integer::u16",
368
+ u32: "core::integer::u32",
369
+ u64: "core::integer::u64",
370
+ u128: "core::integer::u128",
371
+ u256: "core::integer::u256",
372
+ // This one is struct
373
+ u512: "core::integer::u512"
374
+ // This one is struct
375
+ };
376
+ var Literal = {
377
+ ClassHash: "core::starknet::class_hash::ClassHash",
378
+ ContractAddress: "core::starknet::contract_address::ContractAddress",
379
+ Secp256k1Point: "core::starknet::secp256k1::Secp256k1Point"
380
+ };
393
381
 
394
382
  // src/types/lib/contract/index.ts
395
- var EntryPointType = /* @__PURE__ */ ((EntryPointType2) => {
396
- EntryPointType2["EXTERNAL"] = "EXTERNAL";
397
- EntryPointType2["L1_HANDLER"] = "L1_HANDLER";
398
- EntryPointType2["CONSTRUCTOR"] = "CONSTRUCTOR";
399
- return EntryPointType2;
400
- })(EntryPointType || {});
383
+ var EntryPointType = {
384
+ EXTERNAL: "EXTERNAL",
385
+ L1_HANDLER: "L1_HANDLER",
386
+ CONSTRUCTOR: "CONSTRUCTOR"
387
+ };
401
388
 
402
389
  // src/types/lib/index.ts
403
- var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
404
- TransactionType2["DECLARE"] = "DECLARE";
405
- TransactionType2["DEPLOY"] = "DEPLOY";
406
- TransactionType2["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
407
- TransactionType2["INVOKE"] = "INVOKE_FUNCTION";
408
- return TransactionType2;
409
- })(TransactionType || {});
410
- var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
411
- TransactionStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
412
- TransactionStatus2["RECEIVED"] = "RECEIVED";
413
- TransactionStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
414
- TransactionStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
415
- TransactionStatus2["REJECTED"] = "REJECTED";
416
- TransactionStatus2["REVERTED"] = "REVERTED";
417
- return TransactionStatus2;
418
- })(TransactionStatus || {});
419
- var TransactionFinalityStatus = /* @__PURE__ */ ((TransactionFinalityStatus2) => {
420
- TransactionFinalityStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
421
- TransactionFinalityStatus2["RECEIVED"] = "RECEIVED";
422
- TransactionFinalityStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
423
- TransactionFinalityStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
424
- return TransactionFinalityStatus2;
425
- })(TransactionFinalityStatus || {});
426
- var TransactionExecutionStatus = /* @__PURE__ */ ((TransactionExecutionStatus2) => {
427
- TransactionExecutionStatus2["REJECTED"] = "REJECTED";
428
- TransactionExecutionStatus2["REVERTED"] = "REVERTED";
429
- TransactionExecutionStatus2["SUCCEEDED"] = "SUCCEEDED";
430
- return TransactionExecutionStatus2;
431
- })(TransactionExecutionStatus || {});
432
- var BlockStatus = /* @__PURE__ */ ((BlockStatus2) => {
433
- BlockStatus2["PENDING"] = "PENDING";
434
- BlockStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
435
- BlockStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
436
- BlockStatus2["REJECTED"] = "REJECTED";
437
- return BlockStatus2;
438
- })(BlockStatus || {});
439
- var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
440
- BlockTag2["PENDING"] = "pending";
441
- BlockTag2["LATEST"] = "latest";
442
- return BlockTag2;
443
- })(BlockTag || {});
390
+ var TransactionType = {
391
+ DECLARE: "DECLARE",
392
+ DEPLOY: "DEPLOY",
393
+ DEPLOY_ACCOUNT: "DEPLOY_ACCOUNT",
394
+ INVOKE: "INVOKE_FUNCTION"
395
+ };
396
+ var TransactionStatus = {
397
+ NOT_RECEIVED: "NOT_RECEIVED",
398
+ RECEIVED: "RECEIVED",
399
+ ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
400
+ ACCEPTED_ON_L1: "ACCEPTED_ON_L1",
401
+ REJECTED: "REJECTED",
402
+ REVERTED: "REVERTED"
403
+ };
404
+ var TransactionFinalityStatus = {
405
+ NOT_RECEIVED: "NOT_RECEIVED",
406
+ RECEIVED: "RECEIVED",
407
+ ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
408
+ ACCEPTED_ON_L1: "ACCEPTED_ON_L1"
409
+ };
410
+ var TransactionExecutionStatus = {
411
+ REJECTED: "REJECTED",
412
+ REVERTED: "REVERTED",
413
+ SUCCEEDED: "SUCCEEDED"
414
+ };
415
+ var BlockStatus = {
416
+ PENDING: "PENDING",
417
+ ACCEPTED_ON_L1: "ACCEPTED_ON_L1",
418
+ ACCEPTED_ON_L2: "ACCEPTED_ON_L2",
419
+ REJECTED: "REJECTED"
420
+ };
421
+ var BlockTag = {
422
+ PENDING: "pending",
423
+ LATEST: "latest"
424
+ };
444
425
 
445
426
  // src/types/typedData.ts
446
427
  import {
@@ -1253,19 +1234,18 @@ var CairoCustomEnum = class {
1253
1234
  };
1254
1235
 
1255
1236
  // src/utils/calldata/enum/CairoOption.ts
1256
- var CairoOptionVariant = /* @__PURE__ */ ((CairoOptionVariant2) => {
1257
- CairoOptionVariant2[CairoOptionVariant2["Some"] = 0] = "Some";
1258
- CairoOptionVariant2[CairoOptionVariant2["None"] = 1] = "None";
1259
- return CairoOptionVariant2;
1260
- })(CairoOptionVariant || {});
1237
+ var CairoOptionVariant = {
1238
+ Some: 0,
1239
+ None: 1
1240
+ };
1261
1241
  var CairoOption = class {
1262
1242
  Some;
1263
1243
  None;
1264
1244
  constructor(variant, someContent) {
1265
- if (!(variant in CairoOptionVariant)) {
1245
+ if (!(variant in Object.values(CairoOptionVariant))) {
1266
1246
  throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");
1267
1247
  }
1268
- if (variant === 0 /* Some */) {
1248
+ if (variant === CairoOptionVariant.Some) {
1269
1249
  if (typeof someContent === "undefined") {
1270
1250
  throw new Error(
1271
1251
  'The creation of a Cairo Option with "Some" variant needs a content as input.'
@@ -1306,19 +1286,18 @@ var CairoOption = class {
1306
1286
  };
1307
1287
 
1308
1288
  // src/utils/calldata/enum/CairoResult.ts
1309
- var CairoResultVariant = /* @__PURE__ */ ((CairoResultVariant2) => {
1310
- CairoResultVariant2[CairoResultVariant2["Ok"] = 0] = "Ok";
1311
- CairoResultVariant2[CairoResultVariant2["Err"] = 1] = "Err";
1312
- return CairoResultVariant2;
1313
- })(CairoResultVariant || {});
1289
+ var CairoResultVariant = {
1290
+ Ok: 0,
1291
+ Err: 1
1292
+ };
1314
1293
  var CairoResult = class {
1315
1294
  Ok;
1316
1295
  Err;
1317
1296
  constructor(variant, resultContent) {
1318
- if (!(variant in CairoResultVariant)) {
1297
+ if (!(variant in Object.values(CairoResultVariant))) {
1319
1298
  throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");
1320
1299
  }
1321
- if (variant === 0 /* Ok */) {
1300
+ if (variant === CairoResultVariant.Ok) {
1322
1301
  this.Ok = resultContent;
1323
1302
  this.Err = void 0;
1324
1303
  } else {
@@ -1705,12 +1684,12 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
1705
1684
  );
1706
1685
  if (unorderedResult.isOk()) {
1707
1686
  return new CairoResult(
1708
- 0 /* Ok */,
1687
+ CairoResultVariant.Ok,
1709
1688
  orderInput(unorderedObject2.unwrap(), resultOkType)
1710
1689
  );
1711
1690
  }
1712
1691
  return new CairoResult(
1713
- 1 /* Err */,
1692
+ CairoResultVariant.Err,
1714
1693
  orderInput(unorderedObject2.unwrap(), resultErrType)
1715
1694
  );
1716
1695
  }
@@ -1722,11 +1701,11 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
1722
1701
  );
1723
1702
  if (unorderedOption.isSome()) {
1724
1703
  return new CairoOption(
1725
- 0 /* Some */,
1704
+ CairoOptionVariant.Some,
1726
1705
  orderInput(unorderedOption.unwrap(), resultSomeType)
1727
1706
  );
1728
1707
  }
1729
- return new CairoOption(1 /* None */, {});
1708
+ return new CairoOption(CairoOptionVariant.None, {});
1730
1709
  }
1731
1710
  const unorderedCustomEnum = unorderedObject2;
1732
1711
  const variants = Object.entries(unorderedCustomEnum.variant);
@@ -1861,7 +1840,7 @@ function parseCalldataValue(element, type, structs, enums) {
1861
1840
  }
1862
1841
  const typeVariantSome = listTypeVariant2.type;
1863
1842
  if (typeVariantSome === "()") {
1864
- return 0 /* Some */.toString();
1843
+ return CairoOptionVariant.Some.toString();
1865
1844
  }
1866
1845
  const parsedParameter2 = parseCalldataValue(
1867
1846
  myOption.unwrap(),
@@ -1870,11 +1849,11 @@ function parseCalldataValue(element, type, structs, enums) {
1870
1849
  enums
1871
1850
  );
1872
1851
  if (Array.isArray(parsedParameter2)) {
1873
- return [0 /* Some */.toString(), ...parsedParameter2];
1852
+ return [CairoOptionVariant.Some.toString(), ...parsedParameter2];
1874
1853
  }
1875
- return [0 /* Some */.toString(), parsedParameter2];
1854
+ return [CairoOptionVariant.Some.toString(), parsedParameter2];
1876
1855
  }
1877
- return 1 /* None */.toString();
1856
+ return CairoOptionVariant.None.toString();
1878
1857
  }
1879
1858
  if (isTypeResult(type)) {
1880
1859
  const myResult = element;
@@ -1885,7 +1864,7 @@ function parseCalldataValue(element, type, structs, enums) {
1885
1864
  }
1886
1865
  const typeVariantOk = listTypeVariant3.type;
1887
1866
  if (typeVariantOk === "()") {
1888
- return 0 /* Ok */.toString();
1867
+ return CairoResultVariant.Ok.toString();
1889
1868
  }
1890
1869
  const parsedParameter3 = parseCalldataValue(
1891
1870
  myResult.unwrap(),
@@ -1894,9 +1873,9 @@ function parseCalldataValue(element, type, structs, enums) {
1894
1873
  enums
1895
1874
  );
1896
1875
  if (Array.isArray(parsedParameter3)) {
1897
- return [0 /* Ok */.toString(), ...parsedParameter3];
1876
+ return [CairoResultVariant.Ok.toString(), ...parsedParameter3];
1898
1877
  }
1899
- return [0 /* Ok */.toString(), parsedParameter3];
1878
+ return [CairoResultVariant.Ok.toString(), parsedParameter3];
1900
1879
  }
1901
1880
  const listTypeVariant2 = variants.find((variant) => variant.name === "Err");
1902
1881
  if (typeof listTypeVariant2 === "undefined") {
@@ -1904,13 +1883,13 @@ function parseCalldataValue(element, type, structs, enums) {
1904
1883
  }
1905
1884
  const typeVariantErr = listTypeVariant2.type;
1906
1885
  if (typeVariantErr === "()") {
1907
- return 1 /* Err */.toString();
1886
+ return CairoResultVariant.Err.toString();
1908
1887
  }
1909
1888
  const parsedParameter2 = parseCalldataValue(myResult.unwrap(), typeVariantErr, structs, enums);
1910
1889
  if (Array.isArray(parsedParameter2)) {
1911
- return [1 /* Err */.toString(), ...parsedParameter2];
1890
+ return [CairoResultVariant.Err.toString(), ...parsedParameter2];
1912
1891
  }
1913
- return [1 /* Err */.toString(), parsedParameter2];
1892
+ return [CairoResultVariant.Err.toString(), parsedParameter2];
1914
1893
  }
1915
1894
  const myEnum = element;
1916
1895
  const activeVariant = myEnum.activeVariant();
@@ -2075,12 +2054,12 @@ function parseResponseValue(responseIterator, element, structs, enums) {
2075
2054
  return acc;
2076
2055
  }, {});
2077
2056
  if (element.type.startsWith("core::option::Option")) {
2078
- const content = variantNum === 0 /* Some */ ? rawEnum.Some : void 0;
2057
+ const content = variantNum === CairoOptionVariant.Some ? rawEnum.Some : void 0;
2079
2058
  return new CairoOption(variantNum, content);
2080
2059
  }
2081
2060
  if (element.type.startsWith("core::result::Result")) {
2082
2061
  let content;
2083
- if (variantNum === 0 /* Ok */) {
2062
+ if (variantNum === CairoResultVariant.Ok) {
2084
2063
  content = rawEnum.Ok;
2085
2064
  } else {
2086
2065
  content = rawEnum.Err;
@@ -2185,70 +2164,70 @@ var validateUint = (parameter, input) => {
2185
2164
  );
2186
2165
  let param;
2187
2166
  switch (input.type) {
2188
- case "core::integer::u256" /* u256 */:
2167
+ case Uint.u256:
2189
2168
  param = new CairoUint256(parameter).toBigInt();
2190
2169
  break;
2191
- case "core::integer::u512" /* u512 */:
2170
+ case Uint.u512:
2192
2171
  param = new CairoUint512(parameter).toBigInt();
2193
2172
  break;
2194
2173
  default:
2195
2174
  param = toBigInt(parameter);
2196
2175
  }
2197
2176
  switch (input.type) {
2198
- case "core::integer::u8" /* u8 */:
2177
+ case Uint.u8:
2199
2178
  assert(
2200
2179
  param >= 0n && param <= 255n,
2201
2180
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0 - 255]`
2202
2181
  );
2203
2182
  break;
2204
- case "core::integer::u16" /* u16 */:
2183
+ case Uint.u16:
2205
2184
  assert(
2206
2185
  param >= 0n && param <= 65535n,
2207
2186
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 65535]`
2208
2187
  );
2209
2188
  break;
2210
- case "core::integer::u32" /* u32 */:
2189
+ case Uint.u32:
2211
2190
  assert(
2212
2191
  param >= 0n && param <= 4294967295n,
2213
2192
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 4294967295]`
2214
2193
  );
2215
2194
  break;
2216
- case "core::integer::u64" /* u64 */:
2195
+ case Uint.u64:
2217
2196
  assert(
2218
2197
  param >= 0n && param <= 2n ** 64n - 1n,
2219
2198
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^64-1]`
2220
2199
  );
2221
2200
  break;
2222
- case "core::integer::u128" /* u128 */:
2201
+ case Uint.u128:
2223
2202
  assert(
2224
2203
  param >= 0n && param <= 2n ** 128n - 1n,
2225
2204
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^128-1]`
2226
2205
  );
2227
2206
  break;
2228
- case "core::integer::u256" /* u256 */:
2207
+ case Uint.u256:
2229
2208
  assert(
2230
2209
  param >= 0n && param <= 2n ** 256n - 1n,
2231
2210
  `Validate: arg ${input.name} is ${input.type} 0 - 2^256-1`
2232
2211
  );
2233
2212
  break;
2234
- case "core::integer::u512" /* u512 */:
2213
+ case Uint.u512:
2235
2214
  assert(CairoUint512.is(param), `Validate: arg ${input.name} is ${input.type} 0 - 2^512-1`);
2236
2215
  break;
2237
- case "core::starknet::class_hash::ClassHash" /* ClassHash */:
2216
+ case Literal.ClassHash:
2238
2217
  assert(
2239
2218
  // from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1670
2240
2219
  param >= 0n && param <= 2n ** 252n - 1n,
2241
2220
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
2242
2221
  );
2243
2222
  break;
2244
- case "core::starknet::contract_address::ContractAddress" /* ContractAddress */:
2223
+ case Literal.ContractAddress:
2245
2224
  assert(
2246
2225
  // from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1245
2247
2226
  param >= 0n && param <= 2n ** 252n - 1n,
2248
2227
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
2249
2228
  );
2250
2229
  break;
2251
- case "core::starknet::secp256k1::Secp256k1Point" /* Secp256k1Point */: {
2230
+ case Literal.Secp256k1Point: {
2252
2231
  assert(
2253
2232
  param >= 0n && param <= 2n ** 512n - 1n,
2254
2233
  `Validate: arg ${input.name} must be ${input.type} : a 512 bits number.`
@@ -2266,7 +2245,7 @@ var validateBool = (parameter, input) => {
2266
2245
  );
2267
2246
  };
2268
2247
  var validateStruct = (parameter, input, structs) => {
2269
- if (input.type === "core::integer::u256" /* u256 */ || input.type === "core::integer::u512" /* u512 */) {
2248
+ if (input.type === Uint.u256 || input.type === Uint.u512) {
2270
2249
  validateUint(parameter, input);
2271
2250
  return;
2272
2251
  }
@@ -2375,7 +2354,7 @@ var validateNonZero = (parameter, input) => {
2375
2354
  case isTypeUint(baseType):
2376
2355
  validateUint(parameter, { name: "", type: baseType });
2377
2356
  switch (input.type) {
2378
- case "core::integer::u256" /* u256 */:
2357
+ case Uint.u256:
2379
2358
  assert(
2380
2359
  new CairoUint256(parameter).toBigInt() > 0,
2381
2360
  "Validate: value 0 is not authorized in NonZero uint256 type."
@@ -2458,19 +2437,19 @@ var CallData = class _CallData {
2458
2437
  * @param args ArgsOrCalldata - arguments that are passed to the method
2459
2438
  */
2460
2439
  validate(type, method, args = []) {
2461
- if (type !== "DEPLOY" /* DEPLOY */) {
2440
+ if (type !== ValidateType.DEPLOY) {
2462
2441
  const invocableFunctionNames = this.abi.filter((abi) => {
2463
2442
  if (abi.type !== "function") return false;
2464
2443
  const isView = abi.stateMutability === "view" || abi.state_mutability === "view";
2465
- return type === "INVOKE" /* INVOKE */ ? !isView : isView;
2444
+ return type === ValidateType.INVOKE ? !isView : isView;
2466
2445
  }).map((abi) => abi.name);
2467
2446
  assert(
2468
2447
  invocableFunctionNames.includes(method),
2469
- `${type === "INVOKE" /* INVOKE */ ? "invocable" : "viewable"} method not found in abi`
2448
+ `${type === ValidateType.INVOKE ? "invocable" : "viewable"} method not found in abi`
2470
2449
  );
2471
2450
  }
2472
2451
  const abiMethod = this.abi.find(
2473
- (abi) => type === "DEPLOY" /* DEPLOY */ ? abi.name === method && abi.type === "constructor" : abi.name === method && abi.type === "function"
2452
+ (abi) => type === ValidateType.DEPLOY ? abi.name === method && abi.type === "constructor" : abi.name === method && abi.type === "function"
2474
2453
  );
2475
2454
  if (isNoConstructorValid(method, args, abiMethod)) {
2476
2455
  return;
@@ -2547,14 +2526,14 @@ var CallData = class _CallData {
2547
2526
  const keys = [...Object.getOwnPropertyNames(value), ...methodsKeys];
2548
2527
  if (keys.includes("isSome") && keys.includes("isNone")) {
2549
2528
  const myOption = value;
2550
- const variantNb = myOption.isSome() ? 0 /* Some */ : 1 /* None */;
2529
+ const variantNb = myOption.isSome() ? CairoOptionVariant.Some : CairoOptionVariant.None;
2551
2530
  if (myOption.isSome())
2552
2531
  return getEntries({ 0: variantNb, 1: myOption.unwrap() }, `${prefix}${kk}.`);
2553
2532
  return [[`${prefix}${kk}`, felt(variantNb)]];
2554
2533
  }
2555
2534
  if (keys.includes("isOk") && keys.includes("isErr")) {
2556
2535
  const myResult = value;
2557
- const variantNb = myResult.isOk() ? 0 /* Ok */ : 1 /* Err */;
2536
+ const variantNb = myResult.isOk() ? CairoResultVariant.Ok : CairoResultVariant.Err;
2558
2537
  return getEntries({ 0: variantNb, 1: myResult.unwrap() }, `${prefix}${kk}.`);
2559
2538
  }
2560
2539
  if (keys.includes("variant") && keys.includes("activeVariant")) {
@@ -3406,7 +3385,7 @@ var Block = class {
3406
3385
  } else if (isNumber(__identifier)) {
3407
3386
  this.number = __identifier;
3408
3387
  } else {
3409
- this.tag = "pending" /* PENDING */;
3388
+ this.tag = BlockTag.PENDING;
3410
3389
  }
3411
3390
  if (isNumber(this.number) && this.number < 0) {
3412
3391
  throw TypeError(`Block number (${this.number}) can't be negative`);
@@ -3600,7 +3579,7 @@ function getVersionsByType(versionType) {
3600
3579
  // src/channel/rpc_0_6.ts
3601
3580
  var defaultOptions = {
3602
3581
  headers: { "Content-Type": "application/json" },
3603
- blockIdentifier: "pending" /* PENDING */,
3582
+ blockIdentifier: BlockTag.PENDING,
3604
3583
  retries: 200
3605
3584
  };
3606
3585
  var RpcChannel = class {
@@ -4094,7 +4073,7 @@ var RpcChannel = class {
4094
4073
  account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
4095
4074
  };
4096
4075
  }
4097
- if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
4076
+ if (invocation.type === TransactionType.INVOKE) {
4098
4077
  return {
4099
4078
  // v0 v1 v3
4100
4079
  type: rpcspec_0_6_exports.ETransactionType.INVOKE,
@@ -4104,7 +4083,7 @@ var RpcChannel = class {
4104
4083
  ...details
4105
4084
  };
4106
4085
  }
4107
- if (invocation.type === "DECLARE" /* DECLARE */) {
4086
+ if (invocation.type === TransactionType.DECLARE) {
4108
4087
  if (!isSierra(invocation.contract)) {
4109
4088
  return {
4110
4089
  type: invocation.type,
@@ -4127,7 +4106,7 @@ var RpcChannel = class {
4127
4106
  ...details
4128
4107
  };
4129
4108
  }
4130
- if (invocation.type === "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */) {
4109
+ if (invocation.type === TransactionType.DEPLOY_ACCOUNT) {
4131
4110
  const { account_deployment_data, ...restDetails } = details;
4132
4111
  return {
4133
4112
  type: invocation.type,
@@ -4149,7 +4128,7 @@ __export(rpc_0_7_exports, {
4149
4128
  });
4150
4129
  var defaultOptions2 = {
4151
4130
  headers: { "Content-Type": "application/json" },
4152
- blockIdentifier: "pending" /* PENDING */,
4131
+ blockIdentifier: BlockTag.PENDING,
4153
4132
  retries: 200
4154
4133
  };
4155
4134
  var RpcChannel2 = class {
@@ -4662,7 +4641,7 @@ var RpcChannel2 = class {
4662
4641
  account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
4663
4642
  };
4664
4643
  }
4665
- if (invocation.type === "INVOKE_FUNCTION" /* INVOKE */) {
4644
+ if (invocation.type === TransactionType.INVOKE) {
4666
4645
  return {
4667
4646
  // v0 v1 v3
4668
4647
  type: RPCSPEC07.ETransactionType.INVOKE,
@@ -4672,7 +4651,7 @@ var RpcChannel2 = class {
4672
4651
  ...details
4673
4652
  };
4674
4653
  }
4675
- if (invocation.type === "DECLARE" /* DECLARE */) {
4654
+ if (invocation.type === TransactionType.DECLARE) {
4676
4655
  if (!isSierra(invocation.contract)) {
4677
4656
  return {
4678
4657
  type: invocation.type,
@@ -4695,7 +4674,7 @@ var RpcChannel2 = class {
4695
4674
  ...details
4696
4675
  };
4697
4676
  }
4698
- if (invocation.type === "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */) {
4677
+ if (invocation.type === TransactionType.DEPLOY_ACCOUNT) {
4699
4678
  const { account_deployment_data, ...restDetails } = details;
4700
4679
  return {
4701
4680
  type: invocation.type,
@@ -4824,13 +4803,13 @@ var ReceiptTx = class _ReceiptTx {
4824
4803
  return this.statusReceipt === "error";
4825
4804
  }
4826
4805
  static isSuccess(transactionReceipt) {
4827
- return transactionReceipt.execution_status === "SUCCEEDED" /* SUCCEEDED */;
4806
+ return transactionReceipt.execution_status === TransactionExecutionStatus.SUCCEEDED;
4828
4807
  }
4829
4808
  static isReverted(transactionReceipt) {
4830
- return transactionReceipt.execution_status === "REVERTED" /* REVERTED */;
4809
+ return transactionReceipt.execution_status === TransactionExecutionStatus.REVERTED;
4831
4810
  }
4832
4811
  static isRejected(transactionReceipt) {
4833
- return transactionReceipt.status === "REJECTED" /* REJECTED */;
4812
+ return transactionReceipt.status === TransactionExecutionStatus.REJECTED;
4834
4813
  }
4835
4814
  };
4836
4815
 
@@ -5321,9 +5300,9 @@ var RpcProvider = class {
5321
5300
  * ```
5322
5301
  */
5323
5302
  async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
5324
- if (blockIdentifier === "latest" /* LATEST */) return;
5303
+ if (blockIdentifier === BlockTag.LATEST) return;
5325
5304
  const currentBlock = await this.getBlockNumber();
5326
- const targetBlock = blockIdentifier === "pending" /* PENDING */ ? currentBlock + 1 : Number(toHex(blockIdentifier));
5305
+ const targetBlock = blockIdentifier === BlockTag.PENDING ? currentBlock + 1 : Number(toHex(blockIdentifier));
5327
5306
  if (targetBlock <= currentBlock) return;
5328
5307
  const { retries } = this.channel;
5329
5308
  let retriesCount = retries;
@@ -5379,7 +5358,7 @@ var RpcProvider = class {
5379
5358
  * Utility method, same result can be achieved using getBlockWithTxHashes(BlockTag.pending);
5380
5359
  */
5381
5360
  async getPendingTransactions() {
5382
- const { transactions } = await this.getBlockWithTxHashes("pending" /* PENDING */).then(
5361
+ const { transactions } = await this.getBlockWithTxHashes(BlockTag.PENDING).then(
5383
5362
  this.responseParser.parseGetBlockResponse
5384
5363
  );
5385
5364
  return Promise.all(transactions.map((it) => this.getTransactionByHash(it)));
@@ -5470,7 +5449,7 @@ var RpcProvider = class {
5470
5449
  return this.channel.getEstimateFee(
5471
5450
  [
5472
5451
  {
5473
- type: "INVOKE_FUNCTION" /* INVOKE */,
5452
+ type: TransactionType.INVOKE,
5474
5453
  ...invocation,
5475
5454
  ...invocationDetails
5476
5455
  }
@@ -5482,7 +5461,7 @@ var RpcProvider = class {
5482
5461
  return this.channel.getEstimateFee(
5483
5462
  [
5484
5463
  {
5485
- type: "DECLARE" /* DECLARE */,
5464
+ type: TransactionType.DECLARE,
5486
5465
  ...invocation,
5487
5466
  ...details
5488
5467
  }
@@ -5494,7 +5473,7 @@ var RpcProvider = class {
5494
5473
  return this.channel.getEstimateFee(
5495
5474
  [
5496
5475
  {
5497
- type: "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */,
5476
+ type: TransactionType.DEPLOY_ACCOUNT,
5498
5477
  ...invocation,
5499
5478
  ...details
5500
5479
  }
@@ -5617,6 +5596,54 @@ var RpcProvider = class {
5617
5596
  }
5618
5597
  throw Error(`Signature verification Error: ${error}`);
5619
5598
  }
5599
+ /**
5600
+ * Test if class is already declared from ContractClassIdentifier
5601
+ * Helper method using getClass
5602
+ * @param ContractClassIdentifier
5603
+ * @param blockIdentifier
5604
+ */
5605
+ async isClassDeclared(contractClassIdentifier, blockIdentifier) {
5606
+ let classHash;
5607
+ if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
5608
+ const hashes = extractContractHashes(contractClassIdentifier);
5609
+ classHash = hashes.classHash;
5610
+ } else if (contractClassIdentifier.classHash) {
5611
+ classHash = contractClassIdentifier.classHash;
5612
+ } else {
5613
+ throw Error("contractClassIdentifier type not satisfied");
5614
+ }
5615
+ try {
5616
+ const result = await this.getClass(classHash, blockIdentifier);
5617
+ return result instanceof Object;
5618
+ } catch (error) {
5619
+ if (error instanceof LibraryError) {
5620
+ return false;
5621
+ }
5622
+ throw error;
5623
+ }
5624
+ }
5625
+ /**
5626
+ * Build bulk invocations with auto-detect declared class
5627
+ * 1. Test if class is declared if not declare it preventing already declared class error and not declared class errors
5628
+ * 2. Order declarations first
5629
+ * @param invocations
5630
+ */
5631
+ async prepareInvocations(invocations) {
5632
+ const bulk = [];
5633
+ for (const invocation of invocations) {
5634
+ if (invocation.type === TransactionType.DECLARE) {
5635
+ const isDeclared = await this.isClassDeclared(
5636
+ "payload" in invocation ? invocation.payload : invocation
5637
+ );
5638
+ if (!isDeclared) {
5639
+ bulk.unshift(invocation);
5640
+ }
5641
+ } else {
5642
+ bulk.push(invocation);
5643
+ }
5644
+ }
5645
+ return bulk;
5646
+ }
5620
5647
  };
5621
5648
 
5622
5649
  // src/provider/extensions/default.ts
@@ -5720,32 +5747,30 @@ function useEncoded(decoded) {
5720
5747
  }
5721
5748
  return encoded;
5722
5749
  }
5723
- var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
5724
- StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
5725
- StarknetIdContract2["TESTNET_SEPOLIA"] = "0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474";
5726
- return StarknetIdContract2;
5727
- })(StarknetIdContract || {});
5750
+ var StarknetIdContract = {
5751
+ MAINNET: "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",
5752
+ TESTNET_SEPOLIA: "0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474"
5753
+ };
5728
5754
  function getStarknetIdContract(chainId) {
5729
5755
  switch (chainId) {
5730
5756
  case "0x534e5f4d41494e" /* SN_MAIN */:
5731
- return "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678" /* MAINNET */;
5757
+ return StarknetIdContract.MAINNET;
5732
5758
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
5733
- return "0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474" /* TESTNET_SEPOLIA */;
5759
+ return StarknetIdContract.TESTNET_SEPOLIA;
5734
5760
  default:
5735
5761
  throw new Error("Starknet.id is not yet deployed on this network");
5736
5762
  }
5737
5763
  }
5738
- var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
5739
- StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
5740
- StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda";
5741
- return StarknetIdIdentityContract2;
5742
- })(StarknetIdIdentityContract || {});
5764
+ var StarknetIdIdentityContract = {
5765
+ MAINNET: "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af",
5766
+ TESTNET_SEPOLIA: "0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda"
5767
+ };
5743
5768
  function getStarknetIdIdentityContract(chainId) {
5744
5769
  switch (chainId) {
5745
5770
  case "0x534e5f4d41494e" /* SN_MAIN */:
5746
- return "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af" /* MAINNET */;
5771
+ return StarknetIdIdentityContract.MAINNET;
5747
5772
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
5748
- return "0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda" /* TESTNET_SEPOLIA */;
5773
+ return StarknetIdIdentityContract.TESTNET_SEPOLIA;
5749
5774
  default:
5750
5775
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
5751
5776
  }
@@ -5761,49 +5786,46 @@ function getStarknetIdMulticallContract(chainId) {
5761
5786
  throw new Error("Starknet.id multicall contract is not yet deployed on this network");
5762
5787
  }
5763
5788
  }
5764
- var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
5765
- StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
5766
- StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566";
5767
- return StarknetIdVerifierContract2;
5768
- })(StarknetIdVerifierContract || {});
5789
+ var StarknetIdVerifierContract = {
5790
+ MAINNET: "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf",
5791
+ TESTNET_SEPOLIA: "0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566"
5792
+ };
5769
5793
  function getStarknetIdVerifierContract(chainId) {
5770
5794
  switch (chainId) {
5771
5795
  case "0x534e5f4d41494e" /* SN_MAIN */:
5772
- return "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf" /* MAINNET */;
5796
+ return StarknetIdVerifierContract.MAINNET;
5773
5797
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
5774
- return "0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566" /* TESTNET_SEPOLIA */;
5798
+ return StarknetIdVerifierContract.TESTNET_SEPOLIA;
5775
5799
  default:
5776
5800
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
5777
5801
  }
5778
5802
  }
5779
- var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
5780
- StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
5781
- StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02";
5782
- return StarknetIdPfpContract2;
5783
- })(StarknetIdPfpContract || {});
5803
+ var StarknetIdPfpContract = {
5804
+ MAINNET: "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7",
5805
+ TESTNET_SEPOLIA: "0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02"
5806
+ };
5784
5807
  function getStarknetIdPfpContract(chainId) {
5785
5808
  switch (chainId) {
5786
5809
  case "0x534e5f4d41494e" /* SN_MAIN */:
5787
- return "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7" /* MAINNET */;
5810
+ return StarknetIdPfpContract.MAINNET;
5788
5811
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
5789
- return "0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02" /* TESTNET_SEPOLIA */;
5812
+ return StarknetIdPfpContract.TESTNET_SEPOLIA;
5790
5813
  default:
5791
5814
  throw new Error(
5792
5815
  "Starknet.id profile picture verifier contract is not yet deployed on this network"
5793
5816
  );
5794
5817
  }
5795
5818
  }
5796
- var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
5797
- StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
5798
- StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a";
5799
- return StarknetIdPopContract2;
5800
- })(StarknetIdPopContract || {});
5819
+ var StarknetIdPopContract = {
5820
+ MAINNET: "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4",
5821
+ TESTNET_SEPOLIA: "0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a"
5822
+ };
5801
5823
  function getStarknetIdPopContract(chainId) {
5802
5824
  switch (chainId) {
5803
5825
  case "0x534e5f4d41494e" /* SN_MAIN */:
5804
- return "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4" /* MAINNET */;
5826
+ return StarknetIdPopContract.MAINNET;
5805
5827
  case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
5806
- return "0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a" /* TESTNET_SEPOLIA */;
5828
+ return StarknetIdPopContract.TESTNET_SEPOLIA;
5807
5829
  default:
5808
5830
  throw new Error(
5809
5831
  "Starknet.id proof of personhood verifier contract is not yet deployed on this network"
@@ -6494,81 +6516,6 @@ function getLedgerPathBuffer(accountId, applicationName) {
6494
6516
  return pathBuff;
6495
6517
  }
6496
6518
 
6497
- // src/utils/outsideExecution.ts
6498
- var outsideExecution_exports = {};
6499
- __export(outsideExecution_exports, {
6500
- buildExecuteFromOutsideCallData: () => buildExecuteFromOutsideCallData,
6501
- getOutsideCall: () => getOutsideCall,
6502
- getTypedData: () => getTypedData
6503
- });
6504
- function getOutsideCall(call) {
6505
- const callData = call.calldata ?? [];
6506
- const callDataCompiled = Array.isArray(callData) ? callData : CallData.compile(callData);
6507
- return {
6508
- to: call.contractAddress,
6509
- selector: getSelectorFromName(call.entrypoint),
6510
- calldata: callDataCompiled
6511
- };
6512
- }
6513
- function callToTypedData(call, version) {
6514
- const outsideCall = getOutsideCall(call);
6515
- if (version === "1") {
6516
- return {
6517
- ...outsideCall,
6518
- calldata_len: outsideCall.calldata.length,
6519
- calldata: outsideCall.calldata
6520
- };
6521
- }
6522
- return {
6523
- To: outsideCall.to,
6524
- Selector: outsideCall.selector,
6525
- Calldata: outsideCall.calldata
6526
- };
6527
- }
6528
- function getDomain(chainId, version) {
6529
- return {
6530
- name: "Account.execute_from_outside",
6531
- version,
6532
- chainId,
6533
- ...version === "2" ? { revision: "1" } : {}
6534
- };
6535
- }
6536
- function getTypedData(chainId, options, nonce, myCalls, version) {
6537
- if (version === "1") {
6538
- return {
6539
- types: OutsideExecutionTypesV1,
6540
- primaryType: "OutsideExecution",
6541
- domain: getDomain(chainId, version),
6542
- message: {
6543
- ...options,
6544
- nonce,
6545
- calls_len: myCalls.length,
6546
- calls: myCalls.map((call) => callToTypedData(call, version))
6547
- }
6548
- };
6549
- }
6550
- return {
6551
- types: OutsideExecutionTypesV2,
6552
- primaryType: "OutsideExecution",
6553
- domain: getDomain(chainId, version),
6554
- message: {
6555
- Caller: options.caller,
6556
- Nonce: nonce,
6557
- "Execute After": options.execute_after,
6558
- "Execute Before": options.execute_before,
6559
- Calls: myCalls.map((call) => callToTypedData(call, version))
6560
- }
6561
- };
6562
- }
6563
- function buildExecuteFromOutsideCallData(outsideTransaction) {
6564
- const execution2 = outsideTransaction.outsideExecution;
6565
- const formattedSignature = formatSignature(outsideTransaction.signature);
6566
- return CallData.compile({
6567
- outside_execution: execution2,
6568
- signature: formattedSignature
6569
- });
6570
- }
6571
-
6572
6519
  // src/utils/events/index.ts
6573
6520
  var events_exports = {};
6574
6521
  __export(events_exports, {
@@ -6708,6 +6655,81 @@ function parseUDCEvent(txReceipt) {
6708
6655
  };
6709
6656
  }
6710
6657
 
6658
+ // src/utils/outsideExecution.ts
6659
+ var outsideExecution_exports = {};
6660
+ __export(outsideExecution_exports, {
6661
+ buildExecuteFromOutsideCallData: () => buildExecuteFromOutsideCallData,
6662
+ getOutsideCall: () => getOutsideCall,
6663
+ getTypedData: () => getTypedData
6664
+ });
6665
+ function getOutsideCall(call) {
6666
+ const callData = call.calldata ?? [];
6667
+ const callDataCompiled = Array.isArray(callData) ? callData : CallData.compile(callData);
6668
+ return {
6669
+ to: call.contractAddress,
6670
+ selector: getSelectorFromName(call.entrypoint),
6671
+ calldata: callDataCompiled
6672
+ };
6673
+ }
6674
+ function callToTypedData(call, version) {
6675
+ const outsideCall = getOutsideCall(call);
6676
+ if (version === "1") {
6677
+ return {
6678
+ ...outsideCall,
6679
+ calldata_len: outsideCall.calldata.length,
6680
+ calldata: outsideCall.calldata
6681
+ };
6682
+ }
6683
+ return {
6684
+ To: outsideCall.to,
6685
+ Selector: outsideCall.selector,
6686
+ Calldata: outsideCall.calldata
6687
+ };
6688
+ }
6689
+ function getDomain(chainId, version) {
6690
+ return {
6691
+ name: "Account.execute_from_outside",
6692
+ version,
6693
+ chainId,
6694
+ ...version === "2" ? { revision: "1" } : {}
6695
+ };
6696
+ }
6697
+ function getTypedData(chainId, options, nonce, myCalls, version) {
6698
+ if (version === "1") {
6699
+ return {
6700
+ types: OutsideExecutionTypesV1,
6701
+ primaryType: "OutsideExecution",
6702
+ domain: getDomain(chainId, version),
6703
+ message: {
6704
+ ...options,
6705
+ nonce,
6706
+ calls_len: myCalls.length,
6707
+ calls: myCalls.map((call) => callToTypedData(call, version))
6708
+ }
6709
+ };
6710
+ }
6711
+ return {
6712
+ types: OutsideExecutionTypesV2,
6713
+ primaryType: "OutsideExecution",
6714
+ domain: getDomain(chainId, version),
6715
+ message: {
6716
+ Caller: options.caller,
6717
+ Nonce: nonce,
6718
+ "Execute After": options.execute_after,
6719
+ "Execute Before": options.execute_before,
6720
+ Calls: myCalls.map((call) => callToTypedData(call, version))
6721
+ }
6722
+ };
6723
+ }
6724
+ function buildExecuteFromOutsideCallData(outsideTransaction) {
6725
+ const execution2 = outsideTransaction.outsideExecution;
6726
+ const formattedSignature = formatSignature(outsideTransaction.signature);
6727
+ return CallData.compile({
6728
+ outside_execution: execution2,
6729
+ signature: formattedSignature
6730
+ });
6731
+ }
6732
+
6711
6733
  // src/utils/src5.ts
6712
6734
  var src5_exports = {};
6713
6735
  __export(src5_exports, {
@@ -6875,6 +6897,7 @@ var Account = class extends RpcProvider2 {
6875
6897
  return this.estimateInvokeFee(calls, details);
6876
6898
  }
6877
6899
  async estimateFeeBulk(invocations, details = {}) {
6900
+ if (!invocations.length) throw TypeError("Invocations should be non-empty array");
6878
6901
  const { nonce, blockIdentifier, version, skipValidate } = details;
6879
6902
  const accountInvocations = await this.accountInvocationsFactory(invocations, {
6880
6903
  ...v3Details(details),
@@ -6897,6 +6920,7 @@ var Account = class extends RpcProvider2 {
6897
6920
  });
6898
6921
  }
6899
6922
  async simulateTransaction(invocations, details = {}) {
6923
+ if (!invocations.length) throw TypeError("Invocations should be non-empty array");
6900
6924
  const { nonce, blockIdentifier, skipValidate = true, skipExecute, version } = details;
6901
6925
  const accountInvocations = await this.accountInvocationsFactory(invocations, {
6902
6926
  ...v3Details(details),
@@ -6929,7 +6953,7 @@ var Account = class extends RpcProvider2 {
6929
6953
  );
6930
6954
  const estimate = await this.getUniversalSuggestedFee(
6931
6955
  version,
6932
- { type: "INVOKE_FUNCTION" /* INVOKE */, payload: transactions },
6956
+ { type: TransactionType.INVOKE, payload: transactions },
6933
6957
  {
6934
6958
  ...details,
6935
6959
  version
@@ -6987,7 +7011,7 @@ var Account = class extends RpcProvider2 {
6987
7011
  const estimate = await this.getUniversalSuggestedFee(
6988
7012
  version,
6989
7013
  {
6990
- type: "DECLARE" /* DECLARE */,
7014
+ type: TransactionType.DECLARE,
6991
7015
  payload: declareContractPayload
6992
7016
  },
6993
7017
  {
@@ -7055,7 +7079,7 @@ var Account = class extends RpcProvider2 {
7055
7079
  const estimate = await this.getUniversalSuggestedFee(
7056
7080
  version,
7057
7081
  {
7058
- type: "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */,
7082
+ type: TransactionType.DEPLOY_ACCOUNT,
7059
7083
  payload: {
7060
7084
  classHash,
7061
7085
  constructorCalldata: compiledCalldata,
@@ -7297,16 +7321,16 @@ var Account = class extends RpcProvider2 {
7297
7321
  async getSuggestedFee({ type, payload }, details) {
7298
7322
  let feeEstimate;
7299
7323
  switch (type) {
7300
- case "INVOKE_FUNCTION" /* INVOKE */:
7324
+ case TransactionType.INVOKE:
7301
7325
  feeEstimate = await this.estimateInvokeFee(payload, details);
7302
7326
  break;
7303
- case "DECLARE" /* DECLARE */:
7327
+ case TransactionType.DECLARE:
7304
7328
  feeEstimate = await this.estimateDeclareFee(payload, details);
7305
7329
  break;
7306
- case "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */:
7330
+ case TransactionType.DEPLOY_ACCOUNT:
7307
7331
  feeEstimate = await this.estimateAccountDeployFee(payload, details);
7308
7332
  break;
7309
- case "DEPLOY" /* DEPLOY */:
7333
+ case TransactionType.DEPLOY:
7310
7334
  feeEstimate = await this.estimateDeployFee(payload, details);
7311
7335
  break;
7312
7336
  default:
@@ -7408,7 +7432,7 @@ var Account = class extends RpcProvider2 {
7408
7432
  const chainId = await this.getChainId();
7409
7433
  const versions = details.versions.map((it) => toTransactionVersion(it));
7410
7434
  const tx0Payload = "payload" in invocations[0] ? invocations[0].payload : invocations[0];
7411
- const cairoVersion = invocations[0].type === "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */ ? await this.getCairoVersion(tx0Payload.classHash) : await this.getCairoVersion();
7435
+ const cairoVersion = invocations[0].type === TransactionType.DEPLOY_ACCOUNT ? await this.getCairoVersion(tx0Payload.classHash) : await this.getCairoVersion();
7412
7436
  return Promise.all(
7413
7437
  [].concat(invocations).map(async (transaction, index) => {
7414
7438
  const txPayload = "payload" in transaction ? transaction.payload : transaction;
@@ -7428,7 +7452,7 @@ var Account = class extends RpcProvider2 {
7428
7452
  blockIdentifier,
7429
7453
  version: ""
7430
7454
  };
7431
- if (transaction.type === "INVOKE_FUNCTION" /* INVOKE */) {
7455
+ if (transaction.type === TransactionType.INVOKE) {
7432
7456
  const versionX = reduceV2(versions[1]);
7433
7457
  signerDetails.version = versionX;
7434
7458
  common.version = versionX;
@@ -7441,7 +7465,7 @@ var Account = class extends RpcProvider2 {
7441
7465
  ...payload
7442
7466
  };
7443
7467
  }
7444
- if (transaction.type === "DEPLOY" /* DEPLOY */) {
7468
+ if (transaction.type === TransactionType.DEPLOY) {
7445
7469
  const versionX = reduceV2(versions[1]);
7446
7470
  signerDetails.version = versionX;
7447
7471
  common.version = versionX;
@@ -7450,10 +7474,10 @@ var Account = class extends RpcProvider2 {
7450
7474
  return {
7451
7475
  ...common,
7452
7476
  ...payload,
7453
- type: "INVOKE_FUNCTION" /* INVOKE */
7477
+ type: TransactionType.INVOKE
7454
7478
  };
7455
7479
  }
7456
- if (transaction.type === "DECLARE" /* DECLARE */) {
7480
+ if (transaction.type === TransactionType.DECLARE) {
7457
7481
  const versionX = !isSierra(txPayload.contract) ? versions[0] : versions[1];
7458
7482
  signerDetails.version = versionX;
7459
7483
  common.version = versionX;
@@ -7463,7 +7487,7 @@ var Account = class extends RpcProvider2 {
7463
7487
  ...payload
7464
7488
  };
7465
7489
  }
7466
- if (transaction.type === "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */) {
7490
+ if (transaction.type === TransactionType.DEPLOY_ACCOUNT) {
7467
7491
  const versionX = reduceV2(versions[1]);
7468
7492
  signerDetails.version = versionX;
7469
7493
  common.version = versionX;
@@ -7816,7 +7840,7 @@ var Contract = class {
7816
7840
  assert(this.address !== null, "contract is not connected to an address");
7817
7841
  const calldata = getCalldata(args, () => {
7818
7842
  if (parseRequest) {
7819
- this.callData.validate("CALL" /* CALL */, method, args);
7843
+ this.callData.validate(ValidateType.CALL, method, args);
7820
7844
  return this.callData.compile(method, args);
7821
7845
  }
7822
7846
  console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
@@ -7843,7 +7867,7 @@ var Contract = class {
7843
7867
  assert(this.address !== null, "contract is not connected to an address");
7844
7868
  const calldata = getCalldata(args, () => {
7845
7869
  if (parseRequest) {
7846
- this.callData.validate("INVOKE" /* INVOKE */, method, args);
7870
+ this.callData.validate(ValidateType.INVOKE, method, args);
7847
7871
  return this.callData.compile(method, args);
7848
7872
  }
7849
7873
  console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
@@ -7875,7 +7899,7 @@ var Contract = class {
7875
7899
  async estimate(method, args = []) {
7876
7900
  assert(this.address !== null, "contract is not connected to an address");
7877
7901
  if (!getCalldata(args, () => false)) {
7878
- this.callData.validate("INVOKE" /* INVOKE */, method, args);
7902
+ this.callData.validate(ValidateType.INVOKE, method, args);
7879
7903
  }
7880
7904
  const invocation = this.populate(method, args);
7881
7905
  if ("estimateInvokeFee" in this.providerOrAccount) {
@@ -7957,7 +7981,7 @@ var ContractFactory = class {
7957
7981
  const { args: param, options = { parseRequest: true } } = splitArgsAndOptions(args);
7958
7982
  const constructorCalldata = getCalldata(param, () => {
7959
7983
  if (options.parseRequest) {
7960
- this.CallData.validate("DEPLOY" /* DEPLOY */, "constructor", param);
7984
+ this.CallData.validate(ValidateType.DEPLOY, "constructor", param);
7961
7985
  return this.CallData.compile("constructor", param);
7962
7986
  }
7963
7987
  console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");