@mezo-org/passport 0.4.0-dev.9 → 0.5.1-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) 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 +4 -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 +9 -6
  26. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  27. package/dist/src/components/Dropdown/Dropdown.js +10 -10
  28. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  29. package/dist/src/components/Dropdown/ListingItem.d.ts +14 -0
  30. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/ListingItem.js +42 -0
  32. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  33. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +8 -0
  34. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  35. package/dist/src/components/Dropdown/NestedViewLayout.js +32 -0
  36. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  37. package/dist/src/components/Dropdown/Receive/Receive.d.ts +4 -0
  38. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/Receive/Receive.js +64 -0
  40. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  41. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +4 -0
  42. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  43. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +49 -0
  44. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  45. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +6 -0
  46. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  47. package/dist/src/components/Dropdown/Root/AccountBalance.js +35 -0
  48. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  49. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
  50. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
  51. package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
  52. package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
  53. package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
  54. package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
  55. package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
  56. package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
  57. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
  58. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
  59. package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
  60. package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
  61. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +8 -0
  62. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  63. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +43 -0
  64. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  65. package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
  66. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  67. package/dist/src/components/Dropdown/Root/Root.js +45 -0
  68. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  69. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +4 -0
  70. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  71. package/dist/src/components/Dropdown/Root/WalletAddress.js +66 -0
  72. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  73. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +6 -0
  74. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  75. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +88 -0
  76. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  77. package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
  78. package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
  79. package/dist/src/components/Dropdown/SlotNumber.js +67 -0
  80. package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
  81. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  82. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  83. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  84. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  85. package/dist/src/config.d.ts +19 -5
  86. package/dist/src/config.d.ts.map +1 -1
  87. package/dist/src/config.js +58 -14
  88. package/dist/src/config.js.map +1 -1
  89. package/dist/src/constants.d.ts +11 -3
  90. package/dist/src/constants.d.ts.map +1 -1
  91. package/dist/src/constants.js +12 -4
  92. package/dist/src/constants.js.map +1 -1
  93. package/dist/src/hooks/index.d.ts +4 -0
  94. package/dist/src/hooks/index.d.ts.map +1 -1
  95. package/dist/src/hooks/index.js +4 -0
  96. package/dist/src/hooks/index.js.map +1 -1
  97. package/dist/src/hooks/useAssetsConversionRates.d.ts +18 -0
  98. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  99. package/dist/src/hooks/useAssetsConversionRates.js +67 -0
  100. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  101. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +13 -13
  102. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  103. package/dist/src/hooks/useAuthenticateWithWallet.js +9 -8
  104. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  105. package/dist/src/hooks/useBorrowData.d.ts +108 -0
  106. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  107. package/dist/src/hooks/useBorrowData.js +201 -0
  108. package/dist/src/hooks/useBorrowData.js.map +1 -0
  109. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  110. package/dist/src/hooks/useCreateAccount.js +22 -1
  111. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  112. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  113. package/dist/src/hooks/useGetCurrentAccount.js +4 -6
  114. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  115. package/dist/src/hooks/useLinkAccount.d.ts +19 -13
  116. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  117. package/dist/src/hooks/useLinkAccount.js +20 -1
  118. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  119. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  120. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  121. package/dist/src/hooks/useRefreshPassport.js +44 -0
  122. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  123. package/dist/src/hooks/useSignInWithWallet.d.ts +13 -13
  124. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  125. package/dist/src/hooks/useSignUpWithWallet.d.ts +13 -13
  126. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
  127. package/dist/src/hooks/useTokensBalances.d.ts +75 -0
  128. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  129. package/dist/src/hooks/useTokensBalances.js +181 -0
  130. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  131. package/dist/src/hooks/useValidateMezoId.d.ts +8 -0
  132. package/dist/src/hooks/useValidateMezoId.d.ts.map +1 -0
  133. package/dist/src/hooks/useValidateMezoId.js +24 -0
  134. package/dist/src/hooks/useValidateMezoId.js.map +1 -0
  135. package/dist/src/hooks/useWalletAccount.d.ts +2 -1
  136. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  137. package/dist/src/hooks/useWalletAccount.js +20 -15
  138. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  139. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  140. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  141. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  142. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  143. package/dist/src/index.d.ts +2 -1
  144. package/dist/src/index.d.ts.map +1 -1
  145. package/dist/src/index.js +2 -1
  146. package/dist/src/index.js.map +1 -1
  147. package/dist/src/lib/contracts/index.d.ts +13 -0
  148. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  149. package/dist/src/lib/contracts/index.js +66 -0
  150. package/dist/src/lib/contracts/index.js.map +1 -0
  151. package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
  152. package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
  153. package/dist/src/lib/contracts/priceOracle.js +52 -0
  154. package/dist/src/lib/contracts/priceOracle.js.map +1 -0
  155. package/dist/src/provider.d.ts +7 -1
  156. package/dist/src/provider.d.ts.map +1 -1
  157. package/dist/src/provider.js +4 -1
  158. package/dist/src/provider.js.map +1 -1
  159. package/dist/src/stores/dropdownStore.d.ts +12 -0
  160. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  161. package/dist/src/stores/dropdownStore.js +13 -0
  162. package/dist/src/stores/dropdownStore.js.map +1 -0
  163. package/dist/src/utils/address.d.ts +1 -1
  164. package/dist/src/utils/address.d.ts.map +1 -1
  165. package/dist/src/utils/address.js +2 -0
  166. package/dist/src/utils/address.js.map +1 -1
  167. package/dist/src/utils/address.test.js +8 -5
  168. package/dist/src/utils/address.test.js.map +1 -1
  169. package/dist/src/utils/assets.d.ts +145 -0
  170. package/dist/src/utils/assets.d.ts.map +1 -0
  171. package/dist/src/utils/assets.js +100 -0
  172. package/dist/src/utils/assets.js.map +1 -0
  173. package/dist/src/utils/assets.test.d.ts +2 -0
  174. package/dist/src/utils/assets.test.d.ts.map +1 -0
  175. package/dist/src/utils/assets.test.js +46 -0
  176. package/dist/src/utils/assets.test.js.map +1 -0
  177. package/dist/src/utils/currency.d.ts +13 -2
  178. package/dist/src/utils/currency.d.ts.map +1 -1
  179. package/dist/src/utils/currency.js +22 -8
  180. package/dist/src/utils/currency.js.map +1 -1
  181. package/dist/src/utils/currency.test.js +44 -1
  182. package/dist/src/utils/currency.test.js.map +1 -1
  183. package/dist/src/utils/mezoId.d.ts +7 -0
  184. package/dist/src/utils/mezoId.d.ts.map +1 -0
  185. package/dist/src/utils/mezoId.js +41 -0
  186. package/dist/src/utils/mezoId.js.map +1 -0
  187. package/dist/src/utils/number2.d.ts +106 -0
  188. package/dist/src/utils/number2.d.ts.map +1 -0
  189. package/dist/src/utils/number2.js +289 -0
  190. package/dist/src/utils/number2.js.map +1 -0
  191. package/dist/src/utils/numbers.d.ts +15 -33
  192. package/dist/src/utils/numbers.d.ts.map +1 -1
  193. package/dist/src/utils/numbers.js +26 -70
  194. package/dist/src/utils/numbers.js.map +1 -1
  195. package/dist/src/utils/numbers.test.js +46 -42
  196. package/dist/src/utils/numbers.test.js.map +1 -1
  197. package/dist/src/utils/siww.d.ts +1 -0
  198. package/dist/src/utils/siww.d.ts.map +1 -1
  199. package/dist/src/utils/siww.js +50 -12
  200. package/dist/src/utils/siww.js.map +1 -1
  201. package/dist/src/utils/wagmi.d.ts +3 -0
  202. package/dist/src/utils/wagmi.d.ts.map +1 -0
  203. package/dist/src/utils/wagmi.js +7 -0
  204. package/dist/src/utils/wagmi.js.map +1 -0
  205. package/dist/src/wallet/index.d.ts +1 -1
  206. package/dist/src/wallet/index.d.ts.map +1 -1
  207. package/dist/src/wallet/index.js +1 -1
  208. package/dist/src/wallet/index.js.map +1 -1
  209. package/package.json +11 -8
  210. package/src/api/auth.ts +8 -4
  211. package/src/api/client.ts +11 -2
  212. package/src/api/portal.ts +11 -14
  213. package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
  214. package/src/components/Dropdown/Content.tsx +26 -121
  215. package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
  216. package/src/components/Dropdown/Dropdown.tsx +29 -17
  217. package/src/components/Dropdown/ListingItem.tsx +176 -0
  218. package/src/components/Dropdown/NestedViewLayout.tsx +87 -0
  219. package/src/components/Dropdown/README.md +10 -18
  220. package/src/components/Dropdown/Receive/Receive.tsx +144 -0
  221. package/src/components/Dropdown/Root/AccountAddressActions.tsx +99 -0
  222. package/src/components/Dropdown/Root/AccountBalance.tsx +75 -0
  223. package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
  224. package/src/components/Dropdown/Root/AccountError.tsx +34 -0
  225. package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
  226. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +85 -0
  227. package/src/components/Dropdown/Root/Root.tsx +77 -0
  228. package/src/components/Dropdown/Root/WalletAddress.tsx +123 -0
  229. package/src/components/Dropdown/Root/WelcomeBlock.tsx +173 -0
  230. package/src/components/Dropdown/SlotNumber.tsx +131 -0
  231. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  232. package/src/config.ts +88 -20
  233. package/src/constants.ts +12 -4
  234. package/src/hooks/index.ts +7 -0
  235. package/src/hooks/useAssetsConversionRates.ts +79 -0
  236. package/src/hooks/useAuthenticateWithWallet.ts +30 -14
  237. package/src/hooks/useBorrowData.ts +246 -0
  238. package/src/hooks/useCreateAccount.ts +29 -2
  239. package/src/hooks/useGetCurrentAccount.ts +5 -7
  240. package/src/hooks/useLinkAccount.ts +37 -4
  241. package/src/hooks/useRefreshPassport.ts +56 -0
  242. package/src/hooks/useSignInWithWallet.ts +2 -2
  243. package/src/hooks/useSignUpWithWallet.ts +2 -2
  244. package/src/hooks/useTokensBalances.ts +265 -0
  245. package/src/hooks/useValidateMezoId.ts +31 -0
  246. package/src/hooks/useWalletAccount.ts +32 -20
  247. package/src/hooks/useWatchTransferEvents.ts +74 -0
  248. package/src/index.ts +12 -1
  249. package/src/lib/contracts/index.ts +99 -0
  250. package/src/lib/contracts/priceOracle.ts +53 -0
  251. package/src/provider.ts +11 -3
  252. package/src/stores/dropdownStore.ts +20 -0
  253. package/src/utils/address.test.ts +10 -6
  254. package/src/utils/address.ts +5 -3
  255. package/src/utils/assets.test.ts +57 -0
  256. package/src/utils/assets.ts +103 -0
  257. package/src/utils/currency.test.ts +77 -1
  258. package/src/utils/currency.ts +35 -9
  259. package/src/utils/mezoId.ts +51 -0
  260. package/src/utils/number2.ts +419 -0
  261. package/src/utils/numbers.test.ts +49 -42
  262. package/src/utils/numbers.ts +33 -95
  263. package/src/utils/siww.ts +71 -16
  264. package/src/utils/wagmi.ts +12 -0
  265. package/src/wallet/index.ts +3 -2
  266. package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
  267. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
  268. package/dist/src/components/Dropdown/AccountAddress.js +0 -58
  269. package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
  270. package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
  271. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
  272. package/dist/src/components/Dropdown/AccountAssets.js +0 -44
  273. package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
  274. package/dist/src/components/Dropdown/AccountBalance.d.ts +0 -7
  275. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
  276. package/dist/src/components/Dropdown/AccountBalance.js +0 -18
  277. package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
  278. package/dist/src/components/Dropdown/WelcomeBlock.d.ts +0 -8
  279. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
  280. package/dist/src/components/Dropdown/WelcomeBlock.js +0 -44
  281. package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
  282. package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
  283. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
  284. package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
  285. package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
  286. package/dist/src/hooks/useDropdownData.d.ts +0 -44
  287. package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
  288. package/dist/src/hooks/useDropdownData.js +0 -73
  289. package/dist/src/hooks/useDropdownData.js.map +0 -1
  290. package/dist/src/utils/cryptoAssets.d.ts +0 -28
  291. package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
  292. package/dist/src/utils/cryptoAssets.js +0 -73
  293. package/dist/src/utils/cryptoAssets.js.map +0 -1
  294. package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
  295. package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
  296. package/dist/src/utils/cryptoAssets.test.js +0 -49
  297. package/dist/src/utils/cryptoAssets.test.js.map +0 -1
  298. package/src/components/Dropdown/AccountAddress.tsx +0 -111
  299. package/src/components/Dropdown/AccountAssets.tsx +0 -110
  300. package/src/components/Dropdown/AccountBalance.tsx +0 -38
  301. package/src/components/Dropdown/WelcomeBlock.tsx +0 -92
  302. package/src/hooks/useAssetsUSDConversion.ts +0 -31
  303. package/src/hooks/useDropdownData.ts +0 -130
  304. package/src/utils/cryptoAssets.test.ts +0 -59
  305. package/src/utils/cryptoAssets.ts +0 -93
