@mezo-org/passport 0.4.0-dev.82 → 0.4.0-dev.83

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 (177) hide show
  1. package/dist/src/api/auth.d.ts +1 -1
  2. package/dist/src/api/auth.d.ts.map +1 -1
  3. package/dist/src/components/Dropdown/Content.d.ts +0 -15
  4. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  5. package/dist/src/components/Dropdown/Content.js +3 -3
  6. package/dist/src/components/Dropdown/Content.js.map +1 -1
  7. package/dist/src/components/Dropdown/Dropdown.d.ts +0 -4
  8. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  9. package/dist/src/components/Dropdown/Dropdown.js +10 -36
  10. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  11. package/dist/src/components/Dropdown/ListingItem.d.ts +8 -7
  12. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -1
  13. package/dist/src/components/Dropdown/ListingItem.js +36 -28
  14. package/dist/src/components/Dropdown/ListingItem.js.map +1 -1
  15. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +2 -1
  16. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -1
  17. package/dist/src/components/Dropdown/NestedViewLayout.js +13 -15
  18. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -1
  19. package/dist/src/components/Dropdown/Receive/Receive.d.ts +1 -4
  20. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -1
  21. package/dist/src/components/Dropdown/Receive/Receive.js +36 -19
  22. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
  23. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +2 -5
  24. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -1
  25. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +28 -12
  26. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
  27. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +2 -4
  28. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -1
  29. package/dist/src/components/Dropdown/Root/AccountBalance.js +24 -8
  30. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -1
  31. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
  32. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
  33. package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
  34. package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
  35. package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
  36. package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
  37. package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
  38. package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
  39. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
  40. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
  41. package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
  42. package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
  43. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +2 -3
  44. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -1
  45. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +34 -39
  46. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -1
  47. package/dist/src/components/Dropdown/Root/Root.d.ts +0 -15
  48. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
  49. package/dist/src/components/Dropdown/Root/Root.js +22 -34
  50. package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
  51. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +2 -6
  52. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -1
  53. package/dist/src/components/Dropdown/Root/WalletAddress.js +43 -34
  54. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
  55. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +2 -4
  56. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -1
  57. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +60 -16
  58. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -1
  59. package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
  60. package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
  61. package/dist/src/components/Dropdown/SlotNumber.js +67 -0
  62. package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
  63. package/dist/src/config.d.ts +0 -1
  64. package/dist/src/config.d.ts.map +1 -1
  65. package/dist/src/config.js +1 -9
  66. package/dist/src/config.js.map +1 -1
  67. package/dist/src/hooks/useAssetsConversionRates.d.ts +8 -13
  68. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -1
  69. package/dist/src/hooks/useAssetsConversionRates.js +44 -67
  70. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -1
  71. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  72. package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
  73. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  74. package/dist/src/hooks/useBorrowData.d.ts +31 -5
  75. package/dist/src/hooks/useBorrowData.d.ts.map +1 -1
  76. package/dist/src/hooks/useBorrowData.js +53 -11
  77. package/dist/src/hooks/useBorrowData.js.map +1 -1
  78. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  79. package/dist/src/hooks/useCreateAccount.js +3 -3
  80. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  81. package/dist/src/hooks/useGetCurrentAccount.d.ts +2 -2
  82. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  83. package/dist/src/hooks/useGetCurrentAccount.js +4 -6
  84. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  85. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  86. package/dist/src/hooks/useLinkAccount.js +3 -3
  87. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  88. package/dist/src/hooks/useTokensBalances.d.ts +36 -35
  89. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
  90. package/dist/src/hooks/useTokensBalances.js +93 -52
  91. package/dist/src/hooks/useTokensBalances.js.map +1 -1
  92. package/dist/src/hooks/useWalletAccount.d.ts +8 -10
  93. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  94. package/dist/src/hooks/useWalletAccount.js +22 -19
  95. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  96. package/dist/src/lib/contracts/index.d.ts +1 -1
  97. package/dist/src/lib/contracts/index.d.ts.map +1 -1
  98. package/dist/src/lib/contracts/index.js +4 -0
  99. package/dist/src/lib/contracts/index.js.map +1 -1
  100. package/dist/src/provider.d.ts +7 -1
  101. package/dist/src/provider.d.ts.map +1 -1
  102. package/dist/src/provider.js +4 -1
  103. package/dist/src/provider.js.map +1 -1
  104. package/dist/src/utils/assets.d.ts +145 -0
  105. package/dist/src/utils/assets.d.ts.map +1 -0
  106. package/dist/src/utils/assets.js +100 -0
  107. package/dist/src/utils/assets.js.map +1 -0
  108. package/dist/src/utils/assets.test.d.ts +2 -0
  109. package/dist/src/utils/assets.test.d.ts.map +1 -0
  110. package/dist/src/utils/assets.test.js +46 -0
  111. package/dist/src/utils/assets.test.js.map +1 -0
  112. package/dist/src/utils/currency.d.ts +6 -3
  113. package/dist/src/utils/currency.d.ts.map +1 -1
  114. package/dist/src/utils/currency.js +13 -10
  115. package/dist/src/utils/currency.js.map +1 -1
  116. package/dist/src/utils/currency.test.js +44 -2
  117. package/dist/src/utils/currency.test.js.map +1 -1
  118. package/dist/src/utils/numbers.d.ts +13 -53
  119. package/dist/src/utils/numbers.d.ts.map +1 -1
  120. package/dist/src/utils/numbers.js +16 -118
  121. package/dist/src/utils/numbers.js.map +1 -1
  122. package/dist/src/utils/numbers.test.js +24 -142
  123. package/dist/src/utils/numbers.test.js.map +1 -1
  124. package/package.json +2 -1
  125. package/src/api/auth.ts +1 -1
  126. package/src/components/Dropdown/Content.tsx +3 -48
  127. package/src/components/Dropdown/Dropdown.tsx +7 -58
  128. package/src/components/Dropdown/ListingItem.tsx +155 -59
  129. package/src/components/Dropdown/NestedViewLayout.tsx +32 -20
  130. package/src/components/Dropdown/Receive/Receive.tsx +69 -32
  131. package/src/components/Dropdown/Root/AccountAddressActions.tsx +64 -35
  132. package/src/components/Dropdown/Root/AccountBalance.tsx +54 -16
  133. package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
  134. package/src/components/Dropdown/Root/AccountError.tsx +34 -0
  135. package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
  136. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -46
  137. package/src/components/Dropdown/Root/Root.tsx +28 -98
  138. package/src/components/Dropdown/Root/WalletAddress.tsx +95 -89
  139. package/src/components/Dropdown/Root/WelcomeBlock.tsx +109 -29
  140. package/src/components/Dropdown/SlotNumber.tsx +131 -0
  141. package/src/config.ts +1 -11
  142. package/src/hooks/useAssetsConversionRates.ts +49 -67
  143. package/src/hooks/useAuthenticateWithWallet.ts +7 -5
  144. package/src/hooks/useBorrowData.ts +71 -12
  145. package/src/hooks/useCreateAccount.ts +5 -4
  146. package/src/hooks/useGetCurrentAccount.ts +5 -7
  147. package/src/hooks/useLinkAccount.ts +5 -4
  148. package/src/hooks/useTokensBalances.ts +152 -74
  149. package/src/hooks/useWalletAccount.ts +27 -36
  150. package/src/lib/contracts/index.ts +8 -1
  151. package/src/provider.ts +11 -3
  152. package/src/utils/assets.test.ts +57 -0
  153. package/src/utils/assets.ts +103 -0
  154. package/src/utils/currency.test.ts +76 -2
  155. package/src/utils/currency.ts +20 -15
  156. package/src/utils/numbers.test.ts +29 -180
  157. package/src/utils/numbers.ts +22 -171
  158. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +0 -11
  159. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +0 -1
  160. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +0 -9
  161. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +0 -1
  162. package/dist/src/hooks/useDropdownData.d.ts +0 -47
  163. package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
  164. package/dist/src/hooks/useDropdownData.js +0 -97
  165. package/dist/src/hooks/useDropdownData.js.map +0 -1
  166. package/dist/src/utils/cryptoAssets.d.ts +0 -44
  167. package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
  168. package/dist/src/utils/cryptoAssets.js +0 -129
  169. package/dist/src/utils/cryptoAssets.js.map +0 -1
  170. package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
  171. package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
  172. package/dist/src/utils/cryptoAssets.test.js +0 -67
  173. package/dist/src/utils/cryptoAssets.test.js.map +0 -1
  174. package/src/components/Dropdown/Root/AccountAssetItem.tsx +0 -26
  175. package/src/hooks/useDropdownData.ts +0 -152
  176. package/src/utils/cryptoAssets.test.ts +0 -79
  177. package/src/utils/cryptoAssets.ts +0 -171
