@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,68 +1,85 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
useStyletron,
|
|
4
|
+
CoinsStacked02,
|
|
5
|
+
mergeOverrides,
|
|
6
|
+
BlockProps,
|
|
7
|
+
} from "@mezo-org/mezo-clay"
|
|
8
|
+
import { formatUnits } from "viem"
|
|
3
9
|
import ListingItem from "../ListingItem"
|
|
4
|
-
import {
|
|
10
|
+
import { useTokensBalances } from "../../../hooks/useTokensBalances"
|
|
11
|
+
import AccountError from "./AccountError"
|
|
12
|
+
import { CONVERSION_RATE_DECIMALS } from "../../../hooks/useAssetsConversionRates"
|
|
5
13
|
|
|
6
14
|
type AccountOtherAssetsProps = {
|
|
7
|
-
assetsCount: number
|
|
8
|
-
assetsUsdTotal: number
|
|
9
15
|
onClick?: () => void
|
|
10
|
-
}
|
|
16
|
+
} & Omit<BlockProps, "children">
|
|
11
17
|
|
|
12
18
|
export default function AccountOtherAssets(props: AccountOtherAssetsProps) {
|
|
13
|
-
const {
|
|
19
|
+
const { onClick, overrides, ...restProps } = props
|
|
14
20
|
|
|
15
21
|
const [, theme] = useStyletron()
|
|
16
22
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
23
|
+
const {
|
|
24
|
+
data: tokensBalancesData,
|
|
25
|
+
isPending: isTokensBalancesPending,
|
|
26
|
+
isError: isTokensBalancesError,
|
|
27
|
+
} = useTokensBalances()
|
|
28
|
+
|
|
29
|
+
if (isTokensBalancesError) {
|
|
30
|
+
return (
|
|
31
|
+
<AccountError
|
|
32
|
+
topic="other assets"
|
|
33
|
+
paddingTop={theme.sizing.scale100}
|
|
34
|
+
paddingBottom={theme.sizing.scale100}
|
|
35
|
+
overrides={overrides}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
if (isTokensBalancesPending) {
|
|
41
|
+
return <ListingItem isLoading overrides={overrides} />
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const otherAssets = Object.values(tokensBalancesData)
|
|
45
|
+
.filter((asset) => !["BTC", "MUSD"].includes(asset.symbol))
|
|
46
|
+
.filter((asset) => asset.value > 0n)
|
|
47
|
+
|
|
48
|
+
const assetsCount = otherAssets.length
|
|
49
|
+
const totalAssetsInUsd = Number(
|
|
50
|
+
formatUnits(
|
|
51
|
+
otherAssets.reduce((total, asset) => total + asset.usd.value, 0n),
|
|
52
|
+
CONVERSION_RATE_DECIMALS,
|
|
53
|
+
),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
let label = "No other assets"
|
|
57
|
+
if (assetsCount === 1) label = "1 more asset"
|
|
58
|
+
if (assetsCount > 1) label = `${assetsCount} more assets`
|
|
24
59
|
|
|
25
60
|
return (
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
borderTop: `1px solid ${theme.colors.borderInverseSelected}`,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
<ListingItem
|
|
39
|
-
icon={CoinsStacked02}
|
|
40
|
-
label={label}
|
|
41
|
-
value={formattedAssetsUsdTotal}
|
|
42
|
-
overrides={{
|
|
43
|
-
Root: {
|
|
61
|
+
<ListingItem
|
|
62
|
+
icon={<CoinsStacked02 color={theme.colors.contentPrimary} />}
|
|
63
|
+
label={label}
|
|
64
|
+
value={totalAssetsInUsd}
|
|
65
|
+
overrides={mergeOverrides(
|
|
66
|
+
{
|
|
67
|
+
Block: {
|
|
44
68
|
props: {
|
|
45
69
|
$as: "button",
|
|
46
70
|
onClick,
|
|
47
71
|
},
|
|
48
72
|
style: {
|
|
49
|
-
|
|
50
|
-
padding: 0,
|
|
73
|
+
borderWidth: 0,
|
|
51
74
|
cursor: "pointer",
|
|
75
|
+
backgroundColor: "transparent",
|
|
76
|
+
minHeight: "56px",
|
|
52
77
|
},
|
|
53
78
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Content: {
|
|
60
|
-
style: {
|
|
61
|
-
minHeight: theme.sizing.scale1200,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
}}
|
|
65
|
-
/>
|
|
66
|
-
</Block>
|
|
79
|
+
},
|
|
80
|
+
overrides,
|
|
81
|
+
)}
|
|
82
|
+
{...restProps}
|
|
83
|
+
/>
|
|
67
84
|
)
|
|
68
85
|
}
|
|
@@ -6,47 +6,17 @@ import WalletAddress from "./WalletAddress"
|
|
|
6
6
|
import AccountBalance from "./AccountBalance"
|
|
7
7
|
import WelcomeBlock from "./WelcomeBlock"
|
|
8
8
|
import AccountAddressActions from "./AccountAddressActions"
|
|
9
|
-
import AccountAssetItem from "./AccountAssetItem"
|
|
10
|
-
import { DetailedCryptoAsset } from "../../../utils/cryptoAssets"
|
|
11
|
-
import { formatNumberToCompactString } from "../../../utils/numbers"
|
|
12
|
-
import { formatUsd } from "../../../utils/currency"
|
|
13
9
|
import AccountOtherAssets from "./AccountOtherAssets"
|
|
10
|
+
import AccountBtcListing from "./AccountBtcListing"
|
|
11
|
+
import AccountMusdListing from "./AccountMusdListing"
|
|
14
12
|
|
|
15
13
|
type RootProps = {
|
|
16
|
-
mezoId: string
|
|
17
|
-
matsBalance: number
|
|
18
|
-
accountAddress: string
|
|
19
|
-
walletAddress: string
|
|
20
|
-
walletType: "bitcoin" | "evm"
|
|
21
|
-
usdTotalBalance: number
|
|
22
|
-
usdTroveDebt: number
|
|
23
|
-
usdCollateral: number
|
|
24
|
-
assets: {
|
|
25
|
-
btc: DetailedCryptoAsset
|
|
26
|
-
musd: DetailedCryptoAsset
|
|
27
|
-
}
|
|
28
|
-
otherAssetsCount: number
|
|
29
|
-
otherAssetsUsdTotal: number
|
|
30
14
|
onSignOut?: () => void
|
|
31
15
|
onOtherAssetsClick?: () => void
|
|
32
16
|
}
|
|
33
17
|
|
|
34
18
|
export default function Root(props: RootProps) {
|
|
35
|
-
const {
|
|
36
|
-
mezoId,
|
|
37
|
-
walletAddress,
|
|
38
|
-
accountAddress,
|
|
39
|
-
walletType,
|
|
40
|
-
usdTotalBalance,
|
|
41
|
-
usdTroveDebt,
|
|
42
|
-
usdCollateral,
|
|
43
|
-
matsBalance,
|
|
44
|
-
assets,
|
|
45
|
-
otherAssetsCount,
|
|
46
|
-
otherAssetsUsdTotal,
|
|
47
|
-
onSignOut,
|
|
48
|
-
onOtherAssetsClick,
|
|
49
|
-
} = props
|
|
19
|
+
const { onSignOut, onOtherAssetsClick } = props
|
|
50
20
|
|
|
51
21
|
const [, theme] = useStyletron()
|
|
52
22
|
|
|
@@ -58,88 +28,48 @@ export default function Root(props: RootProps) {
|
|
|
58
28
|
onSignOut()
|
|
59
29
|
return
|
|
60
30
|
}
|
|
61
|
-
|
|
62
31
|
signOut()
|
|
63
32
|
disconnect()
|
|
64
33
|
}, [signOut, disconnect, onSignOut])
|
|
65
34
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
35
|
+
const overridesWithDivider = {
|
|
36
|
+
Block: {
|
|
37
|
+
style: {
|
|
38
|
+
borderBottomWidth: "1px",
|
|
39
|
+
borderBottomStyle: "solid",
|
|
40
|
+
borderBottomColor: theme.colors.borderOpaque,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
70
44
|
|
|
71
45
|
return (
|
|
72
|
-
<Block
|
|
73
|
-
|
|
74
|
-
flexDirection="column"
|
|
75
|
-
padding={theme.sizing.scale600}
|
|
76
|
-
>
|
|
77
|
-
<WelcomeBlock mezoId={mezoId} matsBalance={formattedMatsBalance} />
|
|
46
|
+
<Block display="inline-flex" flexDirection="column">
|
|
47
|
+
<WelcomeBlock />
|
|
78
48
|
|
|
79
|
-
<AccountAddressActions
|
|
49
|
+
<AccountAddressActions overrides={overridesWithDivider} />
|
|
80
50
|
|
|
81
|
-
<
|
|
82
|
-
display="flex"
|
|
83
|
-
flexDirection="column"
|
|
84
|
-
backgroundColor={theme.colors.backgroundSecondary}
|
|
85
|
-
overflow="hidden"
|
|
86
|
-
overrides={{
|
|
87
|
-
Block: { style: { borderRadius: theme.borders.radius300 } },
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<WalletAddress address={walletAddress} type={walletType} />
|
|
51
|
+
<WalletAddress overrides={overridesWithDivider} />
|
|
91
52
|
|
|
92
|
-
|
|
93
|
-
totalBalance={formattedUsdTotalBalance}
|
|
94
|
-
totalDebt={formattedUsdTroveDebt}
|
|
95
|
-
/>
|
|
53
|
+
<AccountBalance overrides={overridesWithDivider} />
|
|
96
54
|
|
|
97
|
-
|
|
98
|
-
type="BTC"
|
|
99
|
-
amount={assets.btc.formattedUsdBalance}
|
|
100
|
-
subLabel="Locked collateral"
|
|
101
|
-
subValue={formattedUsdCollateral}
|
|
102
|
-
/>
|
|
55
|
+
<AccountBtcListing />
|
|
103
56
|
|
|
104
|
-
|
|
105
|
-
type="MUSD"
|
|
106
|
-
amount={assets.musd.formattedUsdBalance}
|
|
107
|
-
subLabel="Borrowed"
|
|
108
|
-
subValue={formattedUsdTroveDebt}
|
|
109
|
-
/>
|
|
57
|
+
<AccountMusdListing />
|
|
110
58
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/>
|
|
116
|
-
</Block>
|
|
59
|
+
<AccountOtherAssets
|
|
60
|
+
onClick={onOtherAssetsClick}
|
|
61
|
+
overrides={overridesWithDivider}
|
|
62
|
+
/>
|
|
117
63
|
|
|
118
|
-
<Block
|
|
119
|
-
marginTop={theme.sizing.scale700}
|
|
120
|
-
padding={`0 ${theme.sizing.scale100}`}
|
|
121
|
-
>
|
|
64
|
+
<Block padding={theme.sizing.scale300}>
|
|
122
65
|
<Button
|
|
123
66
|
size="small"
|
|
67
|
+
shape="pill"
|
|
124
68
|
kind="tertiary"
|
|
125
|
-
startEnhancer={<LogOut01 color="currentColor" size={
|
|
126
|
-
onClick={
|
|
127
|
-
overrides={{
|
|
128
|
-
Root: {
|
|
129
|
-
style: {
|
|
130
|
-
":hover": {
|
|
131
|
-
backgroundColor: theme.colors.backgroundSecondary,
|
|
132
|
-
boxShadow: "none",
|
|
133
|
-
},
|
|
134
|
-
":active": {
|
|
135
|
-
backgroundColor: theme.colors.backgroundSecondary,
|
|
136
|
-
color: theme.colors.contentPrimary,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
}}
|
|
69
|
+
startEnhancer={<LogOut01 color="currentColor" size={16} />}
|
|
70
|
+
onClick={handleLogOut}
|
|
141
71
|
>
|
|
142
|
-
|
|
72
|
+
Sign out
|
|
143
73
|
</Button>
|
|
144
74
|
</Block>
|
|
145
75
|
</Block>
|
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BitcoinCircle,
|
|
2
3
|
Block,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
BlockProps,
|
|
5
|
+
EthCircle,
|
|
6
|
+
LabelMedium,
|
|
7
|
+
LabelXSmall,
|
|
8
|
+
mergeOverrides,
|
|
9
|
+
MonoLabelXSmall,
|
|
6
10
|
useStyletron,
|
|
7
11
|
} from "@mezo-org/mezo-clay"
|
|
8
|
-
import React, {
|
|
12
|
+
import React, { useState } from "react"
|
|
9
13
|
import { useCopyToClipboard } from "usehooks-ts"
|
|
10
14
|
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
11
15
|
import { getAddressExplorerUrl, trimAddress } from "../../../utils/address"
|
|
12
|
-
import
|
|
16
|
+
import useWalletAccount from "../../../hooks/useWalletAccount"
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type: "bitcoin" | "evm"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default function WalletAddress(props: WalletAddressProps) {
|
|
20
|
-
const { address, type } = props
|
|
21
|
-
|
|
22
|
-
const { environment } = usePassportContext()
|
|
23
|
-
const blockExplorerUrl = getAddressExplorerUrl(
|
|
24
|
-
address,
|
|
25
|
-
type,
|
|
26
|
-
environment === "testnet",
|
|
27
|
-
)
|
|
28
|
-
const trimmedAddress = trimAddress(address)
|
|
29
|
-
const { icon: accountIcon } = getCryptoAsset(
|
|
30
|
-
type === "bitcoin" ? "BTC" : "ETH",
|
|
31
|
-
)
|
|
18
|
+
export default function WalletAddress(props: BlockProps) {
|
|
19
|
+
const { overrides, ...restProps } = props
|
|
32
20
|
|
|
21
|
+
const { data, isError, isPending } = useWalletAccount()
|
|
22
|
+
const { environment = "mainnet" } = usePassportContext()
|
|
33
23
|
const [, theme] = useStyletron()
|
|
34
|
-
|
|
35
24
|
const [, copy] = useCopyToClipboard()
|
|
36
25
|
const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
|
|
27
|
+
if (isError) {
|
|
28
|
+
return "Error loading wallet address"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isPending) {
|
|
32
|
+
return "Loading..."
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { walletAddress, networkFamily } = data
|
|
36
|
+
|
|
37
|
+
const handleCopyAddress = () => {
|
|
38
|
+
copy(walletAddress)
|
|
39
39
|
setIsCopiedMessageVisible(true)
|
|
40
40
|
|
|
41
41
|
setTimeout(() => {
|
|
42
42
|
setIsCopiedMessageVisible(false)
|
|
43
43
|
}, 2000)
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
47
|
+
walletAddress,
|
|
48
|
+
networkFamily,
|
|
49
|
+
environment === "testnet",
|
|
50
|
+
)
|
|
51
|
+
const trimmedAddress = trimAddress(walletAddress)
|
|
52
|
+
const AccountIcon = networkFamily === "bitcoin" ? BitcoinCircle : EthCircle
|
|
45
53
|
|
|
46
54
|
return (
|
|
47
55
|
<Block
|
|
@@ -50,79 +58,77 @@ export default function WalletAddress(props: WalletAddressProps) {
|
|
|
50
58
|
display="flex"
|
|
51
59
|
alignItems="center"
|
|
52
60
|
backgroundColor="transparent"
|
|
53
|
-
padding={`${theme.sizing.
|
|
54
|
-
overrides={
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
padding={`${theme.sizing.scale800} ${theme.sizing.scale700}`}
|
|
62
|
+
overrides={mergeOverrides(
|
|
63
|
+
{
|
|
64
|
+
Block: {
|
|
65
|
+
style: {
|
|
66
|
+
gap: theme.sizing.scale700,
|
|
67
|
+
borderWidth: 0,
|
|
68
|
+
cursor: "pointer",
|
|
69
|
+
":hover": {
|
|
70
|
+
backgroundColor: theme.colors.backgroundTertiary,
|
|
71
|
+
},
|
|
61
72
|
},
|
|
62
73
|
},
|
|
63
74
|
},
|
|
64
|
-
|
|
65
|
-
>
|
|
66
|
-
<Block as={accountIcon} size={theme.sizing.scale600} />
|
|
67
|
-
{isCopiedMessageVisible ? (
|
|
68
|
-
<ParagraphSmall
|
|
69
|
-
margin={0}
|
|
70
|
-
marginLeft={theme.sizing.scale500}
|
|
71
|
-
color={theme.colors.contentPrimary}
|
|
72
|
-
>
|
|
73
|
-
Copied address to clipboard
|
|
74
|
-
</ParagraphSmall>
|
|
75
|
-
) : (
|
|
76
|
-
<Block
|
|
77
|
-
as="a"
|
|
78
|
-
marginLeft={theme.sizing.scale500}
|
|
79
|
-
href={blockExplorerUrl}
|
|
80
|
-
target="_blank"
|
|
81
|
-
overrides={{
|
|
82
|
-
Block: {
|
|
83
|
-
style: {
|
|
84
|
-
color: "inherit",
|
|
85
|
-
textDecoration: "none",
|
|
86
|
-
":hover": {
|
|
87
|
-
textDecoration: "underline",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<ParagraphSmall
|
|
94
|
-
display="flex"
|
|
95
|
-
alignItems="center"
|
|
96
|
-
margin={0}
|
|
97
|
-
color={theme.colors.contentPrimary}
|
|
98
|
-
>
|
|
99
|
-
{trimmedAddress}
|
|
100
|
-
<LinkIcon
|
|
101
|
-
display="inline"
|
|
102
|
-
size={theme.sizing.scale550}
|
|
103
|
-
overrides={{
|
|
104
|
-
Svg: {
|
|
105
|
-
style: {
|
|
106
|
-
stroke: "currentColor",
|
|
107
|
-
marginLeft: theme.sizing.scale300,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
}}
|
|
111
|
-
/>
|
|
112
|
-
</ParagraphSmall>
|
|
113
|
-
</Block>
|
|
75
|
+
overrides,
|
|
114
76
|
)}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
77
|
+
{...restProps}
|
|
78
|
+
>
|
|
79
|
+
<AccountIcon
|
|
80
|
+
color={theme.colors.black}
|
|
81
|
+
size={theme.sizing.scale800}
|
|
118
82
|
overrides={{
|
|
119
83
|
Svg: {
|
|
120
84
|
style: {
|
|
121
|
-
|
|
85
|
+
backgroundColor: theme.colors.black,
|
|
86
|
+
overflow: "hidden",
|
|
87
|
+
borderRadius: theme.borders.radius200,
|
|
122
88
|
},
|
|
123
89
|
},
|
|
124
90
|
}}
|
|
125
91
|
/>
|
|
92
|
+
<Block
|
|
93
|
+
display="flex"
|
|
94
|
+
flexDirection="column"
|
|
95
|
+
alignItems="flex-start"
|
|
96
|
+
overrides={{
|
|
97
|
+
Block: {
|
|
98
|
+
style: {
|
|
99
|
+
gap: theme.sizing.scale100,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
<LabelMedium>Connected Wallet</LabelMedium>
|
|
105
|
+
|
|
106
|
+
{isCopiedMessageVisible ? (
|
|
107
|
+
<LabelXSmall color={theme.colors.contentSecondary}>
|
|
108
|
+
Copied address to clipboard
|
|
109
|
+
</LabelXSmall>
|
|
110
|
+
) : (
|
|
111
|
+
<Block
|
|
112
|
+
as="a"
|
|
113
|
+
color={theme.colors.contentSecondary}
|
|
114
|
+
href={blockExplorerUrl}
|
|
115
|
+
target="_blank"
|
|
116
|
+
overrides={{
|
|
117
|
+
Block: {
|
|
118
|
+
style: {
|
|
119
|
+
color: "inherit",
|
|
120
|
+
textDecoration: "none",
|
|
121
|
+
":hover": {
|
|
122
|
+
textDecoration: "underline",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
<MonoLabelXSmall>{trimmedAddress}</MonoLabelXSmall>
|
|
129
|
+
</Block>
|
|
130
|
+
)}
|
|
131
|
+
</Block>
|
|
126
132
|
</Block>
|
|
127
133
|
)
|
|
128
134
|
}
|