starknet 8.6.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,24 @@
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
+
12
+ # [8.7.0](https://github.com/starknet-io/starknet.js/compare/v8.6.0...v8.7.0) (2025-11-07)
13
+
14
+ ### Bug Fixes
15
+
16
+ - public node hotfix ([#1510](https://github.com/starknet-io/starknet.js/issues/1510)) ([4165a3c](https://github.com/starknet-io/starknet.js/commit/4165a3c74c94053b60ed2aca12d8bebab5b72f68))
17
+
18
+ ### Features
19
+
20
+ - configurable websocket exponential backoff ([#1503](https://github.com/starknet-io/starknet.js/issues/1503)) ([6d0593f](https://github.com/starknet-io/starknet.js/commit/6d0593f2fcdf6da79fb0aaccef42071a8c0e8126))
21
+
1
22
  # [8.6.0](https://github.com/starknet-io/starknet.js/compare/v8.5.5...v8.6.0) (2025-10-17)
2
23
 
3
24
  ### Features
package/dist/index.d.ts CHANGED
@@ -3917,8 +3917,8 @@ declare const DEFAULT_GLOBAL_CONFIG: {
3917
3917
  blake: ((uint8Array: Uint8Array) => Uint8Array) | undefined;
3918
3918
  };
3919
3919
  declare const RPC_DEFAULT_NODES: {
3920
- readonly SN_MAIN: readonly ["https://starknet-mainnet.public.blastapi.io/rpc/"];
3921
- readonly SN_SEPOLIA: readonly ["https://starknet-sepolia.public.blastapi.io/rpc/"];
3920
+ readonly SN_MAIN: readonly ["https://starknet-mainnet.g.alchemy.com/starknet/version/rpc"];
3921
+ readonly SN_SEPOLIA: readonly ["https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/"];
3922
3922
  };
3923
3923
  declare const PAYMASTER_RPC_NODES: {
3924
3924
  readonly SN_MAIN: readonly ["https://starknet.paymaster.avnu.fi"];
@@ -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
  */
@@ -4406,10 +4416,14 @@ type ReconnectOptions = {
4406
4416
  retries?: number;
4407
4417
  /**
4408
4418
  * The initial delay in milliseconds before the first retry.
4409
- * This delay will be doubled for each subsequent retry (exponential backoff).
4410
4419
  * @default 2000
4411
4420
  */
4412
4421
  delay?: number;
4422
+ /**
4423
+ * Whether to use the exponential backoff (delay being doubled for each subsequent retry).
4424
+ * @default true
4425
+ */
4426
+ exponential?: number | boolean;
4413
4427
  };
4414
4428
  /**
4415
4429
  * The type of the WebSocket implementation.
@@ -4704,6 +4718,7 @@ declare class RpcProvider$1 implements ProviderInterface {
4704
4718
  readSpecVersion(): "0.8.1" | "0.9.0" | undefined;
4705
4719
  getSpecVersion(): Promise<string>;
4706
4720
  setUpSpecVersion(): Promise<"0.8.1" | "0.9.0">;
4721
+ getStarknetVersion(blockIdentifier?: BlockIdentifier): Promise<string>;
4707
4722
  getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
4708
4723
  getBlock(): Promise<PendingBlock>;
4709
4724
  getBlock(blockIdentifier: 'pre_confirmed'): Promise<PendingBlock>;
@@ -5979,7 +5994,7 @@ declare function computeCompiledClassHash(casm: CompiledSierraCasm,
5979
5994
  /**
5980
5995
  * Used to determine which hashing algorithm to use
5981
5996
  */
5982
- specVersion?: _SupportedRpcVersion): string;
5997
+ starknetVersion?: string): string;
5983
5998
 
5984
5999
  /**
5985
6000
  * Hashes Exports
@@ -9281,7 +9296,7 @@ declare function isSierra(contract: CairoContract | string): contract is SierraC
9281
9296
  * // }
9282
9297
  * ```
9283
9298
  */
9284
- declare function extractContractHashes(payload: DeclareContractPayload, specVersion?: _SupportedRpcVersion): CompleteDeclareContractPayload;
9299
+ declare function extractContractHashes(payload: DeclareContractPayload, starknetVersion?: string): CompleteDeclareContractPayload;
9285
9300
  /**
9286
9301
  * Helper to redeclare response Cairo0 contract
9287
9302
  */
@@ -1179,8 +1179,8 @@ var starknet = (() => {
1179
1179
  blake: void 0
1180
1180
  };
1181
1181
  var RPC_DEFAULT_NODES = {
1182
- SN_MAIN: [`https://starknet-mainnet.public.blastapi.io/rpc/`],
1183
- SN_SEPOLIA: [`https://starknet-sepolia.public.blastapi.io/rpc/`]
1182
+ SN_MAIN: [`https://starknet-mainnet.g.alchemy.com/starknet/version/rpc`],
1183
+ SN_SEPOLIA: [`https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/`]
1184
1184
  };
1185
1185
  var PAYMASTER_RPC_NODES = {
1186
1186
  SN_MAIN: [`https://starknet.paymaster.avnu.fi`],
@@ -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(
@@ -14757,6 +14757,12 @@ ${indent}}` : "}";
14757
14757
  const nodes = { ...RPC_DEFAULT_NODES };
14758
14758
  Object.keys(nodes).forEach(function(key, _) {
14759
14759
  nodes[key] = nodes[key].map((it) => {
14760
+ if (it === "https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/") {
14761
+ return `${it}${toApiVersion(rpcVersion)}/uYLxCteYbHTFJpKSoKdVm`;
14762
+ }
14763
+ if (it === "https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/") {
14764
+ return `${it}${toApiVersion(rpcVersion)}/uYLxCteYbHTFJpKSoKdVm`;
14765
+ }
14760
14766
  return `${it}${toApiVersion(rpcVersion)}`;
14761
14767
  });
14762
14768
  });
@@ -15127,6 +15133,14 @@ ${indent}}` : "}";
15127
15133
  block_id
15128
15134
  });
15129
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
+ }
15130
15144
  /**
15131
15145
  * Get the most recent accepted block hash and number
15132
15146
  */
@@ -15716,6 +15730,14 @@ ${indent}}` : "}";
15716
15730
  block_id
15717
15731
  });
15718
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
+ }
15719
15741
  /**
15720
15742
  * Get the most recent accepted block hash and number
15721
15743
  */
@@ -16283,7 +16305,8 @@ ${indent}}` : "}";
16283
16305
  this.autoReconnect = options.autoReconnect ?? true;
16284
16306
  this.reconnectOptions = {
16285
16307
  retries: options.reconnectOptions?.retries ?? 5,
16286
- delay: options.reconnectOptions?.delay ?? 2e3
16308
+ delay: options.reconnectOptions?.delay ?? 2e3,
16309
+ exponential: options.reconnectOptions?.exponential ?? true
16287
16310
  };
16288
16311
  this.requestTimeout = options.requestTimeout ?? 6e4;
16289
16312
  this.WsImplementation = options.websocket || config.get("websocket") || ws_default;
@@ -16544,7 +16567,7 @@ ${indent}}` : "}";
16544
16567
  this.events.emit("open", new Event("open"));
16545
16568
  };
16546
16569
  this.websocket.onerror = () => {
16547
- const delay = this.reconnectOptions.delay * 2 ** (this.reconnectAttempts - 1);
16570
+ const delay = this.reconnectOptions.exponential ? this.reconnectOptions.delay * 2 ** (this.reconnectAttempts - 1) : this.reconnectOptions.delay;
16548
16571
  logger.info(`WebSocket: Reconnect attempt failed. Retrying in ${delay}ms.`);
16549
16572
  this.reconnectTimeoutId = setTimeout(tryReconnect, delay);
16550
16573
  };
@@ -17654,6 +17677,9 @@ ${indent}}` : "}";
17654
17677
  setUpSpecVersion() {
17655
17678
  return this.channel.setUpSpecVersion();
17656
17679
  }
