starknet 8.5.2 → 8.5.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 +6 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.global.js +43 -35
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +43 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [8.5.3](https://github.com/starknet-io/starknet.js/compare/v8.5.2...v8.5.3) (2025-09-05)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- enforce fixed size for cairo bytes ([6a56166](https://github.com/starknet-io/starknet.js/commit/6a56166e65c79d68e012083cefff3fb532e150ac))
|
|
6
|
+
|
|
1
7
|
## [8.5.2](https://github.com/starknet-io/starknet.js/compare/v8.5.1...v8.5.2) (2025-08-27)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -8513,7 +8513,10 @@ declare class CairoBytes31 {
|
|
|
8513
8513
|
toApiRequest(): string[];
|
|
8514
8514
|
toBigInt(): bigint;
|
|
8515
8515
|
decodeUtf8(): string;
|
|
8516
|
-
|
|
8516
|
+
/**
|
|
8517
|
+
* @param padded flag for including leading zeros
|
|
8518
|
+
*/
|
|
8519
|
+
toHexString(padded?: 'padded'): string;
|
|
8517
8520
|
static validate(data: Uint8Array | string | Buffer | unknown): void;
|
|
8518
8521
|
static is(data: Uint8Array | string | Buffer): boolean;
|
|
8519
8522
|
/**
|
|
@@ -8600,6 +8603,15 @@ declare class CairoByteArray {
|
|
|
8600
8603
|
toBigInt(): bigint;
|
|
8601
8604
|
toHexString(): string;
|
|
8602
8605
|
toBuffer(): any;
|
|
8606
|
+
/**
|
|
8607
|
+
* returns an array of all the data chunks and the pending word
|
|
8608
|
+
* when concatenated, represents the original bytes sequence
|
|
8609
|
+
*/
|
|
8610
|
+
toElements(): Uint8Array[];
|
|
8611
|
+
/**
|
|
8612
|
+
* Private helper to check if the CairoByteArray is properly initialized
|
|
8613
|
+
*/
|
|
8614
|
+
private assertInitialized;
|
|
8603
8615
|
static validate(data: Uint8Array | Buffer | BigNumberish | unknown): void;
|
|
8604
8616
|
/**
|
|
8605
8617
|
* Check if the provided data is a valid CairoByteArray
|
|
@@ -8612,14 +8624,6 @@ declare class CairoByteArray {
|
|
|
8612
8624
|
* Check if provided abi type is this data type
|
|
8613
8625
|
*/
|
|
8614
8626
|
static isAbiType(abiType: string): boolean;
|
|
8615
|
-
/**
|
|
8616
|
-
* Private helper to check if the CairoByteArray is properly initialized
|
|
8617
|
-
*/
|
|
8618
|
-
private assertInitialized;
|
|
8619
|
-
/**
|
|
8620
|
-
* Private helper to reconstruct the full byte sequence from chunks and pending word
|
|
8621
|
-
*/
|
|
8622
|
-
private reconstructBytes;
|
|
8623
8627
|
static factoryFromApiResponse(responseIterator: Iterator<string>): CairoByteArray;
|
|
8624
8628
|
}
|
|
8625
8629
|
|
package/dist/index.global.js
CHANGED
|
@@ -5323,7 +5323,8 @@ ${indent}}` : "}";
|
|
|
5323
5323
|
static abiSelector = "core::felt252";
|
|
5324
5324
|
constructor(data) {
|
|
5325
5325
|
_CairoFelt252.validate(data);
|
|
5326
|
-
|
|
5326
|
+
const processedData = _CairoFelt252.__processData(data);
|
|
5327
|
+
this.data = processedData.subarray(processedData.findIndex((x) => x > 0));
|
|
5327
5328
|
}
|
|
5328
5329
|
static __processData(data) {
|
|
5329
5330
|
if (isString(data)) {
|
|
@@ -5926,7 +5927,9 @@ ${indent}}` : "}";
|
|
|
5926
5927
|
static abiSelector = "core::bytes_31::bytes31";
|
|
5927
5928
|
constructor(data) {
|
|
5928
5929
|
_CairoBytes31.validate(data);
|
|
5929
|
-
|
|
5930
|
+
const processedData = _CairoBytes31.__processData(data);
|
|
5931
|
+
this.data = new Uint8Array(_CairoBytes31.MAX_BYTE_SIZE);
|
|
5932
|
+
this.data.set(processedData, _CairoBytes31.MAX_BYTE_SIZE - processedData.length);
|
|
5930
5933
|
}
|
|
5931
5934
|
static __processData(data) {
|
|
5932
5935
|
if (isString(data)) {
|
|
@@ -5947,11 +5950,16 @@ ${indent}}` : "}";
|
|
|
5947
5950
|
return uint8ArrayToBigInt(this.data);
|
|
5948
5951
|
}
|
|
5949
5952
|
decodeUtf8() {
|
|
5950
|
-
|
|
5953
|
+
const cutoff = this.data.findIndex((x) => x > 0);
|
|
5954
|
+
const pruned = this.data.subarray(cutoff >= 0 ? cutoff : Infinity);
|
|
5955
|
+
return new TextDecoder().decode(pruned);
|
|
5951
5956
|
}
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5957
|
+
/**
|
|
5958
|
+
* @param padded flag for including leading zeros
|
|
5959
|
+
*/
|
|
5960
|
+
toHexString(padded) {
|
|
5961
|
+
const hex = padded === "padded" ? buf2hex(this.data) : this.toBigInt().toString(16);
|
|
5962
|
+
return addHexPrefix(hex);
|
|
5955
5963
|
}
|
|
5956
5964
|
static validate(data) {
|
|
5957
5965
|
const byteLength = _CairoBytes31.__processData(data).length;
|
|
@@ -6247,11 +6255,11 @@ ${indent}}` : "}";
|
|
|
6247
6255
|
]);
|
|
6248
6256
|
}
|
|
6249
6257
|
decodeUtf8() {
|
|
6250
|
-
const allBytes = this.
|
|
6258
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
6251
6259
|
return new TextDecoder().decode(allBytes);
|
|
6252
6260
|
}
|
|
6253
6261
|
toBigInt() {
|
|
6254
|
-
const allBytes = this.
|
|
6262
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
6255
6263
|
if (allBytes.length === 0) {
|
|
6256
6264
|
return 0n;
|
|
6257
6265
|
}
|
|
@@ -6262,15 +6270,39 @@ ${indent}}` : "}";
|
|
|
6262
6270
|
return result;
|
|
6263
6271
|
}
|
|
6264
6272
|
toHexString() {
|
|
6265
|
-
const allBytes = this.
|
|
6273
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
6266
6274
|
const hexValue = allBytes.length === 0 ? "0" : buf2hex(allBytes);
|
|
6267
6275
|
return addHexPrefix(hexValue);
|
|
6268
6276
|
}
|
|
6269
6277
|
toBuffer() {
|
|
6270
|
-
this.
|
|
6271
|
-
const allBytes = this.reconstructBytes();
|
|
6278
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
6272
6279
|
return buffer_default.from(allBytes);
|
|
6273
6280
|
}
|
|
6281
|
+
/**
|
|
6282
|
+
* returns an array of all the data chunks and the pending word
|
|
6283
|
+
* when concatenated, represents the original bytes sequence
|
|
6284
|
+
*/
|
|
6285
|
+
toElements() {
|
|
6286
|
+
this.assertInitialized();
|
|
6287
|
+
const allChunks = this.data.flatMap((chunk) => chunk.data);
|
|
6288
|
+
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
6289
|
+
if (pendingLen) {
|
|
6290
|
+
const pending = new Uint8Array(pendingLen);
|
|
6291
|
+
const paddingDifference = pendingLen - this.pending_word.data.length;
|
|
6292
|
+
pending.set(this.pending_word.data, paddingDifference);
|
|
6293
|
+
allChunks.push(pending);
|
|
6294
|
+
}
|
|
6295
|
+
return allChunks;
|
|
6296
|
+
}
|
|
6297
|
+
/**
|
|
6298
|
+
* Private helper to check if the CairoByteArray is properly initialized
|
|
6299
|
+
*/
|
|
6300
|
+
assertInitialized() {
|
|
6301
|
+
assert(
|
|
6302
|
+
this.data && this.pending_word !== void 0 && this.pending_word_len !== void 0,
|
|
6303
|
+
"CairoByteArray is not properly initialized"
|
|
6304
|
+
);
|
|
6305
|
+
}
|
|
6274
6306
|
static validate(data) {
|
|
6275
6307
|
assert(data !== null && data !== void 0, "Invalid input: null or undefined");
|
|
6276
6308
|
assert(
|
|
@@ -6318,30 +6350,6 @@ ${indent}}` : "}";
|
|
|
6318
6350
|
static isAbiType(abiType) {
|
|
6319
6351
|
return abiType === _CairoByteArray.abiSelector;
|
|
6320
6352
|
}
|
|
6321
|
-
/**
|
|
6322
|
-
* Private helper to check if the CairoByteArray is properly initialized
|
|
6323
|
-
*/
|
|
6324
|
-
assertInitialized() {
|
|
6325
|
-
assert(
|
|
6326
|
-
this.data && this.pending_word !== void 0 && this.pending_word_len !== void 0,
|
|
6327
|
-
"CairoByteArray is not properly initialized"
|
|
6328
|
-
);
|
|
6329
|
-
}
|
|
6330
|
-
/**
|
|
6331
|
-
* Private helper to reconstruct the full byte sequence from chunks and pending word
|
|
6332
|
-
*/
|
|
6333
|
-
reconstructBytes() {
|
|
6334
|
-
this.assertInitialized();
|
|
6335
|
-
const allChunks = this.data.flatMap((chunk) => chunk.data);
|
|
6336
|
-
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
6337
|
-
if (pendingLen) {
|
|
6338
|
-
const pending = new Uint8Array(pendingLen);
|
|
6339
|
-
const paddingDifference = pendingLen - this.pending_word.data.length;
|
|
6340
|
-
pending.set(this.pending_word.data, paddingDifference);
|
|
6341
|
-
allChunks.push(pending);
|
|
6342
|
-
}
|
|
6343
|
-
return concatenateArrayBuffer(allChunks);
|
|
6344
|
-
}
|
|
6345
6353
|
static factoryFromApiResponse(responseIterator) {
|
|
6346
6354
|
const data = Array.from(
|
|
6347
6355
|
{ length: Number(getNext(responseIterator)) },
|