Skip to content

Commit 44a7331

Browse files
committed
chore: remove XCM destination generator logic (moved to feat/xcm_destination_generator)
1 parent 925a8c4 commit 44a7331

File tree

9 files changed

+4
-1328
lines changed

9 files changed

+4
-1328
lines changed

src/renderer/app/bootstrap/index.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* eslint-disable import-x/max-dependencies */
2-
3-
import { chainsService } from '@/shared/api/network';
4-
import { spellXcmService } from '@/shared/api/xcm/service/spellXcmService';
51
import { kernelModel } from '@/shared/core';
62
import { createFeature, registerFeatures } from '@/shared/feature';
73
import { isWeb } from '@/shared/lib/utils';
@@ -55,20 +51,6 @@ const populate = async () => {
5551
portfolioModel.populate();
5652
balanceModel.populate();
5753

58-
// Initialize XCM whitelist from nova-utils (non-blocking)
59-
chainsService
60-
.getChainsData()
61-
.then((chains) => {
62-
if (chains && chains.length > 0) {
63-
spellXcmService.initializeXcmWhitelist(chains).catch((error) => {
64-
console.warn('Failed to initialize XCM whitelist in bootstrap:', error);
65-
});
66-
}
67-
})
68-
.catch((error) => {
69-
console.warn('Failed to load chains for XCM whitelist initialization:', error);
70-
});
71-
7254
// TODO rework as populate effects
7355
kernelModel.events.appStarted();
7456
assetsSettingsModel.events.assetsStarted();

src/renderer/shared/api/xcm/service/constants.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Chain, type ChainId } from '@/shared/core';
1+
import { type ChainId } from '@/shared/core';
22

33
export type XcmDestinationBlacklistEntry = {
44
sourceChainId?: ChainId | null;
@@ -12,27 +12,6 @@ export type XcmDestinationWhitelistEntry = {
1212
destinationAsset?: string;
1313
};
1414

15-
/**
16-
* Gets the XCM whitelist entries.
17-
*
18-
* This function will attempt to load from nova-utils, falling back to legacy
19-
* hardcoded list.
20-
*
21-
* @param chains - Array of all available chains (required for nova-utils
22-
* loading)
23-
*
24-
* @returns Promise resolving to whitelist entries
25-
*/
26-
export async function getXcmWhitelist(chains: Chain[]): Promise<XcmDestinationWhitelistEntry[]> {
27-
try {
28-
const { loadXcmWhitelistFromNovaUtils } = await import('./xcmWhitelistService');
29-
return await loadXcmWhitelistFromNovaUtils(chains);
30-
} catch (error) {
31-
console.warn('Failed to load XCM whitelist from nova-utils, using legacy whitelist:', error);
32-
return XCM_DESTINATION_WHITELIST_LEGACY;
33-
}
34-
}
35-
3615
export const XCM_DESTINATION_BLACKLIST: XcmDestinationBlacklistEntry[] = [
3716
{
3817
sourceChainId: '0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a', // Kusama Asset Hub
@@ -155,12 +134,7 @@ export const XCM_DESTINATION_BLACKLIST: XcmDestinationBlacklistEntry[] = [
155134
},
156135
];
157136

158-
/**
159-
* Legacy hardcoded whitelist (kept as fallback).
160-
*
161-
* This will be replaced by data from nova-utils repository
162-
*/
163-
export const XCM_DESTINATION_WHITELIST_LEGACY: XcmDestinationWhitelistEntry[] = [
137+
export const XCM_DESTINATION_WHITELIST: XcmDestinationWhitelistEntry[] = [
164138
{
165139
sourceChainId: '0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c', // Acala
166140
destinationChainId: '0x9eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6', // Astar

src/renderer/shared/api/xcm/service/spellXcmService.ts

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ import { type Asset, type Chain, type ChainId, AssetType } from '@/shared/core';
77
import { CHAIN_ID_TO_SPELL_NAME_MAP, isEthereumAccountId, nonNullable, toAddress } from '@/shared/lib/utils';
88
import { 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';
1711
import { normalizeXcmError } from './xcm-error-utils';
1812

1913
type 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-
149108
function 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-
554487
function 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
};

src/renderer/shared/api/xcm/service/xcmWhitelistService.ts

Lines changed: 0 additions & 164 deletions
This file was deleted.

0 commit comments

Comments
 (0)