From 6503115f39f031d7e0ea526e11f11b048d52c37b Mon Sep 17 00:00:00 2001 From: "Mark S. Shenouda" Date: Mon, 21 Oct 2024 23:10:56 +0300 Subject: [PATCH 1/3] fix: Align Networks/Tokens/lanes Alphabetically --- src/components/CCIP/Chain/Chain.astro | 16 ++--- .../CCIP/Landing/ccip-landing.astro | 18 +++--- src/components/CCIP/Token/Token.astro | 58 ++++++++++--------- src/config/data/ccip/data.ts | 14 ++++- 4 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/components/CCIP/Chain/Chain.astro b/src/components/CCIP/Chain/Chain.astro index bdf535fed6a..4819d3c2fbd 100644 --- a/src/components/CCIP/Chain/Chain.astro +++ b/src/components/CCIP/Chain/Chain.astro @@ -25,14 +25,16 @@ const networks = getAllNetworks({ filter: environment }) const allTokens = getTokensOfChain({ chain: network?.chain || "", filter: environment, -}).map((token) => { - const logo = getTokenIconUrl(token) || "" - return { - name: token, - logo, - totalNetworks: networks.length, // Add totalNetworks property - } }) + .map((token) => { + const logo = getTokenIconUrl(token) || "" + return { + name: token, + logo, + totalNetworks: networks.length, // Add totalNetworks property + } + }) + .sort((a, b) => a.name.localeCompare(b.name)) const lanes = await getAllNetworkLanes({ environment: environment, diff --git a/src/components/CCIP/Landing/ccip-landing.astro b/src/components/CCIP/Landing/ccip-landing.astro index 55f43b3ee62..a43c4ee979f 100644 --- a/src/components/CCIP/Landing/ccip-landing.astro +++ b/src/components/CCIP/Landing/ccip-landing.astro @@ -29,14 +29,16 @@ const supportedTokens = getAllSupportedTokens({ const tokens = Object.keys(supportedTokens).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" })) -const allTokens = tokens.map((token) => { - const logo = getTokenIconUrl(token) || "" - return { - name: token, - logo, - totalNetworks: getChainsOfToken({ token, filter: environment }).length, - } -}) +const allTokens = tokens + .map((token) => { + const logo = getTokenIconUrl(token) || "" + return { + name: token, + logo, + totalNetworks: getChainsOfToken({ token, filter: environment }).length, + } + }) + .sort((a, b) => a.name.localeCompare(b.name)) const searchLanes = getSearchLanes({ environment }) --- diff --git a/src/components/CCIP/Token/Token.astro b/src/components/CCIP/Token/Token.astro index ad99e7ca3e8..449b893cb78 100644 --- a/src/components/CCIP/Token/Token.astro +++ b/src/components/CCIP/Token/Token.astro @@ -28,14 +28,16 @@ const supportedTokens = getAllSupportedTokens({ const tokens = Object.keys(supportedTokens).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" })) -const allTokens = tokens.map((token) => { - const logo = getTokenIconUrl(token) || "" - return { - name: token, - logo, - totalNetworks: getChainsOfToken({ token, filter: environment }).length, - } -}) +const allTokens = tokens + .map((token) => { + const logo = getTokenIconUrl(token) || "" + return { + name: token, + logo, + totalNetworks: getChainsOfToken({ token, filter: environment }).length, + } + }) + .sort((a, b) => a.name.localeCompare(b.name)) const data = getTokenData({ environment: environment, @@ -72,25 +74,27 @@ const searchLanes = getSearchLanes({ environment }) { - const directory = directoryToSupportedChain(key || "") - const title = getTitle(directory) || "" - const networkLogo = getChainIcon(directory) || "" - const explorerUrl = getExplorer(directory) - return { - name: title, - token: data[key].name || "", - key: key, - logo: networkLogo, - symbol: token, - tokenLogo: logo || "", - decimals: data[key].decimals || 0, - tokenAddress: data[key].tokenAddress || "", - tokenPoolType: data[key].poolType || "", - tokenPoolAddress: data[key].poolAddress || "", - explorerUrl: explorerUrl || "", - } - })} + networks={Object.keys(data) + .map((key) => { + const directory = directoryToSupportedChain(key || "") + const title = getTitle(directory) || "" + const networkLogo = getChainIcon(directory) || "" + const explorerUrl = getExplorer(directory) + return { + name: title, + token: data[key].name || "", + key: key, + logo: networkLogo, + symbol: token, + tokenLogo: logo || "", + decimals: data[key].decimals || 0, + tokenAddress: data[key].tokenAddress || "", + tokenPoolType: data[key].poolType || "", + tokenPoolAddress: data[key].poolAddress || "", + explorerUrl: explorerUrl || "", + } + }) + .sort((a, b) => a.name.localeCompare(b.name))} lanes={lanes} token={{ name: data[Object.keys(data)[0]]?.name || "", diff --git a/src/config/data/ccip/data.ts b/src/config/data/ccip/data.ts index 8b4eff5d0eb..19cc6e0a3a1 100644 --- a/src/config/data/ccip/data.ts +++ b/src/config/data/ccip/data.ts @@ -426,7 +426,7 @@ export const getAllNetworks = ({ filter }: { filter: Environment }) => { }) } - return allChains + return allChains.sort((a, b) => a.name.localeCompare(b.name)) } export const getNetwork = ({ chain, filter }: { chain: string; filter: Environment }) => { @@ -531,7 +531,8 @@ export const getAllNetworkLanes = async ({ status: operationalData[lane] || undefined, } }) - return lanesData + + return lanesData.sort((a, b) => a.name.localeCompare(b.name)) } export function getAllTokenLanes({ @@ -632,7 +633,14 @@ export function getSearchLanes({ environment }: { environment: Environment }) { } } - return allLanes + // sorting lanes by source chain name and destination chain name + return allLanes.sort((a, b) => { + if (a.sourceNetwork.name > b.sourceNetwork.name) return 1 + if (a.sourceNetwork.name < b.sourceNetwork.name) return -1 + if (a.destinationNetwork.name > b.destinationNetwork.name) return 1 + if (a.destinationNetwork.name < b.destinationNetwork.name) return -1 + return 0 + }) } export async function getOperationalState(chain: string, site: string) { From 7df0bafe54c32c62a5212be2af9a1d86b0df8481 Mon Sep 17 00:00:00 2001 From: "Mark S. Shenouda" Date: Tue, 22 Oct 2024 14:42:50 +0300 Subject: [PATCH 2/3] fix: remove unused .sort() --- src/components/CCIP/Landing/ccip-landing.astro | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/CCIP/Landing/ccip-landing.astro b/src/components/CCIP/Landing/ccip-landing.astro index a43c4ee979f..55f43b3ee62 100644 --- a/src/components/CCIP/Landing/ccip-landing.astro +++ b/src/components/CCIP/Landing/ccip-landing.astro @@ -29,16 +29,14 @@ const supportedTokens = getAllSupportedTokens({ const tokens = Object.keys(supportedTokens).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" })) -const allTokens = tokens - .map((token) => { - const logo = getTokenIconUrl(token) || "" - return { - name: token, - logo, - totalNetworks: getChainsOfToken({ token, filter: environment }).length, - } - }) - .sort((a, b) => a.name.localeCompare(b.name)) +const allTokens = tokens.map((token) => { + const logo = getTokenIconUrl(token) || "" + return { + name: token, + logo, + totalNetworks: getChainsOfToken({ token, filter: environment }).length, + } +}) const searchLanes = getSearchLanes({ environment }) --- From da8171c2d8189a12db59e01ebbfd8140bfcc8243 Mon Sep 17 00:00:00 2001 From: "Mark S. Shenouda" Date: Tue, 22 Oct 2024 14:44:16 +0300 Subject: [PATCH 3/3] fix: remove unused .sort() in Token.astro --- src/components/CCIP/Token/Token.astro | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/CCIP/Token/Token.astro b/src/components/CCIP/Token/Token.astro index 449b893cb78..4dd443ef653 100644 --- a/src/components/CCIP/Token/Token.astro +++ b/src/components/CCIP/Token/Token.astro @@ -28,16 +28,14 @@ const supportedTokens = getAllSupportedTokens({ const tokens = Object.keys(supportedTokens).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" })) -const allTokens = tokens - .map((token) => { - const logo = getTokenIconUrl(token) || "" - return { - name: token, - logo, - totalNetworks: getChainsOfToken({ token, filter: environment }).length, - } - }) - .sort((a, b) => a.name.localeCompare(b.name)) +const allTokens = tokens.map((token) => { + const logo = getTokenIconUrl(token) || "" + return { + name: token, + logo, + totalNetworks: getChainsOfToken({ token, filter: environment }).length, + } +}) const data = getTokenData({ environment: environment,