starknet 11.9.1 → 11.9.3
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 +12 -0
- package/dist/index.d.ts +28 -7
- package/dist/index.global.js +19 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [11.9.3](https://github.com/starknet-io/starknet.js/compare/v11.9.2...v11.9.3) (2026-11-26)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- toHex() refuses a negative value instead of returning 0x-5 ([#1767](https://github.com/starknet-io/starknet.js/issues/1767)) ([e2036f1](https://github.com/starknet-io/starknet.js/commit/e2036f13326f140b4cb78aede5d10361a0cff8de))
|
|
6
|
+
|
|
7
|
+
## [11.9.2](https://github.com/starknet-io/starknet.js/compare/v11.9.1...v11.9.2) (2026-11-25)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **provider:** read the compiler version in the Sierra program in getContractVersion ([f0b3d7a](https://github.com/starknet-io/starknet.js/commit/f0b3d7a93b4af1920cb10d6b70b670610c7f2c6c))
|
|
12
|
+
|
|
1
13
|
## [11.9.1](https://github.com/starknet-io/starknet.js/compare/v11.9.0...v11.9.1) (2026-11-24)
|
|
2
14
|
|
|
3
15
|
### 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
|
-
/**
|
|
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)
|
|
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)
|
|
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
|
-
*
|
|
10876
|
-
*
|
|
10877
|
-
*
|
|
10878
|
-
*
|
|
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
|
/**
|
|
@@ -12265,13 +12283,16 @@ declare function tryToBigInt(value: BigNumberish | undefined): bigint | undefine
|
|
|
12265
12283
|
/**
|
|
12266
12284
|
* Convert BigNumberish to hex-string
|
|
12267
12285
|
*
|
|
12286
|
+
* A negative value is refused: a hex-string has no sign, and `'0x-5'` is not one.
|
|
12268
12287
|
* @param {BigNumberish} value value to convert
|
|
12269
12288
|
* @returns {string} converted number in hex-string format
|
|
12289
|
+
* @throws {Error} when the value is negative, or cannot be read by {@link toBigInt}
|
|
12270
12290
|
* @example
|
|
12271
12291
|
* ```typescript
|
|
12272
12292
|
* toHex(100); // '0x64'
|
|
12273
12293
|
* toHex('200'); // '0xc8'
|
|
12274
12294
|
* toHex('0x00023AB'); // '0x23ab'
|
|
12295
|
+
* toHex(-5); // throws Error('Invalid input: -5 is negative, a hex-string cannot hold a sign')
|
|
12275
12296
|
* ```
|
|
12276
12297
|
*/
|
|
12277
12298
|
declare function toHex(value: BigNumberish): string;
|
package/dist/index.global.js
CHANGED
|
@@ -3089,17 +3089,21 @@ ${indent}}` : "}";
|
|
|
3089
3089
|
return value ? BigInt(value) : void 0;
|
|
3090
3090
|
}
|
|
3091
3091
|
function toHex(value) {
|
|
3092
|
-
|
|
3092
|
+
const bn = toBigInt(value);
|
|
3093
|
+
if (bn < 0n) {
|
|
3094
|
+
throw new Error(`Invalid input: ${bn} is negative, a hex-string cannot hold a sign`);
|
|
3095
|
+
}
|
|
3096
|
+
return addHexPrefix(bn.toString(16));
|
|
3093
3097
|
}
|
|
3094
3098
|
var toHexString = toHex;
|
|
3095
3099
|
function cleanHex(hex) {
|
|
3096
3100
|
return toHex(hex);
|
|
3097
3101
|
}
|
|
3098
3102
|
function toStorageKey(number) {
|
|
3099
|
-
return addHexPrefix(
|
|
3103
|
+
return addHexPrefix(removeHexPrefix(toHex(number)).padStart(64, "0"));
|
|
3100
3104
|
}
|
|
3101
3105
|
function toHex64(number) {
|
|
3102
|
-
const res = addHexPrefix(
|
|
3106
|
+
const res = addHexPrefix(removeHexPrefix(toHex(number)).padStart(64, "0"));
|
|
3103
3107
|
if (res.length !== 66) throw TypeError("number is too big for hex 0x(64) representation");
|
|
3104
3108
|
return res;
|
|
3105
3109
|
}
|
|
@@ -21779,14 +21783,16 @@ ${indent}}` : "}";
|
|
|
21779
21783
|
return void 0;
|
|
21780
21784
|
}
|
|
21781
21785
|
function getHex(value) {
|
|
21786
|
+
let bn;
|
|
21782
21787
|
try {
|
|
21783
|
-
|
|
21788
|
+
bn = toBigInt(value);
|
|
21784
21789
|
} catch (e) {
|
|
21785
21790
|
if (isString(value)) {
|
|
21786
21791
|
return toHex(CairoBytes31.fromText(value).toBigInt());
|
|
21787
21792
|
}
|
|
21788
21793
|
throw new Error(`Invalid BigNumberish: ${value}`);
|
|
21789
21794
|
}
|
|
21795
|
+
return toHex(bn);
|
|
21790
21796
|
}
|
|
21791
21797
|
function validateTypedData(data) {
|
|
21792
21798
|
const typedData = data;
|
|
@@ -23869,8 +23875,15 @@ ${indent}}` : "}";
|
|
|
23869
23875
|
}
|
|
23870
23876
|
if (isSierra(contractClass)) {
|
|
23871
23877
|
if (compiler) {
|
|
23872
|
-
|
|
23873
|
-
|
|
23878
|
+
try {
|
|
23879
|
+
const program = contractClass.sierra_program;
|
|
23880
|
+
const firstFelt = BigInt(program[0]);
|
|
23881
|
+
if (firstFelt === utf8ToBigInt("0.1.0")) return { cairo: "1", compiler: "1" };
|
|
23882
|
+
const compilerMajor = BigInt(program[3]);
|
|
23883
|
+
if (firstFelt === 1n && compilerMajor === 1n) return { cairo: "1", compiler: "1" };
|
|
23884
|
+
if (firstFelt === 1n && compilerMajor === 2n) return { cairo: "1", compiler: "2" };
|
|
23885
|
+
} catch {
|
|
23886
|
+
}
|
|
23874
23887
|
}
|
|
23875
23888
|
return { cairo: "1", compiler: void 0 };
|
|
23876
23889
|
}
|