-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pool-routing): added /pools/[poolAddress] route, redirects to ma… (
#553) * feat(pool-routing): added /pools/[poolAddress] route, redirects to manage liquidity * feat(pool-routing): using poolId instead of address * feat(pool-routing): removed logs * feat: osmo poolid redirect * fix: redirect * chore: switch endpoints * feat(pool-routing): added osmo specific routing * feat(pool-routing): removing logs and added possibility of number or poolId for osmosis --------- Co-authored-by: nick134 <[email protected]>
- Loading branch information
1 parent
deba9ac
commit 06164b0
Showing
8 changed files
with
73 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ACTIVE_NETWORKS } from 'constants/index' | ||
import { promises as fs } from 'fs' | ||
import path from 'path' | ||
|
||
export async function getServerSideProps(context) { | ||
const { chainId, poolId } = context.params | ||
|
||
// Construct the file path to the JSON file in the public directory | ||
const filePath = path.join( | ||
process.cwd(), 'public', 'mainnet', ACTIVE_NETWORKS.mainnet[chainId], 'pools_list.json', | ||
) | ||
try { | ||
// Read the file from the filesystem | ||
const jsonData = await fs.readFile(filePath, 'utf8') | ||
const poolData = JSON.parse(jsonData) | ||
const pool = poolData.pools.find((pool) => (chainId === 'osmosis' ? (pool.osmo_pool_id === Number(poolId) || pool.pool_id === poolId) : pool.pool_id === poolId)) | ||
if (!pool) { | ||
// If no pool matches, redirect to a custom 404 page or another page | ||
if (!pool) { | ||
return { | ||
redirect: { | ||
destination: '/404', | ||
permanent: false, | ||
}, | ||
} | ||
} else { | ||
return { | ||
redirect: { | ||
destination: `/${chainId}/pools/manage_liquidity?poolId=${pool.pool_id}`, | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
} else { | ||
return { | ||
redirect: { | ||
destination: `/${chainId}/pools/manage_liquidity?poolId=${pool.pool_id}`, | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Failed to read pool data:', error); | ||
return { | ||
redirect: { | ||
destination: '/404', | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
export default function PoolAddressPage() { | ||
// This component does nothing because we're redirecting server-side | ||
return null | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters