@@ -27,6 +27,12 @@ import { useMultiLaneRateLimits } from "~/hooks/useMultiLaneRateLimits.ts"
2727import { RateLimitCell } from "~/components/CCIP/RateLimitCell.tsx"
2828import { realtimeDataService } from "~/lib/ccip/services/realtime-data-instance.ts"
2929
30+ enum TokenTab {
31+ Outbound = "outbound" ,
32+ Inbound = "inbound" ,
33+ Verifiers = "verifiers" ,
34+ }
35+
3036function TokenDrawer ( {
3137 token,
3238 network,
@@ -60,7 +66,7 @@ function TokenDrawer({
6066 environment : Environment
6167} ) {
6268 const [ search , setSearch ] = useState ( "" )
63- const [ activeTab , setActiveTab ] = useState < "outbound" | "inbound" | "verifiers" > ( "outbound" )
69+ const [ activeTab , setActiveTab ] = useState < TokenTab > ( TokenTab . Outbound )
6470
6571 // Get verifiers for the current network
6672 const verifiers = getVerifiersByNetwork ( {
@@ -82,8 +88,8 @@ function TokenDrawer({
8288 // Build lane configurations for fetching rate limits
8389 const laneConfigs = useMemo ( ( ) => {
8490 return Object . keys ( destinationLanes ) . map ( ( destinationChain ) => ( {
85- source : activeTab === "outbound" ? network . key : destinationChain ,
86- destination : activeTab === "outbound" ? destinationChain : network . key ,
91+ source : activeTab === TokenTab . Outbound ? network . key : destinationChain ,
92+ destination : activeTab === TokenTab . Outbound ? destinationChain : network . key ,
8793 } ) )
8894 } , [ destinationLanes , network . key , activeTab ] )
8995
@@ -163,23 +169,23 @@ function TokenDrawer({
163169 tabs = { [
164170 {
165171 name : "Outbound lanes" ,
166- key : "outbound" ,
172+ key : TokenTab . Outbound ,
167173 } ,
168174 {
169175 name : "Inbound lanes" ,
170- key : "inbound" ,
176+ key : TokenTab . Inbound ,
171177 } ,
172178 {
173179 name : "Verifiers" ,
174- key : "verifiers" ,
180+ key : TokenTab . Verifiers ,
175181 } ,
176182 ] }
177- onChange = { ( key ) => setActiveTab ( key as "outbound" | "inbound" | "verifiers" ) }
183+ onChange = { ( key ) => setActiveTab ( key as TokenTab ) }
178184 />
179185 </ div >
180186 < TableSearchInput search = { search } setSearch = { setSearch } />
181187 </ div >
182- { activeTab === "verifiers" ? (
188+ { activeTab === TokenTab . Verifiers ? (
183189 < div className = "ccip-table__wrapper" >
184190 < table className = "ccip-table" >
185191 < thead >
@@ -242,7 +248,7 @@ function TokenDrawer({
242248 < table className = "ccip-table" >
243249 < thead >
244250 < tr >
245- < th > { activeTab === "inbound" ? "Source" : "Destination" } network</ th >
251+ < th > { activeTab === TokenTab . Inbound ? "Source" : "Destination" } network</ th >
246252 < th >
247253 Rate limit capacity
248254 < Tooltip
@@ -303,18 +309,16 @@ function TokenDrawer({
303309 if ( ! laneData || ! networkDetails ) return null
304310
305311 // Get rate limit data for this lane
306- const source = activeTab === "outbound" ? network . key : destinationChain
307- const destination = activeTab === "outbound" ? destinationChain : network . key
312+ const source = activeTab === TokenTab . Outbound ? network . key : destinationChain
313+ const destination = activeTab === TokenTab . Outbound ? destinationChain : network . key
308314 const laneKey = `${ source } -${ destination } `
309315 const laneRateLimits = rateLimitsMap [ laneKey ]
310316 const tokenRateLimits = laneRateLimits ?. [ token . id ]
311317
312- const direction = activeTab === "outbound" ? "out" : "in"
318+ const direction = activeTab === TokenTab . Outbound ? "out" : "in"
313319
314320 // Get standard and FTF rate limits
315- const allLimits = tokenRateLimits
316- ? realtimeDataService . getAllRateLimitsForDirection ( tokenRateLimits , direction )
317- : { standard : null , ftf : null }
321+ const allLimits = realtimeDataService . getAllRateLimitsForDirection ( tokenRateLimits , direction )
318322
319323 // Token is paused if standard rate limit capacity is 0
320324 const tokenPaused = allLimits . standard ?. capacity === "0"
@@ -337,7 +341,7 @@ function TokenDrawer({
337341 logo : networkDetails ?. logo || "" ,
338342 key : destinationChain ,
339343 } }
340- inOutbound = { activeTab === "outbound" ? LaneFilter . Outbound : LaneFilter . Inbound }
344+ inOutbound = { activeTab === TokenTab . Outbound ? LaneFilter . Outbound : LaneFilter . Inbound }
341345 explorer = { network . explorer }
342346 />
343347 ) )
@@ -374,7 +378,7 @@ function TokenDrawer({
374378 < RateLimitCell isLoading = { isLoadingRateLimits } rateLimit = { allLimits . ftf } type = "rate" />
375379 </ td >
376380 < td >
377- { activeTab === "outbound"
381+ { activeTab === TokenTab . Outbound
378382 ? determineTokenMechanism ( network . tokenPoolType , destinationPoolType )
379383 : determineTokenMechanism ( destinationPoolType , network . tokenPoolType ) }
380384 </ td >
@@ -397,7 +401,7 @@ function TokenDrawer({
397401 </ div >
398402 ) }
399403
400- { activeTab !== "verifiers" && (
404+ { activeTab !== TokenTab . Verifiers && (
401405 < div className = "ccip-table__notFound" >
402406 { laneRows ?. filter (
403407 ( { networkDetails } ) => networkDetails && networkDetails . name . toLowerCase ( ) . includes ( search . toLowerCase ( ) )
0 commit comments