@mezo-org/passport 0.4.0-dev.2 → 0.4.0-dev.21
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/README.md +18 -22
- package/dist/src/api/auth.d.ts +57 -52
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +22 -53
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +24 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +54 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/fetch-error.d.ts +5 -0
- package/dist/src/api/fetch-error.d.ts.map +1 -0
- package/dist/src/api/fetch-error.js +8 -0
- package/dist/src/api/fetch-error.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/portal.d.ts +33 -0
- package/dist/src/api/portal.d.ts.map +1 -0
- package/dist/src/api/portal.js +23 -0
- package/dist/src/api/portal.js.map +1 -0
- 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 +23 -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 +65 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +34 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +47 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +57 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.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.js +2 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +5 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/constants.d.ts +3 -3
- package/dist/src/hooks/constants.js +4 -4
- package/dist/src/hooks/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -4
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +4 -4
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +7 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +24 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
- package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js +69 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
- package/dist/src/hooks/useBorrowData.d.ts +1418 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +65 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts +41 -137
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +8 -10
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useCreateSession.d.ts +12 -182
- package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
- package/dist/src/hooks/useCreateSession.js +12 -18
- package/dist/src/hooks/useCreateSession.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +39 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +63 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts +5 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +34 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -0
- package/dist/src/hooks/useGetAccountByAddress.d.ts +3 -5
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByAddress.js +3 -4
- package/dist/src/hooks/useGetAccountByAddress.js.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +3 -5
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.js +3 -4
- package/dist/src/hooks/useGetAccountByMezoId.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +14 -8
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +28 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useGetSession.d.ts +3 -20
- package/dist/src/hooks/useGetSession.d.ts.map +1 -1
- package/dist/src/hooks/useGetSession.js +2 -2
- package/dist/src/hooks/useGetSession.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +15 -121
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +8 -21
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
- package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
- package/dist/src/hooks/usePortalApiClient.js +6 -0
- package/dist/src/hooks/usePortalApiClient.js.map +1 -0
- package/dist/src/hooks/useRefreshPassport.d.ts +17 -0
- package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
- package/dist/src/hooks/useRefreshPassport.js +29 -0
- package/dist/src/hooks/useRefreshPassport.js.map +1 -0
- package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -181
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithDiscord.js +11 -22
- package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +12 -181
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +6 -44
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignOut.d.ts +12 -28
- package/dist/src/hooks/useSignOut.d.ts.map +1 -1
- package/dist/src/hooks/useSignOut.js +11 -6
- package/dist/src/hooks/useSignOut.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useSignUpWithWallet.js +11 -0
- package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
- package/dist/src/hooks/useTokensBalances.d.ts +74 -0
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
- package/dist/src/hooks/useTokensBalances.js +140 -0
- package/dist/src/hooks/useTokensBalances.js.map +1 -0
- package/dist/src/hooks/useUpdateMezoId.d.ts +30 -82
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.js +8 -12
- package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +13 -0
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
- package/dist/src/hooks/useWalletAccount.js +29 -0
- package/dist/src/hooks/useWalletAccount.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +10 -0
- package/dist/src/lib/contracts/index.d.ts.map +1 -0
- package/dist/src/lib/contracts/index.js +49 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- package/dist/src/lib/contracts/musd.d.ts +107 -0
- package/dist/src/lib/contracts/musd.d.ts.map +1 -0
- package/dist/src/lib/contracts/musd.js +1070 -0
- package/dist/src/lib/contracts/musd.js.map +1 -0
- package/dist/src/lib/contracts/troveManager.d.ts +1401 -0
- package/dist/src/lib/contracts/troveManager.d.ts.map +1 -0
- package/dist/src/lib/contracts/troveManager.js +1820 -0
- package/dist/src/lib/contracts/troveManager.js.map +1 -0
- package/dist/src/provider.d.ts +10 -13
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +11 -20
- package/dist/src/provider.js.map +1 -1
- package/dist/src/stores/dropdownStore.d.ts +12 -0
- package/dist/src/stores/dropdownStore.d.ts.map +1 -0
- package/dist/src/stores/dropdownStore.js +13 -0
- package/dist/src/stores/dropdownStore.js.map +1 -0
- package/dist/src/utils/address.d.ts +15 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +37 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +2 -0
- package/dist/src/utils/address.test.d.ts.map +1 -0
- package/dist/src/utils/address.test.js +40 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/cryptoAssets.d.ts +44 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +131 -0
- package/dist/src/utils/cryptoAssets.js.map +1 -0
- package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
- package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.test.js +67 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +14 -0
- package/dist/src/utils/currency.d.ts.map +1 -0
- package/dist/src/utils/currency.js +27 -0
- package/dist/src/utils/currency.js.map +1 -0
- package/dist/src/utils/currency.test.d.ts +2 -0
- package/dist/src/utils/currency.test.d.ts.map +1 -0
- package/dist/src/utils/currency.test.js +34 -0
- package/dist/src/utils/currency.test.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +58 -0
- package/dist/src/utils/numbers.d.ts.map +1 -0
- package/dist/src/utils/numbers.js +132 -0
- package/dist/src/utils/numbers.js.map +1 -0
- package/dist/src/utils/numbers.test.d.ts +2 -0
- package/dist/src/utils/numbers.test.d.ts.map +1 -0
- package/dist/src/utils/numbers.test.js +170 -0
- package/dist/src/utils/numbers.test.js.map +1 -0
- package/package.json +12 -5
- package/src/api/auth.ts +104 -129
- package/src/api/client.ts +78 -0
- package/src/api/fetch-error.ts +8 -0
- package/src/api/index.ts +2 -0
- package/src/api/portal.ts +57 -0
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
- package/src/components/Dropdown/Content.tsx +98 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
- package/src/components/Dropdown/Dropdown.tsx +139 -0
- package/src/components/Dropdown/ListingItem.tsx +80 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
- package/src/components/Dropdown/README.md +41 -0
- package/src/components/Dropdown/Receive/Receive.tsx +119 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
- package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -0
- package/src/components/Dropdown/Root/Root.tsx +147 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -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 +2 -2
- package/src/constants.ts +5 -4
- package/src/hooks/constants.ts +4 -4
- package/src/hooks/index.ts +7 -4
- package/src/hooks/useAssetsConversionRates.ts +32 -0
- package/src/hooks/useAuthenticateWithWallet.ts +102 -0
- package/src/hooks/useBorrowData.ts +79 -0
- package/src/hooks/useCreateAccount.ts +20 -11
- package/src/hooks/useCreateSession.ts +24 -18
- package/src/hooks/useDropdownData.ts +101 -0
- package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +46 -0
- package/src/hooks/useGetAccountByAddress.ts +11 -5
- package/src/hooks/useGetAccountByMezoId.ts +11 -5
- package/src/hooks/useGetCurrentAccount.ts +53 -7
- package/src/hooks/useGetSession.ts +10 -3
- package/src/hooks/useLinkAccount.ts +19 -31
- package/src/hooks/usePortalApiClient.ts +6 -0
- package/src/hooks/useRefreshPassport.ts +40 -0
- package/src/hooks/useSignInWithDiscord.ts +19 -28
- package/src/hooks/useSignInWithWallet.ts +14 -55
- package/src/hooks/useSignOut.ts +22 -6
- package/src/hooks/useSignUpWithWallet.ts +21 -0
- package/src/hooks/useTokensBalances.ts +187 -0
- package/src/hooks/useUpdateMezoId.ts +20 -12
- package/src/hooks/useWalletAccount.ts +55 -0
- package/src/index.ts +1 -0
- package/src/lib/contracts/index.ts +75 -0
- package/src/lib/contracts/musd.ts +1071 -0
- package/src/lib/contracts/troveManager.ts +1819 -0
- package/src/provider.ts +30 -37
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +48 -0
- package/src/utils/address.ts +45 -0
- package/src/utils/cryptoAssets.test.ts +79 -0
- package/src/utils/cryptoAssets.ts +173 -0
- package/src/utils/currency.test.ts +38 -0
- package/src/utils/currency.ts +32 -0
- package/src/utils/numbers.test.ts +220 -0
- package/src/utils/numbers.ts +188 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Block, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { useEffect } from "react"
|
|
3
|
+
import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
|
|
4
|
+
import Root from "./Root/Root"
|
|
5
|
+
import Receive from "./Receive/Receive"
|
|
6
|
+
import { DetailedCryptoAsset } from "../../utils/cryptoAssets"
|
|
7
|
+
import TestnetTopBanner from "./TestnetTopBanner"
|
|
8
|
+
|
|
9
|
+
type ContentProps = {
|
|
10
|
+
mezoId: string
|
|
11
|
+
matsBalance: number
|
|
12
|
+
accountAddress: string
|
|
13
|
+
walletAddress: string
|
|
14
|
+
walletType: "bitcoin" | "evm"
|
|
15
|
+
usdTotalBalance: number
|
|
16
|
+
usdTroveDebt: number
|
|
17
|
+
usdCollateral: number
|
|
18
|
+
assets: {
|
|
19
|
+
btc: DetailedCryptoAsset
|
|
20
|
+
musd: DetailedCryptoAsset
|
|
21
|
+
}
|
|
22
|
+
otherAssetsCount: number
|
|
23
|
+
otherAssetsUsdTotal: number
|
|
24
|
+
onSignOut?: () => void
|
|
25
|
+
onOtherAssetsClick?: () => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function Content(props: ContentProps) {
|
|
29
|
+
const {
|
|
30
|
+
mezoId,
|
|
31
|
+
accountAddress,
|
|
32
|
+
walletAddress,
|
|
33
|
+
walletType,
|
|
34
|
+
usdTotalBalance,
|
|
35
|
+
assets,
|
|
36
|
+
matsBalance,
|
|
37
|
+
usdTroveDebt,
|
|
38
|
+
usdCollateral,
|
|
39
|
+
otherAssetsCount,
|
|
40
|
+
otherAssetsUsdTotal,
|
|
41
|
+
onSignOut,
|
|
42
|
+
onOtherAssetsClick,
|
|
43
|
+
} = props
|
|
44
|
+
|
|
45
|
+
const [_, theme] = useStyletron()
|
|
46
|
+
|
|
47
|
+
const currentView = useDropdownStore((state) => state.view)
|
|
48
|
+
const setView = useDropdownStore((state) => state.setView)
|
|
49
|
+
|
|
50
|
+
useEffect(
|
|
51
|
+
() => () => {
|
|
52
|
+
setView(DropdownView.ROOT)
|
|
53
|
+
},
|
|
54
|
+
[setView],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Block
|
|
59
|
+
display="inline-flex"
|
|
60
|
+
flexDirection="column"
|
|
61
|
+
backgroundColor={theme.colors.backgroundPrimary}
|
|
62
|
+
width="100%"
|
|
63
|
+
overrides={{
|
|
64
|
+
Block: {
|
|
65
|
+
style: {
|
|
66
|
+
boxSizing: "border-box",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<TestnetTopBanner />
|
|
72
|
+
|
|
73
|
+
{currentView === DropdownView.ROOT && (
|
|
74
|
+
<Root
|
|
75
|
+
mezoId={mezoId}
|
|
76
|
+
accountAddress={accountAddress}
|
|
77
|
+
walletAddress={walletAddress}
|
|
78
|
+
walletType={walletType}
|
|
79
|
+
usdTotalBalance={usdTotalBalance}
|
|
80
|
+
assets={assets}
|
|
81
|
+
matsBalance={matsBalance}
|
|
82
|
+
usdTroveDebt={usdTroveDebt}
|
|
83
|
+
usdCollateral={usdCollateral}
|
|
84
|
+
otherAssetsCount={otherAssetsCount}
|
|
85
|
+
otherAssetsUsdTotal={otherAssetsUsdTotal}
|
|
86
|
+
onSignOut={onSignOut}
|
|
87
|
+
onOtherAssetsClick={onOtherAssetsClick}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{currentView === DropdownView.RECEIVE && (
|
|
92
|
+
<Receive address={accountAddress} />
|
|
93
|
+
)}
|
|
94
|
+
</Block>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default Content
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Button, ButtonProps, LogIn01, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { forwardRef } from "react"
|
|
3
|
+
|
|
4
|
+
type DisconnectedTriggerProps = Omit<ButtonProps, "children"> & {
|
|
5
|
+
children: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const DisconnectedTrigger = forwardRef<
|
|
9
|
+
HTMLButtonElement,
|
|
10
|
+
DisconnectedTriggerProps
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const { onClick, children, ...restProps } = props
|
|
13
|
+
|
|
14
|
+
const [, theme] = useStyletron()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Button
|
|
18
|
+
startEnhancer={
|
|
19
|
+
<LogIn01 color="currentColor" size={theme.sizing.scale600} />
|
|
20
|
+
}
|
|
21
|
+
overrides={{
|
|
22
|
+
Root: {
|
|
23
|
+
props: { ref },
|
|
24
|
+
},
|
|
25
|
+
}}
|
|
26
|
+
size="small"
|
|
27
|
+
shape="pill"
|
|
28
|
+
onClick={onClick}
|
|
29
|
+
{...restProps}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</Button>
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export default DisconnectedTrigger
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonProps,
|
|
3
|
+
StatefulPopover,
|
|
4
|
+
StatefulPopoverProps,
|
|
5
|
+
useStyletron,
|
|
6
|
+
} from "@mezo-org/mezo-clay"
|
|
7
|
+
import { useConnectModal } from "@rainbow-me/rainbowkit"
|
|
8
|
+
import React, { useEffect, useMemo } from "react"
|
|
9
|
+
import { useDisconnect } from "wagmi"
|
|
10
|
+
import DefaultAvatar from "../../assets/DefaultAvatar"
|
|
11
|
+
import useWalletAccount from "../../hooks/useWalletAccount"
|
|
12
|
+
import ConnectedTrigger from "./ConnectedTrigger"
|
|
13
|
+
import Content from "./Content"
|
|
14
|
+
import DisconnectedTrigger from "./DisconnectedTrigger"
|
|
15
|
+
import { useSignInWithWallet } from "../../hooks"
|
|
16
|
+
import useDropdownData from "../../hooks/useDropdownData"
|
|
17
|
+
|
|
18
|
+
export type DropdownProps = {
|
|
19
|
+
/** The callback to be called when the user clicks the sign-out button */
|
|
20
|
+
onSignOut?: () => void
|
|
21
|
+
/** The callback to be called when the user clicks the button in sign-in state */
|
|
22
|
+
onSignIn?: () => void
|
|
23
|
+
/** The props to be passed to the trigger button */
|
|
24
|
+
triggerProps?: {
|
|
25
|
+
signedIn?: Omit<ButtonProps, "onClick" | "size"> & {
|
|
26
|
+
size: "medium" | "large"
|
|
27
|
+
}
|
|
28
|
+
signedOut?: Omit<ButtonProps, "onClick">
|
|
29
|
+
}
|
|
30
|
+
onOtherAssetsClick?: () => void
|
|
31
|
+
} & Omit<StatefulPopoverProps, "children" | "content">
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Passport Dropdown component that displays user's wallet and assets information.
|
|
35
|
+
* @param {DropdownProps} props - Component props.
|
|
36
|
+
* @returns {JSX.Element}
|
|
37
|
+
*/
|
|
38
|
+
export function Dropdown(props: DropdownProps) {
|
|
39
|
+
const {
|
|
40
|
+
placement = "bottomRight",
|
|
41
|
+
animateOutTime = 120,
|
|
42
|
+
onSignIn,
|
|
43
|
+
onSignOut,
|
|
44
|
+
overrides,
|
|
45
|
+
triggerProps,
|
|
46
|
+
onOtherAssetsClick,
|
|
47
|
+
...restProps
|
|
48
|
+
} = props
|
|
49
|
+
|
|
50
|
+
const [, theme] = useStyletron()
|
|
51
|
+
|
|
52
|
+
const data = useDropdownData()
|
|
53
|
+
|
|
54
|
+
const isCriticalDropdownDataLoaded = useMemo(
|
|
55
|
+
() => Boolean(data.mezoId && data.accountAddress && data.walletAddress),
|
|
56
|
+
[data],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
const { openConnectModal } = useConnectModal()
|
|
60
|
+
|
|
61
|
+
const { isConnected } = useWalletAccount()
|
|
62
|
+
|
|
63
|
+
const { signInWithWalletAsync, isPending } = useSignInWithWallet()
|
|
64
|
+
|
|
65
|
+
const { disconnectAsync } = useDisconnect()
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (onSignIn) return
|
|
69
|
+
|
|
70
|
+
const handleSignIn = async () => {
|
|
71
|
+
if (!isConnected) return
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
await signInWithWalletAsync()
|
|
75
|
+
} catch (error) {
|
|
76
|
+
await disconnectAsync()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
handleSignIn()
|
|
81
|
+
}, [disconnectAsync, isConnected, onSignIn, signInWithWalletAsync])
|
|
82
|
+
|
|
83
|
+
if (!isConnected || !isCriticalDropdownDataLoaded) {
|
|
84
|
+
return (
|
|
85
|
+
<DisconnectedTrigger
|
|
86
|
+
// If connect wallet flow is not provided it fallbacks to RainbowKit's
|
|
87
|
+
// connect modal
|
|
88
|
+
onClick={onSignIn || openConnectModal}
|
|
89
|
+
isLoading={isPending}
|
|
90
|
+
{...triggerProps?.signedOut}
|
|
91
|
+
>
|
|
92
|
+
Sign in
|
|
93
|
+
</DisconnectedTrigger>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<StatefulPopover
|
|
99
|
+
content={
|
|
100
|
+
<Content
|
|
101
|
+
mezoId={data.mezoId!}
|
|
102
|
+
matsBalance={data.matsBalance}
|
|
103
|
+
accountAddress={data.accountAddress!}
|
|
104
|
+
walletAddress={data.walletAddress!}
|
|
105
|
+
walletType={data.walletType}
|
|
106
|
+
usdTotalBalance={data.usdTotalBalance}
|
|
107
|
+
usdTroveDebt={data.usdTroveDebt}
|
|
108
|
+
usdCollateral={data.usdCollateral}
|
|
109
|
+
assets={data.assets}
|
|
110
|
+
otherAssetsCount={data.otherAssetsCount}
|
|
111
|
+
otherAssetsUsdTotal={data.otherAssetsUsdTotal}
|
|
112
|
+
onSignOut={onSignOut}
|
|
113
|
+
onOtherAssetsClick={onOtherAssetsClick}
|
|
114
|
+
/>
|
|
115
|
+
}
|
|
116
|
+
placement={placement}
|
|
117
|
+
animateOutTime={animateOutTime}
|
|
118
|
+
overrides={{
|
|
119
|
+
...overrides,
|
|
120
|
+
Body: {
|
|
121
|
+
...overrides?.Body,
|
|
122
|
+
style: {
|
|
123
|
+
width: "396px",
|
|
124
|
+
borderRadius: theme.borders.radius500,
|
|
125
|
+
boxShadow: theme.lighting.shadow500,
|
|
126
|
+
overflow: "hidden",
|
|
127
|
+
...overrides?.Body?.style,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
}}
|
|
131
|
+
{...restProps}
|
|
132
|
+
>
|
|
133
|
+
<ConnectedTrigger
|
|
134
|
+
avatar={<DefaultAvatar />}
|
|
135
|
+
{...triggerProps?.signedIn}
|
|
136
|
+
/>
|
|
137
|
+
</StatefulPopover>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ListItem,
|
|
3
|
+
ListItemLabel,
|
|
4
|
+
mergeOverrides,
|
|
5
|
+
ListItemLabelProps,
|
|
6
|
+
IconProps,
|
|
7
|
+
ListItemProps,
|
|
8
|
+
} from "@mezo-org/mezo-clay"
|
|
9
|
+
import React, { FC } from "react"
|
|
10
|
+
|
|
11
|
+
const SHARED_LABEL_OVERRIDES: ListItemLabelProps["overrides"] = {
|
|
12
|
+
LabelDescription: {
|
|
13
|
+
style: {
|
|
14
|
+
color: "#4B4B4B", // contentSecondary
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ListingItemProps = {
|
|
20
|
+
icon?: FC<IconProps>
|
|
21
|
+
label: string
|
|
22
|
+
subLabel?: string
|
|
23
|
+
value: string
|
|
24
|
+
subValue?: string
|
|
25
|
+
overrides?: ListItemProps["overrides"]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function ListingItem(props: ListingItemProps) {
|
|
29
|
+
const {
|
|
30
|
+
icon: Icon,
|
|
31
|
+
label,
|
|
32
|
+
subLabel = "",
|
|
33
|
+
value,
|
|
34
|
+
subValue = "",
|
|
35
|
+
overrides,
|
|
36
|
+
} = props
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ListItem
|
|
40
|
+
artwork={Icon}
|
|
41
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
42
|
+
endEnhancer={() => (
|
|
43
|
+
<ListItemLabel
|
|
44
|
+
description={subValue}
|
|
45
|
+
overrides={mergeOverrides(
|
|
46
|
+
{
|
|
47
|
+
LabelRoot: {
|
|
48
|
+
style: {
|
|
49
|
+
textAlign: "right",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
SHARED_LABEL_OVERRIDES,
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
{value}
|
|
57
|
+
</ListItemLabel>
|
|
58
|
+
)}
|
|
59
|
+
overrides={mergeOverrides(
|
|
60
|
+
{
|
|
61
|
+
Root: {
|
|
62
|
+
style: {
|
|
63
|
+
backgroundColor: "transparent",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
Content: {
|
|
67
|
+
style: {
|
|
68
|
+
border: 0,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
overrides,
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
<ListItemLabel description={subLabel} overrides={SHARED_LABEL_OVERRIDES}>
|
|
76
|
+
{label}
|
|
77
|
+
</ListItemLabel>
|
|
78
|
+
</ListItem>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowLeft,
|
|
3
|
+
Block,
|
|
4
|
+
ButtonIcon,
|
|
5
|
+
LabelMedium,
|
|
6
|
+
useStyletron,
|
|
7
|
+
} from "@mezo-org/mezo-clay"
|
|
8
|
+
import React, { ReactNode, useCallback } from "react"
|
|
9
|
+
import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
|
|
10
|
+
|
|
11
|
+
const getHeaderTitle = (view: DropdownView) => {
|
|
12
|
+
const titleMap: Partial<Record<DropdownView, string>> = {
|
|
13
|
+
[DropdownView.RECEIVE]: "Receive",
|
|
14
|
+
}
|
|
15
|
+
return titleMap[view]!
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type NestedViewLayoutProps = {
|
|
19
|
+
children: ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function NestedViewLayout(props: NestedViewLayoutProps) {
|
|
23
|
+
const { children, ...restProps } = props
|
|
24
|
+
|
|
25
|
+
const currentView = useDropdownStore((state) => state.view)
|
|
26
|
+
const setView = useDropdownStore((state) => state.setView)
|
|
27
|
+
const isNested = useDropdownStore((state) => state.isNestedView())
|
|
28
|
+
|
|
29
|
+
const [, theme] = useStyletron()
|
|
30
|
+
|
|
31
|
+
const handleOnButtonClick = useCallback(() => {
|
|
32
|
+
setView(DropdownView.ROOT)
|
|
33
|
+
}, [setView])
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Block
|
|
37
|
+
display="flex"
|
|
38
|
+
flexDirection="column"
|
|
39
|
+
minHeight="588px"
|
|
40
|
+
padding={theme.sizing.scale700}
|
|
41
|
+
paddingTop={0}
|
|
42
|
+
{...restProps}
|
|
43
|
+
>
|
|
44
|
+
<Block
|
|
45
|
+
display="flex"
|
|
46
|
+
alignItems="center"
|
|
47
|
+
paddingTop={theme.sizing.scale600}
|
|
48
|
+
paddingBottom={theme.sizing.scale600}
|
|
49
|
+
marginBottom={theme.sizing.scale300}
|
|
50
|
+
>
|
|
51
|
+
<ButtonIcon
|
|
52
|
+
onClick={handleOnButtonClick}
|
|
53
|
+
shape="circle"
|
|
54
|
+
size="small"
|
|
55
|
+
overrides={{
|
|
56
|
+
BaseButton: {
|
|
57
|
+
style: {
|
|
58
|
+
background: theme.colors.backgroundPrimary,
|
|
59
|
+
marginRight: isNested ? theme.sizing.scale300 : undefined,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<ArrowLeft size={theme.sizing.scale700} />
|
|
65
|
+
</ButtonIcon>
|
|
66
|
+
|
|
67
|
+
<LabelMedium>{getHeaderTitle(currentView)}</LabelMedium>
|
|
68
|
+
</Block>
|
|
69
|
+
|
|
70
|
+
{children}
|
|
71
|
+
</Block>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default NestedViewLayout
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Passport Dropdown component
|
|
2
|
+
|
|
3
|
+
This component is a layer of interaction with Passport API in form of Dropdown
|
|
4
|
+
component. It allows to establish the session and interact with the API.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
- `onSignIn` (`() => void`) - The callback to be executed on trigger click when
|
|
9
|
+
the state is disconnected. It's optional since by default it triggers the
|
|
10
|
+
[Rainbow Kit's wallet connection modal](https://www.rainbowkit.com/docs/modal-hooks).
|
|
11
|
+
If the callback is not provided it will automatically establish the Passport
|
|
12
|
+
Session. If not, you have to handle it manually using `useSignInWithWallet`
|
|
13
|
+
hook. - **optional**
|
|
14
|
+
- `onSignOut` (`() => void`) - The callback to be executed on click of the
|
|
15
|
+
**Sign out** button. It's optional since by default it disconnects the current
|
|
16
|
+
wallet connector and closes the Passport session. - **optional**
|
|
17
|
+
- `triggerProps.signedIn` (`ButtonProps`) - Props to be passed to the trigger
|
|
18
|
+
button in signed-in state.
|
|
19
|
+
- `triggerProps.signedOut` (`ButtonProps`) - Props to be passed to the trigger
|
|
20
|
+
button in signed-out state
|
|
21
|
+
|
|
22
|
+
Besides that, component allows
|
|
23
|
+
[Clay's `StatefulPopover` props](https://baseweb.design/components/popover/)
|
|
24
|
+
excluding the `children` and `content`.
|
|
25
|
+
|
|
26
|
+
## Overview
|
|
27
|
+
|
|
28
|
+
The component has two distinguishable states - disconnected and connected. In
|
|
29
|
+
disconnected state the component offers the trigger to initiate the connection
|
|
30
|
+
flow. It can be fully customizable by providing your own one. As long as it's
|
|
31
|
+
compliant with Wagmi/RainbowKit it will work. Component will automatically
|
|
32
|
+
detect connected connector and change the state of component displaying the
|
|
33
|
+
avatar thumbnail instead of button.
|
|
34
|
+
|
|
35
|
+
Component has the following features:
|
|
36
|
+
|
|
37
|
+
- displays wallet address that can be copied,
|
|
38
|
+
- displays total balance in USD,
|
|
39
|
+
- displays partial balances per asset with token amounts and USD conversions,
|
|
40
|
+
- serves _Log out_ button which disconnects the wallet connector and closes
|
|
41
|
+
Passport API session.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Block,
|
|
3
|
+
Button,
|
|
4
|
+
LabelMedium,
|
|
5
|
+
MonoLabelXSmall,
|
|
6
|
+
ParagraphSmall,
|
|
7
|
+
useStyletron,
|
|
8
|
+
} from "@mezo-org/mezo-clay"
|
|
9
|
+
import React, { useCallback, useState } from "react"
|
|
10
|
+
import { useCopyToClipboard } from "usehooks-ts"
|
|
11
|
+
import { QRCodeSVG } from "qrcode.react"
|
|
12
|
+
import NestedViewLayout from "../NestedViewLayout"
|
|
13
|
+
import { getAddressExplorerUrl } from "../../../utils/address"
|
|
14
|
+
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
15
|
+
import useWalletAccount from "../../../hooks/useWalletAccount"
|
|
16
|
+
|
|
17
|
+
type ReceiveProps = {
|
|
18
|
+
address: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Receive(props: ReceiveProps) {
|
|
22
|
+
const { address } = props
|
|
23
|
+
|
|
24
|
+
const { environment } = usePassportContext()
|
|
25
|
+
|
|
26
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
27
|
+
address,
|
|
28
|
+
"mezo",
|
|
29
|
+
environment === "testnet",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const [, theme] = useStyletron()
|
|
33
|
+
|
|
34
|
+
const [, copy] = useCopyToClipboard()
|
|
35
|
+
const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
|
|
36
|
+
const handleCopyAddress = useCallback(() => {
|
|
37
|
+
copy(address)
|
|
38
|
+
setIsCopiedMessageVisible(true)
|
|
39
|
+
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
setIsCopiedMessageVisible(false)
|
|
42
|
+
}, 2000)
|
|
43
|
+
}, [copy, address])
|
|
44
|
+
|
|
45
|
+
const { networkFamily } = useWalletAccount()
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<NestedViewLayout>
|
|
49
|
+
<LabelMedium>Receive assets on Mezo</LabelMedium>
|
|
50
|
+
|
|
51
|
+
<ParagraphSmall
|
|
52
|
+
marginTop={theme.sizing.scale300}
|
|
53
|
+
marginBottom={theme.sizing.scale600}
|
|
54
|
+
color={theme.colors.contentTertiary}
|
|
55
|
+
>
|
|
56
|
+
{networkFamily === "bitcoin" ? (
|
|
57
|
+
<>
|
|
58
|
+
Mezo automatically created a smart account that's fully
|
|
59
|
+
controlled by your connected Bitcoin wallet. Use this address to
|
|
60
|
+
receive assets on Mezo.
|
|
61
|
+
</>
|
|
62
|
+
) : (
|
|
63
|
+
<>
|
|
64
|
+
Your connected wallet address is your Mezo address. Use this address
|
|
65
|
+
to receive assets on Mezo.
|
|
66
|
+
</>
|
|
67
|
+
)}
|
|
68
|
+
</ParagraphSmall>
|
|
69
|
+
|
|
70
|
+
<Block
|
|
71
|
+
as={QRCodeSVG}
|
|
72
|
+
value={address}
|
|
73
|
+
flex={1}
|
|
74
|
+
overrides={{
|
|
75
|
+
Block: {
|
|
76
|
+
style: {
|
|
77
|
+
aspectRatio: 1,
|
|
78
|
+
width: "fit-content",
|
|
79
|
+
margin: "0 auto",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<MonoLabelXSmall
|
|
86
|
+
marginTop={theme.sizing.scale800}
|
|
87
|
+
marginBottom={theme.sizing.scale800}
|
|
88
|
+
overrides={{
|
|
89
|
+
Block: {
|
|
90
|
+
style: {
|
|
91
|
+
textAlign: "center",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
{address}
|
|
97
|
+
</MonoLabelXSmall>
|
|
98
|
+
|
|
99
|
+
<Button
|
|
100
|
+
onClick={handleCopyAddress}
|
|
101
|
+
overrides={{
|
|
102
|
+
BaseButton: {
|
|
103
|
+
style: {
|
|
104
|
+
marginBottom: theme.sizing.scale400,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{isCopiedMessageVisible ? "Copied!" : "Copy Mezo Address"}
|
|
110
|
+
</Button>
|
|
111
|
+
|
|
112
|
+
<Button kind="secondary" $as="a" href={blockExplorerUrl} target="_blank">
|
|
113
|
+
View Explorer
|
|
114
|
+
</Button>
|
|
115
|
+
</NestedViewLayout>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export default Receive
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowNarrowLeft,
|
|
3
|
+
Block,
|
|
4
|
+
Button,
|
|
5
|
+
ButtonProps,
|
|
6
|
+
Cube01,
|
|
7
|
+
useStyletron,
|
|
8
|
+
} from "@mezo-org/mezo-clay"
|
|
9
|
+
import React, { useCallback } from "react"
|
|
10
|
+
import { usePassportContext } from "../../../hooks/usePassportContext"
|
|
11
|
+
import { getAddressExplorerUrl } from "../../../utils/address"
|
|
12
|
+
import useDropdownStore, { DropdownView } from "../../../stores/dropdownStore"
|
|
13
|
+
|
|
14
|
+
type AccountAddressActionsProps = {
|
|
15
|
+
address: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const buttonStartEnhancerSize = 12
|
|
19
|
+
|
|
20
|
+
const commonButtonProps: Partial<ButtonProps> = {
|
|
21
|
+
kind: "secondary",
|
|
22
|
+
size: "xsmall",
|
|
23
|
+
overrides: {
|
|
24
|
+
BaseButton: {
|
|
25
|
+
style: {
|
|
26
|
+
flex: 1,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
StartEnhancer: {
|
|
30
|
+
style: {
|
|
31
|
+
stroke: "currentColor",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function AccountAddressActions(
|
|
38
|
+
props: AccountAddressActionsProps,
|
|
39
|
+
) {
|
|
40
|
+
const { address } = props
|
|
41
|
+
|
|
42
|
+
const [, theme] = useStyletron()
|
|
43
|
+
|
|
44
|
+
const { environment } = usePassportContext()
|
|
45
|
+
const blockExplorerUrl = getAddressExplorerUrl(
|
|
46
|
+
address,
|
|
47
|
+
"mezo",
|
|
48
|
+
environment === "testnet",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
const setDropdownView = useDropdownStore((state) => state.setView)
|
|
52
|
+
|
|
53
|
+
const handleReceiveClick = useCallback(() => {
|
|
54
|
+
setDropdownView(DropdownView.RECEIVE)
|
|
55
|
+
}, [setDropdownView])
|
|
56
|
+
|
|
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
|
+
<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
|
+
<Button
|
|
82
|
+
onClick={handleReceiveClick}
|
|
83
|
+
startEnhancer={
|
|
84
|
+
<ArrowNarrowLeft
|
|
85
|
+
size={buttonStartEnhancerSize}
|
|
86
|
+
overrides={{
|
|
87
|
+
Svg: {
|
|
88
|
+
style: {
|
|
89
|
+
transform: "rotate(-45deg)",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
}
|
|
95
|
+
{...commonButtonProps}
|
|
96
|
+
>
|
|
97
|
+
Receive
|
|
98
|
+
</Button>
|
|
99
|
+
</Block>
|
|
100
|
+
)
|
|
101
|
+
}
|