@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.
Files changed (43) hide show
  1. package/README.md +13 -1
  2. package/build.mjs +18 -1
  3. package/dist/authoring.d.ts +317 -15
  4. package/dist/authoring.js +177 -23
  5. package/dist/avatar.d.ts +29 -0
  6. package/dist/avatar.js +21 -0
  7. package/dist/browser.d.ts +174 -2239
  8. package/dist/browser.js +6 -6
  9. package/dist/{chunk-RTHN22KO.js → chunk-6A6K5RUD.js} +22 -8
  10. package/dist/chunk-77H7APVD.js +171 -0
  11. package/dist/chunk-MRIURJE3.js +257 -0
  12. package/dist/{chunk-5IIWKDFX.js → chunk-QBOHLT7M.js} +26 -5
  13. package/dist/chunk-V5R2DMGY.js +1407 -0
  14. package/dist/chunk-V7EZUZ3Z.js +1003 -0
  15. package/dist/chunk-V7UKZLHA.js +35 -0
  16. package/dist/{chunk-BRESOTKV.js → chunk-VARGF4JS.js} +660 -770
  17. package/dist/chunk-ZWY3R6B3.js +26 -0
  18. package/dist/client-CK4nwt7V.d.ts +2631 -0
  19. package/dist/collection-BGneJ6Bk.d.ts +114 -0
  20. package/dist/images--vZ9U0kr.d.ts +234 -0
  21. package/dist/index.d.ts +11 -13132
  22. package/dist/index.js +20 -690
  23. package/dist/integrations-C3Sp558f.d.ts +1297 -0
  24. package/dist/internal.d.ts +120 -0
  25. package/dist/internal.js +111 -0
  26. package/dist/pages-BzqJuI69.d.ts +4006 -0
  27. package/dist/point-ledgers-iS00Z_v0.d.ts +37 -0
  28. package/dist/portal-proxy.js +8 -9
  29. package/dist/profiles-DDMFBRKe.d.ts +297 -0
  30. package/dist/react/index.d.ts +186 -2251
  31. package/dist/react/index.js +11 -15
  32. package/dist/schema-pnuWqvGn.d.ts +3396 -0
  33. package/dist/schema.d.ts +3196 -2374
  34. package/dist/schema.js +549 -3
  35. package/dist/streaks-CwGReWGt.d.ts +73 -0
  36. package/dist/submission-input-C9qm9ixd.d.ts +2672 -0
  37. package/dist/units-CwgsPB_r.d.ts +9 -0
  38. package/dist/wallet-BGOfFkG9.d.ts +231 -0
  39. package/package.json +17 -4
  40. package/dist/chunk-ERBVT7GE.js +0 -1847
  41. package/dist/chunk-XEQDW7FM.js +0 -373
  42. package/dist/chunk-ZKJBCQNI.js +0 -624
  43. 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
+ };