starknet 8.5.0 → 8.5.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 +12 -0
- package/dist/index.global.js +14 -50
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +14 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1907,7 +1907,8 @@ var CairoBytes31 = class _CairoBytes31 {
|
|
|
1907
1907
|
return new TextDecoder().decode(this.data);
|
|
1908
1908
|
}
|
|
1909
1909
|
toHexString() {
|
|
1910
|
-
|
|
1910
|
+
const hexValue = this.data.length === 0 ? "0" : buf2hex(this.data);
|
|
1911
|
+
return addHexPrefix(hexValue);
|
|
1911
1912
|
}
|
|
1912
1913
|
static validate(data) {
|
|
1913
1914
|
const byteLength = _CairoBytes31.__processData(data).length;
|
|
@@ -2204,8 +2205,7 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2204
2205
|
}
|
|
2205
2206
|
decodeUtf8() {
|
|
2206
2207
|
const allBytes = this.reconstructBytes();
|
|
2207
|
-
|
|
2208
|
-
return new TextDecoder().decode(fullBytes);
|
|
2208
|
+
return new TextDecoder().decode(allBytes);
|
|
2209
2209
|
}
|
|
2210
2210
|
toBigInt() {
|
|
2211
2211
|
const allBytes = this.reconstructBytes();
|
|
@@ -2219,32 +2219,13 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2219
2219
|
return result;
|
|
2220
2220
|
}
|
|
2221
2221
|
toHexString() {
|
|
2222
|
-
|
|
2222
|
+
const allBytes = this.reconstructBytes();
|
|
2223
|
+
const hexValue = allBytes.length === 0 ? "0" : buf2hex(allBytes);
|
|
2224
|
+
return addHexPrefix(hexValue);
|
|
2223
2225
|
}
|
|
2224
2226
|
toBuffer() {
|
|
2225
2227
|
this.assertInitialized();
|
|
2226
|
-
const allBytes =
|
|
2227
|
-
this.data.forEach((chunk) => {
|
|
2228
|
-
const chunkBytes = chunk.data;
|
|
2229
|
-
for (let i = 0; i < chunkBytes.length; i += 1) {
|
|
2230
|
-
allBytes.push(chunkBytes[i]);
|
|
2231
|
-
}
|
|
2232
|
-
});
|
|
2233
|
-
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
2234
|
-
if (pendingLen > 0) {
|
|
2235
|
-
const hex = this.pending_word.toHexString();
|
|
2236
|
-
const hexWithoutPrefix = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
2237
|
-
const paddedHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
|
|
2238
|
-
for (let i = 0; i < pendingLen; i += 1) {
|
|
2239
|
-
const byteHex = paddedHex.slice(i * 2, i * 2 + 2);
|
|
2240
|
-
if (byteHex.length >= 2) {
|
|
2241
|
-
const byteValue = parseInt(byteHex, 16);
|
|
2242
|
-
if (!Number.isNaN(byteValue)) {
|
|
2243
|
-
allBytes.push(byteValue);
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2228
|
+
const allBytes = this.reconstructBytes();
|
|
2248
2229
|
return buffer_default.from(allBytes);
|
|
2249
2230
|
}
|
|
2250
2231
|
static validate(data) {
|
|
@@ -2308,32 +2289,15 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2308
2289
|
*/
|
|
2309
2290
|
reconstructBytes() {
|
|
2310
2291
|
this.assertInitialized();
|
|
2311
|
-
const
|
|
2312
|
-
this.data.forEach((chunk) => {
|
|
2313
|
-
const chunkBytes = chunk.data;
|
|
2314
|
-
for (let i = 0; i < chunkBytes.length; i += 1) {
|
|
2315
|
-
allBytes.push(chunkBytes[i]);
|
|
2316
|
-
}
|
|
2317
|
-
});
|
|
2292
|
+
const allChunks = this.data.flatMap((chunk) => chunk.data);
|
|
2318
2293
|
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
2319
|
-
if (pendingLen
|
|
2320
|
-
const
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
const byteHex = paddedHex.slice(i * 2, i * 2 + 2);
|
|
2325
|
-
if (byteHex.length < 2) {
|
|
2326
|
-
allBytes.push(0);
|
|
2327
|
-
} else {
|
|
2328
|
-
const byteValue = parseInt(byteHex, 16);
|
|
2329
|
-
if (Number.isNaN(byteValue)) {
|
|
2330
|
-
throw new Error(`Invalid hex byte: ${byteHex}`);
|
|
2331
|
-
}
|
|
2332
|
-
allBytes.push(byteValue);
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2294
|
+
if (pendingLen) {
|
|
2295
|
+
const pending = new Uint8Array(pendingLen);
|
|
2296
|
+
const paddingDifference = pendingLen - this.pending_word.data.length;
|
|
2297
|
+
pending.set(this.pending_word.data, paddingDifference);
|
|
2298
|
+
allChunks.push(pending);
|
|
2335
2299
|
}
|
|
2336
|
-
return
|
|
2300
|
+
return concatenateArrayBuffer(allChunks);
|
|
2337
2301
|
}
|
|
2338
2302
|
static factoryFromApiResponse(responseIterator) {
|
|
2339
2303
|
const data = Array.from(
|