@lifi/widget 4.7.1 → 4.9.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/esm/components/AmountInput/AmountInput.style.d.ts.map +1 -1
- package/dist/esm/components/AmountInputCard/AmountInputCardPair.js +5 -2
- package/dist/esm/components/AmountInputCard/AmountInputCardPair.js.map +1 -1
- package/dist/esm/components/Card/Card.d.ts.map +1 -1
- package/dist/esm/components/Card/CardIconButton.d.ts.map +1 -1
- package/dist/esm/components/ContractComponent/ItemPrice.d.ts.map +1 -1
- package/dist/esm/components/ListItem/ListItemButton.d.ts.map +1 -1
- package/dist/esm/components/ListItemButton.d.ts.map +1 -1
- package/dist/esm/components/SelectChainAndToken.js +5 -2
- package/dist/esm/components/SelectChainAndToken.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js +5 -4
- package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/dist/esm/components/Token/Token.d.ts.map +1 -1
- package/dist/esm/components/TokenList/types.d.ts.map +1 -1
- package/dist/esm/components/TokenList/useTokenSelect.d.ts.map +1 -1
- package/dist/esm/components/TokenList/useTokenSelect.js +10 -0
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/dist/esm/config/constants.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useAccountsBalancesData.js +5 -2
- package/dist/esm/hooks/useAccountsBalancesData.js.map +1 -1
- package/dist/esm/hooks/useAddressValidation.d.ts +3 -2
- package/dist/esm/hooks/useAddressValidation.d.ts.map +1 -1
- package/dist/esm/hooks/useAddressValidation.js +48 -21
- package/dist/esm/hooks/useAddressValidation.js.map +1 -1
- package/dist/esm/hooks/useAvailableChains.d.ts.map +1 -1
- package/dist/esm/hooks/useAvailableChains.js +21 -38
- package/dist/esm/hooks/useAvailableChains.js.map +1 -1
- package/dist/esm/hooks/useFromTokenSufficiency.js +3 -3
- package/dist/esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/dist/esm/hooks/useGasRecommendation.js +3 -3
- package/dist/esm/hooks/useGasRecommendation.js.map +1 -1
- package/dist/esm/hooks/useGasRefuel.js +4 -1
- package/dist/esm/hooks/useGasRefuel.js.map +1 -1
- package/dist/esm/hooks/useGasSufficiency.js +3 -3
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useIsBatchingSupported.js +2 -2
- package/dist/esm/hooks/useIsBatchingSupported.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +6 -6
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRoutes.d.ts.map +1 -1
- package/dist/esm/hooks/useRoutes.js +18 -13
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useToAddressAutoPopulate.js +6 -8
- package/dist/esm/hooks/useToAddressAutoPopulate.js.map +1 -1
- package/dist/esm/hooks/useToAddressRequirements.d.ts +3 -2
- package/dist/esm/hooks/useToAddressRequirements.d.ts.map +1 -1
- package/dist/esm/hooks/useToAddressRequirements.js +8 -7
- package/dist/esm/hooks/useToAddressRequirements.js.map +1 -1
- package/dist/esm/hooks/useToAddressReset.js +6 -3
- package/dist/esm/hooks/useToAddressReset.js.map +1 -1
- package/dist/esm/hooks/useTokenBalance.js +6 -5
- package/dist/esm/hooks/useTokenBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalancesQueries.js +3 -3
- package/dist/esm/hooks/useTokenBalancesQueries.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.js +3 -3
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +15 -15
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.d.ts.map +1 -1
- package/dist/esm/hooks/useTools.js +26 -27
- package/dist/esm/hooks/useTools.js.map +1 -1
- package/dist/esm/hooks/useTransactionDetails.js +2 -2
- package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
- package/dist/esm/hooks/useTransactionHistory.js +3 -3
- package/dist/esm/hooks/useTransactionHistory.js.map +1 -1
- package/dist/esm/i18n/bn.json +2 -1
- package/dist/esm/i18n/de.json +2 -1
- package/dist/esm/i18n/en.json +2 -1
- package/dist/esm/i18n/es.json +2 -1
- package/dist/esm/i18n/fr.json +2 -1
- package/dist/esm/i18n/hi.json +2 -1
- package/dist/esm/i18n/id.json +2 -1
- package/dist/esm/i18n/it.json +2 -1
- package/dist/esm/i18n/ja.json +2 -1
- package/dist/esm/i18n/ko.json +2 -1
- package/dist/esm/i18n/pl.json +2 -1
- package/dist/esm/i18n/pt.json +2 -1
- package/dist/esm/i18n/th.json +2 -1
- package/dist/esm/i18n/tr.json +2 -1
- package/dist/esm/i18n/uk.json +2 -1
- package/dist/esm/i18n/vi.json +2 -1
- package/dist/esm/i18n/zh.json +2 -1
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/pages/RoutesPage/RoutesPage.style.d.ts.map +1 -1
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +7 -4
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/BookmarksPage.js +35 -31
- package/dist/esm/pages/SendToWallet/BookmarksPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/ConnectedWalletsPage.js +4 -3
- package/dist/esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/RecentWalletsPage.js +43 -39
- package/dist/esm/pages/SendToWallet/RecentWalletsPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToConfiguredWalletPage.js +32 -26
- package/dist/esm/pages/SendToWallet/SendToConfiguredWalletPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js +5 -10
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/dist/esm/providers/I18nProvider/types.d.ts.map +1 -1
- package/dist/esm/providers/WalletProvider/WalletProvider.d.ts.map +1 -1
- package/dist/esm/providers/WalletProvider/WalletProvider.js +14 -2
- package/dist/esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js +15 -11
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/types.d.ts +2 -0
- package/dist/esm/providers/WidgetProvider/types.d.ts.map +1 -1
- package/dist/esm/queries/getChains.d.ts +38 -0
- package/dist/esm/queries/getChains.d.ts.map +1 -0
- package/dist/esm/queries/getChains.js +51 -0
- package/dist/esm/queries/getChains.js.map +1 -0
- package/dist/esm/queries/getTools.d.ts +26 -0
- package/dist/esm/queries/getTools.d.ts.map +1 -0
- package/dist/esm/queries/getTools.js +30 -0
- package/dist/esm/queries/getTools.js.map +1 -0
- package/dist/esm/queries/index.d.ts +4 -0
- package/dist/esm/queries/index.js +3 -0
- package/dist/esm/queries/types.d.ts +25 -0
- package/dist/esm/queries/types.d.ts.map +1 -0
- package/dist/esm/shared.d.ts +2 -1
- package/dist/esm/shared.js +2 -1
- package/dist/esm/stores/StoreProvider.d.ts.map +1 -1
- package/dist/esm/stores/StoreProvider.js +16 -17
- package/dist/esm/stores/StoreProvider.js.map +1 -1
- package/dist/esm/stores/bookmarks/types.d.ts +3 -0
- package/dist/esm/stores/bookmarks/types.d.ts.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.d.ts.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.js +4 -1
- package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
- package/dist/esm/stores/form/FormStore.js +3 -2
- package/dist/esm/stores/form/FormStore.js.map +1 -1
- package/dist/esm/stores/form/URLSearchParamsBuilder.js +7 -3
- package/dist/esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js +4 -1
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/themes/createTheme.d.ts.map +1 -1
- package/dist/esm/types/events.d.ts.map +1 -1
- package/dist/esm/types/token.d.ts.map +1 -1
- package/dist/esm/types/widget.d.ts +30 -0
- package/dist/esm/types/widget.d.ts.map +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/chainType.js +32 -1
- package/dist/esm/utils/chainType.js.map +1 -1
- package/dist/esm/utils/customReceiver.js +6 -1
- package/dist/esm/utils/customReceiver.js.map +1 -1
- package/dist/esm/utils/queries.js.map +1 -1
- package/dist/esm/utils/scopeKeys.d.ts +6 -0
- package/dist/esm/utils/scopeKeys.d.ts.map +1 -0
- package/dist/esm/utils/scopeKeys.js +8 -0
- package/dist/esm/utils/scopeKeys.js.map +1 -0
- package/package.json +15 -7
- package/src/components/AmountInputCard/AmountInputCardPair.tsx +6 -2
- package/src/components/SelectChainAndToken.tsx +5 -1
- package/src/components/SendToWallet/SendToWalletButton.tsx +13 -8
- package/src/components/TokenList/useTokenSelect.ts +15 -0
- package/src/config/constants.ts +3 -0
- package/src/config/version.ts +1 -1
- package/src/hooks/useAccountsBalancesData.ts +6 -2
- package/src/hooks/useAddressValidation.ts +87 -32
- package/src/hooks/useAvailableChains.test.tsx +170 -0
- package/src/hooks/useAvailableChains.ts +29 -47
- package/src/hooks/useFromTokenSufficiency.ts +2 -2
- package/src/hooks/useGasRecommendation.ts +2 -2
- package/src/hooks/useGasRefuel.ts +11 -1
- package/src/hooks/useGasSufficiency.ts +2 -2
- package/src/hooks/useIsBatchingSupported.ts +2 -2
- package/src/hooks/useRouteExecution.ts +5 -5
- package/src/hooks/useRoutes.ts +28 -23
- package/src/hooks/useToAddressAutoPopulate.ts +13 -17
- package/src/hooks/useToAddressRequirements.ts +19 -4
- package/src/hooks/useToAddressReset.ts +13 -4
- package/src/hooks/useTokenBalance.ts +10 -5
- package/src/hooks/useTokenBalancesQueries.ts +3 -3
- package/src/hooks/useTokenSearch.ts +7 -3
- package/src/hooks/useTokens.ts +13 -14
- package/src/hooks/useTools.sharedEntry.test.tsx +155 -0
- package/src/hooks/useTools.ts +42 -37
- package/src/hooks/useTransactionDetails.ts +3 -3
- package/src/hooks/useTransactionHistory.ts +2 -2
- package/src/index.ts +2 -1
- package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +5 -1
- package/src/pages/SendToWallet/BookmarksPage.tsx +42 -52
- package/src/pages/SendToWallet/ConnectedWalletsPage.tsx +4 -14
- package/src/pages/SendToWallet/RecentWalletsPage.tsx +59 -66
- package/src/pages/SendToWallet/SendToConfiguredWalletPage.tsx +45 -50
- package/src/pages/SendToWallet/SendToWalletPage.tsx +4 -16
- package/src/providers/WalletProvider/WalletProvider.tsx +28 -3
- package/src/providers/WidgetProvider/WidgetProvider.test.tsx +73 -0
- package/src/providers/WidgetProvider/WidgetProvider.tsx +28 -14
- package/src/providers/WidgetProvider/types.ts +2 -0
- package/src/queries/getChains.ts +93 -0
- package/src/queries/getTools.ts +62 -0
- package/src/queries/index.ts +30 -0
- package/src/queries/sharedCache.test.tsx +223 -0
- package/src/queries/types.ts +38 -0
- package/src/shared.ts +1 -0
- package/src/stores/StoreProvider.test.tsx +107 -0
- package/src/stores/StoreProvider.tsx +8 -6
- package/src/stores/bookmarks/types.ts +3 -0
- package/src/stores/chains/ChainOrderStore.tsx +4 -1
- package/src/stores/form/FormStore.tsx +2 -0
- package/src/stores/form/URLSearchParamsBuilder.tsx +4 -2
- package/src/stores/form/getDefaultValuesFromQueryString.ts +19 -0
- package/src/stores/header/useHeaderStore.tsx +3 -4
- package/src/types/widget.ts +30 -0
- package/src/utils/chainType.ts +73 -1
- package/src/utils/customReceiver.ts +36 -0
- package/src/utils/queries.ts +1 -0
- package/src/utils/scopeKeys.ts +18 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { defaultChainIdsByType } from "../../utils/chainType.js";
|
|
1
2
|
import { navigationRoutes } from "../../utils/navigationRoutes.js";
|
|
2
3
|
import { useBookmarkActions } from "../../stores/bookmarks/useBookmarkActions.js";
|
|
3
4
|
import { useBookmarks } from "../../stores/bookmarks/useBookmarks.js";
|
|
4
5
|
import { useFieldActions } from "../../stores/form/useFieldActions.js";
|
|
5
6
|
import { PageContainer } from "../../components/PageContainer.js";
|
|
6
|
-
import { defaultChainIdsByType } from "../../utils/chainType.js";
|
|
7
7
|
import { useToAddressRequirements } from "../../hooks/useToAddressRequirements.js";
|
|
8
8
|
import { shortenAddress } from "../../utils/wallet.js";
|
|
9
9
|
import { openInNewTab } from "../../utils/url.js";
|
|
@@ -33,7 +33,7 @@ const BookmarksPage = () => {
|
|
|
33
33
|
const listParentRef = useRef(null);
|
|
34
34
|
const buttonRef = useRef(null);
|
|
35
35
|
const { bookmarks } = useBookmarks();
|
|
36
|
-
const {
|
|
36
|
+
const { isValidReceiver } = useToAddressRequirements();
|
|
37
37
|
const { addBookmark, removeBookmark, setSelectedBookmark } = useBookmarkActions();
|
|
38
38
|
const navigate = useNavigate();
|
|
39
39
|
const { setFieldValue } = useFieldActions();
|
|
@@ -69,36 +69,40 @@ const BookmarksPage = () => {
|
|
|
69
69
|
},
|
|
70
70
|
disablePadding: true,
|
|
71
71
|
sx: { paddingTop: 1.5 },
|
|
72
|
-
children: [bookmarks.map((bookmark) =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
children: [/* @__PURE__ */
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
children: [bookmarks.map((bookmark) => {
|
|
73
|
+
const disabled = !isValidReceiver(bookmark.address);
|
|
74
|
+
const chainId = bookmark.chainId ?? defaultChainIdsByType[bookmark.chainType];
|
|
75
|
+
return /* @__PURE__ */ jsxs(ListItem$1, {
|
|
76
|
+
sx: { position: "relative" },
|
|
77
|
+
children: [/* @__PURE__ */ jsxs(ListItemButton$1, {
|
|
78
|
+
onClick: () => handleBookmarkSelected(bookmark),
|
|
79
|
+
disabled,
|
|
80
|
+
children: [/* @__PURE__ */ jsx(ListItemAvatar, { children: /* @__PURE__ */ jsx(AccountAvatar, { chainId }) }), /* @__PURE__ */ jsx(ListItemText, {
|
|
81
|
+
primary: bookmark.name,
|
|
82
|
+
secondary: shortenAddress(bookmark.address)
|
|
83
|
+
})]
|
|
84
|
+
}), /* @__PURE__ */ jsx(ContextMenu, {
|
|
85
|
+
disabled,
|
|
86
|
+
items: [
|
|
87
|
+
{
|
|
88
|
+
icon: /* @__PURE__ */ jsx(ContentCopyRounded, {}),
|
|
89
|
+
label: t("button.copyAddress"),
|
|
90
|
+
onClick: () => navigator.clipboard.writeText(bookmark.address)
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: /* @__PURE__ */ jsx(OpenInNewRounded, {}),
|
|
94
|
+
label: t("button.viewOnExplorer"),
|
|
95
|
+
onClick: () => openInNewTab(getAddressLink(bookmark.address, chainId))
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
icon: /* @__PURE__ */ jsx(DeleteOutline, {}),
|
|
99
|
+
label: t("button.delete"),
|
|
100
|
+
onClick: () => removeBookmark(bookmark.address)
|
|
101
|
+
}
|
|
102
|
+
]
|
|
80
103
|
})]
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
items: [
|
|
84
|
-
{
|
|
85
|
-
icon: /* @__PURE__ */ jsx(ContentCopyRounded, {}),
|
|
86
|
-
label: t("button.copyAddress"),
|
|
87
|
-
onClick: () => navigator.clipboard.writeText(bookmark.address)
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
icon: /* @__PURE__ */ jsx(OpenInNewRounded, {}),
|
|
91
|
-
label: t("button.viewOnExplorer"),
|
|
92
|
-
onClick: () => openInNewTab(getAddressLink(bookmark.address, defaultChainIdsByType[bookmark.chainType]))
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
icon: /* @__PURE__ */ jsx(DeleteOutline, {}),
|
|
96
|
-
label: t("button.delete"),
|
|
97
|
-
onClick: () => removeBookmark(bookmark.address)
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
})]
|
|
101
|
-
}, bookmark.address)), !bookmarks.length && /* @__PURE__ */ jsx(EmptyListIndicator, {
|
|
104
|
+
}, bookmark.address);
|
|
105
|
+
}), !bookmarks.length && /* @__PURE__ */ jsx(EmptyListIndicator, {
|
|
102
106
|
icon: /* @__PURE__ */ jsx(TurnedIn, {}),
|
|
103
107
|
title: t("sendToWallet.noBookmarkedWallets"),
|
|
104
108
|
message: t("sendToWallet.noBookmarkedWalletsMessage")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BookmarksPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/BookmarksPage.tsx"],"sourcesContent":["import ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport DeleteOutline from '@mui/icons-material/DeleteOutlined'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport TurnedIn from '@mui/icons-material/TurnedIn'\nimport { Button, List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { useNavigate } from '@tanstack/react-router'\nimport { type JSX, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport type { BottomSheetBase } from '../../components/BottomSheet/types.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport type { Bookmark } from '../../stores/bookmarks/types.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useBookmarks } from '../../stores/bookmarks/useBookmarks.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { defaultChainIdsByType } from '../../utils/chainType.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\nimport { BookmarkAddressSheet } from './BookmarkAddressSheet.js'\nimport { BookmarkButtonContainer } from './SendToWalletPage.style.js'\n\nexport const BookmarksPage = (): JSX.Element => {\n const { t } = useTranslation()\n const bookmarkAddressSheetRef = useRef<BottomSheetBase>(null)\n const listParentRef = useRef<HTMLUListElement | null>(null)\n const buttonRef = useRef<HTMLDivElement | null>(null)\n const { bookmarks } = useBookmarks()\n const {
|
|
1
|
+
{"version":3,"file":"BookmarksPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/BookmarksPage.tsx"],"sourcesContent":["import ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport DeleteOutline from '@mui/icons-material/DeleteOutlined'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport TurnedIn from '@mui/icons-material/TurnedIn'\nimport { Button, List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { useNavigate } from '@tanstack/react-router'\nimport { type JSX, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport type { BottomSheetBase } from '../../components/BottomSheet/types.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport type { Bookmark } from '../../stores/bookmarks/types.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useBookmarks } from '../../stores/bookmarks/useBookmarks.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { defaultChainIdsByType } from '../../utils/chainType.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\nimport { BookmarkAddressSheet } from './BookmarkAddressSheet.js'\nimport { BookmarkButtonContainer } from './SendToWalletPage.style.js'\n\nexport const BookmarksPage = (): JSX.Element => {\n const { t } = useTranslation()\n const bookmarkAddressSheetRef = useRef<BottomSheetBase>(null)\n const listParentRef = useRef<HTMLUListElement | null>(null)\n const buttonRef = useRef<HTMLDivElement | null>(null)\n const { bookmarks } = useBookmarks()\n const { isValidReceiver } = useToAddressRequirements()\n const { addBookmark, removeBookmark, setSelectedBookmark } =\n useBookmarkActions()\n const navigate = useNavigate()\n const { setFieldValue } = useFieldActions()\n const { getAddressLink } = useExplorer()\n\n useHeader(t('header.bookmarkedWallets'))\n\n const { listHeight } = useListHeight({\n listParentRef,\n headerRef: buttonRef,\n })\n\n const handleAddBookmark = () => {\n bookmarkAddressSheetRef.current?.open()\n }\n\n const handleBookmarkSelected = (bookmark: Bookmark) => {\n setFieldValue('toAddress', bookmark.address, {\n isTouched: true,\n isDirty: true,\n })\n setSelectedBookmark(bookmark)\n navigate({ to: navigationRoutes.home, replace: true })\n }\n\n return (\n <PageContainer disableGutters>\n <List\n className=\"long-list\"\n ref={listParentRef}\n style={{ height: listHeight, overflow: 'auto' }}\n disablePadding\n sx={{ paddingTop: 1.5 }}\n >\n {bookmarks.map((bookmark) => {\n const disabled = !isValidReceiver(bookmark.address)\n const chainId =\n bookmark.chainId ?? defaultChainIdsByType[bookmark.chainType]\n return (\n <ListItem key={bookmark.address} sx={{ position: 'relative' }}>\n <ListItemButton\n onClick={() => handleBookmarkSelected(bookmark)}\n disabled={disabled}\n >\n <ListItemAvatar>\n <AccountAvatar chainId={chainId} />\n </ListItemAvatar>\n <ListItemText\n primary={bookmark.name}\n secondary={shortenAddress(bookmark.address)}\n />\n </ListItemButton>\n <ContextMenu\n disabled={disabled}\n items={[\n {\n icon: <ContentCopyRounded />,\n label: t('button.copyAddress'),\n onClick: () =>\n navigator.clipboard.writeText(bookmark.address),\n },\n {\n icon: <OpenInNewRounded />,\n label: t('button.viewOnExplorer'),\n onClick: () =>\n openInNewTab(getAddressLink(bookmark.address, chainId)),\n },\n {\n icon: <DeleteOutline />,\n label: t('button.delete'),\n onClick: () => removeBookmark(bookmark.address),\n },\n ]}\n />\n </ListItem>\n )\n })}\n {!bookmarks.length && (\n <EmptyListIndicator\n icon={<TurnedIn />}\n title={t('sendToWallet.noBookmarkedWallets')}\n message={t('sendToWallet.noBookmarkedWalletsMessage')}\n />\n )}\n </List>\n <BookmarkButtonContainer ref={buttonRef}>\n <Button variant=\"contained\" onClick={handleAddBookmark}>\n {t('sendToWallet.addBookmark')}\n </Button>\n </BookmarkButtonContainer>\n <BookmarkAddressSheet\n ref={bookmarkAddressSheetRef}\n onAddBookmark={addBookmark}\n />\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,sBAAmC;CAC9C,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,0BAA0B,OAAwB,IAAI;CAC5D,MAAM,gBAAgB,OAAgC,IAAI;CAC1D,MAAM,YAAY,OAA8B,IAAI;CACpD,MAAM,EAAE,cAAc,aAAa;CACnC,MAAM,EAAE,oBAAoB,yBAAyB;CACrD,MAAM,EAAE,aAAa,gBAAgB,wBACnC,mBAAmB;CACrB,MAAM,WAAW,YAAY;CAC7B,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,EAAE,mBAAmB,YAAY;CAEvC,UAAU,EAAE,0BAA0B,CAAC;CAEvC,MAAM,EAAE,eAAe,cAAc;EACnC;EACA,WAAW;CACb,CAAC;CAED,MAAM,0BAA0B;EAC9B,wBAAwB,SAAS,KAAK;CACxC;CAEA,MAAM,0BAA0B,aAAuB;EACrD,cAAc,aAAa,SAAS,SAAS;GAC3C,WAAW;GACX,SAAS;EACX,CAAC;EACD,oBAAoB,QAAQ;EAC5B,SAAS;GAAE,IAAI,iBAAiB;GAAM,SAAS;EAAK,CAAC;CACvD;CAEA,OACE,qBAAC,eAAD;EAAe,gBAAA;EAAf,UAAA;GACE,qBAAC,MAAD;IACE,WAAU;IACV,KAAK;IACL,OAAO;KAAE,QAAQ;KAAY,UAAU;IAAO;IAC9C,gBAAA;IACA,IAAI,EAAE,YAAY,IAAI;IALxB,UAAA,CAOG,UAAU,KAAK,aAAa;KAC3B,MAAM,WAAW,CAAC,gBAAgB,SAAS,OAAO;KAClD,MAAM,UACJ,SAAS,WAAW,sBAAsB,SAAS;KACrD,OACE,qBAACA,YAAD;MAAiC,IAAI,EAAE,UAAU,WAAW;MAA5D,UAAA,CACE,qBAACC,kBAAD;OACE,eAAe,uBAAuB,QAAQ;OACpC;OAFZ,UAAA,CAIE,oBAAC,gBAAD,EAAA,UACE,oBAAC,eAAD,EAAwB,QAAU,CAAA,EACpB,CAAA,GAChB,oBAAC,cAAD;QACE,SAAS,SAAS;QAClB,WAAW,eAAe,SAAS,OAAO;OAC3C,CAAA,CACa;MAChB,CAAA,GAAA,oBAAC,aAAD;OACY;OACV,OAAO;QACL;SACE,MAAM,oBAAC,oBAAD,CAAqB,CAAA;SAC3B,OAAO,EAAE,oBAAoB;SAC7B,eACE,UAAU,UAAU,UAAU,SAAS,OAAO;QAClD;QACA;SACE,MAAM,oBAAC,kBAAD,CAAmB,CAAA;SACzB,OAAO,EAAE,uBAAuB;SAChC,eACE,aAAa,eAAe,SAAS,SAAS,OAAO,CAAC;QAC1D;QACA;SACE,MAAM,oBAAC,eAAD,CAAgB,CAAA;SACtB,OAAO,EAAE,eAAe;SACxB,eAAe,eAAe,SAAS,OAAO;QAChD;OACF;MACD,CAAA,CACO;KAnCK,GAAA,SAAS,OAmCd;IAEd,CAAC,GACA,CAAC,UAAU,UACV,oBAAC,oBAAD;KACE,MAAM,oBAAC,UAAD,CAAW,CAAA;KACjB,OAAO,EAAE,kCAAkC;KAC3C,SAAS,EAAE,yCAAyC;IACrD,CAAA,CAEC;;GACN,oBAAC,yBAAD;IAAyB,KAAK;IAC5B,UAAA,oBAAC,QAAD;KAAQ,SAAQ;KAAY,SAAS;KAClC,UAAA,EAAE,0BAA0B;IACvB,CAAA;GACe,CAAA;GACzB,oBAAC,sBAAD;IACE,KAAK;IACL,eAAe;GAChB,CAAA;EACY;;AAEnB"}
|
|
@@ -27,7 +27,7 @@ const ConnectedWalletsPage = () => {
|
|
|
27
27
|
const { t } = useTranslation();
|
|
28
28
|
const { accounts } = useAccount();
|
|
29
29
|
const { setSelectedBookmark } = useBookmarkActions();
|
|
30
|
-
const {
|
|
30
|
+
const { isValidReceiver } = useToAddressRequirements();
|
|
31
31
|
const navigate = useNavigate();
|
|
32
32
|
const { setFieldValue } = useFieldActions();
|
|
33
33
|
const { getAddressLink } = useExplorer();
|
|
@@ -76,11 +76,12 @@ const ConnectedWalletsPage = () => {
|
|
|
76
76
|
if (account.address) openInNewTab(getAddressLink(account.address, account.chainId));
|
|
77
77
|
}
|
|
78
78
|
}] : []];
|
|
79
|
+
const disabled = !isValidReceiver(account.address);
|
|
79
80
|
return /* @__PURE__ */ jsxs(ListItem$1, {
|
|
80
81
|
sx: { position: "relative" },
|
|
81
82
|
children: [/* @__PURE__ */ jsxs(ListItemButton$1, {
|
|
82
83
|
onClick: () => handleWalletSelected(account),
|
|
83
|
-
disabled
|
|
84
|
+
disabled,
|
|
84
85
|
children: [/* @__PURE__ */ jsx(ListItemAvatar, { children: /* @__PURE__ */ jsx(AccountAvatar, {
|
|
85
86
|
chainId: account.chainId,
|
|
86
87
|
account
|
|
@@ -90,7 +91,7 @@ const ConnectedWalletsPage = () => {
|
|
|
90
91
|
})]
|
|
91
92
|
}), /* @__PURE__ */ jsx(ContextMenu, {
|
|
92
93
|
items: menuItems,
|
|
93
|
-
disabled
|
|
94
|
+
disabled
|
|
94
95
|
})]
|
|
95
96
|
}, account.address);
|
|
96
97
|
}), !accounts.length && /* @__PURE__ */ jsx(EmptyListIndicator, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectedWalletsPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/ConnectedWalletsPage.tsx"],"sourcesContent":["import { useAccount } from '@lifi/wallet-management'\nimport type { Account } from '@lifi/widget-provider'\nimport ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport Wallet from '@mui/icons-material/Wallet'\nimport { List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { useNavigate } from '@tanstack/react-router'\nimport { type JSX, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\n\nexport const ConnectedWalletsPage = (): JSX.Element => {\n const { t } = useTranslation()\n const { accounts } = useAccount()\n const { setSelectedBookmark } = useBookmarkActions()\n const {
|
|
1
|
+
{"version":3,"file":"ConnectedWalletsPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/ConnectedWalletsPage.tsx"],"sourcesContent":["import { useAccount } from '@lifi/wallet-management'\nimport type { Account } from '@lifi/widget-provider'\nimport ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport Wallet from '@mui/icons-material/Wallet'\nimport { List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { useNavigate } from '@tanstack/react-router'\nimport { type JSX, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\n\nexport const ConnectedWalletsPage = (): JSX.Element => {\n const { t } = useTranslation()\n const { accounts } = useAccount()\n const { setSelectedBookmark } = useBookmarkActions()\n const { isValidReceiver } = useToAddressRequirements()\n const navigate = useNavigate()\n const { setFieldValue } = useFieldActions()\n const { getAddressLink } = useExplorer()\n const listParentRef = useRef<HTMLUListElement | null>(null)\n\n useHeader(t('sendToWallet.connectedWallets'))\n\n const { listHeight } = useListHeight({ listParentRef })\n\n const handleWalletSelected = (account: Account) => {\n setFieldValue('toAddress', account.address!, {\n isTouched: true,\n isDirty: true,\n })\n setSelectedBookmark({\n name: account.connector?.name,\n address: account.address!,\n chainType: account.chainType!,\n isConnectedAccount: true,\n })\n navigate({\n to: navigationRoutes.home,\n replace: true,\n })\n }\n\n return (\n <PageContainer disableGutters>\n <List\n className=\"long-list\"\n ref={listParentRef}\n style={{ height: listHeight, overflow: 'auto' }}\n disablePadding\n sx={{ paddingTop: 1.5 }}\n >\n {accounts.map((account) => {\n const walletAddress = shortenAddress(account.address)\n const menuItems = [\n {\n icon: <ContentCopyRounded />,\n label: t('button.copyAddress'),\n onClick: () => {\n if (account.address) {\n navigator.clipboard.writeText(account.address)\n }\n },\n },\n ...(account.chainId\n ? [\n {\n icon: <OpenInNewRounded />,\n label: t('button.viewOnExplorer'),\n onClick: () => {\n if (account.address) {\n openInNewTab(\n getAddressLink(account.address, account.chainId)\n )\n }\n },\n },\n ]\n : []),\n ]\n const disabled = !isValidReceiver(account.address)\n\n return (\n <ListItem key={account.address} sx={{ position: 'relative' }}>\n <ListItemButton\n onClick={() => handleWalletSelected(account)}\n disabled={disabled}\n >\n <ListItemAvatar>\n <AccountAvatar chainId={account.chainId} account={account} />\n </ListItemAvatar>\n <ListItemText\n primary={account.connector?.name}\n secondary={walletAddress}\n />\n </ListItemButton>\n <ContextMenu items={menuItems} disabled={disabled} />\n </ListItem>\n )\n })}\n {!accounts.length && (\n <EmptyListIndicator\n icon={<Wallet />}\n title={t('sendToWallet.noConnectedWallets')}\n message={t('sendToWallet.noConnectedWalletsMessage')}\n />\n )}\n </List>\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,6BAA0C;CACrD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,aAAa,WAAW;CAChC,MAAM,EAAE,wBAAwB,mBAAmB;CACnD,MAAM,EAAE,oBAAoB,yBAAyB;CACrD,MAAM,WAAW,YAAY;CAC7B,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,EAAE,mBAAmB,YAAY;CACvC,MAAM,gBAAgB,OAAgC,IAAI;CAE1D,UAAU,EAAE,+BAA+B,CAAC;CAE5C,MAAM,EAAE,eAAe,cAAc,EAAE,cAAc,CAAC;CAEtD,MAAM,wBAAwB,YAAqB;EACjD,cAAc,aAAa,QAAQ,SAAU;GAC3C,WAAW;GACX,SAAS;EACX,CAAC;EACD,oBAAoB;GAClB,MAAM,QAAQ,WAAW;GACzB,SAAS,QAAQ;GACjB,WAAW,QAAQ;GACnB,oBAAoB;EACtB,CAAC;EACD,SAAS;GACP,IAAI,iBAAiB;GACrB,SAAS;EACX,CAAC;CACH;CAEA,OACE,oBAAC,eAAD;EAAe,gBAAA;EACb,UAAA,qBAAC,MAAD;GACE,WAAU;GACV,KAAK;GACL,OAAO;IAAE,QAAQ;IAAY,UAAU;GAAO;GAC9C,gBAAA;GACA,IAAI,EAAE,YAAY,IAAI;GALxB,UAAA,CAOG,SAAS,KAAK,YAAY;IACzB,MAAM,gBAAgB,eAAe,QAAQ,OAAO;IACpD,MAAM,YAAY,CAChB;KACE,MAAM,oBAAC,oBAAD,CAAqB,CAAA;KAC3B,OAAO,EAAE,oBAAoB;KAC7B,eAAe;MACb,IAAI,QAAQ,SACV,UAAU,UAAU,UAAU,QAAQ,OAAO;KAEjD;IACF,GACA,GAAI,QAAQ,UACR,CACE;KACE,MAAM,oBAAC,kBAAD,CAAmB,CAAA;KACzB,OAAO,EAAE,uBAAuB;KAChC,eAAe;MACb,IAAI,QAAQ,SACV,aACE,eAAe,QAAQ,SAAS,QAAQ,OAAO,CACjD;KAEJ;IACF,CACF,IACA,CAAC,CACP;IACA,MAAM,WAAW,CAAC,gBAAgB,QAAQ,OAAO;IAEjD,OACE,qBAACA,YAAD;KAAgC,IAAI,EAAE,UAAU,WAAW;KAA3D,UAAA,CACE,qBAACC,kBAAD;MACE,eAAe,qBAAqB,OAAO;MACjC;MAFZ,UAAA,CAIE,oBAAC,gBAAD,EAAA,UACE,oBAAC,eAAD;OAAe,SAAS,QAAQ;OAAkB;MAAU,CAAA,EAC9C,CAAA,GAChB,oBAAC,cAAD;OACE,SAAS,QAAQ,WAAW;OAC5B,WAAW;MACZ,CAAA,CACa;KAChB,CAAA,GAAA,oBAAC,aAAD;MAAa,OAAO;MAAqB;KAAW,CAAA,CAC5C;IAdK,GAAA,QAAQ,OAcb;GAEd,CAAC,GACA,CAAC,SAAS,UACT,oBAAC,oBAAD;IACE,MAAM,oBAAC,QAAD,CAAS,CAAA;IACf,OAAO,EAAE,iCAAiC;IAC1C,SAAS,EAAE,wCAAwC;GACpD,CAAA,CAEC;;CACO,CAAA;AAEnB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { defaultChainIdsByType } from "../../utils/chainType.js";
|
|
1
2
|
import { navigationRoutes } from "../../utils/navigationRoutes.js";
|
|
2
3
|
import { useBookmarkActions } from "../../stores/bookmarks/useBookmarkActions.js";
|
|
3
4
|
import { useBookmarks } from "../../stores/bookmarks/useBookmarks.js";
|
|
4
5
|
import { useFieldActions } from "../../stores/form/useFieldActions.js";
|
|
5
6
|
import { PageContainer } from "../../components/PageContainer.js";
|
|
6
|
-
import { defaultChainIdsByType } from "../../utils/chainType.js";
|
|
7
7
|
import { useToAddressRequirements } from "../../hooks/useToAddressRequirements.js";
|
|
8
8
|
import { shortenAddress } from "../../utils/wallet.js";
|
|
9
9
|
import { openInNewTab } from "../../utils/url.js";
|
|
@@ -34,7 +34,7 @@ const RecentWalletsPage = () => {
|
|
|
34
34
|
const bookmarkAddressSheetRef = useRef(null);
|
|
35
35
|
const listParentRef = useRef(null);
|
|
36
36
|
const { recentWallets } = useBookmarks();
|
|
37
|
-
const {
|
|
37
|
+
const { isValidReceiver } = useToAddressRequirements();
|
|
38
38
|
const { removeRecentWallet, addBookmark, setSelectedBookmark, addRecentWallet } = useBookmarkActions();
|
|
39
39
|
const { setFieldValue } = useFieldActions();
|
|
40
40
|
const { getAddressLink } = useExplorer();
|
|
@@ -70,44 +70,48 @@ const RecentWalletsPage = () => {
|
|
|
70
70
|
},
|
|
71
71
|
disablePadding: true,
|
|
72
72
|
sx: { paddingTop: 1.5 },
|
|
73
|
-
children: [recentWallets.map((recentWallet) =>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
children: [/* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
children: [recentWallets.map((recentWallet) => {
|
|
74
|
+
const disabled = !isValidReceiver(recentWallet.address);
|
|
75
|
+
const chainId = recentWallet.chainId ?? defaultChainIdsByType[recentWallet.chainType];
|
|
76
|
+
return /* @__PURE__ */ jsxs(ListItem$1, {
|
|
77
|
+
sx: { position: "relative" },
|
|
78
|
+
children: [/* @__PURE__ */ jsxs(ListItemButton$1, {
|
|
79
|
+
disabled,
|
|
80
|
+
onClick: () => handleRecentSelected(recentWallet),
|
|
81
|
+
children: [/* @__PURE__ */ jsx(ListItemAvatar, { children: /* @__PURE__ */ jsx(AccountAvatar, { chainId }) }), /* @__PURE__ */ jsx(ListItemText, {
|
|
82
|
+
primary: recentWallet.name || shortenAddress(recentWallet.address),
|
|
83
|
+
secondary: recentWallet.name ? shortenAddress(recentWallet.address) : void 0
|
|
84
|
+
})]
|
|
85
|
+
}), /* @__PURE__ */ jsx(ContextMenu, {
|
|
86
|
+
disabled,
|
|
87
|
+
items: [
|
|
88
|
+
{
|
|
89
|
+
icon: /* @__PURE__ */ jsx(ContentCopyRounded, {}),
|
|
90
|
+
label: t("button.copyAddress"),
|
|
91
|
+
onClick: () => navigator.clipboard.writeText(recentWallet.address)
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
icon: /* @__PURE__ */ jsx(OpenInNewRounded, {}),
|
|
95
|
+
label: t("button.viewOnExplorer"),
|
|
96
|
+
onClick: () => openInNewTab(getAddressLink(recentWallet.address, chainId))
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
icon: /* @__PURE__ */ jsx(TurnedInNot, {}),
|
|
100
|
+
label: t("button.bookmark"),
|
|
101
|
+
onClick: () => {
|
|
102
|
+
setBookmarkTarget(recentWallet);
|
|
103
|
+
bookmarkAddressSheetRef.current?.open();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
icon: /* @__PURE__ */ jsx(DeleteOutline, {}),
|
|
108
|
+
label: t("button.delete"),
|
|
109
|
+
onClick: () => removeRecentWallet(recentWallet.address)
|
|
101
110
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onClick: () => removeRecentWallet(recentWallet.address)
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
})]
|
|
110
|
-
}, recentWallet.address)), !recentWallets.length && /* @__PURE__ */ jsx(EmptyListIndicator, {
|
|
111
|
+
]
|
|
112
|
+
})]
|
|
113
|
+
}, recentWallet.address);
|
|
114
|
+
}), !recentWallets.length && /* @__PURE__ */ jsx(EmptyListIndicator, {
|
|
111
115
|
icon: /* @__PURE__ */ jsx(AccountBalanceWalletIcon, {}),
|
|
112
116
|
title: t("sendToWallet.noRecentWallets"),
|
|
113
117
|
message: t("sendToWallet.noRecentWalletsMessage")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecentWalletsPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/RecentWalletsPage.tsx"],"sourcesContent":["import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet'\nimport ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport DeleteOutline from '@mui/icons-material/DeleteOutlined'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport TurnedInNot from '@mui/icons-material/TurnedInNot'\nimport { List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { useNavigate } from '@tanstack/react-router'\nimport { type JSX, useRef, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport type { BottomSheetBase } from '../../components/BottomSheet/types.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport type { Bookmark } from '../../stores/bookmarks/types.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useBookmarks } from '../../stores/bookmarks/useBookmarks.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { defaultChainIdsByType } from '../../utils/chainType.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\nimport { BookmarkAddressSheet } from './BookmarkAddressSheet.js'\n\nexport const RecentWalletsPage = (): JSX.Element => {\n const { t } = useTranslation()\n const navigate = useNavigate()\n const [bookmarkTarget, setBookmarkTarget] = useState<Bookmark>()\n const bookmarkAddressSheetRef = useRef<BottomSheetBase>(null)\n const listParentRef = useRef<HTMLUListElement | null>(null)\n const { recentWallets } = useBookmarks()\n const {
|
|
1
|
+
{"version":3,"file":"RecentWalletsPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/RecentWalletsPage.tsx"],"sourcesContent":["import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet'\nimport ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport DeleteOutline from '@mui/icons-material/DeleteOutlined'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport TurnedInNot from '@mui/icons-material/TurnedInNot'\nimport { List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { useNavigate } from '@tanstack/react-router'\nimport { type JSX, useRef, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport type { BottomSheetBase } from '../../components/BottomSheet/types.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport type { Bookmark } from '../../stores/bookmarks/types.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useBookmarks } from '../../stores/bookmarks/useBookmarks.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { defaultChainIdsByType } from '../../utils/chainType.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\nimport { BookmarkAddressSheet } from './BookmarkAddressSheet.js'\n\nexport const RecentWalletsPage = (): JSX.Element => {\n const { t } = useTranslation()\n const navigate = useNavigate()\n const [bookmarkTarget, setBookmarkTarget] = useState<Bookmark>()\n const bookmarkAddressSheetRef = useRef<BottomSheetBase>(null)\n const listParentRef = useRef<HTMLUListElement | null>(null)\n const { recentWallets } = useBookmarks()\n const { isValidReceiver } = useToAddressRequirements()\n const {\n removeRecentWallet,\n addBookmark,\n setSelectedBookmark,\n addRecentWallet,\n } = useBookmarkActions()\n const { setFieldValue } = useFieldActions()\n const { getAddressLink } = useExplorer()\n\n useHeader(t('header.recentWallets'))\n\n const { listHeight } = useListHeight({ listParentRef })\n\n const handleRecentSelected = (recentWallet: Bookmark) => {\n addRecentWallet(recentWallet)\n setFieldValue('toAddress', recentWallet.address, {\n isTouched: true,\n isDirty: true,\n })\n setSelectedBookmark(recentWallet)\n navigate({\n to: navigationRoutes.home,\n replace: true,\n })\n }\n\n const handleAddBookmark = (bookmark: Bookmark) => {\n addBookmark(bookmark)\n navigate({ to: navigationRoutes.bookmarks, replace: true })\n }\n\n return (\n <PageContainer disableGutters>\n <List\n className=\"long-list\"\n ref={listParentRef}\n style={{ height: listHeight, overflow: 'auto' }}\n disablePadding\n sx={{ paddingTop: 1.5 }}\n >\n {recentWallets.map((recentWallet) => {\n const disabled = !isValidReceiver(recentWallet.address)\n const chainId =\n recentWallet.chainId ??\n defaultChainIdsByType[recentWallet.chainType]\n return (\n <ListItem key={recentWallet.address} sx={{ position: 'relative' }}>\n <ListItemButton\n disabled={disabled}\n onClick={() => handleRecentSelected(recentWallet)}\n >\n <ListItemAvatar>\n <AccountAvatar chainId={chainId} />\n </ListItemAvatar>\n <ListItemText\n primary={\n recentWallet.name || shortenAddress(recentWallet.address)\n }\n secondary={\n recentWallet.name\n ? shortenAddress(recentWallet.address)\n : undefined\n }\n />\n </ListItemButton>\n <ContextMenu\n disabled={disabled}\n items={[\n {\n icon: <ContentCopyRounded />,\n label: t('button.copyAddress'),\n onClick: () =>\n navigator.clipboard.writeText(recentWallet.address),\n },\n {\n icon: <OpenInNewRounded />,\n label: t('button.viewOnExplorer'),\n onClick: () =>\n openInNewTab(\n getAddressLink(recentWallet.address, chainId)\n ),\n },\n {\n icon: <TurnedInNot />,\n label: t('button.bookmark'),\n onClick: () => {\n setBookmarkTarget(recentWallet)\n bookmarkAddressSheetRef.current?.open()\n },\n },\n {\n icon: <DeleteOutline />,\n label: t('button.delete'),\n onClick: () => removeRecentWallet(recentWallet.address),\n },\n ]}\n />\n </ListItem>\n )\n })}\n {!recentWallets.length && (\n <EmptyListIndicator\n icon={<AccountBalanceWalletIcon />}\n title={t('sendToWallet.noRecentWallets')}\n message={t('sendToWallet.noRecentWalletsMessage')}\n />\n )}\n </List>\n <BookmarkAddressSheet\n ref={bookmarkAddressSheetRef}\n validatedWallet={bookmarkTarget}\n onAddBookmark={handleAddBookmark}\n />\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,0BAAuC;CAClD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,CAAC,gBAAgB,qBAAqB,SAAmB;CAC/D,MAAM,0BAA0B,OAAwB,IAAI;CAC5D,MAAM,gBAAgB,OAAgC,IAAI;CAC1D,MAAM,EAAE,kBAAkB,aAAa;CACvC,MAAM,EAAE,oBAAoB,yBAAyB;CACrD,MAAM,EACJ,oBACA,aACA,qBACA,oBACE,mBAAmB;CACvB,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,EAAE,mBAAmB,YAAY;CAEvC,UAAU,EAAE,sBAAsB,CAAC;CAEnC,MAAM,EAAE,eAAe,cAAc,EAAE,cAAc,CAAC;CAEtD,MAAM,wBAAwB,iBAA2B;EACvD,gBAAgB,YAAY;EAC5B,cAAc,aAAa,aAAa,SAAS;GAC/C,WAAW;GACX,SAAS;EACX,CAAC;EACD,oBAAoB,YAAY;EAChC,SAAS;GACP,IAAI,iBAAiB;GACrB,SAAS;EACX,CAAC;CACH;CAEA,MAAM,qBAAqB,aAAuB;EAChD,YAAY,QAAQ;EACpB,SAAS;GAAE,IAAI,iBAAiB;GAAW,SAAS;EAAK,CAAC;CAC5D;CAEA,OACE,qBAAC,eAAD;EAAe,gBAAA;EAAf,UAAA,CACE,qBAAC,MAAD;GACE,WAAU;GACV,KAAK;GACL,OAAO;IAAE,QAAQ;IAAY,UAAU;GAAO;GAC9C,gBAAA;GACA,IAAI,EAAE,YAAY,IAAI;GALxB,UAAA,CAOG,cAAc,KAAK,iBAAiB;IACnC,MAAM,WAAW,CAAC,gBAAgB,aAAa,OAAO;IACtD,MAAM,UACJ,aAAa,WACb,sBAAsB,aAAa;IACrC,OACE,qBAACA,YAAD;KAAqC,IAAI,EAAE,UAAU,WAAW;KAAhE,UAAA,CACE,qBAACC,kBAAD;MACY;MACV,eAAe,qBAAqB,YAAY;MAFlD,UAAA,CAIE,oBAAC,gBAAD,EAAA,UACE,oBAAC,eAAD,EAAwB,QAAU,CAAA,EACpB,CAAA,GAChB,oBAAC,cAAD;OACE,SACE,aAAa,QAAQ,eAAe,aAAa,OAAO;OAE1D,WACE,aAAa,OACT,eAAe,aAAa,OAAO,IACnC,KAAA;MAEP,CAAA,CACa;KAChB,CAAA,GAAA,oBAAC,aAAD;MACY;MACV,OAAO;OACL;QACE,MAAM,oBAAC,oBAAD,CAAqB,CAAA;QAC3B,OAAO,EAAE,oBAAoB;QAC7B,eACE,UAAU,UAAU,UAAU,aAAa,OAAO;OACtD;OACA;QACE,MAAM,oBAAC,kBAAD,CAAmB,CAAA;QACzB,OAAO,EAAE,uBAAuB;QAChC,eACE,aACE,eAAe,aAAa,SAAS,OAAO,CAC9C;OACJ;OACA;QACE,MAAM,oBAAC,aAAD,CAAc,CAAA;QACpB,OAAO,EAAE,iBAAiB;QAC1B,eAAe;SACb,kBAAkB,YAAY;SAC9B,wBAAwB,SAAS,KAAK;QACxC;OACF;OACA;QACE,MAAM,oBAAC,eAAD,CAAgB,CAAA;QACtB,OAAO,EAAE,eAAe;QACxB,eAAe,mBAAmB,aAAa,OAAO;OACxD;MACF;KACD,CAAA,CACO;IAnDK,GAAA,aAAa,OAmDlB;GAEd,CAAC,GACA,CAAC,cAAc,UACd,oBAAC,oBAAD;IACE,MAAM,oBAAC,0BAAD,CAA2B,CAAA;IACjC,OAAO,EAAE,8BAA8B;IACvC,SAAS,EAAE,qCAAqC;GACjD,CAAA,CAEC;EACN,CAAA,GAAA,oBAAC,sBAAD;GACE,KAAK;GACL,iBAAiB;GACjB,eAAe;EAChB,CAAA,CACY;;AAEnB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { defaultChainIdsByType } from "../../utils/chainType.js";
|
|
1
2
|
import { useWidgetConfig } from "../../providers/WidgetProvider/WidgetProvider.js";
|
|
2
3
|
import { useBookmarkActions } from "../../stores/bookmarks/useBookmarkActions.js";
|
|
3
4
|
import { useFieldActions } from "../../stores/form/useFieldActions.js";
|
|
4
5
|
import { PageContainer } from "../../components/PageContainer.js";
|
|
5
|
-
import { defaultChainIdsByType } from "../../utils/chainType.js";
|
|
6
6
|
import { useToAddressRequirements } from "../../hooks/useToAddressRequirements.js";
|
|
7
7
|
import { useNavigateBack } from "../../hooks/useNavigateBack.js";
|
|
8
8
|
import { shortenAddress } from "../../utils/wallet.js";
|
|
@@ -18,6 +18,7 @@ import { useRef } from "react";
|
|
|
18
18
|
import { List, ListItemAvatar, ListItemText } from "@mui/material";
|
|
19
19
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
20
|
import { useTranslation } from "react-i18next";
|
|
21
|
+
import { useChainTypeFromAddress } from "@lifi/widget-provider";
|
|
21
22
|
import ContentCopyRounded from "@mui/icons-material/ContentCopyRounded";
|
|
22
23
|
import OpenInNewRounded from "@mui/icons-material/OpenInNewRounded";
|
|
23
24
|
//#region src/pages/SendToWallet/SendToConfiguredWalletPage.tsx
|
|
@@ -25,7 +26,8 @@ const SendToConfiguredWalletPage = () => {
|
|
|
25
26
|
const { t } = useTranslation();
|
|
26
27
|
const navigateBack = useNavigateBack();
|
|
27
28
|
const { toAddresses } = useWidgetConfig();
|
|
28
|
-
const {
|
|
29
|
+
const { isValidReceiver } = useToAddressRequirements();
|
|
30
|
+
const { getChainFromAddress } = useChainTypeFromAddress();
|
|
29
31
|
const { setSelectedBookmark } = useBookmarkActions();
|
|
30
32
|
const { setFieldValue } = useFieldActions();
|
|
31
33
|
const { getAddressLink } = useExplorer();
|
|
@@ -51,31 +53,35 @@ const SendToConfiguredWalletPage = () => {
|
|
|
51
53
|
},
|
|
52
54
|
disablePadding: true,
|
|
53
55
|
sx: { paddingTop: 1.5 },
|
|
54
|
-
children: toAddresses?.map((toAddress) =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
children: [/* @__PURE__ */
|
|
60
|
-
|
|
61
|
-
toAddress
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
children: toAddresses?.map((toAddress) => {
|
|
57
|
+
const disabled = !isValidReceiver(toAddress.address);
|
|
58
|
+
const chainId = getChainFromAddress(toAddress.address)?.chainId ?? defaultChainIdsByType[toAddress.chainType];
|
|
59
|
+
return /* @__PURE__ */ jsxs(ListItem$1, {
|
|
60
|
+
sx: { position: "relative" },
|
|
61
|
+
children: [/* @__PURE__ */ jsxs(ListItemButton$1, {
|
|
62
|
+
disabled,
|
|
63
|
+
onClick: () => handleCuratedSelected(toAddress),
|
|
64
|
+
children: [/* @__PURE__ */ jsx(ListItemAvatar, { children: /* @__PURE__ */ jsx(AccountAvatar, {
|
|
65
|
+
chainId,
|
|
66
|
+
toAddress
|
|
67
|
+
}) }), /* @__PURE__ */ jsx(ListItemText, {
|
|
68
|
+
primary: toAddress.name || shortenAddress(toAddress.address),
|
|
69
|
+
secondary: toAddress.name ? shortenAddress(toAddress.address) : void 0
|
|
70
|
+
})]
|
|
71
|
+
}), /* @__PURE__ */ jsx(ContextMenu, {
|
|
72
|
+
disabled,
|
|
73
|
+
items: [{
|
|
74
|
+
icon: /* @__PURE__ */ jsx(ContentCopyRounded, {}),
|
|
75
|
+
label: t("button.copyAddress"),
|
|
76
|
+
onClick: () => navigator.clipboard.writeText(toAddress.address)
|
|
77
|
+
}, {
|
|
78
|
+
icon: /* @__PURE__ */ jsx(OpenInNewRounded, {}),
|
|
79
|
+
label: t("button.viewOnExplorer"),
|
|
80
|
+
onClick: () => openInNewTab(getAddressLink(toAddress.address, chainId))
|
|
81
|
+
}]
|
|
65
82
|
})]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
items: [{
|
|
69
|
-
icon: /* @__PURE__ */ jsx(ContentCopyRounded, {}),
|
|
70
|
-
label: t("button.copyAddress"),
|
|
71
|
-
onClick: () => navigator.clipboard.writeText(toAddress.address)
|
|
72
|
-
}, {
|
|
73
|
-
icon: /* @__PURE__ */ jsx(OpenInNewRounded, {}),
|
|
74
|
-
label: t("button.viewOnExplorer"),
|
|
75
|
-
onClick: () => openInNewTab(getAddressLink(toAddress.address, defaultChainIdsByType[toAddress.chainType]))
|
|
76
|
-
}]
|
|
77
|
-
})]
|
|
78
|
-
}, toAddress.address))
|
|
83
|
+
}, toAddress.address);
|
|
84
|
+
})
|
|
79
85
|
})
|
|
80
86
|
});
|
|
81
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SendToConfiguredWalletPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/SendToConfiguredWalletPage.tsx"],"sourcesContent":["import ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport { List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { type JSX, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useNavigateBack } from '../../hooks/useNavigateBack.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport type { ToAddress } from '../../types/widget.js'\nimport { defaultChainIdsByType } from '../../utils/chainType.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\n\nexport const SendToConfiguredWalletPage = (): JSX.Element => {\n const { t } = useTranslation()\n const navigateBack = useNavigateBack()\n const { toAddresses } = useWidgetConfig()\n const {
|
|
1
|
+
{"version":3,"file":"SendToConfiguredWalletPage.js","names":["ListItem","ListItemButton"],"sources":["../../../../src/pages/SendToWallet/SendToConfiguredWalletPage.tsx"],"sourcesContent":["import { useChainTypeFromAddress } from '@lifi/widget-provider'\nimport ContentCopyRounded from '@mui/icons-material/ContentCopyRounded'\nimport OpenInNewRounded from '@mui/icons-material/OpenInNewRounded'\nimport { List, ListItemAvatar, ListItemText } from '@mui/material'\nimport { type JSX, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { AccountAvatar } from '../../components/Avatar/AccountAvatar.js'\nimport { ContextMenu } from '../../components/ContextMenu.js'\nimport { ListItem } from '../../components/ListItem/ListItem.js'\nimport { ListItemButton } from '../../components/ListItem/ListItemButton.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { useExplorer } from '../../hooks/useExplorer.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useListHeight } from '../../hooks/useListHeight.js'\nimport { useNavigateBack } from '../../hooks/useNavigateBack.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport type { ToAddress } from '../../types/widget.js'\nimport { defaultChainIdsByType } from '../../utils/chainType.js'\nimport { openInNewTab } from '../../utils/url.js'\nimport { shortenAddress } from '../../utils/wallet.js'\n\nexport const SendToConfiguredWalletPage = (): JSX.Element => {\n const { t } = useTranslation()\n const navigateBack = useNavigateBack()\n const { toAddresses } = useWidgetConfig()\n const { isValidReceiver } = useToAddressRequirements()\n const { getChainFromAddress } = useChainTypeFromAddress()\n const { setSelectedBookmark } = useBookmarkActions()\n const { setFieldValue } = useFieldActions()\n const { getAddressLink } = useExplorer()\n const listParentRef = useRef<HTMLUListElement | null>(null)\n\n useHeader(t('header.sendToWallet'))\n\n const { listHeight } = useListHeight({ listParentRef })\n\n const handleCuratedSelected = (toAddress: ToAddress) => {\n setSelectedBookmark(toAddress)\n setFieldValue('toAddress', toAddress.address, {\n isTouched: true,\n isDirty: true,\n })\n navigateBack()\n }\n\n return (\n <PageContainer disableGutters>\n <List\n className=\"long-list\"\n ref={listParentRef}\n style={{ height: listHeight, overflow: 'auto' }}\n disablePadding\n sx={{ paddingTop: 1.5 }}\n >\n {toAddresses?.map((toAddress) => {\n const disabled = !isValidReceiver(toAddress.address)\n // A configured receiver has no chainId; its provider knows the chain.\n const chainId =\n getChainFromAddress(toAddress.address)?.chainId ??\n defaultChainIdsByType[toAddress.chainType]\n return (\n <ListItem key={toAddress.address} sx={{ position: 'relative' }}>\n <ListItemButton\n disabled={disabled}\n onClick={() => handleCuratedSelected(toAddress)}\n >\n <ListItemAvatar>\n <AccountAvatar chainId={chainId} toAddress={toAddress} />\n </ListItemAvatar>\n <ListItemText\n primary={toAddress.name || shortenAddress(toAddress.address)}\n secondary={\n toAddress.name\n ? shortenAddress(toAddress.address)\n : undefined\n }\n />\n </ListItemButton>\n <ContextMenu\n disabled={disabled}\n items={[\n {\n icon: <ContentCopyRounded />,\n label: t('button.copyAddress'),\n onClick: () =>\n navigator.clipboard.writeText(toAddress.address),\n },\n {\n icon: <OpenInNewRounded />,\n label: t('button.viewOnExplorer'),\n onClick: () =>\n openInNewTab(getAddressLink(toAddress.address, chainId)),\n },\n ]}\n />\n </ListItem>\n )\n })}\n </List>\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,mCAAgD;CAC3D,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,eAAe,gBAAgB;CACrC,MAAM,EAAE,gBAAgB,gBAAgB;CACxC,MAAM,EAAE,oBAAoB,yBAAyB;CACrD,MAAM,EAAE,wBAAwB,wBAAwB;CACxD,MAAM,EAAE,wBAAwB,mBAAmB;CACnD,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,EAAE,mBAAmB,YAAY;CACvC,MAAM,gBAAgB,OAAgC,IAAI;CAE1D,UAAU,EAAE,qBAAqB,CAAC;CAElC,MAAM,EAAE,eAAe,cAAc,EAAE,cAAc,CAAC;CAEtD,MAAM,yBAAyB,cAAyB;EACtD,oBAAoB,SAAS;EAC7B,cAAc,aAAa,UAAU,SAAS;GAC5C,WAAW;GACX,SAAS;EACX,CAAC;EACD,aAAa;CACf;CAEA,OACE,oBAAC,eAAD;EAAe,gBAAA;EACb,UAAA,oBAAC,MAAD;GACE,WAAU;GACV,KAAK;GACL,OAAO;IAAE,QAAQ;IAAY,UAAU;GAAO;GAC9C,gBAAA;GACA,IAAI,EAAE,YAAY,IAAI;GAErB,UAAA,aAAa,KAAK,cAAc;IAC/B,MAAM,WAAW,CAAC,gBAAgB,UAAU,OAAO;IAEnD,MAAM,UACJ,oBAAoB,UAAU,OAAO,CAAC,EAAE,WACxC,sBAAsB,UAAU;IAClC,OACE,qBAACA,YAAD;KAAkC,IAAI,EAAE,UAAU,WAAW;KAA7D,UAAA,CACE,qBAACC,kBAAD;MACY;MACV,eAAe,sBAAsB,SAAS;MAFhD,UAAA,CAIE,oBAAC,gBAAD,EAAA,UACE,oBAAC,eAAD;OAAwB;OAAoB;MAAY,CAAA,EAC1C,CAAA,GAChB,oBAAC,cAAD;OACE,SAAS,UAAU,QAAQ,eAAe,UAAU,OAAO;OAC3D,WACE,UAAU,OACN,eAAe,UAAU,OAAO,IAChC,KAAA;MAEP,CAAA,CACa;KAChB,CAAA,GAAA,oBAAC,aAAD;MACY;MACV,OAAO,CACL;OACE,MAAM,oBAAC,oBAAD,CAAqB,CAAA;OAC3B,OAAO,EAAE,oBAAoB;OAC7B,eACE,UAAU,UAAU,UAAU,UAAU,OAAO;MACnD,GACA;OACE,MAAM,oBAAC,kBAAD,CAAmB,CAAA;OACzB,OAAO,EAAE,uBAAuB;OAChC,eACE,aAAa,eAAe,UAAU,SAAS,OAAO,CAAC;MAC3D,CACF;KACD,CAAA,CACO;IAlCK,GAAA,UAAU,OAkCf;GAEd,CAAC;EACG,CAAA;CACO,CAAA;AAEnB"}
|
|
@@ -5,7 +5,6 @@ import { useBookmarks } from "../../stores/bookmarks/useBookmarks.js";
|
|
|
5
5
|
import { useFieldActions } from "../../stores/form/useFieldActions.js";
|
|
6
6
|
import { useFieldValues } from "../../stores/form/useFieldValues.js";
|
|
7
7
|
import { useChain } from "../../hooks/useChain.js";
|
|
8
|
-
import { useToAddressRequirements } from "../../hooks/useToAddressRequirements.js";
|
|
9
8
|
import { useAddressValidation } from "../../hooks/useAddressValidation.js";
|
|
10
9
|
import { useHeader } from "../../hooks/useHeader.js";
|
|
11
10
|
import { ButtonTertiary } from "../../components/ButtonTertiary.js";
|
|
@@ -37,7 +36,6 @@ const SendToWalletPage = () => {
|
|
|
37
36
|
const [validatedWallet, setValidatedWallet] = useState();
|
|
38
37
|
const [errorMessage, setErrorMessage] = useState("");
|
|
39
38
|
const { validateAddress, isValidating } = useAddressValidation();
|
|
40
|
-
const { requiredToChainType } = useToAddressRequirements();
|
|
41
39
|
const [toChainId] = useFieldValues("toChain");
|
|
42
40
|
const { chain: toChain } = useChain(toChainId);
|
|
43
41
|
const [isDoneButtonLoading, setIsDoneButtonLoading] = useState(false);
|
|
@@ -63,7 +61,6 @@ const SendToWalletPage = () => {
|
|
|
63
61
|
setIsDoneButtonLoading(true);
|
|
64
62
|
const validationResult = await validateAddress({
|
|
65
63
|
value: inputAddressValue,
|
|
66
|
-
chainType: requiredToChainType,
|
|
67
64
|
chain: toChain
|
|
68
65
|
});
|
|
69
66
|
setIsDoneButtonLoading(false);
|
|
@@ -71,14 +68,11 @@ const SendToWalletPage = () => {
|
|
|
71
68
|
setErrorMessage(validationResult.error);
|
|
72
69
|
return;
|
|
73
70
|
}
|
|
74
|
-
if (requiredToChainType && requiredToChainType !== validationResult.chainType) {
|
|
75
|
-
setErrorMessage(t("error.title.walletChainTypeInvalid", { chainName: toChain?.name }));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
71
|
setValidatedWallet({
|
|
79
72
|
name: validationResult.addressType === 1 ? inputAddressValue : void 0,
|
|
80
73
|
address: validationResult.address,
|
|
81
|
-
chainType: validationResult.chainType
|
|
74
|
+
chainType: validationResult.chainType,
|
|
75
|
+
chainId: validationResult.chainId
|
|
82
76
|
});
|
|
83
77
|
confirmAddressSheetRef.current?.open();
|
|
84
78
|
};
|
|
@@ -100,7 +94,8 @@ const SendToWalletPage = () => {
|
|
|
100
94
|
setValidatedWallet({
|
|
101
95
|
name: validationResult.addressType === 1 ? inputAddressValue : void 0,
|
|
102
96
|
address: validationResult.address,
|
|
103
|
-
chainType: validationResult.chainType
|
|
97
|
+
chainType: validationResult.chainType,
|
|
98
|
+
chainId: validationResult.chainId
|
|
104
99
|
});
|
|
105
100
|
bookmarkAddressSheetRef.current?.open();
|
|
106
101
|
} else setErrorMessage(validationResult.error);
|
|
@@ -148,7 +143,7 @@ const SendToWalletPage = () => {
|
|
|
148
143
|
placeholder,
|
|
149
144
|
"aria-label": placeholder,
|
|
150
145
|
maxRows: 2,
|
|
151
|
-
inputProps: { maxLength:
|
|
146
|
+
inputProps: { maxLength: 512 },
|
|
152
147
|
multiline: true
|
|
153
148
|
}),
|
|
154
149
|
errorMessage ? /* @__PURE__ */ jsx(ValidationAlert, {
|