From 11a010adab8736c003cdfbd0ab31b29eb10b273f Mon Sep 17 00:00:00 2001 From: Sam Holmes Date: Mon, 30 Mar 2026 11:12:13 -0700 Subject: [PATCH] fix: include token items in migration list The migration handler only included mainnet wallet items, so imported tokens were excluded from the migration flow. Token items need their parent wallet resolved to carry the correct createWalletId into the downstream migration scenes. --- .../scenes/CreateWalletCompletionScene.tsx | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/src/components/scenes/CreateWalletCompletionScene.tsx b/src/components/scenes/CreateWalletCompletionScene.tsx index 504bc412638..955ce007fd4 100644 --- a/src/components/scenes/CreateWalletCompletionScene.tsx +++ b/src/components/scenes/CreateWalletCompletionScene.tsx @@ -252,23 +252,51 @@ const CreateWalletCompletionComponent: React.FC = props => { }) const handleMigrate = useHandler(() => { - // Transform filtered items into the structure expected by the migration component - const migrateWalletList: MigrateWalletItem[] = newWalletItems.map( - createWallet => { - const { key, pluginId } = createWallet - const wallet = wallets.find( - wallet => wallet.currencyInfo.pluginId === pluginId - ) + const successfulNewWalletItems = newWalletItems.filter( + item => itemStatus[item.key] === 'complete' + ) - return { - ...createWallet, - createWalletId: wallet == null ? '' : wallet.id, - displayName: walletNames[key], - key, - type: 'create' - } + const migrateWalletList: MigrateWalletItem[] = [ + ...successfulNewWalletItems, + ...newTokenItems + ].map(createWallet => { + const createWalletIds = createWallet.createWalletIds ?? [] + const parentWalletItem = + createWallet.walletType != null + ? createWallet + : createWalletIds[0] === PLACEHOLDER_WALLET_ID + ? successfulNewWalletItems.find( + item => item.pluginId === createWallet.pluginId + ) + : undefined + const parentWalletIndex = + parentWalletItem == null + ? -1 + : successfulNewWalletItems.findIndex( + item => item.key === parentWalletItem.key + ) + + const wallet = + parentWalletIndex >= 0 + ? wallets[parentWalletIndex] + : createWalletIds[0] == null || + createWalletIds[0] === PLACEHOLDER_WALLET_ID + ? undefined + : account.currencyWallets[createWalletIds[0]] + + return { + ...createWallet, + createWalletId: wallet?.id ?? '', + walletType: + parentWalletItem?.walletType ?? wallet?.currencyInfo.walletType, + displayName: + parentWalletItem == null + ? createWallet.displayName + : walletNames[parentWalletItem.key] ?? parentWalletItem.displayName, + key: createWallet.key, + type: 'create' as const } - ) + }) // Navigate to the migration screen with the prepared list if (migrateWalletList.length > 0) {