Skip to content

Commit ca75c8f

Browse files
authored
add destination chain selector (#1847)
* add destination chain selector * add destination chain selector * clarify ETH/MATIC/AVAX.. are native gas tokens
1 parent 98ea87b commit ca75c8f

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

src/features/ccip/components/supported-networks/ChainConfig.astro

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
import { ChainConfig } from "@config/data/ccip/types"
33
import { loadReferenceData, Environment, Version } from "@config/data/ccip/"
4-
import { SupportedChain } from "@config"
54
import { Address, CopyText, Accordion } from "@components"
65
import {
76
getTitle,
@@ -15,19 +14,23 @@ import LaneConfig from "./LaneConfig.astro"
1514
1615
type ConfigProps = {
1716
chainConfig: ChainConfig
18-
sourceChain: SupportedChain // key in SupportedChain
1917
sourceChainRefId: string // id in reference directory
2018
environment: Environment
2119
version: Version
2220
}
2321
24-
const { chainConfig, sourceChain, environment, sourceChainRefId, version } = Astro.props as ConfigProps
22+
const { chainConfig, environment, sourceChainRefId, version } = Astro.props as ConfigProps
2523
const { router, chainSelector, feeTokens } = chainConfig
26-
const explorerUrl = getExplorer(sourceChain)
27-
if (!explorerUrl) throw Error(`Explorer url not found for ${sourceChain}`)
24+
const sourceChainKey = directoryToSupportedChain(sourceChainRefId)
25+
const sourceChainTitle = getTitle(sourceChainKey)
26+
if (!sourceChainTitle) throw Error(`Title not found for chain ${sourceChainKey}`)
27+
const sourceChainIcon = getChainIcon(sourceChainKey)
28+
if (!sourceChainIcon) throw Error(`Icon not found for chain ${sourceChainKey}`)
29+
const explorerUrl = getExplorer(sourceChainKey)
30+
if (!explorerUrl) throw Error(`Explorer url not found for ${sourceChainKey}`)
2831
const routerExplorerUrl = getExplorerAddressUrl(explorerUrl)(router)
29-
const nativeCurrency = getNativeCurrency(sourceChain)
30-
if (!nativeCurrency) throw Error(`Native currency not found for ${sourceChain}`)
32+
const nativeCurrency = getNativeCurrency(sourceChainKey)
33+
if (!nativeCurrency) throw Error(`Native currency not found for ${sourceChainKey}`)
3134
// sort tokens - LINK first
3235
feeTokens.sort((feeToken1, feeToken2) => {
3336
if (feeToken1 === "LINK") {
@@ -68,11 +71,11 @@ const laneReferenceData = loadReferenceData({ environment, version }).lanesRefer
6871
<td><Address contractUrl={routerExplorerUrl} /></td>
6972
</tr>
7073
<tr>
71-
<td>Chain Selector</td>
74+
<td>Chain selector</td>
7275
<td><CopyText text={chainSelector} code /></td>
7376
</tr>
7477
<tr>
75-
<td>Supported Fee tokens</td>
78+
<td>Supported fee tokens</td>
7679
<td>
7780
<table>
7881
<tbody>
@@ -89,7 +92,10 @@ const laneReferenceData = loadReferenceData({ environment, version }).lanesRefer
8992
</tr>
9093
))
9194
}
92-
<tr><td>{nativeCurrency.symbol}</td></tr>
95+
<tr>
96+
<td>{nativeCurrency.symbol}</td>
97+
<td>Native gas token</td>
98+
</tr>
9399
</tbody>
94100
</table>
95101
</td>
@@ -100,35 +106,36 @@ const laneReferenceData = loadReferenceData({ environment, version }).lanesRefer
100106

101107
{
102108
Object.entries(laneReferenceData).map(([destinationChainRefId, laneConfig], index) => {
103-
const chainKey = directoryToSupportedChain(destinationChainRefId)
104-
const chainTitle = getTitle(chainKey)
105-
if (!chainTitle) throw Error(`Title not found for chain ${chainKey}`)
106-
const chainIcon = getChainIcon(chainKey)
107-
if (!chainIcon) throw Error(`Icon not found for chain ${chainKey}`)
108-
const sourceChainKey = directoryToSupportedChain(sourceChainRefId)
109-
const sourceChainTitle = getTitle(sourceChainKey)
110-
if (!sourceChainTitle) throw Error(`Title not found for chain ${sourceChainKey}`)
111-
const sourceChainIcon = getChainIcon(sourceChainKey)
112-
if (!sourceChainIcon) throw Error(`Icon not found for chain ${sourceChainKey}`)
113-
const id = `${sourceChain}-${chainKey}`.replace(/_/g, "-").toLowerCase()
109+
const destinationChainKey = directoryToSupportedChain(destinationChainRefId)
110+
const destinationChainTitle = getTitle(destinationChainKey)
111+
if (!destinationChainTitle) throw Error(`Title not found for chain ${destinationChainKey}`)
112+
const destinationChainIcon = getChainIcon(destinationChainKey)
113+
if (!destinationChainIcon) throw Error(`Icon not found for chain ${destinationChainKey}`)
114+
const id = `${sourceChainKey}-${destinationChainKey}`.replace(/_/g, "-").toLowerCase()
115+
const destinationChainSelector = loadReferenceData({ environment, version }).chainsReferenceData[
116+
destinationChainRefId
117+
].chainSelector
118+
if (!destinationChainSelector) throw Error(`Chain selector not found for chain ${destinationChainKey}`)
119+
114120
return (
115121
<>
116-
<Accordion title={`From ${sourceChainTitle} to ${chainTitle}`} contentReference={id}>
122+
<Accordion title={`From ${sourceChainTitle} to ${destinationChainTitle}`} contentReference={id}>
117123
<div slot="title" style="display: flex; align-items: center;">
118124
<div class="logo-title-container">
119125
<img src={sourceChainIcon} class="logo-image" />
120126
<span>{sourceChainTitle}</span>
121127
</div>
122128
<span class="arrow">➡️</span>
123129
<div class="logo-title-container">
124-
<img src={chainIcon} class="logo-image" />
125-
<span>{chainTitle}</span>
130+
<img src={destinationChainIcon} class="logo-image" />
131+
<span>{destinationChainTitle}</span>
126132
</div>
127133
</div>
128134
<LaneConfig
129135
laneConfig={laneConfig}
130-
sourceChain={sourceChain}
136+
sourceChain={sourceChainKey}
131137
sourceChainRefId={sourceChainRefId}
138+
destinationChainSelector={destinationChainSelector}
132139
environment={environment}
133140
version={version}
134141
/>

src/features/ccip/components/supported-networks/LaneConfig.astro

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { LaneConfig } from "@config/data/ccip/types"
33
import { loadReferenceData, Environment, Version } from "@config/data/ccip/"
44
import { SupportedChain } from "@config"
5-
import { Address, Aside } from "@components"
5+
import { Address, Aside, CopyText } from "@components"
66
import BigNumber from "bignumber.js"
77
import { utils } from "ethers"
88
import { getExplorer, getExplorerAddressUrl } from "@features/utils"
@@ -12,12 +12,14 @@ type ConfigProps = {
1212
laneConfig: LaneConfig
1313
sourceChain: SupportedChain // key in SupportedChain
1414
sourceChainRefId: string // id in reference directory
15+
destinationChainSelector: string
1516
environment: Environment
1617
version: Version
1718
}
1819
1920
const contactUrl = "https://chainlinkcommunity.typeform.com/ccip-form?typeform-source=docs.chain.link#ref_id=ccip_docs"
20-
const { laneConfig, sourceChain, environment, sourceChainRefId, version } = Astro.props as ConfigProps
21+
const { laneConfig, sourceChain, environment, sourceChainRefId, version, destinationChainSelector } =
22+
Astro.props as ConfigProps
2123
const { rateLimiterConfig, supportedTokens, onRamp } = laneConfig
2224
2325
const normalizeNumber = (bigNum: BigNumber, decimals: number = 18) => {
@@ -127,6 +129,10 @@ if (supportedTokens) {
127129
<td>OnRamp address</td>
128130
<td><Address contractUrl={onRampExplorerUrl} /></td>
129131
</tr>
132+
<tr>
133+
<td>Destination chain selector</td>
134+
<td><CopyText text={destinationChainSelector} code /></td>
135+
</tr>
130136
</tbody>
131137
</table>
132138
<br />

0 commit comments

Comments
 (0)