17680
+ async getStarknetVersion(blockIdentifier) {
17681
+ return this.channel.getStarknetVersion(blockIdentifier);
17682
+ }
17657
17683
  async getNonceForAddress(contractAddress, blockIdentifier) {
17658
17684
  return this.channel.getNonceForAddress(contractAddress, blockIdentifier);
17659
17685
  }
@@ -17893,7 +17919,7 @@ ${indent}}` : "}";
17893
17919
  if (!contractClassIdentifier.classHash && "contract" in contractClassIdentifier) {
17894
17920
  const hashes = extractContractHashes(
17895
17921
  contractClassIdentifier,
17896
- await this.channel.setUpSpecVersion()
17922
+ await this.channel.getStarknetVersion()
17897
17923
  );
17898
17924
  classHash = hashes.classHash;
17899
17925
  } else if (contractClassIdentifier.classHash) {
@@ -20484,7 +20510,7 @@ ${indent}}` : "}";
20484
20510
  const invocations = [
20485
20511
  {
20486
20512
  type: ETransactionType2.DECLARE,
20487
- payload: extractContractHashes(payload, await this.channel.setUpSpecVersion())
20513
+ payload: extractContractHashes(payload, await this.channel.getStarknetVersion())
20488
20514
  }
20489
20515
  ];
20490
20516
  const estimateBulk = await this.estimateFeeBulk(invocations, details);
@@ -20650,7 +20676,7 @@ ${indent}}` : "}";
20650
20676
  async declareIfNot(payload, transactionsDetail = {}) {
20651
20677
  const declareContractPayload = extractContractHashes(
20652
20678
  payload,
20653
- await this.channel.setUpSpecVersion()
20679
+ await this.channel.getStarknetVersion()
20654
20680
  );
20655
20681
  try {
20656
20682
  await this.getClassByHash(declareContractPayload.classHash);
@@ -20666,7 +20692,7 @@ ${indent}}` : "}";
20666
20692
  assert(isSierra(payload.contract), SYSTEM_MESSAGES.declareNonSierra);
20667
20693
  const declareContractPayload = extractContractHashes(
20668
20694
  payload,
20669
- await this.channel.setUpSpecVersion()
20695
+ await this.channel.getStarknetVersion()
20670
20696
  );
20671
20697
  const detailsWithTip = await this.resolveDetailsWithTip(details);
20672
20698
  const { resourceBounds: providedResourceBounds } = details;
@@ -20976,7 +21002,7 @@ ${indent}}` : "}";
20976
21002
  async buildDeclarePayload(payload, details) {
20977
21003
  const { classHash, contract, compiledClassHash } = extractContractHashes(
20978
21004
  payload,
20979
- await this.channel.setUpSpecVersion()
21005
+ await this.channel.getStarknetVersion()
20980
21006
  );
20981
21007
  const compressedCompiledContract = parseContract(contract);
20982
21008
  assert(
@@ -21326,7 +21352,7 @@ ${indent}}` : "}";
21326
21352
  async declare(payload) {
21327
21353
  const declareContractPayload = extractContractHashes(
21328
21354
  payload,
21329
- await this.channel.setUpSpecVersion()
21355
+ await this.channel.getStarknetVersion()
21330
21356
  );
21331
21357
  const pContract = payload.contract;
21332
21358
  const cairo1Contract = {