@mezo-org/passport 0.4.0-dev.7 → 0.4.0-dev.71

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 (255) hide show
  1. package/README.md +18 -22
  2. package/dist/src/api/auth.d.ts +7 -3
  3. package/dist/src/api/auth.d.ts.map +1 -1
  4. package/dist/src/api/auth.js +3 -1
  5. package/dist/src/api/auth.js.map +1 -1
  6. package/dist/src/api/client.d.ts +4 -1
  7. package/dist/src/api/client.d.ts.map +1 -1
  8. package/dist/src/api/client.js +9 -2
  9. package/dist/src/api/client.js.map +1 -1
  10. package/dist/src/api/portal.d.ts +3 -9
  11. package/dist/src/api/portal.d.ts.map +1 -1
  12. package/dist/src/api/portal.js +8 -5
  13. package/dist/src/api/portal.js.map +1 -1
  14. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +2 -1
  15. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -1
  16. package/dist/src/components/Dropdown/ConnectedTrigger.js +29 -20
  17. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -1
  18. package/dist/src/components/Dropdown/Content.d.ts +19 -5
  19. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  20. package/dist/src/components/Dropdown/Content.js +19 -61
  21. package/dist/src/components/Dropdown/Content.js.map +1 -1
  22. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -1
  23. package/dist/src/components/Dropdown/DisconnectedTrigger.js +2 -2
  24. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -1
  25. package/dist/src/components/Dropdown/Dropdown.d.ts +13 -6
  26. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  27. package/dist/src/components/Dropdown/Dropdown.js +32 -9
  28. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  29. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  30. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  32. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  33. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  34. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  35. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  36. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  37. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  38. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  40. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  41. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  42. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  43. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  44. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  45. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  46. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  47. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  48. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  49. package/dist/src/components/Dropdown/{AccountBalance.d.ts → Root/AccountBalance.d.ts} +2 -1
  50. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  51. package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
  52. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  53. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  54. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  55. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
  56. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  57. package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
  58. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  59. package/dist/src/components/Dropdown/Root/Root.js +57 -0
  60. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  61. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  62. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  63. package/dist/src/components/Dropdown/{AccountAddress.js → Root/WalletAddress.js} +21 -15
  64. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  65. package/dist/src/components/Dropdown/{WelcomeBlock.d.ts → Root/WelcomeBlock.d.ts} +1 -1
  66. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  67. package/dist/src/components/Dropdown/{WelcomeBlock.js → Root/WelcomeBlock.js} +5 -5
  68. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  69. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  70. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  71. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  72. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  73. package/dist/src/config.d.ts +18 -5
  74. package/dist/src/config.d.ts.map +1 -1
  75. package/dist/src/config.js +45 -14
  76. package/dist/src/config.js.map +1 -1
  77. package/dist/src/constants.d.ts +11 -3
  78. package/dist/src/constants.d.ts.map +1 -1
  79. package/dist/src/constants.js +12 -4
  80. package/dist/src/constants.js.map +1 -1
  81. package/dist/src/hooks/index.d.ts +4 -0
  82. package/dist/src/hooks/index.d.ts.map +1 -1
  83. package/dist/src/hooks/index.js +4 -0
  84. package/dist/src/hooks/index.js.map +1 -1
  85. package/dist/src/hooks/useAssetsConversionRates.d.ts +23 -0
  86. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  87. package/dist/src/hooks/useAssetsConversionRates.js +90 -0
  88. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  89. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  90. package/dist/src/hooks/useAuthenticateWithWallet.js +9 -9
  91. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  92. package/dist/src/hooks/useBorrowData.d.ts +82 -0
  93. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  94. package/dist/src/hooks/useBorrowData.js +159 -0
  95. package/dist/src/hooks/useBorrowData.js.map +1 -0
  96. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  97. package/dist/src/hooks/useCreateAccount.js +22 -1
  98. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  99. package/dist/src/hooks/useDropdownData.d.ts +37 -34
  100. package/dist/src/hooks/useDropdownData.d.ts.map +1 -1
  101. package/dist/src/hooks/useDropdownData.js +85 -61
  102. package/dist/src/hooks/useDropdownData.js.map +1 -1
  103. package/dist/src/hooks/useLinkAccount.d.ts +19 -13
  104. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  105. package/dist/src/hooks/useLinkAccount.js +20 -1
  106. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  107. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  108. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  109. package/dist/src/hooks/useRefreshPassport.js +44 -0
  110. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  111. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  112. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  113. package/dist/src/hooks/useTokensBalances.js +140 -0
  114. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  115. package/dist/src/hooks/useValidateMezoId.d.ts +8 -0
  116. package/dist/src/hooks/useValidateMezoId.d.ts.map +1 -0
  117. package/dist/src/hooks/useValidateMezoId.js +24 -0
  118. package/dist/src/hooks/useValidateMezoId.js.map +1 -0
  119. package/dist/src/hooks/useWalletAccount.d.ts +2 -1
  120. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  121. package/dist/src/hooks/useWalletAccount.js +19 -15
  122. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  123. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  124. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  125. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  126. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  127. package/dist/src/index.d.ts +2 -1
  128. package/dist/src/index.d.ts.map +1 -1
  129. package/dist/src/index.js +2 -1
  130. package/dist/src/index.js.map +1 -1
  131. package/dist/src/lib/contracts/index.d.ts +13 -0
  132. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  133. package/dist/src/lib/contracts/index.js +62 -0
  134. package/dist/src/lib/contracts/index.js.map +1 -0
  135. package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
  136. package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
  137. package/dist/src/lib/contracts/priceOracle.js +52 -0
  138. package/dist/src/lib/contracts/priceOracle.js.map +1 -0
  139. package/dist/src/provider.js +1 -1
  140. package/dist/src/provider.js.map +1 -1
  141. package/dist/src/stores/dropdownStore.d.ts +12 -0
  142. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  143. package/dist/src/stores/dropdownStore.js +13 -0
  144. package/dist/src/stores/dropdownStore.js.map +1 -0
  145. package/dist/src/utils/address.d.ts +1 -1
  146. package/dist/src/utils/address.d.ts.map +1 -1
  147. package/dist/src/utils/address.js +2 -0
  148. package/dist/src/utils/address.js.map +1 -1
  149. package/dist/src/utils/address.test.js +8 -5
  150. package/dist/src/utils/address.test.js.map +1 -1
  151. package/dist/src/utils/cryptoAssets.d.ts +17 -1
  152. package/dist/src/utils/cryptoAssets.d.ts.map +1 -1
  153. package/dist/src/utils/cryptoAssets.js +87 -31
  154. package/dist/src/utils/cryptoAssets.js.map +1 -1
  155. package/dist/src/utils/cryptoAssets.test.js +51 -33
  156. package/dist/src/utils/cryptoAssets.test.js.map +1 -1
  157. package/dist/src/utils/currency.d.ts +8 -0
  158. package/dist/src/utils/currency.d.ts.map +1 -1
  159. package/dist/src/utils/currency.js +11 -0
  160. package/dist/src/utils/currency.js.map +1 -1
  161. package/dist/src/utils/currency.test.js +1 -0
  162. package/dist/src/utils/currency.test.js.map +1 -1
  163. package/dist/src/utils/mezoId.d.ts +7 -0
  164. package/dist/src/utils/mezoId.d.ts.map +1 -0
  165. package/dist/src/utils/mezoId.js +41 -0
  166. package/dist/src/utils/mezoId.js.map +1 -0
  167. package/dist/src/utils/numbers.d.ts +39 -17
  168. package/dist/src/utils/numbers.d.ts.map +1 -1
  169. package/dist/src/utils/numbers.js +91 -33
  170. package/dist/src/utils/numbers.js.map +1 -1
  171. package/dist/src/utils/numbers.test.js +144 -22
  172. package/dist/src/utils/numbers.test.js.map +1 -1
  173. package/dist/src/utils/siww.d.ts +1 -0
  174. package/dist/src/utils/siww.d.ts.map +1 -1
  175. package/dist/src/utils/siww.js +50 -12
  176. package/dist/src/utils/siww.js.map +1 -1
  177. package/dist/src/utils/wagmi.d.ts +3 -0
  178. package/dist/src/utils/wagmi.d.ts.map +1 -0
  179. package/dist/src/utils/wagmi.js +7 -0
  180. package/dist/src/utils/wagmi.js.map +1 -0
  181. package/dist/src/wallet/index.d.ts +1 -1
  182. package/dist/src/wallet/index.d.ts.map +1 -1
  183. package/dist/src/wallet/index.js +1 -1
  184. package/dist/src/wallet/index.js.map +1 -1
  185. package/package.json +10 -8
  186. package/src/api/auth.ts +8 -4
  187. package/src/api/client.ts +11 -2
  188. package/src/api/portal.ts +11 -14
  189. package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
  190. package/src/components/Dropdown/Content.tsx +67 -117
  191. package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
  192. package/src/components/Dropdown/Dropdown.tsx +75 -15
  193. package/src/components/Dropdown/ListingItem.tsx +80 -0
  194. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  195. package/src/components/Dropdown/README.md +10 -18
  196. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  197. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  198. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  199. package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
  200. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
  201. package/src/components/Dropdown/Root/Root.tsx +147 -0
  202. package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
  203. package/src/components/Dropdown/{WelcomeBlock.tsx → Root/WelcomeBlock.tsx} +5 -6
  204. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  205. package/src/config.ts +73 -20
  206. package/src/constants.ts +12 -4
  207. package/src/hooks/index.ts +7 -0
  208. package/src/hooks/useAssetsConversionRates.ts +97 -0
  209. package/src/hooks/useAuthenticateWithWallet.ts +18 -12
  210. package/src/hooks/useBorrowData.ts +187 -0
  211. package/src/hooks/useCreateAccount.ts +28 -2
  212. package/src/hooks/useDropdownData.ts +119 -97
  213. package/src/hooks/useLinkAccount.ts +36 -4
  214. package/src/hooks/useRefreshPassport.ts +56 -0
  215. package/src/hooks/useTokensBalances.ts +187 -0
  216. package/src/hooks/useValidateMezoId.ts +31 -0
  217. package/src/hooks/useWalletAccount.ts +29 -19
  218. package/src/hooks/useWatchTransferEvents.ts +74 -0
  219. package/src/index.ts +12 -1
  220. package/src/lib/contracts/index.ts +92 -0
  221. package/src/lib/contracts/priceOracle.ts +53 -0
  222. package/src/provider.ts +1 -1
  223. package/src/stores/dropdownStore.ts +20 -0
  224. package/src/utils/address.test.ts +10 -6
  225. package/src/utils/address.ts +5 -3
  226. package/src/utils/cryptoAssets.test.ts +57 -37
  227. package/src/utils/cryptoAssets.ts +113 -35
  228. package/src/utils/currency.test.ts +2 -0
  229. package/src/utils/currency.ts +21 -0
  230. package/src/utils/mezoId.ts +51 -0
  231. package/src/utils/numbers.test.ts +181 -23
  232. package/src/utils/numbers.ts +121 -34
  233. package/src/utils/siww.ts +71 -16
  234. package/src/utils/wagmi.ts +12 -0
  235. package/src/wallet/index.ts +3 -2
  236. package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
  237. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
  238. package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
  239. package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
  240. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
  241. package/dist/src/components/Dropdown/AccountAssets.js +0 -44
  242. package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
  243. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
  244. package/dist/src/components/Dropdown/AccountBalance.js +0 -18
  245. package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
  246. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
  247. package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
  248. package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
  249. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
  250. package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
  251. package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
  252. package/src/components/Dropdown/AccountAddress.tsx +0 -111
  253. package/src/components/Dropdown/AccountAssets.tsx +0 -110
  254. package/src/components/Dropdown/AccountBalance.tsx +0 -38
  255. package/src/hooks/useAssetsUSDConversion.ts +0 -31
