@domino-sdk/relay 1.0.0-next.6 → 1.0.0-next.8
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/README.md +13 -1
- package/build.mjs +18 -1
- package/dist/authoring.d.ts +317 -15
- package/dist/authoring.js +177 -23
- package/dist/avatar.d.ts +29 -0
- package/dist/avatar.js +21 -0
- package/dist/browser.d.ts +174 -2239
- package/dist/browser.js +6 -6
- package/dist/{chunk-RTHN22KO.js → chunk-6A6K5RUD.js} +22 -8
- package/dist/chunk-77H7APVD.js +171 -0
- package/dist/chunk-MRIURJE3.js +257 -0
- package/dist/{chunk-5IIWKDFX.js → chunk-QBOHLT7M.js} +26 -5
- package/dist/chunk-V5R2DMGY.js +1407 -0
- package/dist/chunk-V7EZUZ3Z.js +1003 -0
- package/dist/chunk-V7UKZLHA.js +35 -0
- package/dist/{chunk-BRESOTKV.js → chunk-VARGF4JS.js} +660 -770
- package/dist/chunk-ZWY3R6B3.js +26 -0
- package/dist/client-CK4nwt7V.d.ts +2631 -0
- package/dist/collection-BGneJ6Bk.d.ts +114 -0
- package/dist/images--vZ9U0kr.d.ts +234 -0
- package/dist/index.d.ts +11 -13132
- package/dist/index.js +20 -690
- package/dist/integrations-C3Sp558f.d.ts +1297 -0
- package/dist/internal.d.ts +120 -0
- package/dist/internal.js +111 -0
- package/dist/pages-BzqJuI69.d.ts +4006 -0
- package/dist/point-ledgers-iS00Z_v0.d.ts +37 -0
- package/dist/portal-proxy.js +8 -9
- package/dist/profiles-DDMFBRKe.d.ts +297 -0
- package/dist/react/index.d.ts +186 -2251
- package/dist/react/index.js +11 -15
- package/dist/schema-pnuWqvGn.d.ts +3396 -0
- package/dist/schema.d.ts +3196 -2374
- package/dist/schema.js +549 -3
- package/dist/streaks-CwGReWGt.d.ts +73 -0
- package/dist/submission-input-C9qm9ixd.d.ts +2672 -0
- package/dist/units-CwgsPB_r.d.ts +9 -0
- package/dist/wallet-BGOfFkG9.d.ts +231 -0
- package/package.json +17 -4
- package/dist/chunk-ERBVT7GE.js +0 -1847
- package/dist/chunk-XEQDW7FM.js +0 -373
- package/dist/chunk-ZKJBCQNI.js +0 -624
- package/dist/submission-input-CZDukyb3.d.ts +0 -4998
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/units.ts
|
|
2
|
+
function checkDecimals(decimals) {
|
|
3
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
4
|
+
throw new Error("Token decimals must be an integer from 0 to 255");
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function parseUnits(value, decimals) {
|
|
8
|
+
checkDecimals(decimals);
|
|
9
|
+
const match = /^(\d+)(?:\.(\d+))?$/.exec(value.trim());
|
|
10
|
+
if (!match) {
|
|
11
|
+
throw new Error(`Use a decimal amount such as "1.5", not "${value}"`);
|
|
12
|
+
}
|
|
13
|
+
const [, whole, fraction = ""] = match;
|
|
14
|
+
const significant = fraction.replace(/0+$/, "");
|
|
15
|
+
if (significant.length > decimals) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`"${value}" has more than ${decimals} decimal places, which this token cannot hold`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return BigInt(whole + significant.padEnd(decimals, "0"));
|
|
21
|
+
}
|
|
22
|
+
function formatUnits(amount, decimals) {
|
|
23
|
+
checkDecimals(decimals);
|
|
24
|
+
const value = typeof amount === "bigint" ? amount : BigInt(amount);
|
|
25
|
+
const sign = value < 0n ? "-" : "";
|
|
26
|
+
const digits = (value < 0n ? -value : value).toString().padStart(decimals + 1, "0");
|
|
27
|
+
const whole = digits.slice(0, digits.length - decimals);
|
|
28
|
+
const fraction = digits.slice(digits.length - decimals).replace(/0+$/, "");
|
|
29
|
+
return sign + whole + (fraction ? "." + fraction : "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
parseUnits,
|
|
34
|
+
formatUnits
|
|
35
|
+
};
|