starknet 11.10.5 → 11.10.7

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.js CHANGED
@@ -1102,7 +1102,7 @@ function getDecimalString(str) {
1102
1102
  }
1103
1103
  function getHexString(str) {
1104
1104
  if (isHex(str)) {
1105
- return str;
1105
+ return toHex(str);
1106
1106
  }
1107
1107
  if (isStringWholeNumber(str)) {
1108
1108
  return toHexString(str);
@@ -1255,6 +1255,250 @@ var OutsideExecutionVersion = {
1255
1255
  V2: "2"
1256
1256
  };
1257
1257
 
1258
+ // src/utils/helpers.ts
1259
+ function addCompiledFlag(compiled) {
1260
+ Object.defineProperty(compiled, "__compiled__", {
1261
+ enumerable: false,
1262
+ writable: false,
1263
+ value: true
1264
+ });
1265
+ return compiled;
1266
+ }
1267
+
1268
+ // src/utils/cairoDataTypes/felt.ts
1269
+ var CairoFelt252 = class _CairoFelt252 {
1270
+ /**
1271
+ * The bytes of the value, big-endian and without leading zeros.
1272
+ *
1273
+ * The length is that of the value, not a fixed width : a felt252 holding 0 is one byte, and one
1274
+ * holding `'Hello'` is five. Nothing here records how wide the input was written.
1275
+ * @example
1276
+ * ```typescript
1277
+ * const result = new CairoFelt252('Hello').data.length;
1278
+ * // result = 5
1279
+ * const result2 = new CairoFelt252(0).data.length;
1280
+ * // result2 = 1 (the single byte 0x00)
1281
+ * ```
1282
+ */
1283
+ data;
1284
+ /**
1285
+ * The abi type this class serializes.
1286
+ * @example
1287
+ * ```typescript
1288
+ * const result = CairoFelt252.abiSelector;
1289
+ * // result = "core::felt252"
1290
+ * ```
1291
+ */
1292
+ static abiSelector = "core::felt252";
1293
+ /**
1294
+ * Build from a number, a string or a boolean, refusing anything outside [0, P).
1295
+ *
1296
+ * The bytes are stored without their leading zeros, so `'0x0041'` and `'0x41'` give the same
1297
+ * felt252. A boolean is carried as 1 or 0.
1298
+ * @param {BigNumberish | boolean} data the value to carry, within [0, P)
1299
+ * @throws {Error} when the value is null, undefined, of an unread type, or outside [0, P)
1300
+ * @example
1301
+ * ```typescript
1302
+ * const result = new CairoFelt252('Hello').toApiRequest();
1303
+ * // result = ["310939249775"]
1304
+ * ```
1305
+ */
1306
+ constructor(data) {
1307
+ _CairoFelt252.validate(data);
1308
+ const processedData = _CairoFelt252.__processData(data);
1309
+ this.data = processedData.subarray(processedData.findIndex((x) => x > 0));
1310
+ }
1311
+ /**
1312
+ * Turn an accepted input into its bytes, before the constructor strips their leading zeros.
1313
+ *
1314
+ * The range is not checked here : `validate` is what reads these bytes and decides. Only the
1315
+ * type is, and an input this class does not read raises rather than coming back.
1316
+ * @param {BigNumberish | boolean} data the value to convert
1317
+ * @returns {Uint8Array} the bytes of the value, of whatever length it implies
1318
+ * @throws {Error} when the input is neither a string, an integer, a bigint nor a boolean
1319
+ * @example
1320
+ * ```typescript
1321
+ * const result = CairoFelt252.__processData('Hello').length;
1322
+ * // result = 5
1323
+ * CairoFelt252.__processData(1.5);
1324
+ * // throws Error("1.5 can't be computed by felt()")
1325
+ * ```
1326
+ */
1327
+ static __processData(data) {
1328
+ if (isString(data)) {
1329
+ return stringToUint8Array(data);
1330
+ }
1331
+ if (isBigInt(data)) {
1332
+ return bigIntToUint8Array(data);
1333
+ }
1334
+ if (Number.isInteger(data)) {
1335
+ return bigIntToUint8Array(BigInt(data));
1336
+ }
1337
+ if (isBoolean(data)) {
1338
+ return bigIntToUint8Array(BigInt(data ? 1 : 0));
1339
+ }
1340
+ throw new Error(`${data} can't be computed by felt()`);
1341
+ }
1342
+ /**
1343
+ * The bytes read as one big-endian number.
1344
+ * @returns {bigint} the value this felt252 holds
1345
+ * @example
1346
+ * ```typescript
1347
+ * const result = new CairoFelt252('Hello').toBigInt();
1348
+ * // result = 310939249775n
1349
+ * ```
1350
+ */
1351
+ toBigInt() {
1352
+ return uint8ArrayToBigInt(this.data);
1353
+ }
1354
+ /**
1355
+ * Read the bytes back as UTF-8 text.
1356
+ *
1357
+ * Only a value that was text to begin with comes back as readable text : the bytes of a number
1358
+ * are decoded all the same, and what they spell is rarely what was meant.
1359
+ * @returns {string} the bytes decoded as UTF-8
1360
+ * @example
1361
+ * ```typescript
1362
+ * const result = new CairoFelt252('Hello').decodeUtf8();
1363
+ * // result = "Hello"
1364
+ * const result2 = new CairoFelt252('12345').decodeUtf8();
1365
+ * // result2 = "09" (the number 12345 is the two bytes 0x30 0x39)
1366
+ * ```
1367
+ */
1368
+ decodeUtf8() {
1369
+ return new TextDecoder().decode(this.data);
1370
+ }
1371
+ /**
1372
+ * The value in hexadecimal, without padding.
1373
+ * @returns {string} the value as a 0x-prefixed hex string
1374
+ * @example
1375
+ * ```typescript
1376
+ * const result = new CairoFelt252('Hello').toHexString();
1377
+ * // result = "0x48656c6c6f"
1378
+ * const result2 = new CairoFelt252(0).toHexString();
1379
+ * // result2 = "0x0" (one digit, not "0x00")
1380
+ * ```
1381
+ */
1382
+ toHexString() {
1383
+ return addHexPrefix(this.toBigInt().toString(16));
1384
+ }
1385
+ /**
1386
+ * Serialize to the single felt a contract call carries.
1387
+ * @returns {string[]} one decimal-string felt, flagged as compiled
1388
+ * @example
1389
+ * ```typescript
1390
+ * const result = new CairoFelt252('Hello').toApiRequest();
1391
+ * // result = ["310939249775"]
1392
+ * ```
1393
+ */
1394
+ toApiRequest() {
1395
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1396
+ }
1397
+ /**
1398
+ * Throw unless a number falls in the felt252 range [0, P).
1399
+ *
1400
+ * This takes the number itself, where {@link CairoFelt252.validate} takes whatever a caller
1401
+ * hands over. P is excluded : the largest felt252 is P - 1.
1402
+ * @param {bigint} val the number to check
1403
+ * @throws {Error} when the number is negative or greater than or equal to P
1404
+ * @example
1405
+ * ```typescript
1406
+ * CairoFelt252.assertRange(0n); // passes
1407
+ * CairoFelt252.assertRange(-1n);
1408
+ * // throws Error("Value -1 is out of felt252 range [0, 3618502788666131213697322783095070105623107215331596699973092056135872020481)")
1409
+ * ```
1410
+ */
1411
+ static assertRange(val) {
1412
+ assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
1413
+ }
1414
+ /**
1415
+ * Throw unless the value can be carried by a felt252.
1416
+ *
1417
+ * Null, undefined, any type this class does not read, and `'0x'` are refused first, each with its
1418
+ * own message, then the value is converted and its range checked. A negative number does not
1419
+ * reach that range check : converting it fails earlier, and the message comes from the conversion.
1420
+ * @param {BigNumberish | boolean} data the value to check
1421
+ * @throws {Error} when the value is null, undefined, of an unread type, `'0x'`, or outside [0, P)
1422
+ * @example
1423
+ * ```typescript
1424
+ * CairoFelt252.validate('Hello'); // passes
1425
+ * CairoFelt252.validate({});
1426
+ * // throws Error("Unsupported data type 'object' for felt252. Expected string, number, bigint, or boolean")
1427
+ * CairoFelt252.validate('0x');
1428
+ * // throws Error("Invalid input: '0x' holds no hexadecimal digit")
1429
+ * CairoFelt252.validate(-1);
1430
+ * // throws Error("Cannot convert negative bigint -1 to Uint8Array")
1431
+ * ```
1432
+ */
1433
+ static validate(data) {
1434
+ assert(data !== null, "null value is not allowed for felt252");
1435
+ assert(data !== void 0, "undefined value is not allowed for felt252");
1436
+ assert(
1437
+ isString(data) || isNumber(data) || isBigInt(data) || isBoolean(data),
1438
+ `Unsupported data type '${typeof data}' for felt252. Expected string, number, bigint, or boolean`
1439
+ );
1440
+ assert(!isEmptyHex(data), "Invalid input: '0x' holds no hexadecimal digit");
1441
+ const value = _CairoFelt252.__processData(data);
1442
+ const bn = uint8ArrayToBigInt(value);
1443
+ _CairoFelt252.assertRange(bn);
1444
+ }
1445
+ /**
1446
+ * Can this value be carried by a felt252?
1447
+ *
1448
+ * The non-throwing form of {@link CairoFelt252.validate}, so it answers false for every input
1449
+ * that one refuses, whatever the reason.
1450
+ * @param {BigNumberish | boolean} data the value to test
1451
+ * @returns {boolean} true when the value fits in a felt252
1452
+ * @example
1453
+ * ```typescript
1454
+ * const result = CairoFelt252.is('Hello');
1455
+ * // result = true
1456
+ * const result2 = CairoFelt252.is(-1);
1457
+ * // result2 = false
1458
+ * ```
1459
+ */
1460
+ static is(data) {
1461
+ try {
1462
+ _CairoFelt252.validate(data);
1463
+ return true;
1464
+ } catch {
1465
+ return false;
1466
+ }
1467
+ }
1468
+ /**
1469
+ * Is this abi type the one this class serializes?
1470
+ * @param {string} abiType the abi type to test
1471
+ * @returns {boolean} true for `core::felt252`
1472
+ * @example
1473
+ * ```typescript
1474
+ * const result = CairoFelt252.isAbiType('core::felt252');
1475
+ * // result = true
1476
+ * const result2 = CairoFelt252.isAbiType('core::integer::u8');
1477
+ * // result2 = false
1478
+ * ```
1479
+ */
1480
+ static isAbiType(abiType) {
1481
+ return abiType === _CairoFelt252.abiSelector;
1482
+ }
1483
+ /**
1484
+ * Read one felt252 off a contract response, advancing the iterator past it.
1485
+ *
1486
+ * The felts a node returns are hex strings, and one is consumed per call, so successive calls
1487
+ * read successive return values.
1488
+ * @param {Iterator<string>} responseIterator the response felts, positioned on this felt252
1489
+ * @returns {CairoFelt252} the felt252 that was read
1490
+ * @example
1491
+ * ```typescript
1492
+ * const response = ['0x48656c6c6f'];
1493
+ * const result = CairoFelt252.factoryFromApiResponse(response.values()).decodeUtf8();
1494
+ * // result = "Hello"
1495
+ * ```
1496
+ */
1497
+ static factoryFromApiResponse(responseIterator) {
1498
+ return new _CairoFelt252(getNext(responseIterator));
1499
+ }
1500
+ };
1501
+
1258
1502
  // src/utils/hash/index.ts
1259
1503
  var hash_exports = {};
1260
1504
  __export(hash_exports, {
@@ -1744,371 +1988,127 @@ function blake2sHashMany(data) {
1744
1988
  const word4 = feltView.getUint32(16, false);
1745
1989
  const word5 = feltView.getUint32(20, false);
1746
1990
  const word6 = feltView.getUint32(24, false);
1747
- const word7 = feltView.getUint32(28, false);
1748
- u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
1749
- }
1750
- }
1751
- const bytes = new ArrayBuffer(u32Words.length * 4);
1752
- const bytesView = new DataView(bytes);
1753
- for (let i = 0; i < u32Words.length; i++) {
1754
- bytesView.setUint32(i * 4, u32Words[i], true);
1755
- }
1756
- const hash = blakeHash(new Uint8Array(bytes));
1757
- let hashBigInt = 0n;
1758
- for (let i = 0; i < 32; i++) {
1759
- hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
1760
- }
1761
- return hashBigInt % PRIME;
1762
- }
1763
- function hashBuiltinsBlake(builtins) {
1764
- return blake2sHashMany(encodeBuiltins(builtins));
1765
- }
1766
- function hashEntryPointBlake(data) {
1767
- const base = data.flatMap((it) => {
1768
- return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
1769
- });
1770
- return blake2sHashMany(base);
1771
- }
1772
- function bytecodeHashNodeBlake(iter, node) {
1773
- if (typeof node === "number") {
1774
- const data = [];
1775
- for (let i = 0; i < node; i++) {
1776
- const next = iter.next();
1777
- if (next.done) throw new Error("Bytecode length mismatch");
1778
- data.push(next.value);
1779
- }
1780
- return [node, blake2sHashMany(data)];
1781
- }
1782
- const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
1783
- const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
1784
- const hash = blake2sHashMany(flatData) + 1n;
1785
- const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
1786
- return [totalLen, hash];
1787
- }
1788
- function hashByteCodeSegmentsBlake(casm) {
1789
- const byteCode = casm.bytecode.map((n) => BigInt(n));
1790
- const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
1791
- if (!bytecodeSegmentLengths) {
1792
- return blake2sHashMany(byteCode);
1793
- }
1794
- const iter = byteCode[Symbol.iterator]();
1795
- const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
1796
- if (len !== byteCode.length) {
1797
- throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
1798
- }
1799
- return hash;
1800
- }
1801
- function computeCompiledClassHashBlake(casm) {
1802
- const compiledClassVersion = utf8ToBigInt(COMPILED_CLASS_VERSION);
1803
- const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
1804
- const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
1805
- const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
1806
- const bytecode = hashByteCodeSegmentsBlake(casm);
1807
- return toHex(
1808
- blake2sHashMany([
1809
- compiledClassVersion,
1810
- externalEntryPointsHash,
1811
- l1Handlers,
1812
- constructor,
1813
- bytecode
1814
- ])
1815
- );
1816
- }
1817
-
1818
- // src/utils/resolve.ts
1819
- function isV3Tx(details) {
1820
- const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
1821
- return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
1822
- }
1823
- function isVersion(expected, provided) {
1824
- const expectedParts = expected.split(".");
1825
- const providedParts = provided.split(".");
1826
- return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
1827
- }
1828
- function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
1829
- return Object.values(_SupportedRpcVersion).some(
1830
- (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
1831
- );
1832
- }
1833
- function toAnyPatchVersion(version) {
1834
- const parts = version.split(".");
1835
- if (parts.length < 3) {
1836
- return version;
1837
- }
1838
- return `${parts[0]}.${parts[1]}.*`;
1839
- }
1840
- function toReleaseVersion(version) {
1841
- return version.split(/[-+]/)[0];
1842
- }
1843
- function toApiVersion(version) {
1844
- const [major, minor] = version.replace(/^v/, "").split(".");
1845
- return `v${major}_${minor}`;
1846
- }
1847
- function compareVersions(a, b) {
1848
- const aParts = toReleaseVersion(a).split(".").map(Number);
1849
- const bParts = toReleaseVersion(b).split(".").map(Number);
1850
- const maxLen = Math.max(aParts.length, bParts.length);
1851
- for (let i = 0; i < maxLen; i += 1) {
1852
- const aNum = aParts[i] || 0;
1853
- const bNum = bParts[i] || 0;
1854
- if (aNum > bNum) return 1;
1855
- if (aNum < bNum) return -1;
1856
- }
1857
- return 0;
1858
- }
1859
- function isPreConfirmedBlock(response) {
1860
- return response.status === rpc_exports.EBlockStatus.PRE_CONFIRMED;
1861
- }
1862
- function isPreConfirmedTransaction(response) {
1863
- return !("block_hash" in response);
1864
- }
1865
- function isPreConfirmedStateUpdate(response) {
1866
- return !("block_hash" in response);
1867
- }
1868
-
1869
- // src/utils/helpers.ts
1870
- function addCompiledFlag(compiled) {
1871
- Object.defineProperty(compiled, "__compiled__", {
1872
- enumerable: false,
1873
- writable: false,
1874
- value: true
1875
- });
1876
- return compiled;
1877
- }
1878
-
1879
- // src/utils/cairoDataTypes/felt.ts
1880
- var CairoFelt252 = class _CairoFelt252 {
1881
- /**
1882
- * The bytes of the value, big-endian and without leading zeros.
1883
- *
1884
- * The length is that of the value, not a fixed width : a felt252 holding 0 is one byte, and one
1885
- * holding `'Hello'` is five. Nothing here records how wide the input was written.
1886
- * @example
1887
- * ```typescript
1888
- * const result = new CairoFelt252('Hello').data.length;
1889
- * // result = 5
1890
- * const result2 = new CairoFelt252(0).data.length;
1891
- * // result2 = 1 (the single byte 0x00)
1892
- * ```
1893
- */
1894
- data;
1895
- /**
1896
- * The abi type this class serializes.
1897
- * @example
1898
- * ```typescript
1899
- * const result = CairoFelt252.abiSelector;
1900
- * // result = "core::felt252"
1901
- * ```
1902
- */
1903
- static abiSelector = "core::felt252";
1904
- /**
1905
- * Build from a number, a string or a boolean, refusing anything outside [0, P).
1906
- *
1907
- * The bytes are stored without their leading zeros, so `'0x0041'` and `'0x41'` give the same
1908
- * felt252. A boolean is carried as 1 or 0.
1909
- * @param {BigNumberish | boolean} data the value to carry, within [0, P)
1910
- * @throws {Error} when the value is null, undefined, of an unread type, or outside [0, P)
1911
- * @example
1912
- * ```typescript
1913
- * const result = new CairoFelt252('Hello').toApiRequest();
1914
- * // result = ["310939249775"]
1915
- * ```
1916
- */
1917
- constructor(data) {
1918
- _CairoFelt252.validate(data);
1919
- const processedData = _CairoFelt252.__processData(data);
1920
- this.data = processedData.subarray(processedData.findIndex((x) => x > 0));
1921
- }
1922
- /**
1923
- * Turn an accepted input into its bytes, before the constructor strips their leading zeros.
1924
- *
1925
- * The range is not checked here : `validate` is what reads these bytes and decides. Only the
1926
- * type is, and an input this class does not read raises rather than coming back.
1927
- * @param {BigNumberish | boolean} data the value to convert
1928
- * @returns {Uint8Array} the bytes of the value, of whatever length it implies
1929
- * @throws {Error} when the input is neither a string, an integer, a bigint nor a boolean
1930
- * @example
1931
- * ```typescript
1932
- * const result = CairoFelt252.__processData('Hello').length;
1933
- * // result = 5
1934
- * CairoFelt252.__processData(1.5);
1935
- * // throws Error("1.5 can't be computed by felt()")
1936
- * ```
1937
- */
1938
- static __processData(data) {
1939
- if (isString(data)) {
1940
- return stringToUint8Array(data);
1941
- }
1942
- if (isBigInt(data)) {
1943
- return bigIntToUint8Array(data);
1944
- }
1945
- if (Number.isInteger(data)) {
1946
- return bigIntToUint8Array(BigInt(data));
1947
- }
1948
- if (isBoolean(data)) {
1949
- return bigIntToUint8Array(BigInt(data ? 1 : 0));
1950
- }
1951
- throw new Error(`${data} can't be computed by felt()`);
1952
- }
1953
- /**
1954
- * The bytes read as one big-endian number.
1955
- * @returns {bigint} the value this felt252 holds
1956
- * @example
1957
- * ```typescript
1958
- * const result = new CairoFelt252('Hello').toBigInt();
1959
- * // result = 310939249775n
1960
- * ```
1961
- */
1962
- toBigInt() {
1963
- return uint8ArrayToBigInt(this.data);
1964
- }
1965
- /**
1966
- * Read the bytes back as UTF-8 text.
1967
- *
1968
- * Only a value that was text to begin with comes back as readable text : the bytes of a number
1969
- * are decoded all the same, and what they spell is rarely what was meant.
1970
- * @returns {string} the bytes decoded as UTF-8
1971
- * @example
1972
- * ```typescript
1973
- * const result = new CairoFelt252('Hello').decodeUtf8();
1974
- * // result = "Hello"
1975
- * const result2 = new CairoFelt252('12345').decodeUtf8();
1976
- * // result2 = "09" (the number 12345 is the two bytes 0x30 0x39)
1977
- * ```
1978
- */
1979
- decodeUtf8() {
1980
- return new TextDecoder().decode(this.data);
1981
- }
1982
- /**
1983
- * The value in hexadecimal, without padding.
1984
- * @returns {string} the value as a 0x-prefixed hex string
1985
- * @example
1986
- * ```typescript
1987
- * const result = new CairoFelt252('Hello').toHexString();
1988
- * // result = "0x48656c6c6f"
1989
- * const result2 = new CairoFelt252(0).toHexString();
1990
- * // result2 = "0x0" (one digit, not "0x00")
1991
- * ```
1992
- */
1993
- toHexString() {
1994
- return addHexPrefix(this.toBigInt().toString(16));
1995
- }
1996
- /**
1997
- * Serialize to the single felt a contract call carries.
1998
- * @returns {string[]} one decimal-string felt, flagged as compiled
1999
- * @example
2000
- * ```typescript
2001
- * const result = new CairoFelt252('Hello').toApiRequest();
2002
- * // result = ["310939249775"]
2003
- * ```
2004
- */
2005
- toApiRequest() {
2006
- return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1991
+ const word7 = feltView.getUint32(28, false);
1992
+ u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
1993
+ }
2007
1994
  }
2008
- /**
2009
- * Throw unless a number falls in the felt252 range [0, P).
2010
- *
2011
- * This takes the number itself, where {@link CairoFelt252.validate} takes whatever a caller
2012
- * hands over. P is excluded : the largest felt252 is P - 1.
2013
- * @param {bigint} val the number to check
2014
- * @throws {Error} when the number is negative or greater than or equal to P
2015
- * @example
2016
- * ```typescript
2017
- * CairoFelt252.assertRange(0n); // passes
2018
- * CairoFelt252.assertRange(-1n);
2019
- * // throws Error("Value -1 is out of felt252 range [0, 3618502788666131213697322783095070105623107215331596699973092056135872020481)")
2020
- * ```
2021
- */
2022
- static assertRange(val) {
2023
- assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
1995
+ const bytes = new ArrayBuffer(u32Words.length * 4);
1996
+ const bytesView = new DataView(bytes);
1997
+ for (let i = 0; i < u32Words.length; i++) {
1998
+ bytesView.setUint32(i * 4, u32Words[i], true);
2024
1999
  }
2025
- /**
2026
- * Throw unless the value can be carried by a felt252.
2027
- *
2028
- * Null, undefined, any type this class does not read, and `'0x'` are refused first, each with its
2029
- * own message, then the value is converted and its range checked. A negative number does not
2030
- * reach that range check : converting it fails earlier, and the message comes from the conversion.
2031
- * @param {BigNumberish | boolean} data the value to check
2032
- * @throws {Error} when the value is null, undefined, of an unread type, `'0x'`, or outside [0, P)
2033
- * @example
2034
- * ```typescript
2035
- * CairoFelt252.validate('Hello'); // passes
2036
- * CairoFelt252.validate({});
2037
- * // throws Error("Unsupported data type 'object' for felt252. Expected string, number, bigint, or boolean")
2038
- * CairoFelt252.validate('0x');
2039
- * // throws Error("Invalid input: '0x' holds no hexadecimal digit")
2040
- * CairoFelt252.validate(-1);
2041
- * // throws Error("Cannot convert negative bigint -1 to Uint8Array")
2042
- * ```
2043
- */
2044
- static validate(data) {
2045
- assert(data !== null, "null value is not allowed for felt252");
2046
- assert(data !== void 0, "undefined value is not allowed for felt252");
2047
- assert(
2048
- isString(data) || isNumber(data) || isBigInt(data) || isBoolean(data),
2049
- `Unsupported data type '${typeof data}' for felt252. Expected string, number, bigint, or boolean`
2050
- );
2051
- assert(!isEmptyHex(data), "Invalid input: '0x' holds no hexadecimal digit");
2052
- const value = _CairoFelt252.__processData(data);
2053
- const bn = uint8ArrayToBigInt(value);
2054
- _CairoFelt252.assertRange(bn);
2000
+ const hash = blakeHash(new Uint8Array(bytes));
2001
+ let hashBigInt = 0n;
2002
+ for (let i = 0; i < 32; i++) {
2003
+ hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
2055
2004
  }
2056
- /**
2057
- * Can this value be carried by a felt252?
2058
- *
2059
- * The non-throwing form of {@link CairoFelt252.validate}, so it answers false for every input
2060
- * that one refuses, whatever the reason.
2061
- * @param {BigNumberish | boolean} data the value to test
2062
- * @returns {boolean} true when the value fits in a felt252
2063
- * @example
2064
- * ```typescript
2065
- * const result = CairoFelt252.is('Hello');
2066
- * // result = true
2067
- * const result2 = CairoFelt252.is(-1);
2068
- * // result2 = false
2069
- * ```
2070
- */
2071
- static is(data) {
2072
- try {
2073
- _CairoFelt252.validate(data);
2074
- return true;
2075
- } catch {
2076
- return false;
2005
+ return hashBigInt % PRIME;
2006
+ }
2007
+ function hashBuiltinsBlake(builtins) {
2008
+ return blake2sHashMany(encodeBuiltins(builtins));
2009
+ }
2010
+ function hashEntryPointBlake(data) {
2011
+ const base = data.flatMap((it) => {
2012
+ return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
2013
+ });
2014
+ return blake2sHashMany(base);
2015
+ }
2016
+ function bytecodeHashNodeBlake(iter, node) {
2017
+ if (typeof node === "number") {
2018
+ const data = [];
2019
+ for (let i = 0; i < node; i++) {
2020
+ const next = iter.next();
2021
+ if (next.done) throw new Error("Bytecode length mismatch");
2022
+ data.push(next.value);
2077
2023
  }
2024
+ return [node, blake2sHashMany(data)];
2078
2025
  }
2079
- /**
2080
- * Is this abi type the one this class serializes?
2081
- * @param {string} abiType the abi type to test
2082
- * @returns {boolean} true for `core::felt252`
2083
- * @example
2084
- * ```typescript
2085
- * const result = CairoFelt252.isAbiType('core::felt252');
2086
- * // result = true
2087
- * const result2 = CairoFelt252.isAbiType('core::integer::u8');
2088
- * // result2 = false
2089
- * ```
2090
- */
2091
- static isAbiType(abiType) {
2092
- return abiType === _CairoFelt252.abiSelector;
2026
+ const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
2027
+ const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
2028
+ const hash = blake2sHashMany(flatData) + 1n;
2029
+ const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
2030
+ return [totalLen, hash];
2031
+ }
2032
+ function hashByteCodeSegmentsBlake(casm) {
2033
+ const byteCode = casm.bytecode.map((n) => BigInt(n));
2034
+ const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
2035
+ if (!bytecodeSegmentLengths) {
2036
+ return blake2sHashMany(byteCode);
2093
2037
  }
2094
- /**
2095
- * Read one felt252 off a contract response, advancing the iterator past it.
2096
- *
2097
- * The felts a node returns are hex strings, and one is consumed per call, so successive calls
2098
- * read successive return values.
2099
- * @param {Iterator<string>} responseIterator the response felts, positioned on this felt252
2100
- * @returns {CairoFelt252} the felt252 that was read
2101
- * @example
2102
- * ```typescript
2103
- * const response = ['0x48656c6c6f'];
2104
- * const result = CairoFelt252.factoryFromApiResponse(response.values()).decodeUtf8();
2105
- * // result = "Hello"
2106
- * ```
2107
- */
2108
- static factoryFromApiResponse(responseIterator) {
2109
- return new _CairoFelt252(getNext(responseIterator));
2038
+ const iter = byteCode[Symbol.iterator]();
2039
+ const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
2040
+ if (len !== byteCode.length) {
2041
+ throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
2110
2042
  }
2111
- };
2043
+ return hash;
2044
+ }
2045
+ function computeCompiledClassHashBlake(casm) {
2046
+ const compiledClassVersion = utf8ToBigInt(COMPILED_CLASS_VERSION);
2047
+ const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
2048
+ const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
2049
+ const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
2050
+ const bytecode = hashByteCodeSegmentsBlake(casm);
2051
+ return toHex(
2052
+ blake2sHashMany([
2053
+ compiledClassVersion,
2054
+ externalEntryPointsHash,
2055
+ l1Handlers,
2056
+ constructor,
2057
+ bytecode
2058
+ ])
2059
+ );
2060
+ }
2061
+
2062
+ // src/utils/resolve.ts
2063
+ function isV3Tx(details) {
2064
+ const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
2065
+ return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
2066
+ }
2067
+ function isVersion(expected, provided) {
2068
+ const expectedParts = expected.split(".");
2069
+ const providedParts = provided.split(".");
2070
+ return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
2071
+ }
2072
+ function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
2073
+ return Object.values(_SupportedRpcVersion).some(
2074
+ (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
2075
+ );
2076
+ }
2077
+ function toAnyPatchVersion(version) {
2078
+ const parts = version.split(".");
2079
+ if (parts.length < 3) {
2080
+ return version;
2081
+ }
2082
+ return `${parts[0]}.${parts[1]}.*`;
2083
+ }
2084
+ function toReleaseVersion(version) {
2085
+ return version.split(/[-+]/)[0];
2086
+ }
2087
+ function toApiVersion(version) {
2088
+ const [major, minor] = version.replace(/^v/, "").split(".");
2089
+ return `v${major}_${minor}`;
2090
+ }
2091
+ function compareVersions(a, b) {
2092
+ const aParts = toReleaseVersion(a).split(".").map(Number);
2093
+ const bParts = toReleaseVersion(b).split(".").map(Number);
2094
+ const maxLen = Math.max(aParts.length, bParts.length);
2095
+ for (let i = 0; i < maxLen; i += 1) {
2096
+ const aNum = aParts[i] || 0;
2097
+ const bNum = bParts[i] || 0;
2098
+ if (aNum > bNum) return 1;
2099
+ if (aNum < bNum) return -1;
2100
+ }
2101
+ return 0;
2102
+ }
2103
+ function isPreConfirmedBlock(response) {
2104
+ return response.status === rpc_exports.EBlockStatus.PRE_CONFIRMED;
2105
+ }
2106
+ function isPreConfirmedTransaction(response) {
2107
+ return !("block_hash" in response);
2108
+ }
2109
+ function isPreConfirmedStateUpdate(response) {
2110
+ return !("block_hash" in response);
2111
+ }
2112
2112
 
2113
2113
  // src/utils/cairoDataTypes/cairoType.interface.ts
2114
2114
  function isCairoType(value) {
@@ -12787,79 +12787,62 @@ function getSupportedRpcVersions() {
12787
12787
  }
12788
12788
  var validBlockTags = Object.values(BlockTag);
12789
12789
  var Block = class {
12790
- /**
12791
- * @param {BlockIdentifier} hash if not null, contains the block hash
12792
- */
12790
+ /** It holds the block hash when the block is given by its hash. Otherwise, it is null. */
12793
12791
  hash = null;
12794
- /**
12795
- * @param {BlockIdentifier} number if not null, contains the block number
12796
- */
12792
+ /** It holds the block number when the block is given by its number. Otherwise, it is null. */
12797
12793
  number = null;
12794
+ /** It holds the block tag when the block is given by a tag. Otherwise, it is null. */
12795
+ tag = null;
12798
12796
  /**
12799
- * @param {BlockIdentifier} tag if not null, contains "pre_confirmed" or "latest"
12797
+ * Create a Block.
12798
+ * @param {BlockIdentifier} _identifier the block number, the block hash or the block tag.
12799
+ * `null` and `undefined` mean `'latest'`.
12800
+ * @throws {Error} The identifier names no block. It is an empty string, a text that is not a
12801
+ * block tag, a hash that is not a felt (`'0x'`, a negative bigint, or a value larger than the
12802
+ * largest felt), a number that is not an integer, a negative number, a number larger than
12803
+ * `Number.MAX_SAFE_INTEGER`, or a value that is not a string, a number or a bigint.
12804
+ * @example
12805
+ * ```typescript
12806
+ * const result = new provider.Block('0X0abc').identifier;
12807
+ * // result = { block_hash: '0xabc' }
12808
+ *
12809
+ * new provider.Block(1.5);
12810
+ * // throws Error: Block number (1.5) must be an integer
12811
+ * ```
12800
12812
  */
12801
- tag = null;
12802
- setIdentifier(__identifier) {
12803
- this.hash = null;
12804
- this.number = null;
12805
- this.tag = null;
12806
- if (isString(__identifier)) {
12807
- if (__identifier !== "" && isDecimalString2(__identifier)) {
12808
- this.number = parseInt(__identifier, 10);
12809
- } else if (isHex(__identifier) && !isEmptyHex(__identifier)) {
12810
- this.hash = __identifier;
12811
- } else if (validBlockTags.includes(__identifier)) {
12812
- this.tag = __identifier;
12813
+ constructor(_identifier) {
12814
+ if (isString(_identifier)) {
12815
+ if (isStringWholeNumber(_identifier)) {
12816
+ this.number = parseInt(_identifier, 10);
12817
+ } else if (isHex(_identifier)) {
12818
+ this.hash = new CairoFelt252(_identifier).toHexString();
12813
12819
  } else {
12814
- throw TypeError(`Block identifier unmanaged: ${__identifier}`);
12820
+ assert(
12821
+ validBlockTags.includes(_identifier),
12822
+ `Block identifier unmanaged: '${_identifier}'`
12823
+ );
12824
+ this.tag = _identifier;
12815
12825
  }
12816
- } else if (isBigInt(__identifier)) {
12817
- this.hash = toHex(__identifier);
12818
- } else if (isNumber(__identifier)) {
12819
- this.number = __identifier;
12826
+ } else if (isBigInt(_identifier)) {
12827
+ this.hash = new CairoFelt252(_identifier).toHexString();
12828
+ } else if (isNumber(_identifier)) {
12829
+ this.number = _identifier;
12820
12830
  } else {
12821
- this.tag = BlockTag.LATEST;
12822
- }
12823
- if (isNumber(this.number) && this.number < 0) {
12824
- throw TypeError(`Block number (${this.number}) can't be negative`);
12825
- }
12826
- if (isNumber(this.number) && !Number.isSafeInteger(this.number)) {
12827
- throw TypeError(
12828
- `Block number (${__identifier}) must be a whole number no larger than Number.MAX_SAFE_INTEGER`
12831
+ assert(
12832
+ _identifier === null || _identifier === void 0,
12833
+ `Block identifier unmanaged: ${_identifier}`
12829
12834
  );
12835
+ this.tag = BlockTag.LATEST;
12830
12836
  }
12831
- }
12832
- /**
12833
- * Create a Block instance
12834
- * @param {BlockIdentifier} _identifier hex string and BigInt are detected as block hashes.
12835
- * decimal string and number are detected as block numbers.
12836
- * text string are detected as block tag.
12837
- * null is considered as a 'latest' block tag.
12838
- */
12839
- constructor(_identifier) {
12840
- this.setIdentifier(_identifier);
12841
- }
12842
- // TODO: fix any
12843
- /**
12844
- * @returns {any} the identifier as a string
12845
- * @example
12846
- * ```typescript
12847
- * const result = new provider.Block(123456n).queryIdentifier;
12848
- * // result = "blockHash=0x1e240"
12849
- * ```
12850
- */
12851
- get queryIdentifier() {
12852
12837
  if (this.number !== null) {
12853
- return `blockNumber=${this.number}`;
12838
+ assert(isInteger2(this.number), `Block number (${_identifier}) must be an integer`);
12839
+ assertInRange(this.number, 0, Number.MAX_SAFE_INTEGER, "block number");
12854
12840
  }
12855
- if (this.hash !== null) {
12856
- return `blockHash=${this.hash}`;
12857
- }
12858
- return `blockNumber=${this.tag}`;
12841
+ Object.freeze(this);
12859
12842
  }
12860
- // TODO: fix any
12861
12843
  /**
12862
- * @returns {any} the identifier as an object
12844
+ * @returns {RPC.BLOCK_ID} the block in the form of the `block_id` of an RPC request:
12845
+ * `{ block_number: number }`, `{ block_hash: string }` or a block tag.
12863
12846
  * @example
12864
12847
  * ```typescript
12865
12848
  * const result = new provider.Block(56789).identifier;
@@ -12875,21 +12858,6 @@ var Block = class {
12875
12858
  }
12876
12859
  return this.tag;
12877
12860
  }
12878
- /**
12879
- * change the identifier of an existing Block instance
12880
- * @example
12881
- * ```typescript
12882
- * const myBlock = new provider.Block("latest");
12883
- * myBlock.identifier ="0x3456789abc";
12884
- * const result = myBlock.identifier;
12885
- * // result = { block_hash: '0x3456789abc' }
12886
- * ```
12887
- */
12888
- set identifier(_identifier) {
12889
- this.setIdentifier(_identifier);
12890
- }
12891
- valueOf = () => this.number;
12892
- toString = () => this.hash;
12893
12861
  };
12894
12862
 
12895
12863
  // src/utils/eventEmitter.ts
@@ -14339,6 +14307,10 @@ var RpcChannel = class {
14339
14307
  }
14340
14308
  getStorageProof(classHashes = [], contractAddresses = [], contractsStorageKeys = [], blockIdentifier = this.blockIdentifier) {
14341
14309
  const block_id = new Block(blockIdentifier).identifier;
14310
+ assert(
14311
+ block_id !== "pre_confirmed",
14312
+ "starknet_getStorageProof does not accept the block tag 'pre_confirmed'"
14313
+ );
14342
14314
  const class_hashes = bigNumberishArrayToHexadecimalStringArray(classHashes);
14343
14315
  const contract_addresses = bigNumberishArrayToHexadecimalStringArray(contractAddresses);
14344
14316
  return this.fetchEndpoint("starknet_getStorageProof", {
@@ -14402,6 +14374,10 @@ var RpcChannel = class {
14402
14374
  }
14403
14375
  getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier) {
14404
14376
  const block_id = new Block(blockIdentifier).identifier;
14377
+ assert(
14378
+ block_id !== "pre_confirmed",
14379
+ "starknet_traceBlockTransactions does not accept the block tag 'pre_confirmed'"
14380
+ );
14405
14381
  return this.fetchEndpoint("starknet_traceBlockTransactions", { block_id });
14406
14382
  }
14407
14383
  getBlockTransactionCount(blockIdentifier = this.blockIdentifier) {
@@ -14745,7 +14721,7 @@ __export(v0_10_2_exports, {
14745
14721
  });
14746
14722
 
14747
14723
  // src/channel/rpc_0_10_2.ts
14748
- var RPC = __toESM(require("@starknet-io/starknet-types-0101"));
14724
+ var RPC2 = __toESM(require("@starknet-io/starknet-types-0101"));
14749
14725
  var RpcChannel2 = class {
14750
14726
  id = "RPC0.10.2";
14751
14727
  /**
@@ -14931,6 +14907,10 @@ var RpcChannel2 = class {
14931
14907
  // TODO: New Method add test
14932
14908
  getStorageProof(classHashes = [], contractAddresses = [], contractsStorageKeys = [], blockIdentifier = this.blockIdentifier) {
14933
14909
  const block_id = new Block(blockIdentifier).identifier;
14910
+ assert(
14911
+ block_id !== "pre_confirmed",
14912
+ "starknet_getStorageProof does not accept the block tag 'pre_confirmed'"
14913
+ );
14934
14914
  const class_hashes = bigNumberishArrayToHexadecimalStringArray(classHashes);
14935
14915
  const contract_addresses = bigNumberishArrayToHexadecimalStringArray(contractAddresses);
14936
14916
  return this.fetchEndpoint("starknet_getStorageProof", {
@@ -14989,7 +14969,7 @@ var RpcChannel2 = class {
14989
14969
  */
14990
14970
  getBlockWithTxs(blockIdentifier = this.blockIdentifier, options) {
14991
14971
  const block_id = new Block(blockIdentifier).identifier;
14992
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14972
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14993
14973
  return this.fetchEndpoint("starknet_getBlockWithTxs", {
14994
14974
  block_id,
14995
14975
  ...response_flags && { response_flags }
@@ -15003,7 +14983,7 @@ var RpcChannel2 = class {
15003
14983
  */
15004
14984
  getBlockWithReceipts(blockIdentifier = this.blockIdentifier, options) {
15005
14985
  const block_id = new Block(blockIdentifier).identifier;
15006
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14986
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
15007
14987
  return this.fetchEndpoint("starknet_getBlockWithReceipts", {
15008
14988
  block_id,
15009
14989
  ...response_flags && { response_flags }
@@ -15026,7 +15006,11 @@ var RpcChannel2 = class {
15026
15006
  */
15027
15007
  getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier, options) {
15028
15008
  const block_id = new Block(blockIdentifier).identifier;
15029
- const trace_flags = options?.returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
15009
+ assert(
15010
+ block_id !== "pre_confirmed",
15011
+ "starknet_traceBlockTransactions does not accept the block tag 'pre_confirmed'"
15012
+ );
15013
+ const trace_flags = options?.returnInitialReads ? [RPC2.ETraceFlag.RETURN_INITIAL_READS] : void 0;
15030
15014
  return this.fetchEndpoint("starknet_traceBlockTransactions", {
15031
15015
  block_id,
15032
15016
  ...trace_flags && { trace_flags }
@@ -15044,7 +15028,7 @@ var RpcChannel2 = class {
15044
15028
  */
15045
15029
  getTransactionByHash(txHash, options) {
15046
15030
  const transaction_hash = toHex(txHash);
15047
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
15031
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
15048
15032
  return this.fetchEndpoint("starknet_getTransactionByHash", {
15049
15033
  transaction_hash,
15050
15034
  ...response_flags && { response_flags }
@@ -15059,7 +15043,7 @@ var RpcChannel2 = class {
15059
15043
  */
15060
15044
  getTransactionByBlockIdAndIndex(blockIdentifier, index, options) {
15061
15045
  const block_id = new Block(blockIdentifier).identifier;
15062
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
15046
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
15063
15047
  return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex", {
15064
15048
  block_id,
15065
15049
  index,
@@ -15100,9 +15084,9 @@ var RpcChannel2 = class {
15100
15084
  } = simulateTransactionOptions;
15101
15085
  const block_id = new Block(blockIdentifier).identifier;
15102
15086
  const simulationFlags = [];
15103
- if (skipValidate) simulationFlags.push(RPC.ESimulationFlag.SKIP_VALIDATE);
15104
- if (skipFeeCharge) simulationFlags.push(RPC.ESimulationFlag.SKIP_FEE_CHARGE);
15105
- const trace_flags = returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
15087
+ if (skipValidate) simulationFlags.push(RPC2.ESimulationFlag.SKIP_VALIDATE);
15088
+ if (skipFeeCharge) simulationFlags.push(RPC2.ESimulationFlag.SKIP_FEE_CHARGE);
15089
+ const trace_flags = returnInitialReads ? [RPC2.ETraceFlag.RETURN_INITIAL_READS] : void 0;
15106
15090
  return this.fetchEndpoint("starknet_simulateTransactions", {
15107
15091
  block_id,
15108
15092
  transactions: await Promise.all(invocations.map((it) => this.buildTransaction(it))),
@@ -15121,13 +15105,13 @@ var RpcChannel2 = class {
15121
15105
  const errorStates = options?.errorStates ?? [];
15122
15106
  const successStates = options?.successStates ?? [
15123
15107
  // RPC.ETransactionExecutionStatus.SUCCEEDED, // UDC on SUCCEEDED + pre_confirmed had no proper events to parse UDC
15124
- RPC.ETransactionFinalityStatus.ACCEPTED_ON_L2,
15125
- RPC.ETransactionFinalityStatus.ACCEPTED_ON_L1
15108
+ RPC2.ETransactionFinalityStatus.ACCEPTED_ON_L2,
15109
+ RPC2.ETransactionFinalityStatus.ACCEPTED_ON_L1
15126
15110
  ];
15127
15111
  const errorMessages = {
15128
- [RPC.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
15129
- [RPC.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
15130
- [RPC.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
15112
+ [RPC2.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
15113
+ [RPC2.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
15114
+ [RPC2.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
15131
15115
  };
15132
15116
  const txLife = [];
15133
15117
  let txStatus;
@@ -15224,7 +15208,7 @@ var RpcChannel2 = class {
15224
15208
  const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
15225
15209
  const block_id = new Block(blockIdentifier).identifier;
15226
15210
  const flags = {
15227
- simulation_flags: skipValidate ? [RPC.ESimulationFlag.SKIP_VALIDATE] : []
15211
+ simulation_flags: skipValidate ? [RPC2.ESimulationFlag.SKIP_VALIDATE] : []
15228
15212
  };
15229
15213
  return this.fetchEndpoint("starknet_estimateFee", {
15230
15214
  request: await Promise.all(invocations.map((it) => this.buildTransaction(it, "fee"))),
@@ -15344,7 +15328,7 @@ var RpcChannel2 = class {
15344
15328
  };
15345
15329
  if (invocation.type === api_exports.ETransactionType.INVOKE) {
15346
15330
  const btx = {
15347
- type: RPC.ETransactionType.INVOKE,
15331
+ type: RPC2.ETransactionType.INVOKE,
15348
15332
  sender_address: invocation.contractAddress,
15349
15333
  calldata: CallData.toHex(invocation.calldata),
15350
15334
  ...details,