starknet 11.9.1 → 11.9.2

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,9 @@
1
+ ## [11.9.2](https://github.com/starknet-io/starknet.js/compare/v11.9.1...v11.9.2) (2026-11-25)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **provider:** read the compiler version in the Sierra program in getContractVersion ([f0b3d7a](https://github.com/starknet-io/starknet.js/commit/f0b3d7a93b4af1920cb10d6b70b670610c7f2c6c))
6
+
1
7
  ## [11.9.1](https://github.com/starknet-io/starknet.js/compare/v11.9.0...v11.9.1) (2026-11-24)
2
8
 
3
9
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -925,7 +925,12 @@ type getEstimateFeeBulkOptions = {
925
925
  type ContractVersion = {
926
926
  /** version of the cairo language */
927
927
  cairo: CairoVersion;
928
- /** version of the cairo compiler used to compile the contract */
928
+ /**
929
+ * Major version of the Cairo compiler used to compile the contract ('0' for Cairo 0).
930
+ * `undefined` when unknown: for example with the option `compiler: false` of
931
+ * `getContractVersion`, or for a compiler that this version of starknet.js does not know yet,
932
+ * such as a future 3.x.
933
+ */
929
934
  compiler: CompilerVersion;
930
935
  };
931
936
 
@@ -1324,7 +1329,8 @@ declare abstract class ProviderInterface {
1324
1329
  * @param contractAddress string
1325
1330
  * @param classHash undefined
1326
1331
  * @param options - getContractVersionOptions
1327
- * - (optional) compiler - (default true) extract compiler version using type tactic from abi
1332
+ * - (optional) compiler - (default true) read the major version of the compiler in the Sierra
1333
+ * program (undefined when unknown, for example a compiler newer than 2.x)
1328
1334
  * - (optional) blockIdentifier - block identifier
1329
1335
  */
1330
1336
  abstract getContractVersion(contractAddress: BigNumberish, classHash?: undefined, options?: getContractVersionOptions): Promise<ContractVersion>;
@@ -1333,7 +1339,8 @@ declare abstract class ProviderInterface {
1333
1339
  * @param contractAddress undefined
1334
1340
  * @param classHash
1335
1341
  * @param options - getContractVersionOptions
1336
- * - (optional) compiler - (default true) extract compiler version using type tactic from abi
1342
+ * - (optional) compiler - (default true) read the major version of the compiler in the Sierra
1343
+ * program (undefined when unknown, for example a compiler newer than 2.x)
1337
1344
  * - (optional) blockIdentifier - block identifier
1338
1345
  */
1339
1346
  abstract getContractVersion(contractAddress: undefined, classHash: BigNumberish, options?: getContractVersionOptions): Promise<ContractVersion>;
@@ -10872,10 +10879,21 @@ declare function isCairo1Abi(abi: Abi): boolean;
10872
10879
  */
10873
10880
  declare function isTypeNonZero(type: string): boolean;
10874
10881
  /**
10875
- * Return ContractVersion (Abi version) based on Abi
10876
- * or undefined for unknown version
10877
- * @param abi
10878
- * @returns string
10882
+ * Guess the Cairo version and the compiler version of a contract from the shape of its abi.
10883
+ *
10884
+ * The compiler version is only a guess: '2' when the abi has an `interface` entry, '1' for
10885
+ * another Cairo 1 abi. The guess is wrong for a contract compiled by Cairo 2 that has no
10886
+ * `interface` entry (no external function, or functions declared one by one with
10887
+ * `#[external(v0)]`): the answer is '1'.
10888
+ * For a declared class, `provider.getContractVersion` gives the real compiler version: it reads
10889
+ * it in the Sierra program.
10890
+ * @param abi the abi of the contract
10891
+ * @returns the versions; `undefined` when the abi does not tell
10892
+ * @example
10893
+ * ```typescript
10894
+ * const version = cairo.getAbiContractVersion(myAbi);
10895
+ * // version = { cairo: '1', compiler: '2' }
10896
+ * ```
10879
10897
  */
10880
10898
  declare function getAbiContractVersion(abi: Abi): ContractVersion;
10881
10899
  /**
@@ -23869,8 +23869,15 @@ ${indent}}` : "}";
23869
23869
  }
23870
23870
  if (isSierra(contractClass)) {
23871
23871
  if (compiler) {
23872
- const abiTest = getAbiContractVersion(contractClass.abi);
23873
- return { cairo: "1", compiler: abiTest.compiler };
23872
+ try {
23873
+ const program = contractClass.sierra_program;
23874
+ const firstFelt = BigInt(program[0]);
23875
+ if (firstFelt === utf8ToBigInt("0.1.0")) return { cairo: "1", compiler: "1" };
23876
+ const compilerMajor = BigInt(program[3]);
23877
+ if (firstFelt === 1n && compilerMajor === 1n) return { cairo: "1", compiler: "1" };
23878
+ if (firstFelt === 1n && compilerMajor === 2n) return { cairo: "1", compiler: "2" };
23879
+ } catch {
23880
+ }
23874
23881
  }
23875
23882
  return { cairo: "1", compiler: void 0 };
23876
23883
  }