@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,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,54 @@ 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
+ };
81
132
  //# 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,I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AC,CAAA;QAEtE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,SAAS,CAAA;QAEtC,MAAM,yBAAyB,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACzD,MAAM,WAAW,GAAG,YAAY,IAAI,EAAE,CAAA;QAEtC,IAAI,CAAC;YACH,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACjE,QAAQ,EAAE,WAAW,CAAC,MAAM;aAC7B,CAAA;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC,CAAA;IAED,MAAM,iBAAiB,GAAG,CACxB,UAAkB,EAClB,kBAA0B,EAC1B,cAAsB,EACd,EAAE;QACV,IAAI,kBAAkB,IAAI,cAAc,EAAE,CAAC;YACzC,OAAO,UAAU,GAAG,GAAG,IAAI,MAAM,CAAC,kBAAkB,GAAG,cAAc,CAAC,CAAA;QACxE,CAAC;QAED,OAAO,UAAU,GAAG,GAAG,IAAI,MAAM,CAAC,cAAc,GAAG,kBAAkB,CAAC,CAAA;IACxE,CAAC,CAAA;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IACtC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAA;IAE9D,IAAI,OAAO,gBAAgB,KAAK,WAAW,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,iBAAiB,CACtB,gBAAgB,CAAC,MAAM,EACvB,gBAAgB,CAAC,QAAQ,EACzB,QAAQ,CACT,CAAA;AACH,CAAC,CAAA"}
