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

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 (173) hide show
  1. package/dist/src/components/Dropdown/Content.d.ts +0 -15
  2. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  3. package/dist/src/components/Dropdown/Content.js +3 -3
  4. package/dist/src/components/Dropdown/Content.js.map +1 -1
  5. package/dist/src/components/Dropdown/Dropdown.d.ts +0 -4
  6. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  7. package/dist/src/components/Dropdown/Dropdown.js +10 -36
  8. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  9. package/dist/src/components/Dropdown/ListingItem.d.ts +8 -7
  10. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -1
  11. package/dist/src/components/Dropdown/ListingItem.js +36 -28
  12. package/dist/src/components/Dropdown/ListingItem.js.map +1 -1
  13. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +2 -1
  14. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -1
  15. package/dist/src/components/Dropdown/NestedViewLayout.js +13 -15
  16. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -1
  17. package/dist/src/components/Dropdown/Receive/Receive.d.ts +1 -4
  18. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -1
  19. package/dist/src/components/Dropdown/Receive/Receive.js +30 -19
  20. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
  21. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +2 -5
  22. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -1
  23. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +13 -12
  24. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
  25. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +2 -4
  26. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -1
  27. package/dist/src/components/Dropdown/Root/AccountBalance.js +24 -8
  28. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -1
  29. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
  30. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
  32. package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
  33. package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
  34. package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
  35. package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
  36. package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
  37. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
  38. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
  40. package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
  41. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +2 -3
  42. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -1
  43. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +34 -39
  44. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -1
  45. package/dist/src/components/Dropdown/Root/Root.d.ts +0 -15
  46. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
  47. package/dist/src/components/Dropdown/Root/Root.js +22 -34
  48. package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
  49. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +2 -6
  50. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -1
  51. package/dist/src/components/Dropdown/Root/WalletAddress.js +37 -34
  52. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
  53. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +2 -4
  54. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -1
  55. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +60 -16
  56. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -1
  57. package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
  58. package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
  59. package/dist/src/components/Dropdown/SlotNumber.js +67 -0
  60. package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
  61. package/dist/src/config.d.ts +0 -1
  62. package/dist/src/config.d.ts.map +1 -1
  63. package/dist/src/config.js +1 -9
  64. package/dist/src/config.js.map +1 -1
  65. package/dist/src/hooks/useAssetsConversionRates.d.ts +8 -13
  66. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -1
  67. package/dist/src/hooks/useAssetsConversionRates.js +44 -67
  68. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -1
  69. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  70. package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
  71. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  72. package/dist/src/hooks/useBorrowData.d.ts +30 -4
  73. package/dist/src/hooks/useBorrowData.d.ts.map +1 -1
  74. package/dist/src/hooks/useBorrowData.js +53 -11
  75. package/dist/src/hooks/useBorrowData.js.map +1 -1
  76. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  77. package/dist/src/hooks/useCreateAccount.js +3 -3
  78. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  79. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  80. package/dist/src/hooks/useGetCurrentAccount.js +4 -6
  81. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  82. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  83. package/dist/src/hooks/useLinkAccount.js +3 -3
  84. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  85. package/dist/src/hooks/useTokensBalances.d.ts +36 -35
  86. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
  87. package/dist/src/hooks/useTokensBalances.js +93 -52
  88. package/dist/src/hooks/useTokensBalances.js.map +1 -1
  89. package/dist/src/hooks/useWalletAccount.d.ts +8 -6
  90. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  91. package/dist/src/hooks/useWalletAccount.js +9 -6
  92. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  93. package/dist/src/lib/contracts/index.d.ts +1 -1
  94. package/dist/src/lib/contracts/index.d.ts.map +1 -1
  95. package/dist/src/lib/contracts/index.js +4 -0
  96. package/dist/src/lib/contracts/index.js.map +1 -1
  97. package/dist/src/provider.d.ts +7 -1
  98. package/dist/src/provider.d.ts.map +1 -1
  99. package/dist/src/provider.js +4 -1
  100. package/dist/src/provider.js.map +1 -1
  101. package/dist/src/utils/assets.d.ts +145 -0
  102. package/dist/src/utils/assets.d.ts.map +1 -0
  103. package/dist/src/utils/assets.js +100 -0
  104. package/dist/src/utils/assets.js.map +1 -0
  105. package/dist/src/utils/assets.test.d.ts +2 -0
  106. package/dist/src/utils/assets.test.d.ts.map +1 -0
  107. package/dist/src/utils/assets.test.js +46 -0
  108. package/dist/src/utils/assets.test.js.map +1 -0
  109. package/dist/src/utils/currency.d.ts +6 -3
  110. package/dist/src/utils/currency.d.ts.map +1 -1
  111. package/dist/src/utils/currency.js +13 -10
  112. package/dist/src/utils/currency.js.map +1 -1
  113. package/dist/src/utils/currency.test.js +44 -2
  114. package/dist/src/utils/currency.test.js.map +1 -1
  115. package/dist/src/utils/numbers.d.ts +13 -53
  116. package/dist/src/utils/numbers.d.ts.map +1 -1
  117. package/dist/src/utils/numbers.js +16 -118
  118. package/dist/src/utils/numbers.js.map +1 -1
  119. package/dist/src/utils/numbers.test.js +24 -142
  120. package/dist/src/utils/numbers.test.js.map +1 -1
  121. package/package.json +2 -1
  122. package/src/components/Dropdown/Content.tsx +3 -48
  123. package/src/components/Dropdown/Dropdown.tsx +7 -58
  124. package/src/components/Dropdown/ListingItem.tsx +155 -59
  125. package/src/components/Dropdown/NestedViewLayout.tsx +32 -20
  126. package/src/components/Dropdown/Receive/Receive.tsx +57 -32
  127. package/src/components/Dropdown/Root/AccountAddressActions.tsx +33 -35
  128. package/src/components/Dropdown/Root/AccountBalance.tsx +54 -16
  129. package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
  130. package/src/components/Dropdown/Root/AccountError.tsx +34 -0
  131. package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
  132. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -46
  133. package/src/components/Dropdown/Root/Root.tsx +28 -98
  134. package/src/components/Dropdown/Root/WalletAddress.tsx +87 -89
  135. package/src/components/Dropdown/Root/WelcomeBlock.tsx +112 -30
  136. package/src/components/Dropdown/SlotNumber.tsx +131 -0
  137. package/src/config.ts +1 -11
  138. package/src/hooks/useAssetsConversionRates.ts +49 -67
  139. package/src/hooks/useAuthenticateWithWallet.ts +7 -5
  140. package/src/hooks/useBorrowData.ts +71 -12
  141. package/src/hooks/useCreateAccount.ts +5 -4
  142. package/src/hooks/useGetCurrentAccount.ts +5 -7
  143. package/src/hooks/useLinkAccount.ts +5 -4
  144. package/src/hooks/useTokensBalances.ts +152 -74
  145. package/src/hooks/useWalletAccount.ts +19 -13
  146. package/src/lib/contracts/index.ts +8 -1
  147. package/src/provider.ts +11 -3
  148. package/src/utils/assets.test.ts +57 -0
  149. package/src/utils/assets.ts +103 -0
  150. package/src/utils/currency.test.ts +76 -2
  151. package/src/utils/currency.ts +20 -15
  152. package/src/utils/numbers.test.ts +29 -180
  153. package/src/utils/numbers.ts +22 -171
  154. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +0 -11
  155. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +0 -1
  156. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +0 -9
  157. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +0 -1
  158. package/dist/src/hooks/useDropdownData.d.ts +0 -47
  159. package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
  160. package/dist/src/hooks/useDropdownData.js +0 -97
  161. package/dist/src/hooks/useDropdownData.js.map +0 -1
  162. package/dist/src/utils/cryptoAssets.d.ts +0 -44
  163. package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
  164. package/dist/src/utils/cryptoAssets.js +0 -129
  165. package/dist/src/utils/cryptoAssets.js.map +0 -1
  166. package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
  167. package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
  168. package/dist/src/utils/cryptoAssets.test.js +0 -67
  169. package/dist/src/utils/cryptoAssets.test.js.map +0 -1
  170. package/src/components/Dropdown/Root/AccountAssetItem.tsx +0 -26
  171. package/src/hooks/useDropdownData.ts +0 -152
  172. package/src/utils/cryptoAssets.test.ts +0 -79
  173. 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,42 @@ 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 { data: walletAccountData } = useWalletAccount()
