@mezo-org/passport 0.4.0-dev.6 → 0.4.0-dev.61

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 (220) hide show
  1. package/README.md +18 -22
  2. package/dist/src/api/auth.d.ts.map +1 -1
  3. package/dist/src/api/auth.js +3 -1
  4. package/dist/src/api/auth.js.map +1 -1
  5. package/dist/src/api/client.d.ts +4 -1
  6. package/dist/src/api/client.d.ts.map +1 -1
  7. package/dist/src/api/client.js +9 -2
  8. package/dist/src/api/client.js.map +1 -1
  9. package/dist/src/api/portal.d.ts +3 -9
  10. package/dist/src/api/portal.d.ts.map +1 -1
  11. package/dist/src/api/portal.js +8 -5
  12. package/dist/src/api/portal.js.map +1 -1
  13. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +2 -1
  14. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -1
  15. package/dist/src/components/Dropdown/ConnectedTrigger.js +29 -20
  16. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -1
  17. package/dist/src/components/Dropdown/Content.d.ts +20 -5
  18. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  19. package/dist/src/components/Dropdown/Content.js +19 -57
  20. package/dist/src/components/Dropdown/Content.js.map +1 -1
  21. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -1
  22. package/dist/src/components/Dropdown/DisconnectedTrigger.js +2 -2
  23. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -1
  24. package/dist/src/components/Dropdown/Dropdown.d.ts +17 -8
  25. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  26. package/dist/src/components/Dropdown/Dropdown.js +35 -9
  27. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  28. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  29. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  30. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  31. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  32. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  33. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  34. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  35. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  36. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  37. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  38. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  39. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  40. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  41. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  42. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  43. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  44. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  45. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  46. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  47. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  48. package/dist/src/components/Dropdown/{AccountBalance.d.ts → Root/AccountBalance.d.ts} +2 -1
  49. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  50. package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
  51. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  52. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  53. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  54. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
  55. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  56. package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
  57. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  58. package/dist/src/components/Dropdown/Root/Root.js +57 -0
  59. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  60. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  61. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  62. package/dist/src/components/Dropdown/{AccountAddress.js → Root/WalletAddress.js} +21 -15
  63. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  64. package/dist/src/components/Dropdown/{WelcomeBlock.d.ts → Root/WelcomeBlock.d.ts} +1 -1
  65. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  66. package/dist/src/components/Dropdown/{WelcomeBlock.js → Root/WelcomeBlock.js} +5 -5
  67. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  68. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  69. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  70. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  71. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  72. package/dist/src/config.d.ts +17 -5
  73. package/dist/src/config.d.ts.map +1 -1
  74. package/dist/src/config.js +51 -14
  75. package/dist/src/config.js.map +1 -1
  76. package/dist/src/constants.d.ts +11 -3
  77. package/dist/src/constants.d.ts.map +1 -1
  78. package/dist/src/constants.js +12 -4
  79. package/dist/src/constants.js.map +1 -1
  80. package/dist/src/hooks/index.d.ts +3 -0
  81. package/dist/src/hooks/index.d.ts.map +1 -1
  82. package/dist/src/hooks/index.js +3 -0
  83. package/dist/src/hooks/index.js.map +1 -1
  84. package/dist/src/hooks/useAssetsConversionRates.d.ts +23 -0
  85. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  86. package/dist/src/hooks/useAssetsConversionRates.js +90 -0
  87. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  88. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  89. package/dist/src/hooks/useAuthenticateWithWallet.js +7 -8
  90. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  91. package/dist/src/hooks/useBorrowData.d.ts +82 -0
  92. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  93. package/dist/src/hooks/useBorrowData.js +157 -0
  94. package/dist/src/hooks/useBorrowData.js.map +1 -0
  95. package/dist/src/hooks/useDropdownData.d.ts +37 -34
  96. package/dist/src/hooks/useDropdownData.d.ts.map +1 -1
  97. package/dist/src/hooks/useDropdownData.js +85 -61
  98. package/dist/src/hooks/useDropdownData.js.map +1 -1
  99. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  100. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  101. package/dist/src/hooks/useRefreshPassport.js +44 -0
  102. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  103. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  104. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  105. package/dist/src/hooks/useTokensBalances.js +140 -0
  106. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  107. package/dist/src/hooks/useWalletAccount.d.ts +2 -1
  108. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  109. package/dist/src/hooks/useWalletAccount.js +19 -15
  110. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  111. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  112. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  113. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  114. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  115. package/dist/src/index.d.ts +1 -1
  116. package/dist/src/index.d.ts.map +1 -1
  117. package/dist/src/index.js +1 -1
  118. package/dist/src/index.js.map +1 -1
  119. package/dist/src/lib/contracts/index.d.ts +13 -0
  120. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  121. package/dist/src/lib/contracts/index.js +62 -0
  122. package/dist/src/lib/contracts/index.js.map +1 -0
  123. package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
  124. package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
  125. package/dist/src/lib/contracts/priceOracle.js +52 -0
  126. package/dist/src/lib/contracts/priceOracle.js.map +1 -0
  127. package/dist/src/provider.js +1 -1
  128. package/dist/src/provider.js.map +1 -1
  129. package/dist/src/stores/dropdownStore.d.ts +12 -0
  130. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  131. package/dist/src/stores/dropdownStore.js +13 -0
  132. package/dist/src/stores/dropdownStore.js.map +1 -0
  133. package/dist/src/utils/address.d.ts +1 -1
  134. package/dist/src/utils/address.d.ts.map +1 -1
  135. package/dist/src/utils/address.js +2 -0
  136. package/dist/src/utils/address.js.map +1 -1
  137. package/dist/src/utils/address.test.js +8 -5
  138. package/dist/src/utils/address.test.js.map +1 -1
  139. package/dist/src/utils/cryptoAssets.d.ts +17 -1
  140. package/dist/src/utils/cryptoAssets.d.ts.map +1 -1
  141. package/dist/src/utils/cryptoAssets.js +87 -31
  142. package/dist/src/utils/cryptoAssets.js.map +1 -1
  143. package/dist/src/utils/cryptoAssets.test.js +51 -33
  144. package/dist/src/utils/cryptoAssets.test.js.map +1 -1
  145. package/dist/src/utils/currency.d.ts +8 -0
  146. package/dist/src/utils/currency.d.ts.map +1 -1
  147. package/dist/src/utils/currency.js +11 -0
  148. package/dist/src/utils/currency.js.map +1 -1
  149. package/dist/src/utils/currency.test.js +1 -0
  150. package/dist/src/utils/currency.test.js.map +1 -1
  151. package/dist/src/utils/numbers.d.ts +32 -17
  152. package/dist/src/utils/numbers.d.ts.map +1 -1
  153. package/dist/src/utils/numbers.js +84 -33
  154. package/dist/src/utils/numbers.js.map +1 -1
  155. package/dist/src/utils/numbers.test.js +124 -22
  156. package/dist/src/utils/numbers.test.js.map +1 -1
  157. package/package.json +11 -9
  158. package/src/api/auth.ts +3 -1
  159. package/src/api/client.ts +11 -2
  160. package/src/api/portal.ts +11 -14
  161. package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
  162. package/src/components/Dropdown/Content.tsx +69 -113
  163. package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
  164. package/src/components/Dropdown/Dropdown.tsx +86 -19
  165. package/src/components/Dropdown/ListingItem.tsx +80 -0
  166. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  167. package/src/components/Dropdown/README.md +13 -18
  168. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  169. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  170. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  171. package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
  172. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
  173. package/src/components/Dropdown/Root/Root.tsx +147 -0
  174. package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
  175. package/src/components/Dropdown/{WelcomeBlock.tsx → Root/WelcomeBlock.tsx} +5 -6
  176. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  177. package/src/config.ts +77 -20
  178. package/src/constants.ts +12 -4
  179. package/src/hooks/index.ts +6 -0
  180. package/src/hooks/useAssetsConversionRates.ts +97 -0
  181. package/src/hooks/useAuthenticateWithWallet.ts +8 -11
  182. package/src/hooks/useBorrowData.ts +181 -0
  183. package/src/hooks/useDropdownData.ts +119 -97
  184. package/src/hooks/useRefreshPassport.ts +56 -0
  185. package/src/hooks/useTokensBalances.ts +187 -0
  186. package/src/hooks/useWalletAccount.ts +33 -19
  187. package/src/hooks/useWatchTransferEvents.ts +74 -0
  188. package/src/index.ts +11 -1
  189. package/src/lib/contracts/index.ts +92 -0
  190. package/src/lib/contracts/priceOracle.ts +53 -0
  191. package/src/provider.ts +1 -1
  192. package/src/stores/dropdownStore.ts +20 -0
  193. package/src/utils/address.test.ts +10 -6
  194. package/src/utils/address.ts +5 -3
  195. package/src/utils/cryptoAssets.test.ts +57 -37
  196. package/src/utils/cryptoAssets.ts +113 -35
  197. package/src/utils/currency.test.ts +2 -0
  198. package/src/utils/currency.ts +21 -0
  199. package/src/utils/numbers.test.ts +154 -23
  200. package/src/utils/numbers.ts +112 -34
  201. package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
  202. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
  203. package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
  204. package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
  205. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
  206. package/dist/src/components/Dropdown/AccountAssets.js +0 -44
  207. package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
  208. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
  209. package/dist/src/components/Dropdown/AccountBalance.js +0 -18
  210. package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
  211. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
  212. package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
  213. package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
  214. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
  215. package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
  216. package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
  217. package/src/components/Dropdown/AccountAddress.tsx +0 -111
  218. package/src/components/Dropdown/AccountAssets.tsx +0 -110
  219. package/src/components/Dropdown/AccountBalance.tsx +0 -38
  220. package/src/hooks/useAssetsUSDConversion.ts +0 -31