@@ -1,110 +1,48 @@
1
+ type CompactStringDecimals = Intl.NumberFormatOptions["minimumFractionDigits"] &
2
+ BigIntToLocaleStringOptions["minimumFractionDigits"]
1
3
  /**
2
- * Formats a number or bigint into a human-readable string with K, M, B, or T suffix.
4
+ * Formats a number or bigint into compact string with K, M, B, or T suffix.
3
5
  * @param value The number or bigint to format.
4
6
  * @param decimals Number of decimal places to include (ignored for bigint to avoid floating point issues).
5
7
  * @returns The formatted number as a string.
6
8
  */
7
- export function formatHumanReadableNumber(
9
+ export function formatNumberToCompactString(
8
10
  value: number | bigint,
9
- decimals: number = 4,
11
+ decimals: CompactStringDecimals = 2,
10
12
  ): string {
11
- const suffixes = ["", "K", "M", "B", "T"]
12
- const numericValue = typeof value === "bigint" ? Number(value) : value
13
-
14
- if (numericValue < 1000) return numericValue.toFixed(decimals)
15
-
16
- const magnitude = Math.floor(Math.log10(numericValue) / 3)
17
-
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
- }
23
-
24
- const scaledValue = numericValue / 10 ** (magnitude * 3)
25
- return `${scaledValue.toFixed(decimals)}${suffixes[magnitude]}`
13
+ return value.toLocaleString("en-US", {
14
+ notation: "compact",
15
+ compactDisplay: "short",
16
+ maximumFractionDigits: decimals,
17
+ })
26
18
  }
