starknet 8.7.0 → 8.8.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/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [8.8.0](https://github.com/starknet-io/starknet.js/compare/v8.7.0...v8.8.0) (2025-11-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ - both sepolia and mainet on alchemy ([f119081](https://github.com/starknet-io/starknet.js/commit/f1190815ba032a0b4094e6c16c3b6cd4cca216e1))
6
+ - public node hotfix ([d35e39e](https://github.com/starknet-io/starknet.js/commit/d35e39eb600a30b46146630ec0bbc916db65d976))
7
+
8
+ ### Features
9
+
10
+ - starknet version, use starknt version to determin declare hash instead of spec version ([70a23ee](https://github.com/starknet-io/starknet.js/commit/70a23ee4f14d5f7a0d754bfcfc3312cd5585b951))
11
+
1
12
  # [8.7.0](https://github.com/starknet-io/starknet.js/compare/v8.6.0...v8.7.0) (2025-11-07)
2
13
 
3
14
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -4022,6 +4022,11 @@ declare class RpcChannel$1 {
4022
4022
  blockIdentifier?: BlockIdentifier): Promise<RPCSPEC08.StorageProof>;
4023
4023
  getCompiledCasm(classHash: BigNumberish): Promise<RPCSPEC08.CASM_COMPILED_CONTRACT_CLASS>;
4024
4024
  getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
4025
+ /**
4026
+ * Helper method to get the starknet version from the block, default latest block
4027
+ * @returns Starknet version
4028
+ */
4029
+ getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
4025
4030
  /**
4026
4031
  * Get the most recent accepted block hash and number
4027
4032
  */
@@ -4165,6 +4170,11 @@ declare class RpcChannel {
4165
4170
  blockIdentifier?: BlockIdentifier): Promise<RPC.StorageProof>;
4166
4171
  getCompiledCasm(classHash: BigNumberish): Promise<RPC.CASM_COMPILED_CONTRACT_CLASS>;
4167
4172
  getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
4173
+ /**
4174
+ * Helper method to get the starknet version from the block, default latest block
4175
+ * @returns Starknet version
4176
+ */
4177
+ getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
4168
4178
  /**
4169
4179
  * Get the most recent accepted block hash and number
4170
4180
  */
@@ -4708,6 +4718,7 @@ declare class RpcProvider$1 implements ProviderInterface {
4708
4718
  readSpecVersion(): "0.8.1" | "0.9.0" | undefined;
4709
4719
  getSpecVersion(): Promise<string>;
4710
4720
  setUpSpecVersion(): Promise<"0.8.1" | "0.9.0">;
4721
+ getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
4711
4722
  getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
4712
4723
  getBlock(): Promise<PendingBlock>;
4713
4724
  getBlock(blockIdentifier: 'pre_confirmed'): Promise<PendingBlock>;
@@ -5983,7 +5994,7 @@ declare function computeCompiledClassHash(casm: CompiledSierraCasm,
5983
5994
  /**
5984
5995
  * Used to determine which hashing algorithm to use
5985
5996
  */
5986
- specVersion?: _SupportedRpcVersion): string;
5997
+ starknetVersion?: string): string;
5987
5998
 
5988
5999
  /**
5989
6000
  * Hashes Exports
@@ -9285,7 +9296,7 @@ declare function isSierra(contract: CairoContract | string): contract is SierraC
9285
9296
  * // }
9286
9297
  * ```
9287
9298
  */
9288
- declare function extractContractHashes(payload: DeclareContractPayload, specVersion?: _SupportedRpcVersion): CompleteDeclareContractPayload;
9299
+ declare function extractContractHashes(payload: DeclareContractPayload, starknetVersion?: string): CompleteDeclareContractPayload;
9289
9300
  /**
9290
9301
  * Helper to redeclare response Cairo0 contract
9291
9302
  */
@@ -9938,8 +9938,8 @@ ${indent}}` : "}";
9938
9938
  }
9939
9939
  return computeLegacyContractClassHash(compiledContract);
9940
9940
  }
9941
- function computeCompiledClassHash(casm, specVersion) {
9942
- if (specVersion && compareVersions(specVersion, "0.10.0") >= 0) {
9941
+ function computeCompiledClassHash(casm, starknetVersion) {
9942
+ if (starknetVersion && compareVersions(starknetVersion, "0.14.1") >= 0) {
9943
9943
  return computeCompiledClassHashBlake(casm);
9944
9944
  }
9945
9945
  return computeCompiledClassHashPoseidon(casm);
@@ -14324,11 +14324,11 @@ ${indent}}` : "}";
14324
14324
  const compiledContract = isString(contract) ? parse2(contract) : contract;
14325
14325
  return "sierra_program" in compiledContract;
14326
14326
  }
14327
- function extractContractHashes(payload, specVersion) {
14327
+ function extractContractHashes(payload, starknetVersion) {
14328
14328
  const response = { ...payload };
14329
14329
  if (isSierra(payload.contract)) {
14330
14330
  if (!payload.compiledClassHash && payload.casm) {
14331
- response.compiledClassHash = computeCompiledClassHash(payload.casm, specVersion);
14331
+ response.compiledClassHash = computeCompiledClassHash(payload.casm, starknetVersion);
14332
14332
  }
14333
14333
  if (!response.compiledClassHash)
14334
14334
  throw new Error(
@@ -15133,6 +15133,14 @@ ${indent}}` : "}";
15133
15133
  block_id
15134
15134
  });
15135
15135
  }
15136
+ /**
15137
+ * Helper method to get the starknet version from the block, default latest block
15138
+ * @returns Starknet version
15139
+ */
15140
+ async getStarknetVersion(blockIdentifier = this.blockIdentifier) {
15141
+ const block = await this.getBlockWithTxHashes(blockIdentifier);
15142
+ return block.starknet_version;
15143
+ }
15136
15144
  /**
15137
15145
  * Get the most recent accepted block hash and number
15138
15146
  */
@@ -15722,6 +15730,14 @@ ${indent}}` : "}";
15722
15730
  block_id
15723
15731
  });
15724
15732
  }
15733
+ /**
15734
+ * Helper method to get the starknet version from the block, default latest block
15735
+ * @returns Starknet version
15736
+ */
15737
+ async getStarknetVersion(blockIdentifier = this.blockIdentifier) {
15738
+ const block = await this.getBlockWithTxHashes(blockIdentifier);
15739
+ return block.starknet_version;
15740
+ }
15725
15741
  /**
15726
15742
  * Get the most recent accepted block hash and number
15727
15743
  */
@@ -17661,6 +17677,9 @@ ${indent}}` : "}";
17661
17677
  setUpSpecVersion() {
17662
17678
  return this.channel.setUpSpecVersion();
17663
17679
  }
17680
+ async getStarknetVersion(blockIdentifier) {
17681
+ return this.channel.getStarknetVersion(blockIdentifier);
17682
+ }
17664
17683
  async getNonceForAddress(contractAddress, blockIdentifier) {
17665
17684
  return this.channel.getNonceForAddress(contractAddress, blockIdentifier);
17666
17685
  }
@@ -17900,7 +17919,7 @@ ${indent}}` : "}";
17900
17919
  if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
17901
17920
  const hashes = extractContractHashes(
17902
17921
  contractClassIdentifier,
17903
- await this.channel.setUpSpecVersion()
17922
+ await this.channel.getStarknetVersion()
17904
17923
  );
17905
17924
  classHash = hashes.classHash;
17906
17925
  } else if (contractClassIdentifier.classHash) {
@@ -20491,7 +20510,7 @@ ${indent}}` : "}";
20491
20510
  const invocations = [
20492
20511
  {
20493
20512
  type: ETransactionType2.DECLARE,
20494
- payload: extractContractHashes(payload, await this.channel.setUpSpecVersion())
20513
+ payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
20495
20514
  }
20496
20515
  ];
20497
20516
  const estimateBulk = await this.estimateFeeBulk(invocations, details);
@@ -20657,7 +20676,7 @@ ${indent}}` : "}";
20657
20676
  async declareIfNot(payload, transactionsDetail = {}) {
20658
20677
  const declareContractPayload = extractContractHashes(
20659
20678
  payload,
20660
- await this.channel.setUpSpecVersion()
20679
+ await this.channel.getStarknetVersion()
20661
20680
  );
20662
20681
  try {
20663
20682
  await this.getClassByHash(declareContractPayload.classHash);
@@ -20673,7 +20692,7 @@ ${indent}}` : "}";
20673
20692
  assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
20674
20693
  const declareContractPayload = extractContractHashes(
20675
20694
  payload,
20676
- await this.channel.setUpSpecVersion()
20695
+ await this.channel.getStarknetVersion()
20677
20696
  );
20678
20697
  const detailsWithTip = await this.resolveDetailsWithTip(details);
20679
20698
  const { resourceBounds: providedResourceBounds } = details;
@@ -20983,7 +21002,7 @@ ${indent}}` : "}";
20983
21002
  async buildDeclarePayload(payload, details) {
20984
21003
  const { classHash, contract, compiledClassHash } = extractContractHashes(
20985
21004
  payload,
20986
- await this.channel.setUpSpecVersion()
21005
+ await this.channel.getStarknetVersion()
20987
21006
  );
20988
21007
  const compressedCompiledContract = parseContract(contract);
20989
21008
  assert(
@@ -21333,7 +21352,7 @@ ${indent}}` : "}";
21333
21352
  async declare(payload) {
21334
21353
  const declareContractPayload = extractContractHashes(
21335
21354
  payload,
21336
- await this.channel.setUpSpecVersion()
21355
+ await this.channel.getStarknetVersion()
21337
21356
  );
21338
21357
  const pContract = payload.contract;
21339
21358
  const cairo1Contract = {