Skip to content

Commit 97d48f4

Browse files
committed
components structure refactor
1 parent 97738dc commit 97d48f4

File tree

195 files changed

+16872
-6324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+16872
-6324
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ src/locales/
2020
*.md
2121
*.log
2222
*.lock
23+
24+
src/components/transactions/Swap/backup/**/*.*

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@cowprotocol:registry=https://npm.pkg.github.com
2+
always-auth=true
3+
# registry=https://registry.npmjs.org/
4+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
"@aave/react": "0.6.1",
3737
"@amplitude/analytics-browser": "^2.13.0",
3838
"@bgd-labs/aave-address-book": "^4.31.0",
39-
"@cowprotocol/app-data": "^3.1.0",
40-
"@cowprotocol/cow-sdk": "6.3.3",
39+
"@cowprotocol/sdk-app-data": "4.1.3-pr-614-5b1d24e9.0",
40+
"@cowprotocol/cow-sdk": "7.0.10-pr-614-5b1d24e9.0",
41+
"@cowprotocol/sdk-flash-loans": "0.0.1-pr-614-5b1d24e9.0",
42+
"@cowprotocol/sdk-viem-adapter": "0.1.2-pr-614-5b1d24e9.0",
4143
"@emotion/cache": "11.10.3",
4244
"@emotion/react": "11.10.4",
4345
"@emotion/server": "latest",

pages/_app.page.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { AddressBlocked } from 'src/components/AddressBlocked';
1616
import { Meta } from 'src/components/Meta';
1717
import { TransactionEventHandler } from 'src/components/TransactionEventHandler';
1818
import { GasStationProvider } from 'src/components/transactions/GasStation/GasStationProvider';
19-
import { CowOrderToast } from 'src/components/transactions/Switch/cowprotocol/CowOrderToast';
19+
import { CowOrderToast } from 'src/components/transactions/Swap/modals/result/CowOrderToast';
2020
import { AppDataProvider } from 'src/hooks/app-data-provider/useAppDataProvider';
2121
import { CowOrderToastProvider } from 'src/hooks/useCowOrderToast';
2222
import { ModalContextProvider } from 'src/hooks/useModal';
@@ -31,16 +31,22 @@ import createEmotionCache from '../src/createEmotionCache';
3131
import { AppGlobalStyles } from '../src/layouts/AppGlobalStyles';
3232
import { LanguageProvider } from '../src/libs/LanguageProvider';
3333

