@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
@@ -5,15 +5,13 @@ import {
5
5
  useStyletron,
6
6
  } from "@mezo-org/mezo-clay"
7
7
  import { useConnectModal } from "@rainbow-me/rainbowkit"
8
- import React, { useEffect, useMemo } from "react"
9
- import { useDisconnect } from "wagmi"
8
+ import React from "react"
10
9
  import DefaultAvatar from "../../assets/DefaultAvatar"
11
- import useWalletAccount from "../../hooks/useWalletAccount"
12
10
  import ConnectedTrigger from "./ConnectedTrigger"
13
11
  import Content from "./Content"
14
12
  import DisconnectedTrigger from "./DisconnectedTrigger"
15
- import { useSignInWithWallet } from "../../hooks"
16
- import useDropdownData from "../../hooks/useDropdownData"
13
+ import useWalletAccount from "../../hooks/useWalletAccount"
14
+ import { useWatchTransferEventsForAllTokens } from "../../hooks/useWatchTransferEvents"
17
15
 
18
16
  export type DropdownProps = {
19
17
  /** The callback to be called when the user clicks the sign-out button */
@@ -28,10 +26,6 @@ export type DropdownProps = {
28
26
  signedOut?: Omit<ButtonProps, "onClick">
29
27
  }
30
28
  onOtherAssetsClick?: () => void
31
- /** Time in milliseconds after which account data (like mats or mezo id) in dropdown should be re-fetched. Default is 90000 (90 secs) */
32
- accountDataRefetchInterval?: number
33
- /** Time in milliseconds after which native balance in dropdown should be re-fetched. Default is 90000 (90 secs) */
34
- nativeBalanceRefetchInterval?: number
35
29
  } & Omit<StatefulPopoverProps, "children" | "content">
36
30
 
