@mezo-org/passport 0.4.0-dev.81 → 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.
- package/dist/src/api/auth.d.ts +1 -1
- package/dist/src/api/auth.d.ts.map +1 -1
- 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 -33
- 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 +36 -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 +28 -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 +43 -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 +1 -11
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +3 -40
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +0 -2
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +0 -2
- package/dist/src/constants.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 +31 -5
- 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 +2 -2
- 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 -10
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +22 -19
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.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/api/auth.ts +1 -1
- package/src/components/Dropdown/Content.tsx +3 -48
- package/src/components/Dropdown/Dropdown.tsx +7 -55
- package/src/components/Dropdown/ListingItem.tsx +155 -59
- package/src/components/Dropdown/NestedViewLayout.tsx +32 -20
- package/src/components/Dropdown/Receive/Receive.tsx +69 -32
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +64 -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 +95 -89
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +109 -29
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/config.ts +3 -59
- package/src/constants.ts +0 -6
- 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 +27 -36
- package/src/index.ts +0 -1
- 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
|
@@ -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,54 @@ 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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
}
|
|
48
|
+
}
|
|
44
49
|
|
|
45
|
-
const
|
|
50
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
51
|
+
walletAccountData.accountAddress,
|
|
52
|
+
"mezo",
|
|
53
|
+
environment === "testnet",
|
|
54
|
+
)
|
|
46
55
|
|
|
47
56
|
return (
|
|
48
57
|
<NestedViewLayout>
|
|
49
|
-
<
|
|
58
|
+
<LabelLarge>Your Mezo Address</LabelLarge>
|
|
50
59
|
|
|
51
60
|
<ParagraphSmall
|
|
52
|
-
marginTop={
|
|
53
|
-
marginBottom={theme.sizing.
|
|
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'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={
|
|
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
|
-
<
|
|
94
|
+
<Block
|
|
95
|
+
display="flex"
|
|
96
|
+
alignItems="center"
|
|
97
|
+
backgroundColor={theme.colors.backgroundSecondary}
|
|
86
98
|
marginTop={theme.sizing.scale800}
|
|
87
|
-
marginBottom={theme.sizing.
|
|
99
|
+
marginBottom={theme.sizing.scale600}
|
|
100
|
+
padding={theme.sizing.scale300}
|
|
88
101
|
overrides={{
|
|
89
102
|
Block: {
|
|
90
103
|
style: {
|
|
91
|
-
|
|
104
|
+
gap: theme.sizing.scale300,
|
|
105
|
+
borderRadius: theme.borders.radius400,
|
|
92
106
|
},
|
|
93
107
|
},
|
|
94
108
|
}}
|
|
95
109
|
>
|
|
96
|
-
|
|
97
|
-
|
|
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.
|
|
135
|
+
marginBottom: theme.sizing.scale500,
|
|
105
136
|
},
|
|
106
137
|
},
|
|
107
138
|
}}
|
|
108
139
|
>
|
|
109
|
-
{isCopiedMessageVisible ? "Copied!" : "Copy Mezo
|
|
140
|
+
{isCopiedMessageVisible ? "Copied!" : "Copy Mezo address"}
|
|
110
141
|
</Button>
|
|
111
142
|
|
|
112
|
-
<Button
|
|
113
|
-
|
|
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
|
)
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ArrowNarrowLeft,
|
|
3
3
|
Block,
|
|
4
|
+
BlockProps,
|
|
4
5
|
Button,
|
|
5
6
|
ButtonProps,
|
|
6
|
-
|
|
7
|
+
mergeOverrides,
|
|
8
|
+
Skeleton,
|
|
7
9
|
useStyletron,
|
|
8
10
|
} from "@mezo-org/mezo-clay"
|
|
9
|
-
import React
|
|
11
|
+
import React from "react"
|
|
10
12
|
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
11
13
|
import { getAddressExplorerUrl } from "../../../utils/address"
|
|
12
14
|
import useDropdownStore, { DropdownView } from "../../../stores/dropdownStore"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
address: string
|
|
16
|
-
}
|
|
15
|
+
import useWalletAccount from "../../../hooks/useWalletAccount"
|
|
16
|
+
import AccountError from "./AccountError"
|
|
17
17
|
|
|
18
18
|
const buttonStartEnhancerSize = 12
|
|
19
19
|
|
|
20
20
|
const commonButtonProps: Partial<ButtonProps> = {
|
|
21
21
|
kind: "secondary",
|
|
22
|
-
size: "
|
|
22
|
+
size: "small",
|
|
23
|
+
shape: "pill",
|
|
23
24
|
overrides: {
|
|
24
25
|
BaseButton: {
|
|
25
26
|
style: {
|
|
@@ -34,50 +35,69 @@ const commonButtonProps: Partial<ButtonProps> = {
|
|
|
34
35
|
},
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export default function AccountAddressActions(
|
|
38
|
-
|
|
39
|
-
) {
|
|
40
|
-
const { address } = props
|
|
38
|
+
export default function AccountAddressActions(props: BlockProps) {
|
|
39
|
+
const { overrides, ...restProps } = props
|
|
41
40
|
|
|
42
41
|
const [, theme] = useStyletron()
|
|
43
|
-
|
|
44
42
|
const { environment } = usePassportContext()
|
|
43
|
+
const setDropdownView = useDropdownStore((state) => state.setView)
|
|
44
|
+
const handleReceiveClick = () => setDropdownView(DropdownView.RECEIVE)
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
data: walletAccountData,
|
|
48
|
+
isError: isWalletAccountDataError,
|
|
49
|
+
isPending: isWalletAccountDataPending,
|
|
50
|
+
} = useWalletAccount()
|
|
51
|
+
|
|
52
|
+
if (isWalletAccountDataError) {
|
|
53
|
+
return <AccountError topic="wallet account data" />
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (isWalletAccountDataPending) {
|
|
57
|
+
return (
|
|
58
|
+
<Block
|
|
59
|
+
display="flex"
|
|
60
|
+
alignItems="center"
|
|
61
|
+
backgroundColor="transparent"
|
|
62
|
+
marginBottom={theme.sizing.scale600}
|
|
63
|
+
overrides={{
|
|
64
|
+
Block: {
|
|
65
|
+
style: {
|
|
66
|
+
gap: theme.sizing.scale600,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<Skeleton animation width="100%" height="28px" />
|
|
72
|
+
<Skeleton animation width="100%" height="28px" />
|
|
73
|
+
</Block>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
45
77
|
const blockExplorerUrl = getAddressExplorerUrl(
|
|
46
|
-
|
|
78
|
+
walletAccountData.accountAddress,
|
|
47
79
|
"mezo",
|
|
48
80
|
environment === "testnet",
|
|
49
81
|
)
|
|
50
82
|
|
|
51
|
-
const setDropdownView = useDropdownStore((state) => state.setView)
|
|
52
|
-
|
|
53
|
-
const handleReceiveClick = useCallback(() => {
|
|
54
|
-
setDropdownView(DropdownView.RECEIVE)
|
|
55
|
-
}, [setDropdownView])
|
|
56
|
-
|
|
57
83
|
return (
|
|
58
84
|
<Block
|
|
59
85
|
display="flex"
|
|
60
86
|
alignItems="center"
|
|
61
87
|
backgroundColor="transparent"
|
|
62
|
-
|
|
63
|
-
overrides={
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
padding={`0 ${theme.sizing.scale600} ${theme.sizing.scale800}`}
|
|
89
|
+
overrides={mergeOverrides(
|
|
90
|
+
{
|
|
91
|
+
Block: {
|
|
92
|
+
style: {
|
|
93
|
+
gap: theme.sizing.scale600,
|
|
94
|
+
},
|
|
67
95
|
},
|
|
68
96
|
},
|
|
69
|
-
|
|
97
|
+
overrides,
|
|
98
|
+
)}
|
|
99
|
+
{...restProps}
|
|
70
100
|
>
|
|
71
|
-
<Button
|
|
72
|
-
startEnhancer={<Cube01 size={buttonStartEnhancerSize} />}
|
|
73
|
-
$as="a"
|
|
74
|
-
href={blockExplorerUrl}
|
|
75
|
-
target="_blank"
|
|
76
|
-
{...commonButtonProps}
|
|
77
|
-
>
|
|
78
|
-
View Mezo Explorer
|
|
79
|
-
</Button>
|
|
80
|
-
|
|
81
101
|
<Button
|
|
82
102
|
onClick={handleReceiveClick}
|
|
83
103
|
startEnhancer={
|
|
@@ -96,6 +116,15 @@ export default function AccountAddressActions(
|
|
|
96
116
|
>
|
|
97
117
|
Receive
|
|
98
118
|
</Button>
|
|
119
|
+
|
|
120
|
+
<Button
|
|
121
|
+
$as="a"
|
|
122
|
+
href={blockExplorerUrl}
|
|
123
|
+
target="_blank"
|
|
124
|
+
{...commonButtonProps}
|
|
125
|
+
>
|
|
126
|
+
Block Explorer
|
|
127
|
+
</Button>
|
|
99
128
|
</Block>
|
|
100
129
|
)
|
|
101
130
|
}
|
|
@@ -1,30 +1,68 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import { useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import { BlockProps, useStyletron } from "@mezo-org/mezo-clay"
|
|
3
|
+
import { formatUnits } from "viem"
|
|
3
4
|
import ListingItem from "../ListingItem"
|
|
5
|
+
import { useTokensBalances } from "../../../hooks/useTokensBalances"
|
|
6
|
+
import { useBorrowData } from "../../../hooks/useBorrowData"
|
|
7
|
+
import AccountError from "./AccountError"
|
|
8
|
+
import { CONVERSION_RATE_DECIMALS } from "../../../hooks/useAssetsConversionRates"
|
|
9
|
+
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
4
10
|
|
|
5
|
-
type AccountBalanceProps =
|
|
6
|
-
totalBalance: string
|
|
7
|
-
totalDebt: string
|
|
8
|
-
}
|
|
11
|
+
type AccountBalanceProps = Omit<BlockProps, "children">
|
|
9
12
|
|
|
10
13
|
export default function AccountBalance(props: AccountBalanceProps) {
|
|
11
|
-
const {
|
|
12
|
-
|
|
14
|
+
const { overrides, ...restProps } = props
|
|
13
15
|
const [, theme] = useStyletron()
|
|
16
|
+
const { nativeBalanceRefetchInterval } = usePassportContext()
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
data: tokensBalancesData,
|
|
20
|
+
isError: isTokensBalancesError,
|
|
21
|
+
isPending: isTokensBalancesDataPending,
|
|
22
|
+
} = useTokensBalances({
|
|
23
|
+
queryOptions: {
|
|
24
|
+
refetchInterval: nativeBalanceRefetchInterval,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
const {
|
|
28
|
+
data: borrowData,
|
|
29
|
+
isError: isBorrowDataError,
|
|
30
|
+
isPending: isBorrowDataPending,
|
|
31
|
+
} = useBorrowData()
|
|
32
|
+
|
|
33
|
+
if (isTokensBalancesDataPending || isBorrowDataPending) {
|
|
34
|
+
return <ListingItem isLoading overrides={overrides} />
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isTokensBalancesError || isBorrowDataError) {
|
|
38
|
+
return (
|
|
39
|
+
<AccountError
|
|
40
|
+
padding={`${theme.sizing.scale500} ${theme.sizing.scale800}`}
|
|
41
|
+
topic="account balance"
|
|
42
|
+
overrides={overrides}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const totalBalanceInUsd = Object.values(tokensBalancesData).reduce(
|
|
48
|
+
(acc, tokenBalance) => acc + tokenBalance.usd.value,
|
|
49
|
+
0n,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const totalBalanceNumber = Number(
|
|
53
|
+
formatUnits(totalBalanceInUsd, CONVERSION_RATE_DECIMALS),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const totalDebtNumber = Number(borrowData.debtInUsd.formatted)
|
|
14
57
|
|
|
15
58
|
return (
|
|
16
59
|
<ListingItem
|
|
17
60
|
label="Total assets"
|
|
18
|
-
value={
|
|
61
|
+
value={totalBalanceNumber}
|
|
19
62
|
subLabel="Total liabilities"
|
|
20
|
-
subValue={
|
|
21
|
-
overrides={
|
|
22
|
-
|
|
23
|
-
style: {
|
|
24
|
-
borderBottom: `1px solid ${theme.colors.borderInverseSelected}`,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
}}
|
|
63
|
+
subValue={totalDebtNumber}
|
|
64
|
+
overrides={overrides}
|
|
65
|
+
{...restProps}
|
|
28
66
|
/>
|
|
29
67
|
)
|
|
30
68
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { BitcoinCircle, BlockProps } from "@mezo-org/mezo-clay"
|
|
3
|
+
import ListingItem from "../ListingItem"
|
|
4
|
+
import { getAsset } from "../../../utils/assets"
|
|
5
|
+
import { useBorrowData } from "../../../hooks/useBorrowData"
|
|
6
|
+
import { useTokensBalances } from "../../../hooks/useTokensBalances"
|
|
7
|
+
import AccountError from "./AccountError"
|
|
8
|
+
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
9
|
+
|
|
10
|
+
type AccountBTCListingProps = Omit<BlockProps, "children">
|
|
11
|
+
|
|
12
|
+
export default function AccountBTCListing(props: AccountBTCListingProps) {
|
|
13
|
+
const { nativeBalanceRefetchInterval } = usePassportContext()
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
data: borrowData,
|
|
17
|
+
isError: isBorrowDataError,
|
|
18
|
+
isPending: isBorrowDataPending,
|
|
19
|
+
} = useBorrowData()
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
data: tokensBalancesData,
|
|
23
|
+
isError: isTokensBalancesError,
|
|
24
|
+
isPending: isTokensBalancesPending,
|
|
25
|
+
} = useTokensBalances({
|
|
26
|
+
queryOptions: {
|
|
27
|
+
refetchInterval: nativeBalanceRefetchInterval,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
if (isTokensBalancesError || isBorrowDataError) {
|
|
32
|
+
return <AccountError topic="Bitcoin balance" />
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isTokensBalancesPending || isBorrowDataPending) {
|
|
36
|
+
return <ListingItem isLoading />
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const btcBalance = Number(tokensBalancesData.BTC.usd.formatted)
|
|
40
|
+
const lockedCollateral = Number(borrowData.collateral.usd.formatted)
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ListingItem
|
|
44
|
+
icon={<BitcoinCircle />}
|
|
45
|
+
label={getAsset("BTC").name}
|
|
46
|
+
value={btcBalance}
|
|
47
|
+
subLabel="Locked collateral"
|
|
48
|
+
subValue={lockedCollateral}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
BlockProps,
|
|
4
|
+
LabelSmall,
|
|
5
|
+
mergeOverrides,
|
|
6
|
+
useStyletron,
|
|
7
|
+
} from "@mezo-org/mezo-clay"
|
|
8
|
+
|
|
9
|
+
type AccountErrorProps = {
|
|
10
|
+
topic: string
|
|
11
|
+
} & BlockProps
|
|
12
|
+
|
|
13
|
+
export default function AccountError(props: AccountErrorProps) {
|
|
14
|
+
const { topic, overrides, ...restProps } = props
|
|
15
|
+
|
|
16
|
+
const [, theme] = useStyletron()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<LabelSmall
|
|
20
|
+
padding={`${theme.sizing.scale600} ${theme.sizing.scale800}`}
|
|
21
|
+
color="negative"
|
|
22
|
+
overrides={mergeOverrides(overrides, {
|
|
23
|
+
Block: {
|
|
24
|
+
style: {
|
|
25
|
+
lineHeight: theme.sizing.scale700,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})}
|
|
29
|
+
{...restProps}
|
|
30
|
+
>
|
|
31
|
+
An error occured loading {topic}.
|
|
32
|
+
</LabelSmall>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { BlockProps, MUsdCircle02 } from "@mezo-org/mezo-clay"
|
|
3
|
+
import ListingItem from "../ListingItem"
|
|
4
|
+
import { getAsset } from "../../../utils/assets"
|
|
5
|
+
import { useBorrowData } from "../../../hooks/useBorrowData"
|
|
6
|
+
import { useTokensBalances } from "../../../hooks/useTokensBalances"
|
|
7
|
+
import AccountError from "./AccountError"
|
|
8
|
+
|
|
9
|
+
export default function AccountMusdListing(
|
|
10
|
+
props: Omit<BlockProps, "children">,
|
|
11
|
+
) {
|
|
12
|
+
const {
|
|
13
|
+
data: borrowData,
|
|
14
|
+
isError: isBorrowDataError,
|
|
15
|
+
isPending: isBorrowDataPending,
|
|
16
|
+
} = useBorrowData()
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
data: tokensBalancesData,
|
|
20
|
+
isError: isTokensBalancesError,
|
|
21
|
+
isPending: isTokensBalancesPending,
|
|
22
|
+
} = useTokensBalances()
|
|
23
|
+
|
|
24
|
+
if (isBorrowDataError || isTokensBalancesError) {
|
|
25
|
+
return <AccountError topic="MUSD balance" />
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isBorrowDataPending || isTokensBalancesPending) {
|
|
29
|
+
return <ListingItem isLoading />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const musdBalance = Number(tokensBalancesData.MUSD.usd.formatted)
|
|
33
|
+
const lockedCollateral = Number(borrowData.debtInUsd.formatted)
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ListingItem
|
|
37
|
+
icon={<MUsdCircle02 />}
|
|
38
|
+
label={getAsset("MUSD").name}
|
|
39
|
+
value={musdBalance}
|
|
40
|
+
subLabel="Borrowed"
|
|
41
|
+
subValue={lockedCollateral}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|