starknet 8.5.4 → 8.6.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.js CHANGED
@@ -128,6 +128,7 @@ __export(index_exports, {
128
128
  addAddressPadding: () => addAddressPadding,
129
129
  byteArray: () => byteArray_exports,
130
130
  cairo: () => cairo_exports,
131
+ compareVersions: () => compareVersions,
131
132
  config: () => config,
132
133
  constants: () => constants_exports,
133
134
  contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
@@ -304,7 +305,7 @@ function buf2hex(buffer) {
304
305
  return buffer.reduce((r, x) => r + x.toString(16).padStart(2, "0"), "");
305
306
  }
306
307
  function removeHexPrefix(hex) {
307
- return hex.replace(/^0x/i, "");
308
+ return hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
308
309
  }
309
310
  function addHexPrefix(hex) {
310
311
  return `0x${removeHexPrefix(hex)}`;
@@ -346,11 +347,10 @@ function concatenateArrayBuffer(uint8arrays) {
346
347
  return result;
347
348
  }
348
349
  function hexStringToUint8Array(hex) {
349
- const cleanHex2 = hex.startsWith("0x") ? hex.slice(2) : hex;
350
- if (cleanHex2.length > 0 && !/^[0-9a-fA-F]+$/.test(cleanHex2)) {
351
- throw new Error(`Invalid hex string: "${hex}" contains non-hexadecimal characters`);
350
+ if (!isHexString(addHexPrefix(hex))) {
351
+ throw new Error(`Invalid hex string: "${hex}"`);
352
352
  }
353
- const paddedHex = cleanHex2.length % 2 !== 0 ? `0${cleanHex2}` : cleanHex2;
353
+ const paddedHex = removeHexPrefix(sanitizeHex(hex));
354
354
  const bytes = new Uint8Array(paddedHex.length / 2);
355
355
  for (let i = 0; i < paddedHex.length; i += 2) {
356
356
  bytes[i / 2] = parseInt(paddedHex.substring(i, i + 2), 16);
@@ -490,7 +490,8 @@ var DEFAULT_GLOBAL_CONFIG = {
490
490
  defaultTipType: "recommendedTip",
491
491
  fetch: void 0,
492
492
  websocket: void 0,
493
- buffer: void 0
493
+ buffer: void 0,
494
+ blake: void 0
494
495
  };
495
496
  var RPC_DEFAULT_NODES = {
496
497
  SN_MAIN: [`https://starknet-mainnet.public.blastapi.io/rpc/`],
@@ -991,6 +992,9 @@ function toHex(value) {
991
992
  return addHexPrefix(toBigInt(value).toString(16));
992
993
  }
993
994
  var toHexString = toHex;
995
+ function cleanHex(hex) {
996
+ return toHex(hex);
997
+ }
994
998
  function toStorageKey(number) {
995
999
  return addHexPrefix(toBigInt(number).toString(16).padStart(64, "0"));
996
1000
  }
@@ -1002,9 +1006,6 @@ function toHex64(number) {
1002
1006
  function hexToDecimalString(hex) {
1003
1007
  return BigInt(addHexPrefix(hex)).toString(10);
1004
1008
  }
1005
- function cleanHex(hex) {
1006
- return hex.toLowerCase().replace(/^(0x)0+/, "$1");
1007
- }
1008
1009
  function assertInRange(input, lowerBound, upperBound, inputName = "") {
1009
1010
  const messageSuffix = inputName === "" ? "invalid length" : `invalid ${inputName} length`;
1010
1011
  const inputBigInt = BigInt(input);
@@ -4787,12 +4788,16 @@ var CallData = class _CallData {
4787
4788
  // src/utils/hash/index.ts
4788
4789
  var hash_exports = {};
4789
4790
  __export(hash_exports, {
4791
+ COMPILED_CLASS_VERSION: () => COMPILED_CLASS_VERSION,
4792
+ blake2sHashMany: () => blake2sHashMany,
4790
4793
  calculateContractAddressFromHash: () => calculateContractAddressFromHash,
4791
4794
  calculateDeclareTransactionHash: () => calculateDeclareTransactionHash3,
4792
4795
  calculateDeployAccountTransactionHash: () => calculateDeployAccountTransactionHash3,
4793
4796
  calculateInvokeTransactionHash: () => calculateInvokeTransactionHash2,
4794
4797
  calculateL2MessageTxHash: () => calculateL2MessageTxHash,
4795
4798
  computeCompiledClassHash: () => computeCompiledClassHash,
4799
+ computeCompiledClassHashBlake: () => computeCompiledClassHashBlake,
4800
+ computeCompiledClassHashPoseidon: () => computeCompiledClassHashPoseidon,
4796
4801
  computeContractClassHash: () => computeContractClassHash,
4797
4802
  computeHashOnElements: () => computeHashOnElements2,
4798
4803
  computeHintedClassHash: () => computeHintedClassHash,
@@ -4802,13 +4807,17 @@ __export(hash_exports, {
4802
4807
  computePoseidonHash: () => computePoseidonHash,
4803
4808
  computePoseidonHashOnElements: () => computePoseidonHashOnElements,
4804
4809
  computeSierraContractClassHash: () => computeSierraContractClassHash,
4810
+ encodeBuiltins: () => encodeBuiltins,
4811
+ flattenEntryPointData: () => flattenEntryPointData,
4805
4812
  formatSpaces: () => formatSpaces,
4806
4813
  getL1MessageHash: () => getL1MessageHash,
4807
4814
  getL2MessageHash: () => getL2MessageHash,
4808
4815
  getSelector: () => getSelector,
4809
4816
  getSelectorFromName: () => getSelectorFromName,
4810
4817
  hashByteCodeSegments: () => hashByteCodeSegments,
4818
+ hashByteCodeSegmentsBlake: () => hashByteCodeSegmentsBlake,
4811
4819
  keccakBn: () => keccakBn,
4820
+ nullSkipReplacer: () => nullSkipReplacer,
4812
4821
  poseidon: () => poseidon,
4813
4822
  solidityUint256PackedKeccak256: () => solidityUint256PackedKeccak256,
4814
4823
  starknetKeccak: () => starknetKeccak
@@ -5073,21 +5082,51 @@ function calculateDeployAccountTransactionHash3(args) {
5073
5082
  throw new Error("Invalid Tx version for hash calculation");
5074
5083
  }
5075
5084
 
5076
- // src/utils/hash/classHash.ts
5077
- var import_starknet3 = require("@scure/starknet");
5085
+ // src/utils/hash/classHash/util.ts
5086
+ var COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
5087
+ function formatSpaces(json2) {
5088
+ let insideQuotes = false;
5089
+ const newString = [];
5090
+ for (const char of json2) {
5091
+ if (char === '"' && (newString.length > 0 && newString.slice(-1)[0] === "\\") === false) {
5092
+ insideQuotes = !insideQuotes;
5093
+ }
5094
+ if (insideQuotes) {
5095
+ newString.push(char);
5096
+ } else {
5097
+ newString.push(char === ":" ? ": " : char === "," ? ", " : char);
5098
+ }
5099
+ }
5100
+ return newString.join("");
5101
+ }
5102
+ function nullSkipReplacer(key, value) {
5103
+ if (key === "attributes" || key === "accessible_scopes") {
5104
+ return Array.isArray(value) && value.length === 0 ? void 0 : value;
5105
+ }
5106
+ if (key === "debug_info") {
5107
+ return null;
5108
+ }
5109
+ return value === null ? void 0 : value;
5110
+ }
5111
+ function encodeBuiltins(builtins) {
5112
+ return builtins.map((it) => BigInt(encodeShortString(it)));
5113
+ }
5114
+ function flattenEntryPointData(data, encodedBuiltinsArray) {
5115
+ return data.flatMap((it, index) => [
5116
+ BigInt(it.selector),
5117
+ BigInt(it.offset),
5118
+ ...encodedBuiltinsArray[index]
5119
+ ]);
5120
+ }
5121
+
5122
+ // src/utils/hash/classHash/pedersen.ts
5078
5123
  function computePedersenHash(a, b) {
5079
5124
  return starkCurve.pedersen(BigInt(a), BigInt(b));
5080
5125
  }
5081
- function computePoseidonHash(a, b) {
5082
- return toHex(starkCurve.poseidonHash(BigInt(a), BigInt(b)));
5083
- }
5084
5126
  function computeHashOnElements2(data) {
5085
5127
  return [...data, data.length].reduce((x, y) => starkCurve.pedersen(BigInt(x), BigInt(y)), 0).toString();
5086
5128
  }
5087
5129
  var computePedersenHashOnElements = computeHashOnElements2;
5088
- function computePoseidonHashOnElements(data) {
5089
- return toHex((0, import_starknet3.poseidonHashMany)(data.map((x) => BigInt(x))));
5090
- }
5091
5130
  function calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress) {
5092
5131
  const compiledCalldata = CallData.compile(constructorCalldata);
5093
5132
  const constructorCalldataHash = computeHashOnElements2(compiledCalldata);
@@ -5101,30 +5140,6 @@ function calculateContractAddressFromHash(salt, classHash, constructorCalldata,
5101
5140
  ]);
5102
5141
  return toHex(BigInt(hash) % ADDR_BOUND);
5103
5142
  }
5104
- function nullSkipReplacer(key, value) {
5105
- if (key === "attributes" || key === "accessible_scopes") {
5106
- return Array.isArray(value) && value.length === 0 ? void 0 : value;
5107
- }
5108
- if (key === "debug_info") {
5109
- return null;
5110
- }
5111
- return value === null ? void 0 : value;
5112
- }
5113
- function formatSpaces(json2) {
5114
- let insideQuotes = false;
5115
- const newString = [];
5116
- for (const char of json2) {
5117
- if (char === '"' && (newString.length > 0 && newString.slice(-1)[0] === "\\") === false) {
5118
- insideQuotes = !insideQuotes;
5119
- }
5120
- if (insideQuotes) {
5121
- newString.push(char);
5122
- } else {
5123
- newString.push(char === ":" ? ": " : char === "," ? ", " : char);
5124
- }
5125
- }
5126
- return newString.join("");
5127
- }
5128
5143
  function computeHintedClassHash(compiledContract) {
5129
5144
  const { abi, program } = compiledContract;
5130
5145
  const contractClass = { abi, program };
@@ -5158,12 +5173,17 @@ function computeLegacyContractClassHash(contract) {
5158
5173
  dataHash
5159
5174
  ]);
5160
5175
  }
5176
+
5177
+ // src/utils/hash/classHash/poseidon.ts
5178
+ var import_starknet3 = require("@scure/starknet");
5179
+ function computePoseidonHash(a, b) {
5180
+ return toHex(starkCurve.poseidonHash(BigInt(a), BigInt(b)));
5181
+ }
5182
+ function computePoseidonHashOnElements(data) {
5183
+ return toHex((0, import_starknet3.poseidonHashMany)(data.map((x) => BigInt(x))));
5184
+ }
5161
5185
  function hashBuiltins(builtins) {
5162
- return (0, import_starknet3.poseidonHashMany)(
5163
- builtins.flatMap((it) => {
5164
- return BigInt(encodeShortString(it));
5165
- })
5166
- );
5186
+ return (0, import_starknet3.poseidonHashMany)(encodeBuiltins(builtins));
5167
5187
  }
5168
5188
  function hashEntryPoint(data) {
5169
5189
  const base = data.flatMap((it) => {
@@ -5181,8 +5201,7 @@ function hashByteCodeSegments(casm) {
5181
5201
  });
5182
5202
  return 1n + (0, import_starknet3.poseidonHashMany)(hashLeaves);
5183
5203
  }
5184
- function computeCompiledClassHash(casm) {
5185
- const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
5204
+ function computeCompiledClassHashPoseidon(casm) {
5186
5205
  const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
5187
5206
  const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
5188
5207
  const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
@@ -5227,6 +5246,161 @@ function computeSierraContractClassHash(sierra) {
5227
5246
  ])
5228
5247
  );
5229
5248
  }
5249
+
5250
+ // src/utils/connect/blake.ts
5251
+ var import_blake2s = require("@noble/hashes/blake2s");
5252
+ function blakeHash(uint8Array) {
5253
+ return config.get("blake")?.(uint8Array) || (0, import_blake2s.blake2s)(uint8Array, { dkLen: 32 });
5254
+ }
5255
+
5256
+ // src/utils/hash/classHash/blake.ts
5257
+ function blake2sHashMany(data) {
5258
+ const SMALL_THRESHOLD = 0x8000000000000000n;
5259
+ const BIG_MARKER = 2147483648;
5260
+ const u32Words = [];
5261
+ const buf = new ArrayBuffer(32);
5262
+ const feltView = new DataView(buf);
5263
+ for (const felt2 of data) {
5264
+ const u64_0 = felt2 & 0xffffffffffffffffn;
5265
+ const u64_1 = (felt2 & 0xffffffffffffffff0000000000000000n) >> 64n;
5266
+ const u64_2 = (felt2 & 0xffffffffffffffff00000000000000000000000000000000n) >> 128n;
5267
+ const u64_3 = (felt2 & 0xffffffffffffffff000000000000000000000000000000000000000000000000n) >> 192n;
5268
+ feltView.setBigUint64(0, u64_3, false);
5269
+ feltView.setBigUint64(8, u64_2, false);
5270
+ feltView.setBigUint64(16, u64_1, false);
5271
+ feltView.setBigUint64(24, u64_0, false);
5272
+ if (felt2 < SMALL_THRESHOLD) {
5273
+ const hi0 = feltView.getUint32(24, false);
5274
+ const lo0 = feltView.getUint32(28, false);
5275
+ u32Words.push(hi0, lo0);
5276
+ } else {
5277
+ const word0 = feltView.getUint32(0, false) | BIG_MARKER;
5278
+ const word1 = feltView.getUint32(4, false);
5279
+ const word2 = feltView.getUint32(8, false);
5280
+ const word3 = feltView.getUint32(12, false);
5281
+ const word4 = feltView.getUint32(16, false);
5282
+ const word5 = feltView.getUint32(20, false);
5283
+ const word6 = feltView.getUint32(24, false);
5284
+ const word7 = feltView.getUint32(28, false);
5285
+ u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
5286
+ }
5287
+ }
5288
+ const bytes = new ArrayBuffer(u32Words.length * 4);
5289
+ const bytesView = new DataView(bytes);
5290
+ for (let i = 0; i < u32Words.length; i++) {
5291
+ bytesView.setUint32(i * 4, u32Words[i], true);
5292
+ }
5293
+ const hash = blakeHash(new Uint8Array(bytes));
5294
+ let hashBigInt = 0n;
5295
+ for (let i = 0; i < 32; i++) {
5296
+ hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
5297
+ }
5298
+ return hashBigInt % PRIME;
5299
+ }
5300
+ function hashBuiltinsBlake(builtins) {
5301
+ return blake2sHashMany(encodeBuiltins(builtins));
5302
+ }
5303
+ function hashEntryPointBlake(data) {
5304
+ const base = data.flatMap((it) => {
5305
+ return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
5306
+ });
5307
+ return blake2sHashMany(base);
5308
+ }
5309
+ function bytecodeHashNodeBlake(iter, node) {
5310
+ if (typeof node === "number") {
5311
+ const data = [];
5312
+ for (let i = 0; i < node; i++) {
5313
+ const next = iter.next();
5314
+ if (next.done) throw new Error("Bytecode length mismatch");
5315
+ data.push(next.value);
5316
+ }
5317
+ return [node, blake2sHashMany(data)];
5318
+ }
5319
+ const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
5320
+ const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
5321
+ const hash = blake2sHashMany(flatData) + 1n;
5322
+ const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
5323
+ return [totalLen, hash];
5324
+ }
5325
+ function hashByteCodeSegmentsBlake(casm) {
5326
+ const byteCode = casm.bytecode.map((n) => BigInt(n));
5327
+ const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
5328
+ if (!bytecodeSegmentLengths) {
5329
+ return blake2sHashMany(byteCode);
5330
+ }
5331
+ const iter = byteCode[Symbol.iterator]();
5332
+ const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
5333
+ if (len !== byteCode.length) {
5334
+ throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
5335
+ }
5336
+ return hash;
5337
+ }
5338
+ function computeCompiledClassHashBlake(casm) {
5339
+ const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
5340
+ const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
5341
+ const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
5342
+ const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
5343
+ const bytecode = hashByteCodeSegmentsBlake(casm);
5344
+ return toHex(
5345
+ blake2sHashMany([
5346
+ compiledClassVersion,
5347
+ externalEntryPointsHash,
5348
+ l1Handlers,
5349
+ constructor,
5350
+ bytecode
5351
+ ])
5352
+ );
5353
+ }
5354
+
5355
+ // src/utils/resolve.ts
5356
+ function isV3Tx(details) {
5357
+ const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5358
+ return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5359
+ }
5360
+ function isVersion(expected, provided) {
5361
+ const expectedParts = expected.split(".");
5362
+ const providedParts = provided.split(".");
5363
+ return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
5364
+ }
5365
+ function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
5366
+ return Object.values(_SupportedRpcVersion).some(
5367
+ (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
5368
+ );
5369
+ }
5370
+ function toAnyPatchVersion(version) {
5371
+ const parts = version.split(".");
5372
+ if (parts.length < 3) {
5373
+ return version;
5374
+ }
5375
+ return `${parts[0]}.${parts[1]}.*`;
5376
+ }
5377
+ function toApiVersion(version) {
5378
+ const [major, minor] = version.replace(/^v/, "").split(".");
5379
+ return `v${major}_${minor}`;
5380
+ }
5381
+ function compareVersions(a, b) {
5382
+ const aParts = a.split(".").map(Number);
5383
+ const bParts = b.split(".").map(Number);
5384
+ const maxLen = Math.max(aParts.length, bParts.length);
5385
+ for (let i = 0; i < maxLen; i += 1) {
5386
+ const aNum = aParts[i] || 0;
5387
+ const bNum = bParts[i] || 0;
5388
+ if (aNum > bNum) return 1;
5389
+ if (aNum < bNum) return -1;
5390
+ }
5391
+ return 0;
5392
+ }
5393
+ function isPendingBlock(response) {
5394
+ return response.status === "PENDING";
5395
+ }
5396
+ function isPendingTransaction(response) {
5397
+ return !("block_hash" in response);
5398
+ }
5399
+ function isPendingStateUpdate(response) {
5400
+ return !("block_hash" in response);
5401
+ }
5402
+
5403
+ // src/utils/hash/classHash/index.ts
5230
5404
  function computeContractClassHash(contract) {
5231
5405
  const compiledContract = isString(contract) ? parse2(contract) : contract;
5232
5406
  if ("sierra_program" in compiledContract) {
@@ -5234,6 +5408,12 @@ function computeContractClassHash(contract) {
5234
5408
  }
5235
5409
  return computeLegacyContractClassHash(compiledContract);
5236
5410
  }
5411
+ function computeCompiledClassHash(casm, specVersion) {
5412
+ if (specVersion && compareVersions(specVersion, "0.10.0") >= 0) {
5413
+ return computeCompiledClassHashBlake(casm);
5414
+ }
5415
+ return computeCompiledClassHashPoseidon(casm);
5416
+ }
5237
5417
 
5238
5418
  // src/utils/stark/index.ts
5239
5419
  var stark_exports = {};
@@ -5439,11 +5619,11 @@ function isSierra(contract) {
5439
5619
  const compiledContract = isString(contract) ? parse2(contract) : contract;
5440
5620
  return "sierra_program" in compiledContract;
5441
5621
  }
5442
- function extractContractHashes(payload) {
5622
+ function extractContractHashes(payload, specVersion) {
5443
5623
  const response = { ...payload };
5444
5624
  if (isSierra(payload.contract)) {
5445
5625
  if (!payload.compiledClassHash && payload.casm) {
5446
- response.compiledClassHash = computeCompiledClassHash(payload.casm);
5626
+ response.compiledClassHash = computeCompiledClassHash(payload.casm, specVersion);
5447
5627
  }
5448
5628
  if (!response.compiledClassHash)
5449
5629
  throw new Error(
@@ -5500,44 +5680,6 @@ __export(provider_exports, {
5500
5680
  validBlockTags: () => validBlockTags,
5501
5681
  wait: () => wait
5502
5682
  });
5503
-
5504
- // src/utils/resolve.ts
5505
- function isV3Tx(details) {
5506
- const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5507
- return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5508
- }
5509
- function isVersion(expected, provided) {
5510
- const expectedParts = expected.split(".");
5511
- const providedParts = provided.split(".");
5512
- return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
5513
- }
5514
- function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
5515
- return Object.values(_SupportedRpcVersion).some(
5516
- (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
5517
- );
5518
- }
5519
- function toAnyPatchVersion(version) {
5520
- const parts = version.split(".");
5521
- if (parts.length < 3) {
5522
- return version;
5523
- }
5524
- return `${parts[0]}.${parts[1]}.*`;
5525
- }
5526
- function toApiVersion(version) {
5527
- const [major, minor] = version.replace(/^v/, "").split(".");
5528
- return `v${major}_${minor}`;
5529
- }
5530
- function isPendingBlock(response) {
5531
- return response.status === "PENDING";
5532
- }
5533
- function isPendingTransaction(response) {
5534
- return !("block_hash" in response);
5535
- }
5536
- function isPendingStateUpdate(response) {
5537
- return !("block_hash" in response);
5538
- }
5539
-
5540
- // src/utils/provider.ts
5541
5683
  function wait(delay) {
5542
5684
  return new Promise((res) => {
5543
5685
  setTimeout(res, delay);
@@ -8711,7 +8853,10 @@ var RpcProvider = class {
8711
8853
  async isClassDeclared(contractClassIdentifier, blockIdentifier) {
8712
8854
  let classHash;
8713
8855
  if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
8714
- const hashes = extractContractHashes(contractClassIdentifier);
8856
+ const hashes = extractContractHashes(
8857
+ contractClassIdentifier,
8858
+ await this.channel.setUpSpecVersion()
8859
+ );
8715
8860
  classHash = hashes.classHash;
8716
8861
  } else if (contractClassIdentifier.classHash) {
8717
8862
  classHash = contractClassIdentifier.classHash;
@@ -10982,7 +11127,7 @@ var Deployer = class {
10982
11127
  throw new Error("Deployer emitted event is empty");
10983
11128
  }
10984
11129
  const event = txReceipt.events.find(
10985
- (it) => cleanHex(it.from_address) === cleanHex(toHex(this.address))
11130
+ (it) => toHex(it.from_address) === toHex(this.address)
10986
11131
  ) || {
10987
11132
  data: []
10988
11133
  };
@@ -11082,7 +11227,10 @@ var Account = class extends RpcProvider2 {
11082
11227
  "Declare fee estimation is not supported for Cairo0 contracts"
11083
11228
  );
11084
11229
  const invocations = [
11085
- { type: api_exports.ETransactionType.DECLARE, payload: extractContractHashes(payload) }
11230
+ {
11231
+ type: api_exports.ETransactionType.DECLARE,
11232
+ payload: extractContractHashes(payload, await this.channel.setUpSpecVersion())
11233
+ }
11086
11234
  ];
11087
11235
  const estimateBulk = await this.estimateFeeBulk(invocations, details);
11088
11236
  return estimateBulk[0];
@@ -11245,7 +11393,10 @@ var Account = class extends RpcProvider2 {
11245
11393
  * @param transactionsDetail (optional)
11246
11394
  */
11247
11395
  async declareIfNot(payload, transactionsDetail = {}) {
11248
- const declareContractPayload = extractContractHashes(payload);
11396
+ const declareContractPayload = extractContractHashes(
11397
+ payload,
11398
+ await this.channel.setUpSpecVersion()
11399
+ );
11249
11400
  try {
11250
11401
  await this.getClassByHash(declareContractPayload.classHash);
11251
11402
  } catch (error) {
@@ -11258,7 +11409,10 @@ var Account = class extends RpcProvider2 {
11258
11409
  }
11259
11410
  async declare(payload, details = {}) {
11260
11411
  assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
11261
- const declareContractPayload = extractContractHashes(payload);
11412
+ const declareContractPayload = extractContractHashes(
11413
+ payload,
11414
+ await this.channel.setUpSpecVersion()
11415
+ );
11262
11416
  const detailsWithTip = await this.resolveDetailsWithTip(details);
11263
11417
  const { resourceBounds: providedResourceBounds } = details;
11264
11418
  let resourceBounds = providedResourceBounds;
@@ -11565,7 +11719,10 @@ var Account = class extends RpcProvider2 {
11565
11719
  };
11566
11720
  }
11567
11721
  async buildDeclarePayload(payload, details) {
11568
- const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
11722
+ const { classHash, contract, compiledClassHash } = extractContractHashes(
11723
+ payload,
11724
+ await this.channel.setUpSpecVersion()
11725
+ );
11569
11726
  const compressedCompiledContract = parseContract(contract);
11570
11727
  assert(
11571
11728
  !isUndefined(compiledClassHash) && (details.version === ETransactionVersion3.F3 || details.version === ETransactionVersion3.V3),
@@ -11911,8 +12068,11 @@ var WalletAccount = class _WalletAccount extends Account {
11911
12068
  };
11912
12069
  return addInvokeTransaction(this.walletProvider, params);
11913
12070
  }
11914
- declare(payload) {
11915
- const declareContractPayload = extractContractHashes(payload);
12071
+ async declare(payload) {
12072
+ const declareContractPayload = extractContractHashes(
12073
+ payload,
12074
+ await this.channel.setUpSpecVersion()
12075
+ );
11916
12076
  const pContract = payload.contract;
11917
12077
  const cairo1Contract = {
11918
12078
  ...pContract,
@@ -12329,7 +12489,7 @@ var Contract = class _Contract {
12329
12489
  transaction_hash: txR.transaction_hash,
12330
12490
  ...event
12331
12491
  };
12332
- }).filter((event) => cleanHex(event.from_address) === cleanHex(this.address), []) || [];
12492
+ }).filter((event) => toHex(event.from_address) === toHex(this.address), []) || [];
12333
12493
  parsed = parseEvents(
12334
12494
  emittedEvents,
12335
12495
  this.events,
@@ -12624,6 +12784,7 @@ function units(amount, simbol = "fri") {
12624
12784
  addAddressPadding,
12625
12785
  byteArray,
12626
12786
  cairo,
12787
+ compareVersions,
12627
12788
  config,
12628
12789
  constants,
12629
12790
  contractClassResponseToLegacyCompiledContract,