@@ -7,13 +7,7 @@ import { type Asset, type Chain, type ChainId, AssetType } from '@/shared/core';
77import { CHAIN_ID_TO_SPELL_NAME_MAP , isEthereumAccountId , nonNullable , toAddress } from '@/shared/lib/utils' ;
88import { type AccountId } from '@/shared/polkadotjs-schemas' ;
99
10- import {
11- type XcmDestinationBlacklistEntry ,
12- type XcmDestinationWhitelistEntry ,
13- XCM_DESTINATION_BLACKLIST ,
14- XCM_DESTINATION_WHITELIST_LEGACY ,
15- getXcmWhitelist ,
16- } from './constants' ;
10+ import { type XcmDestinationBlacklistEntry , XCM_DESTINATION_BLACKLIST , XCM_DESTINATION_WHITELIST } from './constants' ;
1711import { normalizeXcmError } from './xcm-error-utils' ;
1812
1913type XcmTransferParams = {
@@ -111,55 +105,13 @@ function isRouteBlacklisted(sourceChainId: ChainId, destinationChainId: ChainId)
111105 } ) ;
112106}
113107
114- let cachedWhitelistEntries : XcmDestinationWhitelistEntry [ ] | null = null ;
115- let whitelistLoadingPromise : Promise < XcmDestinationWhitelistEntry [ ] > | null = null ;
116-
117- /**
118- * Gets whitelist entries, loading from nova-utils if not already cached
119- */
120- async function getWhitelistEntries ( chains : Chain [ ] ) : Promise < XcmDestinationWhitelistEntry [ ] > {
121- if ( cachedWhitelistEntries ) {
122- return cachedWhitelistEntries ;
123- }
124-
125- if ( whitelistLoadingPromise ) {
126- return whitelistLoadingPromise ;
127- }
128-
129- whitelistLoadingPromise = getXcmWhitelist ( chains ) . then ( ( entries ) => {
130- cachedWhitelistEntries = entries ;
131- whitelistLoadingPromise = null ;
132- return entries ;
133- } ) ;
134-
135- return whitelistLoadingPromise ;
136- }
137-
138- /**
139- * Synchronous version that uses cached whitelist or falls back to legacy
140- */
141- function getWhitelistEntriesSync ( ) : XcmDestinationWhitelistEntry [ ] {
142- if ( cachedWhitelistEntries ) {
143- return cachedWhitelistEntries ;
144- }
145- // Fallback to legacy whitelist if nova-utils hasn't loaded yet
146- return XCM_DESTINATION_WHITELIST_LEGACY ;
147- }
148-
149108function isRouteWhitelisted (
150109 sourceChainId : ChainId ,
151110 destinationChainId : ChainId ,
152111 sourceAssetSymbol ?: string ,
153112 destinationAssetSymbol ?: string ,
154- whitelistEntries ?: XcmDestinationWhitelistEntry [ ] ,
155113) : boolean {
156- const entries = whitelistEntries || getWhitelistEntriesSync ( ) ;
157-
158- if ( ! entries || entries . length === 0 ) {
159- return false ;
160- }
161-
162- return entries . some ( ( entry ) => {
114+ return XCM_DESTINATION_WHITELIST . some ( ( entry ) => {
163115 if ( entry . sourceChainId !== sourceChainId || entry . destinationChainId !== destinationChainId ) {
164116 return false ;
165117 }
@@ -532,25 +484,6 @@ async function buildTransfer(params: XcmTransferParams): Promise<XcmTransferResu
532484 } ;
533485}
534486
535- /**
536- * Initializes the XCM whitelist by loading it from nova-utils This should be
537- * called early in the application lifecycle when chains are available
538- *
539- * @param chains - Array of all available chains
540- */
541- async function initializeXcmWhitelist ( chains : Chain [ ] ) : Promise < void > {
542- if ( cachedWhitelistEntries ) {
543- return ;
544- }
545-
546- try {
547- const entries = await getWhitelistEntries ( chains ) ;
548- console . log ( `✅ XCM whitelist loaded from nova-utils: ${ entries . length } entries` ) ;
549- } catch ( error ) {
550- console . warn ( 'Failed to initialize XCM whitelist from nova-utils, using legacy whitelist:' , error ) ;
551- }
552- }
553-
554487function getAvailableTransfers ( fromChain : Chain , asset : Asset ) : string [ ] {
555488 const fromChainName = getSpellChainName ( fromChain ) ;
556489 if ( ! fromChainName ) {
@@ -571,7 +504,6 @@ function getAvailableTransfers(fromChain: Chain, asset: Asset): string[] {
571504 return false ;
572505 }
573506
574- // Use cached whitelist synchronously (will fallback to legacy if not loaded yet)
575507 return isRouteWhitelisted ( fromChain . chainId , destinationChainId , asset . symbol ) ;
576508 } ) ;
577509 return filteredDestinations ;
@@ -593,5 +525,4 @@ export const spellXcmService = {
593525 detectHopChains,
594526 buildXcmTransferBuilder,
595527 createBuilderConfig,
596- initializeXcmWhitelist,
597528} ;
0 commit comments