-
Notifications
You must be signed in to change notification settings - Fork 287
fix: preserve imported token migrations #5989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,23 +252,51 @@ const CreateWalletCompletionComponent: React.FC<Props> = 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unchecked array index on
|
||
| ? 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) { | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfiltered token items with failed parents break migration
High Severity
newTokenItemsare spread into the migration list without filtering for parent wallet success. When a parent wallet creation fails, tokens withPLACEHOLDER_WALLET_IDwon't find aparentWalletIteminsuccessfulNewWalletItems, resulting inwalletbeingundefinedandcreateWalletIdfalling back to''. InMigrateWalletCalculateFeeScene, theuseAsyncEffectprocesses all items and doescurrencyWallets[createWalletId]followed by an unguarded destructuring of.currencyInfo, which throws aTypeErroronundefined— breaking the entire migration flow for all items, not just the failed ones.Additional Locations (1)
src/components/scenes/CreateWalletCompletionScene.tsx#L288-L289