37
31
  /**
@@ -48,57 +42,23 @@ export function Dropdown(props: DropdownProps) {
48
42
  overrides,
49
43
  triggerProps,
50
44
  onOtherAssetsClick,
51
- accountDataRefetchInterval,
52
- nativeBalanceRefetchInterval,
53
45
  ...restProps
54
46
  } = props
55
47
 
56
48
  const [, theme] = useStyletron()
57
49
 
58
- const data = useDropdownData({
59
- accountDataRefetchInterval,
60
- nativeBalanceRefetchInterval,
61
- })
50
+ const { data: walletAccountData } = useWalletAccount()
62
51
 
63
- const isCriticalDropdownDataLoaded = useMemo(
64
- () => Boolean(data.mezoId && data.accountAddress && data.walletAddress),
65
- [data],
66
- )
52
+ useWatchTransferEventsForAllTokens()
67
53
 
68
54
  const { openConnectModal } = useConnectModal()
69
55
 
70
- const { isConnected } = useWalletAccount()
71
-
72
- const { signInWithWalletAsync, isPending } = useSignInWithWallet()
73
-
74
- const { disconnectAsync } = useDisconnect()
75
-
76
- useEffect(() => {
77
- if (onSignIn) return
78
-
79
- const handleSignIn = async () => {
80
- console.log("handle sign in...")
81
- if (!isConnected) return
82
-
83
- try {
84
- console.log("sign in with wallet async")
85
- await signInWithWalletAsync()
86
- } catch (error) {
87
- console.log("disconnect async")
88
- await disconnectAsync()
89
- }
90
- }
91
-
92
- handleSignIn()
93
- }, [disconnectAsync, isConnected, onSignIn, signInWithWalletAsync])
94
-
95
- if (!isConnected || !isCriticalDropdownDataLoaded) {
56
+ if (!walletAccountData?.isConnected) {
96
57
  return (
97
58
  <DisconnectedTrigger
98
59
  // If connect wallet flow is not provided it fallbacks to RainbowKit's
99
60
  // connect modal
100
61
  onClick={onSignIn || openConnectModal}
101
- isLoading={isPending}
102
62
  {...triggerProps?.signedOut}
103
63
  >
104
64
  Sign in
@@ -110,17 +70,6 @@ export function Dropdown(props: DropdownProps) {
110
70
  <StatefulPopover
111
71
  content={
112
72
  <Content
113
- mezoId={data.mezoId!}
114
- matsBalance={data.matsBalance}
115
- accountAddress={data.accountAddress!}
116
- walletAddress={data.walletAddress!}
117
- walletType={data.walletType}
118
- usdTotalBalance={data.usdTotalBalance}
119
- usdTroveDebt={data.usdTroveDebt}
120
- usdCollateral={data.usdCollateral}
121
- assets={data.assets}
122
- otherAssetsCount={data.otherAssetsCount}
123
- otherAssetsUsdTotal={data.otherAssetsUsdTotal}
124
73
  onSignOut={onSignOut}
125
74
  onOtherAssetsClick={onOtherAssetsClick}
126
75
  />
@@ -132,7 +81,7 @@ export function Dropdown(props: DropdownProps) {
132
81
  Body: {
133
82
  ...overrides?.Body,
134
83
  style: {
135
- width: "396px",
84
+ width: "402px",
136
85
  borderRadius: theme.borders.radius500,
137
86
  boxShadow: theme.lighting.shadow500,
138
87
  overflow: "hidden",
@@ -1,80 +1,176 @@
1
1
  import {
2
- ListItem,
3
- ListItemLabel,
4
2
  mergeOverrides,
5
- ListItemLabelProps,
6
- IconProps,
7
- ListItemProps,
3
+ Block,
4
+ useStyletron,
5
+ BlockProps,
6
+ Skeleton,
7
+ LabelMedium,
8
+ ParagraphSmall,
8
9
  } from "@mezo-org/mezo-clay"
9
- import React, { FC } from "react"
10
+ import React, { ReactNode } from "react"
11
+ import SlotNumber from "./SlotNumber"
12
+ import { formatUsd } from "../../utils/currency"
10
13
 
11
- const SHARED_LABEL_OVERRIDES: ListItemLabelProps["overrides"] = {
12
- LabelDescription: {
13
- style: {
14
- color: "#4B4B4B", // contentSecondary
15
- },
16
- },
14
+ type ListingItemLayoutProps = Omit<BlockProps, "children"> & {
15
+ icon: ReactNode
16
+ label: ReactNode
17
+ value: ReactNode
18
+ subLabel: ReactNode
19
+ subValue: ReactNode
20
+ }
21
+
22
+ function ListingItemLayout(props: ListingItemLayoutProps) {
23
+ const { icon, label, value, subLabel, subValue, overrides, ...restProps } =
24
+ props
25
+ const [, theme] = useStyletron()
26
+
27
+ return (
28
+ <Block
29
+ display="flex"
30
+ alignItems="center"
31
+ paddingLeft={theme.sizing.scale600}
32
+ paddingRight={theme.sizing.scale600}
33
+ overrides={mergeOverrides(
34
+ {
35
+ Block: {
36
+ style: {
37
+ gap: theme.sizing.scale600,
38
+ minHeight: "72px",
39
+ },
40
+ },
41
+ },
42
+ overrides,
43
+ )}
44
+ {...restProps}
45
+ >
46
+ {icon && icon}
47
+
48
+ <Block display="flex" flexDirection="column" alignItems="flex-start">
49
+ {label && label}
50
+ {subLabel && subLabel}
51
+ </Block>
52
+
53
+ <Block
54
+ display="flex"
55
+ flexDirection="column"
56
+ alignItems="flex-end"
57
+ marginLeft="auto"
58
+ >
59
+ {value && value}
60
+ {subValue && subValue}
61
+ </Block>
62
+ </Block>
63
+ )
17
64
  }
18
65
 
19
66
  type ListingItemProps = {
20
- icon?: FC<IconProps>
21
- label: string
67
+ icon?: ReactNode
68
+ label?: string
22
69
  subLabel?: string
23
- value: string
24
- subValue?: string
25
- overrides?: ListItemProps["overrides"]
70
+ value?: number
71
+ subValue?: number
72
+ overrides?: BlockProps["overrides"]
73
+ isLoading?: boolean
26
74
  }
27
75
 
28
76
  export default function ListingItem(props: ListingItemProps) {
29
77
  const {
30
- icon: Icon,
78
+ icon,
31
79
  label,
32
- subLabel = "",
80
+ subLabel,
33
81
  value,
34
- subValue = "",
82
+ subValue,
35
83
  overrides,
84
+ isLoading = false,
36
85
  } = props
37
86
 
38
- return (
39
- <ListItem
40
- artwork={Icon}
41
- // eslint-disable-next-line react/no-unstable-nested-components
42
- endEnhancer={() => (
43
- <ListItemLabel
44
- description={subValue}
45
- overrides={mergeOverrides(
46
- {
47
- LabelRoot: {
48
- style: {
49
- textAlign: "right",
50
- },
87
+ const [, theme] = useStyletron()
88
+
89
+ if (isLoading) {
90
+ return (
91
+ <ListingItemLayout
92
+ icon={
93
+ <Skeleton
94
+ animation
95
+ width={theme.sizing.scale800}
96
+ height={theme.sizing.scale800}
97
+ />
98
+ }
99
+ label={
100
+ <Skeleton
101
+ animation
102
+ width={theme.sizing.scale2400}
103
+ height={theme.sizing.scale600}
104
+ overrides={{
105
+ Root: {
106
+ style: { marginBottom: theme.sizing.scale100 },
51
107
  },
52
- },
53
- SHARED_LABEL_OVERRIDES,
54
- )}
108
+ }}
109
+ />
110
+ }
111
+ subLabel={
112
+ <Skeleton
113
+ animation
114
+ width={theme.sizing.scale1600}
115
+ height={theme.sizing.scale550}
116
+ />
117
+ }
118
+ value={
119
+ <Skeleton
120
+ animation
121
+ width={theme.sizing.scale2400}
122
+ height={theme.sizing.scale600}
123
+ overrides={{
124
+ Root: {
125
+ style: { marginBottom: theme.sizing.scale100 },
126
+ },
127
+ }}
128
+ />
129
+ }
130
+ subValue={
131
+ <Skeleton
132
+ animation
133
+ width={theme.sizing.scale1600}
134
+ height={theme.sizing.scale550}
135
+ />
136
+ }
137
+ overrides={overrides}
138
+ />
139
+ )
140
+ }
141
+
142
+ return (
143
+ <ListingItemLayout
144
+ icon={icon}
145
+ label={<LabelMedium>{label}</LabelMedium>}
146
+ subLabel={
147
+ <ParagraphSmall
148
+ margin={0}
149
+ as="div"
150
+ color={theme.colors.contentSecondary}
55
151
  >
56
- {value}
57
- </ListItemLabel>
58
- )}
59
- overrides={mergeOverrides(
60
- {
61
- Root: {
62
- style: {
63
- backgroundColor: "transparent",
64
- },
65
- },
66
- Content: {
67
- style: {
68
- border: 0,
69
- },
70
- },
71
- },
72
- overrides,
73
- )}
74
- >
75
- <ListItemLabel description={subLabel} overrides={SHARED_LABEL_OVERRIDES}>
76
- {label}
77
- </ListItemLabel>
78
- </ListItem>
152
+ {subLabel}
153
+ </ParagraphSmall>
154
+ }
155
+ value={
156
+ value !== undefined && (
157
+ <LabelMedium>
158
+ <SlotNumber formatFunction={formatUsd}>{value}</SlotNumber>
159
+ </LabelMedium>
160
+ )
161
+ }
162
+ subValue={
163
+ subValue !== undefined && (
164
+ <ParagraphSmall
165
+ margin={0}
166
+ as="div"
167
+ color={theme.colors.contentSecondary}
168
+ >
169
+ <SlotNumber formatFunction={formatUsd}>{subValue}</SlotNumber>
170
+ </ParagraphSmall>
171
+ )
172
+ }
173
+ overrides={overrides}
174
+ />
79
175
  )
80
176
  }
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  ArrowLeft,
3
3
  Block,
4
+ BlockProps,
4
5
  ButtonIcon,
5
- LabelMedium,
6
+ HeadingSmall,
6
7
  useStyletron,
7
8
  } from "@mezo-org/mezo-clay"
8
9
  import React, { ReactNode, useCallback } from "react"
@@ -10,21 +11,20 @@ import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
10
11
 
11
12
  const getHeaderTitle = (view: DropdownView) => {
12
13
  const titleMap: Partial<Record<DropdownView, string>> = {
13
- [DropdownView.RECEIVE]: "Receive",
14
+ [DropdownView.RECEIVE]: "Scan to receive",
14
15
  }
15
16
  return titleMap[view]!
16
17
  }
17
18
 
18
19
  type NestedViewLayoutProps = {
19
20
  children: ReactNode
20
- }
21
+ } & BlockProps
21
22
 
22
23
  function NestedViewLayout(props: NestedViewLayoutProps) {
23
24
  const { children, ...restProps } = props
24
25
 
25
26
  const currentView = useDropdownStore((state) => state.view)
26
27
  const setView = useDropdownStore((state) => state.setView)
27
- const isNested = useDropdownStore((state) => state.isNestedView())
28
28
 
29
29
  const [, theme] = useStyletron()
30
30
 
@@ -37,37 +37,49 @@ function NestedViewLayout(props: NestedViewLayoutProps) {
37
37
  display="flex"
38
38
  flexDirection="column"
39
39
  minHeight="588px"
40
- padding={theme.sizing.scale700}
41
- paddingTop={0}
42
40
  {...restProps}
43
41
  >
44
42
  <Block
45
43
  display="flex"
46
44
  alignItems="center"
47
- paddingTop={theme.sizing.scale600}
48
- paddingBottom={theme.sizing.scale600}
45
+ padding={theme.sizing.scale100}
46
+ paddingTop={theme.sizing.scale800}
47
+ paddingBottom={theme.sizing.scale500}
49
48
  marginBottom={theme.sizing.scale300}
49
+ overrides={{
50
+ Block: {
51
+ style: {
52
+ gap: theme.sizing.scale300,
53
+ },
54
+ },
55
+ }}
50
56
  >
51
57
  <ButtonIcon
52
58
  onClick={handleOnButtonClick}
53
59
  shape="circle"
54
- size="small"
55
- overrides={{
56
- BaseButton: {
57
- style: {
58
- background: theme.colors.backgroundPrimary,
59
- marginRight: isNested ? theme.sizing.scale300 : undefined,
60
- },
61
- },
62
- }}
60
+ size="medium"
61
+ kind="tertiary"
63
62
  >
64
- <ArrowLeft size={theme.sizing.scale700} />
63
+ <ArrowLeft />
65
64
  </ButtonIcon>
66
65
 
67
- <LabelMedium>{getHeaderTitle(currentView)}</LabelMedium>
66
+ <HeadingSmall
67
+ marginTop={theme.sizing.scale300}
68
+ marginBottom={theme.sizing.scale300}
69
+ >
70
+ {getHeaderTitle(currentView)}
71
+ </HeadingSmall>
68
72
  </Block>
69
73
 
70
- {children}
74
+ <Block
75
+ display="flex"
76
+ flexDirection="column"
77
+ padding={theme.sizing.scale600}
78
+ paddingTop={0}
79
+ flex={1}
80
+ >
81
+ {children}
82
+ </Block>
71
83
  </Block>
72
84
  )
73
85
  }
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  Block,
3
3
  Button,
4
- LabelMedium,
4
+ LabelLarge,
5
+ MezoCircle,
5
6
  MonoLabelXSmall,
6
7
  ParagraphSmall,
7
8
  useStyletron,
8
9
  } from "@mezo-org/mezo-clay"
9
- import React, { useCallback, useState } from "react"
10
+ import React, { useState } from "react"
10
11
  import { useCopyToClipboard } from "usehooks-ts"
11
12
  import { QRCodeSVG } from "qrcode.react"
12
13
  import NestedViewLayout from "../NestedViewLayout"
@@ -14,46 +15,54 @@ import { getAddressExplorerUrl } from "../../../utils/address"
14
15
  import { usePassportContext } from "../../../hooks/usePassportContext"
15
16
  import useWalletAccount from "../../../hooks/useWalletAccount"
16
17
 
17
- type ReceiveProps = {
18
- address: string
19
- }
20
-
21
- function Receive(props: ReceiveProps) {
22
- const { address } = props
23
-
18
+ function Receive() {
24
19
  const { environment } = usePassportContext()
25
20
 
26
- const blockExplorerUrl = getAddressExplorerUrl(
27
- address,
28
- "mezo",
29
- environment === "testnet",
30
- )
21
+ const {
22
+ data: walletAccountData,
23
+ isError: isWalletAccountDataError,
24
+ isPending: isWalletAccountDataPending,
25
+ } = useWalletAccount()
31
26
 
32
27
  const [, theme] = useStyletron()
33
28
 
34
29
  const [, copy] = useCopyToClipboard()
30
+
35
31
  const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
36
- const handleCopyAddress = useCallback(() => {
37
- copy(address)
32
+
33
+ if (isWalletAccountDataError) {
34
+ return "Error loading wallet account data"
35
+ }
36
+
37
+ if (isWalletAccountDataPending) {
38
+ return "Loading wallet account data..."
39
+ }
40
+
41
+ const handleCopyAddress = () => {
42
+ copy(walletAccountData.accountAddress)
38
43
  setIsCopiedMessageVisible(true)
39
44
 
40
45
  setTimeout(() => {
41
46
  setIsCopiedMessageVisible(false)
42
47
  }, 2000)
43
- }, [copy, address])
48
+ }
44
49
 
45
- const { networkFamily } = useWalletAccount()
50
+ const blockExplorerUrl = getAddressExplorerUrl(
51
+ walletAccountData.accountAddress,
52
+ "mezo",
53
+ environment === "testnet",
54
+ )
46
55
 
47
56
  return (
48
57
  <NestedViewLayout>
49
- <LabelMedium>Your Mezo Address</LabelMedium>
58
+ <LabelLarge>Your Mezo Address</LabelLarge>
50
59
 
51
60
  <ParagraphSmall
52
- marginTop={theme.sizing.scale300}
53
- marginBottom={theme.sizing.scale600}
61
+ marginTop={0}
62
+ marginBottom={theme.sizing.scale800}
54
63
  color={theme.colors.contentTertiary}
55
64
  >
56
- {networkFamily === "bitcoin" ? (
65
+ {walletAccountData.networkFamily === "bitcoin" ? (
57
66
  <>
58
67
  Mezo automatically created a smart account that&apos;s fully
59
68
  controlled by your connected Bitcoin wallet. Use this address to
@@ -69,7 +78,7 @@ function Receive(props: ReceiveProps) {
69
78
 
70
79
  <Block
71
80
  as={QRCodeSVG}
72
- value={address}
81
+ value={walletAccountData.accountAddress}
73
82
  flex={1}
74
83
  overrides={{
75
84
  Block: {
@@ -82,35 +91,63 @@ function Receive(props: ReceiveProps) {
82
91
  }}
83
92
  />
84
93
 
85
- <MonoLabelXSmall
94
+ <Block
95
+ display="flex"
96
+ alignItems="center"
97
+ backgroundColor={theme.colors.backgroundSecondary}
86
98
  marginTop={theme.sizing.scale800}
87
- marginBottom={theme.sizing.scale800}
99
+ marginBottom={theme.sizing.scale600}
100
+ padding={theme.sizing.scale300}
88
101
  overrides={{
89
102
  Block: {
90
103
  style: {
91
- textAlign: "center",
104
+ gap: theme.sizing.scale300,
105
+ borderRadius: theme.borders.radius400,
92
106
  },
93
107
  },
94
108
  }}
95
109
  >
96
- {address}
97
- </MonoLabelXSmall>
110
+ <MezoCircle
111
+ size={theme.sizing.scale700}
112
+ color={theme.colors.accent}
113
+ symbolColor={theme.colors.white}
114
+ overrides={{
115
+ Svg: {
116
+ style: {
117
+ backgroundColor: theme.colors.accent,
118
+ overflow: "hidden",
119
+ borderRadius: theme.borders.radius200,
120
+ flexShrink: 0,
121
+ },
122
+ },
123
+ }}
124
+ />
125
+
126
+ <MonoLabelXSmall>{walletAccountData.accountAddress}</MonoLabelXSmall>
127
+ </Block>
98
128
 
99
129
  <Button
100
130
  onClick={handleCopyAddress}
131
+ size="medium"
101
132
  overrides={{
102
133
  BaseButton: {
103
134
  style: {
104
- marginBottom: theme.sizing.scale400,
135
+ marginBottom: theme.sizing.scale500,
105
136
  },
106
137
  },
107
138
  }}
108
139
  >
109
- {isCopiedMessageVisible ? "Copied!" : "Copy Mezo Address"}
140
+ {isCopiedMessageVisible ? "Copied!" : "Copy Mezo address"}
110
141
  </Button>
111
142
 
112
- <Button kind="secondary" $as="a" href={blockExplorerUrl} target="_blank">
113
- View Explorer
143
+ <Button
144
+ kind="secondary"
145
+ size="medium"
146
+ $as="a"
147
+ href={blockExplorerUrl}
148
+ target="_blank"
149
+ >
150
+ View Mezo explorer
114
151
  </Button>
115
152
  </NestedViewLayout>
116
153
  )