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.mjs CHANGED
@@ -891,7 +891,7 @@ function getDecimalString(str) {
891
891
  }
892
892
  function getHexString(str) {
893
893
  if (isHex(str)) {
894
- return str;
894
+ return toHex(str);
895
895
  }
896
896
  if (isStringWholeNumber(str)) {
897
897
  return toHexString(str);
@@ -1044,6 +1044,250 @@ var OutsideExecutionVersion = {
1044
1044
  V2: "2"
1045
1045
  };
1046
1046
 
1047
+ // src/utils/helpers.ts
1048
+ function addCompiledFlag(compiled) {
1049
+ Object.defineProperty(compiled, "__compiled__", {
1050
+ enumerable: false,
1051
+ writable: false,
1052
+ value: true
1053
+ });
1054
+ return compiled;
1055
+ }
1056
+
1057
+ // src/utils/cairoDataTypes/felt.ts
1058
+ var CairoFelt252 = class _CairoFelt252 {
1059
+ /**
1060
+ * The bytes of the value, big-endian and without leading zeros.
1061
+ *
1062
+ * The length is that of the value, not a fixed width : a felt252 holding 0 is one byte, and one
1063
+ * holding `'Hello'` is five. Nothing here records how wide the input was written.
1064
+ * @example
1065
+ * ```typescript
1066
+ * const result = new CairoFelt252('Hello').data.length;
1067
+ * // result = 5
1068
+ * const result2 = new CairoFelt252(0).data.length;
1069
+ * // result2 = 1 (the single byte 0x00)
1070
+ * ```
1071
+ */
1072
+ data;
1073
+ /**
1074
+ * The abi type this class serializes.
1075
+ * @example
1076
+ * ```typescript
1077
+ * const result = CairoFelt252.abiSelector;
1078
+ * // result = "core::felt252"
1079
+ * ```
1080
+ */
1081
+ static abiSelector = "core::felt252";
1082
+ /**
1083
+ * Build from a number, a string or a boolean, refusing anything outside [0, P).
1084
+ *
1085
+ * The bytes are stored without their leading zeros, so `'0x0041'` and `'0x41'` give the same
1086
+ * felt252. A boolean is carried as 1 or 0.
1087
+ * @param {BigNumberish | boolean} data the value to carry, within [0, P)
1088
+ * @throws {Error} when the value is null, undefined, of an unread type, or outside [0, P)
1089
+ * @example
1090
+ * ```typescript
1091
+ * const result = new CairoFelt252('Hello').toApiRequest();
1092
+ * // result = ["310939249775"]
1093
+ * ```
1094
+ */
1095
+ constructor(data) {
1096
+ _CairoFelt252.validate(data);
1097
+ const processedData = _CairoFelt252.__processData(data);
1098
+ this.data = processedData.subarray(processedData.findIndex((x) => x > 0));
1099
+ }
1100
+ /**
1101
+ * Turn an accepted input into its bytes, before the constructor strips their leading zeros.
1102
+ *
1103
+ * The range is not checked here : `validate` is what reads these bytes and decides. Only the
1104
+ * type is, and an input this class does not read raises rather than coming back.
1105
+ * @param {BigNumberish | boolean} data the value to convert
1106
+ * @returns {Uint8Array} the bytes of the value, of whatever length it implies
1107
+ * @throws {Error} when the input is neither a string, an integer, a bigint nor a boolean
1108
+ * @example
1109
+ * ```typescript
1110
+ * const result = CairoFelt252.__processData('Hello').length;
1111
+ * // result = 5
1112
+ * CairoFelt252.__processData(1.5);
1113
+ * // throws Error("1.5 can't be computed by felt()")
1114
+ * ```
1115
+ */
1116
+ static __processData(data) {
1117
+ if (isString(data)) {
1118
+ return stringToUint8Array(data);
1119
+ }
1120
+ if (isBigInt(data)) {
1121
+ return bigIntToUint8Array(data);
1122
+ }
1123
+ if (Number.isInteger(data)) {
1124
+ return bigIntToUint8Array(BigInt(data));
1125
+ }
1126
+ if (isBoolean(data)) {
1127
+ return bigIntToUint8Array(BigInt(data ? 1 : 0));
1128
+ }
1129
+ throw new Error(`${data} can't be computed by felt()`);
1130
+ }
1131
+ /**
1132
+ * The bytes read as one big-endian number.
1133
+ * @returns {bigint} the value this felt252 holds
1134
+ * @example
1135
+ * ```typescript
1136
+ * const result = new CairoFelt252('Hello').toBigInt();
1137
+ * // result = 310939249775n
1138
+ * ```
1139
+ */
1140
+ toBigInt() {
1141
+ return uint8ArrayToBigInt(this.data);
1142
+ }
1143
+ /**
1144
+ * Read the bytes back as UTF-8 text.
1145
+ *
1146
+ * Only a value that was text to begin with comes back as readable text : the bytes of a number
1147
+ * are decoded all the same, and what they spell is rarely what was meant.
1148
+ * @returns {string} the bytes decoded as UTF-8
1149
+ * @example
1150
+ * ```typescript
1151
+ * const result = new CairoFelt252('Hello').decodeUtf8();
1152
+ * // result = "Hello"
1153
+ * const result2 = new CairoFelt252('12345').decodeUtf8();
1154
+ * // result2 = "09" (the number 12345 is the two bytes 0x30 0x39)
1155
+ * ```
1156
+ */
1157
+ decodeUtf8() {
1158
+ return new TextDecoder().decode(this.data);
1159
+ }
1160
+ /**
1161
+ * The value in hexadecimal, without padding.
1162
+ * @returns {string} the value as a 0x-prefixed hex string
1163
+ * @example
1164
+ * ```typescript
1165
+ * const result = new CairoFelt252('Hello').toHexString();
1166
+ * // result = "0x48656c6c6f"
1167
+ * const result2 = new CairoFelt252(0).toHexString();
1168
+ * // result2 = "0x0" (one digit, not "0x00")
1169
+ * ```
1170
+ */
1171
+ toHexString() {
1172
+ return addHexPrefix(this.toBigInt().toString(16));
1173
+ }
1174
+ /**
1175
+ * Serialize to the single felt a contract call carries.
1176
+ * @returns {string[]} one decimal-string felt, flagged as compiled
1177
+ * @example
1178
+ * ```typescript
1179
+ * const result = new CairoFelt252('Hello').toApiRequest();
1180
+ * // result = ["310939249775"]
1181
+ * ```
1182
+ */
1183
+ toApiRequest() {
1184
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1185
+ }
1186
+ /**
1187
+ * Throw unless a number falls in the felt252 range [0, P).
1188
+ *
1189
+ * This takes the number itself, where {@link CairoFelt252.validate} takes whatever a caller
1190
+ * hands over. P is excluded : the largest felt252 is P - 1.
1191
+ * @param {bigint} val the number to check
1192
+ * @throws {Error} when the number is negative or greater than or equal to P
1193
+ * @example
1194
+ * ```typescript
1195
+ * CairoFelt252.assertRange(0n); // passes
1196
+ * CairoFelt252.assertRange(-1n);
1197
+ * // throws Error("Value -1 is out of felt252 range [0, 3618502788666131213697322783095070105623107215331596699973092056135872020481)")
1198
+ * ```
1199
+ */
1200
+ static assertRange(val) {
1201
+ assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
1202
+ }
1203
+ /**
1204
+ * Throw unless the value can be carried by a felt252.
1205
+ *
1206
+ * Null, undefined, any type this class does not read, and `'0x'` are refused first, each with its
1207
+ * own message, then the value is converted and its range checked. A negative number does not
1208
+ * reach that range check : converting it fails earlier, and the message comes from the conversion.
1209
+ * @param {BigNumberish | boolean} data the value to check
1210
+ * @throws {Error} when the value is null, undefined, of an unread type, `'0x'`, or outside [0, P)
1211
+ * @example
1212
+ * ```typescript
1213
+ * CairoFelt252.validate('Hello'); // passes
1214
+ * CairoFelt252.validate({});
1215
+ * // throws Error("Unsupported data type 'object' for felt252. Expected string, number, bigint, or boolean")
1216
+ * CairoFelt252.validate('0x');
1217
+ * // throws Error("Invalid input: '0x' holds no hexadecimal digit")
1218
+ * CairoFelt252.validate(-1);
1219
+ * // throws Error("Cannot convert negative bigint -1 to Uint8Array")
1220
+ * ```
1221
+ */
1222
+ static validate(data) {
1223
+ assert(data !== null, "null value is not allowed for felt252");
1224
+ assert(data !== void 0, "undefined value is not allowed for felt252");
1225
+ assert(
1226
+ isString(data) || isNumber(data) || isBigInt(data) || isBoolean(data),
1227
+ `Unsupported data type '${typeof data}' for felt252. Expected string, number, bigint, or boolean`
1228
+ );
1229
+ assert(!isEmptyHex(data), "Invalid input: '0x' holds no hexadecimal digit");
1230
+ const value = _CairoFelt252.__processData(data);
1231
+ const bn = uint8ArrayToBigInt(value);
1232
+ _CairoFelt252.assertRange(bn);
1233
+ }
1234
+ /**
1235
+ * Can this value be carried by a felt252?
1236
+ *
1237
+ * The non-throwing form of {@link CairoFelt252.validate}, so it answers false for every input
1238
+ * that one refuses, whatever the reason.
1239
+ * @param {BigNumberish | boolean} data the value to test
1240
+ * @returns {boolean} true when the value fits in a felt252
1241
+ * @example
1242
+ * ```typescript
1243
+ * const result = CairoFelt252.is('Hello');
1244
+ * // result = true
1245
+ * const result2 = CairoFelt252.is(-1);
1246
+ * // result2 = false
1247
+ * ```
1248
+ */
1249
+ static is(data) {
1250
+ try {
1251
+ _CairoFelt252.validate(data);
1252
+ return true;
1253
+ } catch {
1254
+ return false;
1255
+ }
1256
+ }
1257
+ /**
1258
+ * Is this abi type the one this class serializes?
1259
+ * @param {string} abiType the abi type to test
1260
+ * @returns {boolean} true for `core::felt252`
1261
+ * @example
1262
+ * ```typescript
1263
+ * const result = CairoFelt252.isAbiType('core::felt252');
1264
+ * // result = true
1265
+ * const result2 = CairoFelt252.isAbiType('core::integer::u8');
1266
+ * // result2 = false
1267
+ * ```
1268
+ */
1269
+ static isAbiType(abiType) {
1270
+ return abiType === _CairoFelt252.abiSelector;
1271
+ }
1272
+ /**
1273
+ * Read one felt252 off a contract response, advancing the iterator past it.
1274
+ *
1275
+ * The felts a node returns are hex strings, and one is consumed per call, so successive calls
1276
+ * read successive return values.
1277
+ * @param {Iterator<string>} responseIterator the response felts, positioned on this felt252
1278
+ * @returns {CairoFelt252} the felt252 that was read
1279
+ * @example
1280
+ * ```typescript
1281
+ * const response = ['0x48656c6c6f'];
1282
+ * const result = CairoFelt252.factoryFromApiResponse(response.values()).decodeUtf8();
1283
+ * // result = "Hello"
1284
+ * ```
1285
+ */
1286
+ static factoryFromApiResponse(responseIterator) {
1287
+ return new _CairoFelt252(getNext(responseIterator));
1288
+ }
1289
+ };
1290
+
1047
1291
  // src/utils/hash/index.ts
1048
1292
  var hash_exports = {};
1049
1293
  __export(hash_exports, {
@@ -1533,371 +1777,127 @@ function blake2sHashMany(data) {
1533
1777
  const word4 = feltView.getUint32(16, false);
1534
1778
  const word5 = feltView.getUint32(20, false);
1535
1779
  const word6 = feltView.getUint32(24, false);
1536
- const word7 = feltView.getUint32(28, false);
1537
- u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
1538
- }
1539
- }
1540
- const bytes = new ArrayBuffer(u32Words.length * 4);
1541
- const bytesView = new DataView(bytes);
1542
- for (let i = 0; i < u32Words.length; i++) {
1543
- bytesView.setUint32(i * 4, u32Words[i], true);
1544
- }
1545
- const hash = blakeHash(new Uint8Array(bytes));
1546
- let hashBigInt = 0n;
1547
- for (let i = 0; i < 32; i++) {
1548
- hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
1549
- }
1550
- return hashBigInt % PRIME;
1551
- }
1552
- function hashBuiltinsBlake(builtins) {
1553
- return blake2sHashMany(encodeBuiltins(builtins));
1554
- }
1555
- function hashEntryPointBlake(data) {
1556
- const base = data.flatMap((it) => {
1557
- return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
1558
- });
1559
- return blake2sHashMany(base);
1560
- }
1561
- function bytecodeHashNodeBlake(iter, node) {
1562
- if (typeof node === "number") {
1563
- const data = [];
1564
- for (let i = 0; i < node; i++) {
1565
- const next = iter.next();
1566
- if (next.done) throw new Error("Bytecode length mismatch");
1567
- data.push(next.value);
1568
- }
1569
- return [node, blake2sHashMany(data)];
1570
- }
1571
- const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
1572
- const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
1573
- const hash = blake2sHashMany(flatData) + 1n;
1574
- const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
1575
- return [totalLen, hash];
1576
- }
1577
- function hashByteCodeSegmentsBlake(casm) {
1578
- const byteCode = casm.bytecode.map((n) => BigInt(n));
1579
- const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
1580
- if (!bytecodeSegmentLengths) {
1581
- return blake2sHashMany(byteCode);
1582
- }
1583
- const iter = byteCode[Symbol.iterator]();
1584
- const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
1585
- if (len !== byteCode.length) {
1586
- throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
1587
- }
1588
- return hash;
1589
- }
1590
- function computeCompiledClassHashBlake(casm) {
1591
- const compiledClassVersion = utf8ToBigInt(COMPILED_CLASS_VERSION);
1592
- const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
1593
- const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
1594
- const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
1595
- const bytecode = hashByteCodeSegmentsBlake(casm);
1596
- return toHex(
1597
- blake2sHashMany([
1598
- compiledClassVersion,
1599
- externalEntryPointsHash,
1600
- l1Handlers,
1601
- constructor,
1602
- bytecode
1603
- ])
1604
- );
1605
- }
1606
-
1607
- // src/utils/resolve.ts
1608
- function isV3Tx(details) {
1609
- const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
1610
- return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
1611
- }
1612
- function isVersion(expected, provided) {
1613
- const expectedParts = expected.split(".");
1614
- const providedParts = provided.split(".");
1615
- return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
1616
- }
1617
- function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
1618
- return Object.values(_SupportedRpcVersion).some(
1619
- (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
1620
- );
1621
- }
1622
- function toAnyPatchVersion(version) {
1623
- const parts = version.split(".");
1624
- if (parts.length < 3) {
1625
- return version;
1626
- }
1627
- return `${parts[0]}.${parts[1]}.*`;
1628
- }
1629
- function toReleaseVersion(version) {
1630
- return version.split(/[-+]/)[0];
1631
- }
1632
- function toApiVersion(version) {
1633
- const [major, minor] = version.replace(/^v/, "").split(".");
1634
- return `v${major}_${minor}`;
1635
- }
1636
- function compareVersions(a, b) {
1637
- const aParts = toReleaseVersion(a).split(".").map(Number);
1638
- const bParts = toReleaseVersion(b).split(".").map(Number);
1639
- const maxLen = Math.max(aParts.length, bParts.length);
1640
- for (let i = 0; i < maxLen; i += 1) {
1641
- const aNum = aParts[i] || 0;
1642
- const bNum = bParts[i] || 0;
1643
- if (aNum > bNum) return 1;
1644
- if (aNum < bNum) return -1;
1645
- }
1646
- return 0;
1647
- }
1648
- function isPreConfirmedBlock(response) {
1649
- return response.status === rpc_exports.EBlockStatus.PRE_CONFIRMED;
1650
- }
1651
- function isPreConfirmedTransaction(response) {
1652
- return !("block_hash" in response);
1653
- }
1654
- function isPreConfirmedStateUpdate(response) {
1655
- return !("block_hash" in response);
1656
- }
1657
-
1658
- // src/utils/helpers.ts
1659
- function addCompiledFlag(compiled) {
1660
- Object.defineProperty(compiled, "__compiled__", {
1661
- enumerable: false,
1662
- writable: false,
1663
- value: true
1664
- });
1665
- return compiled;
1666
- }
1667
-
1668
- // src/utils/cairoDataTypes/felt.ts
1669
- var CairoFelt252 = class _CairoFelt252 {
1670
- /**
1671
- * The bytes of the value, big-endian and without leading zeros.
1672
- *
1673
- * The length is that of the value, not a fixed width : a felt252 holding 0 is one byte, and one
1674
- * holding `'Hello'` is five. Nothing here records how wide the input was written.
1675
- * @example
1676
- * ```typescript
1677
- * const result = new CairoFelt252('Hello').data.length;
1678
- * // result = 5
1679
- * const result2 = new CairoFelt252(0).data.length;
1680
- * // result2 = 1 (the single byte 0x00)
1681
- * ```
1682
- */
1683
- data;
1684
- /**
1685
- * The abi type this class serializes.
1686
- * @example
1687
- * ```typescript
1688
- * const result = CairoFelt252.abiSelector;
1689
- * // result = "core::felt252"
1690
- * ```
1691
- */
1692
- static abiSelector = "core::felt252";
1693
- /**
1694
- * Build from a number, a string or a boolean, refusing anything outside [0, P).
1695
- *
1696
- * The bytes are stored without their leading zeros, so `'0x0041'` and `'0x41'` give the same
1697
- * felt252. A boolean is carried as 1 or 0.
1698
- * @param {BigNumberish | boolean} data the value to carry, within [0, P)
1699
- * @throws {Error} when the value is null, undefined, of an unread type, or outside [0, P)
1700
- * @example
1701
- * ```typescript
1702
- * const result = new CairoFelt252('Hello').toApiRequest();
1703
- * // result = ["310939249775"]
1704
- * ```
1705
- */
1706
- constructor(data) {
1707
- _CairoFelt252.validate(data);
1708
- const processedData = _CairoFelt252.__processData(data);
1709
- this.data = processedData.subarray(processedData.findIndex((x) => x > 0));
1710
- }
1711
- /**
1712
- * Turn an accepted input into its bytes, before the constructor strips their leading zeros.
1713
- *
1714
- * The range is not checked here : `validate` is what reads these bytes and decides. Only the
1715
- * type is, and an input this class does not read raises rather than coming back.
1716
- * @param {BigNumberish | boolean} data the value to convert
1717
- * @returns {Uint8Array} the bytes of the value, of whatever length it implies
1718
- * @throws {Error} when the input is neither a string, an integer, a bigint nor a boolean
1719
- * @example
1720
- * ```typescript
1721
- * const result = CairoFelt252.__processData('Hello').length;
1722
- * // result = 5
1723
- * CairoFelt252.__processData(1.5);
1724
- * // throws Error("1.5 can't be computed by felt()")
1725
- * ```
1726
- */
1727
- static __processData(data) {
1728
- if (isString(data)) {
1729
- return stringToUint8Array(data);
1730
- }
1731
- if (isBigInt(data)) {
1732
- return bigIntToUint8Array(data);
1733
- }
1734
- if (Number.isInteger(data)) {
1735
- return bigIntToUint8Array(BigInt(data));
1736
- }
1737
- if (isBoolean(data)) {
1738
- return bigIntToUint8Array(BigInt(data ? 1 : 0));
1739
- }
1740
- throw new Error(`${data} can't be computed by felt()`);
1741
- }
1742
- /**
1743
- * The bytes read as one big-endian number.
1744
- * @returns {bigint} the value this felt252 holds
1745
- * @example
1746
- * ```typescript
1747
- * const result = new CairoFelt252('Hello').toBigInt();
1748
- * // result = 310939249775n
1749
- * ```
1750
- */
1751
- toBigInt() {
1752
- return uint8ArrayToBigInt(this.data);
1753
- }
1754
- /**
1755
- * Read the bytes back as UTF-8 text.
1756
- *
1757
- * Only a value that was text to begin with comes back as readable text : the bytes of a number
1758
- * are decoded all the same, and what they spell is rarely what was meant.
1759
- * @returns {string} the bytes decoded as UTF-8
1760
- * @example
1761
- * ```typescript
1762
- * const result = new CairoFelt252('Hello').decodeUtf8();
1763
- * // result = "Hello"
1764
- * const result2 = new CairoFelt252('12345').decodeUtf8();
1765
- * // result2 = "09" (the number 12345 is the two bytes 0x30 0x39)
1766
- * ```
1767
- */
1768
- decodeUtf8() {
1769
- return new TextDecoder().decode(this.data);
1770
- }
1771
- /**
1772
- * The value in hexadecimal, without padding.
1773
- * @returns {string} the value as a 0x-prefixed hex string
1774
- * @example
1775
- * ```typescript
1776
- * const result = new CairoFelt252('Hello').toHexString();
1777
- * // result = "0x48656c6c6f"
1778
- * const result2 = new CairoFelt252(0).toHexString();
1779
- * // result2 = "0x0" (one digit, not "0x00")
1780
- * ```
1781
- */
1782
- toHexString() {
1783
- return addHexPrefix(this.toBigInt().toString(16));
1784
- }
1785
- /**
1786
- * Serialize to the single felt a contract call carries.
1787
- * @returns {string[]} one decimal-string felt, flagged as compiled
1788
- * @example
1789
- * ```typescript
1790
- * const result = new CairoFelt252('Hello').toApiRequest();
1791
- * // result = ["310939249775"]
1792
- * ```
1793
- */
1794
- toApiRequest() {
1795
- return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1780
+ const word7 = feltView.getUint32(28, false);
1781
+ u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
1782
+ }
1796
1783
  }
1797
- /**
1798
- * Throw unless a number falls in the felt252 range [0, P).
1799
- *
1800
- * This takes the number itself, where {@link CairoFelt252.validate} takes whatever a caller
1801
- * hands over. P is excluded : the largest felt252 is P - 1.
1802
- * @param {bigint} val the number to check
1803
- * @throws {Error} when the number is negative or greater than or equal to P
1804
- * @example
1805
- * ```typescript
1806
- * CairoFelt252.assertRange(0n); // passes
1807
- * CairoFelt252.assertRange(-1n);
1808
- * // throws Error("Value -1 is out of felt252 range [0, 3618502788666131213697322783095070105623107215331596699973092056135872020481)")
1809
- * ```
1810
- */
1811
- static assertRange(val) {
1812
- assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
1784
+ const bytes = new ArrayBuffer(u32Words.length * 4);
1785
+ const bytesView = new DataView(bytes);
1786
+ for (let i = 0; i < u32Words.length; i++) {
1787
+ bytesView.setUint32(i * 4, u32Words[i], true);
1813
1788
  }
1814
- /**
1815
- * Throw unless the value can be carried by a felt252.
1816
- *
1817
- * Null, undefined, any type this class does not read, and `'0x'` are refused first, each with its
1818
- * own message, then the value is converted and its range checked. A negative number does not
1819
- * reach that range check : converting it fails earlier, and the message comes from the conversion.
1820
- * @param {BigNumberish | boolean} data the value to check
1821
- * @throws {Error} when the value is null, undefined, of an unread type, `'0x'`, or outside [0, P)
1822
- * @example
1823
- * ```typescript
1824
- * CairoFelt252.validate('Hello'); // passes
1825
- * CairoFelt252.validate({});
1826
- * // throws Error("Unsupported data type 'object' for felt252. Expected string, number, bigint, or boolean")
1827
- * CairoFelt252.validate('0x');
1828
- * // throws Error("Invalid input: '0x' holds no hexadecimal digit")
1829
- * CairoFelt252.validate(-1);
1830
- * // throws Error("Cannot convert negative bigint -1 to Uint8Array")
1831
- * ```
1832
- */
1833
- static validate(data) {
1834
- assert(data !== null, "null value is not allowed for felt252");
1835
- assert(data !== void 0, "undefined value is not allowed for felt252");
1836
- assert(
1837
- isString(data) || isNumber(data) || isBigInt(data) || isBoolean(data),
1838
- `Unsupported data type '${typeof data}' for felt252. Expected string, number, bigint, or boolean`
1839
- );
1840
- assert(!isEmptyHex(data), "Invalid input: '0x' holds no hexadecimal digit");
1841
- const value = _CairoFelt252.__processData(data);
1842
- const bn = uint8ArrayToBigInt(value);
1843
- _CairoFelt252.assertRange(bn);
1789
+ const hash = blakeHash(new Uint8Array(bytes));
1790
+ let hashBigInt = 0n;
1791
+ for (let i = 0; i < 32; i++) {
1792
+ hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
1844
1793
  }
1845
- /**
1846
- * Can this value be carried by a felt252?
1847
- *
1848
- * The non-throwing form of {@link CairoFelt252.validate}, so it answers false for every input
1849
- * that one refuses, whatever the reason.
1850
- * @param {BigNumberish | boolean} data the value to test
1851
- * @returns {boolean} true when the value fits in a felt252
1852
- * @example
1853
- * ```typescript
1854
- * const result = CairoFelt252.is('Hello');
1855
- * // result = true
1856
- * const result2 = CairoFelt252.is(-1);
1857
- * // result2 = false
1858
- * ```
1859
- */
1860
- static is(data) {
1861
- try {
1862
- _CairoFelt252.validate(data);
1863
- return true;
1864
- } catch {
1865
- return false;
1794
+ return hashBigInt % PRIME;
1795
+ }
1796
+ function hashBuiltinsBlake(builtins) {
1797
+ return blake2sHashMany(encodeBuiltins(builtins));
1798
+ }
1799
+ function hashEntryPointBlake(data) {
1800
+ const base = data.flatMap((it) => {
1801
+ return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
1802
+ });
1803
+ return blake2sHashMany(base);
1804
+ }
1805
+ function bytecodeHashNodeBlake(iter, node) {
1806
+ if (typeof node === "number") {
1807
+ const data = [];
1808
+ for (let i = 0; i < node; i++) {
1809
+ const next = iter.next();
1810
+ if (next.done) throw new Error("Bytecode length mismatch");
1811
+ data.push(next.value);
1866
1812
  }
1813
+ return [node, blake2sHashMany(data)];
1867
1814
  }
1868
- /**
1869
- * Is this abi type the one this class serializes?
1870
- * @param {string} abiType the abi type to test
1871
- * @returns {boolean} true for `core::felt252`
1872
- * @example
1873
- * ```typescript
1874
- * const result = CairoFelt252.isAbiType('core::felt252');
1875
- * // result = true
1876
- * const result2 = CairoFelt252.isAbiType('core::integer::u8');
1877
- * // result2 = false
1878
- * ```
1879
- */
1880
- static isAbiType(abiType) {
1881
- return abiType === _CairoFelt252.abiSelector;
1815
+ const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
1816
+ const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
1817
+ const hash = blake2sHashMany(flatData) + 1n;
1818
+ const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
1819
+ return [totalLen, hash];
1820
+ }
1821
+ function hashByteCodeSegmentsBlake(casm) {
1822
+ const byteCode = casm.bytecode.map((n) => BigInt(n));
1823
+ const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
1824
+ if (!bytecodeSegmentLengths) {
1825
+ return blake2sHashMany(byteCode);
1882
1826
  }
1883
- /**
1884
- * Read one felt252 off a contract response, advancing the iterator past it.
1885
- *
1886
- * The felts a node returns are hex strings, and one is consumed per call, so successive calls
1887
- * read successive return values.
1888
- * @param {Iterator<string>} responseIterator the response felts, positioned on this felt252
1889
- * @returns {CairoFelt252} the felt252 that was read
1890
- * @example
1891
- * ```typescript
1892
- * const response = ['0x48656c6c6f'];
1893
- * const result = CairoFelt252.factoryFromApiResponse(response.values()).decodeUtf8();
1894
- * // result = "Hello"
1895
- * ```
1896
- */
1897
- static factoryFromApiResponse(responseIterator) {
1898
- return new _CairoFelt252(getNext(responseIterator));
1827
+ const iter = byteCode[Symbol.iterator]();
1828
+ const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
1829
+ if (len !== byteCode.length) {
1830
+ throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
1899
1831
  }
1900
- };
1832
+ return hash;
1833
+ }
1834
+ function computeCompiledClassHashBlake(casm) {
1835
+ const compiledClassVersion = utf8ToBigInt(COMPILED_CLASS_VERSION);
1836
+ const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
1837
+ const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
1838
+ const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
1839
+ const bytecode = hashByteCodeSegmentsBlake(casm);
1840
+ return toHex(
1841
+ blake2sHashMany([
1842
+ compiledClassVersion,
1843
+ externalEntryPointsHash,
1844
+ l1Handlers,
1845
+ constructor,
1846
+ bytecode
1847
+ ])
1848
+ );
1849
+ }
1850
+
1851
+ // src/utils/resolve.ts
1852
+ function isV3Tx(details) {
1853
+ const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
1854
+ return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
1855
+ }
1856
+ function isVersion(expected, provided) {
1857
+ const expectedParts = expected.split(".");
1858
+ const providedParts = provided.split(".");
1859
+ return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
1860
+ }
1861
+ function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
1862
+ return Object.values(_SupportedRpcVersion).some(
1863
+ (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
1864
+ );
1865
+ }
1866
+ function toAnyPatchVersion(version) {
1867
+ const parts = version.split(".");
1868
+ if (parts.length < 3) {
1869
+ return version;
1870
+ }
1871
+ return `${parts[0]}.${parts[1]}.*`;
1872
+ }
1873
+ function toReleaseVersion(version) {
1874
+ return version.split(/[-+]/)[0];
1875
+ }
1876
+ function toApiVersion(version) {
1877
+ const [major, minor] = version.replace(/^v/, "").split(".");
1878
+ return `v${major}_${minor}`;
1879
+ }
1880
+ function compareVersions(a, b) {
1881
+ const aParts = toReleaseVersion(a).split(".").map(Number);
1882
+ const bParts = toReleaseVersion(b).split(".").map(Number);
1883
+ const maxLen = Math.max(aParts.length, bParts.length);
1884
+ for (let i = 0; i < maxLen; i += 1) {
1885
+ const aNum = aParts[i] || 0;
1886
+ const bNum = bParts[i] || 0;
1887
+ if (aNum > bNum) return 1;
1888
+ if (aNum < bNum) return -1;
1889
+ }
1890
+ return 0;
1891
+ }
1892
+ function isPreConfirmedBlock(response) {
1893
+ return response.status === rpc_exports.EBlockStatus.PRE_CONFIRMED;
1894
+ }
1895
+ function isPreConfirmedTransaction(response) {
1896
+ return !("block_hash" in response);
1897
+ }
1898
+ function isPreConfirmedStateUpdate(response) {
1899
+ return !("block_hash" in response);
1900
+ }
1901
1901
 
1902
1902
  // src/utils/cairoDataTypes/cairoType.interface.ts
1903
1903
  function isCairoType(value) {
@@ -12576,79 +12576,62 @@ function getSupportedRpcVersions() {
12576
12576
  }
12577
12577
  var validBlockTags = Object.values(BlockTag);
12578
12578
  var Block = class {
12579
- /**
12580
- * @param {BlockIdentifier} hash if not null, contains the block hash
12581
- */
12579
+ /** It holds the block hash when the block is given by its hash. Otherwise, it is null. */
12582
12580
  hash = null;
12583
- /**
12584
- * @param {BlockIdentifier} number if not null, contains the block number
12585
- */
12581
+ /** It holds the block number when the block is given by its number. Otherwise, it is null. */
12586
12582
  number = null;
12583
+ /** It holds the block tag when the block is given by a tag. Otherwise, it is null. */
12584
+ tag = null;
12587
12585
  /**
12588
- * @param {BlockIdentifier} tag if not null, contains "pre_confirmed" or "latest"
12586
+ * Create a Block.
12587
+ * @param {BlockIdentifier} _identifier the block number, the block hash or the block tag.
12588
+ * `null` and `undefined` mean `'latest'`.
12589
+ * @throws {Error} The identifier names no block. It is an empty string, a text that is not a
12590
+ * block tag, a hash that is not a felt (`'0x'`, a negative bigint, or a value larger than the
12591
+ * largest felt), a number that is not an integer, a negative number, a number larger than
12592
+ * `Number.MAX_SAFE_INTEGER`, or a value that is not a string, a number or a bigint.
12593
+ * @example
12594
+ * ```typescript
12595
+ * const result = new provider.Block('0X0abc').identifier;
12596
+ * // result = { block_hash: '0xabc' }
12597
+ *
12598
+ * new provider.Block(1.5);
12599
+ * // throws Error: Block number (1.5) must be an integer
12600
+ * ```
12589
12601
  */
12590
- tag = null;
12591
- setIdentifier(__identifier) {
12592
- this.hash = null;
12593
- this.number = null;
12594
- this.tag = null;
12595
- if (isString(__identifier)) {
12596
- if (__identifier !== "" && isDecimalString2(__identifier)) {
12597
- this.number = parseInt(__identifier, 10);
12598
- } else if (isHex(__identifier) && !isEmptyHex(__identifier)) {
12599
- this.hash = __identifier;
12600
- } else if (validBlockTags.includes(__identifier)) {
12601
- this.tag = __identifier;
12602
+ constructor(_identifier) {
12603
+ if (isString(_identifier)) {
12604
+ if (isStringWholeNumber(_identifier)) {
12605
+ this.number = parseInt(_identifier, 10);
12606
+ } else if (isHex(_identifier)) {
12607
+ this.hash = new CairoFelt252(_identifier).toHexString();
12602
12608
  } else {
12603
- throw TypeError(`Block identifier unmanaged: ${__identifier}`);
12609
+ assert(
12610
+ validBlockTags.includes(_identifier),
12611
+ `Block identifier unmanaged: '${_identifier}'`
12612
+ );
12613
+ this.tag = _identifier;
12604
12614
  }
12605
- } else if (isBigInt(__identifier)) {
12606
- this.hash = toHex(__identifier);
12607
- } else if (isNumber(__identifier)) {
12608
- this.number = __identifier;
12615
+ } else if (isBigInt(_identifier)) {
12616
+ this.hash = new CairoFelt252(_identifier).toHexString();
12617
+ } else if (isNumber(_identifier)) {
12618
+ this.number = _identifier;
12609
12619
  } else {
12610
- this.tag = BlockTag.LATEST;
12611
- }
12612
- if (isNumber(this.number) && this.number < 0) {
12613
- throw TypeError(`Block number (${this.number}) can't be negative`);
12614
- }
12615
- if (isNumber(this.number) && !Number.isSafeInteger(this.number)) {
12616
- throw TypeError(
12617
- `Block number (${__identifier}) must be a whole number no larger than Number.MAX_SAFE_INTEGER`
12620
+ assert(
12621
+ _identifier === null || _identifier === void 0,
12622
+ `Block identifier unmanaged: ${_identifier}`
12618
12623
  );
12624
+ this.tag = BlockTag.LATEST;
12619
12625
  }
12620
- }
12621
- /**
12622
- * Create a Block instance
12623
- * @param {BlockIdentifier} _identifier hex string and BigInt are detected as block hashes.
12624
- * decimal string and number are detected as block numbers.
12625
- * text string are detected as block tag.
12626
- * null is considered as a 'latest' block tag.
12627
- */
12628
- constructor(_identifier) {
12629
- this.setIdentifier(_identifier);
12630
- }
12631
- // TODO: fix any
12632
- /**
12633
- * @returns {any} the identifier as a string
12634
- * @example
12635
- * ```typescript
12636
- * const result = new provider.Block(123456n).queryIdentifier;
12637
- * // result = "blockHash=0x1e240"
12638
- * ```
12639
- */
12640
- get queryIdentifier() {
12641
12626
  if (this.number !== null) {
12642
- return `blockNumber=${this.number}`;
12627
+ assert(isInteger2(this.number), `Block number (${_identifier}) must be an integer`);
12628
+ assertInRange(this.number, 0, Number.MAX_SAFE_INTEGER, "block number");
12643
12629
  }
12644
- if (this.hash !== null) {
12645
- return `blockHash=${this.hash}`;
12646
- }
12647
- return `blockNumber=${this.tag}`;
12630
+ Object.freeze(this);
12648
12631
  }
12649
- // TODO: fix any
12650
12632
  /**
12651
- * @returns {any} the identifier as an object
12633
+ * @returns {RPC.BLOCK_ID} the block in the form of the `block_id` of an RPC request:
12634
+ * `{ block_number: number }`, `{ block_hash: string }` or a block tag.
12652
12635
  * @example
12653
12636
  * ```typescript
12654
12637
  * const result = new provider.Block(56789).identifier;
@@ -12664,21 +12647,6 @@ var Block = class {
12664
12647
  }
12665
12648
  return this.tag;
12666
12649
  }
12667
- /**
12668
- * change the identifier of an existing Block instance
12669
- * @example
12670
- * ```typescript
12671
- * const myBlock = new provider.Block("latest");
12672
- * myBlock.identifier ="0x3456789abc";
12673
- * const result = myBlock.identifier;
12674
- * // result = { block_hash: '0x3456789abc' }
12675
- * ```
12676
- */
12677
- set identifier(_identifier) {
12678
- this.setIdentifier(_identifier);
12679
- }
12680
- valueOf = () => this.number;
12681
- toString = () => this.hash;
12682
12650
  };
12683
12651
 
12684
12652
  // src/utils/eventEmitter.ts
@@ -14128,6 +14096,10 @@ var RpcChannel = class {
14128
14096
  }
14129
14097
  getStorageProof(classHashes = [], contractAddresses = [], contractsStorageKeys = [], blockIdentifier = this.blockIdentifier) {
14130
14098
  const block_id = new Block(blockIdentifier).identifier;
14099
+ assert(
14100
+ block_id !== "pre_confirmed",
14101
+ "starknet_getStorageProof does not accept the block tag 'pre_confirmed'"
14102
+ );
14131
14103
  const class_hashes = bigNumberishArrayToHexadecimalStringArray(classHashes);
14132
14104
  const contract_addresses = bigNumberishArrayToHexadecimalStringArray(contractAddresses);
14133
14105
  return this.fetchEndpoint("starknet_getStorageProof", {
@@ -14191,6 +14163,10 @@ var RpcChannel = class {
14191
14163
  }
14192
14164
  getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier) {
14193
14165
  const block_id = new Block(blockIdentifier).identifier;
14166
+ assert(
14167
+ block_id !== "pre_confirmed",
14168
+ "starknet_traceBlockTransactions does not accept the block tag 'pre_confirmed'"
14169
+ );
14194
14170
  return this.fetchEndpoint("starknet_traceBlockTransactions", { block_id });
14195
14171
  }
14196
14172
  getBlockTransactionCount(blockIdentifier = this.blockIdentifier) {
@@ -14534,7 +14510,7 @@ __export(v0_10_2_exports, {
14534
14510
  });
14535
14511
 
14536
14512
  // src/channel/rpc_0_10_2.ts
14537
- import * as RPC from "@starknet-io/starknet-types-0101";
14513
+ import * as RPC2 from "@starknet-io/starknet-types-0101";
14538
14514
  var RpcChannel2 = class {
14539
14515
  id = "RPC0.10.2";
14540
14516
  /**
@@ -14720,6 +14696,10 @@ var RpcChannel2 = class {
14720
14696
  // TODO: New Method add test
14721
14697
  getStorageProof(classHashes = [], contractAddresses = [], contractsStorageKeys = [], blockIdentifier = this.blockIdentifier) {
14722
14698
  const block_id = new Block(blockIdentifier).identifier;
14699
+ assert(
14700
+ block_id !== "pre_confirmed",
14701
+ "starknet_getStorageProof does not accept the block tag 'pre_confirmed'"
14702
+ );
14723
14703
  const class_hashes = bigNumberishArrayToHexadecimalStringArray(classHashes);
14724
14704
  const contract_addresses = bigNumberishArrayToHexadecimalStringArray(contractAddresses);
14725
14705
  return this.fetchEndpoint("starknet_getStorageProof", {
@@ -14778,7 +14758,7 @@ var RpcChannel2 = class {
14778
14758
  */
14779
14759
  getBlockWithTxs(blockIdentifier = this.blockIdentifier, options) {
14780
14760
  const block_id = new Block(blockIdentifier).identifier;
14781
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14761
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14782
14762
  return this.fetchEndpoint("starknet_getBlockWithTxs", {
14783
14763
  block_id,
14784
14764
  ...response_flags && { response_flags }
@@ -14792,7 +14772,7 @@ var RpcChannel2 = class {
14792
14772
  */
14793
14773
  getBlockWithReceipts(blockIdentifier = this.blockIdentifier, options) {
14794
14774
  const block_id = new Block(blockIdentifier).identifier;
14795
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14775
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14796
14776
  return this.fetchEndpoint("starknet_getBlockWithReceipts", {
14797
14777
  block_id,
14798
14778
  ...response_flags && { response_flags }
@@ -14815,7 +14795,11 @@ var RpcChannel2 = class {
14815
14795
  */
14816
14796
  getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier, options) {
14817
14797
  const block_id = new Block(blockIdentifier).identifier;
14818
- const trace_flags = options?.returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
14798
+ assert(
14799
+ block_id !== "pre_confirmed",
14800
+ "starknet_traceBlockTransactions does not accept the block tag 'pre_confirmed'"
14801
+ );
14802
+ const trace_flags = options?.returnInitialReads ? [RPC2.ETraceFlag.RETURN_INITIAL_READS] : void 0;
14819
14803
  return this.fetchEndpoint("starknet_traceBlockTransactions", {
14820
14804
  block_id,
14821
14805
  ...trace_flags && { trace_flags }
@@ -14833,7 +14817,7 @@ var RpcChannel2 = class {
14833
14817
  */
14834
14818
  getTransactionByHash(txHash, options) {
14835
14819
  const transaction_hash = toHex(txHash);
14836
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14820
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14837
14821
  return this.fetchEndpoint("starknet_getTransactionByHash", {
14838
14822
  transaction_hash,
14839
14823
  ...response_flags && { response_flags }
@@ -14848,7 +14832,7 @@ var RpcChannel2 = class {
14848
14832
  */
14849
14833
  getTransactionByBlockIdAndIndex(blockIdentifier, index, options) {
14850
14834
  const block_id = new Block(blockIdentifier).identifier;
14851
- const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14835
+ const response_flags = options?.includeProofFacts ? [RPC2.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
14852
14836
  return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex", {
14853
14837
  block_id,
14854
14838
  index,
@@ -14889,9 +14873,9 @@ var RpcChannel2 = class {
14889
14873
  } = simulateTransactionOptions;
14890
14874
  const block_id = new Block(blockIdentifier).identifier;
14891
14875
  const simulationFlags = [];
14892
- if (skipValidate) simulationFlags.push(RPC.ESimulationFlag.SKIP_VALIDATE);
14893
- if (skipFeeCharge) simulationFlags.push(RPC.ESimulationFlag.SKIP_FEE_CHARGE);
14894
- const trace_flags = returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
14876
+ if (skipValidate) simulationFlags.push(RPC2.ESimulationFlag.SKIP_VALIDATE);
14877
+ if (skipFeeCharge) simulationFlags.push(RPC2.ESimulationFlag.SKIP_FEE_CHARGE);
14878
+ const trace_flags = returnInitialReads ? [RPC2.ETraceFlag.RETURN_INITIAL_READS] : void 0;
14895
14879
  return this.fetchEndpoint("starknet_simulateTransactions", {
14896
14880
  block_id,
14897
14881
  transactions: await Promise.all(invocations.map((it) => this.buildTransaction(it))),
@@ -14910,13 +14894,13 @@ var RpcChannel2 = class {
14910
14894
  const errorStates = options?.errorStates ?? [];
14911
14895
  const successStates = options?.successStates ?? [
14912
14896
  // RPC.ETransactionExecutionStatus.SUCCEEDED, // UDC on SUCCEEDED + pre_confirmed had no proper events to parse UDC
14913
- RPC.ETransactionFinalityStatus.ACCEPTED_ON_L2,
14914
- RPC.ETransactionFinalityStatus.ACCEPTED_ON_L1
14897
+ RPC2.ETransactionFinalityStatus.ACCEPTED_ON_L2,
14898
+ RPC2.ETransactionFinalityStatus.ACCEPTED_ON_L1
14915
14899
  ];
14916
14900
  const errorMessages = {
14917
- [RPC.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
14918
- [RPC.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
14919
- [RPC.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
14901
+ [RPC2.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
14902
+ [RPC2.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
14903
+ [RPC2.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
14920
14904
  };
14921
14905
  const txLife = [];
14922
14906
  let txStatus;
@@ -15013,7 +14997,7 @@ var RpcChannel2 = class {
15013
14997
  const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
15014
14998
  const block_id = new Block(blockIdentifier).identifier;
15015
14999
  const flags = {
15016
- simulation_flags: skipValidate ? [RPC.ESimulationFlag.SKIP_VALIDATE] : []
15000
+ simulation_flags: skipValidate ? [RPC2.ESimulationFlag.SKIP_VALIDATE] : []
15017
15001
  };
15018
15002
  return this.fetchEndpoint("starknet_estimateFee", {
15019
15003
  request: await Promise.all(invocations.map((it) => this.buildTransaction(it, "fee"))),
@@ -15133,7 +15117,7 @@ var RpcChannel2 = class {
15133
15117
  };
15134
15118
  if (invocation.type === api_exports.ETransactionType.INVOKE) {
15135
15119
  const btx = {
15136
- type: RPC.ETransactionType.INVOKE,
15120
+ type: RPC2.ETransactionType.INVOKE,
15137
15121
  sender_address: invocation.contractAddress,
15138
15122
  calldata: CallData.toHex(invocation.calldata),
15139
15123
  ...details,