-
Notifications
You must be signed in to change notification settings - Fork 282
Use the new EdgeCurrencyWallet.split method #5924
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
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 |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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' } | ||
| }) | ||
|
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. Missing try/catch leaves user stuck on split errorMedium Severity The old Additional Locations (1) |
||
| } | ||
|
|
||
| navigation.navigate('edgeTabs', { | ||
| screen: 'walletsTab', | ||
| params: { screen: 'walletList' } | ||
| }) | ||
| }) | ||
|
|
||
| const handleImport = useHandler(async () => { | ||
|
|
||


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.
Missing try/catch around split call in handleSplit
Medium Severity
The old
handleSplitwrapped each split operation intry/catch, callingshowErroron failure. The new code callssourceWallet.split(splitItems)with notry/catchat all. Ifsplit()throws an exception (e.g. network error, internal failure) rather than returning an error result, it becomes an unhandled promise rejection sinceuseHandlerdoesn't catch errors. The companion change inSwapProcessingScenecorrectly has thesplit()call inside atry/catch. ThehandleCreatehandler in this same file also wraps its core logic intry/catch.