Skip to content

Commit

Permalink
chore: Pool page redirects to new UI (#5897)
Browse files Browse the repository at this point in the history
* chore: Init

* chore: Add for add/remove pages
  • Loading branch information
garethfuller committed Sep 11, 2024
1 parent 3b6dff3 commit 3fd8071
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/composables/useNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const NETWORK_ID =
Network.MAINNET;
if (windowAvailable) localStorage.setItem('networkId', NETWORK_ID.toString());
export const networkSlug = config[NETWORK_ID].slug;
export const networkSlugV3 = config[NETWORK_ID].slugV3;
export const networkConfig = config[NETWORK_ID];

/**
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/arbitrum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'Arbitrum',
monorepoName: 'arbitrum',
slug: 'arbitrum',
slugV3: 'arbitrum',
network: 'arbitrum-one',
trustWalletNetwork: 'arbitrum',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/avalanche/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'Avalanche',
monorepoName: 'avalanche',
slug: 'avalanche',
slugV3: 'avalanche',
network: 'avalanche',
trustWalletNetwork: 'avalanchec',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'Base',
monorepoName: 'base',
slug: 'base',
slugV3: 'base',
network: 'base',
trustWalletNetwork: 'base',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/fraxtal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: Config = {
shortName: 'Fraxtal',
monorepoName: 'fraxtal',
slug: 'fraxtal',
slugV3: 'fraxtal',
network: 'fraxtal',
trustWalletNetwork: 'fraxtal',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/gnosis-chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const config: Config = {
shortName: 'Gnosis',
monorepoName: 'gnosis',
slug: 'gnosis-chain',
slugV3: 'gnosis',
network: 'gnosis-chain',
trustWalletNetwork: 'xdai',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/goerli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: Config = {
shortName: 'Goerli',
monorepoName: 'goerli',
slug: 'goerli',
slugV3: 'goerli',
network: 'goerli',
trustWalletNetwork: 'goerli',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/mainnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: Config = {
shortName: 'Mainnet',
monorepoName: 'mainnet',
slug: 'ethereum',
slugV3: 'ethereum',
network: 'mainnet',
trustWalletNetwork: 'ethereum',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: Config = {
shortName: 'Mode',
monorepoName: 'mode',
slug: 'mode',
slugV3: 'mode',
network: 'mode',
trustWalletNetwork: 'mode',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/optimism/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'Optimism',
monorepoName: 'optimism',
slug: 'optimism',
slugV3: 'optimism',
network: 'optimism',
trustWalletNetwork: 'optimism',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/polygon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'Polygon',
monorepoName: 'polygon',
slug: 'polygon',
slugV3: 'polygon',
network: 'polygon',
trustWalletNetwork: 'polygon',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/sepolia/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'Sepolia',
monorepoName: 'sepolia',
slug: 'sepolia',
slugV3: 'sepolia',
network: 'sepolia',
trustWalletNetwork: 'ethereum',
unknown: false,
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface Config {
shortName: string;
monorepoName?: string;
slug: string;
slugV3: string;
network: string;
trustWalletNetwork?: string;
unknown: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/zkevm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
shortName: 'zkEVM',
monorepoName: 'zkevm',
slug: 'zkevm',
slugV3: 'zkevm',
network: 'polygon-zkevm',
trustWalletNetwork: 'polygonzkevm',
unknown: false,
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/router/nav-guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
handleNetworkSlug,
networkFromSlug,
networkSlug,
networkSlugV3,
} from '@/composables/useNetwork';
import { isJoinsDisabled } from '@/composables/usePoolHelpers';
import config from '@/lib/config';
Expand All @@ -26,6 +27,7 @@ export function applyNavGuards(router: Router): Router {
router = applyPoolJoinRedirects(router);
router = applyMetaData(router);
router = applyVotingRedirects(router);
router = applyPoolPageRedirects(router);

return router;
}
Expand Down Expand Up @@ -187,3 +189,19 @@ function applyVotingRedirects(router: Router): Router {
});
return router;
}

/**
* Redirect to the pool page if the route is a pool page redirect.
*/
function applyPoolPageRedirects(router: Router): Router {
router.beforeEach((to, from, next) => {
if (to.name === 'pool') {
window.location.href = `https://balancer.fi/pools/${networkSlugV3}/v2/${to.params.id}`;
} else if (to.name === 'add-liquidity') {
window.location.href = `https://balancer.fi/pools/${networkSlugV3}/v2/${to.params.id}/add-liquidity`;
} else if (to.name === 'withdraw') {
window.location.href = `https://balancer.fi/pools/${networkSlugV3}/v2/${to.params.id}/remove-liquidity`;
} else next();
});
return router;
}

0 comments on commit 3fd8071

Please sign in to comment.