@@ -1,47 +1,55 @@
1
1
  import {
2
+ BitcoinCircle,
2
3
  Block,
3
- Copy03 as CopyIcon,
4
- LinkExternal02 as LinkIcon,
5
- ParagraphSmall,
4
+ BlockProps,
5
+ EthCircle,
6
+ LabelMedium,
7
+ LabelXSmall,
8
+ mergeOverrides,
9
+ MonoLabelXSmall,
6
10
  useStyletron,
7
11
  } from "@mezo-org/mezo-clay"
8
- import React, { useCallback, useState } from "react"
12
+ import React, { useState } from "react"
9
13
  import { useCopyToClipboard } from "usehooks-ts"
10
14
  import { usePassportContext } from "../../../hooks/usePassportContext"
11
15
  import { getAddressExplorerUrl, trimAddress } from "../../../utils/address"
12
- import { getCryptoAsset } from "../../../utils/cryptoAssets"
16
+ import useWalletAccount from "../../../hooks/useWalletAccount"
13
17
 
14
- type WalletAddressProps = {
15
- address: string
16
- type: "bitcoin" | "evm"
17
- }
18
-
19
- export default function WalletAddress(props: WalletAddressProps) {
20
- const { address, type } = props
21
-
22
- const { environment } = usePassportContext()
23
- const blockExplorerUrl = getAddressExplorerUrl(
24
- address,
25
- type,
26
- environment === "testnet",
27
- )
28
- const trimmedAddress = trimAddress(address)
29
- const { icon: accountIcon } = getCryptoAsset(
30
- type === "bitcoin" ? "BTC" : "ETH",
31
- )
18
+ export default function WalletAddress(props: BlockProps) {
19
+ const { overrides, ...restProps } = props
32
20
 
21
+ const { data, isError, isPending } = useWalletAccount()
22
+ const { environment = "mainnet" } = usePassportContext()
33
23
  const [, theme] = useStyletron()
34
-
35
24
  const [, copy] = useCopyToClipboard()
36
25
  const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
37
- const handleCopyAddress = useCallback(() => {
38
- copy(address)
26
+
27
+ if (isError) {
28
+ return "Error loading wallet address"
29
+ }
30
+
31
+ if (isPending) {
32
+ return "Loading..."
33
+ }
34
+
35
+ const { walletAddress, networkFamily } = data
36
+
37
+ const handleCopyAddress = () => {
38
+ copy(walletAddress)
39
39
  setIsCopiedMessageVisible(true)
40
40
 
41
41
  setTimeout(() => {
42
42
  setIsCopiedMessageVisible(false)
43
43
  }, 2000)
44
- }, [copy, address])
44
+ }
45
+
46
+ const blockExplorerUrl = getAddressExplorerUrl(
47
+ walletAddress,
48
+ networkFamily,
49
+ environment === "testnet",
50
+ )
51
+ const trimmedAddress = trimAddress(walletAddress)
52
+ const AccountIcon = networkFamily === "bitcoin" ? BitcoinCircle : EthCircle
45
53
 
46
54
  return (
47
55
  <Block
@@ -50,79 +58,77 @@ export default function WalletAddress(props: WalletAddressProps) {
50
58
  display="flex"
51
59
  alignItems="center"
52
60
  backgroundColor="transparent"
53
- padding={`${theme.sizing.scale600} ${theme.sizing.scale500}`}
54
- overrides={{
55
- Block: {
56
- style: {
57
- borderWidth: 0,
58
- cursor: "pointer",
59
- ":hover": {
60
- backgroundColor: theme.colors.backgroundTertiary,
61
+ padding={`${theme.sizing.scale800} ${theme.sizing.scale700}`}
62
+ overrides={mergeOverrides(
63
+ {
64
+ Block: {
65
+ style: {
66
+ gap: theme.sizing.scale700,
67
+ borderWidth: 0,
68
+ cursor: "pointer",
69
+ ":hover": {
70
+ backgroundColor: theme.colors.backgroundTertiary,
71
+ },
61
72
  },
62
73
  },
63
74
  },
64
- }}
65
- >
66
- <Block as={accountIcon} size={theme.sizing.scale600} />
67
- {isCopiedMessageVisible ? (
68
- <ParagraphSmall
69
- margin={0}
70
- marginLeft={theme.sizing.scale500}
71
- color={theme.colors.contentPrimary}
72
- >
73
- Copied address to clipboard
74
- </ParagraphSmall>
75
- ) : (
76
- <Block
77
- as="a"
78
- marginLeft={theme.sizing.scale500}
79
- href={blockExplorerUrl}
80
- target="_blank"
81
- overrides={{
82
- Block: {
83
- style: {
84
- color: "inherit",
85
- textDecoration: "none",
86
- ":hover": {
87
- textDecoration: "underline",
88
- },
89
- },
90
- },
91
- }}
92
- >
93
- <ParagraphSmall
94
- display="flex"
95
- alignItems="center"
96
- margin={0}
97
- color={theme.colors.contentPrimary}
98
- >
99
- {trimmedAddress}
100
- <LinkIcon
101
- display="inline"
102
- size={theme.sizing.scale550}
103
- overrides={{
104
- Svg: {
105
- style: {
106
- stroke: "currentColor",
107
- marginLeft: theme.sizing.scale300,
108
- },
109
- },
110
- }}
111
- />
112
- </ParagraphSmall>
113
- </Block>
75
+ overrides,
114
76
  )}
115
- <CopyIcon
116
- size={theme.sizing.scale550}
117
- color={theme.colors.contentPrimary}
77
+ {...restProps}
78
+ >
79
+ <AccountIcon
80
+ color={theme.colors.black}
81
+ size={theme.sizing.scale800}
118
82
  overrides={{
119
83
  Svg: {
120
84
  style: {
121
- marginLeft: "auto",
85
+ backgroundColor: theme.colors.black,
86
+ overflow: "hidden",
87
+ borderRadius: theme.borders.radius200,
122
88
  },
123
89
  },
124
90
  }}
125
91
  />
92
+ <Block
93
+ display="flex"
94
+ flexDirection="column"
95
+ alignItems="flex-start"
96
+ overrides={{
97
+ Block: {
98
+ style: {
99
+ gap: theme.sizing.scale100,
100
+ },
101
+ },
102
+ }}
103
+ >
104
+ <LabelMedium>Connected Wallet</LabelMedium>
105
+
106
+ {isCopiedMessageVisible ? (
107
+ <LabelXSmall color={theme.colors.contentSecondary}>
108
+ Copied address to clipboard
109
+ </LabelXSmall>
110
+ ) : (
111
+ <Block
112
+ as="a"
113
+ color={theme.colors.contentSecondary}
114
+ href={blockExplorerUrl}
115
+ target="_blank"
116
+ overrides={{
117
+ Block: {
118
+ style: {
119
+ color: "inherit",
120
+ textDecoration: "none",
121
+ ":hover": {
122
+ textDecoration: "underline",
123
+ },
124
+ },
125
+ },
126
+ }}
127
+ >
128
+ <MonoLabelXSmall>{trimmedAddress}</MonoLabelXSmall>
129
+ </Block>
130
+ )}
131
+ </Block>
126
132
  </Block>
127
133
  )
128
134
  }
@@ -1,32 +1,33 @@
1
1
  import {
2
2
  Block,
3
- HeadingSmall,
4
- LabelSmall,
3
+ BlockProps,
4
+ HeadingMedium,
5
+ LabelLarge,
5
6
  Mats,
7
+ mergeOverrides,
8
+ Skeleton,
6
9
  useStyletron,
7
10
  } from "@mezo-org/mezo-clay"
8
11
  import React from "react"
9
12
  import DefaultAvatar from "../../../assets/DefaultAvatar"
13
+ import { useGetCurrentAccount } from "../../../hooks"
14
+ import { formatNumberToCompactString } from "../../../utils/numbers"
15
+ import AccountError from "./AccountError"
16
+ import { usePassportContext } from "../../../hooks/usePassportContext"
17
+ import SlotNumber from "../SlotNumber"
10
18
 
11
19
  const DOT_DELIMITER_REGEX = /(?=\.)/
12
20
 
13
- type WelcomeBlockProps = {
14
- mezoId: string
15
- matsBalance: string
16
- }
17
-
18
- export default function WelcomeBlock(props: WelcomeBlockProps) {
19
- const { mezoId, matsBalance } = props
20
-
21
- const [name, nameSuffix] = mezoId.split(DOT_DELIMITER_REGEX)
21
+ function WelcomeBlockSkeleton() {
22
22
  const [, theme] = useStyletron()
23
23
 
24
24
  return (
25
25
  <Block
26
26
  display="flex"
27
27
  alignItems="center"
28
- padding={`${theme.sizing.scale600} 0`}
29
- marginBottom={theme.sizing.scale300}
28
+ padding={theme.sizing.scale600}
29
+ paddingTop={theme.sizing.scale900}
30
+ paddingBottom={theme.sizing.scale800}
30
31
  overrides={{
31
32
  Block: {
32
33
  style: {
@@ -35,12 +36,12 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
35
36
  },
36
37
  }}
37
38
  >
38
- <Block
39
- as={DefaultAvatar}
39
+ <Skeleton
40
+ animation
40
41
  width={theme.sizing.scale1200}
41
42
  height={theme.sizing.scale1200}
42
43
  overrides={{
43
- Block: {
44
+ Root: {
44
45
  style: {
45
46
  borderRadius: "100%",
46
47
  },
@@ -51,6 +52,7 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
51
52
  <Block
52
53
  display="flex"
53
54
  flexDirection="column"
55
+ flex={1}
54
56
  overrides={{
55
57
  Block: {
56
58
  style: {
@@ -59,32 +61,110 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
59
61
  },
60
62
  }}
61
63
  >
62
- <HeadingSmall as="span">
63
- <Block as="span">{name}</Block>
64
- <Block as="span" color={theme.colors.gray500}>
65
- {nameSuffix}
64
+ <Skeleton animation width="60%" height={theme.sizing.scale900} />
65
+ <Skeleton animation width="40%" height={theme.sizing.scale800} />
66
+ </Block>
67
+ </Block>
68
+ )
69
+ }
70
+
71
+ type WelcomeBlockProps = BlockProps
72
+
73
+ export default function WelcomeBlock(props: WelcomeBlockProps) {
74
+ const { overrides, ...restProps } = props
75
+ const { accountDataRefetchInterval } = usePassportContext()
76
+
77
+ const { data, isError, isPending } = useGetCurrentAccount({
78
+ staleTime: accountDataRefetchInterval,
79
+ refetchInterval: accountDataRefetchInterval,
80
+ })
81
+ const [, theme] = useStyletron()
82
+
83
+ if (isError) {
84
+ return (
85
+ <AccountError
86
+ padding={theme.sizing.scale600}
87
+ paddingTop={theme.sizing.scale900}
88
+ paddingBottom={theme.sizing.scale800}
89
+ marginBottom={theme.sizing.scale300}
90
+ topic="account information"
91
+ />
92
+ )
93
+ }
94
+
95
+ if (isPending) {
96
+ return <WelcomeBlockSkeleton />
97
+ }
98
+
99
+ const [mezoId, mezoIdSuffix] = data.mezoId.split(DOT_DELIMITER_REGEX)
100
+
101
+ return (
102
+ <Block
103
+ display="flex"
104
+ alignItems="center"
105
+ paddingLeft={theme.sizing.scale600}
106
+ paddingRight={theme.sizing.scale600}
107
+ paddingTop={theme.sizing.scale900}
108
+ paddingBottom={theme.sizing.scale800}
109
+ overrides={mergeOverrides(overrides, {
110
+ Block: {
111
+ style: {
112
+ gap: theme.sizing.scale600,
113
+ },
114
+ },
115
+ })}
116
+ {...restProps}
117
+ >
118
+ <Block
119
+ as={DefaultAvatar}
120
+ width={theme.sizing.scale1200}
121
+ height={theme.sizing.scale1200}
122
+ overrides={{
123
+ Block: {
124
+ style: {
125
+ borderRadius: "100%",
126
+ },
127
+ },
128
+ }}
129
+ />
130
+
131
+ <Block display="flex" flexDirection="column">
132
+ <HeadingMedium as="span">
133
+ <Block as="span">{mezoId}</Block>
134
+ <Block as="span" color={theme.colors.contentSecondary}>
135
+ {mezoIdSuffix}
66
136
  </Block>
67
- </HeadingSmall>
137
+ </HeadingMedium>
68
138
 
69
- <LabelSmall
139
+ <Block
70
140
  display="flex"
71
141
  alignItems="center"
72
- margin={0}
73
- color={theme.colors.contentTertiary}
74
142
  overrides={{
75
143
  Block: {
76
144
  style: {
77
- gap: theme.sizing.scale400,
145
+ gap: theme.sizing.scale100,
78
146
  },
79
147
  },
80
148
  }}
81
149
  >
82
150
  <Mats
83
- color={theme.colors.contentPrimary}
84
- size={theme.sizing.scale500}
151
+ size={theme.sizing.scale600}
152
+ overrides={{
153
+ Svg: {
154
+ style: {
155
+ margin: theme.sizing.scale100, // To reduce gap
156
+ },
157
+ },
158
+ }}
85
159
  />
86
- {matsBalance} mats
87
- </LabelSmall>
160
+
161
+ <LabelLarge color={theme.colors.contentPrimary}>
162
+ <SlotNumber formatFunction={formatNumberToCompactString}>
163
+ {data.mats.totalMats}
164
+ </SlotNumber>{" "}
165
+ mats
166
+ </LabelLarge>
167
+ </Block>
88
168
  </Block>
89
169
  </Block>
90
170
  )
@@ -0,0 +1,131 @@
1
+ /* eslint-disable react/no-array-index-key */
2
+ import React, { useMemo } from "react"
3
+ import { AnimatePresence, motion } from "motion/react"
4
+ import { Block, useStyletron } from "@mezo-org/mezo-clay"
5
+
6
+ type SlotNumberProps = {
7
+ className?: string
8
+ children: number
9
+ formatFunction?: (value: number) => string
10
+ }
11
+
12
+ type SlotNumberDigitProps = {
13
+ className?: string
14
+ children: number
15
+ }
16
+
17
+ function SlotNumberDigit(props: SlotNumberDigitProps) {
18
+ const { children: value, ...restProps } = props
19
+
20
+ const [css] = useStyletron()
21
+
22
+ const digits = [...Array(10).keys()]
23
+
24
+ return (
25
+ <AnimatePresence initial={false}>
26
+ <motion.div
27
+ initial={{
28
+ y: "100%",
29
+ }}
30
+ animate={{
31
+ y: "0%",
32
+ }}
33
+ layout="position"
34
+ className={css({
35
+ position: "relative",
36
+ })}
37
+ {...restProps}
38
+ >
39
+ <Block
40
+ overrides={{
41
+ Block: {
42
+ style: {
43
+ visibility: "hidden",
44
+ },
45
+ },
46
+ }}
47
+ >
48
+ {value}
49
+ </Block>
50
+
51
+ <motion.div
52
+ className={css({
53
+ display: "flex",
54
+ flexDirection: "column",
55
+ position: "absolute",
56
+ inset: 0,
57
+ height: "fit-content",
58
+ })}
59
+ initial={false}
60
+ animate={{ y: `${(value / 10) * -100}%` }}
61
+ transition={{
62
+ type: "spring",
63
+ damping: 16,
64
+ stiffness: 220,
65
+ }}
66
+ >
67
+ {digits.map((digit) => (
68
+ <Block as="span" key={digit}>
69
+ {digit}
70
+ </Block>
71
+ ))}
72
+ </motion.div>
73
+ </motion.div>
74
+ </AnimatePresence>
75
+ )
76
+ }
77
+
78
+ /**
79
+ * SlotNumber component displays a number with animated digits.
80
+ *
81
+ * @typedef {object} SlotNumberProps
82
+ * @property {number} children - The number to display.
83
+ * @property {function} [formatFunction] - Optional function to format the number.
84
+ * @property {BlockProps} [restProps] - Additional properties for the Block component.
85
+ * @see https://pyszkowski.dev/writings/slot-number
86
+ * @returns {JSX.Element} The rendered SlotNumber component.
87
+ */
88
+ function SlotNumber(props: SlotNumberProps) {
89
+ const { children: value, formatFunction, ...restProps } = props
90
+
91
+ const [css] = useStyletron()
92
+
93
+ const characters = useMemo(() => {
94
+ const formattedValue = formatFunction
95
+ ? formatFunction(value)
96
+ : value.toString()
97
+
98
+ return formattedValue
99
+ .split("")
100
+ .map((character) => (/^[0-9]$/.test(character) ? +character : character))
101
+ .reverse()
102
+ }, [formatFunction, value])
103
+
104
+ return (
105
+ <motion.div
106
+ layout
107
+ className={css({
108
+ display: "inline-flex",
109
+ flexDirection: "row-reverse",
110
+ justifyContent: "flex-end",
111
+ overflow: "hidden",
112
+ userSelect: "none",
113
+ })}
114
+ {...restProps}
115
+ >
116
+ {characters.map((character, index) =>
117
+ typeof character === "number" ? (
118
+ <SlotNumberDigit key={`slot-number-character-${index}`}>
119
+ {character}
120
+ </SlotNumberDigit>
121
+ ) : (
122
+ <motion.span layout key={`slot-number-character-${index}`}>
123
+ {character}
124
+ </motion.span>
125
+ ),
126
+ )}
127
+ </motion.div>
128
+ )
129
+ }
130
+
131
+ export default SlotNumber
package/src/config.ts CHANGED
@@ -72,16 +72,6 @@ export const xverseWalletMezoMainnet = getXverseWallet(
72
72
  bitcoinWalletMainnetConfig,
73
73
  )
74
74
 
75
- export const preconfiguredWalletConnectWallet = (projectId: string) =>
76
- walletConnectWallet({
77
- projectId,
78
- options: {
79
- qrModalOptions: {
80
- enableExplorer: false,
81
- },
82
- },
83
- })
84
-
85
75
  export function getDefaultWallets(
86
76
  network: "mainnet" | "testnet" = "mainnet",
87
77
  ): WalletList {
@@ -103,7 +93,7 @@ export function getDefaultWallets(
103
93
  },
104
94
  {
105
95
  groupName: "Ethereum",
106
- wallets: [({ projectId }) => preconfiguredWalletConnectWallet(projectId)],
96
+ wallets: [walletConnectWallet],
107
97
  },
108
98
  ]
109
99
  }