@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.
- package/dist/src/components/Dropdown/Content.d.ts +0 -15
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.js +3 -3
- package/dist/src/components/Dropdown/Content.js.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +0 -4
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.js +10 -36
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.d.ts +8 -7
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.js +36 -28
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +2 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -1
- package/dist/src/components/Dropdown/NestedViewLayout.js +13 -15
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -1
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +1 -4
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Receive/Receive.js +30 -19
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +2 -5
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +13 -12
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +2 -4
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.js +24 -8
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
- package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +2 -3
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +34 -39
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -1
- package/dist/src/components/Dropdown/Root/Root.d.ts +0 -15
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/Root.js +22 -34
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +2 -6
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.js +37 -34
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +2 -4
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +60 -16
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -1
- package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.js +67 -0
- package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +1 -9
- package/dist/src/config.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +8 -13
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.js +44 -67
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.d.ts +30 -4
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -1
- package/dist/src/hooks/useBorrowData.js +53 -11
- package/dist/src/hooks/useBorrowData.js.map +1 -1
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +3 -3
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +4 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +3 -3
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/useTokensBalances.d.ts +36 -35
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
- package/dist/src/hooks/useTokensBalances.js +93 -52
- package/dist/src/hooks/useTokensBalances.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +8 -6
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +9 -6
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +1 -1
- package/dist/src/lib/contracts/index.d.ts.map +1 -1
- package/dist/src/lib/contracts/index.js +4 -0
- package/dist/src/lib/contracts/index.js.map +1 -1
- package/dist/src/provider.d.ts +7 -1
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +4 -1
- package/dist/src/provider.js.map +1 -1
- package/dist/src/utils/assets.d.ts +145 -0
- package/dist/src/utils/assets.d.ts.map +1 -0
- package/dist/src/utils/assets.js +100 -0
- package/dist/src/utils/assets.js.map +1 -0
- package/dist/src/utils/assets.test.d.ts +2 -0
- package/dist/src/utils/assets.test.d.ts.map +1 -0
- package/dist/src/utils/assets.test.js +46 -0
- package/dist/src/utils/assets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +6 -3
- package/dist/src/utils/currency.d.ts.map +1 -1
- package/dist/src/utils/currency.js +13 -10
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/currency.test.js +44 -2
- package/dist/src/utils/currency.test.js.map +1 -1
- package/dist/src/utils/numbers.d.ts +13 -53
- package/dist/src/utils/numbers.d.ts.map +1 -1
- package/dist/src/utils/numbers.js +16 -118
- package/dist/src/utils/numbers.js.map +1 -1
- package/dist/src/utils/numbers.test.js +24 -142
- package/dist/src/utils/numbers.test.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Dropdown/Content.tsx +3 -48
- package/src/components/Dropdown/Dropdown.tsx +7 -58
- package/src/components/Dropdown/ListingItem.tsx +155 -59
- package/src/components/Dropdown/NestedViewLayout.tsx +32 -20
- package/src/components/Dropdown/Receive/Receive.tsx +57 -32
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +33 -35
- package/src/components/Dropdown/Root/AccountBalance.tsx +54 -16
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
- package/src/components/Dropdown/Root/AccountError.tsx +34 -0
- package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -46
- package/src/components/Dropdown/Root/Root.tsx +28 -98
- package/src/components/Dropdown/Root/WalletAddress.tsx +87 -89
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +112 -30
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/config.ts +1 -11
- package/src/hooks/useAssetsConversionRates.ts +49 -67
- package/src/hooks/useAuthenticateWithWallet.ts +7 -5
- package/src/hooks/useBorrowData.ts +71 -12
- package/src/hooks/useCreateAccount.ts +5 -4
- package/src/hooks/useGetCurrentAccount.ts +5 -7
- package/src/hooks/useLinkAccount.ts +5 -4
- package/src/hooks/useTokensBalances.ts +152 -74
- package/src/hooks/useWalletAccount.ts +19 -13
- package/src/lib/contracts/index.ts +8 -1
- package/src/provider.ts +11 -3
- package/src/utils/assets.test.ts +57 -0
- package/src/utils/assets.ts +103 -0
- package/src/utils/currency.test.ts +76 -2
- package/src/utils/currency.ts +20 -15
- package/src/utils/numbers.test.ts +29 -180
- package/src/utils/numbers.ts +22 -171
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +0 -11
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +0 -9
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +0 -1
- package/dist/src/hooks/useDropdownData.d.ts +0 -47
- package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
- package/dist/src/hooks/useDropdownData.js +0 -97
- package/dist/src/hooks/useDropdownData.js.map +0 -1
- package/dist/src/utils/cryptoAssets.d.ts +0 -44
- package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.js +0 -129
- package/dist/src/utils/cryptoAssets.js.map +0 -1
- package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
- package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.test.js +0 -67
- package/dist/src/utils/cryptoAssets.test.js.map +0 -1
- package/src/components/Dropdown/Root/AccountAssetItem.tsx +0 -26
- package/src/hooks/useDropdownData.ts +0 -152
- package/src/utils/cryptoAssets.test.ts +0 -79
- 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
|
|
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
|
|
16
|
-
import
|
|
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 =
|
|
59
|
-
accountDataRefetchInterval,
|
|
60
|
-
nativeBalanceRefetchInterval,
|
|
61
|
-
})
|
|
50
|
+
const { data: walletAccountData } = useWalletAccount()
|
|
62
51
|
|
|
63
|
-
|
|
64
|
-
() => Boolean(data.mezoId && data.accountAddress && data.walletAddress),
|
|
65
|
-
[data],
|
|
66
|
-
)
|
|
52
|
+
useWatchTransferEventsForAllTokens()
|
|
67
53
|
|
|
68
54
|
const { openConnectModal } = useConnectModal()
|
|
69
55
|
|
|
70
|
-
|
|
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: "
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Block,
|
|
4
|
+
useStyletron,
|
|
5
|
+
BlockProps,
|
|
6
|
+
Skeleton,
|
|
7
|
+
LabelMedium,
|
|
8
|
+
ParagraphSmall,
|
|
8
9
|
} from "@mezo-org/mezo-clay"
|
|
9
|
-
import React, {
|
|
10
|
+
import React, { ReactNode } from "react"
|
|
11
|
+
import SlotNumber from "./SlotNumber"
|
|
12
|
+
import { formatUsd } from "../../utils/currency"
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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?:
|
|
21
|
-
label
|
|
67
|
+
icon?: ReactNode
|
|
68
|
+
label?: string
|
|
22
69
|
subLabel?: string
|
|
23
|
-
value
|
|
24
|
-
subValue?:
|
|
25
|
-
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
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
57
|
-
</
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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]: "
|
|
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
|
-
|
|
48
|
-
|
|
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="
|
|
55
|
-
|
|
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
|
|
63
|
+
<ArrowLeft />
|
|
65
64
|
</ButtonIcon>
|
|
66
65
|
|
|
67
|
-
<
|
|
66
|
+
<HeadingSmall
|
|
67
|
+
marginTop={theme.sizing.scale300}
|
|
68
|
+
marginBottom={theme.sizing.scale300}
|
|
69
|
+
>
|
|
70
|
+
{getHeaderTitle(currentView)}
|
|
71
|
+
</HeadingSmall>
|
|
68
72
|
</Block>
|
|
69
73
|
|
|
70
|
-
|
|
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
|
-
|
|
4
|
+
LabelLarge,
|
|
5
|
+
MezoCircle,
|
|
5
6
|
MonoLabelXSmall,
|
|
6
7
|
ParagraphSmall,
|
|
7
8
|
useStyletron,
|
|
8
9
|
} from "@mezo-org/mezo-clay"
|
|
9
|
-
import 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
|
-
|
|
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
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
}
|
|
36
|
+
}
|
|
44
37
|
|
|
45
|
-
const
|
|
38
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
39
|
+
walletAccountData.accountAddress!,
|
|
40
|
+
"mezo",
|
|
41
|
+
environment === "testnet",
|
|
42
|
+
)
|
|
46
43
|
|
|
47
44
|
return (
|
|
48
45
|
<NestedViewLayout>
|
|
49
|
-
<
|
|
46
|
+
<LabelLarge>Your Mezo Address</LabelLarge>
|
|
50
47
|
|
|
51
48
|
<ParagraphSmall
|
|
52
|
-
marginTop={
|
|
53
|
-
marginBottom={theme.sizing.
|
|
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'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={
|
|
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
|
-
<
|
|
82
|
+
<Block
|
|
83
|
+
display="flex"
|
|
84
|
+
alignItems="center"
|
|
85
|
+
backgroundColor={theme.colors.backgroundSecondary}
|
|
86
86
|
marginTop={theme.sizing.scale800}
|
|
87
|
-
marginBottom={theme.sizing.
|
|
87
|
+
marginBottom={theme.sizing.scale600}
|
|
88
|
+
padding={theme.sizing.scale300}
|
|
88
89
|
overrides={{
|
|
89
90
|
Block: {
|
|
90
91
|
style: {
|
|
91
|
-
|
|
92
|
+
gap: theme.sizing.scale300,
|
|
93
|
+
borderRadius: theme.borders.radius400,
|
|
92
94
|
},
|
|
93
95
|
},
|
|
94
96
|
}}
|
|
95
97
|
>
|
|
96
|
-
|
|
97
|
-
|
|
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.
|
|
123
|
+
marginBottom: theme.sizing.scale500,
|
|
105
124
|
},
|
|
106
125
|
},
|
|
107
126
|
}}
|
|
108
127
|
>
|
|
109
|
-
{isCopiedMessageVisible ? "Copied!" : "Copy Mezo
|
|
128
|
+
{isCopiedMessageVisible ? "Copied!" : "Copy Mezo address"}
|
|
110
129
|
</Button>
|
|
111
130
|
|
|
112
|
-
<Button
|
|
113
|
-
|
|
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
|
)
|