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/dist/index.mjs
CHANGED
|
@@ -1106,7 +1106,8 @@ var CairoFelt252 = class _CairoFelt252 {
|
|
|
1106
1106
|
static abiSelector = "core::felt252";
|
|
1107
1107
|
constructor(data) {
|
|
1108
1108
|
_CairoFelt252.validate(data);
|
|
1109
|
-
|
|
1109
|
+
const processedData = _CairoFelt252.__processData(data);
|
|
1110
|
+
this.data = processedData.subarray(processedData.findIndex((x) => x > 0));
|
|
1110
1111
|
}
|
|
1111
1112
|
static __processData(data) {
|
|
1112
1113
|
if (isString(data)) {
|
|
@@ -1709,7 +1710,9 @@ var CairoBytes31 = class _CairoBytes31 {
|
|
|
1709
1710
|
static abiSelector = "core::bytes_31::bytes31";
|
|
1710
1711
|
constructor(data) {
|
|
1711
1712
|
_CairoBytes31.validate(data);
|
|
1712
|
-
|
|
1713
|
+
const processedData = _CairoBytes31.__processData(data);
|
|
1714
|
+
this.data = new Uint8Array(_CairoBytes31.MAX_BYTE_SIZE);
|
|
1715
|
+
this.data.set(processedData, _CairoBytes31.MAX_BYTE_SIZE - processedData.length);
|
|
1713
1716
|
}
|
|
1714
1717
|
static __processData(data) {
|
|
1715
1718
|
if (isString(data)) {
|
|
@@ -1730,11 +1733,16 @@ var CairoBytes31 = class _CairoBytes31 {
|
|
|
1730
1733
|
return uint8ArrayToBigInt(this.data);
|
|
1731
1734
|
}
|
|
1732
1735
|
decodeUtf8() {
|
|
1733
|
-
|
|
1736
|
+
const cutoff = this.data.findIndex((x) => x > 0);
|
|
1737
|
+
const pruned = this.data.subarray(cutoff >= 0 ? cutoff : Infinity);
|
|
1738
|
+
return new TextDecoder().decode(pruned);
|
|
1734
1739
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1740
|
+
/**
|
|
1741
|
+
* @param padded flag for including leading zeros
|
|
1742
|
+
*/
|
|
1743
|
+
toHexString(padded) {
|
|
1744
|
+
const hex = padded === "padded" ? buf2hex(this.data) : this.toBigInt().toString(16);
|
|
1745
|
+
return addHexPrefix(hex);
|
|
1738
1746
|
}
|
|
1739
1747
|
static validate(data) {
|
|
1740
1748
|
const byteLength = _CairoBytes31.__processData(data).length;
|
|
@@ -2030,11 +2038,11 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2030
2038
|
]);
|
|
2031
2039
|
}
|
|
2032
2040
|
decodeUtf8() {
|
|
2033
|
-
const allBytes = this.
|
|
2041
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
2034
2042
|
return new TextDecoder().decode(allBytes);
|
|
2035
2043
|
}
|
|
2036
2044
|
toBigInt() {
|
|
2037
|
-
const allBytes = this.
|
|
2045
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
2038
2046
|
if (allBytes.length === 0) {
|
|
2039
2047
|
return 0n;
|
|
2040
2048
|
}
|
|
@@ -2045,15 +2053,39 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2045
2053
|
return result;
|
|
2046
2054
|
}
|
|
2047
2055
|
toHexString() {
|
|
2048
|
-
const allBytes = this.
|
|
2056
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
2049
2057
|
const hexValue = allBytes.length === 0 ? "0" : buf2hex(allBytes);
|
|
2050
2058
|
return addHexPrefix(hexValue);
|
|
2051
2059
|
}
|
|
2052
2060
|
toBuffer() {
|
|
2053
|
-
this.
|
|
2054
|
-
const allBytes = this.reconstructBytes();
|
|
2061
|
+
const allBytes = concatenateArrayBuffer(this.toElements());
|
|
2055
2062
|
return buffer_default.from(allBytes);
|
|
2056
2063
|
}
|
|
2064
|
+
/**
|
|
2065
|
+
* returns an array of all the data chunks and the pending word
|
|
2066
|
+
* when concatenated, represents the original bytes sequence
|
|
2067
|
+
*/
|
|
2068
|
+
toElements() {
|
|
2069
|
+
this.assertInitialized();
|
|
2070
|
+
const allChunks = this.data.flatMap((chunk) => chunk.data);
|
|
2071
|
+
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
2072
|
+
if (pendingLen) {
|
|
2073
|
+
const pending = new Uint8Array(pendingLen);
|
|
2074
|
+
const paddingDifference = pendingLen - this.pending_word.data.length;
|
|
2075
|
+
pending.set(this.pending_word.data, paddingDifference);
|
|
2076
|
+
allChunks.push(pending);
|
|
2077
|
+
}
|
|
2078
|
+
return allChunks;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Private helper to check if the CairoByteArray is properly initialized
|
|
2082
|
+
*/
|
|
2083
|
+
assertInitialized() {
|
|
2084
|
+
assert(
|
|
2085
|
+
this.data && this.pending_word !== void 0 && this.pending_word_len !== void 0,
|
|
2086
|
+
"CairoByteArray is not properly initialized"
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2057
2089
|
static validate(data) {
|
|
2058
2090
|
assert(data !== null && data !== void 0, "Invalid input: null or undefined");
|
|
2059
2091
|
assert(
|
|
@@ -2101,30 +2133,6 @@ var CairoByteArray = class _CairoByteArray {
|
|
|
2101
2133
|
static isAbiType(abiType) {
|
|
2102
2134
|
return abiType === _CairoByteArray.abiSelector;
|
|
2103
2135
|
}
|
|
2104
|
-
/**
|
|
2105
|
-
* Private helper to check if the CairoByteArray is properly initialized
|
|
2106
|
-
*/
|
|
2107
|
-
assertInitialized() {
|
|
2108
|
-
assert(
|
|
2109
|
-
this.data && this.pending_word !== void 0 && this.pending_word_len !== void 0,
|
|
2110
|
-
"CairoByteArray is not properly initialized"
|
|
2111
|
-
);
|
|
2112
|
-
}
|
|
2113
|
-
/**
|
|
2114
|
-
* Private helper to reconstruct the full byte sequence from chunks and pending word
|
|
2115
|
-
*/
|
|
2116
|
-
reconstructBytes() {
|
|
2117
|
-
this.assertInitialized();
|
|
2118
|
-
const allChunks = this.data.flatMap((chunk) => chunk.data);
|
|
2119
|
-
const pendingLen = Number(this.pending_word_len.toBigInt());
|
|
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);
|
|
2125
|
-
}
|
|
2126
|
-
return concatenateArrayBuffer(allChunks);
|
|
2127
|
-
}
|
|
2128
2136
|
static factoryFromApiResponse(responseIterator) {
|
|
2129
2137
|
const data = Array.from(
|
|
2130
2138
|
{ length: Number(getNext(responseIterator)) },
|