@mezo-org/passport 0.15.1-dev.7 → 0.16.0-dev.0
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/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +8 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +27 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +23 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +45 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts +14 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +42 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +8 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +32 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +4 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +64 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +49 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +32 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- 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 +28 -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 +8 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +43 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +45 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +66 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +88 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
- 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/components/Dropdown/TestnetTopBanner.d.ts +3 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
- package/dist/src/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/config.d.ts +4 -3
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +13 -9
- package/dist/src/config.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +0 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +11 -11
- package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.js +1 -1
- package/dist/src/hooks/useBorrowData.js.map +1 -1
- package/dist/src/hooks/useCollateralPrice.js +1 -1
- package/dist/src/hooks/useCollateralPrice.js.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +1 -1
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +1 -1
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +11 -11
- package/dist/src/hooks/useSignUpWithWallet.d.ts +11 -11
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
- package/dist/src/hooks/useTokensBalances.js +10 -2
- package/dist/src/hooks/useTokensBalances.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +3 -3
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +4 -6
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -1
- package/dist/src/hooks/useWatchTransferEvents.js +1 -0
- package/dist/src/hooks/useWatchTransferEvents.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/artifacts/MEZO.json +428 -0
- 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 +3 -0
- package/dist/src/lib/contracts/index.js.map +1 -1
- package/dist/src/utils/assets.d.ts +15 -0
- package/dist/src/utils/assets.d.ts.map +1 -1
- package/dist/src/utils/assets.js +13 -0
- package/dist/src/utils/assets.js.map +1 -1
- package/package.json +8 -7
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
- package/src/components/Dropdown/Content.tsx +53 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
- package/src/components/Dropdown/Dropdown.tsx +100 -0
- package/src/components/Dropdown/ListingItem.tsx +176 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +87 -0
- package/src/components/Dropdown/README.md +41 -0
- package/src/components/Dropdown/Receive/Receive.tsx +144 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +99 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +69 -0
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +53 -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 +85 -0
- package/src/components/Dropdown/Root/Root.tsx +77 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +123 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +173 -0
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/config.ts +26 -16
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAuthenticateWithWallet.ts +1 -1
- package/src/hooks/useBorrowData.ts +1 -1
- package/src/hooks/useCollateralPrice.ts +1 -1
- package/src/hooks/useCreateAccount.ts +1 -1
- package/src/hooks/useLinkAccount.ts +1 -1
- package/src/hooks/useTokensBalances.ts +10 -1
- package/src/hooks/useWalletAccount.ts +7 -18
- package/src/hooks/useWatchTransferEvents.ts +1 -0
- package/src/index.ts +2 -0
- package/src/lib/contracts/artifacts/MEZO.json +428 -0
- package/src/lib/contracts/index.ts +4 -0
- package/src/utils/assets.ts +14 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BitcoinCircle,
|
|
3
|
+
Block,
|
|
4
|
+
BlockProps,
|
|
5
|
+
EthCircle,
|
|
6
|
+
LabelMedium,
|
|
7
|
+
LabelXSmall,
|
|
8
|
+
mergeOverrides,
|
|
9
|
+
MonoLabelXSmall,
|
|
10
|
+
useStyletron,
|
|
11
|
+
} from "@mezo-org/mezo-clay"
|
|
12
|
+
import React, { useState } from "react"
|
|
13
|
+
import { useCopyToClipboard } from "usehooks-ts"
|
|
14
|
+
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
15
|
+
import { getAddressExplorerUrl, trimAddress } from "../../../utils/address"
|
|
16
|
+
import useWalletAccount from "../../../hooks/useWalletAccount"
|
|
17
|
+
|
|
18
|
+
export default function WalletAddress(props: BlockProps) {
|
|
19
|
+
const { overrides, ...restProps } = props
|
|
20
|
+
const { walletAddress, networkFamily } = useWalletAccount()
|
|
21
|
+
const { environment = "mainnet" } = usePassportContext()
|
|
22
|
+
const [, theme] = useStyletron()
|
|
23
|
+
const [, copy] = useCopyToClipboard()
|
|
24
|
+
const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
|
|
25
|
+
|
|
26
|
+
const handleCopyAddress = () => {
|
|
27
|
+
copy(walletAddress!)
|
|
28
|
+
setIsCopiedMessageVisible(true)
|
|
29
|
+
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
setIsCopiedMessageVisible(false)
|
|
32
|
+
}, 2000)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
36
|
+
walletAddress!,
|
|
37
|
+
networkFamily,
|
|
38
|
+
environment === "testnet",
|
|
39
|
+
)
|
|
40
|
+
const trimmedAddress = trimAddress(walletAddress!)
|
|
41
|
+
const AccountIcon = networkFamily === "bitcoin" ? BitcoinCircle : EthCircle
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Block
|
|
45
|
+
as="button"
|
|
46
|
+
onClick={handleCopyAddress}
|
|
47
|
+
display="flex"
|
|
48
|
+
alignItems="center"
|
|
49
|
+
backgroundColor="transparent"
|
|
50
|
+
padding={`${theme.sizing.scale800} ${theme.sizing.scale700}`}
|
|
51
|
+
overrides={mergeOverrides(
|
|
52
|
+
{
|
|
53
|
+
Block: {
|
|
54
|
+
style: {
|
|
55
|
+
gap: theme.sizing.scale700,
|
|
56
|
+
borderWidth: 0,
|
|
57
|
+
cursor: "pointer",
|
|
58
|
+
":hover": {
|
|
59
|
+
backgroundColor: theme.colors.backgroundTertiary,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
overrides,
|
|
65
|
+
)}
|
|
66
|
+
{...restProps}
|
|
67
|
+
>
|
|
68
|
+
<AccountIcon
|
|
69
|
+
color={theme.colors.black}
|
|
70
|
+
size={theme.sizing.scale800}
|
|
71
|
+
overrides={{
|
|
72
|
+
Svg: {
|
|
73
|
+
style: {
|
|
74
|
+
backgroundColor: theme.colors.black,
|
|
75
|
+
overflow: "hidden",
|
|
76
|
+
borderRadius: theme.borders.radius200,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
<Block
|
|
82
|
+
display="flex"
|
|
83
|
+
flexDirection="column"
|
|
84
|
+
alignItems="flex-start"
|
|
85
|
+
overrides={{
|
|
86
|
+
Block: {
|
|
87
|
+
style: {
|
|
88
|
+
gap: theme.sizing.scale100,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<LabelMedium>Connected Wallet</LabelMedium>
|
|
94
|
+
|
|
95
|
+
{isCopiedMessageVisible ? (
|
|
96
|
+
<LabelXSmall color={theme.colors.contentSecondary}>
|
|
97
|
+
Copied address to clipboard
|
|
98
|
+
</LabelXSmall>
|
|
99
|
+
) : (
|
|
100
|
+
<Block
|
|
101
|
+
as="a"
|
|
102
|
+
color={theme.colors.contentSecondary}
|
|
103
|
+
href={blockExplorerUrl}
|
|
104
|
+
target="_blank"
|
|
105
|
+
overrides={{
|
|
106
|
+
Block: {
|
|
107
|
+
style: {
|
|
108
|
+
color: "inherit",
|
|
109
|
+
textDecoration: "none",
|
|
110
|
+
":hover": {
|
|
111
|
+
textDecoration: "underline",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
<MonoLabelXSmall>{trimmedAddress}</MonoLabelXSmall>
|
|
118
|
+
</Block>
|
|
119
|
+
)}
|
|
120
|
+
</Block>
|
|
121
|
+
</Block>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Block,
|
|
3
|
+
BlockProps,
|
|
4
|
+
HeadingMedium,
|
|
5
|
+
LabelLarge,
|
|
6
|
+
Mats,
|
|
7
|
+
mergeOverrides,
|
|
8
|
+
Skeleton,
|
|
9
|
+
useStyletron,
|
|
10
|
+
} from "@mezo-org/mezo-clay"
|
|
11
|
+
import React from "react"
|
|
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"
|
|
18
|
+
|
|
19
|
+
const DOT_DELIMITER_REGEX = /(?=\.)/
|
|
20
|
+
|
|
21
|
+
function WelcomeBlockSkeleton() {
|
|
22
|
+
const [, theme] = useStyletron()
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Block
|
|
26
|
+
display="flex"
|
|
27
|
+
alignItems="center"
|
|
28
|
+
padding={theme.sizing.scale600}
|
|
29
|
+
paddingTop={theme.sizing.scale900}
|
|
30
|
+
paddingBottom={theme.sizing.scale800}
|
|
31
|
+
overrides={{
|
|
32
|
+
Block: {
|
|
33
|
+
style: {
|
|
34
|
+
gap: theme.sizing.scale600,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<Skeleton
|
|
40
|
+
animation
|
|
41
|
+
width={theme.sizing.scale1200}
|
|
42
|
+
height={theme.sizing.scale1200}
|
|
43
|
+
overrides={{
|
|
44
|
+
Root: {
|
|
45
|
+
style: {
|
|
46
|
+
borderRadius: "100%",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<Block
|
|
53
|
+
display="flex"
|
|
54
|
+
flexDirection="column"
|
|
55
|
+
flex={1}
|
|
56
|
+
overrides={{
|
|
57
|
+
Block: {
|
|
58
|
+
style: {
|
|
59
|
+
gap: theme.sizing.scale100,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
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
|
+
)}
|
|
140
|
+
|
|
141
|
+
<Block
|
|
142
|
+
display="flex"
|
|
143
|
+
alignItems="center"
|
|
144
|
+
overrides={{
|
|
145
|
+
Block: {
|
|
146
|
+
style: {
|
|
147
|
+
gap: theme.sizing.scale100,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<Mats
|
|
153
|
+
size={theme.sizing.scale600}
|
|
154
|
+
overrides={{
|
|
155
|
+
Svg: {
|
|
156
|
+
style: {
|
|
157
|
+
margin: theme.sizing.scale100, // To reduce gap
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
|
|
163
|
+
<LabelLarge color={theme.colors.contentPrimary}>
|
|
164
|
+
<SlotNumber formatFunction={formatNumberToCompactString}>
|
|
165
|
+
{data.totalMats}
|
|
166
|
+
</SlotNumber>{" "}
|
|
167
|
+
mats
|
|
168
|
+
</LabelLarge>
|
|
169
|
+
</Block>
|
|
170
|
+
</Block>
|
|
171
|
+
</Block>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
@@ -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
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
Block,
|
|
4
|
+
InfoCircle,
|
|
5
|
+
LabelSmall,
|
|
6
|
+
useStyletron,
|
|
7
|
+
} from "@mezo-org/mezo-clay"
|
|
8
|
+
import { usePassportContext } from "../../hooks/usePassportContext"
|
|
9
|
+
|
|
10
|
+
export default function TestnetTopBanner() {
|
|
11
|
+
const [, theme] = useStyletron()
|
|
12
|
+
|
|
13
|
+
const { environment } = usePassportContext()
|
|
14
|
+
|
|
15
|
+
if (environment !== "testnet") {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Block
|
|
21
|
+
display="flex"
|
|
22
|
+
alignItems="center"
|
|
23
|
+
padding={`${theme.sizing.scale700} ${theme.sizing.scale600}`}
|
|
24
|
+
backgroundColor={theme.colors.warning}
|
|
25
|
+
>
|
|
26
|
+
<InfoCircle size={theme.sizing.scale550} />
|
|
27
|
+
<LabelSmall marginLeft={theme.sizing.scale500}>
|
|
28
|
+
You are using testnet funds.
|
|
29
|
+
</LabelSmall>
|
|
30
|
+
</Block>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dropdown, DropdownProps } from "./Dropdown"
|
package/src/config.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { getOKXWallet, getUnisatWallet, getXverseWallet } from "./wallet"
|
|
|
12
12
|
|
|
13
13
|
type WagmiConfigParameters = Omit<
|
|
14
14
|
CreateConfigParameters,
|
|
15
|
-
"client" | "connectors" | "chains" | "transports"
|
|
15
|
+
"client" | "connectors" | "chains" | "wallets" | "transports"
|
|
16
16
|
>
|
|
17
17
|
type GetDefaultConfigParameters = WagmiConfigParameters & {
|
|
18
18
|
appName: string
|
|
@@ -20,12 +20,32 @@ type GetDefaultConfigParameters = WagmiConfigParameters & {
|
|
|
20
20
|
appDescription?: string
|
|
21
21
|
appUrl?: string
|
|
22
22
|
appIcon?: string
|
|
23
|
-
|
|
24
|
-
walletConnectProjectId
|
|
23
|
+
bitcoinWallets?: WalletList
|
|
24
|
+
walletConnectProjectId?: string
|
|
25
25
|
chains?: [Chain, ...Chain[]]
|
|
26
26
|
transports?: Pick<CreateConfigParameters, "transports">
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const transports = {
|
|
30
|
+
[CHAIN_ID.mainnet]: http(RPC_BY_NETWORK.mainnet.http),
|
|
31
|
+
[CHAIN_ID.testnet]: http(RPC_BY_NETWORK.testnet.http),
|
|
32
|
+
} as Pick<CreateConfigParameters, "transports">
|
|
33
|
+
|
|
34
|
+
export const defaultConfig: Required<
|
|
35
|
+
Pick<
|
|
36
|
+
GetDefaultConfigParameters,
|
|
37
|
+
| "transports"
|
|
38
|
+
| "walletConnectProjectId"
|
|
39
|
+
| "chains"
|
|
40
|
+
| "multiInjectedProviderDiscovery"
|
|
41
|
+
>
|
|
42
|
+
> = {
|
|
43
|
+
transports,
|
|
44
|
+
walletConnectProjectId: "",
|
|
45
|
+
chains: [mezoMainnet, mezoTestnet],
|
|
46
|
+
multiInjectedProviderDiscovery: true,
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
const bitcoinWalletTestnetConfig = {
|
|
30
50
|
rpcUrl: RPC_BY_NETWORK.testnet.http,
|
|
31
51
|
chainId: CHAIN_ID.testnet,
|
|
@@ -92,27 +112,17 @@ export function getConfig(config: GetDefaultConfigParameters): Config {
|
|
|
92
112
|
const {
|
|
93
113
|
appName,
|
|
94
114
|
mezoNetwork = "mainnet",
|
|
95
|
-
walletConnectProjectId,
|
|
115
|
+
walletConnectProjectId = defaultConfig.walletConnectProjectId,
|
|
96
116
|
...restParameters
|
|
97
117
|
} = config
|
|
98
118
|
|
|
99
|
-
const
|
|
100
|
-
mezoNetwork === "mainnet" ? [mezoMainnet] : [mezoTestnet]
|
|
101
|
-
|
|
102
|
-
const transports =
|
|
103
|
-
mezoNetwork === "mainnet"
|
|
104
|
-
? { [mezoMainnet.id]: http(RPC_BY_NETWORK.mainnet.http) }
|
|
105
|
-
: { [mezoTestnet.id]: http(RPC_BY_NETWORK.testnet.http) }
|
|
106
|
-
|
|
107
|
-
const wallets = config.wallets ?? [...getDefaultWallets(mezoNetwork)]
|
|
119
|
+
const wallets = config.bitcoinWallets ?? [...getDefaultWallets(mezoNetwork)]
|
|
108
120
|
|
|
109
121
|
return getDefaultConfig({
|
|
122
|
+
...defaultConfig,
|
|
110
123
|
appName,
|
|
111
|
-
chains,
|
|
112
|
-
transports,
|
|
113
124
|
wallets,
|
|
114
125
|
projectId: walletConnectProjectId,
|
|
115
|
-
multiInjectedProviderDiscovery: true,
|
|
116
126
|
...restParameters,
|
|
117
127
|
})
|
|
118
128
|
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "../utils/siww"
|
|
14
14
|
import { useGetAccountByAddress } from "./useGetAccountByAddress"
|
|
15
15
|
import type { Session } from "../api"
|
|
16
|
-
import
|
|
16
|
+
import useWalletAccount from "./useWalletAccount"
|
|
17
17
|
|
|
18
18
|
function useAuthenticateWithWallet(
|
|
19
19
|
shouldCreateAccount = false,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { usePassportContext } from "./usePassportContext"
|
|
10
10
|
import { CHAIN_ID } from "../constants"
|
|
11
11
|
import { bigIntMax, normalizePrecision } from "../utils/numbers"
|
|
12
|
-
import
|
|
12
|
+
import useWalletAccount from "./useWalletAccount"
|
|
13
13
|
import { getAsset } from "../utils/assets"
|
|
14
14
|
import { convertToUsd } from "../utils/currency"
|
|
15
15
|
import { useCollateralPrice } from "./useCollateralPrice"
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "../lib/contracts"
|
|
7
7
|
import { usePassportContext } from "./usePassportContext"
|
|
8
8
|
import { CHAIN_ID } from "../constants"
|
|
9
|
-
import
|
|
9
|
+
import useWalletAccount from "./useWalletAccount"
|
|
10
10
|
|
|
11
11
|
// Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
|
|
12
12
|
// support importing JSON as const yet so types cannot be inferred from the
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { useAuthApiClient } from "./useAuthApiClient"
|
|
8
8
|
import { QUERY_KEYS } from "./constants"
|
|
9
9
|
import type { CreateAccountRequest, CreateAccountResponse } from "../api"
|
|
10
|
-
import
|
|
10
|
+
import useWalletAccount from "./useWalletAccount"
|
|
11
11
|
import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi"
|
|
12
12
|
|
|
13
13
|
export function useCreateAccount(
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { useAuthApiClient } from "./useAuthApiClient"
|
|
8
8
|
import type { LinkAccountResponse, SignatureData } from "../api"
|
|
9
9
|
import { QUERY_KEYS } from "./constants"
|
|
10
|
-
import
|
|
10
|
+
import useWalletAccount from "./useWalletAccount"
|
|
11
11
|
import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi"
|
|
12
12
|
|
|
13
13
|
type LinkAccountMutationFnParameters =
|
|
@@ -13,11 +13,12 @@ import {
|
|
|
13
13
|
MezoChainToken,
|
|
14
14
|
testnetTokenContracts,
|
|
15
15
|
} from "../lib/contracts"
|
|
16
|
-
import
|
|
16
|
+
import useWalletAccount from "./useWalletAccount"
|
|
17
17
|
import {
|
|
18
18
|
getAsset,
|
|
19
19
|
isBitcoinLikeCryptoAsset,
|
|
20
20
|
isTTokenCryptoAsset,
|
|
21
|
+
isMezoCryptoAsset,
|
|
21
22
|
} from "../utils/assets"
|
|
22
23
|
import { convertToUsd } from "../utils/currency"
|
|
23
24
|
import { CHAIN_ID, mezoMainnet, mezoTestnet } from "../constants"
|
|
@@ -65,6 +66,7 @@ const BALANCE_TOKENS: MezoChainToken[] = [
|
|
|
65
66
|
"mUSDT",
|
|
66
67
|
"mxSolvBTC",
|
|
67
68
|
"MUSD",
|
|
69
|
+
"MEZO",
|
|
68
70
|
]
|
|
69
71
|
|
|
70
72
|
type UseMezoChainTokensBalancesOptions<T extends MezoChainToken[]> = {
|
|
@@ -219,6 +221,13 @@ export function useTokensBalances<T extends MezoChainToken[]>(
|
|
|
219
221
|
conversion.decimals,
|
|
220
222
|
)
|
|
221
223
|
}
|
|
224
|
+
// TODO: Provide MEZO oracle to get accurate token price
|
|
225
|
+
if (isMezoCryptoAsset(tokenBalance.symbol)) {
|
|
226
|
+
usd = {
|
|
227
|
+
value: 0n,
|
|
228
|
+
formatted: "0",
|
|
229
|
+
}
|
|
230
|
+
}
|
|
222
231
|
|
|
223
232
|
return { ...tokenBalance, usd }
|
|
224
233
|
})
|
|
@@ -2,12 +2,9 @@ import { OrangeKitConnector } from "@mezo-org/orangekit"
|
|
|
2
2
|
import { useQuery } from "@tanstack/react-query"
|
|
3
3
|
import { useMemo } from "react"
|
|
4
4
|
import { Address } from "viem"
|
|
5
|
-
import { Connector, useAccount
|
|
5
|
+
import { Connector, useAccount } from "wagmi"
|
|
6
6
|
|
|
7
|
-
type UseWalletAccountReturn =
|
|
8
|
-
UseAccountReturnType,
|
|
9
|
-
"isConnected" | "address" | "connector" | "chainId"
|
|
10
|
-
> & {
|
|
7
|
+
type UseWalletAccountReturn = {
|
|
11
8
|
accountAddress?: Address
|
|
12
9
|
walletAddress?: string
|
|
13
10
|
isConnected: boolean
|
|
@@ -16,14 +13,10 @@ type UseWalletAccountReturn = Omit<
|
|
|
16
13
|
chainId?: number
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
chainId,
|
|
24
|
-
isConnected,
|
|
25
|
-
...rest
|
|
26
|
-
} = useAccount()
|
|
16
|
+
// TODO: Invesitgate race conditions and refactor
|
|
17
|
+
|
|
18
|
+
export default function useWalletAccount(): UseWalletAccountReturn {
|
|
19
|
+
const { address: evmAddress, connector, chainId } = useAccount()
|
|
27
20
|
|
|
28
21
|
const networkFamily = useMemo(
|
|
29
22
|
() => (connector?.type !== "orangekit" ? "evm" : "bitcoin"),
|
|
@@ -45,7 +38,6 @@ export function useWalletAccount(): UseWalletAccountReturn {
|
|
|
45
38
|
balance,
|
|
46
39
|
}
|
|
47
40
|
},
|
|
48
|
-
enabled: networkFamily === "bitcoin" && !!connector,
|
|
49
41
|
})
|
|
50
42
|
|
|
51
43
|
const { address: btcAddress } = btcData || {}
|
|
@@ -53,12 +45,9 @@ export function useWalletAccount(): UseWalletAccountReturn {
|
|
|
53
45
|
return {
|
|
54
46
|
accountAddress: evmAddress,
|
|
55
47
|
walletAddress: btcAddress ?? evmAddress,
|
|
56
|
-
isConnected:
|
|
57
|
-
isConnected &&
|
|
58
|
-
(networkFamily === "bitcoin" ? !!btcAddress : !!evmAddress),
|
|
48
|
+
isConnected: networkFamily === "bitcoin" ? !!btcAddress : !!evmAddress,
|
|
59
49
|
networkFamily,
|
|
60
50
|
connector,
|
|
61
51
|
chainId,
|
|
62
|
-
...rest,
|
|
63
52
|
}
|
|
64
53
|
}
|