Skip to content

Commit a701c92

Browse files
authored
fix: [lw-11841]: handle errors during hw accounts creation in nami mode (#1549)
1 parent 5b19d63 commit a701c92

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

packages/nami/src/ui/app/hw/select-account.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ export const SelectAccounts = ({
6565
selected[currentState] && !isAccountDisabled(currentState),
6666
)
6767
.map(Number);
68-
// enable more accounts for existing hw
69-
if (walletId && existingAccountsIndexes.size > 0) {
70-
for (const accountIndex of accountIndexes) {
71-
try {
68+
try {
69+
// enable more accounts for existing hw
70+
if (walletId && existingAccountsIndexes.size > 0) {
71+
for (const accountIndex of accountIndexes) {
7272
await walletRepository.addAccount({
7373
accountIndex,
7474
extendedAccountPublicKey:
@@ -85,31 +85,27 @@ export const SelectAccounts = ({
8585
},
8686
walletId,
8787
});
88-
} catch (error: unknown) {
89-
throw error;
9088
}
91-
}
92-
await activateAccount({ accountIndex: accountIndexes[0], walletId });
93-
} else {
94-
// create new hw
95-
let cardanoWallet: Wallet.CardanoWallet;
96-
try {
97-
cardanoWallet = await createHardwareWalletRevamped({
89+
await activateAccount({ accountIndex: accountIndexes[0], walletId });
90+
} else {
91+
// create new hw
92+
const cardanoWallet = await createHardwareWalletRevamped({
9893
connection,
9994
name: 'Wallet 1',
10095
accountIndexes,
10196
});
10297
await saveHardwareWallet(cardanoWallet, environmentName);
103-
} catch (error_) {
104-
console.error(error_);
105-
setError('An error occured');
10698
}
99+
onConfirm();
100+
void capture(Events.HWSelectAccountNextClick, {
101+
numAccounts: accountIndexes.length.toString(),
102+
});
103+
} catch (error_) {
104+
console.error(error_);
105+
setError('An error occured');
106+
} finally {
107+
setIsLoading(false);
107108
}
108-
onConfirm();
109-
void capture(Events.HWSelectAccountNextClick, {
110-
numAccounts: accountIndexes.length.toString(),
111-
});
112-
setIsLoading(false);
113109
};
114110

115111
const isAccountDisabled = useCallback(

0 commit comments

Comments
 (0)