starknet 11.7.1 → 11.8.0
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/falcon/index.d.ts +139 -39
- package/dist/falcon/index.js +464 -224
- package/dist/falcon/index.js.map +1 -1
- package/dist/falcon/index.mjs +462 -222
- package/dist/falcon/index.mjs.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.global.js +21 -17
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22010,32 +22010,36 @@ var ContractInterface = class {
|
|
|
22010
22010
|
};
|
|
22011
22011
|
|
|
22012
22012
|
// src/utils/units.ts
|
|
22013
|
-
function units(amount,
|
|
22014
|
-
if (
|
|
22015
|
-
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
if (decimal.length > 18) {
|
|
22013
|
+
function units(amount, symbol = "fri") {
|
|
22014
|
+
if (symbol === "strk") {
|
|
22015
|
+
if (!isBigInt(amount) && !isString(amount)) {
|
|
22016
|
+
throw new Error(`units: a strk amount must be a string or a bigint, not ${typeof amount}`);
|
|
22017
|
+
}
|
|
22018
|
+
const numStr = isBigInt(amount) || isHex(amount) ? toBigInt(amount).toString() : amount;
|
|
22019
|
+
const match = /^(-?)(\d*)(?:\.(\d*))?$/.exec(numStr);
|
|
22020
|
+
if (!match || `${match[2]}${match[3] ?? ""}` === "") {
|
|
22021
|
+
throw new Error(`units: '${numStr}' is not a strk amount`);
|
|
22022
|
+
}
|
|
22023
|
+
const [, sign2, integer, decimal = ""] = match;
|
|
22024
|
+
if (/[1-9]/.test(decimal.slice(18))) {
|
|
22026
22025
|
throw new Error(`units: '${numStr}' strk has more than 18 decimals`);
|
|
22027
22026
|
}
|
|
22028
|
-
const
|
|
22029
|
-
return `${
|
|
22027
|
+
const fri2 = BigInt(`${integer}${decimal.slice(0, 18).padEnd(18, "0")}`);
|
|
22028
|
+
return fri2 === 0n ? "0" : `${sign2}${fri2.toString()}`;
|
|
22029
|
+
}
|
|
22030
|
+
if (isString(amount) && amount.trim() === "") {
|
|
22031
|
+
throw new Error("units: the fri amount is an empty string");
|
|
22030
22032
|
}
|
|
22031
|
-
const
|
|
22033
|
+
const fri = toBigInt(amount);
|
|
22034
|
+
const sign = fri < 0n ? "-" : "";
|
|
22035
|
+
const bis = (fri < 0n ? -fri : fri).toString();
|
|
22032
22036
|
let strk;
|
|
22033
22037
|
if (bis.length <= 18) {
|
|
22034
22038
|
strk = `0.${bis.padStart(18, "0")}`;
|
|
22035
22039
|
} else {
|
|
22036
22040
|
strk = `${bis.slice(0, bis.length - 18)}.${bis.slice(bis.length - 18)}`;
|
|
22037
22041
|
}
|
|
22038
|
-
return strk.replace(/(\.[0-9]*[1-9])0+$|\.0*$/, "$1");
|
|
22042
|
+
return sign + strk.replace(/(\.[0-9]*[1-9])0+$|\.0*$/, "$1");
|
|
22039
22043
|
}
|
|
22040
22044
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22041
22045
|
0 && (module.exports = {
|