From f046f6e1e9df2eaadf81f2b596f5469e4dbab6a2 Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Wed, 13 Jul 2022 16:07:48 +0300
Subject: [PATCH 01/29] removed v2 full screen modal
---
.../ModalFullscreen.stories.tsx | 38 -----------
.../modalFullscreen/ModalFullscreen.tsx | 68 -------------------
.../SearchableTokenList.tsx | 13 ++--
.../selectPoolModal/SelectPoolModal.tsx | 9 ++-
4 files changed, 10 insertions(+), 118 deletions(-)
delete mode 100644 src/components/modalFullscreen/ModalFullscreen.stories.tsx
delete mode 100644 src/components/modalFullscreen/ModalFullscreen.tsx
diff --git a/src/components/modalFullscreen/ModalFullscreen.stories.tsx b/src/components/modalFullscreen/ModalFullscreen.stories.tsx
deleted file mode 100644
index 04f5fefe3..000000000
--- a/src/components/modalFullscreen/ModalFullscreen.stories.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { ComponentStory, ComponentMeta } from '@storybook/react';
-import { ModalFullscreen } from './ModalFullscreen';
-import { useState } from 'react';
-import { withDesign } from 'storybook-addon-designs';
-import { Button } from 'components/button/Button';
-
-export default {
- title: 'Components/Modal/Fullscreen',
- component: ModalFullscreen,
- decorators: [withDesign],
-} as ComponentMeta;
-
-const Template: ComponentStory = (args) => {
- const [isOpen, setIsOpen] = useState(false);
-
- return (
- <>
-
-
- some content
-
- >
- );
-};
-
-export const Open = Template.bind({});
-Open.args = {
- isOpen: true,
- setIsOpen: () => {},
- title: 'Modal title',
-};
-
-Open.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/fwADI9wqDrRAdlMX8EddCw/Bancor-v3?node-id=7879%3A257081',
- },
-};
diff --git a/src/components/modalFullscreen/ModalFullscreen.tsx b/src/components/modalFullscreen/ModalFullscreen.tsx
deleted file mode 100644
index f264caae5..000000000
--- a/src/components/modalFullscreen/ModalFullscreen.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Dialog, Transition } from '@headlessui/react';
-import { Fragment } from 'react';
-import { ReactComponent as IconChevron } from 'assets/icons/chevronRight.svg';
-import { ReactComponent as IconBancor } from 'assets/icons/bancor.svg';
-import 'elements/layoutHeader/LayoutHeader.css';
-import { LayoutHeaderMobile } from 'elements/layoutHeader/LayoutHeaderMobile';
-import { Button } from 'components/button/Button';
-
-interface ModalFullscreenProps {
- title?: string | JSX.Element | JSX.Element[];
- children: JSX.Element | JSX.Element[];
- setIsOpen: Function;
- isOpen: boolean;
- showHeader?: boolean;
-}
-
-export const ModalFullscreen = ({
- title,
- children,
- setIsOpen,
- isOpen,
- showHeader,
-}: ModalFullscreenProps) => {
- return (
- <>
-
-
-
- >
- );
-};
diff --git a/src/components/searchableTokenList/SearchableTokenList.tsx b/src/components/searchableTokenList/SearchableTokenList.tsx
index 931cf67f0..5fc36e9b4 100644
--- a/src/components/searchableTokenList/SearchableTokenList.tsx
+++ b/src/components/searchableTokenList/SearchableTokenList.tsx
@@ -2,7 +2,6 @@ import { useMemo, useState } from 'react';
import { useAppSelector } from 'store';
import { Token } from 'services/observables/tokens';
import { Modal } from 'components/modal/Modal';
-import { ModalFullscreen } from 'components/modalFullscreen/ModalFullscreen';
import { prettifyNumber } from 'utils/helperFunctions';
import { wait } from 'utils/pureFunctions';
import { ReactComponent as IconEdit } from 'assets/icons/edit.svg';
@@ -15,6 +14,7 @@ import { userPreferredListIds$ } from 'services/observables/tokenLists';
import { orderBy } from 'lodash';
import { SearchInput } from 'components/searchInput/SearchInput';
import { Image } from 'components/image/Image';
+import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
interface SearchableTokenListProps {
onClick: Function;
@@ -43,17 +43,16 @@ const SearchableTokenListLayout = ({
}: SearchableTokenListLayoutProps) => {
if (isMobile) {
return (
- {
if (manage) return setManage(false);
onClose();
}}
isOpen={isOpen}
- showHeader
>
{children}
-
+
);
}
@@ -139,7 +138,7 @@ export const SearchableTokenList = ({
setManage={setManage}
>
{manage ? (
-
+
{tokensLists.map((tokenList) => {
const isSelected = userPreferredListIds.some(
@@ -178,14 +177,14 @@ export const SearchableTokenList = ({
) : (
<>
-
+
-
+
void;
onSelect: Function;
}
@@ -24,14 +24,13 @@ export const SelectPoolModal = ({
if (isMobile) {
return (
-
-
+
);
}
From 4b2f61387b00488858893a6c228bf057a3846312 Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Wed, 13 Jul 2022 16:18:38 +0300
Subject: [PATCH 02/29] fixed searchable token list layout
---
src/components/modalFullscreen/modalFullscreenV3.tsx | 6 +++++-
src/components/searchableTokenList/SearchableTokenList.tsx | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/components/modalFullscreen/modalFullscreenV3.tsx b/src/components/modalFullscreen/modalFullscreenV3.tsx
index 30e98e009..161dde2be 100644
--- a/src/components/modalFullscreen/modalFullscreenV3.tsx
+++ b/src/components/modalFullscreen/modalFullscreenV3.tsx
@@ -9,6 +9,7 @@ interface Props {
children: ReactNode;
title: string;
titleElement?: ReactNode;
+ className?: string;
}
const ModalFullscreenV3 = ({
@@ -17,6 +18,7 @@ const ModalFullscreenV3 = ({
children,
title,
titleElement,
+ className,
}: Props) => {
return (
<>
@@ -50,7 +52,9 @@ const ModalFullscreenV3 = ({
-
+
{children}
diff --git a/src/components/searchableTokenList/SearchableTokenList.tsx b/src/components/searchableTokenList/SearchableTokenList.tsx
index 5fc36e9b4..232b898de 100644
--- a/src/components/searchableTokenList/SearchableTokenList.tsx
+++ b/src/components/searchableTokenList/SearchableTokenList.tsx
@@ -49,6 +49,7 @@ const SearchableTokenListLayout = ({
if (manage) return setManage(false);
onClose();
}}
+ className="flex flex-col px-0"
isOpen={isOpen}
>
{children}
From 8eb226c4c515e5ae766cc11698954aa723148b28 Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Thu, 14 Jul 2022 16:01:46 +0300
Subject: [PATCH 03/29] Moved all modals and adjusted some
---
src/App.tsx | 2 +
.../SearchableTokenList.tsx | 52 ++-----------------
src/components/selectPool/SelectPool.tsx | 2 +-
.../selectPoolModal/SelectPoolModal.tsx | 42 ---------------
src/elements/earn/pools/TopPools.tsx | 2 +-
.../earn/pools/poolsTable/PoolsTable.tsx | 2 +-
.../poolsTable/PoolsTableCellActions.tsx | 2 +-
.../ProtectedPositionTableCellActions.tsx | 6 +--
.../rewards/StakeRewardsBtn.tsx | 2 +-
.../earn/portfolio/v3/V3AvailableToStake.tsx | 2 +-
.../v3/bonuses/V3BonusesModal.stories.tsx | 2 +-
.../portfolio/v3/bonuses/V3ClaimBonuses.tsx | 2 +-
.../v3/earningsTable/V3EarningTable.tsx | 4 +-
.../V3ExternalHoldingsItem.tsx | 2 +-
.../v3/holdings/V3HoldingsItemStaked.tsx | 2 +-
.../v3/holdings/V3HoldingsItemUnstaked.tsx | 2 +-
.../v3/holdings/V3HoldingsItemWithdraw.tsx | 2 +-
.../initWithdraw/V3WithdrawModal.stories.tsx | 2 +-
.../v3/initWithdraw/step4/V3WithdrawStep4.tsx | 2 +-
.../v3/pendingWithdraw/V3Withdraw.tsx | 4 +-
src/elements/layoutHeader/LayoutHeader.tsx | 2 +-
src/elements/swapLimit/SwapLimit.tsx | 16 +++---
src/hooks/useApproveModal.tsx | 2 +-
.../v3 => modals}/DepositDisabledModal.tsx | 8 +--
.../v3 => modals}/DepositV3Modal.tsx | 13 ++---
.../ModalCreatePool.tsx | 0
.../modalVbnt => modals}/ModalVbnt.tsx | 0
src/modals/SearchableTokenListModal.tsx | 45 ++++++++++++++++
.../SelectPoolModal.tsx} | 48 +++++++++++++++--
.../v3 => modals}/UpgradeBntModal.tsx | 0
.../v3 => modals}/UpgradeTknModal.tsx | 0
.../v3/bonuses => modals}/V3BonusesModal.tsx | 0
.../V3ExternalHoldingsModal.tsx | 0
.../v3/holdings => modals}/V3UnstakeModal.tsx | 9 ++--
.../V3WithdrawCancelModal.tsx | 14 +++--
.../V3WithdrawConfirmModal.tsx | 0
.../V3WithdrawModal.tsx | 10 ++--
.../WalletConnectModal.tsx | 8 +--
.../WithdrawLiquidityWidget.tsx | 0
src/modals/index.tsx | 3 ++
.../modalApprove => modals}/modalApprove.tsx | 0
.../modalApproveNew.tsx | 0
.../modalDepositETH.tsx | 13 +++--
.../modalDuration.tsx | 0
src/pages/Vote.tsx | 2 +-
45 files changed, 167 insertions(+), 164 deletions(-)
delete mode 100644 src/components/selectPoolModal/SelectPoolModal.tsx
rename src/{elements/earn/pools/poolsTable/v3 => modals}/DepositDisabledModal.tsx (86%)
rename src/{elements/earn/pools/poolsTable/v3 => modals}/DepositV3Modal.tsx (99%)
rename src/{elements/modalCreatePool => modals}/ModalCreatePool.tsx (100%)
rename src/{elements/modalVbnt => modals}/ModalVbnt.tsx (100%)
create mode 100644 src/modals/SearchableTokenListModal.tsx
rename src/{components/selectPoolModal/SelectPoolModalContent.tsx => modals/SelectPoolModal.tsx} (61%)
rename src/{elements/earn/portfolio/v3 => modals}/UpgradeBntModal.tsx (100%)
rename src/{elements/earn/portfolio/v3 => modals}/UpgradeTknModal.tsx (100%)
rename src/{elements/earn/portfolio/v3/bonuses => modals}/V3BonusesModal.tsx (100%)
rename src/{elements/earn/portfolio/v3/externalHoldings => modals}/V3ExternalHoldingsModal.tsx (100%)
rename src/{elements/earn/portfolio/v3/holdings => modals}/V3UnstakeModal.tsx (98%)
rename src/{elements/earn/portfolio/v3/pendingWithdraw => modals}/V3WithdrawCancelModal.tsx (91%)
rename src/{elements/earn/portfolio/v3/pendingWithdraw/confirm => modals}/V3WithdrawConfirmModal.tsx (100%)
rename src/{elements/earn/portfolio/v3/initWithdraw => modals}/V3WithdrawModal.tsx (96%)
rename src/{elements/walletConnect => modals}/WalletConnectModal.tsx (62%)
rename src/{elements/earn/portfolio/withdrawLiquidity => modals}/WithdrawLiquidityWidget.tsx (100%)
create mode 100644 src/modals/index.tsx
rename src/{elements/modalApprove => modals}/modalApprove.tsx (100%)
rename src/{elements/modalApprove => modals}/modalApproveNew.tsx (100%)
rename src/{elements/modalDepositETH => modals}/modalDepositETH.tsx (95%)
rename src/{elements/modalDuration => modals}/modalDuration.tsx (100%)
diff --git a/src/App.tsx b/src/App.tsx
index 80ca9b1b2..f50123e4f 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -30,6 +30,7 @@ import { useWeb3React } from '@web3-react/core';
import { useAutoConnect } from 'services/web3/wallet/hooks';
import { setUser } from 'services/observables/user';
import { BancorRouter } from 'router/BancorRouter';
+import { Modals } from 'modals';
const handleModeChange = (_: MediaQueryListEvent) => {
const darkMode = store.getState().user.darkMode;
@@ -102,6 +103,7 @@ export const App = () => {
)}
+
);
};
diff --git a/src/components/searchableTokenList/SearchableTokenList.tsx b/src/components/searchableTokenList/SearchableTokenList.tsx
index 232b898de..1a7df341c 100644
--- a/src/components/searchableTokenList/SearchableTokenList.tsx
+++ b/src/components/searchableTokenList/SearchableTokenList.tsx
@@ -1,12 +1,10 @@
import { useMemo, useState } from 'react';
import { useAppSelector } from 'store';
import { Token } from 'services/observables/tokens';
-import { Modal } from 'components/modal/Modal';
import { prettifyNumber } from 'utils/helperFunctions';
import { wait } from 'utils/pureFunctions';
import { ReactComponent as IconEdit } from 'assets/icons/edit.svg';
import { getTokenListLS, setTokenListLS } from 'utils/localStorage';
-import { isMobile } from 'react-device-detect';
import { SuggestedTokens } from './SuggestedTokens';
import { Switch } from 'components/switch/Switch';
import { TokenList } from 'services/observables/tokens';
@@ -14,7 +12,7 @@ import { userPreferredListIds$ } from 'services/observables/tokenLists';
import { orderBy } from 'lodash';
import { SearchInput } from 'components/searchInput/SearchInput';
import { Image } from 'components/image/Image';
-import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
+import { SearchableTokenListModal } from 'modals/SearchableTokenListModal';
interface SearchableTokenListProps {
onClick: Function;
@@ -26,50 +24,6 @@ interface SearchableTokenListProps {
limit?: boolean;
}
-interface SearchableTokenListLayoutProps {
- manage: boolean;
- setManage: Function;
- isOpen: boolean;
- onClose: Function;
- children: JSX.Element;
-}
-
-const SearchableTokenListLayout = ({
- manage,
- setManage,
- onClose,
- isOpen,
- children,
-}: SearchableTokenListLayoutProps) => {
- if (isMobile) {
- return (
- {
- if (manage) return setManage(false);
- onClose();
- }}
- className="flex flex-col px-0"
- isOpen={isOpen}
- >
- {children}
-
- );
- }
-
- return (
- setManage(false)}
- >
- {children}
-
- );
-};
-
const suggestedTokens = ['BNT', 'ETH', 'WBTC', 'USDC', 'USDT'];
export const SearchableTokenList = ({
@@ -132,7 +86,7 @@ export const SearchableTokenList = ({
}, [excludedTokens, includedTokens, limit, search, tokens]);
return (
-
>
)}
-
+
);
};
diff --git a/src/components/selectPool/SelectPool.tsx b/src/components/selectPool/SelectPool.tsx
index 204735497..5a5fa9c17 100644
--- a/src/components/selectPool/SelectPool.tsx
+++ b/src/components/selectPool/SelectPool.tsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { SelectPoolModal } from 'components/selectPoolModal/SelectPoolModal';
+import { SelectPoolModal } from 'modals/SelectPoolModal';
import { ReactComponent as IconChevronDown } from 'assets/icons/chevronDown.svg';
import { Pool } from 'services/observables/pools';
import { Image } from 'components/image/Image';
diff --git a/src/components/selectPoolModal/SelectPoolModal.tsx b/src/components/selectPoolModal/SelectPoolModal.tsx
deleted file mode 100644
index 036769a6c..000000000
--- a/src/components/selectPoolModal/SelectPoolModal.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { isMobile } from 'react-device-detect';
-import { Modal } from '../modal/Modal';
-import { SelectPoolModalContent } from './SelectPoolModalContent';
-import { Pool } from 'services/observables/pools';
-import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
-
-interface Props {
- pools: Pool[];
- isOpen: boolean;
- setIsOpen: (isOpen: boolean) => void;
- onSelect: Function;
-}
-
-export const SelectPoolModal = ({
- pools,
- isOpen,
- setIsOpen,
- onSelect,
-}: Props) => {
- const handleOnSelect = (pool: Pool) => {
- setIsOpen(false);
- onSelect(pool);
- };
-
- if (isMobile) {
- return (
-
-
-
- );
- }
-
- return (
-
-
-
- );
-};
diff --git a/src/elements/earn/pools/TopPools.tsx b/src/elements/earn/pools/TopPools.tsx
index 76c28c933..57318a5c3 100644
--- a/src/elements/earn/pools/TopPools.tsx
+++ b/src/elements/earn/pools/TopPools.tsx
@@ -3,7 +3,7 @@ import { useAppSelector } from 'store';
import { getTopPoolsV3 } from 'store/bancor/pool';
import { ReactComponent as IconGift } from 'assets/icons/gift.svg';
import { Image } from 'components/image/Image';
-import { DepositDisabledModal } from 'elements/earn/pools/poolsTable/v3/DepositDisabledModal';
+import { DepositDisabledModal } from 'modals/DepositDisabledModal';
// import { DepositV3Modal } from './poolsTable/v3/DepositV3Modal';
export const TopPools = () => {
diff --git a/src/elements/earn/pools/poolsTable/PoolsTable.tsx b/src/elements/earn/pools/poolsTable/PoolsTable.tsx
index 1b0c29e04..63af3b6db 100644
--- a/src/elements/earn/pools/poolsTable/PoolsTable.tsx
+++ b/src/elements/earn/pools/poolsTable/PoolsTable.tsx
@@ -8,7 +8,7 @@ import { ReactComponent as IconGift } from 'assets/icons/gift.svg';
import { PoolsTableSort } from './PoolsTableFilter';
import { PoolV3 } from 'services/observables/pools';
// import { DepositV3Modal } from 'elements/earn/pools/poolsTable/v3/DepositV3Modal';
-import { DepositDisabledModal } from 'elements/earn/pools/poolsTable/v3/DepositDisabledModal';
+import { DepositDisabledModal } from 'modals/DepositDisabledModal';
import { prettifyNumber, toBigNumber } from 'utils/helperFunctions';
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
import { Statistics } from 'elements/earn/pools/Statistics';
diff --git a/src/elements/earn/pools/poolsTable/PoolsTableCellActions.tsx b/src/elements/earn/pools/poolsTable/PoolsTableCellActions.tsx
index 4baddd2fc..c459a819d 100644
--- a/src/elements/earn/pools/poolsTable/PoolsTableCellActions.tsx
+++ b/src/elements/earn/pools/poolsTable/PoolsTableCellActions.tsx
@@ -1,6 +1,6 @@
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
import { PopoverV3 } from 'components/popover/PopoverV3';
-import { DepositDisabledModal } from 'elements/earn/pools/poolsTable/v3/DepositDisabledModal';
+import { DepositDisabledModal } from 'modals/DepositDisabledModal';
export const PoolsTableCellActions = (_id: string) => {
return (
diff --git a/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx b/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx
index ccff8ef9a..d5be039e4 100644
--- a/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx
+++ b/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx
@@ -6,14 +6,14 @@ import { CellProps } from 'react-table';
import { PropsWithChildren, useCallback, useMemo, useState } from 'react';
import { TableCellExpander } from 'components/table/TableCellExpander';
import { Button } from 'components/button/Button';
-import { WithdrawLiquidityWidget } from '../../withdrawLiquidity/WithdrawLiquidityWidget';
-import { UpgradeBntModal } from '../../v3/UpgradeBntModal';
+import { WithdrawLiquidityWidget } from '../../../../../modals/WithdrawLiquidityWidget';
+import { UpgradeBntModal } from '../../../../../modals/UpgradeBntModal';
import { bntToken } from 'services/web3/config';
import { getAllBntPositionsAndAmount } from 'store/liquidity/liquidity';
import { useAppSelector } from 'store';
import { getIsV3Exist } from 'store/bancor/pool';
import { PopoverV3 } from 'components/popover/PopoverV3';
-import { UpgradeTknModal } from '../../v3/UpgradeTknModal';
+import { UpgradeTknModal } from '../../../../../modals/UpgradeTknModal';
export const ProtectedPositionTableCellActions = (
cellData: PropsWithChildren<
diff --git a/src/elements/earn/portfolio/liquidityProtection/rewards/StakeRewardsBtn.tsx b/src/elements/earn/portfolio/liquidityProtection/rewards/StakeRewardsBtn.tsx
index 62a35abf7..f9a72ee5c 100644
--- a/src/elements/earn/portfolio/liquidityProtection/rewards/StakeRewardsBtn.tsx
+++ b/src/elements/earn/portfolio/liquidityProtection/rewards/StakeRewardsBtn.tsx
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useAppSelector } from 'store';
import { getProtectedPools } from 'store/bancor/pool';
-import { SelectPoolModal } from 'components/selectPoolModal/SelectPoolModal';
+import { SelectPoolModal } from 'modals/SelectPoolModal';
import { Pool } from 'services/observables/pools';
import { useNavigation } from 'hooks/useNavigation';
import { Button } from 'components/button/Button';
diff --git a/src/elements/earn/portfolio/v3/V3AvailableToStake.tsx b/src/elements/earn/portfolio/v3/V3AvailableToStake.tsx
index 93da49e40..a34db2761 100644
--- a/src/elements/earn/portfolio/v3/V3AvailableToStake.tsx
+++ b/src/elements/earn/portfolio/v3/V3AvailableToStake.tsx
@@ -7,7 +7,7 @@ import { useAppSelector } from 'store';
import { getAvailableToStakeTokens } from 'store/bancor/token';
import { Token } from 'services/observables/tokens';
import { PoolV3 } from 'services/observables/pools';
-import { DepositDisabledModal } from 'elements/earn/pools/poolsTable/v3/DepositDisabledModal';
+import { DepositDisabledModal } from 'modals/DepositDisabledModal';
import 'swiper/css';
const AvailableItem = ({ token, pool }: { token: Token; pool: PoolV3 }) => {
diff --git a/src/elements/earn/portfolio/v3/bonuses/V3BonusesModal.stories.tsx b/src/elements/earn/portfolio/v3/bonuses/V3BonusesModal.stories.tsx
index 73f255c9e..a527fcbb6 100644
--- a/src/elements/earn/portfolio/v3/bonuses/V3BonusesModal.stories.tsx
+++ b/src/elements/earn/portfolio/v3/bonuses/V3BonusesModal.stories.tsx
@@ -2,7 +2,7 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';
import { withDesign } from 'storybook-addon-designs';
import { store } from 'store';
import { Provider } from 'react-redux';
-import { V3BonusesModal } from 'elements/earn/portfolio/v3/bonuses/V3BonusesModal';
+import { V3BonusesModal } from 'modals/V3BonusesModal';
export default {
title: 'Elements/V3/Portfolio/Bonuses',
diff --git a/src/elements/earn/portfolio/v3/bonuses/V3ClaimBonuses.tsx b/src/elements/earn/portfolio/v3/bonuses/V3ClaimBonuses.tsx
index 8142164d8..af1b9e08c 100644
--- a/src/elements/earn/portfolio/v3/bonuses/V3ClaimBonuses.tsx
+++ b/src/elements/earn/portfolio/v3/bonuses/V3ClaimBonuses.tsx
@@ -1,5 +1,5 @@
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
-import { V3BonusesModal } from 'elements/earn/portfolio/v3/bonuses/V3BonusesModal';
+import { V3BonusesModal } from 'modals/V3BonusesModal';
import { useV3Bonuses } from 'elements/earn/portfolio/v3/bonuses/useV3Bonuses';
import { prettifyNumber } from 'utils/helperFunctions';
diff --git a/src/elements/earn/portfolio/v3/earningsTable/V3EarningTable.tsx b/src/elements/earn/portfolio/v3/earningsTable/V3EarningTable.tsx
index 72fe573ba..cf7ef2f21 100644
--- a/src/elements/earn/portfolio/v3/earningsTable/V3EarningTable.tsx
+++ b/src/elements/earn/portfolio/v3/earningsTable/V3EarningTable.tsx
@@ -1,7 +1,7 @@
import { DataTable, TableColumn } from 'components/table/DataTable';
import { useMemo, useState } from 'react';
import { TokenBalance } from 'components/tokenBalance/TokenBalance';
-import V3WithdrawModal from 'elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal';
+import V3WithdrawModal from 'modals/V3WithdrawModal';
import { V3EarningTableMenu } from 'elements/earn/portfolio/v3/earningsTable/menu/V3EarningTableMenu';
import { useAppSelector } from 'store';
import {
@@ -10,7 +10,7 @@ import {
} from 'store/portfolio/v3Portfolio';
import { Holding } from 'store/portfolio/v3Portfolio.types';
// import { DepositV3Modal } from 'elements/earn/pools/poolsTable/v3/DepositV3Modal';
-import { DepositDisabledModal } from 'elements/earn/pools/poolsTable/v3/DepositDisabledModal';
+import { DepositDisabledModal } from 'modals/DepositDisabledModal';
import { SortingRule } from 'react-table';
import { shrinkToken } from 'utils/formulas';
import { prettifyNumber } from 'utils/helperFunctions';
diff --git a/src/elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsItem.tsx b/src/elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsItem.tsx
index a03df9200..7c1ba20e8 100644
--- a/src/elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsItem.tsx
+++ b/src/elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsItem.tsx
@@ -2,7 +2,7 @@ import { memo, useState } from 'react';
import { prettifyNumber } from 'utils/helperFunctions';
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
import { ExternalHolding } from 'elements/earn/portfolio/v3/externalHoldings/externalHoldings.types';
-import { V3ExternalHoldingsModal } from 'elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsModal';
+import { V3ExternalHoldingsModal } from 'modals/V3ExternalHoldingsModal';
import { TokensOverlap } from 'components/tokensOverlap/TokensOverlap';
interface Props {
diff --git a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemStaked.tsx b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemStaked.tsx
index 47f798a24..918c099b3 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemStaked.tsx
+++ b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemStaked.tsx
@@ -2,7 +2,7 @@ import { Holding } from 'store/portfolio/v3Portfolio.types';
import { prettifyNumber, toBigNumber } from 'utils/helperFunctions';
import { ReactComponent as IconGift } from 'assets/icons/gift.svg';
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
-import { V3UnstakeModal } from 'elements/earn/portfolio/v3/holdings/V3UnstakeModal';
+import { V3UnstakeModal } from 'modals/V3UnstakeModal';
import { PopoverV3 } from 'components/popover/PopoverV3';
export const V3HoldingsItemStaked = ({ holding }: { holding: Holding }) => {
diff --git a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx
index 6ecde19c6..7a5ff509e 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx
+++ b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx
@@ -14,7 +14,7 @@ import { updatePortfolioData } from 'services/web3/v3/portfolio/helpers';
import { ErrorCode } from 'services/web3/types';
import { useApproveModal } from 'hooks/useApproveModal';
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
-import V3WithdrawModal from 'elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal';
+import V3WithdrawModal from 'modals/V3WithdrawModal';
import { PopoverV3 } from 'components/popover/PopoverV3';
export const V3HoldingsItemUnstaked = ({ holding }: { holding: Holding }) => {
diff --git a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx
index 007ed7c1e..780994ab0 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx
+++ b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx
@@ -1,7 +1,7 @@
import { Holding } from 'store/portfolio/v3Portfolio.types';
import { useState } from 'react';
import { prettifyNumber, toBigNumber } from 'utils/helperFunctions';
-import V3WithdrawModal from 'elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal';
+import V3WithdrawModal from 'modals/V3WithdrawModal';
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
export const V3HoldingsItemWithdraw = ({ holding }: { holding: Holding }) => {
diff --git a/src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.stories.tsx b/src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.stories.tsx
index 4d9935ecf..77299f317 100644
--- a/src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.stories.tsx
+++ b/src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.stories.tsx
@@ -1,7 +1,7 @@
import { ComponentMeta, ComponentStory } from '@storybook/react';
import { withDesign } from 'storybook-addon-designs';
import { useState } from 'react';
-import V3WithdrawModal from 'elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal';
+import V3WithdrawModal from 'modals/V3WithdrawModal';
import { store } from 'store';
import { Provider } from 'react-redux';
diff --git a/src/elements/earn/portfolio/v3/initWithdraw/step4/V3WithdrawStep4.tsx b/src/elements/earn/portfolio/v3/initWithdraw/step4/V3WithdrawStep4.tsx
index 2e2a487dd..efa1050ef 100644
--- a/src/elements/earn/portfolio/v3/initWithdraw/step4/V3WithdrawStep4.tsx
+++ b/src/elements/earn/portfolio/v3/initWithdraw/step4/V3WithdrawStep4.tsx
@@ -7,7 +7,7 @@ import {
} from 'datebook';
import { openNewTab } from 'utils/pureFunctions';
import dayjs from 'dayjs';
-import { V3WithdrawConfirmContent } from '../../pendingWithdraw/confirm/V3WithdrawConfirmModal';
+import { V3WithdrawConfirmContent } from '../../../../../../modals/V3WithdrawConfirmModal';
import { useAppSelector } from 'store';
import { getPortfolioWithdrawalRequests } from 'store/portfolio/v3Portfolio';
diff --git a/src/elements/earn/portfolio/v3/pendingWithdraw/V3Withdraw.tsx b/src/elements/earn/portfolio/v3/pendingWithdraw/V3Withdraw.tsx
index 986228e8e..1120e9115 100644
--- a/src/elements/earn/portfolio/v3/pendingWithdraw/V3Withdraw.tsx
+++ b/src/elements/earn/portfolio/v3/pendingWithdraw/V3Withdraw.tsx
@@ -1,7 +1,7 @@
import { useV3Withdraw } from 'elements/earn/portfolio/v3/pendingWithdraw/useV3Withdraw';
import { WithdrawItem } from 'elements/earn/portfolio/v3/pendingWithdraw/V3WithdrawItem';
-import { V3WithdrawCancelModal } from 'elements/earn/portfolio/v3/pendingWithdraw/V3WithdrawCancelModal';
-import { V3WithdrawConfirmModal } from 'elements/earn/portfolio/v3/pendingWithdraw/confirm/V3WithdrawConfirmModal';
+import { V3WithdrawCancelModal } from 'modals/V3WithdrawCancelModal';
+import { V3WithdrawConfirmModal } from 'modals/V3WithdrawConfirmModal';
export const V3Withdraw = () => {
const {
diff --git a/src/elements/layoutHeader/LayoutHeader.tsx b/src/elements/layoutHeader/LayoutHeader.tsx
index 9bfbaa8ed..69b214b60 100644
--- a/src/elements/layoutHeader/LayoutHeader.tsx
+++ b/src/elements/layoutHeader/LayoutHeader.tsx
@@ -2,7 +2,7 @@ import { NotificationsMenu } from 'elements/notifications/NotificationsMenu';
import { SettingsMenu } from 'elements/settings/SettingsMenu';
import { ReactComponent as IconBancor } from 'assets/icons/bancor.svg';
import { useWalletConnect } from '../walletConnect/useWalletConnect';
-import { WalletConnectModal } from '../walletConnect/WalletConnectModal';
+import { WalletConnectModal } from '../../modals/WalletConnectModal';
import { WalletConnectButton } from '../walletConnect/WalletConnectButton';
import { useEffect, useState } from 'react';
import { NetworkIndicator } from './NetworkIndicator';
diff --git a/src/elements/swapLimit/SwapLimit.tsx b/src/elements/swapLimit/SwapLimit.tsx
index dcde69add..6bf22d1bb 100644
--- a/src/elements/swapLimit/SwapLimit.tsx
+++ b/src/elements/swapLimit/SwapLimit.tsx
@@ -3,7 +3,7 @@ import dayjs from 'utils/dayjs';
import BigNumber from 'bignumber.js';
import { InputField } from 'components/inputField/InputField';
import { TokenInputField } from 'components/tokenInputField/TokenInputField';
-import { ModalDuration } from 'elements/modalDuration/modalDuration';
+import { ModalDuration } from 'modals/modalDuration';
import { Token, updateUserBalances } from 'services/observables/tokens';
import { ReactComponent as IconSync } from 'assets/icons/sync.svg';
import { classNameGenerator } from 'utils/pureFunctions';
@@ -17,19 +17,13 @@ import { useDispatch } from 'react-redux';
import { useWeb3React } from '@web3-react/core';
import { ethToken, wethToken } from 'services/web3/config';
import { useAppSelector } from 'store';
-import { ModalApprove } from 'elements/modalApprove/modalApprove';
+import { ModalApprove } from 'modals/modalApprove';
import {
ApprovalContract,
getNetworkContractApproval,
} from 'services/web3/approval';
import { prettifyNumber } from 'utils/helperFunctions';
-import {
- ConversionEvents,
- sendConversionEvent,
- setCurrentConversion,
-} from 'services/api/googleTagManager';
import { calculatePercentageChange } from 'utils/formulas';
-import { ModalDepositETH } from 'elements/modalDepositETH/modalDepositETH';
import {
Button,
ButtonPercentages,
@@ -37,6 +31,12 @@ import {
} from 'components/button/Button';
import useAsyncEffect from 'use-async-effect';
import { useWalletConnect } from 'elements/walletConnect/useWalletConnect';
+import { ModalDepositETH } from 'modals/modalDepositETH';
+import {
+ sendConversionEvent,
+ ConversionEvents,
+ setCurrentConversion,
+} from 'services/api/googleTagManager';
enum Field {
from,
diff --git a/src/hooks/useApproveModal.tsx b/src/hooks/useApproveModal.tsx
index ac884255f..d89c962e7 100644
--- a/src/hooks/useApproveModal.tsx
+++ b/src/hooks/useApproveModal.tsx
@@ -5,7 +5,7 @@ import {
getNetworkContractApproval,
setNetworkContractApproval,
} from 'services/web3/approval';
-import { ModalApproveNew } from 'elements/modalApprove/modalApproveNew';
+import { ModalApproveNew } from 'modals/modalApproveNew';
import {
addNotification,
NotificationType,
diff --git a/src/elements/earn/pools/poolsTable/v3/DepositDisabledModal.tsx b/src/modals/DepositDisabledModal.tsx
similarity index 86%
rename from src/elements/earn/pools/poolsTable/v3/DepositDisabledModal.tsx
rename to src/modals/DepositDisabledModal.tsx
index ea3301993..9a5245bd5 100644
--- a/src/elements/earn/pools/poolsTable/v3/DepositDisabledModal.tsx
+++ b/src/modals/DepositDisabledModal.tsx
@@ -1,11 +1,11 @@
import { useState } from 'react';
import { ModalV3 } from 'components/modal/ModalV3';
-interface Props {
+export const DepositDisabledModal = ({
+ renderButton,
+}: {
renderButton: (onClick: () => void) => React.ReactNode;
-}
-
-export const DepositDisabledModal = ({ renderButton }: Props) => {
+}) => {
const [isOpen, setIsOpen] = useState(false);
const onClose = async () => {
diff --git a/src/elements/earn/pools/poolsTable/v3/DepositV3Modal.tsx b/src/modals/DepositV3Modal.tsx
similarity index 99%
rename from src/elements/earn/pools/poolsTable/v3/DepositV3Modal.tsx
rename to src/modals/DepositV3Modal.tsx
index 93957c893..43683f6b3 100644
--- a/src/elements/earn/pools/poolsTable/v3/DepositV3Modal.tsx
+++ b/src/modals/DepositV3Modal.tsx
@@ -31,14 +31,15 @@ import { ReactComponent as IconChevron } from 'assets/icons/chevronDown.svg';
import { getPoolsV3Map } from 'store/bancor/pool';
import { useWalletConnect } from 'elements/walletConnect/useWalletConnect';
-interface Props {
- pool: PoolV3;
- renderButton: (onClick: () => void) => React.ReactNode;
-}
-
const REWARDS_EXTRA_GAS = 130_000;
-export const DepositV3Modal = ({ pool, renderButton }: Props) => {
+export const DepositV3Modal = ({
+ pool,
+ renderButton,
+}: {
+ pool: PoolV3;
+ renderButton: (onClick: () => void) => React.ReactNode;
+}) => {
const account = useAppSelector((state) => state.user.account);
const [isOpen, setIsOpen] = useState(false);
const [txBusy, setTxBusy] = useState(false);
diff --git a/src/elements/modalCreatePool/ModalCreatePool.tsx b/src/modals/ModalCreatePool.tsx
similarity index 100%
rename from src/elements/modalCreatePool/ModalCreatePool.tsx
rename to src/modals/ModalCreatePool.tsx
diff --git a/src/elements/modalVbnt/ModalVbnt.tsx b/src/modals/ModalVbnt.tsx
similarity index 100%
rename from src/elements/modalVbnt/ModalVbnt.tsx
rename to src/modals/ModalVbnt.tsx
diff --git a/src/modals/SearchableTokenListModal.tsx b/src/modals/SearchableTokenListModal.tsx
new file mode 100644
index 000000000..b8be1a442
--- /dev/null
+++ b/src/modals/SearchableTokenListModal.tsx
@@ -0,0 +1,45 @@
+import { Modal } from 'components/modal/Modal';
+import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
+import { isMobile } from 'react-device-detect';
+
+export const SearchableTokenListModal = ({
+ manage,
+ setManage,
+ onClose,
+ isOpen,
+ children,
+}: {
+ manage: boolean;
+ setManage: Function;
+ isOpen: boolean;
+ onClose: Function;
+ children: JSX.Element;
+}) => {
+ if (isMobile) {
+ return (
+ {
+ if (manage) return setManage(false);
+ onClose();
+ }}
+ className="flex flex-col px-0"
+ isOpen={isOpen}
+ >
+ {children}
+
+ );
+ }
+
+ return (
+ setManage(false)}
+ >
+ {children}
+
+ );
+};
diff --git a/src/components/selectPoolModal/SelectPoolModalContent.tsx b/src/modals/SelectPoolModal.tsx
similarity index 61%
rename from src/components/selectPoolModal/SelectPoolModalContent.tsx
rename to src/modals/SelectPoolModal.tsx
index 15490209c..8045da32d 100644
--- a/src/components/selectPoolModal/SelectPoolModalContent.tsx
+++ b/src/modals/SelectPoolModal.tsx
@@ -1,13 +1,53 @@
-import { InputField } from '../inputField/InputField';
import { useState } from 'react';
+import { isMobile } from 'react-device-detect';
+import { Modal } from '../components/modal/Modal';
import { Pool } from 'services/observables/pools';
+import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
+import { InputField } from '../components/inputField/InputField';
import { Image } from 'components/image/Image';
-interface Props {
+export const SelectPoolModal = ({
+ pools,
+ isOpen,
+ setIsOpen,
+ onSelect,
+}: {
pools: Pool[];
+ isOpen: boolean;
+ setIsOpen: (isOpen: boolean) => void;
onSelect: Function;
-}
-export const SelectPoolModalContent = ({ pools, onSelect }: Props) => {
+}) => {
+ const handleOnSelect = (pool: Pool) => {
+ setIsOpen(false);
+ onSelect(pool);
+ };
+
+ if (isMobile) {
+ return (
+
+
+
+ );
+ }
+
+ return (
+
+
+
+ );
+};
+
+const SelectPoolModalContent = ({
+ pools,
+ onSelect,
+}: {
+ pools: Pool[];
+ onSelect: (pool: Pool) => void;
+}) => {
const [search, setSearch] = useState('');
const filteredPools = pools.filter((pool) =>
pool.reserves[0].symbol.toLowerCase().includes(search.toLowerCase())
diff --git a/src/elements/earn/portfolio/v3/UpgradeBntModal.tsx b/src/modals/UpgradeBntModal.tsx
similarity index 100%
rename from src/elements/earn/portfolio/v3/UpgradeBntModal.tsx
rename to src/modals/UpgradeBntModal.tsx
diff --git a/src/elements/earn/portfolio/v3/UpgradeTknModal.tsx b/src/modals/UpgradeTknModal.tsx
similarity index 100%
rename from src/elements/earn/portfolio/v3/UpgradeTknModal.tsx
rename to src/modals/UpgradeTknModal.tsx
diff --git a/src/elements/earn/portfolio/v3/bonuses/V3BonusesModal.tsx b/src/modals/V3BonusesModal.tsx
similarity index 100%
rename from src/elements/earn/portfolio/v3/bonuses/V3BonusesModal.tsx
rename to src/modals/V3BonusesModal.tsx
diff --git a/src/elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsModal.tsx b/src/modals/V3ExternalHoldingsModal.tsx
similarity index 100%
rename from src/elements/earn/portfolio/v3/externalHoldings/V3ExternalHoldingsModal.tsx
rename to src/modals/V3ExternalHoldingsModal.tsx
diff --git a/src/elements/earn/portfolio/v3/holdings/V3UnstakeModal.tsx b/src/modals/V3UnstakeModal.tsx
similarity index 98%
rename from src/elements/earn/portfolio/v3/holdings/V3UnstakeModal.tsx
rename to src/modals/V3UnstakeModal.tsx
index 7445963ed..7e42a030e 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3UnstakeModal.tsx
+++ b/src/modals/V3UnstakeModal.tsx
@@ -16,12 +16,13 @@ import {
import { updatePortfolioData } from 'services/web3/v3/portfolio/helpers';
import { ErrorCode } from 'services/web3/types';
-interface Props {
+export const V3UnstakeModal = ({
+ holding,
+ renderButton,
+}: {
holding: Holding;
renderButton: (onClick: () => void) => React.ReactNode;
-}
-
-export const V3UnstakeModal = ({ holding, renderButton }: Props) => {
+}) => {
const account = useAppSelector((state) => state.user.account);
const [isOpen, setIsOpen] = useState(false);
const [txBusy, setTxBusy] = useState(false);
diff --git a/src/elements/earn/portfolio/v3/pendingWithdraw/V3WithdrawCancelModal.tsx b/src/modals/V3WithdrawCancelModal.tsx
similarity index 91%
rename from src/elements/earn/portfolio/v3/pendingWithdraw/V3WithdrawCancelModal.tsx
rename to src/modals/V3WithdrawCancelModal.tsx
index e63bbb72b..767734849 100644
--- a/src/elements/earn/portfolio/v3/pendingWithdraw/V3WithdrawCancelModal.tsx
+++ b/src/modals/V3WithdrawCancelModal.tsx
@@ -5,20 +5,18 @@ import { Button, ButtonSize } from 'components/button/Button';
import { TokenBalanceLarge } from 'components/tokenBalance/TokenBalanceLarge';
import { toBigNumber } from 'utils/helperFunctions';
-interface Props {
- isModalOpen: boolean;
- setIsModalOpen: (isOpen: boolean) => void;
- withdrawRequest: WithdrawalRequest;
- cancelWithdrawal: () => Promise;
-}
-
export const V3WithdrawCancelModal = memo(
({
isModalOpen,
setIsModalOpen,
withdrawRequest,
cancelWithdrawal,
- }: Props) => {
+ }: {
+ isModalOpen: boolean;
+ setIsModalOpen: (isOpen: boolean) => void;
+ withdrawRequest: WithdrawalRequest;
+ cancelWithdrawal: () => Promise;
+ }) => {
const [txBusy, setTxBusy] = useState(false);
const { pool } = withdrawRequest;
const token = pool.reserveToken;
diff --git a/src/elements/earn/portfolio/v3/pendingWithdraw/confirm/V3WithdrawConfirmModal.tsx b/src/modals/V3WithdrawConfirmModal.tsx
similarity index 100%
rename from src/elements/earn/portfolio/v3/pendingWithdraw/confirm/V3WithdrawConfirmModal.tsx
rename to src/modals/V3WithdrawConfirmModal.tsx
diff --git a/src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.tsx b/src/modals/V3WithdrawModal.tsx
similarity index 96%
rename from src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.tsx
rename to src/modals/V3WithdrawModal.tsx
index afbf15fbe..b429b69ac 100644
--- a/src/elements/earn/portfolio/v3/initWithdraw/V3WithdrawModal.tsx
+++ b/src/modals/V3WithdrawModal.tsx
@@ -8,13 +8,15 @@ import { SwapSwitch } from 'elements/swapSwitch/SwapSwitch';
import { useV3WithdrawModal } from 'elements/earn/portfolio/v3/initWithdraw/useV3WithdrawModal';
import { Holding } from 'store/portfolio/v3Portfolio.types';
-interface Props {
+const V3WithdrawModal = ({
+ isOpen,
+ setIsOpen,
+ holding,
+}: {
isOpen: boolean;
setIsOpen: (isOpen: boolean) => void;
holding: Holding;
-}
-
-const V3WithdrawModal = ({ isOpen, setIsOpen, holding }: Props) => {
+}) => {
const {
step,
onClose,
diff --git a/src/elements/walletConnect/WalletConnectModal.tsx b/src/modals/WalletConnectModal.tsx
similarity index 62%
rename from src/elements/walletConnect/WalletConnectModal.tsx
rename to src/modals/WalletConnectModal.tsx
index a7c019f0c..13d52a2ef 100644
--- a/src/elements/walletConnect/WalletConnectModal.tsx
+++ b/src/modals/WalletConnectModal.tsx
@@ -1,8 +1,8 @@
import { Modal } from 'components/modal/Modal';
-import { UseWalletConnect } from './useWalletConnect';
-import { WalletConnectModalList } from './WalletConnectModalList';
-import { WalletConnectModalPending } from './WalletConnectModalPending';
-import { WalletConnectModalError } from './WalletConnectModalError';
+import { UseWalletConnect } from '../elements/walletConnect/useWalletConnect';
+import { WalletConnectModalList } from '../elements/walletConnect/WalletConnectModalList';
+import { WalletConnectModalPending } from '../elements/walletConnect/WalletConnectModalPending';
+import { WalletConnectModalError } from '../elements/walletConnect/WalletConnectModalError';
export const WalletConnectModal = (props: UseWalletConnect) => {
const { isPending, isError } = props;
diff --git a/src/elements/earn/portfolio/withdrawLiquidity/WithdrawLiquidityWidget.tsx b/src/modals/WithdrawLiquidityWidget.tsx
similarity index 100%
rename from src/elements/earn/portfolio/withdrawLiquidity/WithdrawLiquidityWidget.tsx
rename to src/modals/WithdrawLiquidityWidget.tsx
diff --git a/src/modals/index.tsx b/src/modals/index.tsx
new file mode 100644
index 000000000..261940fcf
--- /dev/null
+++ b/src/modals/index.tsx
@@ -0,0 +1,3 @@
+export const Modals = () => {
+ return <>>;
+};
diff --git a/src/elements/modalApprove/modalApprove.tsx b/src/modals/modalApprove.tsx
similarity index 100%
rename from src/elements/modalApprove/modalApprove.tsx
rename to src/modals/modalApprove.tsx
diff --git a/src/elements/modalApprove/modalApproveNew.tsx b/src/modals/modalApproveNew.tsx
similarity index 100%
rename from src/elements/modalApprove/modalApproveNew.tsx
rename to src/modals/modalApproveNew.tsx
diff --git a/src/elements/modalDepositETH/modalDepositETH.tsx b/src/modals/modalDepositETH.tsx
similarity index 95%
rename from src/elements/modalDepositETH/modalDepositETH.tsx
rename to src/modals/modalDepositETH.tsx
index 18a2dcf7d..c013c4e1a 100644
--- a/src/elements/modalDepositETH/modalDepositETH.tsx
+++ b/src/modals/modalDepositETH.tsx
@@ -2,18 +2,17 @@ import { Modal } from 'components/modal/Modal';
import { ReactComponent as IconDeposit } from 'assets/icons/deposit.svg';
import { Button, ButtonSize } from 'components/button/Button';
-interface ModalDepositETHProps {
- amount: string;
- isOpen: boolean;
- setIsOpen: Function;
- onConfirm: Function;
-}
export const ModalDepositETH = ({
amount,
isOpen,
setIsOpen,
onConfirm,
-}: ModalDepositETHProps) => {
+}: {
+ amount: string;
+ isOpen: boolean;
+ setIsOpen: Function;
+ onConfirm: Function;
+}) => {
return (
}
diff --git a/src/elements/modalDuration/modalDuration.tsx b/src/modals/modalDuration.tsx
similarity index 100%
rename from src/elements/modalDuration/modalDuration.tsx
rename to src/modals/modalDuration.tsx
diff --git a/src/pages/Vote.tsx b/src/pages/Vote.tsx
index e23342612..f2c2b3eaa 100644
--- a/src/pages/Vote.tsx
+++ b/src/pages/Vote.tsx
@@ -1,7 +1,7 @@
import { useWeb3React } from '@web3-react/core';
import { ReactComponent as IconLink } from 'assets/icons/link.svg';
import { CountdownTimer } from 'components/countdownTimer/CountdownTimer';
-import { ModalVbnt } from 'elements/modalVbnt/ModalVbnt';
+import { ModalVbnt } from 'modals/ModalVbnt';
import { useCallback, useState } from 'react';
import { useEffect } from 'react';
import { useAppSelector } from 'store';
From 03b9937f95ad053b8a038e2933d66211f9568ce5 Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Thu, 14 Jul 2022 16:06:17 +0300
Subject: [PATCH 04/29] renamed some modals to create consistency
---
.../ProtectedPositionTableCellActions.tsx | 4 ++--
src/elements/swapLimit/SwapLimit.tsx | 6 +++---
src/hooks/useApproveModal.tsx | 2 +-
src/modals/{modalApprove.tsx => ApproveModal.tsx} | 0
.../{ModalCreatePool.tsx => CreatePoolModal.tsx} | 0
.../{modalDepositETH.tsx => DepositETHModal.tsx} | 0
src/modals/{modalDuration.tsx => DurationModal.tsx} | 0
.../{modalApproveNew.tsx => NewApproveModal.tsx} | 0
src/modals/{ModalVbnt.tsx => VbntModal.tsx} | 0
...iquidityWidget.tsx => WithdrawLiquidityModal.tsx} | 12 +++++-------
src/pages/Vote.tsx | 2 +-
11 files changed, 12 insertions(+), 14 deletions(-)
rename src/modals/{modalApprove.tsx => ApproveModal.tsx} (100%)
rename src/modals/{ModalCreatePool.tsx => CreatePoolModal.tsx} (100%)
rename src/modals/{modalDepositETH.tsx => DepositETHModal.tsx} (100%)
rename src/modals/{modalDuration.tsx => DurationModal.tsx} (100%)
rename src/modals/{modalApproveNew.tsx => NewApproveModal.tsx} (100%)
rename src/modals/{ModalVbnt.tsx => VbntModal.tsx} (100%)
rename src/modals/{WithdrawLiquidityWidget.tsx => WithdrawLiquidityModal.tsx} (94%)
diff --git a/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx b/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx
index d5be039e4..b9bece5c4 100644
--- a/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx
+++ b/src/elements/earn/portfolio/liquidityProtection/protectedPositions/ProtectedPositionTableCellActions.tsx
@@ -6,7 +6,7 @@ import { CellProps } from 'react-table';
import { PropsWithChildren, useCallback, useMemo, useState } from 'react';
import { TableCellExpander } from 'components/table/TableCellExpander';
import { Button } from 'components/button/Button';
-import { WithdrawLiquidityWidget } from '../../../../../modals/WithdrawLiquidityWidget';
+import { WithdrawLiquidityModal } from '../../../../../modals/WithdrawLiquidityModal';
import { UpgradeBntModal } from '../../../../../modals/UpgradeBntModal';
import { bntToken } from 'services/web3/config';
import { getAllBntPositionsAndAmount } from 'store/liquidity/liquidity';
@@ -123,7 +123,7 @@ export const ProtectedPositionTableCellActions = (
groupContent,
subMenu: () => setIsOpenWithdraw(true),
})}
-
diff --git a/src/elements/swapLimit/SwapLimit.tsx b/src/elements/swapLimit/SwapLimit.tsx
index 6bf22d1bb..e9009f3a3 100644
--- a/src/elements/swapLimit/SwapLimit.tsx
+++ b/src/elements/swapLimit/SwapLimit.tsx
@@ -3,7 +3,7 @@ import dayjs from 'utils/dayjs';
import BigNumber from 'bignumber.js';
import { InputField } from 'components/inputField/InputField';
import { TokenInputField } from 'components/tokenInputField/TokenInputField';
-import { ModalDuration } from 'modals/modalDuration';
+import { ModalDuration } from 'modals/DurationModal';
import { Token, updateUserBalances } from 'services/observables/tokens';
import { ReactComponent as IconSync } from 'assets/icons/sync.svg';
import { classNameGenerator } from 'utils/pureFunctions';
@@ -17,7 +17,7 @@ import { useDispatch } from 'react-redux';
import { useWeb3React } from '@web3-react/core';
import { ethToken, wethToken } from 'services/web3/config';
import { useAppSelector } from 'store';
-import { ModalApprove } from 'modals/modalApprove';
+import { ModalApprove } from 'modals/ApproveModal';
import {
ApprovalContract,
getNetworkContractApproval,
@@ -31,7 +31,7 @@ import {
} from 'components/button/Button';
import useAsyncEffect from 'use-async-effect';
import { useWalletConnect } from 'elements/walletConnect/useWalletConnect';
-import { ModalDepositETH } from 'modals/modalDepositETH';
+import { ModalDepositETH } from 'modals/DepositETHModal';
import {
sendConversionEvent,
ConversionEvents,
diff --git a/src/hooks/useApproveModal.tsx b/src/hooks/useApproveModal.tsx
index d89c962e7..3ed91c9fa 100644
--- a/src/hooks/useApproveModal.tsx
+++ b/src/hooks/useApproveModal.tsx
@@ -5,7 +5,7 @@ import {
getNetworkContractApproval,
setNetworkContractApproval,
} from 'services/web3/approval';
-import { ModalApproveNew } from 'modals/modalApproveNew';
+import { ModalApproveNew } from 'modals/NewApproveModal';
import {
addNotification,
NotificationType,
diff --git a/src/modals/modalApprove.tsx b/src/modals/ApproveModal.tsx
similarity index 100%
rename from src/modals/modalApprove.tsx
rename to src/modals/ApproveModal.tsx
diff --git a/src/modals/ModalCreatePool.tsx b/src/modals/CreatePoolModal.tsx
similarity index 100%
rename from src/modals/ModalCreatePool.tsx
rename to src/modals/CreatePoolModal.tsx
diff --git a/src/modals/modalDepositETH.tsx b/src/modals/DepositETHModal.tsx
similarity index 100%
rename from src/modals/modalDepositETH.tsx
rename to src/modals/DepositETHModal.tsx
diff --git a/src/modals/modalDuration.tsx b/src/modals/DurationModal.tsx
similarity index 100%
rename from src/modals/modalDuration.tsx
rename to src/modals/DurationModal.tsx
diff --git a/src/modals/modalApproveNew.tsx b/src/modals/NewApproveModal.tsx
similarity index 100%
rename from src/modals/modalApproveNew.tsx
rename to src/modals/NewApproveModal.tsx
diff --git a/src/modals/ModalVbnt.tsx b/src/modals/VbntModal.tsx
similarity index 100%
rename from src/modals/ModalVbnt.tsx
rename to src/modals/VbntModal.tsx
diff --git a/src/modals/WithdrawLiquidityWidget.tsx b/src/modals/WithdrawLiquidityModal.tsx
similarity index 94%
rename from src/modals/WithdrawLiquidityWidget.tsx
rename to src/modals/WithdrawLiquidityModal.tsx
index 9831bed0d..aa30a8d63 100644
--- a/src/modals/WithdrawLiquidityWidget.tsx
+++ b/src/modals/WithdrawLiquidityModal.tsx
@@ -4,15 +4,13 @@ import { PopoverV3 } from 'components/popover/PopoverV3';
import { useMemo } from 'react';
import { useAppSelector } from 'store';
-interface Props {
- isModalOpen: boolean;
- setIsModalOpen: (isOpen: boolean) => void;
-}
-
-export const WithdrawLiquidityWidget = ({
+export const WithdrawLiquidityModal = ({
isModalOpen,
setIsModalOpen,
-}: Props) => {
+}: {
+ isModalOpen: boolean;
+ setIsModalOpen: (isOpen: boolean) => void;
+}) => {
const { lockDuration } = useAppSelector(
(state) => state.v3Portfolio.withdrawalSettings
);
diff --git a/src/pages/Vote.tsx b/src/pages/Vote.tsx
index f2c2b3eaa..b7dacbb20 100644
--- a/src/pages/Vote.tsx
+++ b/src/pages/Vote.tsx
@@ -1,7 +1,7 @@
import { useWeb3React } from '@web3-react/core';
import { ReactComponent as IconLink } from 'assets/icons/link.svg';
import { CountdownTimer } from 'components/countdownTimer/CountdownTimer';
-import { ModalVbnt } from 'modals/ModalVbnt';
+import { ModalVbnt } from 'modals/VbntModal';
import { useCallback, useState } from 'react';
import { useEffect } from 'react';
import { useAppSelector } from 'store';
From d95c1119b24806afbbbec1ce2af9cfa3e53a030d Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Thu, 14 Jul 2022 16:13:41 +0300
Subject: [PATCH 05/29] more changes to align everything
---
src/elements/swapLimit/SwapLimit.tsx | 12 ++++++------
src/modals/ApproveModal.tsx | 22 ++++++++++------------
src/modals/CreatePoolModal.tsx | 2 +-
src/modals/DepositETHModal.tsx | 2 +-
src/modals/DurationModal.tsx | 12 +++++-------
src/modals/NewApproveModal.tsx | 20 +++++++++-----------
src/modals/V3ExternalHoldingsModal.tsx | 12 +++++-------
src/modals/V3WithdrawConfirmModal.tsx | 21 ++++++++++++---------
src/modals/VbntModal.tsx | 20 +++++++++-----------
src/pages/Vote.tsx | 4 ++--
10 files changed, 60 insertions(+), 67 deletions(-)
diff --git a/src/elements/swapLimit/SwapLimit.tsx b/src/elements/swapLimit/SwapLimit.tsx
index e9009f3a3..206532bec 100644
--- a/src/elements/swapLimit/SwapLimit.tsx
+++ b/src/elements/swapLimit/SwapLimit.tsx
@@ -3,7 +3,7 @@ import dayjs from 'utils/dayjs';
import BigNumber from 'bignumber.js';
import { InputField } from 'components/inputField/InputField';
import { TokenInputField } from 'components/tokenInputField/TokenInputField';
-import { ModalDuration } from 'modals/DurationModal';
+import { DurationModal } from 'modals/DurationModal';
import { Token, updateUserBalances } from 'services/observables/tokens';
import { ReactComponent as IconSync } from 'assets/icons/sync.svg';
import { classNameGenerator } from 'utils/pureFunctions';
@@ -17,7 +17,7 @@ import { useDispatch } from 'react-redux';
import { useWeb3React } from '@web3-react/core';
import { ethToken, wethToken } from 'services/web3/config';
import { useAppSelector } from 'store';
-import { ModalApprove } from 'modals/ApproveModal';
+import { ApproveModal } from 'modals/ApproveModal';
import {
ApprovalContract,
getNetworkContractApproval,
@@ -31,7 +31,7 @@ import {
} from 'components/button/Button';
import useAsyncEffect from 'use-async-effect';
import { useWalletConnect } from 'elements/walletConnect/useWalletConnect';
-import { ModalDepositETH } from 'modals/DepositETHModal';
+import { DepositETHModal } from 'modals/DepositETHModal';
import {
sendConversionEvent,
ConversionEvents,
@@ -510,13 +510,13 @@ export const SwapLimit = ({
Expires in
-
+
>
)}
-
-
{
+}: {
+ setIsOpen: Function;
+ isOpen: boolean;
+ amount: string;
+ fromToken?: Token;
+ handleApproved: Function;
+ waitForApproval?: boolean;
+ contract: ApprovalContract;
+}) => {
const dispatch = useDispatch();
if (!fromToken) return null;
diff --git a/src/modals/CreatePoolModal.tsx b/src/modals/CreatePoolModal.tsx
index f1c3894e6..eacfdcc83 100644
--- a/src/modals/CreatePoolModal.tsx
+++ b/src/modals/CreatePoolModal.tsx
@@ -20,7 +20,7 @@ import {
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
import { Pool } from 'services/observables/pools';
-export const ModalCreatePool = () => {
+export const CreatePoolModal = () => {
const account = useAppSelector((state) => state.user.account);
const [isOpen, setIsOpen] = useState(false);
diff --git a/src/modals/DepositETHModal.tsx b/src/modals/DepositETHModal.tsx
index c013c4e1a..e08a4a143 100644
--- a/src/modals/DepositETHModal.tsx
+++ b/src/modals/DepositETHModal.tsx
@@ -2,7 +2,7 @@ import { Modal } from 'components/modal/Modal';
import { ReactComponent as IconDeposit } from 'assets/icons/deposit.svg';
import { Button, ButtonSize } from 'components/button/Button';
-export const ModalDepositETH = ({
+export const DepositETHModal = ({
amount,
isOpen,
setIsOpen,
diff --git a/src/modals/DurationModal.tsx b/src/modals/DurationModal.tsx
index 5cf8edcf4..cbc79a8ce 100644
--- a/src/modals/DurationModal.tsx
+++ b/src/modals/DurationModal.tsx
@@ -8,20 +8,18 @@ import { ReactComponent as IconClock } from 'assets/icons/clock-solid.svg';
import { formatDuration } from 'utils/helperFunctions';
import { Button, ButtonSize } from 'components/button/Button';
-interface ModalDurationProps {
- duration: Duration;
- setDuration: Function;
-}
-
interface DurationItem {
id: string;
title: number;
}
-export const ModalDuration = ({
+export const DurationModal = ({
duration,
setDuration,
-}: ModalDurationProps) => {
+}: {
+ duration: Duration;
+ setDuration: Function;
+}) => {
const [isOpen, setIsOpen] = useState(false);
const [days, setDays] = useState(duration.days());
const [hours, setHours] = useState(duration.hours());
diff --git a/src/modals/NewApproveModal.tsx b/src/modals/NewApproveModal.tsx
index d227d9ab7..ba286d4e1 100644
--- a/src/modals/NewApproveModal.tsx
+++ b/src/modals/NewApproveModal.tsx
@@ -3,16 +3,6 @@ import { Token } from 'services/observables/tokens';
import { Button, ButtonSize } from 'components/button/Button';
import { Image } from 'components/image/Image';
-interface Props {
- isOpen: boolean;
- setIsOpen: Function;
- setApproval: Function;
- token: Token;
- amount: string;
- isLoading: boolean;
- onClose?: Function;
-}
-
export const ModalApproveNew = ({
isOpen,
setIsOpen,
@@ -21,7 +11,15 @@ export const ModalApproveNew = ({
amount,
isLoading,
onClose,
-}: Props) => {
+}: {
+ isOpen: boolean;
+ setIsOpen: Function;
+ setApproval: Function;
+ token: Token;
+ amount: string;
+ isLoading: boolean;
+ onClose?: Function;
+}) => {
return (
{
diff --git a/src/modals/V3ExternalHoldingsModal.tsx b/src/modals/V3ExternalHoldingsModal.tsx
index b68c9f8ba..76b2b6805 100644
--- a/src/modals/V3ExternalHoldingsModal.tsx
+++ b/src/modals/V3ExternalHoldingsModal.tsx
@@ -12,17 +12,15 @@ import { mockToken } from 'utils/mocked';
import { getMigrateFnByAmmProvider } from 'elements/earn/portfolio/v3/externalHoldings/externalHoldings';
import { shrinkToken } from 'utils/formulas';
-interface Props {
- position: ExternalHolding;
- isOpen: boolean;
- setIsOpen: (isOpen: boolean) => void;
-}
-
export const V3ExternalHoldingsModal = ({
position,
isOpen,
setIsOpen,
-}: Props) => {
+}: {
+ position: ExternalHolding;
+ isOpen: boolean;
+ setIsOpen: (isOpen: boolean) => void;
+}) => {
const [txBusy, setTxBusy] = useState(false);
const account = useAppSelector((state) => state.user.account);
const dispatch = useDispatch();
diff --git a/src/modals/V3WithdrawConfirmModal.tsx b/src/modals/V3WithdrawConfirmModal.tsx
index 950f445cf..8acdba438 100644
--- a/src/modals/V3WithdrawConfirmModal.tsx
+++ b/src/modals/V3WithdrawConfirmModal.tsx
@@ -11,20 +11,18 @@ import { bntToken } from 'services/web3/config';
import { Switch } from 'components/switch/Switch';
import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
-interface Props {
- isModalOpen: boolean;
- setIsModalOpen: (isOpen: boolean) => void;
- withdrawRequest: WithdrawalRequest;
- openCancelModal: (req: WithdrawalRequest) => void;
-}
-
export const V3WithdrawConfirmModal = memo(
({
isModalOpen,
setIsModalOpen,
withdrawRequest,
openCancelModal,
- }: Props) => {
+ }: {
+ isModalOpen: boolean;
+ setIsModalOpen: (isOpen: boolean) => void;
+ withdrawRequest: WithdrawalRequest;
+ openCancelModal: (req: WithdrawalRequest) => void;
+ }) => {
return (
{
+}: {
+ isModalOpen: boolean;
+ setIsModalOpen: (isOpen: boolean) => void;
+ withdrawRequest: WithdrawalRequest;
+ openCancelModal: (req: WithdrawalRequest) => void;
+}) => {
const {
ModalApprove,
token,
diff --git a/src/modals/VbntModal.tsx b/src/modals/VbntModal.tsx
index 738a737b8..c0a62fdaa 100644
--- a/src/modals/VbntModal.tsx
+++ b/src/modals/VbntModal.tsx
@@ -22,23 +22,21 @@ import { ApprovalContract } from 'services/web3/approval';
import { useAppSelector } from 'store';
import { Button, ButtonSize } from 'components/button/Button';
-interface ModalVbntProps {
- setIsOpen: Function;
- isOpen: boolean;
- token: Token;
- stake: boolean;
- stakeBalance?: string;
- onCompleted?: Function;
-}
-
-export const ModalVbnt = ({
+export const VbntModal = ({
setIsOpen,
isOpen,
token,
stake,
stakeBalance,
onCompleted,
-}: ModalVbntProps) => {
+}: {
+ setIsOpen: Function;
+ isOpen: boolean;
+ token: Token;
+ stake: boolean;
+ stakeBalance?: string;
+ onCompleted?: Function;
+}) => {
const account = useAppSelector((state) => state.user.account);
const [amount, setAmount] = useState('');
const percentages = useMemo(() => [25, 50, 75, 100], []);
diff --git a/src/pages/Vote.tsx b/src/pages/Vote.tsx
index b7dacbb20..caccf3395 100644
--- a/src/pages/Vote.tsx
+++ b/src/pages/Vote.tsx
@@ -1,7 +1,7 @@
import { useWeb3React } from '@web3-react/core';
import { ReactComponent as IconLink } from 'assets/icons/link.svg';
import { CountdownTimer } from 'components/countdownTimer/CountdownTimer';
-import { ModalVbnt } from 'modals/VbntModal';
+import { VbntModal } from 'modals/VbntModal';
import { useCallback, useState } from 'react';
import { useEffect } from 'react';
import { useAppSelector } from 'store';
@@ -255,7 +255,7 @@ export const Vote = () => {
{govToken && (
-
Date: Thu, 14 Jul 2022 16:31:17 +0300
Subject: [PATCH 06/29] moved modal v3 and full screen modal v3 and renamed
them, removed stale modal code
---
src/components/modal/Modal.stories.tsx | 38 -----
src/components/modal/Modal.tsx | 99 -----------
src/components/modal/ModalV3.tsx | 101 -----------
.../modalFullscreen/modalFullscreenV3.tsx | 67 --------
.../SearchableTokenList.tsx | 2 +-
src/components/slideover/Slideover.tsx | 2 +-
src/modals/ApproveModal.tsx | 4 +-
src/modals/CreatePoolModal.tsx | 2 +-
src/modals/DepositDisabledModal.tsx | 6 +-
src/modals/DepositETHModal.tsx | 4 +-
src/modals/DepositV3Modal.tsx | 6 +-
src/modals/DurationModal.tsx | 2 +-
src/modals/NewApproveModal.tsx | 4 +-
src/modals/SearchableTokenListModal.tsx | 9 +-
src/modals/SelectPoolModal.tsx | 7 +-
src/modals/UpgradeBntModal.tsx | 4 +-
src/modals/UpgradeTknModal.tsx | 4 +-
src/modals/V3BonusesModal.tsx | 2 +-
src/modals/V3ExternalHoldingsModal.tsx | 2 +-
src/modals/V3UnstakeModal.tsx | 6 +-
src/modals/V3WithdrawCancelModal.tsx | 2 +-
src/modals/V3WithdrawConfirmModal.tsx | 6 +-
src/modals/V3WithdrawModal.tsx | 6 +-
src/modals/VbntModal.tsx | 4 +-
src/modals/WalletConnectModal.tsx | 2 +-
src/modals/WithdrawLiquidityModal.tsx | 6 +-
src/modals/index.tsx | 160 ++++++++++++++++++
27 files changed, 205 insertions(+), 352 deletions(-)
delete mode 100644 src/components/modal/Modal.stories.tsx
delete mode 100644 src/components/modal/Modal.tsx
delete mode 100644 src/components/modal/ModalV3.tsx
delete mode 100644 src/components/modalFullscreen/modalFullscreenV3.tsx
diff --git a/src/components/modal/Modal.stories.tsx b/src/components/modal/Modal.stories.tsx
deleted file mode 100644
index 0996079a3..000000000
--- a/src/components/modal/Modal.stories.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { ComponentStory, ComponentMeta } from '@storybook/react';
-import { Modal } from './Modal';
-import { useState } from 'react';
-import { withDesign } from 'storybook-addon-designs';
-import { Button } from 'components/button/Button';
-
-export default {
- title: 'Components/Modal/Normal',
- component: Modal,
- decorators: [withDesign],
-} as ComponentMeta;
-
-const Template: ComponentStory = (args) => {
- const [isOpen, setIsOpen] = useState(false);
-
- return (
- <>
-
-
- some content
-
- >
- );
-};
-
-export const Open = Template.bind({});
-Open.args = {
- isOpen: true,
- setIsOpen: () => {},
- title: 'Modal title',
-};
-
-Open.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/fwADI9wqDrRAdlMX8EddCw/Bancor-v3?node-id=7879%3A257081',
- },
-};
diff --git a/src/components/modal/Modal.tsx b/src/components/modal/Modal.tsx
deleted file mode 100644
index 6dc132860..000000000
--- a/src/components/modal/Modal.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import { Dialog, Transition } from '@headlessui/react';
-import { Fragment } from 'react';
-import { ReactComponent as IconTimes } from 'assets/icons/times.svg';
-import { ReactComponent as IconChevron } from 'assets/icons/chevronRight.svg';
-
-interface ModalProps {
- title?: string;
- children: JSX.Element;
- separator?: boolean;
- titleElement?: any;
- setIsOpen: Function;
- isOpen: boolean;
- onBackClick?: Function;
- showBackButton?: boolean;
- onClose?: Function;
- large?: boolean;
-}
-
-export const Modal = ({
- title,
- children,
- separator,
- titleElement,
- setIsOpen,
- isOpen,
- showBackButton,
- onBackClick,
- onClose,
- large,
-}: ModalProps) => {
- return (
- <>
-
-
-
- >
- );
-};
diff --git a/src/components/modal/ModalV3.tsx b/src/components/modal/ModalV3.tsx
deleted file mode 100644
index 412e996bb..000000000
--- a/src/components/modal/ModalV3.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import { Dialog, Transition } from '@headlessui/react';
-import { Fragment, ReactNode } from 'react';
-import { ReactComponent as IconTimes } from 'assets/icons/times.svg';
-import { ReactComponent as IconChevron } from 'assets/icons/chevronRight.svg';
-
-interface Props {
- title?: string;
- children: JSX.Element;
- separator?: boolean;
- titleElement?: ReactNode;
- setIsOpen: (isOpen: boolean) => void;
- isOpen: boolean;
- onBackClick?: Function;
- showBackButton?: boolean;
- onClose?: Function;
- large?: boolean;
-}
-
-export const ModalV3 = ({
- title,
- children,
- separator,
- titleElement,
- setIsOpen,
- isOpen,
- showBackButton,
- onBackClick,
- onClose,
- large,
-}: Props) => {
- return (
- <>
-
-
-
- >
- );
-};
diff --git a/src/components/modalFullscreen/modalFullscreenV3.tsx b/src/components/modalFullscreen/modalFullscreenV3.tsx
deleted file mode 100644
index 161dde2be..000000000
--- a/src/components/modalFullscreen/modalFullscreenV3.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { Dialog, Transition } from '@headlessui/react';
-import { Fragment, memo, ReactNode } from 'react';
-import { ReactComponent as IconBancor } from 'assets/icons/bancor.svg';
-import { ReactComponent as IconTimes } from 'assets/icons/times.svg';
-
-interface Props {
- isOpen: boolean;
- setIsOpen: (isOpen: boolean) => void;
- children: ReactNode;
- title: string;
- titleElement?: ReactNode;
- className?: string;
-}
-
-const ModalFullscreenV3 = ({
- isOpen,
- setIsOpen,
- children,
- title,
- titleElement,
- className,
-}: Props) => {
- return (
- <>
-
-
-
- >
- );
-};
-
-export default memo(ModalFullscreenV3);
diff --git a/src/components/searchableTokenList/SearchableTokenList.tsx b/src/components/searchableTokenList/SearchableTokenList.tsx
index 1a7df341c..7b6da39e6 100644
--- a/src/components/searchableTokenList/SearchableTokenList.tsx
+++ b/src/components/searchableTokenList/SearchableTokenList.tsx
@@ -17,7 +17,7 @@ import { SearchableTokenListModal } from 'modals/SearchableTokenListModal';
interface SearchableTokenListProps {
onClick: Function;
isOpen: boolean;
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
excludedTokens?: string[];
includedTokens?: string[];
tokens: Token[];
diff --git a/src/components/slideover/Slideover.tsx b/src/components/slideover/Slideover.tsx
index 20469db39..a5a456b80 100644
--- a/src/components/slideover/Slideover.tsx
+++ b/src/components/slideover/Slideover.tsx
@@ -3,7 +3,7 @@ import { Dialog, Transition } from '@headlessui/react';
interface SlideoverProps {
isOpen: boolean;
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
children: JSX.Element;
}
diff --git a/src/modals/ApproveModal.tsx b/src/modals/ApproveModal.tsx
index 5d85ae46b..6c7b58c16 100644
--- a/src/modals/ApproveModal.tsx
+++ b/src/modals/ApproveModal.tsx
@@ -1,4 +1,3 @@
-import { Modal } from 'components/modal/Modal';
import { ReactComponent as IconLock } from 'assets/icons/lock.svg';
import {
addNotification,
@@ -15,6 +14,7 @@ import { wait } from 'utils/pureFunctions';
import { sendConversionApprovedEvent } from 'services/api/googleTagManager';
import { ErrorCode } from 'services/web3/types';
import { Button, ButtonSize } from 'components/button/Button';
+import { Modal } from 'modals';
export const ApproveModal = ({
setIsOpen,
@@ -25,7 +25,7 @@ export const ApproveModal = ({
waitForApproval,
contract,
}: {
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
isOpen: boolean;
amount: string;
fromToken?: Token;
diff --git a/src/modals/CreatePoolModal.tsx b/src/modals/CreatePoolModal.tsx
index eacfdcc83..69aede7c5 100644
--- a/src/modals/CreatePoolModal.tsx
+++ b/src/modals/CreatePoolModal.tsx
@@ -8,7 +8,6 @@ import { EthNetworks } from 'services/web3/types';
import { getNetworkVariables } from 'services/web3/config';
import { SelectToken } from 'components/selectToken/SelectToken';
import { InputField } from 'components/inputField/InputField';
-import { Modal } from 'components/modal/Modal';
import {
ownershipNotification,
poolCreateNotification,
@@ -19,6 +18,7 @@ import {
} from 'services/notifications/notifications';
import { Button, ButtonSize, ButtonVariant } from 'components/button/Button';
import { Pool } from 'services/observables/pools';
+import { Modal } from 'modals';
export const CreatePoolModal = () => {
const account = useAppSelector((state) => state.user.account);
diff --git a/src/modals/DepositDisabledModal.tsx b/src/modals/DepositDisabledModal.tsx
index 9a5245bd5..e5c783c6e 100644
--- a/src/modals/DepositDisabledModal.tsx
+++ b/src/modals/DepositDisabledModal.tsx
@@ -1,5 +1,5 @@
+import { Modal } from 'modals';
import { useState } from 'react';
-import { ModalV3 } from 'components/modal/ModalV3';
export const DepositDisabledModal = ({
renderButton,
@@ -15,11 +15,11 @@ export const DepositDisabledModal = ({
return (
<>
{renderButton(() => setIsOpen(true))}
-
+
Deposits are temporarily paused.
-
+
>
);
};
diff --git a/src/modals/DepositETHModal.tsx b/src/modals/DepositETHModal.tsx
index e08a4a143..712a857ce 100644
--- a/src/modals/DepositETHModal.tsx
+++ b/src/modals/DepositETHModal.tsx
@@ -1,6 +1,6 @@
-import { Modal } from 'components/modal/Modal';
import { ReactComponent as IconDeposit } from 'assets/icons/deposit.svg';
import { Button, ButtonSize } from 'components/button/Button';
+import { Modal } from 'modals';
export const DepositETHModal = ({
amount,
@@ -10,7 +10,7 @@ export const DepositETHModal = ({
}: {
amount: string;
isOpen: boolean;
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
onConfirm: Function;
}) => {
return (
diff --git a/src/modals/DepositV3Modal.tsx b/src/modals/DepositV3Modal.tsx
index 43683f6b3..7e798bf7e 100644
--- a/src/modals/DepositV3Modal.tsx
+++ b/src/modals/DepositV3Modal.tsx
@@ -6,7 +6,6 @@ import { useDispatch } from 'react-redux';
import { updatePortfolioData } from 'services/web3/v3/portfolio/helpers';
import { useAppSelector } from 'store';
import { useApproveModal } from 'hooks/useApproveModal';
-import { ModalV3 } from 'components/modal/ModalV3';
import { SwapSwitch } from 'elements/swapSwitch/SwapSwitch';
import { TokenInputPercentageV3 } from 'components/tokenInputPercentage/TokenInputPercentageV3';
import { ethToken } from 'services/web3/config';
@@ -30,6 +29,7 @@ import { ExpandableSection } from 'components/expandableSection/ExpandableSectio
import { ReactComponent as IconChevron } from 'assets/icons/chevronDown.svg';
import { getPoolsV3Map } from 'store/bancor/pool';
import { useWalletConnect } from 'elements/walletConnect/useWalletConnect';
+import { Modal } from 'modals';
const REWARDS_EXTRA_GAS = 130_000;
@@ -160,7 +160,7 @@ export const DepositV3Modal = ({
return (
<>
{renderButton(() => setIsOpen(true))}
-
{ApproveModal}
-
+
>
);
};
diff --git a/src/modals/DurationModal.tsx b/src/modals/DurationModal.tsx
index cbc79a8ce..6fd8bcfad 100644
--- a/src/modals/DurationModal.tsx
+++ b/src/modals/DurationModal.tsx
@@ -1,12 +1,12 @@
import { useState } from 'react';
import dayjs from 'utils/dayjs';
import { Dropdown } from 'components/dropdown/Dropdown';
-import { Modal } from 'components/modal/Modal';
import { Duration } from 'dayjs/plugin/duration';
import { ReactComponent as IconChevronDown } from 'assets/icons/chevronDown.svg';
import { ReactComponent as IconClock } from 'assets/icons/clock-solid.svg';
import { formatDuration } from 'utils/helperFunctions';
import { Button, ButtonSize } from 'components/button/Button';
+import { Modal } from 'modals';
interface DurationItem {
id: string;
diff --git a/src/modals/NewApproveModal.tsx b/src/modals/NewApproveModal.tsx
index ba286d4e1..51bbcdd82 100644
--- a/src/modals/NewApproveModal.tsx
+++ b/src/modals/NewApproveModal.tsx
@@ -1,7 +1,7 @@
-import { Modal } from 'components/modal/Modal';
import { Token } from 'services/observables/tokens';
import { Button, ButtonSize } from 'components/button/Button';
import { Image } from 'components/image/Image';
+import { Modal } from 'modals';
export const ModalApproveNew = ({
isOpen,
@@ -13,7 +13,7 @@ export const ModalApproveNew = ({
onClose,
}: {
isOpen: boolean;
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
setApproval: Function;
token: Token;
amount: string;
diff --git a/src/modals/SearchableTokenListModal.tsx b/src/modals/SearchableTokenListModal.tsx
index b8be1a442..a15db03c3 100644
--- a/src/modals/SearchableTokenListModal.tsx
+++ b/src/modals/SearchableTokenListModal.tsx
@@ -1,5 +1,4 @@
-import { Modal } from 'components/modal/Modal';
-import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
+import { Modal, ModalFullscreen } from 'modals';
import { isMobile } from 'react-device-detect';
export const SearchableTokenListModal = ({
@@ -12,12 +11,12 @@ export const SearchableTokenListModal = ({
manage: boolean;
setManage: Function;
isOpen: boolean;
- onClose: Function;
+ onClose: () => void;
children: JSX.Element;
}) => {
if (isMobile) {
return (
- {
if (manage) return setManage(false);
@@ -27,7 +26,7 @@ export const SearchableTokenListModal = ({
isOpen={isOpen}
>
{children}
-
+
);
}
diff --git a/src/modals/SelectPoolModal.tsx b/src/modals/SelectPoolModal.tsx
index 8045da32d..b423db99f 100644
--- a/src/modals/SelectPoolModal.tsx
+++ b/src/modals/SelectPoolModal.tsx
@@ -1,10 +1,9 @@
import { useState } from 'react';
import { isMobile } from 'react-device-detect';
-import { Modal } from '../components/modal/Modal';
import { Pool } from 'services/observables/pools';
-import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
import { InputField } from '../components/inputField/InputField';
import { Image } from 'components/image/Image';
+import { Modal, ModalFullscreen } from 'modals';
export const SelectPoolModal = ({
pools,
@@ -24,13 +23,13 @@ export const SelectPoolModal = ({
if (isMobile) {
return (
-
-
+
);
}
diff --git a/src/modals/UpgradeBntModal.tsx b/src/modals/UpgradeBntModal.tsx
index ca1304ee1..77eb496d4 100644
--- a/src/modals/UpgradeBntModal.tsx
+++ b/src/modals/UpgradeBntModal.tsx
@@ -1,4 +1,4 @@
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import {
fetchProtectedPositions,
ProtectedPosition,
@@ -31,7 +31,7 @@ export const UpgradeBntModal = ({
}: {
position: ProtectedPositionGrouped;
isOpen: boolean;
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
}) => {
const dispatch = useDispatch();
diff --git a/src/modals/UpgradeTknModal.tsx b/src/modals/UpgradeTknModal.tsx
index 544ccb467..800b0a64c 100644
--- a/src/modals/UpgradeTknModal.tsx
+++ b/src/modals/UpgradeTknModal.tsx
@@ -1,4 +1,4 @@
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import {
fetchProtectedPositions,
ProtectedPosition,
@@ -27,7 +27,7 @@ export const UpgradeTknModal = ({
}: {
positions: ProtectedPosition[];
isOpen: boolean;
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
}) => {
const dispatch = useDispatch();
const pools = useAppSelector((state) => state.pool.v2Pools);
diff --git a/src/modals/V3BonusesModal.tsx b/src/modals/V3BonusesModal.tsx
index 98f2b41a8..85a63f2fd 100644
--- a/src/modals/V3BonusesModal.tsx
+++ b/src/modals/V3BonusesModal.tsx
@@ -4,7 +4,7 @@ import { Button, ButtonVariant } from 'components/button/Button';
import { prettifyNumber } from 'utils/helperFunctions';
import { GroupedStandardReward } from 'store/portfolio/v3Portfolio';
import { shrinkToken } from 'utils/formulas';
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import { useCallback, useMemo, useState } from 'react';
import { TokensOverlap } from 'components/tokensOverlap/TokensOverlap';
import { ReactComponent as IconCheck } from 'assets/icons/check.svg';
diff --git a/src/modals/V3ExternalHoldingsModal.tsx b/src/modals/V3ExternalHoldingsModal.tsx
index 76b2b6805..b7da89db2 100644
--- a/src/modals/V3ExternalHoldingsModal.tsx
+++ b/src/modals/V3ExternalHoldingsModal.tsx
@@ -1,4 +1,4 @@
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import { useMemo, useState } from 'react';
import { ContractsApi } from 'services/web3/v3/contractsApi';
import { updatePortfolioData } from 'services/web3/v3/portfolio/helpers';
diff --git a/src/modals/V3UnstakeModal.tsx b/src/modals/V3UnstakeModal.tsx
index 7e42a030e..f38d8cf91 100644
--- a/src/modals/V3UnstakeModal.tsx
+++ b/src/modals/V3UnstakeModal.tsx
@@ -1,7 +1,6 @@
import { useState } from 'react';
import { useDispatch } from 'react-redux';
import { useAppSelector } from 'store';
-import { ModalV3 } from 'components/modal/ModalV3';
import { Holding } from 'store/portfolio/v3Portfolio.types';
import { prettifyNumber, toBigNumber } from 'utils/helperFunctions';
import { shrinkToken } from 'utils/formulas';
@@ -15,6 +14,7 @@ import {
} from 'services/notifications/notifications';
import { updatePortfolioData } from 'services/web3/v3/portfolio/helpers';
import { ErrorCode } from 'services/web3/types';
+import { Modal } from 'modals';
export const V3UnstakeModal = ({
holding,
@@ -84,7 +84,7 @@ export const V3UnstakeModal = ({
return (
<>
{renderButton(() => setIsOpen(true))}
-
)}
-
+
>
);
};
diff --git a/src/modals/V3WithdrawCancelModal.tsx b/src/modals/V3WithdrawCancelModal.tsx
index 767734849..aae61c656 100644
--- a/src/modals/V3WithdrawCancelModal.tsx
+++ b/src/modals/V3WithdrawCancelModal.tsx
@@ -1,6 +1,6 @@
import { WithdrawalRequest } from 'store/portfolio/v3Portfolio.types';
import { memo, useCallback, useMemo, useState } from 'react';
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import { Button, ButtonSize } from 'components/button/Button';
import { TokenBalanceLarge } from 'components/tokenBalance/TokenBalanceLarge';
import { toBigNumber } from 'utils/helperFunctions';
diff --git a/src/modals/V3WithdrawConfirmModal.tsx b/src/modals/V3WithdrawConfirmModal.tsx
index 8acdba438..74ed12beb 100644
--- a/src/modals/V3WithdrawConfirmModal.tsx
+++ b/src/modals/V3WithdrawConfirmModal.tsx
@@ -9,7 +9,7 @@ import { ReactComponent as IconInfo } from 'assets/icons/info.svg';
import { shrinkToken } from 'utils/formulas';
import { bntToken } from 'services/web3/config';
import { Switch } from 'components/switch/Switch';
-import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
+import { ModalFullscreen } from 'modals';
export const V3WithdrawConfirmModal = memo(
({
@@ -24,7 +24,7 @@ export const V3WithdrawConfirmModal = memo(
openCancelModal: (req: WithdrawalRequest) => void;
}) => {
return (
-
-
+
);
}
);
diff --git a/src/modals/V3WithdrawModal.tsx b/src/modals/V3WithdrawModal.tsx
index b429b69ac..1ac246de9 100644
--- a/src/modals/V3WithdrawModal.tsx
+++ b/src/modals/V3WithdrawModal.tsx
@@ -1,5 +1,4 @@
import { memo } from 'react';
-import ModalFullscreenV3 from 'components/modalFullscreen/modalFullscreenV3';
import V3WithdrawStep1 from 'elements/earn/portfolio/v3/initWithdraw/step1/V3WithdrawStep1';
import V3WithdrawStep3 from 'elements/earn/portfolio/v3/initWithdraw/step3/V3WithdrawStep3';
import V3WithdrawStep4 from 'elements/earn/portfolio/v3/initWithdraw/step4/V3WithdrawStep4';
@@ -7,6 +6,7 @@ import V3WithdrawStep2 from 'elements/earn/portfolio/v3/initWithdraw/step2/V3Wit
import { SwapSwitch } from 'elements/swapSwitch/SwapSwitch';
import { useV3WithdrawModal } from 'elements/earn/portfolio/v3/initWithdraw/useV3WithdrawModal';
import { Holding } from 'store/portfolio/v3Portfolio.types';
+import { ModalFullscreen } from 'modals';
const V3WithdrawModal = ({
isOpen,
@@ -35,7 +35,7 @@ const V3WithdrawModal = ({
} = useV3WithdrawModal({ setIsOpen });
return (
-
)}
-
+
);
};
diff --git a/src/modals/VbntModal.tsx b/src/modals/VbntModal.tsx
index c0a62fdaa..48512cd0c 100644
--- a/src/modals/VbntModal.tsx
+++ b/src/modals/VbntModal.tsx
@@ -1,4 +1,4 @@
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import { SwapSwitch } from 'elements/swapSwitch/SwapSwitch';
import { useMemo, useState } from 'react';
import { Token, updateUserBalances } from 'services/observables/tokens';
@@ -30,7 +30,7 @@ export const VbntModal = ({
stakeBalance,
onCompleted,
}: {
- setIsOpen: Function;
+ setIsOpen: (isOpen: boolean) => void;
isOpen: boolean;
token: Token;
stake: boolean;
diff --git a/src/modals/WalletConnectModal.tsx b/src/modals/WalletConnectModal.tsx
index 13d52a2ef..62346ef5a 100644
--- a/src/modals/WalletConnectModal.tsx
+++ b/src/modals/WalletConnectModal.tsx
@@ -1,4 +1,4 @@
-import { Modal } from 'components/modal/Modal';
+import { Modal } from 'modals';
import { UseWalletConnect } from '../elements/walletConnect/useWalletConnect';
import { WalletConnectModalList } from '../elements/walletConnect/WalletConnectModalList';
import { WalletConnectModalPending } from '../elements/walletConnect/WalletConnectModalPending';
diff --git a/src/modals/WithdrawLiquidityModal.tsx b/src/modals/WithdrawLiquidityModal.tsx
index aa30a8d63..109b23056 100644
--- a/src/modals/WithdrawLiquidityModal.tsx
+++ b/src/modals/WithdrawLiquidityModal.tsx
@@ -1,6 +1,6 @@
import { EmergencyInfo } from 'components/EmergencyInfo';
-import { ModalV3 } from 'components/modal/ModalV3';
import { PopoverV3 } from 'components/popover/PopoverV3';
+import { Modal } from 'modals';
import { useMemo } from 'react';
import { useAppSelector } from 'store';
@@ -21,7 +21,7 @@ export const WithdrawLiquidityModal = ({
);
return (
- setIsModalOpen(false)} isOpen={isModalOpen} large>
+ setIsModalOpen(false)} isOpen={isModalOpen} large>
Migrate to Bancor V3 to withdraw.
@@ -40,6 +40,6 @@ export const WithdrawLiquidityModal = ({
)}
/>
-
+
);
};
diff --git a/src/modals/index.tsx b/src/modals/index.tsx
index 261940fcf..3e50637f1 100644
--- a/src/modals/index.tsx
+++ b/src/modals/index.tsx
@@ -1,3 +1,163 @@
+import { Dialog, Transition } from '@headlessui/react';
+import { Fragment, ReactNode } from 'react';
+import { ReactComponent as IconTimes } from 'assets/icons/times.svg';
+import { ReactComponent as IconChevron } from 'assets/icons/chevronRight.svg';
+import { ReactComponent as IconBancor } from 'assets/icons/bancor.svg';
+
export const Modals = () => {
return <>>;
};
+
+export const Modal = ({
+ title,
+ children,
+ separator,
+ titleElement,
+ setIsOpen,
+ isOpen,
+ showBackButton,
+ onBackClick,
+ onClose,
+ large,
+}: {
+ title?: string;
+ children: JSX.Element;
+ separator?: boolean;
+ titleElement?: ReactNode;
+ setIsOpen: (isOpen: boolean) => void;
+ isOpen: boolean;
+ onBackClick?: Function;
+ showBackButton?: boolean;
+ onClose?: Function;
+ large?: boolean;
+}) => {
+ return (
+ <>
+
+
+
+ >
+ );
+};
+
+export const ModalFullscreen = ({
+ isOpen,
+ setIsOpen,
+ children,
+ title,
+ titleElement,
+ className,
+}: {
+ isOpen: boolean;
+ setIsOpen: (isOpen: boolean) => void;
+ children: ReactNode;
+ title: string;
+ titleElement?: ReactNode;
+ className?: string;
+}) => {
+ return (
+ <>
+
+
+
+ >
+ );
+};
From f8e61dd9aa70e4c86fc3b4b49e09b5b284fdfa20 Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Sun, 24 Jul 2022 16:39:32 +0300
Subject: [PATCH 07/29] moved limit approve to the hook
---
src/elements/swapLimit/SwapLimit.tsx | 178 +++++++++++---------
src/services/api/keeperDao.ts | 90 ++--------
src/services/notifications/notifications.ts | 53 ++++++
3 files changed, 159 insertions(+), 162 deletions(-)
diff --git a/src/elements/swapLimit/SwapLimit.tsx b/src/elements/swapLimit/SwapLimit.tsx
index 206532bec..cad79d276 100644
--- a/src/elements/swapLimit/SwapLimit.tsx
+++ b/src/elements/swapLimit/SwapLimit.tsx
@@ -9,19 +9,11 @@ import { ReactComponent as IconSync } from 'assets/icons/sync.svg';
import { classNameGenerator } from 'utils/pureFunctions';
import { getRate } from 'services/web3/swap/market';
import { KeeprDaoToken, swapLimit } from 'services/api/keeperDao';
-import {
- addNotification,
- NotificationType,
-} from 'store/notification/notification';
import { useDispatch } from 'react-redux';
import { useWeb3React } from '@web3-react/core';
import { ethToken, wethToken } from 'services/web3/config';
import { useAppSelector } from 'store';
-import { ApproveModal } from 'modals/ApproveModal';
-import {
- ApprovalContract,
- getNetworkContractApproval,
-} from 'services/web3/approval';
+import { ApprovalContract } from 'services/web3/approval';
import { prettifyNumber } from 'utils/helperFunctions';
import { calculatePercentageChange } from 'utils/formulas';
import {
@@ -36,7 +28,18 @@ import {
sendConversionEvent,
ConversionEvents,
setCurrentConversion,
+ sendConversionSuccessEvent,
+ sendConversionFailEvent,
} from 'services/api/googleTagManager';
+import { useApproveModal } from 'hooks/useApproveModal';
+import {
+ depositETHNotification,
+ rejectNotification,
+ swapLimitFailedNotification,
+ swapLimitNotification,
+} from 'services/notifications/notifications';
+import { depositWeth } from 'services/web3/swap/limit';
+import { ErrorCode } from 'services/web3/types';
enum Field {
from,
@@ -72,7 +75,6 @@ export const SwapLimit = ({
const [marketRate, setMarketRate] = useState(-1);
const [percentage, setPercentage] = useState('');
const [selPercentage, setSelPercentage] = useState(1);
- const [showApproveModal, setShowApproveModal] = useState(false);
const [showEthModal, setShowEthModal] = useState(false);
const [fromError, setFromError] = useState('');
const [rateWarning, setRateWarning] = useState({ type: '', msg: '' });
@@ -218,29 +220,6 @@ export const SwapLimit = ({
[toToken?.address, fromToken?.address]
);
- //Check if approval is required
- const checkApproval = async (token: Token) => {
- try {
- const isApprovalReq = await getNetworkContractApproval(
- token,
- ApprovalContract.ExchangeProxy,
- fromAmount
- );
- if (isApprovalReq) {
- sendConversionEvent(ConversionEvents.approvePop);
- setShowApproveModal(true);
- } else await handleSwap(true, token.address === wethToken);
- } catch (e: any) {
- dispatch(
- addNotification({
- type: NotificationType.error,
- title: 'Transaction Failed',
- msg: `${token.symbol} approval had failed. Please try again or contact support.`,
- })
- );
- }
- };
-
const updateETHandWETH = async () => {
if (!(toToken && account)) return;
@@ -250,11 +229,7 @@ export const SwapLimit = ({
await updateUserBalances();
};
- const handleSwap = async (
- approved: boolean = false,
- weth: boolean = false,
- showETHtoWETHModal: boolean = false
- ) => {
+ const handleSwap = async () => {
if (!account) {
handleWalletButtonClick();
return;
@@ -262,23 +237,73 @@ export const SwapLimit = ({
if (!(fromToken && toToken && fromAmount && toAmount)) return;
- if (showETHtoWETHModal) return setShowEthModal(true);
-
- if (!approved) return checkApproval(fromToken);
+ const tokenPair = fromToken.symbol + '/' + toToken?.symbol;
+ setCurrentConversion(
+ 'Limit',
+ chainId,
+ tokenPair,
+ fromToken.symbol,
+ toToken?.symbol,
+ fromAmount,
+ fromAmountUsd,
+ toAmount,
+ toAmountUsd,
+ fiatToggle,
+ rate,
+ percentage,
+ duration.asSeconds().toString()
+ );
+ sendConversionEvent(ConversionEvents.click);
- const notification = await swapLimit(
- weth ? { ...fromToken, address: wethToken } : fromToken,
+ await swapLimit(
+ fromToken.address === ethToken
+ ? { ...fromToken, address: wethToken }
+ : fromToken,
toToken,
fromAmount,
toAmount,
account,
duration,
- checkApproval
+ () => sendConversionEvent(ConversionEvents.wallet_req),
+ () => {
+ sendConversionSuccessEvent(fromToken.usdPrice);
+ swapLimitNotification(
+ dispatch,
+ fromToken,
+ toToken,
+ fromAmount,
+ toAmount
+ );
+ if (fromToken.address === ethToken) updateETHandWETH();
+ refreshLimit();
+ },
+ () => {
+ sendConversionFailEvent('User rejected transaction');
+ rejectNotification(dispatch);
+ },
+ (error: string) => {
+ sendConversionFailEvent(error);
+ swapLimitFailedNotification(
+ dispatch,
+ fromToken,
+ toToken,
+ fromAmount,
+ toAmount
+ );
+ }
);
+ };
- if (notification) dispatch(addNotification(notification));
- if (fromToken.address === ethToken) updateETHandWETH();
- refreshLimit();
+ const deposiEthWeth = async () => {
+ try {
+ const txHash = await depositWeth(fromAmount);
+ depositETHNotification(dispatch, fromAmount, txHash);
+ approveWETH();
+ } catch (e: any) {
+ if (e.code === ErrorCode.DeniedTx)
+ sendConversionFailEvent('User rejected transaction');
+ else sendConversionFailEvent(e.message);
+ }
};
const isSwapDisabled = () => {
@@ -339,26 +364,22 @@ export const SwapLimit = ({
return 'Trade';
};
- const handleSwapClick = () => {
- const tokenPair = fromToken.symbol + '/' + toToken?.symbol;
- setCurrentConversion(
- 'Limit',
- chainId,
- tokenPair,
- fromToken.symbol,
- toToken?.symbol,
- fromAmount,
- fromAmountUsd,
- toAmount,
- toAmountUsd,
- fiatToggle,
- rate,
- percentage,
- duration.asSeconds().toString()
- );
- sendConversionEvent(ConversionEvents.click);
- handleSwap(false, false, fromToken.address === ethToken);
- };
+ const [onStart, ModalApprove] = useApproveModal(
+ [{ amount: fromAmount, token: fromToken }],
+ handleSwap,
+ ApprovalContract.ExchangeProxy
+ );
+
+ const [approveWETH, ModalApproveWETH] = useApproveModal(
+ [
+ {
+ amount: fromAmount,
+ token: { ...fromToken, symbol: 'WETH', address: wethToken },
+ },
+ ],
+ handleSwap,
+ ApprovalContract.ExchangeProxy
+ );
return (
@@ -516,29 +537,20 @@ export const SwapLimit = ({
)}
-
- handleSwap(true, fromToken.address === ethToken)
- }
- contract={ApprovalContract.ExchangeProxy}
- />
+ {ModalApprove}
+ {ModalApproveWETH}
handleSwap(true)}
+ onConfirm={() => deposiEthWeth()}
/>
);
};
diff --git a/src/elements/trade/useTrade.ts b/src/elements/trade/useTrade.ts
index 41b2f0c02..8a5444dff 100644
--- a/src/elements/trade/useTrade.ts
+++ b/src/elements/trade/useTrade.ts
@@ -5,7 +5,7 @@ import { swap } from 'services/web3/swap/market';
import { ContractsApi } from 'services/web3/v3/contractsApi';
import { toBigNumber } from 'utils/helperFunctions';
import { TokenMinimal, updateUserBalances } from 'services/observables/tokens';
-import { useApproveModal } from 'hooks/useApproveModal';
+import { useApproval } from 'hooks/useApproval';
import { UseTradeWidgetReturn } from 'elements/trade/useTradeWidget';
import {
rejectNotification,
@@ -30,7 +30,6 @@ import {
import BigNumber from 'bignumber.js';
export interface UseTradeReturn {
- ApproveModal: JSX.Element;
isBusy: boolean;
handleSelectSwitch: () => void;
errorInsufficientBalance: string | undefined;
@@ -140,7 +139,7 @@ export const useTrade = ({
return;
}
setIsBusy(true);
- onStart();
+ startApprove();
};
const tokensToApprove = fromInput
@@ -153,22 +152,13 @@ export const useTrade = ({
? ContractsApi.BancorNetwork.contractAddress
: ApprovalContract.BancorNetwork;
- const [onStart, ApproveModal] = useApproveModal(
+ const startApprove = useApproval(
tokensToApprove,
handleTrade,
contractToApprove,
() => sendConversionEvent(Events.approvePop),
(isUnlimited) => {
sendConversionEvent(Events.approved, undefined, isUnlimited);
- },
- () => {
- setIsBusy(false);
- if (fromInput && toInput) {
- fromInput.setInputTkn('');
- fromInput.setInputFiat('');
- toInput.setInputTkn('');
- toInput.setInputFiat('');
- }
}
);
@@ -222,7 +212,6 @@ export const useTrade = ({
return {
handleCTAClick,
- ApproveModal,
isBusy,
handleSelectFrom,
handleSelectTo,
diff --git a/src/hooks/useApproval.tsx b/src/hooks/useApproval.tsx
new file mode 100644
index 000000000..2d7f720ff
--- /dev/null
+++ b/src/hooks/useApproval.tsx
@@ -0,0 +1,164 @@
+import { useCallback, useRef, useState } from 'react';
+import {
+ ApprovalContract,
+ getNetworkContractApproval,
+ setNetworkContractApproval,
+} from 'services/web3/approval';
+import {
+ addNotification,
+ NotificationType,
+} from 'store/notification/notification';
+import { useDispatch } from 'react-redux';
+import { ErrorCode } from 'services/web3/types';
+import { wait } from 'utils/pureFunctions';
+import { web3 } from 'services/web3';
+import { Events } from 'services/api/googleTagManager';
+import { useModal } from './useModal';
+import { ModalNames } from 'modals';
+import { TokenMinimal } from 'services/observables/tokens';
+
+interface TokenAmount {
+ token: TokenMinimal;
+ amount: string;
+}
+
+export const useApproval = (
+ tokens: TokenAmount[] = [],
+ onComplete: (txHash?: string) => void,
+ contract: ApprovalContract | string = ApprovalContract.BancorNetwork,
+ gtmPopupEvent?: (event: Events) => void,
+ gtmSelectEvent?: (isUnlimited: boolean) => void
+) => {
+ const { pushModal, popModal } = useModal();
+
+ const [tokenIndex, setTokenIndex] = useState(0);
+ const [isLoading, setIsLoading] = useState(false);
+ const ref = useRef([]);
+
+ const awaitConfirmation = useCallback(async () => {
+ const receipts = [];
+ for (const txHash of ref.current) {
+ try {
+ const receipt = await web3.provider.getTransactionReceipt(txHash);
+ receipts.push(receipt);
+ } catch (e: any) {
+ console.error('failed to getTransactionReceipt for approve token tx');
+ return;
+ }
+ }
+
+ const successCount = receipts.filter((r) => r && r.status).length;
+ if (successCount === ref.current.length) {
+ onComplete(ref.current.length > 0 ? ref.current[0] : undefined);
+ ref.current = [];
+ } else {
+ await wait(3000);
+ await awaitConfirmation();
+ }
+ }, [onComplete]);
+
+ const dispatch = useDispatch();
+
+ const startApprove = async () => {
+ if (tokens.length === 0) {
+ onComplete();
+ return;
+ }
+ await checkApprovalRequired();
+ };
+
+ if (tokens.length === 0) return startApprove;
+
+ const checkNextToken = async (index = tokenIndex): Promise => {
+ const nextIndex = index + 1;
+ const count = tokens.length;
+ if (count === nextIndex) {
+ return awaitConfirmation();
+ }
+ await wait(500);
+ setTokenIndex(nextIndex);
+ return checkApprovalRequired(nextIndex);
+ };
+
+ const checkApprovalRequired = async (tokenIndex: number = 0) => {
+ const { token, amount } = tokens[tokenIndex];
+ const isApprovalRequired = await getNetworkContractApproval(
+ token,
+ contract,
+ amount
+ );
+
+ if (!isApprovalRequired) {
+ return checkNextToken(tokenIndex);
+ }
+
+ gtmPopupEvent && gtmPopupEvent(Events.approvePop);
+
+ pushModal({
+ modalName: ModalNames.ApproveModal,
+ data: { isLoading, token, amount, approve },
+ });
+ };
+
+ const approve = async (amount?: string) => {
+ if (gtmSelectEvent) {
+ const isUnlimited = amount === undefined;
+ gtmSelectEvent(isUnlimited);
+ }
+ const { token } = tokens[tokenIndex];
+ try {
+ setIsLoading(true);
+ const txHash = await setNetworkContractApproval(
+ token,
+ contract,
+ amount,
+ true
+ );
+
+ ref.current = [...ref.current, txHash];
+ dispatch(
+ addNotification({
+ type: NotificationType.pending,
+ title: 'Pending Confirmation',
+ msg: `Approve ${tokens[tokenIndex].token.symbol} is pending confirmation`,
+ updatedInfo: {
+ successTitle: 'Transaction Confirmed',
+ successMsg: `${amount || 'Unlimited'} approval set for ${
+ tokens[tokenIndex].token.symbol
+ }`,
+ errorTitle: 'Transaction Failed',
+ errorMsg: `${tokens[tokenIndex].token.symbol} approval had failed. Please try again or contact support.`,
+ },
+ txHash,
+ })
+ );
+ popModal();
+ setIsLoading(false);
+
+ await checkNextToken();
+ } catch (e: any) {
+ if (e.code === ErrorCode.DeniedTx) {
+ dispatch(
+ addNotification({
+ type: NotificationType.error,
+ title: 'Transaction Rejected',
+ msg: 'You rejected the transaction. If this was by mistake, please try again.',
+ })
+ );
+ } else {
+ dispatch(
+ addNotification({
+ type: NotificationType.error,
+ title: 'Transaction Failed',
+ msg: `${tokens[tokenIndex].token.symbol} approval had failed. Please try again or contact support.`,
+ })
+ );
+ }
+
+ popModal();
+ setIsLoading(false);
+ }
+ };
+
+ return startApprove;
+};
diff --git a/src/modals/ApproveModal.tsx b/src/modals/ApproveModal.tsx
index 57f6a57ac..ea0d314ac 100644
--- a/src/modals/ApproveModal.tsx
+++ b/src/modals/ApproveModal.tsx
@@ -2,166 +2,29 @@ import { TokenMinimal } from 'services/observables/tokens';
import { Button, ButtonSize } from 'components/button/Button';
import { Image } from 'components/image/Image';
import { Modal, ModalNames } from 'modals';
-import { useState, useRef, useCallback } from 'react';
-import { useDispatch } from 'react-redux';
-import { web3 } from 'services/web3';
-import {
- ApprovalContract,
- getNetworkContractApproval,
- setNetworkContractApproval,
-} from 'services/web3/approval';
-import { ErrorCode } from 'services/web3/types';
-import {
- addNotification,
- NotificationType,
-} from 'store/notification/notification';
-import { wait } from 'utils/pureFunctions';
import { useModal } from 'hooks/useModal';
import { useAppSelector } from 'store';
import { getIsModalOpen, getModalData } from 'store/modals/modals';
-import { Events } from 'services/api/googleTagManager';
-interface TokenAmount {
+interface ApproveModalProps {
token: TokenMinimal;
amount: string;
-}
-
-interface ApproveModalProps {
- token_amounts: TokenAmount[];
- contract: ApprovalContract | string;
- onComplete: (txHash?: string) => void;
- gtmPopupEvent?: (event: Events) => void;
- gtmSelectEvent?: (isUnlimited: boolean) => void;
+ isLoading: boolean;
+ approve: (amount?: string) => void;
}
export const ApproveModal = () => {
- const dispatch = useDispatch();
- const ref = useRef([]);
- const [tokenIndex, setTokenIndex] = useState(0);
- const [isLoading, setIsLoading] = useState(false);
const { popModal } = useModal();
const isOpen = useAppSelector((state) =>
getIsModalOpen(state, ModalNames.ApproveModal)
);
const props = useAppSelector((state) =>
- getModalData(state, ModalNames.V3WithdrawConfirm)
+ getModalData(state, ModalNames.ApproveModal)
);
- const awaitConfirmation = useCallback(async () => {
- const receipts = [];
- for (const txHash of ref.current) {
- try {
- const receipt = await web3.provider.getTransactionReceipt(txHash);
- receipts.push(receipt);
- } catch (e: any) {
- console.error('failed to getTransactionReceipt for approve token tx');
- return;
- }
- }
-
- const successCount = receipts.filter((r) => r && r.status).length;
- if (successCount === ref.current.length) {
- props?.onComplete(ref.current.length > 0 ? ref.current[0] : undefined);
- ref.current = [];
- } else {
- await wait(3000);
- await awaitConfirmation();
- }
- }, [props?.onComplete]);
-
if (!props) return null;
- const { token_amounts, contract, gtmPopupEvent, gtmSelectEvent } = props;
- if (token_amounts.length === 0) return null;
-
- const checkNextToken = async (index = tokenIndex): Promise => {
- const nextIndex = index + 1;
- const count = token_amounts.length;
- if (count === nextIndex) {
- return awaitConfirmation();
- }
- await wait(500);
- setTokenIndex(nextIndex);
- return checkApprovalRequired(nextIndex);
- };
-
- const checkApprovalRequired = async (tokenIndex: number = 0) => {
- const { token, amount } = token_amounts[tokenIndex];
- const isApprovalRequired = await getNetworkContractApproval(
- token,
- contract,
- amount
- );
-
- if (!isApprovalRequired) {
- return checkNextToken(tokenIndex);
- }
-
- gtmPopupEvent && gtmPopupEvent(Events.approvePop);
- };
-
- const setApproval = async (amount?: string) => {
- if (gtmSelectEvent) {
- const isUnlimited = amount === undefined;
- gtmSelectEvent(isUnlimited);
- }
- const { token } = token_amounts[tokenIndex];
- try {
- setIsLoading(true);
- const txHash = await setNetworkContractApproval(
- token,
- contract,
- amount,
- true
- );
-
- ref.current = [...ref.current, txHash];
- dispatch(
- addNotification({
- type: NotificationType.pending,
- title: 'Pending Confirmation',
- msg: `Approve ${token_amounts[tokenIndex].token.symbol} is pending confirmation`,
- updatedInfo: {
- successTitle: 'Transaction Confirmed',
- successMsg: `${amount || 'Unlimited'} approval set for ${
- token_amounts[tokenIndex].token.symbol
- }`,
- errorTitle: 'Transaction Failed',
- errorMsg: `${token_amounts[tokenIndex].token.symbol} approval had failed. Please try again or contact support.`,
- },
- txHash,
- })
- );
- popModal();
- setIsLoading(false);
-
- await checkNextToken();
- } catch (e: any) {
- if (e.code === ErrorCode.DeniedTx) {
- dispatch(
- addNotification({
- type: NotificationType.error,
- title: 'Transaction Rejected',
- msg: 'You rejected the transaction. If this was by mistake, please try again.',
- })
- );
- } else {
- dispatch(
- addNotification({
- type: NotificationType.error,
- title: 'Transaction Failed',
- msg: `${token_amounts[tokenIndex].token.symbol} approval had failed. Please try again or contact support.`,
- })
- );
- }
-
- popModal();
- setIsLoading(false);
- }
- };
-
- const token = token_amounts[tokenIndex].token;
- const amount = token_amounts[tokenIndex].amount;
+ const { token, amount, isLoading, approve } = props;
return (
@@ -179,7 +42,7 @@ export const ApproveModal = () => {
Before you can proceed, you need to approve {token.symbol} spending.
setApproval()}
+ onClick={() => approve()}
size={ButtonSize.Full}
className="my-15"
disabled={isLoading}
@@ -190,7 +53,7 @@ export const ApproveModal = () => {
Want to approve before each transaction?
setApproval(amount)}
+ onClick={() => approve(amount)}
className="underline"
disabled={isLoading}
>
diff --git a/src/modals/DepositV3Modal.tsx b/src/modals/DepositV3Modal.tsx
index be5aa218c..93b4fd84c 100644
--- a/src/modals/DepositV3Modal.tsx
+++ b/src/modals/DepositV3Modal.tsx
@@ -5,7 +5,7 @@ import { ContractsApi } from 'services/web3/v3/contractsApi';
import { useDispatch } from 'react-redux';
import { updatePortfolioData } from 'services/web3/v3/portfolio/helpers';
import { useAppSelector } from 'store';
-import { useApproveModal } from 'hooks/useApproveModal';
+import { useApproval } from 'hooks/useApproval';
import { SwapSwitch } from 'elements/swapSwitch/SwapSwitch';
import { bntToken, ethToken } from 'services/web3/config';
import { prettifyNumber, toBigNumber } from 'utils/helperFunctions';
@@ -163,7 +163,7 @@ export const DepositV3Modal = () => {
}
};
- const [onStart, ApproveModal] = useApproveModal(
+ const startApprove = useApproval(
pool ? [{ amount: amount || '0', token: pool.reserveToken }] : [],
(approvalHash?: string) => deposit(approvalHash),
accessFullEarnings && pool?.latestProgram?.isActive
@@ -213,13 +213,13 @@ export const DepositV3Modal = () => {
deposit_display_currency: getCurrency(),
});
sendDepositEvent(DepositEvent.DepositAmountContinue);
- onStart();
+ startApprove();
} else if (shouldConnect) {
handleWalletButtonClick();
}
}, [
canDeposit,
- onStart,
+ startApprove,
shouldConnect,
handleWalletButtonClick,
accessFullEarnings,
@@ -468,7 +468,6 @@ export const DepositV3Modal = () => {
? 'Enter amount'
: `Deposit ${pool.name}`}
- {ApproveModal}
{!isBNT && }
>
diff --git a/src/modals/V3ExternalHoldingsModal.tsx b/src/modals/V3ExternalHoldingsModal.tsx
index 006194c0b..f949c3391 100644
--- a/src/modals/V3ExternalHoldingsModal.tsx
+++ b/src/modals/V3ExternalHoldingsModal.tsx
@@ -7,7 +7,7 @@ import { useAppSelector } from 'store';
import { useDispatch } from 'react-redux';
import { Button, ButtonSize } from 'components/button/Button';
import { TokenBalance } from 'components/tokenBalance/TokenBalance';
-import { useApproveModal } from 'hooks/useApproveModal';
+import { useApproval } from 'hooks/useApproval';
import { mockToken } from 'utils/mocked';
import { getMigrateFnByAmmProvider } from 'elements/earn/portfolio/v3/externalHoldings/externalHoldings';
import { shrinkToken } from 'utils/formulas';
@@ -90,7 +90,7 @@ export const V3ExternalHoldingsModal = () => {
}
};
- const [onStart, ApproveModal] = useApproveModal(
+ const startApprove = useApproval(
tokensToApprove,
migrate,
ContractsApi.BancorPortal.contractAddress
@@ -101,7 +101,7 @@ export const V3ExternalHoldingsModal = () => {
const handleButtonClick = async () => {
setTxBusy(true);
- onStart();
+ startApprove();
};
return (
@@ -146,8 +146,6 @@ export const V3ExternalHoldingsModal = () => {
{lockDurationInDays} day cooldown • {withdrawalFeeInPercent}%
withdrawal fee
-
- {ApproveModal}
);
diff --git a/src/modals/V3ManageProgramsModal.tsx b/src/modals/V3ManageProgramsModal.tsx
index 855ec6693..ecc97134e 100644
--- a/src/modals/V3ManageProgramsModal.tsx
+++ b/src/modals/V3ManageProgramsModal.tsx
@@ -19,7 +19,7 @@ import { useTknFiatInput } from 'elements/trade/useTknFiatInput';
import BigNumber from 'bignumber.js';
import dayjs from 'dayjs';
import { TradeWidgetInput } from 'elements/trade/TradeWidgetInput';
-import { useApproveModal } from 'hooks/useApproveModal';
+import { useApproval } from 'hooks/useApproval';
import { Modal, ModalNames } from 'modals';
import { useModal } from 'hooks/useModal';
import { getIsModalOpen, getModalData } from 'store/modals/modals';
@@ -128,7 +128,7 @@ export const V3ManageProgramsModal = () => {
}
};
- const [onStart, ApproveModal] = useApproveModal(
+ const startApprove = useApproval(
holding
? [
{
@@ -147,8 +147,8 @@ export const V3ManageProgramsModal = () => {
const onStartJoin = useCallback(() => {
setTxJoinBusy(true);
- onStart();
- }, [onStart]);
+ startApprove();
+ }, [startApprove]);
if (!holding) return null;
@@ -227,7 +227,6 @@ export const V3ManageProgramsModal = () => {
>
Add bn{holding.pool.reserveToken.symbol} to rewards program
- {ApproveModal}
) : (
diff --git a/src/modals/V3WithdrawConfirmModal.tsx b/src/modals/V3WithdrawConfirmModal.tsx
index 35a0f9a49..9ef4112ed 100644
--- a/src/modals/V3WithdrawConfirmModal.tsx
+++ b/src/modals/V3WithdrawConfirmModal.tsx
@@ -59,7 +59,6 @@ export const V3WithdrawConfirmContent = ({
openCancelModal: (req: WithdrawalRequest) => void;
}) => {
const {
- ModalApprove,
token,
loadingAmounts,
withdrawAmounts,
@@ -92,8 +91,6 @@ export const V3WithdrawConfirmContent = ({
return (
- {ModalApprove}
-
{
);
};
- const [checkApprove, ModalApprove] = useApproveModal(
+ const startApprove = useApproval(
props ? [{ amount: amount, token: props.token }] : [],
handleStakeUnstake,
ApprovalContract.Governance,
@@ -176,7 +176,7 @@ export const VbntModal = () => {
onClick={() => {
setAmount('');
popModal();
- if (stake) checkApprove();
+ if (stake) startApprove();
else handleStakeUnstake();
}}
disabled={stakeDisabled}
@@ -188,7 +188,6 @@ export const VbntModal = () => {
- {ModalApprove}
>
);
};
diff --git a/src/modals/index.tsx b/src/modals/index.tsx
index 84208abd6..2a129d299 100644
--- a/src/modals/index.tsx
+++ b/src/modals/index.tsx
@@ -21,6 +21,7 @@ import { V3ManageProgramsModal } from './V3ManageProgramsModal';
import { DepositV3Modal } from './DepositV3Modal';
import { SearchableTokenListModal } from './SearchableTokenListModal';
import { WithdrawLiquidityModal } from './WithdrawLiquidityModal';
+import { ApproveModal } from './ApproveModal';
export enum ModalNames {
ApproveModal,
@@ -47,6 +48,7 @@ export enum ModalNames {
export const Modals = () => {
return (
<>
+
From 01dca4ebd4b3ab5d5d8ead2db0f098168cf448c3 Mon Sep 17 00:00:00 2001
From: Ran Cohen
Date: Wed, 19 Oct 2022 15:57:01 +0300
Subject: [PATCH 29/29] fixed data not being transfer to some modals
---
.../v3/earningsTable/menu/V3EarningTableMenuMain.tsx | 2 +-
src/elements/earn/portfolio/v3/holdings/V3HoldingPage.tsx | 6 +++---
.../earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx | 2 +-
.../earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/elements/earn/portfolio/v3/earningsTable/menu/V3EarningTableMenuMain.tsx b/src/elements/earn/portfolio/v3/earningsTable/menu/V3EarningTableMenuMain.tsx
index 433e0d0ca..db1c79691 100644
--- a/src/elements/earn/portfolio/v3/earningsTable/menu/V3EarningTableMenuMain.tsx
+++ b/src/elements/earn/portfolio/v3/earningsTable/menu/V3EarningTableMenuMain.tsx
@@ -22,7 +22,7 @@ export const V3EarningTableMenuMain = memo(
const { pushModal } = useModal();
const handleWithdrawClick = useCallback(() => {
- pushModal({ modalName: ModalNames.V3Withdraw, data: holding });
+ pushModal({ modalName: ModalNames.V3Withdraw, data: { holding } });
}, [holding, pushModal]);
const handleBonusClick = useCallback(() => {
diff --git a/src/elements/earn/portfolio/v3/holdings/V3HoldingPage.tsx b/src/elements/earn/portfolio/v3/holdings/V3HoldingPage.tsx
index 7d37ca9a6..12ae9b872 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3HoldingPage.tsx
+++ b/src/elements/earn/portfolio/v3/holdings/V3HoldingPage.tsx
@@ -213,7 +213,7 @@ export const V3HoldingPage = () => {
onClick={() =>
pushModal({
modalName: ModalNames.DepositV3,
- data: pool,
+ data: { pool },
})
}
size={ButtonSize.ExtraSmall}
@@ -248,7 +248,7 @@ export const V3HoldingPage = () => {
onClick={() =>
pushModal({
modalName: ModalNames.V3ManagePrograms,
- data: holding,
+ data: { holding },
})
}
>
@@ -272,7 +272,7 @@ export const V3HoldingPage = () => {
onClick={() =>
pushModal({
modalName: ModalNames.V3Withdraw,
- data: holding,
+ data: { holding },
})
}
disabled={isDisabled}
diff --git a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx
index 56f50e220..c17e164d3 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx
+++ b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemUnstaked.tsx
@@ -112,7 +112,7 @@ export const V3HoldingsItemUnstaked = ({ holding }: { holding: Holding }) => {
onClick={() =>
pushModal({
modalName: ModalNames.V3Withdraw,
- data: holding,
+ data: { holding },
})
}
>
diff --git a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx
index 5aa3c7b1a..df1d2944d 100644
--- a/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx
+++ b/src/elements/earn/portfolio/v3/holdings/V3HoldingsItemWithdraw.tsx
@@ -25,7 +25,7 @@ export const V3HoldingsItemWithdraw = ({ holding }: { holding: Holding }) => {
onClick={() =>
pushModal({
modalName: ModalNames.V3Withdraw,
- data: holding,
+ data: { holding },
})
}
>