@@ -1,49 +1,67 @@
1
- import { BitcoinCircle, EthCircle, MUsdCircle, TBtcCircle, } from "@mezo-org/mezo-clay";
2
- import { getCryptoAsset } from "./cryptoAssets";
1
+ import { BitcoinCircle, EthCircle, MUsdCircle02 } from "@mezo-org/mezo-clay";
2
+ import { getCryptoAsset, isBitcoinLikeCryptoAsset, isUsdLikeCryptoAsset, } from "./cryptoAssets";
3
+ // FIXME: Test fails if run in full suite (pnpm test) but works when run in isolation (pnpm test cryptoAssets)
3
4
  describe("getCryptoAsset", () => {
4
- it("returns the correct asset for 'btc'", () => {
5
- const asset = getCryptoAsset("btc");
5
+ it("returns the correct asset for 'BTC (mBTC)'", () => {
6
+ const asset = getCryptoAsset("BTC");
6
7
  expect(asset.name).toBe("Bitcoin");
7
8
  expect(asset.symbol).toBe("BTC");
8
- expect(asset.decimals).toBe(8);
9
+ expect(asset.decimals).toBe(18);
9
10
  expect(asset.icon).toBe(BitcoinCircle);
10
11
  });
11
- it("returns the correct asset for 'eth'", () => {
12
- const asset = getCryptoAsset("eth");
12
+ it("returns the correct asset for 'ETH'", () => {
13
+ const asset = getCryptoAsset("ETH");
13
14
  expect(asset.name).toBe("Ethereum");
14
15
  expect(asset.symbol).toBe("ETH");
15
16
  expect(asset.decimals).toBe(18);
16
17
  expect(asset.icon).toBe(EthCircle);
17
18
  });
18
- it("returns the correct asset for 'tbtc'", () => {
19
- const asset = getCryptoAsset("tbtc");
20
- expect(asset.name).toBe("Threshold Bitcoin");
21
- expect(asset.symbol).toBe("tBTC");
19
+ it("returns the correct asset for 'MUSD'", () => {
20
+ const asset = getCryptoAsset("MUSD");
21
+ expect(asset.name).toBe("MUSD");
22
+ expect(asset.symbol).toBe("MUSD");
22
23
  expect(asset.decimals).toBe(18);
23
- expect(asset.icon).toBe(TBtcCircle);
24
- });
25
- it("returns the correct asset for 'wbtc'", () => {
26
- const asset = getCryptoAsset("wbtc");
27
- expect(asset.name).toBe("Wrapped Bitcoin");
28
- expect(asset.symbol).toBe("wBTC");
29
- expect(asset.decimals).toBe(8);
30
- // FIXME: Test should expect the exact icon component
31
- expect(asset.icon).toEqual(expect.any(Function));
24
+ expect(asset.icon).toBe(MUsdCircle02);
32
25
  });
33
- it("returns the correct asset for 'mbtc'", () => {
34
- const asset = getCryptoAsset("mbtc");
35
- expect(asset.name).toBe("Matsnet Bitcoin");
36
- expect(asset.symbol).toBe("BTC");
37
- expect(asset.decimals).toBe(18);
38
- // FIXME: Test should expect the exact icon component
39
- expect(asset.icon).toEqual(expect.any(Function));
26
+ });
27
+ describe("isBitcoinLikeCryptoAsset", () => {
28
+ const cases = [
29
+ { input: "mcbBTC", expected: true },
30
+ { input: "mDAI", expected: false },
31
+ { input: "mFBTC", expected: true },
32
+ { input: "mSolvBTC", expected: true },
33
+ { input: "mswBTC", expected: true },
34
+ { input: "mT", expected: false },
35
+ { input: "mUSDC", expected: false },
36
+ { input: "mUSDe", expected: false },
37
+ { input: "mUSDT", expected: false },
38
+ { input: "mxSolvBTC", expected: true },
39
+ { input: "MUSD", expected: false },
40
+ ];
41
+ cases.forEach(({ input, expected }) => {
42
+ it(`returns ${expected} for ${input}`, () => {
43
+ expect(isBitcoinLikeCryptoAsset(input)).toBe(expected);
44
+ });
40
45
  });
41
- it("returns the correct asset for 'musd'", () => {
42
- const asset = getCryptoAsset("musd");
43
- expect(asset.name).toBe("Mezo USD");
44
- expect(asset.symbol).toBe("mUSD");
45
- expect(asset.decimals).toBe(18);
46
- expect(asset.icon).toBe(MUsdCircle);
46
+ });
47
+ describe("isUsdLikeCryptoAsset", () => {
48
+ const cases = [
49
+ { input: "mcbBTC", expected: false },
50
+ { input: "mDAI", expected: true },
51
+ { input: "mFBTC", expected: false },
52
+ { input: "mSolvBTC", expected: false },
53
+ { input: "mswBTC", expected: false },
54
+ { input: "mT", expected: false },
55
+ { input: "mUSDC", expected: true },
56
+ { input: "mUSDe", expected: true },
57
+ { input: "mUSDT", expected: true },
58
+ { input: "mxSolvBTC", expected: false },
59
+ { input: "MUSD", expected: true },
60
+ ];
61
+ cases.forEach(({ input, expected }) => {
62
+ it(`returns ${expected} for ${input}`, () => {
63
+ expect(isUsdLikeCryptoAsset(input)).toBe(expected);
64
+ });
47
65
  });
48
66
  });
49
67
  //# sourceMappingURL=cryptoAssets.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cryptoAssets.test.js","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,E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AE,QAAQ,EAAE,IAAI,EAAE;QAClC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE;QACvC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;KAClC,CAAA;IAED,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACpC,EAAE,CAAC,WAAW,QAAQ,QAAQ,KAAK,EAAE,EAAE,GAAG,EAAE;YAC1C,MAAM,CAAC,oBAAoB,CAAC,KAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -11,4 +11,12 @@ export declare function formatCurrency(value: number, options?: Omit<Intl.Number
11
11
  * @returns The formatted currency
12
12
  */
13
13
  export declare function formatUsd(value: number): string;
14
+ /**
15
+ * Converts an asset amount to USD based on a conversion rate and decimals
16
+ * @param assetAmount - The amount of the asset in its smallest unit (e.g., satoshis for BTC)
17
+ * @param conversionRate - The conversion rate from the asset to USD in fixed-point format
18
+ * @param decimals - The number of decimals for the asset
19
+ * @returns - The value in USD as a number
20
+ */
21
+ export declare function convertToUsd(assetAmount: bigint, assetDecimals: number, conversionRate: bigint, conversionRateDecimals: number): number;
14
22
  //# sourceMappingURL=currency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/utils/currency.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAM,GACpD,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
1
+ {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/utils/currency.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAM,GACpD,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,sBAAsB,EAAE,MAAM,GAC7B,MAAM,CAKR"}
@@ -1,3 +1,4 @@
1
+ import { fromFixedPoint } from "./numbers";
1
2
  const DEFAULT_FORMAT_OPTIONS = {
2
3
  style: "currency",
3
4
  minimumFractionDigits: 2,
@@ -24,4 +25,14 @@ export function formatCurrency(value, options = {}) {
24
25
  export function formatUsd(value) {
25
26
  return formatCurrency(value, { currency: "USD" });
26
27
  }
28
+ /**
29
+ * Converts an asset amount to USD based on a conversion rate and decimals
30
+ * @param assetAmount - The amount of the asset in its smallest unit (e.g., satoshis for BTC)
31
+ * @param conversionRate - The conversion rate from the asset to USD in fixed-point format
32
+ * @param decimals - The number of decimals for the asset
33
+ * @returns - The value in USD as a number
34
+ */
35
+ export function convertToUsd(assetAmount, assetDecimals, conversionRate, conversionRateDecimals) {
36
+ return fromFixedPoint((assetAmount * conversionRate) / 10n ** BigInt(conversionRateDecimals), assetDecimals);
37
+ }
27
38
  //# sourceMappingURL=currency.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/utils/currency.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAA6B;IACvD,KAAK,EAAE,UAAU;IACjB,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;CACzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAa,EACb,UAAmD,EAAE;IAErD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QAC/C,GAAG,sBAAsB;QACzB,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,cAAc,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;AACnD,CAAC"}
1
+ {"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/utils/currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,MAAM,sBAAsB,GAA6B;IACvD,KAAK,EAAE,UAAU;IACjB,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;CACzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAa,EACb,UAAmD,EAAE;IAErD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QAC/C,GAAG,sBAAsB;QACzB,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,cAAc,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,WAAmB,EACnB,aAAqB,EACrB,cAAsB,EACtB,sBAA8B;IAE9B,OAAO,cAAc,CACnB,CAAC,WAAW,GAAG,cAAc,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,EACtE,aAAa,CACd,CAAA;AACH,CAAC"}
@@ -31,4 +31,5 @@ describe("formatUsd", () => {
31
31
  expect(result).toBe("$0.00");
32
32
  });
33
33
  });
34
+ // TODO: Add tests for convertToUsd function
34
35
  //# sourceMappingURL=currency.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.test.js","sourceRoot":"","sources":["../../../src/utils/currency.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,EAAE;YACjC,QAAQ,EAAE,KAAK;YACf,qBAAqB,EAAE,CAAC;YACxB,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAA;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,EAAE;YACtC,QAAQ,EAAE,KAAK;YACf,qBAAqB,EAAE,CAAC;YACxB,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAA;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,S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AAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,4CAA4C"}
@@ -0,0 +1,7 @@
1
+ export type MezoId = `${string}.mezo`;
2
+ export declare const DISALLOWED_MEZO_ID_PATTERNS: {
3
+ pattern: RegExp;
4
+ error: string;
5
+ }[];
6
+ export declare function validateMezoId(mezoId: string): string[];
7
+ //# sourceMappingURL=mezoId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mezoId.d.ts","sourceRoot":"","sources":["../../../src/utils/mezoId.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,GAAG,MAAM,OAAO,CAAA;AAWrC,eAAO,MAAM,2BAA2B,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAyBzE,CAAA;AAEH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAYvD"}
@@ -0,0 +1,41 @@
1
+ // NOTE: This was copied from mezo-portal and is based on the validation from
2
+ // workers/passport-auth/src/utils/mezo-id.ts.
3
+ // Most of these are restrictions for an DNS hostname label (i.e., the part
4
+ // before/after `.` in a full hostname) as outlined in RFC1034
5
+ // (https://www.rfc-editor.org/rfc/rfc1034).
6
+ //
7
+ // A few addenda are made to ensure that nothing can sneak through that could
8
+ // look like an Ethereum or Bitcoin address.
9
+ export const DISALLOWED_MEZO_ID_PATTERNS = [
10
+ // RFC1034.
11
+ { pattern: /^$/, error: "Must not be empty." },
12
+ { pattern: /^.{16,}$/, error: "Must have 15 characters or fewer." },
13
+ {
14
+ pattern: /^[^A-Za-z]/,
15
+ error: "Must start with one of the letters A-Z or a-z.",
16
+ },
17
+ {
18
+ pattern: /[^A-Za-z0-9-]/,
19
+ error: "Must only use letters or numbers (A-Z, a-z, or 0-9), or hyphen (-).",
20
+ },
21
+ { pattern: /-$/, error: "Must not end in a hyphen (-)." },
22
+ // On-chain shenanigan avoidance.
23
+ { pattern: /0x/i, error: "Must not contain 0x." },
24
+ {
25
+ pattern: /^(?:bc1|tb1|[a-z]pub|[a-z]priv)/i,
26
+ error: "Must not start with a Bitcoin magic string.",
27
+ },
28
+ {
29
+ pattern: /^m[0-9]+$/i,
30
+ error: 'No "m" + "numeric string" prefixes.',
31
+ },
32
+ ];
33
+ export function validateMezoId(mezoId) {
34
+ if (!/\.mezo$/.test(mezoId)) {
35
+ return ["Must end with '.mezo'."];
36
+ }
37
+ const mezoIdWithoutSuffix = mezoId.replace(/\.mezo$/, "");
38
+ const errors = DISALLOWED_MEZO_ID_PATTERNS.flatMap(({ pattern, error }) => pattern.test(mezoIdWithoutSuffix) ? [error] : []);
39
+ return errors;
40
+ }
41
+ //# sourceMappingURL=mezoId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mezoId.js","sourceRoot":"","sources":["../../../src/utils/mezoId.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,8CAA8C;AAE9C,2EAA2E;AAC3E,8DAA8D;AAC9D,4CAA4C;AAC5C,EAAE;AACF,6EAA6E;AAC7E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,2BAA2B,GACtC;IACE,WAAW;IACX,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,EAAE;IAC9C,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,mCAAmC,EAAE;IACnE;QACE,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE,gDAAgD;KACxD;IACD;QACE,OAAO,EAAE,eAAe;QACxB,KAAK,EACH,qEAAqE;KACxE;IACD,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,+BAA+B,EAAE;IACzD,iCAAiC;IACjC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;IACjD;QACE,OAAO,EAAE,kCAAkC;QAC3C,KAAK,EAAE,6CAA6C;KACrD;IACD;QACE,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE,qCAAqC;KAC7C;CACF,CAAA;AAEH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAEzD,MAAM,MAAM,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CACxE,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CACjD,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,16 +1,24 @@
1
1
  /**
2
- * Formats a number or bigint into a human-readable string with K, M, B, or T suffix.
2
+ * Formats a number or bigint into compact string with K, M, B, or T suffix.
3
3
  * @param value The number or bigint to format.
4
4
  * @param decimals Number of decimal places to include (ignored for bigint to avoid floating point issues).
5
5
  * @returns The formatted number as a string.
6
6
  */
7
- export declare function formatHumanReadableNumber(value: number | bigint, decimals?: number): string;
7
+ export declare function formatNumberToCompactString(value: number | bigint, decimals?: number): string;
8
+ /**
9
+ * Formats a number or string into a locale-sensitive string with the desired number of decimals.
10
+ * @param value The number or string to format.
11
+ * @param desiredDecimals The number of decimal places to include.
12
+ * @returns The formatted number as a string.
13
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L5-L19
14
+ */
15
+ export declare function formatNumberToLocaleString(value: string | number, desiredDecimals?: number): string;
8
16
  /**
9
17
  * Returns a number rounded up to the desired number of decimals.
10
18
  * @param amount The number to round up.
11
19
  * @param desiredDecimals The number of decimals to round up to.
12
20
  * @returns The rounded up number.
13
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L1-L3
21
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L1-L3
14
22
  */
15
23
  export declare function roundUpNumber(amount: number, desiredDecimals?: number): number;
16
24
  /**
@@ -20,24 +28,38 @@ export declare function roundUpNumber(amount: number, desiredDecimals?: number):
20
28
  * @param fixedPointDecimals The number of decimals in the fixed point bigint.
21
29
  * @param desiredDecimals The number of decimals in the output number.
22
30
  * @returns The floating point number truncated to `desiredDecimals`.
23
- * @see https://github.com/tahowallet/extension/blob/main/background/lib/fixed-point.ts#L216-L239
31
+ * @see https://github.com/tahowallet/extension/blob/f6b26b7cb4a0a0278b1fccc6319626638f1a6dfa/background/lib/fixed-point.ts#L216-L239
24
32
  */
25
33
  export declare function fromFixedPoint(fixedPoint: bigint, fixedPointDecimals: number, desiredDecimals?: number): number;
26
34
  /**
27
- * Display a cryptoAsset amount correctly with desired decimals.
35
+ * Display a token amount correctly with desired decimals.
28
36
  * The function returns a string with a language-sensitive representation of this number.
29
- * - If the amount entered is zero, return the result with the desired decimals.
30
- * For example, 0.00 for a precision of 2.
31
- * - If `formattedAmount` is less than the minimum amount to display
32
- * for the specified precision return information about this.
33
- * For example, <0.01 for a precision of 2.
34
- * - Other amounts are formatted according to the use of the `bigIntToUserAmount` function.
35
- * @param amount The amount of tokens to format.
36
- * @param decimals The number of decimals the cryptoAsset has.
37
+ * @param amount The fixed point number to convert.
38
+ * @param decimals The number of decimals in the fixed point number.
37
39
  * @param desiredDecimals The number of decimals to display.
38
- * @param withRoundUp If true, the amount will be rounded up.
39
- * @returns The formatted cryptoAsset amount.
40
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L57-L87
40
+ * @param withRoundUp Whether to round up the number.
41
+ * @returns The formatted number as a string.
42
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L57-L87
43
+ */
44
+ export declare const fromFixedPointToString: (amount: number | string | bigint, decimals?: number, desiredDecimals?: number, withRoundUp?: boolean) => string;
45
+ /**
46
+ * Converts a floating-point number or string to a bigint representation
47
+ * scaled by the specified number of decimal places (default: 18).
48
+ *
49
+ * This function avoids floating-point precision issues by manually
50
+ * parsing and scaling the number.
51
+ *
52
+ * @param amount - A number or string containing a floating point number.
53
+ * @param decimals - Number of decimals to scale to (default: 18).
54
+ * @returns A bigint representation scaled to the given decimal places.
55
+ * @see https://github.com/thesis/mezo-portal/blob/3bd4f39cb77c39948af2886a6ce7415a0c60307a/dapp/src/shared/utils/numbers.ts#L55
56
+ */
57
+ export declare const fromFloatToBigInt: (amount: string | number, decimals?: number) => bigint;
58
+ /**
59
+ * Utility function to find the maximum value from an array of bigint values.
60
+ * @param values Array of bigint values to find the maximum from.
61
+ * @returns The maximum value from the provided bigint values.
62
+ * @dev Works exactly like `Math.max` but for bigint values.
41
63
  */
42
- export declare function formatTokenAmount(amount: number | string | bigint, decimals?: number, desiredDecimals?: number, withRoundUp?: boolean): string;
64
+ export declare const bigIntMax: (...values: bigint[]) => bigint;
43
65
  //# sourceMappingURL=numbers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../../src/utils/numbers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,GAAE,MAAU,GACnB,MAAM,CAgBR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,SAAI,GAAG,MAAM,CAEzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,SAAI,GAClB,MAAM,CAUR;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAChC,QAAQ,SAAK,EACb,eAAe,SAAI,EACnB,WAAW,UAAQ,UA0BpB"}
1
+ {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../../src/utils/numbers.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,SAAI,GACX,MAAM,CAMR;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,eAAe,SAAI,UAYpB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,SAAI,GAAG,MAAM,CAEzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,SAAI,GAClB,MAAM,CAUR;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,MAAM,GAAG,MAAM,GAAG,MAAM,EAChC,iBAAa,EACb,wBAAmB,EACnB,qBAAmB,WA0BpB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,GAAG,MAAM,EACvB,iBAAa,KACZ,MAmDF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,QAAQ,MAAM,EAAE,WACe,CAAA"}
@@ -1,29 +1,40 @@
1
1
  /**
2
- * Formats a number or bigint into a human-readable string with K, M, B, or T suffix.
2
+ * Formats a number or bigint into compact string with K, M, B, or T suffix.
3
3
  * @param value The number or bigint to format.
4
4
  * @param decimals Number of decimal places to include (ignored for bigint to avoid floating point issues).
5
5
  * @returns The formatted number as a string.
6
6
  */
7
- export function formatHumanReadableNumber(value, decimals = 4) {
8
- const suffixes = ["", "K", "M", "B", "T"];
9
- const numericValue = typeof value === "bigint" ? Number(value) : value;
10
- if (numericValue < 1000)
11
- return numericValue.toFixed(decimals);
12
- const magnitude = Math.floor(Math.log10(numericValue) / 3);
13
- if (magnitude >= suffixes.length) {
14
- const max = 10 ** ((suffixes.length - 1) * 3) * 1000 - 1;
15
- const capped = max / 10 ** ((suffixes.length - 1) * 3);
16
- return `> ${capped.toFixed(0)}${suffixes[suffixes.length - 1]}`;
17
- }
18
- const scaledValue = numericValue / 10 ** (magnitude * 3);
19
- return `${scaledValue.toFixed(decimals)}${suffixes[magnitude]}`;
7
+ export function formatNumberToCompactString(value, decimals = 4) {
8
+ return value.toLocaleString("en-US", {
9
+ notation: "compact",
10
+ compactDisplay: "short",
11
+ maximumFractionDigits: decimals,
12
+ });
13
+ }
14
+ /**
15
+ * Formats a number or string into a locale-sensitive string with the desired number of decimals.
16
+ * @param value The number or string to format.
17
+ * @param desiredDecimals The number of decimal places to include.
18
+ * @returns The formatted number as a string.
19
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L5-L19
20
+ */
21
+ export function formatNumberToLocaleString(value, desiredDecimals = 0) {
22
+ const number = typeof value === "number" ? value : parseFloat(value);
23
+ if (number === 0 && desiredDecimals === 0)
24
+ return "0";
25
+ if (number === 0)
26
+ return `0.${"0".repeat(desiredDecimals)}`;
27
+ return number.toLocaleString("en-US", {
28
+ minimumFractionDigits: desiredDecimals,
29
+ maximumFractionDigits: desiredDecimals,
30
+ });
20
31
  }
21
32
  /**
22
33
  * Returns a number rounded up to the desired number of decimals.
23
34
  * @param amount The number to round up.
24
35
  * @param desiredDecimals The number of decimals to round up to.
25
36
  * @returns The rounded up number.
26
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L1-L3
37
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L1-L3
27
38
  */
28
39
  export function roundUpNumber(amount, desiredDecimals = 2) {
29
40
  return Math.ceil(amount * 10 ** desiredDecimals) / 10 ** desiredDecimals;
@@ -35,9 +46,9 @@ export function roundUpNumber(amount, desiredDecimals = 2) {
35
46
  * @param fixedPointDecimals The number of decimals in the fixed point bigint.
36
47
  * @param desiredDecimals The number of decimals in the output number.
37
48
  * @returns The floating point number truncated to `desiredDecimals`.
38
- * @see https://github.com/tahowallet/extension/blob/main/background/lib/fixed-point.ts#L216-L239
49
+ * @see https://github.com/tahowallet/extension/blob/f6b26b7cb4a0a0278b1fccc6319626638f1a6dfa/background/lib/fixed-point.ts#L216-L239
39
50
  */
40
- export function fromFixedPoint(fixedPoint, fixedPointDecimals, desiredDecimals = 2) {
51
+ export function fromFixedPoint(fixedPoint, fixedPointDecimals, desiredDecimals = 4) {
41
52
  const fixedPointDesiredDecimalsAmount = fixedPoint /
42
53
  10n ** BigInt(Math.max(1, fixedPointDecimals - desiredDecimals));
43
54
  const formattedAmount = Number(fixedPointDesiredDecimalsAmount) /
@@ -45,22 +56,16 @@ export function fromFixedPoint(fixedPoint, fixedPointDecimals, desiredDecimals =
45
56
  return formattedAmount;
46
57
  }
47
58
  /**
48
- * Display a cryptoAsset amount correctly with desired decimals.
59
+ * Display a token amount correctly with desired decimals.
49
60
  * The function returns a string with a language-sensitive representation of this number.
50
- * - If the amount entered is zero, return the result with the desired decimals.
51
- * For example, 0.00 for a precision of 2.
52
- * - If `formattedAmount` is less than the minimum amount to display
53
- * for the specified precision return information about this.
54
- * For example, <0.01 for a precision of 2.
55
- * - Other amounts are formatted according to the use of the `bigIntToUserAmount` function.
56
- * @param amount The amount of tokens to format.
57
- * @param decimals The number of decimals the cryptoAsset has.
61
+ * @param amount The fixed point number to convert.
62
+ * @param decimals The number of decimals in the fixed point number.
58
63
  * @param desiredDecimals The number of decimals to display.
59
- * @param withRoundUp If true, the amount will be rounded up.
60
- * @returns The formatted cryptoAsset amount.
61
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L57-L87
64
+ * @param withRoundUp Whether to round up the number.
65
+ * @returns The formatted number as a string.
66
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L57-L87
62
67
  */
63
- export function formatTokenAmount(amount, decimals = 18, desiredDecimals = 2, withRoundUp = false) {
68
+ export const fromFixedPointToString = (amount, decimals = 18, desiredDecimals = 4, withRoundUp = false) => {
64
69
  const fixedPoint = BigInt(amount);
65
70
  if (fixedPoint === 0n) {
66
71
  return `0.${"0".repeat(desiredDecimals)}`;
@@ -74,8 +79,61 @@ export function formatTokenAmount(amount, decimals = 18, desiredDecimals = 2, wi
74
79
  return `<0.${"0".repeat(desiredDecimals - 1)}1`;
75
80
  }
76
81
  const finalFormattedAmount = withRoundUp
77
- ? roundUpNumber(formattedAmount, desiredDecimals)
82
+ ? Math.ceil(formattedAmount * 10 ** desiredDecimals) / 10 ** desiredDecimals
78
83
  : formattedAmount;
79
- return formatHumanReadableNumber(finalFormattedAmount, desiredDecimals);
80
- }
84
+ return formatNumberToLocaleString(finalFormattedAmount, desiredDecimals);
85
+ };
86
+ /**
87
+ * Converts a floating-point number or string to a bigint representation
88
+ * scaled by the specified number of decimal places (default: 18).
89
+ *
90
+ * This function avoids floating-point precision issues by manually
91
+ * parsing and scaling the number.
92
+ *
93
+ * @param amount - A number or string containing a floating point number.
94
+ * @param decimals - Number of decimals to scale to (default: 18).
95
+ * @returns A bigint representation scaled to the given decimal places.
96
+ * @see https://github.com/thesis/mezo-portal/blob/3bd4f39cb77c39948af2886a6ce7415a0c60307a/dapp/src/shared/utils/numbers.ts#L55
97
+ */
98
+ export const fromFloatToBigInt = (amount, decimals = 18) => {
99
+ const FLOATING_POINT_REGEX = /^-?\d{1,3}(,\d{3})*(\.\d+)?$|^-?\d+(\.\d+)?$/;
100
+ const parseToFixedPointNumber = (floatingPointString) => {
101
+ if (!floatingPointString.match(FLOATING_POINT_REGEX)) {
102
+ return undefined;
103
+ }
104
+ const [whole, decimalsPart, ...extra] = floatingPointString.split(".");
105
+ if (extra.length > 0)
106
+ return undefined;
107
+ const noThousandsSeparatorWhole = whole.replace(/,/g, "");
108
+ const setDecimals = decimalsPart ?? "";
109
+ try {
110
+ return {
111
+ amount: BigInt([noThousandsSeparatorWhole, setDecimals].join("")),
112
+ decimals: setDecimals.length,
113
+ };
114
+ }
115
+ catch {
116
+ return undefined;
117
+ }
118
+ };
119
+ const convertFixedPoint = (fixedPoint, fixedPointDecimals, targetDecimals) => {
120
+ if (fixedPointDecimals >= targetDecimals) {
121
+ return fixedPoint / 10n ** BigInt(fixedPointDecimals - targetDecimals);
122
+ }
123
+ return fixedPoint * 10n ** BigInt(targetDecimals - fixedPointDecimals);
124
+ };
125
+ const parsedAmount = amount.toString();
126
+ const fixedPointAmount = parseToFixedPointNumber(parsedAmount);
127
+ if (typeof fixedPointAmount === "undefined") {
128
+ return 0n;
129
+ }
130
+ return convertFixedPoint(fixedPointAmount.amount, fixedPointAmount.decimals, decimals);
131
+ };
132
+ /**
133
+ * Utility function to find the maximum value from an array of bigint values.
134
+ * @param values Array of bigint values to find the maximum from.
135
+ * @returns The maximum value from the provided bigint values.
136
+ * @dev Works exactly like `Math.max` but for bigint values.
137
+ */
138
+ export const bigIntMax = (...values) => values.reduce((max, value) => (value > max ? value : max));
81
139
  //# sourceMappingURL=numbers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../../src/utils/numbers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAsB,EACtB,WAAmB,CAAC;IAEpB,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAEtE,IAAI,YAAY,GAAG,IAAI;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAE9D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IAE1D,IAAI,SAAS,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAA;QACxD,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACtD,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAA;IACjE,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,GAAG,EAAE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;IACxD,OAAO,GAAG,WAAW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