@@ -1,38 +1,45 @@
1
1
  import {
2
- formatHumanReadableNumber,
3
- formatTokenAmount,
2
+ formatNumberToCompactString,
4
3
  fromFixedPoint,
5
4
  roundUpNumber,
5
+ formatNumberToLocaleString,
6
+ fromFixedPointToString,
6
7
  } from "./numbers"
7
8
 
8
- describe("formatHumanReadableNumber", () => {
9
+ describe("formatNumberToCompactString", () => {
9
10
  it("formats number less than 1000 with decimals", () => {
10
- expect(formatHumanReadableNumber(123.456789, 2)).toBe("123.46")
11
+ expect(formatNumberToCompactString(123.456789, 2)).toBe("123.46")
11
12
  })
12
13
 
13
14
  it("formats thousands with K", () => {
14
- expect(formatHumanReadableNumber(12_345, 2)).toBe("12.35K")
15
+ expect(formatNumberToCompactString(12_345, 2)).toBe("12.35K")
15
16
  })
16
17
 
17
18
  it("formats millions with M", () => {
18
- expect(formatHumanReadableNumber(12_345_678, 2)).toBe("12.35M")
19
+ expect(formatNumberToCompactString(12_345_678, 2)).toBe("12.35M")
19
20
  })
20
21
 
21
22
  it("formats billions with B", () => {
22
- expect(formatHumanReadableNumber(12_345_678_901, 2)).toBe("12.35B")
23
+ expect(formatNumberToCompactString(12_345_678_901, 2)).toBe("12.35B")
23
24
  })
24
25
 
25
26
  it("formats trillions with T", () => {
26
- expect(formatHumanReadableNumber(12_345_678_901_234, 2)).toBe("12.35T")
27
+ expect(formatNumberToCompactString(12_345_678_901_234, 2)).toBe("12.35T")
27
28
  })
28
29
 
29
30
  it("formats bigint as readable number", () => {
30
- expect(formatHumanReadableNumber(1234567890123456789n, 2)).toBe("> 1000T")
31
+ expect(formatNumberToCompactString(1234567890123456789n, 2)).toBe(
32
+ "1,234,567.89T",
33
+ )
31
34
  })
32
35
 
33
36
  it("caps at > 1000T for huge numbers", () => {
34
37
  const hugeNumber = 10 ** 18 // 1e18
35
- expect(formatHumanReadableNumber(hugeNumber, 2)).toBe("> 1000T")
38
+ expect(formatNumberToCompactString(hugeNumber, 2)).toBe("1,000,000T")
39
+ })
40
+
41
+ it("formats numbers with trailing zeros correctly", () => {
42
+ expect(formatNumberToCompactString(1_000, 2)).toBe("1K")
36
43
  })
37
44
  })
38
45
 
@@ -53,7 +60,7 @@ describe("roundUpNumber", () => {
53
60
  describe("fromFixedPoint", () => {
54
61
  it("converts fixed point with 18 decimals to float", () => {
55
62
  const raw = 1234567890000000000n // 1.23456789 ETH in 18 decimals
56
- expect(fromFixedPoint(raw, 18, 4)).toBe(1.2345)
63
+ expect(fromFixedPoint(raw, 18)).toBe(1.2345)
57
64
  })
58
65
 
59
66
  it("converts with truncation to 2 decimals", () => {
@@ -67,23 +74,147 @@ describe("fromFixedPoint", () => {
67
74
  })
68
75
  })
69
76
 
70
- describe("formatTokenAmount", () => {
71
- it("formats zero value with desired decimals", () => {
72
- expect(formatTokenAmount(0, 18, 3)).toBe("0.000")
73
- expect(formatTokenAmount("0", 18, 2)).toBe("0.00")
77
+ describe("formatNumberToLocaleString", () => {
78
+ it("formats zero with 0 decimals", () => {
79
+ expect(formatNumberToLocaleString(0, 0)).toBe("0")
80
+ })
81
+
82
+ it("formats zero with >0 decimals", () => {
83
+ expect(formatNumberToLocaleString(0, 2)).toBe("0.00")
84
+ expect(formatNumberToLocaleString(0, 4)).toBe("0.0000")
85
+ })
86
+
87
+ it("formats small decimal number", () => {
88
+ expect(formatNumberToLocaleString(0.123456, 2)).toBe("0.12")
89
+ expect(formatNumberToLocaleString(0.123456, 4)).toBe("0.1235")
90
+ })
91
+
92
+ it("formats number just above 1", () => {
93
+ expect(formatNumberToLocaleString(1.000001, 3)).toBe("1.000")
94
+ expect(formatNumberToLocaleString(1.234567, 2)).toBe("1.23")
95
+ })
96
+
97
+ it("formats whole number", () => {
98
+ expect(formatNumberToLocaleString(1234, 0)).toBe("1,234")
99
+ expect(formatNumberToLocaleString(1000, 2)).toBe("1,000.00")
74
100
  })
75
101
 
76
- it("returns <0.01 if amount is less than minimum display value", () => {
77
- expect(formatTokenAmount("1", 18, 2)).toBe("<0.01") // 1 wei = 1e-18
102
+ it("formats number with trailing decimal zeroes", () => {
103
+ expect(formatNumberToLocaleString(10.1, 3)).toBe("10.100")
104
+ expect(formatNumberToLocaleString(5.0, 2)).toBe("5.00")
78
105
  })
79
106
 
80
- it("formats a normal value without rounding", () => {
81
- const result = formatTokenAmount("1230000000000000000", 18, 2)
82
- expect(result).toBe("1.23")
107
+ it("formats string input", () => {
108
+ expect(formatNumberToLocaleString("123.456", 2)).toBe("123.46")
109
+ expect(formatNumberToLocaleString("0.00123", 4)).toBe("0.0012")
83
110
  })
84
111
 
85
- it("formats with rounding if withRoundUp = true", () => {
86
- const result = formatTokenAmount("1234560000000000000", 18, 2, true)
87
- expect(result).toBe("1.24")
112
+ it("formats negative number", () => {
113
+ expect(formatNumberToLocaleString(-123.456, 2)).toBe("-123.46")
114
+ expect(formatNumberToLocaleString("-0.00999", 3)).toBe("-0.010")
115
+ })
116
+
117
+ it("formats large number with commas", () => {
118
+ expect(formatNumberToLocaleString(12345678.9, 2)).toBe("12,345,678.90")
119
+ })
120
+
121
+ it("handles max decimals safely", () => {
122
+ expect(formatNumberToLocaleString(1.123456789, 8)).toBe("1.12345679")
123
+ expect(formatNumberToLocaleString("0.000000000000000001", 18)).toBe(
124
+ "0.000000000000000001",
125
+ )
126
+ })
127
+
128
+ it("defaults to 0 decimals if not passed", () => {
129
+ expect(formatNumberToLocaleString(1234.567)).toBe("1,235") // rounds up by default
130
+ })
131
+ })
132
+
133
+ describe("fromFixedPointToString", () => {
134
+ const toFixedPoint = (num: number) => BigInt(Math.round(num * 1e18))
135
+
136
+ const cases = [
137
+ { input: 2.0, expected: "2.000" },
138
+ { input: 2.009, expected: "2.009" },
139
+ { input: 2.01, expected: "2.010" },
140
+ { input: 2.015, expected: "2.016" },
141
+ { input: 2.05, expected: "2.050" },
142
+ { input: 2.09, expected: "2.090" },
143
+ ]
144
+
145
+ describe("withRoundUp: true", () => {
146
+ cases.forEach(({ input, expected }) => {
147
+ it(`formats ${input} → ${expected}`, () => {
148
+ const fixed = toFixedPoint(input)
149
+ expect(fromFixedPointToString(fixed, 18, 3, true)).toBe(expected)
150
+ })
151
+ })
152
+ })
153
+
154
+ describe("withRoundUp: false", () => {
155
+ const noRoundCases = [
156
+ { input: 2.0099, expected: "2.009" },
157
+ { input: 2.0159, expected: "2.015" },
158
+ { input: 2.0101, expected: "2.010" },
159
+ { input: 2.0199, expected: "2.019" },
160
+ ]
161
+
162
+ noRoundCases.forEach(({ input, expected }) => {
163
+ it(`formats ${input} → ${expected} (no rounding)`, () => {
164
+ const fixed = toFixedPoint(input)
165
+ expect(fromFixedPointToString(fixed, 18, 3, false)).toBe(expected)
166
+ })
167
+ })
168
+ })
169
+
170
+ describe("zero handling", () => {
171
+ it("formats 0 → 0.000 (3 decimals)", () => {
172
+ expect(fromFixedPointToString(0n, 18, 3)).toBe("0.000")
173
+ })
174
+
175
+ it("formats 0 → 0.0000 (4 decimals)", () => {
176
+ expect(fromFixedPointToString(0n, 18, 4)).toBe("0.0000")
177
+ })
178
+ })
179
+
180
+ describe("very small numbers below display threshold", () => {
181
+ it("returns <0.0001 for small number (3 decimals)", () => {
182
+ const small = BigInt(123) // ~1.23e-16
183
+ expect(fromFixedPointToString(small, 18, 4)).toBe("<0.0001")
184
+ })
185
+
186
+ it("returns <0.01 for small number with only 2 decimals", () => {
187
+ const tiny = BigInt(9999999999999) // <0.01
188
+ expect(fromFixedPointToString(tiny, 18, 2)).toBe("<0.01")
189
+ })
190
+ })
191
+
192
+ describe("input types", () => {
193
+ it("accepts bigint", () => {
194
+ const amount = 2100000000000000000n
195
+ expect(fromFixedPointToString(amount, 18, 3)).toBe("2.100")
196
+ })
197
+
198
+ it("accepts string", () => {
199
+ expect(fromFixedPointToString("2000000000000000000", 18, 3)).toBe("2.000")
200
+ })
201
+
202
+ it("accepts number", () => {
203
+ expect(fromFixedPointToString(Number("1000000000000000000"), 18, 3)).toBe(
204
+ "1.000",
205
+ )
206
+ })
207
+ })
208
+
209
+ describe("high values", () => {
210
+ it("formats 1_000_000.123456789 correctly", () => {
211
+ const big = toFixedPoint(1_000_000.123456789)
212
+ expect(fromFixedPointToString(big, 18, 6)).toBe("1,000,000.123456")
213
+ })
214
+
215
+ it("formats 1e12 ETH", () => {
216
+ const big = BigInt("1000000000000000000000000000000")
217
+ expect(fromFixedPointToString(big, 18, 2)).toBe("1,000,000,000,000.00")
218
+ })
88
219
  })
89
220
  })
@@ -1,28 +1,44 @@
1
+ type DesiredDecimals = Intl.NumberFormatOptions &
2
+ BigIntToLocaleStringOptions["minimumFractionDigits"]
3
+
1
4
  /**
2
- * Formats a number or bigint into a human-readable string with K, M, B, or T suffix.
5
+ * Formats a number or bigint into compact string with K, M, B, or T suffix.
3
6
  * @param value The number or bigint to format.
4
7
  * @param decimals Number of decimal places to include (ignored for bigint to avoid floating point issues).
5
8
  * @returns The formatted number as a string.
6
9
  */
7
- export function formatHumanReadableNumber(
10
+ export function formatNumberToCompactString(
8
11
  value: number | bigint,
9
- decimals: number = 4,
12
+ decimals = 4,
10
13
  ): string {
11
- const suffixes = ["", "K", "M", "B", "T"]
12
- const numericValue = typeof value === "bigint" ? Number(value) : value
14
+ return value.toLocaleString("en-US", {
15
+ notation: "compact",
16
+ compactDisplay: "short",
17
+ maximumFractionDigits: decimals as DesiredDecimals,
18
+ })
19
+ }
13
20
 
14
- if (numericValue < 1000) return numericValue.toFixed(decimals)
21
+ /**
22
+ * Formats a number or string into a locale-sensitive string with the desired number of decimals.
23
+ * @param value The number or string to format.
24
+ * @param desiredDecimals The number of decimal places to include.
25
+ * @returns The formatted number as a string.
26
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L5-L19
27
+ */
28
+ export function formatNumberToLocaleString(
29
+ value: string | number,
30
+ desiredDecimals = 0,
31
+ ) {
32
+ const number = typeof value === "number" ? value : parseFloat(value)
15
33
 
16
- const magnitude = Math.floor(Math.log10(numericValue) / 3)
34
+ if (number === 0 && desiredDecimals === 0) return "0"
17
35
 
18
- if (magnitude >= suffixes.length) {
19
- const max = 10 ** ((suffixes.length - 1) * 3) * 1000 - 1
20
- const capped = max / 10 ** ((suffixes.length - 1) * 3)
21
- return `> ${capped.toFixed(0)}${suffixes[suffixes.length - 1]}`
22
- }
36
+ if (number === 0) return `0.${"0".repeat(desiredDecimals)}`
23
37
 
24
- const scaledValue = numericValue / 10 ** (magnitude * 3)
25
- return `${scaledValue.toFixed(decimals)}${suffixes[magnitude]}`
38
+ return number.toLocaleString("en-US", {
39
+ minimumFractionDigits: desiredDecimals,
40
+ maximumFractionDigits: desiredDecimals,
41
+ })
26
42
  }
27
43
 
28
44
  /**
@@ -30,7 +46,7 @@ export function formatHumanReadableNumber(
30
46
  * @param amount The number to round up.
31
47
  * @param desiredDecimals The number of decimals to round up to.
32
48
  * @returns The rounded up number.
33
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L1-L3
49
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L1-L3
34
50
  */
35
51
  export function roundUpNumber(amount: number, desiredDecimals = 2): number {
36
52
  return Math.ceil(amount * 10 ** desiredDecimals) / 10 ** desiredDecimals
@@ -43,12 +59,12 @@ export function roundUpNumber(amount: number, desiredDecimals = 2): number {
43
59
  * @param fixedPointDecimals The number of decimals in the fixed point bigint.
44
60
  * @param desiredDecimals The number of decimals in the output number.
45
61
  * @returns The floating point number truncated to `desiredDecimals`.
46
- * @see https://github.com/tahowallet/extension/blob/main/background/lib/fixed-point.ts#L216-L239
62
+ * @see https://github.com/tahowallet/extension/blob/f6b26b7cb4a0a0278b1fccc6319626638f1a6dfa/background/lib/fixed-point.ts#L216-L239
47
63
  */
48
64
  export function fromFixedPoint(
49
65
  fixedPoint: bigint,
50
66
  fixedPointDecimals: number,
51
- desiredDecimals = 2,
67
+ desiredDecimals = 4,
52
68
  ): number {
53
69
  const fixedPointDesiredDecimalsAmount =
54
70
  fixedPoint /
@@ -62,27 +78,21 @@ export function fromFixedPoint(
62
78
  }
63
79
 
64
80
  /**
65
- * Display a cryptoAsset amount correctly with desired decimals.
81
+ * Display a token amount correctly with desired decimals.
66
82
  * The function returns a string with a language-sensitive representation of this number.
67
- * - If the amount entered is zero, return the result with the desired decimals.
68
- * For example, 0.00 for a precision of 2.
69
- * - If `formattedAmount` is less than the minimum amount to display
70
- * for the specified precision return information about this.
71
- * For example, <0.01 for a precision of 2.
72
- * - Other amounts are formatted according to the use of the `bigIntToUserAmount` function.
73
- * @param amount The amount of tokens to format.
74
- * @param decimals The number of decimals the cryptoAsset has.
83
+ * @param amount The fixed point number to convert.
84
+ * @param decimals The number of decimals in the fixed point number.
75
85
  * @param desiredDecimals The number of decimals to display.
76
- * @param withRoundUp If true, the amount will be rounded up.
77
- * @returns The formatted cryptoAsset amount.
78
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L57-L87
86
+ * @param withRoundUp Whether to round up the number.
87
+ * @returns The formatted number as a string.
88
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L57-L87
79
89
  */
80
- export function formatTokenAmount(
90
+ export const fromFixedPointToString = (
81
91
  amount: number | string | bigint,
82
92
  decimals = 18,
83
- desiredDecimals = 2,
93
+ desiredDecimals = 4,
84
94
  withRoundUp = false,
85
- ) {
95
+ ) => {
86
96
  const fixedPoint = BigInt(amount)
87
97
 
88
98
  if (fixedPoint === 0n) {
@@ -104,7 +114,75 @@ export function formatTokenAmount(
104
114
  }
105
115
 
106
116
  const finalFormattedAmount = withRoundUp
107
- ? roundUpNumber(formattedAmount, desiredDecimals)
117
+ ? Math.ceil(formattedAmount * 10 ** desiredDecimals) / 10 ** desiredDecimals
108
118
  : formattedAmount
109
- return formatHumanReadableNumber(finalFormattedAmount, desiredDecimals)
119
+ return formatNumberToLocaleString(finalFormattedAmount, desiredDecimals)
120
+ }
121
+
122
+ /**
123
+ * Converts a floating-point number or string to a bigint representation
124
+ * scaled by the specified number of decimal places (default: 18).
125
+ *
126
+ * This function avoids floating-point precision issues by manually
127
+ * parsing and scaling the number.
128
+ *
129
+ * @param amount - A number or string containing a floating point number.
130
+ * @param decimals - Number of decimals to scale to (default: 18).
131
+ * @returns A bigint representation scaled to the given decimal places.
132
+ * @see https://github.com/thesis/mezo-portal/blob/3bd4f39cb77c39948af2886a6ce7415a0c60307a/dapp/src/shared/utils/numbers.ts#L55
133
+ */
134
+ export const fromFloatToBigInt = (
135
+ amount: string | number,
136
+ decimals = 18,
137
+ ): bigint => {
138
+ const FLOATING_POINT_REGEX = /^-?\d{1,3}(,\d{3})*(\.\d+)?$|^-?\d+(\.\d+)?$/
139
+
140
+ const parseToFixedPointNumber = (
141
+ floatingPointString: string,
142
+ ): { amount: bigint; decimals: number } | undefined => {
143
+ if (!floatingPointString.match(FLOATING_POINT_REGEX)) {
144
+ return undefined
145
+ }
146
+
147
+ const [whole, decimalsPart, ...extra] = floatingPointString.split(".")
148
+
149
+ if (extra.length > 0) return undefined
150
+
151
+ const noThousandsSeparatorWhole = whole.replace(/,/g, "")
152
+ const setDecimals = decimalsPart ?? ""
153
+
154
+ try {
155
+ return {
156
+ amount: BigInt([noThousandsSeparatorWhole, setDecimals].join("")),
157
+ decimals: setDecimals.length,
158
+ }
159
+ } catch {
160
+ return undefined
161
+ }
162
+ }
163
+
164
+ const convertFixedPoint = (
165
+ fixedPoint: bigint,
166
+ fixedPointDecimals: number,
167
+ targetDecimals: number,
168
+ ): bigint => {
169
+ if (fixedPointDecimals >= targetDecimals) {
170
+ return fixedPoint / 10n ** BigInt(fixedPointDecimals - targetDecimals)
171
+ }
172
+
173
+ return fixedPoint * 10n ** BigInt(targetDecimals - fixedPointDecimals)
174
+ }
175
+
176
+ const parsedAmount = amount.toString()
177
+ const fixedPointAmount = parseToFixedPointNumber(parsedAmount)
178
+
179
+ if (typeof fixedPointAmount === "undefined") {
180
+ return 0n
181
+ }
182
+
183
+ return convertFixedPoint(
184
+ fixedPointAmount.amount,
185
+ fixedPointAmount.decimals,
186
+ decimals,
187
+ )
110
188
  }
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- type AccountAddressProps = {
3
- address: string;
4
- type: "bitcoin" | "evm";
5
- };
6
- export default function AccountAddress(props: AccountAddressProps): React.JSX.Element;
7
- export {};
8
- //# sourceMappingURL=AccountAddress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountAddress.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAddress.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,GAAG,KAAK,CAAA;CACxB,CAAA;AAID,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBA0FhE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountAddress.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAddress.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,QAAQ,EAClB,cAAc,IAAI,QAAQ,EAC1B,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAOzD,oCAAoC;AAEpC,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAA0B;IAC/D,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAE/B,MAAM,EAAE,WAAW,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAC5C,MAAM,gBAAgB,GAAG,qBAAqB,CAC5C,OAAO,EACP,IAAI,EACJ,WAAW,KAAK,SAAS,CAC1B,CAAA;IACD,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,cAAc,CAC1C,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK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,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC3B,SAAS,EAAE;wBACT,GAAG,EAAE;4BACH,KAAK,EAAE;gCACL,MAAM,EAAE,cAAc;gCACtB,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ;6BAClC;yBACF;qBACF,GACD,CACa,CACX;QACR,oBAAC,QAAQ,IACP,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC3B,SAAS,EAAE;gBACT,GAAG,EAAE;oBACH,KAAK,EAAE;wBACL,UAAU,EAAE,MAAM;wBAClB,MAAM,EAAE,cAAc;qBACvB;iBACF;aACF,GACD,CACI,CACT,CAAA;AACH,CAAC"}
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import { CryptoAssetKey } from "../../utils/cryptoAssets";
3
- type AccountAssetsProps = {
4
- label: string | React.ReactNode;
5
- assets: {
6
- type: CryptoAssetKey;
7
- decimals: number;
8
- balance: number;
9
- balanceInUsd: number;
10
- }[];
11
- };
12
- export default function AccountAssets(props: AccountAssetsProps): React.JSX.Element | null;
13
- export {};
14
- //# sourceMappingURL=AccountAssets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountAssets.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAssets.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAkB,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,cAAc,EAAkB,MAAM,0BAA0B,CAAA;AAGzE,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,cAAc,CAAA;QACpB,QAAQ,EAAE,MAAM,CAAA;QAChB,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;KACrB,EAAE,CAAA;CACJ,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,kBAAkB,4BAyF9D"}
@@ -1,44 +0,0 @@
1
- import { Block, LabelSmall, ParagraphSmall, useStyletron, } from "@mezo-org/mezo-clay";
2
- import React, { useMemo } from "react";
3
- import { getCryptoAsset } from "../../utils/cryptoAssets";
4
- import { formatUsd } from "../../utils/currency";
5
- export default function AccountAssets(props) {
6
- const { label, assets } = props;
7
- const [, theme] = useStyletron();
8
- const assetsData = useMemo(() => assets.map((token) => {
9
- const { name, symbol, icon } = getCryptoAsset(token.type);
10
- return {
11
- ...token,
12
- icon,
13
- label: name,
14
- symbol,
15
- };
16
- }), [assets]);
17
- const labelContent = typeof label === "string" ? (React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray800 }, label)) : (label);
18
- if (assetsData.length === 0) {
19
- return null;
20
- }
21
- return (React.createElement(Block, { padding: `0 ${theme.sizing.scale500}` },
22
- React.createElement(Block, { margin: `${theme.sizing.scale400} 0` }, labelContent),
23
- React.createElement(Block, { as: "ul", marginBottom: theme.sizing.scale600, padding: 0, display: "flex", flexDirection: "column", overrides: {
24
- Block: {
25
- style: {
26
- gap: theme.sizing.scale100,
27
- },
28
- },
29
- } }, assetsData.map((asset) => (React.createElement(Block, { as: "li", key: `${asset.type}-${asset.balance}`, display: "flex", justifyContent: "space-between", alignItems: "center", margin: `${theme.sizing.scale100} 0` },
30
- React.createElement(asset.icon, { size: theme.sizing.scale800, overrides: {
31
- Svg: {
32
- style: {
33
- marginRight: theme.sizing.scale500,
34
- },
35
- },
36
- } }),
37
- React.createElement(Block, { flex: 1 },
38
- React.createElement(LabelSmall, { margin: 0 }, asset.label),
39
- React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray500 }, asset.symbol)),
40
- React.createElement(Block, { display: "flex", alignItems: "end", flexDirection: "column" },
41
- React.createElement(LabelSmall, { margin: 0 }, asset.balance),
42
- React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray500 }, formatUsd(asset.balanceInUsd)))))))));
43
- }
44
- //# sourceMappingURL=AccountAssets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountAssets.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAssets.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAkB,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAYhD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAyB;IAC7D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IAE/B,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,YAAY,EAAE,CAAA;IAEhC,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CACH,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEzD,OAAO;YACL,GAAG,KAAK;YACR,IAAI;YACJ,KAAK,EAAE,IAAI;YACX,MAAM;SACP,CAAA;IACH,CAAC,CAAC,EACJ,CAAC,MAAM,CAAC,CACT,CAAA;IAED,MAAM,YAAY,GAChB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC1B,oBAAC,cAAc,IAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,IACnD,KAAK,CACS,CAClB,CAAC,CAAC,CAAC,CACF,KAAK,CACN,CAAA;IAEH,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CACL,oBAAC,KAAK,IAAC,OAAO,EAAE,KAAK,KAAK,CAAC,MAAM,CAA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AAC,aAAa,EAAC,QAAQ;gBAC3D,oBAAC,UAAU,IAAC,MAAM,EAAE,CAAC,IAAG,KAAK,CAAC,OAAO,CAAc;gBACnD,oBAAC,cAAc,IAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,IACnD,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,CACf,CACX,CACF,CACT,CAAC,CACI,CACF,CACT,CAAA;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountBalance.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountBalance.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAwBhE"}
@@ -1,18 +0,0 @@
1
- import { Block, HeadingSmall, ParagraphSmall, useStyletron, } from "@mezo-org/mezo-clay";
2
- import React from "react";
3
- import { formatUsd } from "../../utils/currency";
4
- export default function AccountBalance(props) {
5
- const { amount } = props;
6
- const formattedUsdBalance = formatUsd(amount);
7
- const [, theme] = useStyletron();
8
- return (React.createElement(Block, { padding: theme.sizing.scale500, overrides: {
9
- Block: {
10
- style: {
11
- borderBottom: `1px solid ${theme.colors.backgroundPrimary}`,
12
- },
13
- },
14
- } },
15
- React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray800 }, "Available balance"),
16
- React.createElement(HeadingSmall, { margin: 0 }, formattedUsdBalance)));
17
- }
18
- //# sourceMappingURL=AccountBalance.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountBalance.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountBalance.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAMhD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAA0B;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IAExB,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;IAE7C,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,YAAY,EAAE,CAAA;IAEhC,OAAO,CACL,oBAAC,KAAK,IACJ,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC9B,SAAS,EAAE;YACT,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,YAAY,EAAE,aAAa,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE;iBAC5D;aACF;SACF;QAED,oBAAC,cAAc,IAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,wBAErC;QACjB,oBAAC,YAAY,IAAC,MAAM,EAAE,CAAC,IAAG,mBAAmB,CAAgB,CACvD,CACT,CAAA;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WelcomeBlock.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/WelcomeBlock.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBAyE5D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WelcomeBlock.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/WelcomeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5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AK,IAAC,EAAE,EAAC,MAAM,IAAE,IAAI,CAAS;gBAC/B,oBAAC,KAAK,IAAC,EAAE,EAAC,MAAM,EAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,IACzC,UAAU,CACL,CACK;YAEf,oBAAC,UAAU,IACT,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,QAAQ,EACnB,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe,EACnC,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,KAAK,EAAE;4BACL,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ;yBAC3B;qBACF;iBACF;gBAED,oBAAC,IAAI,IACH,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,EAClC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,GAC3B;gBACD,yBAAyB,CAAC,WAAW,EAAE,CAAC,CAAC,CAC/B,CACP,CACF,CACT,CAAA;AACH,CAAC"}
@@ -1,8 +0,0 @@
1
- import { UseBaseQueryOptions } from "@tanstack/react-query";
2
- type AssetsUsdConversion = {
3
- btcUsd: string;
4
- ethUsd: string;
5
- };
6
- export declare function useAssetsUsdConversion(useQueryOptions?: Partial<UseBaseQueryOptions<AssetsUsdConversion>>): import("@tanstack/react-query").UseQueryResult<AssetsUsdConversion, Error>;
7
- export {};
8
- //# sourceMappingURL=useAssetsUSDConversion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAssetsUSDConversion.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAssetsUSDConversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAKrE,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,sBAAsB,CACpC,eAAe,GAAE,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAM,8EAmBxE"}
@@ -1,21 +0,0 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { ONE_MINUTE_MS } from "../utils/time";
3
- import { QUERY_KEYS } from "./constants";
4
- import { usePortalApiClient } from "./usePortalApiClient";
5
- export function useAssetsUsdConversion(useQueryOptions = {}) {
6
- const portalApiClient = usePortalApiClient();
7
- return useQuery({
8
- queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
9
- queryFn: async () => {
10
- const { currentUsdPerBtc, currentUsdPerEth } = await portalApiClient.getPortalStatistics();
11
- return {
12
- btcUsd: currentUsdPerBtc,
13
- ethUsd: currentUsdPerEth,
14
- };
15
- },
16
- staleTime: 30 * ONE_MINUTE_MS,
17
- retry: 1,
18
- ...useQueryOptions,
19
- });
20
- }
21
- //# sourceMappingURL=useAssetsUSDConversion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAssetsUSDConversion.js","sourceRoot":"","sources":["../../../src/hooks/useAssetsUSDConversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAOzD,MAAM,UAAU,sBAAsB,CACpC,kBAAqE,EAAE;IAEvE,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAE5C,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC;QAC5C,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAC1C,MAAM,eAAe,CAAC,mBAAmB,EAAE,CAAA;YAE7C,OAAO;gBACL,MAAM,EAAE,gBAAgB;gBACxB,MAAM,EAAE,gBAAgB;aACzB,CAAA;QACH,CAAC;QACD,SAAS,EAAE,EAAE,GAAG,aAAa;QAC7B,KAAK,EAAE,CAAC;QACR,GAAG,eAAe;KACnB,CAAC,CAAA;AACJ,CAAC"}