31
22
 
32
23
  const [, theme] = useStyletron()
33
24
 
34
25
  const [, copy] = useCopyToClipboard()
26
+
35
27
  const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
36
- const handleCopyAddress = useCallback(() => {
37
- copy(address)
28
+
29
+ const handleCopyAddress = () => {
30
+ copy(walletAccountData.accountAddress!)
38
31
  setIsCopiedMessageVisible(true)
39
32
 
40
33
  setTimeout(() => {
41
34
  setIsCopiedMessageVisible(false)
42
35
  }, 2000)
43
- }, [copy, address])
36
+ }
44
37
 
45
- const { networkFamily } = useWalletAccount()
38
+ const blockExplorerUrl = getAddressExplorerUrl(
39
+ walletAccountData.accountAddress!,
40
+ "mezo",
41
+ environment === "testnet",
42
+ )
46
43
 
47
44
  return (
48
45
  <NestedViewLayout>
49
- <LabelMedium>Your Mezo Address</LabelMedium>
46
+ <LabelLarge>Your Mezo Address</LabelLarge>
50
47
 
51
48
  <ParagraphSmall
52
- marginTop={theme.sizing.scale300}
53
- marginBottom={theme.sizing.scale600}
49
+ marginTop={0}
50
+ marginBottom={theme.sizing.scale800}
54
51
  color={theme.colors.contentTertiary}
55
52
  >
56
- {networkFamily === "bitcoin" ? (
53
+ {walletAccountData.networkFamily === "bitcoin" ? (
57
54
  <>
58
55
  Mezo automatically created a smart account that&apos;s fully
59
56
  controlled by your connected Bitcoin wallet. Use this address to
@@ -69,7 +66,7 @@ function Receive(props: ReceiveProps) {
69
66
 
70
67
  <Block
71
68
  as={QRCodeSVG}
72
- value={address}
69
+ value={walletAccountData.accountAddress!}
73
70
  flex={1}
74
71
  overrides={{
75
72
  Block: {
@@ -82,35 +79,63 @@ function Receive(props: ReceiveProps) {
82
79
  }}
83
80
  />
84
81
 
85
- <MonoLabelXSmall
82
+ <Block
83
+ display="flex"
84
+ alignItems="center"
85
+ backgroundColor={theme.colors.backgroundSecondary}
86
86
  marginTop={theme.sizing.scale800}
87
- marginBottom={theme.sizing.scale800}
87
+ marginBottom={theme.sizing.scale600}
88
+ padding={theme.sizing.scale300}
88
89
  overrides={{
89
90
  Block: {
90
91
  style: {
91
- textAlign: "center",
92
+ gap: theme.sizing.scale300,
93
+ borderRadius: theme.borders.radius400,
92
94
  },
93
95
  },
94
96
  }}
95
97
  >
96
- {address}
97
- </MonoLabelXSmall>
98
+ <MezoCircle
99
+ size={theme.sizing.scale700}
100
+ color={theme.colors.accent}
101
+ symbolColor={theme.colors.white}
102
+ overrides={{
103
+ Svg: {
104
+ style: {
105
+ backgroundColor: theme.colors.accent,
106
+ overflow: "hidden",
107
+ borderRadius: theme.borders.radius200,
108
+ flexShrink: 0,
109
+ },
110
+ },
111
+ }}
112
+ />
113
+
114
+ <MonoLabelXSmall>{walletAccountData.accountAddress}</MonoLabelXSmall>
115
+ </Block>
98
116
 
99
117
  <Button
100
118
  onClick={handleCopyAddress}
119
+ size="medium"
101
120
  overrides={{
102
121
  BaseButton: {
103
122
  style: {
104
- marginBottom: theme.sizing.scale400,
123
+ marginBottom: theme.sizing.scale500,
105
124
  },
106
125
  },
107
126
  }}
108
127
  >
109
- {isCopiedMessageVisible ? "Copied!" : "Copy Mezo Address"}
128
+ {isCopiedMessageVisible ? "Copied!" : "Copy Mezo address"}
110
129
  </Button>
111
130
 
112
- <Button kind="secondary" $as="a" href={blockExplorerUrl} target="_blank">
113
- View Explorer
131
+ <Button
132
+ kind="secondary"
133
+ size="medium"
134
+ $as="a"
135
+ href={blockExplorerUrl}
136
+ target="_blank"
137
+ >
138
+ View Mezo explorer
114
139
  </Button>
115
140
  </NestedViewLayout>
116
141
  )