Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -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',
Expand Down
38 changes: 20 additions & 18 deletions src/components/scenes/CreateWalletEditNameScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface CreateWalletEditNameParams {

interface Props extends EdgeAppSceneProps<'createWalletEditName'> {}

const CreateWalletEditNameComponent = (props: Props) => {
const CreateWalletEditNameComponent: React.FC<Props> = props => {
const { navigation, route } = props
const { createWalletList, splitSourceWalletId } = route.params
const isSplit = splitSourceWalletId != null
Expand Down Expand Up @@ -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' }
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing try/catch around split call in handleSplit

Medium Severity

The old handleSplit wrapped each split operation in try/catch, calling showError on failure. The new code calls sourceWallet.split(splitItems) with no try/catch at all. If split() throws an exception (e.g. network error, internal failure) rather than returning an error result, it becomes an unhandled promise rejection since useHandler doesn't catch errors. The companion change in SwapProcessingScene correctly has the split() call inside a try/catch. The handleCreate handler in this same file also wraps its core logic in try/catch.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing try/catch leaves user stuck on split error

Medium Severity

The old handleSplit wrapped each split attempt in a try/catch, guaranteeing the user was always navigated to the wallet list even on failure. The new version has no try/catch at all. If sourceWallet.split() throws (rather than returning error results), or if account.currencyConfig[item.pluginId] is undefined (optional chaining ?. was also removed), the function exits early and the navigation.navigate call never runs. While usePendingPress catches the rejection and shows the error, the user remains stuck on the edit-name scene with no automatic navigation back.

Additional Locations (1)

Fix in Cursor Fix in Web

}

navigation.navigate('edgeTabs', {
screen: 'walletsTab',
params: { screen: 'walletList' }
})
})

const handleImport = useHandler(async () => {
Expand Down
18 changes: 10 additions & 8 deletions src/components/scenes/SwapProcessingScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,21 @@ export const SwapProcessingScene: React.FC<Props> = (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]
Expand Down
Loading