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.mjs
CHANGED
|
@@ -1733,7 +1733,8 @@ var CairoBytes31 = class _CairoBytes31 {
|
|
|
1733
1733
|
return new TextDecoder().decode(this.data);
|
|
1734
1734
|
}
|
|
1735
1735
|
toHexString() {
|
|
1736
|
-
|
|
1736
|
+
const hexValue = this.data.length === 0 ? "0" : buf2hex(this.data);
|
|
1737
|
+
return addHexPrefix(hexValue);
|
|
1737
1738
|
}
|
|
1738
1739
|
static validate(data) {
|
|
1739
1740
|
const byteLength = _CairoBytes31.__processData(data).length;
|
|
@@ -2030,8 +2031,7 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2030
2031
|
}
|
|
2031
2032
|
decodeUtf8() {
|
|
2032
2033
|
const allBytes = this.reconstructBytes();
|
|
2033
|
-
|
|
2034
|
-
return new TextDecoder().decode(fullBytes);
|
|
2034
|
+
return new TextDecoder().decode(allBytes);
|
|
2035
2035
|
}
|
|
2036
2036
|
toBigInt() {
|
|
2037
2037
|
const allBytes = this.reconstructBytes();
|
|
@@ -2045,32 +2045,13 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2045
2045
|
return result;
|
|
2046
2046
|
}
|
|
2047
2047
|
toHexString() {
|
|
2048
|
-
|
|
2048
|
+
const allBytes = this.reconstructBytes();
|
|
2049
|
+
const hexValue = allBytes.length === 0 ? "0" : buf2hex(allBytes);
|
|
2050
|
+
return addHexPrefix(hexValue);
|
|
2049
2051
|
}
|
|
2050
2052
|
toBuffer() {
|
|
2051
2053
|
this.assertInitialized();
|
|
2052
|
-
const allBytes =
|
|
2053
|
-
this.data.forEach((chunk) => {
|
|
2054
|
-
const chunkBytes = chunk.data;
|
|
2055
|
-
for (let i = 0; i < chunkBytes.length; i += 1) {
|
|
2056
|
-
allBytes.push(chunkBytes[i]);
|
|
2057
|
-
}
|
|
2058
|
-
});
|
|
2059
|
-
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
2060
|
-
if (pendingLen > 0) {
|
|
2061
|
-
const hex = this.pending_word.toHexString();
|
|
2062
|
-
const hexWithoutPrefix = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
2063
|
-
const paddedHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
|
|
2064
|
-
for (let i = 0; i < pendingLen; i += 1) {
|
|
2065
|
-
const byteHex = paddedHex.slice(i * 2, i * 2 + 2);
|
|
2066
|
-
if (byteHex.length >= 2) {
|
|
2067
|
-
const byteValue = parseInt(byteHex, 16);
|
|
2068
|
-
if (!Number.isNaN(byteValue)) {
|
|
2069
|
-
allBytes.push(byteValue);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2054
|
+
const allBytes = this.reconstructBytes();
|
|
2074
2055
|
return buffer_default.from(allBytes);
|
|
2075
2056
|
}
|
|
2076
2057
|
static validate(data) {
|
|
@@ -2134,32 +2115,15 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2134
2115
|
*/
|
|
2135
2116
|
reconstructBytes() {
|
|
2136
2117
|
this.assertInitialized();
|
|
2137
|
-
const
|
|
2138
|
-
this.data.forEach((chunk) => {
|
|
2139
|
-
const chunkBytes = chunk.data;
|
|
2140
|
-
for (let i = 0; i < chunkBytes.length; i += 1) {
|
|
2141
|
-
allBytes.push(chunkBytes[i]);
|
|
2142
|
-
}
|
|
2143
|
-
});
|
|
2118
|
+
const allChunks = this.data.flatMap((chunk) => chunk.data);
|
|
2144
2119
|
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
2145
|
-
if (pendingLen
|
|
2146
|
-
const
|
|
2147
|
-
const
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
const byteHex = paddedHex.slice(i * 2, i * 2 + 2);
|
|
2151
|
-
if (byteHex.length < 2) {
|
|
2152
|
-
allBytes.push(0);
|
|
2153
|
-
} else {
|
|
2154
|
-
const byteValue = parseInt(byteHex, 16);
|
|
2155
|
-
if (Number.isNaN(byteValue)) {
|
|
2156
|
-
throw new Error(`Invalid hex byte: ${byteHex}`);
|
|
2157
|
-
}
|
|
2158
|
-
allBytes.push(byteValue);
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2120
|
+
if (pendingLen) {
|
|
2121
|
+
const pending = new Uint8Array(pendingLen);
|
|
2122
|
+
const paddingDifference = pendingLen - this.pending_word.data.length;
|
|
2123
|
+
pending.set(this.pending_word.data, paddingDifference);
|
|
2124
|
+
allChunks.push(pending);
|
|
2161
2125
|
}
|
|
2162
|
-
return
|
|
2126
|
+
return concatenateArrayBuffer(allChunks);
|
|
2163
2127
|
}
|
|
2164
2128
|
static factoryFromApiResponse(responseIterator) {
|
|
2165
2129
|
const data = Array.from(
|