Skip to content

Commit

Permalink
fix(EWM-262): prevent sending tip3 token to yourself (#468)
Browse files Browse the repository at this point in the history
Co-authored-by: Egor Komarov <[email protected]>
  • Loading branch information
Odrin and Egor Komarov authored Sep 4, 2024
1 parent 5bf8f9a commit cf51d2e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,5 +550,6 @@
"accountAddedSheetTitle": "New account has been added successfully",
"accountAddedSheetSubtitle": "When adding a new account, a new public key was also added. They were connected with each other.",
"accountAddedSheetSwitch": "Switch to this account",
"accountAddedSheetContinue": "Continue without switching"
"accountAddedSheetContinue": "Continue without switching",
"invalidReceiverAddress": "Invalid receiver address"
}
3 changes: 2 additions & 1 deletion assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,5 +550,6 @@
"accountAddedSheetTitle": "New account has been added successfully",
"accountAddedSheetSubtitle": "When adding a new account, a new public key was also added. They were connected with each other.",
"accountAddedSheetSwitch": "Switch to this account",
"accountAddedSheetContinue": "Continue without switching"
"accountAddedSheetContinue": "Continue without switching",
"invalidReceiverAddress": "Invalid receiver address"
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ class WalletPrepareTransferPageWidgetModel extends CustomWidgetModel<

void onSubmittedAmountWord(_) => commentFocus.requestFocus();

String? validateAddressField(String? value) {
if (value?.isEmpty ?? true) {
return LocaleKeys.addressIsEmpty.tr();
}
if (_selectedAsset?.isNative != true && model.address.address == value) {
return LocaleKeys.invalidReceiverAddress.tr();
}
return null;
}

Future<void> _init() async {
final acc = model.findAccountByAddress(model.address);
if (acc == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class WalletPrepareTransferView extends StatelessWidget {
focusNode: _wm.receiverFocus,
onSubmit: _wm.onSubmittedReceiverAddress,
inputFormatters: [_wm.addressFilterFormatter],
validator: (value) => value?.isEmpty ?? true
? LocaleKeys.addressIsEmpty.tr()
: null,
validator: _wm.validateAddressField,
suffixes: [_buildReceiverSuffix()],
),
WalletPrepareTransferAmountInput(
Expand Down
1 change: 1 addition & 0 deletions lib/generated/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -567,4 +567,5 @@ abstract class LocaleKeys {
static const accountAddedSheetSubtitle = 'accountAddedSheetSubtitle';
static const accountAddedSheetSwitch = 'accountAddedSheetSwitch';
static const accountAddedSheetContinue = 'accountAddedSheetContinue';
static const invalidReceiverAddress = 'invalidReceiverAddress';
}

0 comments on commit cf51d2e

Please sign in to comment.