Skip to content

Commit 5caf6ec

Browse files
committed
rate limits mocks
1 parent 21af97b commit 5caf6ec

File tree

38 files changed

+75595
-36171
lines changed

38 files changed

+75595
-36171
lines changed

public/api/ccip/v1/openapi.json

Lines changed: 1147 additions & 15 deletions
Large diffs are not rendered by default.

src/__mocks__/rate-limits-mainnet.json

Lines changed: 55946 additions & 0 deletions
Large diffs are not rendered by default.

src/__mocks__/rate-limits-testnet.json

Lines changed: 7465 additions & 0 deletions
Large diffs are not rendered by default.

src/components/CCIP/Chain/ChainTokenGrid.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ function ChainTokenGrid({ tokens, network, environment }: ChainTokenGridProps) {
5353
tokenSymbol: data[key].symbol,
5454
tokenDecimals: data[key].decimals,
5555
tokenAddress: data[key].tokenAddress,
56-
tokenPoolType: data[key].poolType,
57-
tokenPoolAddress: data[key].poolAddress || "",
56+
tokenPoolType: data[key].pool.type,
57+
tokenPoolAddress: data[key].pool.address || "",
58+
tokenPoolVersion: data[key].pool.version || "",
5859
explorer: network.explorer,
5960
chainType,
6061
}

src/components/CCIP/Drawer/LaneDrawer.tsx

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import Address from "~/components/AddressReact.tsx"
22
import "../Tables/Table.css"
33
import { Environment, LaneConfig, LaneFilter, Version } from "~/config/data/ccip/types.ts"
44
import { getNetwork, getTokenData } from "~/config/data/ccip/data.ts"
5-
import { displayCapacity, determineTokenMechanism, isTokenPaused } from "~/config/data/ccip/utils.ts"
5+
import { determineTokenMechanism } from "~/config/data/ccip/utils.ts"
66
import { useState } from "react"
77
import LaneDetailsHero from "../ChainHero/LaneDetailsHero.tsx"
88
import { getExplorerAddressUrl, getTokenIconUrl, fallbackTokenIconUrl } from "~/features/utils/index.ts"
99
import TableSearchInput from "../Tables/TableSearchInput.tsx"
10-
import RateTooltip from "../Tooltip/RateTooltip.tsx"
1110
import { Tooltip } from "~/features/common/Tooltip/Tooltip.tsx"
1211
import { ChainType, ExplorerInfo } from "@config/types.ts"
1312

