@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
|
@@ -1,47 +1,47 @@
|
|
|
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 } = 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
|
+
const { walletAddress, networkFamily } = data
|
|
28
|
+
|
|
29
|
+
const handleCopyAddress = () => {
|
|
30
|
+
copy(walletAddress!)
|
|
39
31
|
setIsCopiedMessageVisible(true)
|
|
40
32
|
|
|
41
33
|
setTimeout(() => {
|
|
42
34
|
setIsCopiedMessageVisible(false)
|
|
43
35
|
}, 2000)
|
|
44
|
-
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
39
|
+
walletAddress!,
|
|
40
|
+
networkFamily,
|
|
41
|
+
environment === "testnet",
|
|
42
|
+
)
|
|
43
|
+
const trimmedAddress = trimAddress(walletAddress!)
|
|
44
|
+
const AccountIcon = networkFamily === "bitcoin" ? BitcoinCircle : EthCircle
|
|
45
45
|
|
|
46
46
|
return (
|
|
47
47
|
<Block
|
|
@@ -50,79 +50,77 @@ export default function WalletAddress(props: WalletAddressProps) {
|
|
|
50
50
|
display="flex"
|
|
51
51
|
alignItems="center"
|
|
52
52
|
backgroundColor="transparent"
|
|
53
|
-
padding={`${theme.sizing.
|
|
54
|
-
overrides={
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
padding={`${theme.sizing.scale800} ${theme.sizing.scale700}`}
|
|
54
|
+
overrides={mergeOverrides(
|
|
55
|
+
{
|
|
56
|
+
Block: {
|
|
57
|
+
style: {
|
|
58
|
+
gap: theme.sizing.scale700,
|
|
59
|
+
borderWidth: 0,
|
|
60
|
+
cursor: "pointer",
|
|
61
|
+
":hover": {
|
|
62
|
+
backgroundColor: theme.colors.backgroundTertiary,
|
|
63
|
+
},
|
|
61
64
|
},
|
|
62
65
|
},
|
|
63
66
|
},
|
|
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>
|
|
67
|
+
overrides,
|
|
114
68
|
)}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
69
|
+
{...restProps}
|
|
70
|
+
>
|
|
71
|
+
<AccountIcon
|
|
72
|
+
color={theme.colors.black}
|
|
73
|
+
size={theme.sizing.scale800}
|
|
118
74
|
overrides={{
|
|
119
75
|
Svg: {
|
|
120
76
|
style: {
|
|
121
|
-
|
|
77
|
+
backgroundColor: theme.colors.black,
|
|
78
|
+
overflow: "hidden",
|
|
79
|
+
borderRadius: theme.borders.radius200,
|
|
122
80
|
},
|
|
123
81
|
},
|
|
124
82
|
}}
|
|
125
83
|
/>
|
|
84
|
+
<Block
|
|
85
|
+
display="flex"
|
|
86
|
+
flexDirection="column"
|
|
87
|
+
alignItems="flex-start"
|
|
88
|
+
overrides={{
|
|
89
|
+
Block: {
|
|
90
|
+
style: {
|
|
91
|
+
gap: theme.sizing.scale100,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<LabelMedium>Connected Wallet</LabelMedium>
|
|
97
|
+
|
|
98
|
+
{isCopiedMessageVisible ? (
|
|
99
|
+
<LabelXSmall color={theme.colors.contentSecondary}>
|
|
100
|
+
Copied address to clipboard
|
|
101
|
+
</LabelXSmall>
|
|
102
|
+
) : (
|
|
103
|
+
<Block
|
|
104
|
+
as="a"
|
|
105
|
+
color={theme.colors.contentSecondary}
|
|
106
|
+
href={blockExplorerUrl}
|
|
107
|
+
target="_blank"
|
|
108
|
+
overrides={{
|
|
109
|
+
Block: {
|
|
110
|
+
style: {
|
|
111
|
+
color: "inherit",
|
|
112
|
+
textDecoration: "none",
|
|
113
|
+
":hover": {
|
|
114
|
+
textDecoration: "underline",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
<MonoLabelXSmall>{trimmedAddress}</MonoLabelXSmall>
|
|
121
|
+
</Block>
|
|
122
|
+
)}
|
|
123
|
+
</Block>
|
|
126
124
|
</Block>
|
|
127
125
|
)
|
|
128
126
|
}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Block,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
BlockProps,
|
|
4
|
+
HeadingMedium,
|
|
5
|
+
LabelLarge,
|
|
5
6
|
Mats,
|
|
7
|
+
mergeOverrides,
|
|
8
|
+
Skeleton,
|
|
6
9
|
useStyletron,
|
|
7
10
|
} from "@mezo-org/mezo-clay"
|
|
8
11
|
import React from "react"
|
|
9
12
|
import DefaultAvatar from "../../../assets/DefaultAvatar"
|
|
13
|
+
import { useGetCurrentAccount } from "../../../hooks"
|
|
14
|
+
import { formatNumberToCompactString } from "../../../utils/numbers"
|
|
15
|
+
import AccountError from "./AccountError"
|
|
16
|
+
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
17
|
+
import SlotNumber from "../SlotNumber"
|
|
10
18
|
|
|
11
19
|
const DOT_DELIMITER_REGEX = /(?=\.)/
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
mezoId: string
|
|
15
|
-
matsBalance: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default function WelcomeBlock(props: WelcomeBlockProps) {
|
|
19
|
-
const { mezoId, matsBalance } = props
|
|
20
|
-
|
|
21
|
-
const [name, nameSuffix] = mezoId.split(DOT_DELIMITER_REGEX)
|
|
21
|
+
function WelcomeBlockSkeleton() {
|
|
22
22
|
const [, theme] = useStyletron()
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<Block
|
|
26
26
|
display="flex"
|
|
27
27
|
alignItems="center"
|
|
28
|
-
padding={
|
|
29
|
-
|
|
28
|
+
padding={theme.sizing.scale600}
|
|
29
|
+
paddingTop={theme.sizing.scale900}
|
|
30
|
+
paddingBottom={theme.sizing.scale800}
|
|
30
31
|
overrides={{
|
|
31
32
|
Block: {
|
|
32
33
|
style: {
|
|
@@ -35,12 +36,12 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
|
|
|
35
36
|
},
|
|
36
37
|
}}
|
|
37
38
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
39
|
+
<Skeleton
|
|
40
|
+
animation
|
|
40
41
|
width={theme.sizing.scale1200}
|
|
41
42
|
height={theme.sizing.scale1200}
|
|
42
43
|
overrides={{
|
|
43
|
-
|
|
44
|
+
Root: {
|
|
44
45
|
style: {
|
|
45
46
|
borderRadius: "100%",
|
|
46
47
|
},
|
|
@@ -51,6 +52,7 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
|
|
|
51
52
|
<Block
|
|
52
53
|
display="flex"
|
|
53
54
|
flexDirection="column"
|
|
55
|
+
flex={1}
|
|
54
56
|
overrides={{
|
|
55
57
|
Block: {
|
|
56
58
|
style: {
|
|
@@ -59,32 +61,112 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
|
|
|
59
61
|
},
|
|
60
62
|
}}
|
|
61
63
|
>
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
<Skeleton animation width="60%" height={theme.sizing.scale900} />
|
|
65
|
+
<Skeleton animation width="40%" height={theme.sizing.scale800} />
|
|
66
|
+
</Block>
|
|
67
|
+
</Block>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type WelcomeBlockProps = BlockProps
|
|
72
|
+
|
|
73
|
+
export default function WelcomeBlock(props: WelcomeBlockProps) {
|
|
74
|
+
const { overrides, ...restProps } = props
|
|
75
|
+
const { accountDataRefetchInterval } = usePassportContext()
|
|
76
|
+
|
|
77
|
+
const { data, isError, isPending } = useGetCurrentAccount({
|
|
78
|
+
staleTime: accountDataRefetchInterval,
|
|
79
|
+
refetchInterval: accountDataRefetchInterval,
|
|
80
|
+
})
|
|
81
|
+
const [, theme] = useStyletron()
|
|
82
|
+
|
|
83
|
+
if (isError) {
|
|
84
|
+
return (
|
|
85
|
+
<AccountError
|
|
86
|
+
padding={theme.sizing.scale600}
|
|
87
|
+
paddingTop={theme.sizing.scale900}
|
|
88
|
+
paddingBottom={theme.sizing.scale800}
|
|
89
|
+
marginBottom={theme.sizing.scale300}
|
|
90
|
+
topic="account information"
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (isPending) {
|
|
96
|
+
return <WelcomeBlockSkeleton />
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const [mezoId, mezoIdSuffix] = (data.mezoId ?? "").split(DOT_DELIMITER_REGEX)
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Block
|
|
103
|
+
display="flex"
|
|
104
|
+
alignItems="center"
|
|
105
|
+
paddingLeft={theme.sizing.scale600}
|
|
106
|
+
paddingRight={theme.sizing.scale600}
|
|
107
|
+
paddingTop={theme.sizing.scale900}
|
|
108
|
+
paddingBottom={theme.sizing.scale800}
|
|
109
|
+
overrides={mergeOverrides(overrides, {
|
|
110
|
+
Block: {
|
|
111
|
+
style: {
|
|
112
|
+
gap: theme.sizing.scale600,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
})}
|
|
116
|
+
{...restProps}
|
|
117
|
+
>
|
|
118
|
+
<Block
|
|
119
|
+
as={DefaultAvatar}
|
|
120
|
+
width={theme.sizing.scale1200}
|
|
121
|
+
height={theme.sizing.scale1200}
|
|
122
|
+
overrides={{
|
|
123
|
+
Block: {
|
|
124
|
+
style: {
|
|
125
|
+
borderRadius: "100%",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
<Block display="flex" flexDirection="column">
|
|
132
|
+
{mezoId && mezoIdSuffix && (
|
|
133
|
+
<HeadingMedium as="span">
|
|
134
|
+
<Block as="span">{mezoId}</Block>
|
|
135
|
+
<Block as="span" color={theme.colors.contentSecondary}>
|
|
136
|
+
{mezoIdSuffix}
|
|
137
|
+
</Block>
|
|
138
|
+
</HeadingMedium>
|
|
139
|
+
)}
|
|
68
140
|
|
|
69
|
-
<
|
|
141
|
+
<Block
|
|
70
142
|
display="flex"
|
|
71
143
|
alignItems="center"
|
|
72
|
-
margin={0}
|
|
73
|
-
color={theme.colors.contentTertiary}
|
|
74
144
|
overrides={{
|
|
75
145
|
Block: {
|
|
76
146
|
style: {
|
|
77
|
-
gap: theme.sizing.
|
|
147
|
+
gap: theme.sizing.scale100,
|
|
78
148
|
},
|
|
79
149
|
},
|
|
80
150
|
}}
|
|
81
151
|
>
|
|
82
152
|
<Mats
|
|
83
|
-
|
|
84
|
-
|
|
153
|
+
size={theme.sizing.scale600}
|
|
154
|
+
overrides={{
|
|
155
|
+
Svg: {
|
|
156
|
+
style: {
|
|
157
|
+
margin: theme.sizing.scale100, // To reduce gap
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
}}
|
|
85
161
|
/>
|
|
86
|
-
|
|
87
|
-
|
|
162
|
+
|
|
163
|
+
<LabelLarge color={theme.colors.contentPrimary}>
|
|
164
|
+
<SlotNumber formatFunction={formatNumberToCompactString}>
|
|
165
|
+
{data.mats.totalMats}
|
|
166
|
+
</SlotNumber>{" "}
|
|
167
|
+
mats
|
|
168
|
+
</LabelLarge>
|
|
169
|
+
</Block>
|
|
88
170
|
</Block>
|
|
89
171
|
</Block>
|
|
90
172
|
)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
2
|
+
import React, { useMemo } from "react"
|
|
3
|
+
import { AnimatePresence, motion } from "motion/react"
|
|
4
|
+
import { Block, useStyletron } from "@mezo-org/mezo-clay"
|
|
5
|
+
|
|
6
|
+
type SlotNumberProps = {
|
|
7
|
+
className?: string
|
|
8
|
+
children: number
|
|
9
|
+
formatFunction?: (value: number) => string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type SlotNumberDigitProps = {
|
|
13
|
+
className?: string
|
|
14
|
+
children: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function SlotNumberDigit(props: SlotNumberDigitProps) {
|
|
18
|
+
const { children: value, ...restProps } = props
|
|
19
|
+
|
|
20
|
+
const [css] = useStyletron()
|
|
21
|
+
|
|
22
|
+
const digits = [...Array(10).keys()]
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<AnimatePresence initial={false}>
|
|
26
|
+
<motion.div
|
|
27
|
+
initial={{
|
|
28
|
+
y: "100%",
|
|
29
|
+
}}
|
|
30
|
+
animate={{
|
|
31
|
+
y: "0%",
|
|
32
|
+
}}
|
|
33
|
+
layout="position"
|
|
34
|
+
className={css({
|
|
35
|
+
position: "relative",
|
|
36
|
+
})}
|
|
37
|
+
{...restProps}
|
|
38
|
+
>
|
|
39
|
+
<Block
|
|
40
|
+
overrides={{
|
|
41
|
+
Block: {
|
|
42
|
+
style: {
|
|
43
|
+
visibility: "hidden",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{value}
|
|
49
|
+
</Block>
|
|
50
|
+
|
|
51
|
+
<motion.div
|
|
52
|
+
className={css({
|
|
53
|
+
display: "flex",
|
|
54
|
+
flexDirection: "column",
|
|
55
|
+
position: "absolute",
|
|
56
|
+
inset: 0,
|
|
57
|
+
height: "fit-content",
|
|
58
|
+
})}
|
|
59
|
+
initial={false}
|
|
60
|
+
animate={{ y: `${(value / 10) * -100}%` }}
|
|
61
|
+
transition={{
|
|
62
|
+
type: "spring",
|
|
63
|
+
damping: 16,
|
|
64
|
+
stiffness: 220,
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
{digits.map((digit) => (
|
|
68
|
+
<Block as="span" key={digit}>
|
|
69
|
+
{digit}
|
|
70
|
+
</Block>
|
|
71
|
+
))}
|
|
72
|
+
</motion.div>
|
|
73
|
+
</motion.div>
|
|
74
|
+
</AnimatePresence>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* SlotNumber component displays a number with animated digits.
|
|
80
|
+
*
|
|
81
|
+
* @typedef {object} SlotNumberProps
|
|
82
|
+
* @property {number} children - The number to display.
|
|
83
|
+
* @property {function} [formatFunction] - Optional function to format the number.
|
|
84
|
+
* @property {BlockProps} [restProps] - Additional properties for the Block component.
|
|
85
|
+
* @see https://pyszkowski.dev/writings/slot-number
|
|
86
|
+
* @returns {JSX.Element} The rendered SlotNumber component.
|
|
87
|
+
*/
|
|
88
|
+
function SlotNumber(props: SlotNumberProps) {
|
|
89
|
+
const { children: value, formatFunction, ...restProps } = props
|
|
90
|
+
|
|
91
|
+
const [css] = useStyletron()
|
|
92
|
+
|
|
93
|
+
const characters = useMemo(() => {
|
|
94
|
+
const formattedValue = formatFunction
|
|
95
|
+
? formatFunction(value)
|
|
96
|
+
: value.toString()
|
|
97
|
+
|
|
98
|
+
return formattedValue
|
|
99
|
+
.split("")
|
|
100
|
+
.map((character) => (/^[0-9]$/.test(character) ? +character : character))
|
|
101
|
+
.reverse()
|
|
102
|
+
}, [formatFunction, value])
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<motion.div
|
|
106
|
+
layout
|
|
107
|
+
className={css({
|
|
108
|
+
display: "inline-flex",
|
|
109
|
+
flexDirection: "row-reverse",
|
|
110
|
+
justifyContent: "flex-end",
|
|
111
|
+
overflow: "hidden",
|
|
112
|
+
userSelect: "none",
|
|
113
|
+
})}
|
|
114
|
+
{...restProps}
|
|
115
|
+
>
|
|
116
|
+
{characters.map((character, index) =>
|
|
117
|
+
typeof character === "number" ? (
|
|
118
|
+
<SlotNumberDigit key={`slot-number-character-${index}`}>
|
|
119
|
+
{character}
|
|
120
|
+
</SlotNumberDigit>
|
|
121
|
+
) : (
|
|
122
|
+
<motion.span layout key={`slot-number-character-${index}`}>
|
|
123
|
+
{character}
|
|
124
|
+
</motion.span>
|
|
125
|
+
),
|
|
126
|
+
)}
|
|
127
|
+
</motion.div>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default SlotNumber
|
package/src/config.ts
CHANGED
|
@@ -72,16 +72,6 @@ export const xverseWalletMezoMainnet = getXverseWallet(
|
|
|
72
72
|
bitcoinWalletMainnetConfig,
|
|
73
73
|
)
|
|
74
74
|
|
|
75
|
-
export const preconfiguredWalletConnectWallet = (projectId: string) =>
|
|
76
|
-
walletConnectWallet({
|
|
77
|
-
projectId,
|
|
78
|
-
options: {
|
|
79
|
-
qrModalOptions: {
|
|
80
|
-
enableExplorer: false,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
})
|
|
84
|
-
|
|
85
75
|
export function getDefaultWallets(
|
|
86
76
|
network: "mainnet" | "testnet" = "mainnet",
|
|
87
77
|
): WalletList {
|
|
@@ -103,7 +93,7 @@ export function getDefaultWallets(
|
|
|
103
93
|
},
|
|
104
94
|
{
|
|
105
95
|
groupName: "Ethereum",
|
|
106
|
-
wallets: [
|
|
96
|
+
wallets: [walletConnectWallet],
|
|
107
97
|
},
|
|
108
98
|
]
|
|
109
99
|
}
|