27
19
 
28
20
  /**
29
- * Returns a number rounded up to the desired number of decimals.
30
- * @param amount The number to round up.
31
- * @param desiredDecimals The number of decimals to round up to.
32
- * @returns The rounded up number.
33
- * @see https://github.com/thesis/acre/blob/main/dapp/src/utils/numbersUtils.ts#L1-L3
21
+ * Normalizes a bigint value to a target precision.
22
+ * @param value The bigint value to normalize.
23
+ * @param currentPrecision The current precision of the value.
24
+ * @param targetPrecision The target precision to normalize to.
25
+ * @returns The normalized bigint value.
34
26
  */
35
- export function roundUpNumber(amount: number, desiredDecimals = 2): number {
36
- return Math.ceil(amount * 10 ** desiredDecimals) / 10 ** desiredDecimals
37
- }
38
-
39
- /**
40
- * Convert a fixed point bigint with precision `fixedPointDecimals` to a
41
- * floating point number truncated to `desiredDecimals`.
42
- * @param fixedPoint The fixed point bigint to convert.
43
- * @param fixedPointDecimals The number of decimals in the fixed point bigint.
44
- * @param desiredDecimals The number of decimals in the output number.
45
- * @returns The floating point number truncated to `desiredDecimals`.
46
- * @see https://github.com/tahowallet/extension/blob/main/background/lib/fixed-point.ts#L216-L239
47
- */
48
- export function fromFixedPoint(
49
- fixedPoint: bigint,
50
- fixedPointDecimals: number,
51
- desiredDecimals = 2,
52
- ): number {
53
- const fixedPointDesiredDecimalsAmount =
54
- fixedPoint /
55
- 10n ** BigInt(Math.max(1, fixedPointDecimals - desiredDecimals))
56
-
57
- const formattedAmount =
58
- Number(fixedPointDesiredDecimalsAmount) /
59
- 10 ** Math.min(desiredDecimals, fixedPointDecimals)
60
-
61
- return formattedAmount
27
+ export const normalizePrecision = (
28
+ value: bigint,
29
+ currentPrecision: number,
30
+ targetPrecision = currentPrecision,
31
+ ): bigint => {
32
+ if (currentPrecision > targetPrecision) {
33
+ return value / 10n ** BigInt(currentPrecision - targetPrecision)
34
+ }
35
+ if (currentPrecision < targetPrecision) {
36
+ return value * 10n ** BigInt(targetPrecision - currentPrecision)
37
+ }
38
+ return value
62
39
  }
63
40
 
64
41
  /**
65
- * Display a cryptoAsset amount correctly with desired decimals.
66
- * 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.
75
- * @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
42
+ * Utility function to find the maximum value from given `BigInt` values.
43
+ * @param values Array of BigInt values to find the maximum from.
44
+ * @returns The maximum value from the provided `BigInt` values.
45
+ * @dev Works exactly like `Math.max` but for `BigInt` values.
79
46
  */
80
- export function formatTokenAmount(
81
- amount: number | string | bigint,
82
- decimals = 18,
83
- desiredDecimals = 2,
84
- withRoundUp = false,
85
- ) {
86
- const fixedPoint = BigInt(amount)
87
-
88
- if (fixedPoint === 0n) {
89
- return `0.${"0".repeat(desiredDecimals)}`
90
- }
91
-
92
- const formattedAmount = fromFixedPoint(
93
- fixedPoint,
94
- decimals,
95
- // To round the amount up, let's increase the precision by one.
96
- // The desired decimal numbers will be set later anyway.
97
- withRoundUp ? desiredDecimals + 1 : desiredDecimals,
98
- )
99
-
100
- const minAmountToDisplay = 1 / 10 ** Math.min(desiredDecimals, decimals)
101
-
102
- if (minAmountToDisplay > formattedAmount) {
103
- return `<0.${"0".repeat(desiredDecimals - 1)}1`
104
- }
105
-
106
- const finalFormattedAmount = withRoundUp
107
- ? roundUpNumber(formattedAmount, desiredDecimals)
108
- : formattedAmount
109
- return formatHumanReadableNumber(finalFormattedAmount, desiredDecimals)
110
- }
47
+ export const bigIntMax = (...values: bigint[]): bigint =>
48
+ values.reduce((max, value) => (value > max ? value : max))
package/src/utils/siww.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { SignInWithWalletMessage } from "@mezo-org/sign-in-with-wallet"
1
+ import {
2
+ SignInWithWalletErrorType,
3
+ SignInWithWalletMessage,
4
+ } from "@mezo-org/sign-in-with-wallet"
2
5
  import { ONE_DAY_MS } from "./time"
3
6
 
4
7
  const SESSION_EXPIRATION_DURATION_MS = 14 * ONE_DAY_MS
@@ -13,19 +16,71 @@ export function createSignInWithWalletMessage(
13
16
  ) {
14
17
  const { host: domain, origin: uri } = window.location
15
18
 
16
- const message = new SignInWithWalletMessage({
17
- domain,
18
- address, // if "bitcoin" this should be btc address, not underlaying eth address
19
- uri,
20
- nonce,
21
- issuedAt: new Date().toISOString(),
22
- expirationTime: new Date(
23
- Date.now() + SESSION_EXPIRATION_DURATION_MS,
24
- ).toISOString(),
25
- version: "1",
26
- chainId: networkFamily === "evm" ? chainId : undefined,
27
- networkFamily,
28
- })
29
-
30
- return message.prepareMessage()
19
+ let siwwMessage
20
+ try {
21
+ siwwMessage = new SignInWithWalletMessage({
22
+ domain,
23
+ address, // if "bitcoin" this should be btc address, not underlaying eth address
24
+ uri,
25
+ nonce,
26
+ issuedAt: new Date().toISOString(),
27
+ expirationTime: new Date(
28
+ Date.now() + SESSION_EXPIRATION_DURATION_MS,
29
+ ).toISOString(),
30
+ version: "1",
31
+ chainId: networkFamily === "evm" ? chainId : undefined,
32
+ networkFamily,
33
+ })
34
+ } catch (error) {
35
+ throw new Error(`Failed to create sign in with wallet message: ${error}`)
36
+ }
37
+
38
+ return siwwMessage.prepareMessage()
39
+ }
40
+
41
+ class SIWWDomainError extends Error {
42
+ constructor(message: string) {
43
+ super(`Error when verifying domain in SIWW message: ${message}`)
44
+ this.name = "SIWWDomainError"
45
+ }
46
+ }
47
+
48
+ export async function verifyDomainInSignInWithWalletMessage(
49
+ message: string,
50
+ signature: string,
51
+ nonce: string,
52
+ ) {
53
+ const { host: domain } = window.location
54
+ let siwwMessage: SignInWithWalletMessage
55
+ try {
56
+ siwwMessage = new SignInWithWalletMessage(message)
57
+ } catch (error) {
58
+ throw new SIWWDomainError("Failed to parse SIWW message")
59
+ }
60
+
61
+ if (!siwwMessage.expirationTime) {
62
+ throw new SIWWDomainError("SIWW messages must have an expiration time set")
63
+ }
64
+
65
+ const result = await siwwMessage.verify(
66
+ {
67
+ signature,
68
+ // Nonce has to match the session ID carried in the request.
69
+ nonce,
70
+ domain,
71
+ // Time is used as a reference to verify the expiration time set in the
72
+ // message.
73
+ time: new Date().toISOString(),
74
+ },
75
+ { suppressExceptions: true },
76
+ )
77
+
78
+ if (
79
+ result.error &&
80
+ result.error.type === SignInWithWalletErrorType.DOMAIN_MISMATCH
81
+ ) {
82
+ throw new SIWWDomainError(
83
+ "Domain does not match provided domain for verification.",
84
+ )
85
+ }
31
86
  }
@@ -0,0 +1,12 @@
1
+ import { OrangeKitConnector } from "@mezo-org/orangekit"
2
+ import { Connector } from "wagmi"
3
+
4
+ export async function getBitcoinPublicKeyFromConnector(connector: Connector) {
5
+ if (connector.type !== "orangekit") return undefined
6
+
7
+ const provider = (
8
+ connector as unknown as OrangeKitConnector
9
+ ).getBitcoinProvider()
10
+
11
+ return provider.getPublicKey()
12
+ }
@@ -1,9 +1,10 @@
1
1
  export {
2
+ BitcoinWalletConnectionError,
2
3
  getOKXWallet,
3
4
  getUnisatWallet,
4
5
  getXverseWallet,
5
- BitcoinWalletConnectionError,
6
- WalletNetworkDoesNotMatchProviderChainError,
7
6
  isUnsupportedBitcoinAddressError,
8
7
  isWalletNetworkDoesNotMatchProviderChainError,
8
+ OrangeKitConnector,
9
+ WalletNetworkDoesNotMatchProviderChainError,
9
10
  } from "@mezo-org/orangekit"
@@ -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,58 +0,0 @@
1
- import { Block, Copy03 as CopyIcon, LinkExternal02 as LinkIcon, ParagraphSmall, useStyletron, } from "@mezo-org/mezo-clay";
2
- import React from "react";
3
- import { useCopyToClipboard } from "usehooks-ts";
4
- import { usePassportContext } from "../../hooks/usePassportContext";
5
- import { getAddressExplorerUrl, trimAddress } from "../../utils/address";
6
- import { getCryptoAsset } from "../../utils/cryptoAssets";
7
- // TODO: Add visual feedback on copy
8
- export default function AccountAddress(props) {
9
- const { address, type } = props;
10
- const { environment } = usePassportContext();
11
- const blockExplorerUrl = getAddressExplorerUrl(address, type, environment === "testnet");
12
- const trimmedAddress = trimAddress(address);
13
- const { icon: accountIcon } = getCryptoAsset(type === "bitcoin" ? "btc" : "eth");
14
- const [, theme] = useStyletron();
15
- const [, copy] = useCopyToClipboard();
16
- return (React.createElement(Block, { as: "button", onClick: () => copy(address), display: "flex", alignItems: "center", backgroundColor: "transparent", padding: `${theme.sizing.scale600} ${theme.sizing.scale500}`, overrides: {
17
- Block: {
18
- style: {
19
- borderWidth: 0,
20
- cursor: "pointer",
21
- ":hover": {
22
- backgroundColor: theme.colors.backgroundTertiary,
23
- },
24
- },
25
- },
26
- } },
27
- React.createElement(Block, { as: accountIcon, size: theme.sizing.scale600 }),
28
- React.createElement(Block, { as: "a", marginLeft: theme.sizing.scale300, href: blockExplorerUrl, target: "_blank", overrides: {
29
- Block: {
30
- style: {
31
- color: "inherit",
32
- textDecoration: "none",
33
- ":hover": {
34
- textDecoration: "underline",
35
- },
36
- },
37
- },
38
- } },
39
- React.createElement(ParagraphSmall, { display: "flex", alignItems: "center", margin: 0, color: theme.colors.gray800 },
40
- trimmedAddress,
41
- React.createElement(LinkIcon, { display: "inline", size: theme.sizing.scale550, overrides: {
42
- Svg: {
43
- style: {
44
- stroke: "currentColor",
45
- marginLeft: theme.sizing.scale200,
46
- },
47
- },
48
- } }))),
49
- React.createElement(CopyIcon, { size: theme.sizing.scale550, overrides: {
50
- Svg: {
51
- style: {
52
- marginLeft: "auto",
53
- stroke: "currentColor",
54
- },
55
- },
56
- } })));
57
- }
58
- //# sourceMappingURL=AccountAddress.js.map
@@ -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,CACnC,CAAA;IAED,MAAM,CAAC,E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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","sourceRo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,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,7 +0,0 @@
1
- import React from "react";
2
- type AccountBalanceProps = {
3
- amount: number;
4
- };
5
- export default function AccountBalance(props: AccountBalanceProps): React.JSX.Element;
6
- export {};
7
- //# sourceMappingURL=AccountBalance.d.ts.map
@@ -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,8 +0,0 @@
1
- import React from "react";
2
- type WelcomeBlockProps = {
3
- mezoId: string;
4
- matsBalance: number;
5
- };
6
- export default function WelcomeBlock(props: WelcomeBlockProps): React.JSX.Element;
7
- export {};
8
- //# sourceMappingURL=WelcomeBlock.d.ts.map
@@ -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,44 +0,0 @@
1
- import { Block, HeadingSmall, LabelSmall, Mats, useStyletron, } from "@mezo-org/mezo-clay";
2
- import React from "react";
3
- import DefaultAvatar from "../../assets/DefaultAvatar";
4
- import { formatHumanReadableNumber } from "../../utils/numbers";
5
- const DOT_DELIMITER_REGEX = /(?=\.)/;
6
- export default function WelcomeBlock(props) {
7
- const { mezoId, matsBalance } = props;
8
- const [name, nameSuffix] = mezoId.split(DOT_DELIMITER_REGEX);
9
- const [, theme] = useStyletron();
10
- return (React.createElement(Block, { display: "flex", alignItems: "center", padding: `${theme.sizing.scale600} 0`, marginBottom: theme.sizing.scale300, overrides: {
11
- Block: {
12
- style: {
13
- gap: theme.sizing.scale600,
14
- },
15
- },
16
- } },
17
- React.createElement(Block, { as: DefaultAvatar, width: theme.sizing.scale1200, height: theme.sizing.scale1200, overrides: {
18
- Block: {
19
- style: {
20
- borderRadius: "100%",
21
- },
22
- },
23
- } }),
24
- React.createElement(Block, { display: "flex", flexDirection: "column", overrides: {
25
- Block: {
26
- style: {
27
- gap: theme.sizing.scale100,
28
- },
29
- },
30
- } },
31
- React.createElement(HeadingSmall, { as: "span" },
32
- React.createElement(Block, { as: "span" }, name),
33
- React.createElement(Block, { as: "span", color: theme.colors.gray500 }, nameSuffix)),
34
- React.createElement(LabelSmall, { display: "flex", alignItems: "center", margin: 0, color: theme.colors.contentTertiary, overrides: {
35
- Block: {
36
- style: {
37
- gap: theme.sizing.scale300,
38
- },
39
- },
40
- } },
41
- React.createElement(Mats, { color: theme.colors.contentPrimary, size: theme.sizing.scale600 }),
42
- formatHumanReadableNumber(matsBalance, 0)))));
43
- }
44
- //# sourceMappingURL=WelcomeBlock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WelcomeBlock.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/WelcomeBlock.tsx"],"names":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AAK,CAAC,MAAM,CAAC,QAAQ;qBAC3B;iBACF;aACF;YAED,oBAAC,YAAY,IAAC,EAAE,EAAC,MAAM;gBACrB,oBAAC,KAAK,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"}
@@ -1,44 +0,0 @@
1
- import { CryptoAssetKey } from "../utils/cryptoAssets";
2
- /**
3
- * Formats crypto asset to balance details (balance in USD and decimals)
4
- * @param type The type of crypto asset
5
- * @param balance The balance of crypto asset
6
- * @param btcUsdConversionRate The USD conversion rate
7
- * @returns The balance details
8
- */
9
- export declare function formatCryptoAsset(type: CryptoAssetKey, balance: bigint, btcUsdConversionRate: number): {
10
- type: CryptoAssetKey;
11
- balance: number;
12
- balanceInUsd: number;
13
- decimals: number;
14
- };
15
- export type DropdownCryptoAsset<T = CryptoAssetKey> = {
16
- type: T;
17
- balance: bigint;
18
- };
19
- type DropdownDetailedCryptoAsset = ReturnType<typeof formatCryptoAsset>;
20
- export type DropdownData = {
21
- mezoId: string;
22
- address: string;
23
- walletType: "bitcoin" | "evm";
24
- totalBalanceInUsd: number;
25
- formattedNativeAssets: DropdownDetailedCryptoAsset[];
26
- matsnet: {
27
- mats: number;
28
- formattedAssets: DropdownDetailedCryptoAsset[];
29
- };
30
- };
31
- type UseDropdownDataOptions = {
32
- evmNativeAssets?: DropdownCryptoAsset[];
33
- matsnetAssets?: DropdownCryptoAsset[];
34
- };
35
- /**
36
- * Aggregates dropdown data for Dropdown component.
37
- * @param options - Options for the dropdown data.
38
- * @param options.evmNativeAssets - Native assets for EVM wallet.
39
- * @param options.matsnetAssets - Matsnet tokens. Rendered as separate section.
40
- * @returns Dropdown data.
41
- */
42
- export default function useDropdownData(options?: UseDropdownDataOptions): DropdownData | null;
43
- export {};
44
- //# sourceMappingURL=useDropdownData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDropdownData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAIf,MAAM,uBAAuB,CAAA;AAK9B;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EACf,oBAAoB,EAAE,MAAM;;;;;EAmB7B;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,cAAc,IAAI;IACpD,IAAI,EAAE,CAAC,CAAA;IACP,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,2BAA2B,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEvE,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,SAAS,GAAG,KAAK,CAAA;IAC7B,iBAAiB,EAAE,MAAM,CAAA;IACzB,qBAAqB,EAAE,2BAA2B,EAAE,CAAA;IACpD,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,eAAe,EAAE,2BAA2B,EAAE,CAAA;KAC/C,CAAA;CACF,CAAA;AAED,KAAK,sBAAsB,GAAG;IAE5B,eAAe,CAAC,EAAE,mBAAmB,EAAE,CAAA;IACvC,aAAa,CAAC,EAAE,mBAAmB,EAAE,CAAA;CACtC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,YAAY,GAAG,IAAI,CAoDrB"}