Skip to content

Commit

Permalink
After renaming a wallet, it doesn't open, and is expecting the old na…
Browse files Browse the repository at this point in the history
…me path

if you try rename wallet and don't change name it gives error "exception: input doesn't match the secure element value"

Advanced settings sometimes show the passphrase and sometimes not

Restore wallet > restore with keys - remove advanced options

Security and backup should request PIN

Fix a bug where form would allow to overwrite the secure storage pin
  • Loading branch information
MrCyjaneK committed Nov 4, 2024
1 parent f2b7719 commit 815b695
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"view_only_restore_qr": "Restore View-Only Wallet",
"seed_screen_wallet_seed_polyseed": "Wallet seed (Polyseed)",
"seed_screen_wallet_seed_polyseed_encrypted": "Wallet seed (Polyseed [Encrypted])",
"seed_screen_wallet_seed_legacy": "Wallet seed (Legacy)"
"seed_screen_wallet_seed_legacy": "Wallet seed (Legacy)",
"password_doesnt_match": "Passwords doesn't match"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"view_only_restore_qr": "Kod QR portfela podglądu",
"seed_screen_wallet_seed_polyseed": "Fraza odzyskiwania (Polyseed)",
"seed_screen_wallet_seed_polyseed_encrypted": "Fraza odzyskiwania (Polyseed [Szyfrowana])",
"seed_screen_wallet_seed_legacy": "Fraza odzyskiwania (Legacy)"
"seed_screen_wallet_seed_legacy": "Fraza odzyskiwania (Legacy)",
"password_doesnt_match": "Hasła się różnią"
}
24 changes: 23 additions & 1 deletion lib/view_model/create_wallet_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,37 @@ class CreateWalletViewModel extends ViewModel {
],
);

late PinFormElement walletPasswordInitial = PinFormElement(
label: "Wallet password",
password: true,
valueOutcome: PlainValueOutcome(),
validator: (String? input) {
if (input == null) return L.warning_input_cannot_be_null;
if (input == "") return L.warning_input_cannot_be_empty;
if (input.length < 4) {
return L.warning_password_too_short;
}
return null;
},
);

late PinFormElement walletPassword = PinFormElement(
label: "Wallet password",
password: true,
valueOutcome: FlutterSecureStorageValueOutcome(
"secure.wallet_password",
canWrite: true,
verifyMatching: false,
verifyMatching: true,
),
validator: (String? input) {
if (input == null) return L.warning_input_cannot_be_null;
if (input == "") return L.warning_input_cannot_be_empty;
if (input.length < 4) {
return L.warning_password_too_short;
}
if (input != walletPasswordInitial.ctrl.text) {
return L.password_doesnt_match;
}
return null;
},
);
Expand Down Expand Up @@ -185,20 +202,23 @@ class CreateWalletViewModel extends ViewModel {
};

late final List<FormElement> _createForm = [
walletPasswordInitial,
walletPassword,
walletName,
walletSeedType,
seedOffset
];

late final List<FormElement> _restoreSeedForm = [
walletPasswordInitial,
walletPassword,
walletName,
seed,
seedOffset
];

late final List<FormElement> _restoreFormKeysForm = [
walletPasswordInitial,
walletPassword,
walletName,
walletAddress,
Expand Down Expand Up @@ -492,9 +512,11 @@ class PinFormElement extends FormElement {
Future<void> Function(BuildContext context)? onChanged;
Future<void> Function(BuildContext context)? onConfirm;
Future<void> onConfirmInternal(BuildContext context) async {
isConfirmed = true;
await valueOutcome.encode(ctrl.text);
}

bool isConfirmed = false;
String? Function(String? input) validator;
}

Expand Down
30 changes: 22 additions & 8 deletions lib/widgets/form_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,32 @@ class _FormBuilderState extends State<FormBuilder> {
setState(() {});
}

void _pinSet() {
widget.rebuild?.call(true);
void _pinSet(bool val) {
widget.rebuild?.call(val);
_rebuild();
}

@override
Widget build(BuildContext context) {
if (widget.formElements.isNotEmpty &&
(widget.formElements.first is PinFormElement &&
(widget.formElements.first as PinFormElement).showNumboard) &&
!widget.isPinSet) {
final e = widget.formElements.first as PinFormElement;
if ((widget.formElements.isNotEmpty &&
(widget.formElements.first is PinFormElement &&
(widget.formElements.first as PinFormElement).showNumboard) &&
!(widget.formElements[0] as PinFormElement).isConfirmed) ||
widget.formElements.length >= 2 &&
(widget.formElements[1] is PinFormElement &&
(widget.formElements[1] as PinFormElement).showNumboard) &&
!(widget.formElements[1] as PinFormElement).isConfirmed) {
var e = widget.formElements.first as PinFormElement;
int i = 0;
int count = 0;
if (widget.formElements.length >= 2 &&
(widget.formElements[1] is PinFormElement)) {
count++;
}
if (e.isConfirmed) {
i++;
e = widget.formElements[1] as PinFormElement;
}
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down Expand Up @@ -69,10 +83,10 @@ class _FormBuilderState extends State<FormBuilder> {
nextPage: () async {
final b = await callThrowable(context, () async {
await e.onConfirmInternal(context);
_pinSet();
}, "Secure storage communication");
if (b == false) return;
if (!context.mounted) return;
_pinSet(count == i);
e.onConfirm?.call(context);
},
showComma: false,
Expand Down

0 comments on commit 815b695

Please sign in to comment.