From 063f6bc68cb280dc4ec2c6acb13fc6f676a3253b Mon Sep 17 00:00:00 2001 From: William Swanson Date: Fri, 30 Jan 2026 10:06:51 -0800 Subject: [PATCH] Use the new EdgeCurrencyWallet.split method --- CHANGELOG.md | 1 + eslint.config.mjs | 3 +- .../scenes/CreateWalletEditNameScene.tsx | 38 ++++++++++--------- src/components/scenes/SwapProcessingScene.tsx | 18 +++++---- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a5e9a28df..6ea040383b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - changed: Append chain names to token codes in RampCreateScene - changed: Light mode persistence, theme colors, and images - changed: ramps: Infinite buy support enabled +- fixed: Handle parallel wallet splits more reliably - fixed: iOS simulator builds for XCode 26 ## 4.42.0 (2025-01-19) diff --git a/eslint.config.mjs b/eslint.config.mjs index e1527f185ba..fb0252d2c08 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -247,7 +247,7 @@ export default [ 'src/components/scenes/CreateWalletAccountSelectScene.tsx', 'src/components/scenes/CreateWalletAccountSetupScene.tsx', 'src/components/scenes/CreateWalletCompletionScene.tsx', - 'src/components/scenes/CreateWalletEditNameScene.tsx', + 'src/components/scenes/CreateWalletImportOptionsScene.tsx', 'src/components/scenes/CreateWalletImportScene.tsx', @@ -301,7 +301,6 @@ export default [ 'src/components/scenes/SpendingLimitsScene.tsx', 'src/components/scenes/Staking/EarnScene.tsx', - 'src/components/scenes/SwapProcessingScene.tsx', 'src/components/scenes/SwapSettingsScene.tsx', 'src/components/scenes/SwapSuccessScene.tsx', 'src/components/scenes/SweepPrivateKeyCalculateFeeScene.tsx', diff --git a/src/components/scenes/CreateWalletEditNameScene.tsx b/src/components/scenes/CreateWalletEditNameScene.tsx index d28b2f6de3b..99b389c5e28 100644 --- a/src/components/scenes/CreateWalletEditNameScene.tsx +++ b/src/components/scenes/CreateWalletEditNameScene.tsx @@ -42,7 +42,7 @@ export interface CreateWalletEditNameParams { interface Props extends EdgeAppSceneProps<'createWalletEditName'> {} -const CreateWalletEditNameComponent = (props: Props) => { +const CreateWalletEditNameComponent: React.FC = props => { const { navigation, route } = props const { createWalletList, splitSourceWalletId } = route.params const isSplit = splitSourceWalletId != null @@ -136,25 +136,27 @@ const CreateWalletEditNameComponent = (props: Props) => { }) const handleSplit = useHandler(async () => { - if (splitSourceWalletId != null) { - for (const item of newWalletItems) { - try { - const splitWalletId = await account.splitWalletInfo( - splitSourceWalletId, - account.currencyConfig[item.pluginId]?.currencyInfo.walletType - ) - const splitWallet = await account.waitForCurrencyWallet(splitWalletId) - await splitWallet.renameWallet(walletNames[item.key]) - } catch (error: unknown) { - showError(error) - break - } + if (splitSourceWalletId == null) return + const sourceWallet = account.currencyWallets[splitSourceWalletId] + if (sourceWallet == null) return + + const splitItems = newWalletItems.map(item => ({ + fiatCurrencyCode: sourceWallet.fiatCurrencyCode, + name: walletNames[item.key], + walletType: account.currencyConfig[item.pluginId].currencyInfo.walletType + })) + const results = await sourceWallet.split(splitItems) + for (const result of results) { + if (!result.ok) { + showError(result.error) + break // Don't spam the user } - navigation.navigate('edgeTabs', { - screen: 'walletsTab', - params: { screen: 'walletList' } - }) } + + navigation.navigate('edgeTabs', { + screen: 'walletsTab', + params: { screen: 'walletList' } + }) }) const handleImport = useHandler(async () => { diff --git a/src/components/scenes/SwapProcessingScene.tsx b/src/components/scenes/SwapProcessingScene.tsx index 087c5368397..8cfaca9a7b8 100644 --- a/src/components/scenes/SwapProcessingScene.tsx +++ b/src/components/scenes/SwapProcessingScene.tsx @@ -98,19 +98,21 @@ export const SwapProcessingScene: React.FC = (props: Props) => { // If not found, split from the source chain wallet to the destination // chain wallet type: isWalletCreated = true - const splitFromWallet = fromWallet const targetWalletType = account.currencyConfig[targetPluginId]?.currencyInfo.walletType if (targetWalletType == null) throw new Error('Target wallet type unavailable') - const splitWalletId = await account.splitWalletInfo( - splitFromWallet.id, - targetWalletType - ) - const newWallet = await account.waitForCurrencyWallet(splitWalletId) - finalToWalletId = newWallet.id - finalToWallet = newWallet + const [result] = await fromWallet.split([ + { + fiatCurrencyCode: fromWallet.fiatCurrencyCode, + name: getWalletName(fromWallet), + walletType: targetWalletType + } + ]) + if (!result.ok) throw result.error + finalToWalletId = result.result.id + finalToWallet = result.result } else { finalToWalletId = matchingWalletId finalToWallet = account.currencyWallets[matchingWalletId]