diff --git a/src/components/navs/AppNav/AppNavNetworkSelect.vue b/src/components/navs/AppNav/AppNavNetworkSelect.vue index 2927f0e77..feb10e75e 100644 --- a/src/components/navs/AppNav/AppNavNetworkSelect.vue +++ b/src/components/navs/AppNav/AppNavNetworkSelect.vue @@ -67,7 +67,7 @@ const appNetworkSupported = computed((): boolean => { const activeNetwork = computed((): NetworkOption | undefined => allNetworks.value.find(network => { - if (!appNetworkSupported.value && network.id === 'ethereum') return true; + if (!appNetworkSupported.value && network.id === 'celo') return true; return isActive(network); }) ); diff --git a/src/composables/useNetwork.ts b/src/composables/useNetwork.ts index c391bd2a4..948bc4f57 100644 --- a/src/composables/useNetwork.ts +++ b/src/composables/useNetwork.ts @@ -125,12 +125,13 @@ export function handleNetworkSlug( ) { const networkFromUrl = networkFromSlug(networkSlug); const localStorageNetwork = networkFor( - localStorage.getItem('networkId') ?? '1' + localStorage.getItem('networkId') ?? '42220' ); if (!networkFromUrl) { // missing or incorrect network name -> next() withtout network change return noNetworkChangeCallback(); } + if (localStorageNetwork === networkFromUrl) { // if on the correct network -> next() return noNetworkChangeCallback(); diff --git a/src/plugins/router/nav-guards.ts b/src/plugins/router/nav-guards.ts index bb1a230e2..cc4f0f112 100644 --- a/src/plugins/router/nav-guards.ts +++ b/src/plugins/router/nav-guards.ts @@ -80,6 +80,15 @@ function applyNetworkSubdomainRedirect(router: Router): Router { */ function applyNetworkPathRedirects(router: Router): Router { router.beforeEach((to, from, next) => { + const networkSlugFromUrl = to.params.networkSlug?.toString() ?? ''; + + if ( + networkSlugFromUrl !== config[Network.CELO].slug && + networkSlugFromUrl !== config[Network.ALFAJORES].slug + ) { + console.debug(networkSlugFromUrl, config[Network.CELO].slug); + router.push({ path: `/${config[Network.CELO].slug}${to.fullPath}` }); + } if (redirecting.value) { next(); } else { @@ -106,6 +115,7 @@ function applyNetworkPathRedirects(router: Router): Router { '/risks', ]; const routerHandledRedirects = ['not-found', 'trade-redirect']; + if ( to.redirectedFrom?.fullPath && to.redirectedFrom?.fullPath.includes('/pool') @@ -121,7 +131,7 @@ function applyNetworkPathRedirects(router: Router): Router { } else { const newPath = to.redirectedFrom?.fullPath ?? to.fullPath; const newNetwork = newPath.includes('/pool') - ? config[Network.MAINNET].slug + ? config[Network.CELO].slug : networkSlug; router.push({ path: `/${newNetwork}${newPath}` }); } diff --git a/src/plugins/router/route-resolver.ts b/src/plugins/router/route-resolver.ts index 566823e63..ead3a7ae5 100644 --- a/src/plugins/router/route-resolver.ts +++ b/src/plugins/router/route-resolver.ts @@ -6,6 +6,6 @@ export interface RouteTo { export function resolveRoute(to: RouteTo) { if (!to?.name) throw new Error(`Provided route (${to}) must have name`); - return router.resolve({ name: to.name, params: { networkSlug: 'ethereum' } }) + return router.resolve({ name: to.name, params: { networkSlug: 'celo' } }) .matched[0].components?.default; }