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.mjs CHANGED
@@ -130,7 +130,7 @@ function buf2hex(buffer) {
130
130
  return buffer.reduce((r, x) => r + x.toString(16).padStart(2, "0"), "");
131
131
  }
132
132
  function removeHexPrefix(hex) {
133
- return hex.replace(/^0x/i, "");
133
+ return hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
134
134
  }
135
135
  function addHexPrefix(hex) {
136
136
  return `0x${removeHexPrefix(hex)}`;
@@ -172,11 +172,10 @@ function concatenateArrayBuffer(uint8arrays) {
172
172
  return result;
173
173
  }
174
174
  function hexStringToUint8Array(hex) {
175
- const cleanHex2 = hex.startsWith("0x") ? hex.slice(2) : hex;
176
- if (cleanHex2.length > 0 && !/^[0-9a-fA-F]+$/.test(cleanHex2)) {
177
- throw new Error(`Invalid hex string: "${hex}" contains non-hexadecimal characters`);
175
+ if (!isHexString(addHexPrefix(hex))) {
176
+ throw new Error(`Invalid hex string: "${hex}"`);
178
177
  }
179
- const paddedHex = cleanHex2.length % 2 !== 0 ? `0${cleanHex2}` : cleanHex2;
178
+ const paddedHex = removeHexPrefix(sanitizeHex(hex));
180
179
  const bytes = new Uint8Array(paddedHex.length / 2);
181
180
  for (let i = 0; i < paddedHex.length; i += 2) {
182
181
  bytes[i / 2] = parseInt(paddedHex.substring(i, i + 2), 16);
@@ -316,7 +315,8 @@ var DEFAULT_GLOBAL_CONFIG = {
316
315
  defaultTipType: "recommendedTip",
317
316
  fetch: void 0,
318
317
  websocket: void 0,
319
- buffer: void 0
318
+ buffer: void 0,
319
+ blake: void 0
320
320
  };
321
321
  var RPC_DEFAULT_NODES = {
322
322
  SN_MAIN: [`https://starknet-mainnet.public.blastapi.io/rpc/`],
@@ -817,6 +817,9 @@ function toHex(value) {
817
817
  return addHexPrefix(toBigInt(value).toString(16));
818
818
  }
819
819
  var toHexString = toHex;
820
+ function cleanHex(hex) {
821
+ return toHex(hex);
822
+ }
820
823
  function toStorageKey(number) {
821
824
  return addHexPrefix(toBigInt(number).toString(16).padStart(64, "0"));
822
825
  }
@@ -828,9 +831,6 @@ function toHex64(number) {
828
831
  function hexToDecimalString(hex) {
829
832
  return BigInt(addHexPrefix(hex)).toString(10);
830
833
  }
831
- function cleanHex(hex) {
832
- return hex.toLowerCase().replace(/^(0x)0+/, "$1");
833
- }
834
834
  function assertInRange(input, lowerBound, upperBound, inputName = "") {
835
835
  const messageSuffix = inputName === "" ? "invalid length" : `invalid ${inputName} length`;
836
836
  const inputBigInt = BigInt(input);
@@ -4613,12 +4613,16 @@ var CallData = class _CallData {
4613
4613
  // src/utils/hash/index.ts
4614
4614
  var hash_exports = {};
4615
4615
  __export(hash_exports, {
4616
+ COMPILED_CLASS_VERSION: () => COMPILED_CLASS_VERSION,
4617
+ blake2sHashMany: () => blake2sHashMany,
4616
4618
  calculateContractAddressFromHash: () => calculateContractAddressFromHash,
4617
4619
  calculateDeclareTransactionHash: () => calculateDeclareTransactionHash3,
4618
4620
  calculateDeployAccountTransactionHash: () => calculateDeployAccountTransactionHash3,
4619
4621
  calculateInvokeTransactionHash: () => calculateInvokeTransactionHash2,
4620
4622
  calculateL2MessageTxHash: () => calculateL2MessageTxHash,
4621
4623
  computeCompiledClassHash: () => computeCompiledClassHash,
4624
+ computeCompiledClassHashBlake: () => computeCompiledClassHashBlake,
4625
+ computeCompiledClassHashPoseidon: () => computeCompiledClassHashPoseidon,
4622
4626
  computeContractClassHash: () => computeContractClassHash,
4623
4627
  computeHashOnElements: () => computeHashOnElements2,
4624
4628
  computeHintedClassHash: () => computeHintedClassHash,
@@ -4628,13 +4632,17 @@ __export(hash_exports, {
4628
4632
  computePoseidonHash: () => computePoseidonHash,
4629
4633
  computePoseidonHashOnElements: () => computePoseidonHashOnElements,
4630
4634
  computeSierraContractClassHash: () => computeSierraContractClassHash,
4635
+ encodeBuiltins: () => encodeBuiltins,
4636
+ flattenEntryPointData: () => flattenEntryPointData,
4631
4637
  formatSpaces: () => formatSpaces,
4632
4638
  getL1MessageHash: () => getL1MessageHash,
4633
4639
  getL2MessageHash: () => getL2MessageHash,
4634
4640
  getSelector: () => getSelector,
4635
4641
  getSelectorFromName: () => getSelectorFromName,
4636
4642
  hashByteCodeSegments: () => hashByteCodeSegments,
4643
+ hashByteCodeSegmentsBlake: () => hashByteCodeSegmentsBlake,
4637
4644
  keccakBn: () => keccakBn,
4645
+ nullSkipReplacer: () => nullSkipReplacer,
4638
4646
  poseidon: () => poseidon,
4639
4647
  solidityUint256PackedKeccak256: () => solidityUint256PackedKeccak256,
4640
4648
  starknetKeccak: () => starknetKeccak
@@ -4899,21 +4907,51 @@ function calculateDeployAccountTransactionHash3(args) {
4899
4907
  throw new Error("Invalid Tx version for hash calculation");
4900
4908
  }
4901
4909
 
4902
- // src/utils/hash/classHash.ts
4903
- import { poseidonHashMany as poseidonHashMany2 } from "@scure/starknet";
4910
+ // src/utils/hash/classHash/util.ts
4911
+ var COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
4912
+ function formatSpaces(json2) {
4913
+ let insideQuotes = false;
4914
+ const newString = [];
4915
+ for (const char of json2) {
4916
+ if (char === '"' && (newString.length > 0 && newString.slice(-1)[0] === "\\") === false) {
4917
+ insideQuotes = !insideQuotes;
4918
+ }
4919
+ if (insideQuotes) {
4920
+ newString.push(char);
4921
+ } else {
4922
+ newString.push(char === ":" ? ": " : char === "," ? ", " : char);
4923
+ }
4924
+ }
4925
+ return newString.join("");
4926
+ }
4927
+ function nullSkipReplacer(key, value) {
4928
+ if (key === "attributes" || key === "accessible_scopes") {
4929
+ return Array.isArray(value) && value.length === 0 ? void 0 : value;
4930
+ }
4931
+ if (key === "debug_info") {
4932
+ return null;
4933
+ }
4934
+ return value === null ? void 0 : value;
4935
+ }
4936
+ function encodeBuiltins(builtins) {
4937
+ return builtins.map((it) => BigInt(encodeShortString(it)));
4938
+ }
4939
+ function flattenEntryPointData(data, encodedBuiltinsArray) {
4940
+ return data.flatMap((it, index) => [
4941
+ BigInt(it.selector),
4942
+ BigInt(it.offset),
4943
+ ...encodedBuiltinsArray[index]
4944
+ ]);
4945
+ }
4946
+
4947
+ // src/utils/hash/classHash/pedersen.ts
4904
4948
  function computePedersenHash(a, b) {
4905
4949
  return starkCurve.pedersen(BigInt(a), BigInt(b));
4906
4950
  }
4907
- function computePoseidonHash(a, b) {
4908
- return toHex(starkCurve.poseidonHash(BigInt(a), BigInt(b)));
4909
- }
4910
4951
  function computeHashOnElements2(data) {
4911
4952
  return [...data, data.length].reduce((x, y) => starkCurve.pedersen(BigInt(x), BigInt(y)), 0).toString();
4912
4953
  }
4913
4954
  var computePedersenHashOnElements = computeHashOnElements2;
4914
- function computePoseidonHashOnElements(data) {
4915
- return toHex(poseidonHashMany2(data.map((x) => BigInt(x))));
4916
- }
4917
4955
  function calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress) {
4918
4956
  const compiledCalldata = CallData.compile(constructorCalldata);
4919
4957
  const constructorCalldataHash = computeHashOnElements2(compiledCalldata);
@@ -4927,30 +4965,6 @@ function calculateContractAddressFromHash(salt, classHash, constructorCalldata,
4927
4965
  ]);
4928
4966
  return toHex(BigInt(hash) % ADDR_BOUND);
4929
4967
  }
4930
- function nullSkipReplacer(key, value) {
4931
- if (key === "attributes" || key === "accessible_scopes") {
4932
- return Array.isArray(value) && value.length === 0 ? void 0 : value;
4933
- }
4934
- if (key === "debug_info") {
4935
- return null;
4936
- }
4937
- return value === null ? void 0 : value;
4938
- }
4939
- function formatSpaces(json2) {
4940
- let insideQuotes = false;
4941
- const newString = [];
4942
- for (const char of json2) {
4943
- if (char === '"' && (newString.length > 0 && newString.slice(-1)[0] === "\\") === false) {
4944
- insideQuotes = !insideQuotes;
4945
- }
4946
- if (insideQuotes) {
4947
- newString.push(char);
4948
- } else {
4949
- newString.push(char === ":" ? ": " : char === "," ? ", " : char);
4950
- }
4951
- }
4952
- return newString.join("");
4953
- }
4954
4968
  function computeHintedClassHash(compiledContract) {
4955
4969
  const { abi, program } = compiledContract;
4956
4970
  const contractClass = { abi, program };
@@ -4984,12 +4998,17 @@ function computeLegacyContractClassHash(contract) {
4984
4998
  dataHash
4985
4999
  ]);
4986
5000
  }
5001
+
5002
+ // src/utils/hash/classHash/poseidon.ts
5003
+ import { poseidonHashMany as poseidonHashMany2 } from "@scure/starknet";
5004
+ function computePoseidonHash(a, b) {
5005
+ return toHex(starkCurve.poseidonHash(BigInt(a), BigInt(b)));
5006
+ }
5007
+ function computePoseidonHashOnElements(data) {
5008
+ return toHex(poseidonHashMany2(data.map((x) => BigInt(x))));
5009
+ }
4987
5010
  function hashBuiltins(builtins) {
4988
- return poseidonHashMany2(
4989
- builtins.flatMap((it) => {
4990
- return BigInt(encodeShortString(it));
4991
- })
4992
- );
5011
+ return poseidonHashMany2(encodeBuiltins(builtins));
4993
5012
  }
4994
5013
  function hashEntryPoint(data) {
4995
5014
  const base = data.flatMap((it) => {
@@ -5007,8 +5026,7 @@ function hashByteCodeSegments(casm) {
5007
5026
  });
5008
5027
  return 1n + poseidonHashMany2(hashLeaves);
5009
5028
  }
5010
- function computeCompiledClassHash(casm) {
5011
- const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
5029
+ function computeCompiledClassHashPoseidon(casm) {
5012
5030
  const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
5013
5031
  const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
5014
5032
  const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
@@ -5053,6 +5071,161 @@ function computeSierraContractClassHash(sierra) {
5053
5071
  ])
5054
5072
  );
5055
5073
  }
5074
+
5075
+ // src/utils/connect/blake.ts
5076
+ import { blake2s } from "@noble/hashes/blake2s";
5077
+ function blakeHash(uint8Array) {
5078
+ return config.get("blake")?.(uint8Array) || blake2s(uint8Array, { dkLen: 32 });
5079
+ }
5080
+
5081
+ // src/utils/hash/classHash/blake.ts
5082
+ function blake2sHashMany(data) {
5083
+ const SMALL_THRESHOLD = 0x8000000000000000n;
5084
+ const BIG_MARKER = 2147483648;
5085
+ const u32Words = [];
5086
+ const buf = new ArrayBuffer(32);
5087
+ const feltView = new DataView(buf);
5088
+ for (const felt2 of data) {
5089
+ const u64_0 = felt2 & 0xffffffffffffffffn;
5090
+ const u64_1 = (felt2 & 0xffffffffffffffff0000000000000000n) >> 64n;
5091
+ const u64_2 = (felt2 & 0xffffffffffffffff00000000000000000000000000000000n) >> 128n;
5092
+ const u64_3 = (felt2 & 0xffffffffffffffff000000000000000000000000000000000000000000000000n) >> 192n;
5093
+ feltView.setBigUint64(0, u64_3, false);
5094
+ feltView.setBigUint64(8, u64_2, false);
5095
+ feltView.setBigUint64(16, u64_1, false);
5096
+ feltView.setBigUint64(24, u64_0, false);
5097
+ if (felt2 < SMALL_THRESHOLD) {
5098
+ const hi0 = feltView.getUint32(24, false);
5099
+ const lo0 = feltView.getUint32(28, false);
5100
+ u32Words.push(hi0, lo0);
5101
+ } else {
5102
+ const word0 = feltView.getUint32(0, false) | BIG_MARKER;
5103
+ const word1 = feltView.getUint32(4, false);
5104
+ const word2 = feltView.getUint32(8, false);
5105
+ const word3 = feltView.getUint32(12, false);
5106
+ const word4 = feltView.getUint32(16, false);
5107
+ const word5 = feltView.getUint32(20, false);
5108
+ const word6 = feltView.getUint32(24, false);
5109
+ const word7 = feltView.getUint32(28, false);
5110
+ u32Words.push(word0, word1, word2, word3, word4, word5, word6, word7);
5111
+ }
5112
+ }
5113
+ const bytes = new ArrayBuffer(u32Words.length * 4);
5114
+ const bytesView = new DataView(bytes);
5115
+ for (let i = 0; i < u32Words.length; i++) {
5116
+ bytesView.setUint32(i * 4, u32Words[i], true);
5117
+ }
5118
+ const hash = blakeHash(new Uint8Array(bytes));
5119
+ let hashBigInt = 0n;
5120
+ for (let i = 0; i < 32; i++) {
5121
+ hashBigInt |= BigInt(hash[i]) << BigInt(i * 8);
5122
+ }
5123
+ return hashBigInt % PRIME;
5124
+ }
5125
+ function hashBuiltinsBlake(builtins) {
5126
+ return blake2sHashMany(encodeBuiltins(builtins));
5127
+ }
5128
+ function hashEntryPointBlake(data) {
5129
+ const base = data.flatMap((it) => {
5130
+ return [BigInt(it.selector), BigInt(it.offset), hashBuiltinsBlake(it.builtins)];
5131
+ });
5132
+ return blake2sHashMany(base);
5133
+ }
5134
+ function bytecodeHashNodeBlake(iter, node) {
5135
+ if (typeof node === "number") {
5136
+ const data = [];
5137
+ for (let i = 0; i < node; i++) {
5138
+ const next = iter.next();
5139
+ if (next.done) throw new Error("Bytecode length mismatch");
5140
+ data.push(next.value);
5141
+ }
5142
+ return [node, blake2sHashMany(data)];
5143
+ }
5144
+ const innerNodes = node.map((child) => bytecodeHashNodeBlake(iter, child));
5145
+ const flatData = innerNodes.flatMap(([len, hash2]) => [BigInt(len), hash2]);
5146
+ const hash = blake2sHashMany(flatData) + 1n;
5147
+ const totalLen = innerNodes.reduce((sum, [len]) => sum + len, 0);
5148
+ return [totalLen, hash];
5149
+ }
5150
+ function hashByteCodeSegmentsBlake(casm) {
5151
+ const byteCode = casm.bytecode.map((n) => BigInt(n));
5152
+ const bytecodeSegmentLengths = casm.bytecode_segment_lengths;
5153
+ if (!bytecodeSegmentLengths) {
5154
+ return blake2sHashMany(byteCode);
5155
+ }
5156
+ const iter = byteCode[Symbol.iterator]();
5157
+ const [len, hash] = bytecodeHashNodeBlake(iter, bytecodeSegmentLengths);
5158
+ if (len !== byteCode.length) {
5159
+ throw new Error(`Bytecode length mismatch: expected ${byteCode.length}, got ${len}`);
5160
+ }
5161
+ return hash;
5162
+ }
5163
+ function computeCompiledClassHashBlake(casm) {
5164
+ const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
5165
+ const externalEntryPointsHash = hashEntryPointBlake(casm.entry_points_by_type.EXTERNAL);
5166
+ const l1Handlers = hashEntryPointBlake(casm.entry_points_by_type.L1_HANDLER);
5167
+ const constructor = hashEntryPointBlake(casm.entry_points_by_type.CONSTRUCTOR);
5168
+ const bytecode = hashByteCodeSegmentsBlake(casm);
5169
+ return toHex(
5170
+ blake2sHashMany([
5171
+ compiledClassVersion,
5172
+ externalEntryPointsHash,
5173
+ l1Handlers,
5174
+ constructor,
5175
+ bytecode
5176
+ ])
5177
+ );
5178
+ }
5179
+
5180
+ // src/utils/resolve.ts
5181
+ function isV3Tx(details) {
5182
+ const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5183
+ return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5184
+ }
5185
+ function isVersion(expected, provided) {
5186
+ const expectedParts = expected.split(".");
5187
+ const providedParts = provided.split(".");
5188
+ return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
5189
+ }
5190
+ function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
5191
+ return Object.values(_SupportedRpcVersion).some(
5192
+ (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
5193
+ );
5194
+ }
5195
+ function toAnyPatchVersion(version) {
5196
+ const parts = version.split(".");
5197
+ if (parts.length < 3) {
5198
+ return version;
5199
+ }
5200
+ return `${parts[0]}.${parts[1]}.*`;
5201
+ }
5202
+ function toApiVersion(version) {
5203
+ const [major, minor] = version.replace(/^v/, "").split(".");
5204
+ return `v${major}_${minor}`;
5205
+ }
5206
+ function compareVersions(a, b) {
5207
+ const aParts = a.split(".").map(Number);
5208
+ const bParts = b.split(".").map(Number);
5209
+ const maxLen = Math.max(aParts.length, bParts.length);
5210
+ for (let i = 0; i < maxLen; i += 1) {
5211
+ const aNum = aParts[i] || 0;
5212
+ const bNum = bParts[i] || 0;
5213
+ if (aNum > bNum) return 1;
5214
+ if (aNum < bNum) return -1;
5215
+ }
5216
+ return 0;
5217
+ }
5218
+ function isPendingBlock(response) {
5219
+ return response.status === "PENDING";
5220
+ }
5221
+ function isPendingTransaction(response) {
5222
+ return !("block_hash" in response);
5223
+ }
5224
+ function isPendingStateUpdate(response) {
5225
+ return !("block_hash" in response);
5226
+ }
5227
+
5228
+ // src/utils/hash/classHash/index.ts
5056
5229
  function computeContractClassHash(contract) {
5057
5230
  const compiledContract = isString(contract) ? parse2(contract) : contract;
5058
5231
  if ("sierra_program" in compiledContract) {
@@ -5060,6 +5233,12 @@ function computeContractClassHash(contract) {
5060
5233
  }
5061
5234
  return computeLegacyContractClassHash(compiledContract);
5062
5235
  }
5236
+ function computeCompiledClassHash(casm, specVersion) {
5237
+ if (specVersion && compareVersions(specVersion, "0.10.0") >= 0) {
5238
+ return computeCompiledClassHashBlake(casm);
5239
+ }
5240
+ return computeCompiledClassHashPoseidon(casm);
5241
+ }
5063
5242
 
5064
5243
  // src/utils/stark/index.ts
5065
5244
  var stark_exports = {};
@@ -5265,11 +5444,11 @@ function isSierra(contract) {
5265
5444
  const compiledContract = isString(contract) ? parse2(contract) : contract;
5266
5445
  return "sierra_program" in compiledContract;
5267
5446
  }
5268
- function extractContractHashes(payload) {
5447
+ function extractContractHashes(payload, specVersion) {
5269
5448
  const response = { ...payload };
5270
5449
  if (isSierra(payload.contract)) {
5271
5450
  if (!payload.compiledClassHash && payload.casm) {
5272
- response.compiledClassHash = computeCompiledClassHash(payload.casm);
5451
+ response.compiledClassHash = computeCompiledClassHash(payload.casm, specVersion);
5273
5452
  }
5274
5453
  if (!response.compiledClassHash)
5275
5454
  throw new Error(
@@ -5326,44 +5505,6 @@ __export(provider_exports, {
5326
5505
  validBlockTags: () => validBlockTags,
5327
5506
  wait: () => wait
5328
5507
  });
5329
-
5330
- // src/utils/resolve.ts
5331
- function isV3Tx(details) {
5332
- const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5333
- return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5334
- }
5335
- function isVersion(expected, provided) {
5336
- const expectedParts = expected.split(".");
5337
- const providedParts = provided.split(".");
5338
- return expectedParts.every((part, index) => part === "*" || part === providedParts[index]);
5339
- }
5340
- function isSupportedSpecVersion(version, options = { allowAnyPatchVersion: false }) {
5341
- return Object.values(_SupportedRpcVersion).some(
5342
- (v) => isVersion(options.allowAnyPatchVersion ? toAnyPatchVersion(v) : v, version)
5343
- );
5344
- }
5345
- function toAnyPatchVersion(version) {
5346
- const parts = version.split(".");
5347
- if (parts.length < 3) {
5348
- return version;
5349
- }
5350
- return `${parts[0]}.${parts[1]}.*`;
5351
- }
5352
- function toApiVersion(version) {
5353
- const [major, minor] = version.replace(/^v/, "").split(".");
5354
- return `v${major}_${minor}`;
5355
- }
5356
- function isPendingBlock(response) {
5357
- return response.status === "PENDING";
5358
- }
5359
- function isPendingTransaction(response) {
5360
- return !("block_hash" in response);
5361
- }
5362
- function isPendingStateUpdate(response) {
5363
- return !("block_hash" in response);
5364
- }
5365
-
5366
- // src/utils/provider.ts
5367
5508
  function wait(delay) {
5368
5509
  return new Promise((res) => {
5369
5510
  setTimeout(res, delay);
@@ -8537,7 +8678,10 @@ var RpcProvider = class {
8537
8678
  async isClassDeclared(contractClassIdentifier, blockIdentifier) {
8538
8679
  let classHash;
8539
8680
  if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
8540
- const hashes = extractContractHashes(contractClassIdentifier);
8681
+ const hashes = extractContractHashes(
8682
+ contractClassIdentifier,
8683
+ await this.channel.setUpSpecVersion()
8684
+ );
8541
8685
  classHash = hashes.classHash;
8542
8686
  } else if (contractClassIdentifier.classHash) {
8543
8687
  classHash = contractClassIdentifier.classHash;
@@ -10808,7 +10952,7 @@ var Deployer = class {
10808
10952
  throw new Error("Deployer emitted event is empty");
10809
10953
  }
10810
10954
  const event = txReceipt.events.find(
10811
- (it) => cleanHex(it.from_address) === cleanHex(toHex(this.address))
10955
+ (it) => toHex(it.from_address) === toHex(this.address)
10812
10956
  ) || {
10813
10957
  data: []
10814
10958
  };
@@ -10908,7 +11052,10 @@ var Account = class extends RpcProvider2 {
10908
11052
  "Declare fee estimation is not supported for Cairo0 contracts"
10909
11053
  );
10910
11054
  const invocations = [
10911
- { type: api_exports.ETransactionType.DECLARE, payload: extractContractHashes(payload) }
11055
+ {
11056
+ type: api_exports.ETransactionType.DECLARE,
11057
+ payload: extractContractHashes(payload, await this.channel.setUpSpecVersion())
11058
+ }
10912
11059
  ];
10913
11060
  const estimateBulk = await this.estimateFeeBulk(invocations, details);
10914
11061
  return estimateBulk[0];
@@ -11071,7 +11218,10 @@ var Account = class extends RpcProvider2 {
11071
11218
  * @param transactionsDetail (optional)
11072
11219
  */
11073
11220
  async declareIfNot(payload, transactionsDetail = {}) {
11074
- const declareContractPayload = extractContractHashes(payload);
11221
+ const declareContractPayload = extractContractHashes(
11222
+ payload,
11223
+ await this.channel.setUpSpecVersion()
11224
+ );
11075
11225
  try {
11076
11226
  await this.getClassByHash(declareContractPayload.classHash);
11077
11227
  } catch (error) {
@@ -11084,7 +11234,10 @@ var Account = class extends RpcProvider2 {
11084
11234
  }
11085
11235
  async declare(payload, details = {}) {
11086
11236
  assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
11087
- const declareContractPayload = extractContractHashes(payload);
11237
+ const declareContractPayload = extractContractHashes(
11238
+ payload,
11239
+ await this.channel.setUpSpecVersion()
11240
+ );
11088
11241
  const detailsWithTip = await this.resolveDetailsWithTip(details);
11089
11242
  const { resourceBounds: providedResourceBounds } = details;
11090
11243
  let resourceBounds = providedResourceBounds;
@@ -11391,7 +11544,10 @@ var Account = class extends RpcProvider2 {
11391
11544
  };
11392
11545
  }
11393
11546
  async buildDeclarePayload(payload, details) {
11394
- const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
11547
+ const { classHash, contract, compiledClassHash } = extractContractHashes(
11548
+ payload,
11549
+ await this.channel.setUpSpecVersion()
11550
+ );
11395
11551
  const compressedCompiledContract = parseContract(contract);
11396
11552
  assert(
11397
11553
  !isUndefined(compiledClassHash) && (details.version === ETransactionVersion3.F3 || details.version === ETransactionVersion3.V3),
@@ -11737,8 +11893,11 @@ var WalletAccount = class _WalletAccount extends Account {
11737
11893
  };
11738
11894
  return addInvokeTransaction(this.walletProvider, params);
11739
11895
  }
11740
- declare(payload) {
11741
- const declareContractPayload = extractContractHashes(payload);
11896
+ async declare(payload) {
11897
+ const declareContractPayload = extractContractHashes(
11898
+ payload,
11899
+ await this.channel.setUpSpecVersion()
11900
+ );
11742
11901
  const pContract = payload.contract;
11743
11902
  const cairo1Contract = {
11744
11903
  ...pContract,
@@ -12155,7 +12314,7 @@ var Contract = class _Contract {
12155
12314
  transaction_hash: txR.transaction_hash,
12156
12315
  ...event
12157
12316
  };
12158
- }).filter((event) => cleanHex(event.from_address) === cleanHex(this.address), []) || [];
12317
+ }).filter((event) => toHex(event.from_address) === toHex(this.address), []) || [];
12159
12318
  parsed = parseEvents(
12160
12319
  emittedEvents,
12161
12320
  this.events,
@@ -12450,6 +12609,7 @@ export {
12450
12609
  addAddressPadding,
12451
12610
  byteArray_exports as byteArray,
12452
12611
  cairo_exports as cairo,
12612
+ compareVersions,
12453
12613
  config,
12454
12614
  constants_exports as constants,
12455
12615
  contractClassResponseToLegacyCompiledContract,