Skip to content

Commit 1198ec4

Browse files
fix(cat-voices): handle unknown account with better error message (#2675)
1 parent b9feecf commit 1198ec4

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

catalyst_voices/packages/internal/catalyst_voices_blocs/lib/src/registration/cubits/recover_cubit.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ final class RecoverCubit extends Cubit<RecoverStateData>
7777
return false;
7878
}
7979

80-
final account = await _registrationService.recoverAccount(
81-
seedPhrase: seedPhrase,
82-
);
80+
final account = await _registrationService
81+
.recoverAccount(seedPhrase: seedPhrase)
82+
.onError<NotFoundException>((_, __) => throw const LocalizedRecoverAccountNotFound());
8383

8484
final address = account.address!;
8585
final balance = await _registrationService.getWalletBalance(

catalyst_voices/packages/internal/catalyst_voices_localization/lib/l10n/intl_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@
644644
"@registrationWalletNotFound": {
645645
"description": "Error message shown when connect wallet but matching was not found"
646646
},
647+
"registrationAccountNotFound": "Account not found. Make sure seed phrase is correct.",
648+
"@registrationAccountNotFound": {
649+
"description": "Error message shown when recovering account with invalid seed phrase."
650+
},
647651
"walletLinkRoleChooserTitle": "How do you want to participate in Catalyst?",
648652
"@walletLinkRoleChooserTitle": {
649653
"description": "A title on the role chooser screen in registration."

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/user/user_repository.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:catalyst_cardano_serialization/catalyst_cardano_serialization.dart';
22
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
33
import 'package:catalyst_voices_repositories/catalyst_voices_repositories.dart';
4-
import 'package:catalyst_voices_repositories/generated/api/cat_gateway.swagger.dart';
54
import 'package:catalyst_voices_repositories/generated/api/cat_reviews.models.swagger.dart';
65
import 'package:catalyst_voices_repositories/src/common/rbac_token_ext.dart';
76
import 'package:catalyst_voices_repositories/src/common/response_mapper.dart';
@@ -111,10 +110,10 @@ final class UserRepositoryImpl implements UserRepository {
111110
required CatalystId catalystId,
112111
required RbacToken rbacToken,
113112
}) async {
114-
final rbacRegistration = await _recoverRbacRegistration(
115-
catalystId,
116-
rbacToken,
117-
);
113+
final rbacRegistration = await _apiServices.gateway
114+
.apiV1RbacRegistrationGet(lookup: catalystId.toUri().toStringWithoutScheme())
115+
.successBodyOrThrow();
116+
118117
final publicId = await _getReviewsCatalystIDPublic(token: rbacToken);
119118
final username = (publicId?.username as String?) ??
120119
await _lookupUsernameFromDocuments(
@@ -163,16 +162,4 @@ final class UserRepositoryImpl implements UserRepository {
163162
},
164163
).then((value) => value?.username);
165164
}
166-
167-
Future<RbacRegistrationChain> _recoverRbacRegistration(
168-
CatalystId catalystId,
169-
RbacToken token,
170-
) {
171-
return _apiServices.gateway
172-
.apiV1RbacRegistrationGet(
173-
lookup: catalystId.toUri().toStringWithoutScheme(),
174-
authorization: token.authHeader(),
175-
)
176-
.successBodyOrThrow();
177-
}
178165
}

catalyst_voices/packages/internal/catalyst_voices_view_models/lib/src/registration/exception/localized_registration_exception.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import 'package:catalyst_voices_models/catalyst_voices_models.dart';
55
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
66
import 'package:flutter/widgets.dart';
77

8+
final class LocalizedRecoverAccountNotFound extends LocalizedRegistrationException {
9+
const LocalizedRecoverAccountNotFound();
10+
11+
@override
12+
String message(BuildContext context) => context.l10n.registrationAccountNotFound;
13+
}
14+
815
/// A [LocalizedException] describing an error during a user registration.
916
sealed class LocalizedRegistrationException extends LocalizedException {
1017
const LocalizedRegistrationException();

0 commit comments

Comments
 (0)