34-
const SwitchModal = dynamic(() =>
35-
import('src/components/transactions/Switch/SwitchModal').then((module) => module.SwitchModal)
34+
const SwapModal = dynamic(() =>
35+
import('src/components/transactions/Swap/modals/SwapModal').then((module) => module.SwapModal)
3636
);
3737

3838
const CollateralSwapModal = dynamic(() =>
39-
import('src/components/transactions/Switch/CollateralSwap/CollateralSwapModal').then(
39+
import('src/components/transactions/Swap/modals/CollateralSwapModal').then(
4040
(module) => module.CollateralSwapModal
4141
)
4242
);
4343

44+
const DebtSwapModal = dynamic(() =>
45+
import('src/components/transactions/Swap/modals/DebtSwapModal').then(
46+
(module) => module.DebtSwapModal
47+
)
48+
);
49+
4450
const BridgeModal = dynamic(() =>
4551
import('src/components/transactions/Bridge/BridgeModal').then((module) => module.BridgeModal)
4652
);
@@ -53,16 +59,6 @@ const ClaimRewardsModal = dynamic(() =>
5359
(module) => module.ClaimRewardsModal
5460
)
5561
);
56-
const CollateralChangeModal = dynamic(() =>
57-
import('src/components/transactions/CollateralChange/CollateralChangeModal').then(
58-
(module) => module.CollateralChangeModal
59-
)
60-
);
61-
const DebtSwitchModal = dynamic(() =>
62-
import('src/components/transactions/DebtSwitch/DebtSwitchModal').then(
63-
(module) => module.DebtSwitchModal
64-
)
65-
);
6662
const EmodeModal = dynamic(() =>
6763
import('src/components/transactions/Emode/EmodeModal').then((module) => module.EmodeModal)
6864
);
@@ -170,19 +166,20 @@ export default function MyApp(props: MyAppProps) {
170166
<WithdrawModal />
171167
<BorrowModal />
172168
<RepayModal />
173-
<CollateralChangeModal />
174-
<DebtSwitchModal />
175169
<ClaimRewardsModal />
176170
<EmodeModal />
177171
<FaucetModal />
178172
<TransactionEventHandler />
179-
<SwitchModal />
180-
<CollateralSwapModal />
181173
<StakingMigrateModal />
182174
<BridgeModal />
183175
<ReadOnlyModal />
184-
<CowOrderToast />
176+
177+
{/* Swap Modals */}
178+
<SwapModal />
179+
<CollateralSwapModal />
180+
<DebtSwapModal />
185181
<CancelCowOrderModal />
182+
<CowOrderToast />
186183
</GasStationProvider>
187184
</AppDataProvider>
188185
</SharedDependenciesProvider>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Trans } from '@lingui/macro';
2+
3+
import { TextWithTooltip } from '../TextWithTooltip';
4+
5+
export const EstimatedCostsForLimitSwapTooltip = () => {
6+
return (
7+
<TextWithTooltip variant="caption" text={<Trans>Estimated Costs & Fees</Trans>}>
8+
<Trans>
9+
These are the estimated costs associated with your limit swap, including costs and fees.
10+
Consider these costs when setting your order amounts to help optimize execution and maximize
11+
your chances of filling the order.
12+
</Trans>
13+
</TextWithTooltip>
14+
);
15+
};

src/components/transactions/CollateralChange/CollateralChangeModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export const CollateralChangeModal = () => {
1111
const { type, close, args } = useModalContext() as ModalContextType<{
1212
underlyingAsset: string;
1313
}>;
14+
return null;
1415
return (
15-
<BasicModal open={type === ModalType.CollateralChange} setOpen={close}>
16+
<BasicModal open={type === ModalType.CollateralSwap} setOpen={close}>
1617
<ModalWrapper title={<Trans>Review tx</Trans>} underlyingAsset={args.underlyingAsset}>
1718
{(params) => (
1819
<UserAuthenticated>

src/components/transactions/DebtSwitch/DebtSwitchModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export const DebtSwitchModal = () => {
1111
const { type, close, args } = useModalContext() as ModalContextType<{
1212
underlyingAsset: string;
1313
}>;
14+
return null;
1415
return (
15-
<BasicModal open={type === ModalType.DebtSwitch} setOpen={close}>
16+
<BasicModal open={type === ModalType.DebtSwap} setOpen={close}>
1617
<ModalWrapper
1718
title={<Trans>Swap borrow position</Trans>}
1819
underlyingAsset={args.underlyingAsset}

src/components/transactions/FlowCommons/BaseSuccess.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const BaseSuccessView = ({
9595
onClick={handleClose}
9696
variant="contained"
9797
size="large"
98-
sx={{ minHeight: '50px', mb: '30px' }}
98+
sx={{ minHeight: '50px', mb: '0px' }}
9999
data-cy="closeButton"
100100
>
101101
<Trans>Ok, Close</Trans>

src/components/transactions/Repay/RepayModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { isFeatureEnabled } from 'src/utils/marketsAndNetworksConfig';
99

1010
import { BasicModal } from '../../primitives/BasicModal';
1111
import { ModalWrapper } from '../FlowCommons/ModalWrapper';
12-
import { CollateralRepayModalContent } from './CollateralRepayModalContent';
12+
import { RepayWithCollateralModalContent } from '../Swap/modals/request/RepayWithCollateralModalContent';
1313
import { RepayModalContent } from './RepayModalContent';
1414
import { RepayType, RepayTypeSelector } from './RepayTypeSelector';
1515

@@ -53,10 +53,10 @@ export const RepayModal = () => {
5353
)}
5454
{repayType === RepayType.BALANCE && <RepayModalContent {...params} user={user} />}
5555
{repayType === RepayType.COLLATERAL && (
56-
<CollateralRepayModalContent
56+
<RepayWithCollateralModalContent
5757
{...params}
5858
debtType={args.currentRateMode}
59-
user={user}
59+
underlyingAsset={args.underlyingAsset}
6060
/>
6161
)}
6262
</>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Trans } from '@lingui/macro';
2+
import { Button } from '@mui/material';
3+
4+
import { SwapState } from '../types';
5+
6+
type blockType = 'errors' | 'generic';
7+
const stateToBlockType = (state: SwapState): blockType => {
8+
if (state.error) return 'errors';
9+
return 'generic';
10+
};
11+
12+
export const ActionsBlocked: React.FC<{ state: SwapState }> = ({ state }) => {
13+
const blockType = stateToBlockType(state);
14+
15+
return (
16+
<Button
17+
variant="contained"
18+
disabled={true}
19+
size="large"
20+
sx={{ minHeight: '44px', marginTop: '20px', width: '100%' }}
21+
data-cy="actionButton"
22+
>
23+
{blockType === 'errors' ? <Trans>Check errors</Trans> : <Trans>Swap</Trans>}
24+
</Button>
25+
);
26+
};

0 commit comments

Comments
 (0)