@@ -1,26 +1,29 @@
1
- import { formatHumanReadableNumber, formatTokenAmount, fromFixedPoint, roundUpNumber, } from "./numbers";
2
- describe("formatHumanReadableNumber", () => {
1
+ import { formatNumberToCompactString, fromFixedPoint, roundUpNumber, formatNumberToLocaleString, fromFixedPointToString, } from "./numbers";
2
+ describe("formatNumberToCompactString", () => {
3
3
  it("formats number less than 1000 with decimals", () => {
4
- expect(formatHumanReadableNumber(123.456789, 2)).toBe("123.46");
4
+ expect(formatNumberToCompactString(123.456789, 2)).toBe("123.46");
5
5
  });
6
6
  it("formats thousands with K", () => {
7
- expect(formatHumanReadableNumber(12_345, 2)).toBe("12.35K");
7
+ expect(formatNumberToCompactString(12_345, 2)).toBe("12.35K");
8
8
  });
9
9
  it("formats millions with M", () => {
10
- expect(formatHumanReadableNumber(12_345_678, 2)).toBe("12.35M");
10
+ expect(formatNumberToCompactString(12_345_678, 2)).toBe("12.35M");
11
11
  });
12
12
  it("formats billions with B", () => {
13
- expect(formatHumanReadableNumber(12_345_678_901, 2)).toBe("12.35B");
13
+ expect(formatNumberToCompactString(12_345_678_901, 2)).toBe("12.35B");
14
14
  });
15
15
  it("formats trillions with T", () => {
16
- expect(formatHumanReadableNumber(12_345_678_901_234, 2)).toBe("12.35T");
16
+ expect(formatNumberToCompactString(12_345_678_901_234, 2)).toBe("12.35T");
17
17
  });
18
18
  it("formats bigint as readable number", () => {
19
- expect(formatHumanReadableNumber(1234567890123456789n, 2)).toBe("> 1000T");
19
+ expect(formatNumberToCompactString(1234567890123456789n, 2)).toBe("1,234,567.89T");
20
20
  });
21
21
  it("caps at > 1000T for huge numbers", () => {
22
22
  const hugeNumber = 10 ** 18; // 1e18
23
- expect(formatHumanReadableNumber(hugeNumber, 2)).toBe("> 1000T");
23
+ expect(formatNumberToCompactString(hugeNumber, 2)).toBe("1,000,000T");
24
+ });
25
+ it("formats numbers with trailing zeros correctly", () => {
26
+ expect(formatNumberToCompactString(1_000, 2)).toBe("1K");
24
27
  });
25
28
  });
26
29
  describe("roundUpNumber", () => {
@@ -37,7 +40,7 @@ describe("roundUpNumber", () => {
37
40
  describe("fromFixedPoint", () => {
38
41
  it("converts fixed point with 18 decimals to float", () => {
39
42
  const raw = 1234567890000000000n; // 1.23456789 ETH in 18 decimals
40
- expect(fromFixedPoint(raw, 18, 4)).toBe(1.2345);
43
+ expect(fromFixedPoint(raw, 18)).toBe(1.2345);
41
44
  });
42
45
  it("converts with truncation to 2 decimals", () => {
43
46
  const raw = 987654321000000000n; // ~0.987654321 ETH
@@ -48,21 +51,120 @@ describe("fromFixedPoint", () => {
48
51
  expect(fromFixedPoint(raw, 6, 2)).toBe(1000000000000000000);
49
52
  });
50
53
  });
51
- describe("formatTokenAmount", () => {
52
- it("formats zero value with desired decimals", () => {
53
- expect(formatTokenAmount(0, 18, 3)).toBe("0.000");
54
- expect(formatTokenAmount("0", 18, 2)).toBe("0.00");
54
+ describe("formatNumberToLocaleString", () => {
55
+ it("formats zero with 0 decimals", () => {
56
+ expect(formatNumberToLocaleString(0, 0)).toBe("0");
57
+ });
58
+ it("formats zero with >0 decimals", () => {
59
+ expect(formatNumberToLocaleString(0, 2)).toBe("0.00");
60
+ expect(formatNumberToLocaleString(0, 4)).toBe("0.0000");
61
+ });
62
+ it("formats small decimal number", () => {
63
+ expect(formatNumberToLocaleString(0.123456, 2)).toBe("0.12");
64
+ expect(formatNumberToLocaleString(0.123456, 4)).toBe("0.1235");
65
+ });
66
+ it("formats number just above 1", () => {
67
+ expect(formatNumberToLocaleString(1.000001, 3)).toBe("1.000");
68
+ expect(formatNumberToLocaleString(1.234567, 2)).toBe("1.23");
69
+ });
70
+ it("formats whole number", () => {
71
+ expect(formatNumberToLocaleString(1234, 0)).toBe("1,234");
72
+ expect(formatNumberToLocaleString(1000, 2)).toBe("1,000.00");
55
73
  });
56
- it("returns <0.01 if amount is less than minimum display value", () => {
57
- expect(formatTokenAmount("1", 18, 2)).toBe("<0.01"); // 1 wei = 1e-18
74
+ it("formats number with trailing decimal zeroes", () => {
75
+ expect(formatNumberToLocaleString(10.1, 3)).toBe("10.100");
76
+ expect(formatNumberToLocaleString(5.0, 2)).toBe("5.00");
58
77
  });
59
- it("formats a normal value without rounding", () => {
60
- const result = formatTokenAmount("1230000000000000000", 18, 2);
61
- expect(result).toBe("1.23");
78
+ it("formats string input", () => {
79
+ expect(formatNumberToLocaleString("123.456", 2)).toBe("123.46");
80
+ expect(formatNumberToLocaleString("0.00123", 4)).toBe("0.0012");
62
81
  });
63
- it("formats with rounding if withRoundUp = true", () => {
64
- const result = formatTokenAmount("1234560000000000000", 18, 2, true);
65
- expect(result).toBe("1.24");
82
+ it("formats negative number", () => {
83
+ expect(formatNumberToLocaleString(-123.456, 2)).toBe("-123.46");
84
+ expect(formatNumberToLocaleString("-0.00999", 3)).toBe("-0.010");
85
+ });
86
+ it("formats large number with commas", () => {
87
+ expect(formatNumberToLocaleString(12345678.9, 2)).toBe("12,345,678.90");
88
+ });
89
+ it("handles max decimals safely", () => {
90
+ expect(formatNumberToLocaleString(1.123456789, 8)).toBe("1.12345679");
91
+ expect(formatNumberToLocaleString("0.000000000000000001", 18)).toBe("0.000000000000000001");
92
+ });
93
+ it("defaults to 0 decimals if not passed", () => {
94
+ expect(formatNumberToLocaleString(1234.567)).toBe("1,235"); // rounds up by default
95
+ });
96
+ });
97
+ describe("fromFixedPointToString", () => {
98
+ const toFixedPoint = (num) => BigInt(Math.round(num * 1e18));
99
+ const cases = [
100
+ { input: 2.0, expected: "2.000" },
101
+ { input: 2.009, expected: "2.009" },
102
+ { input: 2.01, expected: "2.010" },
103
+ { input: 2.015, expected: "2.016" },
104
+ { input: 2.05, expected: "2.050" },
105
+ { input: 2.09, expected: "2.090" },
106
+ ];
107
+ describe("withRoundUp: true", () => {
108
+ cases.forEach(({ input, expected }) => {
109
+ it(`formats ${input} → ${expected}`, () => {
110
+ const fixed = toFixedPoint(input);
111
+ expect(fromFixedPointToString(fixed, 18, 3, true)).toBe(expected);
112
+ });
113
+ });
114
+ });
115
+ describe("withRoundUp: false", () => {
116
+ const noRoundCases = [
117
+ { input: 2.0099, expected: "2.009" },
118
+ { input: 2.0159, expected: "2.015" },
119
+ { input: 2.0101, expected: "2.010" },
120
+ { input: 2.0199, expected: "2.019" },
121
+ ];
122
+ noRoundCases.forEach(({ input, expected }) => {
123
+ it(`formats ${input} → ${expected} (no rounding)`, () => {
124
+ const fixed = toFixedPoint(input);
125
+ expect(fromFixedPointToString(fixed, 18, 3, false)).toBe(expected);
126
+ });
127
+ });
128
+ });
129
+ describe("zero handling", () => {
130
+ it("formats 0 → 0.000 (3 decimals)", () => {
131
+ expect(fromFixedPointToString(0n, 18, 3)).toBe("0.000");
132
+ });
133
+ it("formats 0 → 0.0000 (4 decimals)", () => {
134
+ expect(fromFixedPointToString(0n, 18, 4)).toBe("0.0000");
135
+ });
136
+ });
137
+ describe("very small numbers below display threshold", () => {
138
+ it("returns <0.0001 for small number (3 decimals)", () => {
139
+ const small = BigInt(123); // ~1.23e-16
140
+ expect(fromFixedPointToString(small, 18, 4)).toBe("<0.0001");
141
+ });
142
+ it("returns <0.01 for small number with only 2 decimals", () => {
143
+ const tiny = BigInt(9999999999999); // <0.01
144
+ expect(fromFixedPointToString(tiny, 18, 2)).toBe("<0.01");
145
+ });
146
+ });
147
+ describe("input types", () => {
148
+ it("accepts bigint", () => {
149
+ const amount = 2100000000000000000n;
150
+ expect(fromFixedPointToString(amount, 18, 3)).toBe("2.100");
151
+ });
152
+ it("accepts string", () => {
153
+ expect(fromFixedPointToString("2000000000000000000", 18, 3)).toBe("2.000");
154
+ });
155
+ it("accepts number", () => {
156
+ expect(fromFixedPointToString(Number("1000000000000000000"), 18, 3)).toBe("1.000");
157
+ });
158
+ });
159
+ describe("high values", () => {
160
+ it("formats 1_000_000.123456789 correctly", () => {
161
+ const big = toFixedPoint(1_000_000.123456789);
162
+ expect(fromFixedPointToString(big, 18, 6)).toBe("1,000,000.123456");
163
+ });
164
+ it("formats 1e12 ETH", () => {
165
+ const big = BigInt("1000000000000000000000000000000");
166
+ expect(fromFixedPointToString(big, 18, 2)).toBe("1,000,000,000,000.00");
167
+ });
66
168
  });
67
169
  });
68
170
  //# sourceMappingURL=numbers.test.js.map
@@ -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  {
2
2
  "name": "@mezo-org/passport",
3
- "version": "0.4.0-dev.6",
3
+ "version": "0.4.0-dev.61",
4
4
  "main": "dist/src/index.js",
5
5
  "license": "GPL-3.0-only",
6
6
  "scripts": {
@@ -28,8 +28,6 @@
28
28
  "@types/jest": "^29.5.12",
29
29
  "@types/node": "^20.11.30",
30
30
  "@types/react": "^18.2.64",
31
- "@types/ungap__structured-clone": "^1.2.0",
32
- "@ungap/structured-clone": "^1.3.0",
33
31
  "eslint": "^8.57.1",
34
32
  "jest": "^29.7.0",
35
33
  "jest-environment-jsdom": "^29.7.0",
@@ -39,17 +37,21 @@
39
37
  "typescript": "^5.4.3"
40
38
  },
41
39
  "dependencies": {
42
- "@mezo-org/mezo-clay": "0.1.0-dev.18",
43
- "@mezo-org/orangekit": "1.0.0-beta.40-dev.0",
44
- "@mezo-org/sign-in-with-wallet": "1.0.0-beta.8"
40
+ "@mezo-org/mezo-clay": "0.1.0-dev.27",
41
+ "@mezo-org/mezod-contracts": "^1.0.0",
42
+ "@mezo-org/musd-contracts": "^1.0.1",
43
+ "@mezo-org/orangekit": "1.0.0-beta.40-dev.14",
44
+ "@mezo-org/sign-in-with-wallet": "1.0.0-beta.8",
45
+ "qrcode.react": "^4.2.0",
46
+ "styletron-engine-monolithic": "^1.0.0",
47
+ "usehooks-ts": "^3.1.1",
48
+ "zustand": "^5.0.3"
45
49
  },
46
50
  "peerDependencies": {
47
51
  "@rainbow-me/rainbowkit": "2.0.2",
48
52
  "@tanstack/react-query": "^5.28.4",
49
53
  "react": "^18.2.0",
50
- "styletron-engine-monolithic": "^1.0.0",
51
- "usehooks-ts": "^3.1.1",
52
54
  "viem": "2.22.8",
53
55
  "wagmi": "2.5.12"
54
56
  }
55
- }
57
+ }
package/src/api/auth.ts CHANGED
@@ -82,7 +82,9 @@ export class AuthApiClient extends ApiClient {
82
82
  environment: keyof typeof AUTH_API_ENDPOINTS_BY_ENV = "mainnet",
83
83
  apiUrl?: string,
84
84
  ) {
85
- super(apiUrl ?? AUTH_API_ENDPOINTS_BY_ENV[environment])
85
+ super({
86
+ apiUrl: apiUrl ?? AUTH_API_ENDPOINTS_BY_ENV[environment],
87
+ })
86
88
  }
87
89
 
88
90
  async getSession(code?: string) {
package/src/api/client.ts CHANGED
@@ -5,10 +5,19 @@ type RequestHandlerOptions = Omit<RequestInit, "credentials" | "body"> & {
5
5
  queryParams?: Record<string, string | undefined>
6
6
  }
7
7
 
8
+ const ENDS_WITH_VERSIONING_REGEX = /\/v\d+(?=\/|$)/
9
+ const TRAILING_SLASH_REGEX = /\/$/
10
+
8
11
  export abstract class ApiClient {
9
12
  private apiUrl: string
10
13
 
11
- constructor(apiUrl: string) {
14
+ constructor(opts: { apiUrl: string; removeVersioning?: boolean }) {
15
+ const { apiUrl, removeVersioning = false } = opts
16
+
17
+ if (removeVersioning) {
18
+ this.apiUrl = apiUrl.replace(ENDS_WITH_VERSIONING_REGEX, "")
19
+ return
20
+ }
12
21
  this.apiUrl = apiUrl
13
22
  }
14
23
 
@@ -33,7 +42,7 @@ export abstract class ApiClient {
33
42
  const { method, body, queryParams = {}, ...restOptions } = options
34
43
 
35
44
  // If last character in apiUrl is forward slash we are removing it
36
- const authApiUrlRoute = this.apiUrl.replace(/\/$/, "")
45
+ const authApiUrlRoute = this.apiUrl.replace(TRAILING_SLASH_REGEX, "")
37
46
  const url = new URL(`${authApiUrlRoute}${endpoint}`)
38
47
 
39
48
  // Removes falsy values (e.g. null, undefined etc.) from query params and
package/src/api/portal.ts CHANGED
@@ -6,25 +6,19 @@ type PortalStatistics = {
6
6
  tvl: number
7
7
  currentUsdPerBtc: string
8
8
  currentUsdPerEth: string
9
+ currentUsdPerTToken: string
9
10
  usdPerBtc24hChange: string
10
11
  }
11
12
 
12
13
  type PortalMats = {
13
- address: string
14
14
  totalMats: number
15
- matsFromDeposits: number
16
- matsFromReferrals: number
17
- matsFromSecondaryReferrals: number
18
- netMatsTransferred: number
19
- dailyMats: number
20
- dailyMatsFromDeposits: number
21
- dailyMatsFromReferrals: number
22
- dailyMatsFromSecondaryReferrals: number
15
+ inactiveMats: number
16
+ matsActivated: boolean
23
17
  }
24
18
 
25
19
  export const PORTAL_API_ENDPOINTS_BY_ENV = {
26
- mainnet: "https://api.mezo.org/api/v1",
27
- testnet: "https://api.test.mezo.org/api/v1",
20
+ mainnet: "https://api.mezo.org/api/",
21
+ testnet: "https://api.test.mezo.org/api/",
28
22
  }
29
23
 
30
24
  export class PortalApiClient extends ApiClient {
@@ -32,11 +26,14 @@ export class PortalApiClient extends ApiClient {
32
26
  environment: keyof typeof PORTAL_API_ENDPOINTS_BY_ENV = "mainnet",
33
27
  apiUrl?: string,
34
28
  ) {
35
- super(apiUrl ?? PORTAL_API_ENDPOINTS_BY_ENV[environment])
29
+ super({
30
+ apiUrl: apiUrl ?? PORTAL_API_ENDPOINTS_BY_ENV[environment],
31
+ removeVersioning: true,
32
+ })
36
33
  }
37
34
 
38
35
  async getPortalStatistics() {
39
- const data = await this.handleRequest<PortalStatistics>("/statistics", {
36
+ const data = await this.handleRequest<PortalStatistics>("/v1/statistics", {
40
37
  method: "GET",
41
38
  })
42
39
 
@@ -45,7 +42,7 @@ export class PortalApiClient extends ApiClient {
45
42
 
46
43
  async getPortalMats(address: string) {
47
44
  const data = await this.handleRequest<PortalMats>(
48
- `/accounts/${address}/mats`,
45
+ `/v2/account/${address}/mats`,
49
46
  {
50
47
  method: "GET",
51
48
  },
@@ -1,54 +1,74 @@
1
- import { Block, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
2
- import React, { forwardRef, ReactNode } from "react"
1
+ import { Block, Button, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
2
+ import React, { forwardRef, ReactNode, useMemo } from "react"
3
3
 
4
- type ConnectedTriggerProps = Omit<ButtonProps, "children"> & {
4
+ type ConnectedTriggerProps = Omit<ButtonProps, "children" | "size"> & {
5
5
  avatar: ReactNode
6
+ size?: "medium" | "large"
6
7
  }
7
8
 
8
9
  const ConnectedTrigger = forwardRef<HTMLButtonElement, ConnectedTriggerProps>(
9
10
  (props, ref) => {
10
- const { onClick, avatar, ...restProps } = props
11
+ const { onClick, avatar, size = "medium", ...restProps } = props
11
12
 
12
13
  const [, theme] = useStyletron()
13
14
 
15
+ const avatarSize = useMemo(() => {
16
+ const sizeMap = {
17
+ medium: theme.sizing.scale950,
18
+ large: theme.sizing.scale1400,
19
+ }
20
+
21
+ return sizeMap[size]
22
+ }, [theme, size])
23
+
24
+ const buttonPadding = useMemo(() => {
25
+ const paddingMap = {
26
+ medium: theme.sizing.scale0,
27
+ large: theme.sizing.scale100,
28
+ }
29
+
30
+ return paddingMap[size]
31
+ }, [theme, size])
32
+
14
33
  return (
15
- <Block
16
- as="button"
34
+ <Button
17
35
  overrides={{
18
- Block: {
36
+ BaseButton: {
19
37
  props: { ref, ...restProps },
20
38
  style: {
21
- border: "none",
22
- background: "none",
23
- padding: 0,
24
- margin: 0,
25
- cursor: "pointer",
39
+ borderRadius: "100%",
40
+ overflow: "hidden",
41
+ padding: buttonPadding,
26
42
  },
27
43
  },
28
44
  }}
29
45
  onClick={onClick}
30
46
  >
31
- <Block
32
- width={theme.sizing.scale950}
33
- height={theme.sizing.scale950}
34
- overrides={{
35
- Block: {
36
- style: {
37
- borderRadius: "100%",
38
- border: `2px solid ${theme.colors.contentPrimary}`,
39
- boxSizing: "border-box",
40
- overflow: "hidden",
47
+ {typeof avatar === "string" ? (
48
+ <Block
49
+ width={avatarSize}
50
+ height={avatarSize}
51
+ as="img"
52
+ src={avatar}
53
+ alt=""
54
+ />
55
+ ) : (
56
+ <Block
57
+ width={avatarSize}
58
+ height={avatarSize}
59
+ overrides={{
60
+ Block: {
61
+ style: {
62
+ borderRadius: "100%",
63
+ overflow: "hidden",
64
+ },
41
65
  },
42
- },
43
- }}
44
- >
45
- {typeof avatar === "string" ? (
46
- <Block as="img" src={avatar} alt="" />
47
- ) : (
48
- avatar
49
- )}
50
- </Block>
51
- </Block>
66
+ }}
67
+ >
68
+ {avatar}
69
+ </Block>
70
+ )}
71
+ </Button>
52
72
  )
53
73
  },
54
74
  )