@@ -63,7 +62,7 @@ function LaneDrawer({
6362
<div className="ccip-table__filters">
6463
<div>
6564
<div className="ccip-table__filters-title">
66-
Tokens <span>({lane?.supportedTokens ? Object.keys(lane.supportedTokens).length : 0})</span>
65+
Tokens <span>({lane?.supportedTokens ? lane.supportedTokens.length : 0})</span>
6766
</div>
6867
</div>
6968
<TableSearchInput search={search} setSearch={setSearch} />
@@ -124,8 +123,8 @@ function LaneDrawer({
124123
</thead>
125124
<tbody>
126125
{lane.supportedTokens &&
127-
Object.keys(lane.supportedTokens)
128-
?.filter((token) => token.toLowerCase().includes(search.toLowerCase()))
126+
lane.supportedTokens
127+
.filter((token) => token.toLowerCase().includes(search.toLowerCase()))
129128
.map((token, index) => {
130129
const data = getTokenData({
131130
environment,
@@ -135,13 +134,10 @@ function LaneDrawer({
135134
if (!Object.keys(data).length) return null
136135
const logo = getTokenIconUrl(token)
137136

138-
// Check if token is paused
139-
const tokenPaused = isTokenPaused(
140-
data[sourceNetwork.key].decimals,
141-
lane.supportedTokens?.[token]?.rateLimiterConfig?.[
142-
inOutbound === LaneFilter.Inbound ? "in" : "out"
143-
]
144-
)
137+
// TODO: Fetch rate limits from API for both inbound and outbound
138+
// Token pause detection requires rate limiter data from API
139+
// A token is paused when rate limit capacity is 0
140+
const tokenPaused = false
145141

146142
return (
147143
<tr key={index} className={tokenPaused ? "ccip-table__row--paused" : ""}>
@@ -179,35 +175,25 @@ function LaneDrawer({
179175
<td>
180176
{inOutbound === LaneFilter.Outbound
181177
? determineTokenMechanism(
182-
data[sourceNetwork.key].poolType,
183-
data[destinationNetwork.key].poolType
178+
data[sourceNetwork.key].pool.type,
179+
data[destinationNetwork.key].pool.type
184180
)
185181
: determineTokenMechanism(
186-
data[destinationNetwork.key].poolType,
187-
data[sourceNetwork.key].poolType
182+
data[destinationNetwork.key].pool.type,
183+
data[sourceNetwork.key].pool.type
188184
)}
189185
</td>
190186

191187
<td>
192-
{lane.supportedTokens &&
193-
displayCapacity(
194-
data[sourceNetwork.key].decimals,
195-
token,
196-
lane.supportedTokens[token]?.rateLimiterConfig?.[
197-
inOutbound === LaneFilter.Inbound ? "in" : "out"
198-
]
199-
)}
188+
{/* TODO: Fetch rate limits from API for both inbound and outbound
189+
GET /api/ccip/v1/lanes/by-internal-id/{source}/{destination}/supported-tokens?environment={environment}
190+
Response will contain both standard and custom rate limits per token */}
191+
Disabled
200192
</td>
201193
<td className="rate-tooltip-cell">
202-
{lane.supportedTokens && (
203-
<RateTooltip
204-
destinationLane={lane.supportedTokens[token]}
205-
inOutbound={inOutbound}
206-
symbol={token}
207-
decimals={data[sourceNetwork.key].decimals}
208-
position="left"
209-
/>
210-
)}
194+
{/* TODO: Fetch rate limits from API for both inbound and outbound
195+
Display refill rate from standard.in/out or custom.in/out based on inOutbound filter */}
196+
Disabled
211197
</td>
212198
</tr>
213199
)
@@ -217,8 +203,9 @@ function LaneDrawer({
217203
</div>
218204
<div className="ccip-table__notFound">
219205
{lane.supportedTokens &&
220-
Object.keys(lane.supportedTokens)?.filter((lane) => lane.toLowerCase().includes(search.toLowerCase()))
221-
.length === 0 && <>No tokens found</>}
206+
lane.supportedTokens.filter((token) => token.toLowerCase().includes(search.toLowerCase())).length === 0 && (
207+
<>No tokens found</>
208+
)}
222209
</div>
223210
</div>
224211
</>

src/components/CCIP/Drawer/TokenDrawer.tsx

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@ import {
88
SupportedTokenConfig,
99
Version,
1010
LaneFilter,
11-
displayCapacity,
1211
determineTokenMechanism,
1312
PoolType,
1413
getTokenData,
1514
LaneConfig,
1615
} from "~/config/data/ccip/index.ts"
17-
import { isTokenPaused } from "~/config/data/ccip/utils.ts"
1816
import { useState } from "react"
1917
import { ChainType, ExplorerInfo, SupportedChain } from "~/config/index.ts"
2018
import LaneDrawer from "../Drawer/LaneDrawer.tsx"
2119
import TableSearchInput from "../Tables/TableSearchInput.tsx"
2220
import Tabs from "../Tables/Tabs.tsx"
2321
import { Tooltip } from "~/features/common/Tooltip/Tooltip.tsx"
24-
import RateTooltip from "../Tooltip/RateTooltip.tsx"
2522

2623
function TokenDrawer({
2724
token,
@@ -84,7 +81,7 @@ function TokenDrawer({
8481
console.error(`No token data found for ${token.id} on ${network.key} -> ${destinationChain}`)
8582
return null
8683
}
87-
const destinationPoolType = destinationTokenData.poolType
84+
const destinationPoolType = destinationTokenData.pool.type
8885
if (!destinationPoolType) {
8986
console.error(`No pool type found for ${token.id} on ${network.key} -> ${destinationChain}`)
9087
return null
@@ -100,11 +97,11 @@ function TokenDrawer({
10097
console.error(`No lane data found for ${token.id} on ${network.key} -> ${destinationChain}`)
10198
return null
10299
}
103-
if (!laneData.supportedTokens) {
100+
if (!laneData.supportedTokens || !Array.isArray(laneData.supportedTokens)) {
104101
console.error(`No supported tokens found for ${token.id} on ${network.key} -> ${destinationChain}`)
105102
return null
106103
}
107-
if (!(token.id in laneData.supportedTokens)) {
104+
if (!laneData.supportedTokens.includes(token.id)) {
108105
console.error(`${token.id} not found in supported tokens for ${network.key} -> ${destinationChain}`)
109106
return null
110107
}
@@ -216,13 +213,10 @@ function TokenDrawer({
216213
.map(({ networkDetails, laneData, destinationChain, destinationPoolType }) => {
217214
if (!laneData || !networkDetails) return null
218215

219-
// Check if token is paused on this lane
220-
const tokenPaused = isTokenPaused(
221-
network.tokenDecimals,
222-
destinationLanes[destinationChain].rateLimiterConfig?.[
223-
inOutbound === LaneFilter.Inbound ? "in" : "out"
224-
]
225-
)
216+
// TODO: Fetch rate limits from API for both inbound and outbound
217+
// Token pause detection requires rate limiter data from API
218+
// A token is paused when rate limit capacity is 0
219+
const tokenPaused = false
226220

227221
return (
228222
<tr key={networkDetails.name} className={tokenPaused ? "ccip-table__row--paused" : ""}>
@@ -262,21 +256,15 @@ function TokenDrawer({
262256
</button>
263257
</td>
264258
<td>
265-
{displayCapacity(
266-
network.tokenDecimals,
267-
network.tokenSymbol,
268-
destinationLanes[destinationChain].rateLimiterConfig?.[
269-
inOutbound === LaneFilter.Inbound ? "in" : "out"
270-
]
271-
)}
259+
{/* TODO: Fetch rate limits from API for both inbound and outbound
260+
GET /api/ccip/v1/lanes/by-internal-id/{source}/{destination}/supported-tokens?environment={environment}
261+
Response will contain both standard and custom rate limits per token */}
262+
Disabled
272263
</td>
273264
<td>
274-
<RateTooltip
275-
destinationLane={destinationLanes[destinationChain]}
276-
inOutbound={inOutbound}
277-
symbol={network.tokenSymbol}
278-
decimals={network.tokenDecimals}
279-
/>
265+
{/* TODO: Fetch rate limits from API for both inbound and outbound
266+
Display refill rate from standard.in/out or custom.in/out based on inOutbound filter */}
267+
Disabled
280268
</td>
281269
<td>
282270
{inOutbound === LaneFilter.Outbound

src/components/CCIP/Search/Search.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,8 @@ function Search({ chains, tokens, small, environment, lanes }: SearchProps) {
273273
{lane.sourceNetwork.name} {">"} {lane.destinationNetwork.name}
274274
{!small && (
275275
<span>
276-
{lane?.lane?.supportedTokens ? Object.keys(lane.lane.supportedTokens).length : 0}{" "}
277-
{lane?.lane?.supportedTokens && Object.keys(lane.lane.supportedTokens).length > 1
278-
? "tokens"
279-
: "token"}
276+
{lane?.lane?.supportedTokens ? lane.lane.supportedTokens.length : 0}{" "}
277+
{lane?.lane?.supportedTokens && lane.lane.supportedTokens.length > 1 ? "tokens" : "token"}
280278
</span>
281279
)}
282280
</button>

src/components/CCIP/Tables/TokenChainsTable.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface TableProps {
2323
tokenAddress: string
2424
tokenPoolType: PoolType
2525
tokenPoolAddress: string
26+
tokenPoolVersion: string
2627
explorer: ExplorerInfo
2728
}[]
2829
token: {
@@ -60,6 +61,9 @@ function TokenChainsTable({ networks, token, lanes, environment }: TableProps) {
6061
<th>Token address</th>
6162
<th>Token pool type</th>
6263
<th>Token pool address</th>
64+
<th>Pool version</th>
65+
<th>Custom finality</th>
66+
<th>Min Blocks required</th>
6367
</tr>
6468
</thead>
6569
<tbody>
@@ -139,6 +143,18 @@ function TokenChainsTable({ networks, token, lanes, environment }: TableProps) {
139143
endLength={6}
140144
/>
141145
</td>
146+
<td>{network.tokenPoolVersion}</td>
147+
<td>
148+
{/* TODO: Fetch from API - GET /api/ccip/v1/tokens/{tokenCanonicalSymbol}/finality?environment={environment}
149+
Custom finality is derived from minBlockConfirmation > 0
150+
Display: "Yes" | "No" | "N/A" (with tooltip for unavailable) */}
151+
-
152+
</td>
153+
<td>
154+
{/* TODO: Fetch from API - GET /api/ccip/v1/tokens/{tokenCanonicalSymbol}/finality?environment={environment}
155+
Display minBlockConfirmation value or "-" if custom finality is disabled/unavailable */}
156+
-
157+
</td>
142158
</tr>
143159
)
144160
})}

src/components/CCIP/Token/Token.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ const tokenStructuredData = generateTokenStructuredData(token, environment, chai
150150
tokenSymbol: data[key]?.symbol ?? "",
151151
tokenDecimals: data[key]?.decimals ?? 0,
152152
tokenAddress: data[key]?.tokenAddress ?? "",
153-
tokenPoolType: data[key]?.poolType,
154-
tokenPoolAddress: data[key]?.poolAddress ?? "",
153+
tokenPoolType: data[key]?.pool.type,
154+
tokenPoolAddress: data[key]?.pool.address ?? "",
155+
tokenPoolVersion: data[key]?.pool.version ?? "",
155156
explorer: explorer,
156157
chainType: chainType,
157158
}

src/config/data/ccip/data.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,14 @@ export const getAllSupportedTokens = (params: { environment: Environment; versio
272272

273273
Object.entries(laneReferenceData).forEach(([destinationChainRdd, destinationLaneReferenceData]) => {
274274
const supportedTokens = destinationLaneReferenceData.supportedTokens
275-
if (supportedTokens) {
276-
Object.entries(supportedTokens).forEach(([token, tokenConfig]) => {
275+
if (supportedTokens && Array.isArray(supportedTokens)) {
276+
supportedTokens.forEach((token) => {
277277
const destinationChain = directoryToSupportedChain(destinationChainRdd)
278278

279279
tokens[token] = tokens[token] || {}
280280
tokens[token][sourceChain] = tokens[token][sourceChain] || {}
281-
tokens[token][sourceChain][destinationChain] = tokenConfig
281+
// Rate limiter config is now in separate files, store empty config
282+
tokens[token][sourceChain][destinationChain] = {}
282283
})
283284
}
284285
})
@@ -316,8 +317,8 @@ export const getTokenMechanism = (params: {
316317
const tokenConfig = tokensReferenceData[params.token]
317318
const sourceChainPoolInfo = tokenConfig[sourceChainRdd]
318319
const destinationChainPoolInfo = tokenConfig[destinationChainRdd]
319-
const sourceChainPoolType = sourceChainPoolInfo.poolType
320-
const destinationChainPoolType = destinationChainPoolInfo.poolType
320+
const sourceChainPoolType = sourceChainPoolInfo.pool.type
321+
const destinationChainPoolType = destinationChainPoolInfo.pool.type
321322
const tokenMechanism = determineTokenMechanism(sourceChainPoolType, destinationChainPoolType)
322323
return tokenMechanism
323324
}
@@ -474,7 +475,7 @@ export const getTokensOfChain = ({ chain, filter }: { chain: string; filter: Env
474475
return Object.keys(tokensData).filter((token) => {
475476
const tokenData = tokensData[token]
476477
// Check if tokenData for the given chain exists and isn't 'feeTokenOnly'
477-
if (tokenData[chain] && tokenData[chain].poolType !== "feeTokenOnly") {
478+
if (tokenData[chain] && tokenData[chain].pool.type !== "feeTokenOnly") {
478479
const lanes = getAllTokenLanes({ token, environment: filter })
479480
// Ensure there is at least one lane and that the lane exists for the given chain
480481
return Object.keys(lanes).length > 0 && lanes[chain] && Object.keys(lanes[chain]).length > 0
@@ -593,7 +594,7 @@ export const getChainsOfToken = ({ token, filter }: { token: string; filter: Env
593594

594595
// Get all valid chains for the given token
595596
return Object.entries(tokensData[token])
596-
.filter(([, tokenData]) => tokenData.poolType !== "feeTokenOnly")
597+
.filter(([, tokenData]) => tokenData.pool.type !== "feeTokenOnly")
597598
.filter(([chain]) => {
598599
const lanes = getAllTokenLanes({ token, environment: filter })
599600
return Object.keys(lanes).length > 0 && lanes[chain] && Object.keys(lanes[chain]).length > 0
@@ -677,11 +678,13 @@ export function getAllTokenLanes({
677678
for (const destinationChain in sourceData) {
678679
const destinationData = sourceData[destinationChain]
679680

680-
// Check if the token is supported
681-
if (destinationData?.supportedTokens?.[token]) {
681+
// Check if the token is supported (supportedTokens is now an array)
682+
const supportedTokens = destinationData?.supportedTokens
683+
if (Array.isArray(supportedTokens) && supportedTokens.includes(token)) {
682684
allDestinationLanes[sourceChain] = {
683685
...allDestinationLanes[sourceChain],
684-
[destinationChain]: destinationData.supportedTokens[token],
686+
// Rate limiter config is now in separate files, store empty config
687+
[destinationChain]: {},
685688
}
686689
}
687690
}

0 commit comments

Comments
 (0)