Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/components/CCIP/Chain/Chain.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 10 additions & 8 deletions src/components/CCIP/Landing/ccip-landing.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ const supportedTokens = getAllSupportedTokens({

const tokens = Object.keys(supportedTokens).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were already doing sort here. Why do we have to do below too?! I would keep just once

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another thought.. Should we not actually sort it at the initial methods (so within the "getTokens" and "getNetworks" instead than do it in this individual files?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the .sort() is not needed here
about your second comment: because getAllSupportedTokens is a function that returns an object and it's not guaranteed to organize an object so I'm doing it here in the top level of the page
Also it's being used in other places all over the app not just CCIP so it will be hard to change this function


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 })
---
Expand Down
58 changes: 31 additions & 27 deletions src/components/CCIP/Token/Token.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ const supportedTokens = getAllSupportedTokens({

const tokens = Object.keys(supportedTokens).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same apply here


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,
Expand Down Expand Up @@ -72,25 +74,27 @@ const searchLanes = getSearchLanes({ environment })
<Table
client:only="react"
environment={environment}
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 || "",
}
})}
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 || "",
Expand Down
14 changes: 11 additions & 3 deletions src/config/data/ccip/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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) {
Expand Down