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.mjs
CHANGED
|
@@ -21801,32 +21801,36 @@ var ContractInterface = class {
|
|
|
21801
21801
|
};
|
|
21802
21802
|
|
|
21803
21803
|
// src/utils/units.ts
|
|
21804
|
-
function units(amount,
|
|
21805
|
-
if (
|
|
21806
|
-
|
|
21807
|
-
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
|
|
21814
|
-
|
|
21815
|
-
|
|
21816
|
-
if (decimal.length > 18) {
|
|
21804
|
+
function units(amount, symbol = "fri") {
|
|
21805
|
+
if (symbol === "strk") {
|
|
21806
|
+
if (!isBigInt(amount) && !isString(amount)) {
|
|
21807
|
+
throw new Error(`units: a strk amount must be a string or a bigint, not ${typeof amount}`);
|
|
21808
|
+
}
|
|
21809
|
+
const numStr = isBigInt(amount) || isHex(amount) ? toBigInt(amount).toString() : amount;
|
|
21810
|
+
const match = /^(-?)(\d*)(?:\.(\d*))?$/.exec(numStr);
|
|
21811
|
+
if (!match || `${match[2]}${match[3] ?? ""}` === "") {
|
|
21812
|
+
throw new Error(`units: '${numStr}' is not a strk amount`);
|
|
21813
|
+
}
|
|
21814
|
+
const [, sign2, integer, decimal = ""] = match;
|
|
21815
|
+
if (/[1-9]/.test(decimal.slice(18))) {
|
|
21817
21816
|
throw new Error(`units: '${numStr}' strk has more than 18 decimals`);
|
|
21818
21817
|
}
|
|
21819
|
-
const
|
|
21820
|
-
return `${
|
|
21818
|
+
const fri2 = BigInt(`${integer}${decimal.slice(0, 18).padEnd(18, "0")}`);
|
|
21819
|
+
return fri2 === 0n ? "0" : `${sign2}${fri2.toString()}`;
|
|
21820
|
+
}
|
|
21821
|
+
if (isString(amount) && amount.trim() === "") {
|
|
21822
|
+
throw new Error("units: the fri amount is an empty string");
|
|
21821
21823
|
}
|
|
21822
|
-
const
|
|
21824
|
+
const fri = toBigInt(amount);
|
|
21825
|
+
const sign = fri < 0n ? "-" : "";
|
|
21826
|
+
const bis = (fri < 0n ? -fri : fri).toString();
|
|
21823
21827
|
let strk;
|
|
21824
21828
|
if (bis.length <= 18) {
|
|
21825
21829
|
strk = `0.${bis.padStart(18, "0")}`;
|
|
21826
21830
|
} else {
|
|
21827
21831
|
strk = `${bis.slice(0, bis.length - 18)}.${bis.slice(bis.length - 18)}`;
|
|
21828
21832
|
}
|
|
21829
|
-
return strk.replace(/(\.[0-9]*[1-9])0+$|\.0*$/, "$1");
|
|
21833
|
+
return sign + strk.replace(/(\.[0-9]*[1-9])0+$|\.0*$/, "$1");
|
|
21830
21834
|
}
|
|
21831
21835
|
var export_TypedDataRevision = api_exports.TypedDataRevision;
|
|
21832
21836
|
export {
|