CAKE-192 | added verification of open alias and unstoppable domains in exchange_page.dart and send_page.dart

This commit is contained in:
OleksandrSobol 2021-06-15 22:43:50 +03:00
parent 37f326e21f
commit 7ddbc6b8f4
4 changed files with 39 additions and 19 deletions

View file

@ -778,15 +778,22 @@ class ExchangePage extends BasePage {
Future<String> applyUnstoppableDomainAddress(BuildContext context,
String domain, String ticker) async {
try {
final address =
await exchangeViewModel.getUnstoppableDomainAddress(domain, ticker);
if ((address != null)&&address.isNotEmpty) {
unstoppableDomainAddressAlert(context, domain);
return address;
const topLevelDomain = 'crypto';
if (domain.contains('.')) {
final name = domain.split('.').last;
if (name.isNotEmpty && (name == topLevelDomain)) {
try {
final address =
await exchangeViewModel.getUnstoppableDomainAddress(domain, ticker);
if ((address != null)&&address.isNotEmpty) {
unstoppableDomainAddressAlert(context, domain);
return address;
}
} catch (e) {
print(e.toString());
}
}
} catch (e) {
print(e.toString());
}
return domain;

View file

@ -38,10 +38,9 @@ class SendPage extends BasePage {
_cryptoAmountFocus = FocusNode(),
_fiatAmountFocus = FocusNode(),
_addressFocusNode = FocusNode() {
_addressFocusNode.addListener(() async {
_addressFocusNode.addListener(() {
if (!_addressFocusNode.hasFocus && _addressController.text.isNotEmpty) {
await getOpenaliasRecord(_addressFocusNode.context);
await applyUnstoppableDomainAddress(_addressFocusNode.context);
applyOpenaliasOrUnstoppableDomains(_addressFocusNode.context);
}
});
}
@ -174,9 +173,8 @@ class SendPage extends BasePage {
.headline
.decorationColor),
validator: sendViewModel.addressValidator,
onPushPasteButton: (context) async {
await getOpenaliasRecord(context);
await applyUnstoppableDomainAddress(context);
onPushPasteButton: (context) {
applyOpenaliasOrUnstoppableDomains(context);
},
),
Observer(
@ -518,13 +516,12 @@ class SendPage extends BasePage {
to: template.name,
amount: template.amount,
from: template.cryptoCurrency,
onTap: () async {
onTap: () {
_addressController.text =
template.address;
_cryptoAmountController.text =
template.amount;
await getOpenaliasRecord(context);
await applyUnstoppableDomainAddress(context);
applyOpenaliasOrUnstoppableDomains(context);
},
onRemove: () {
showPopUp<void>(
@ -792,4 +789,20 @@ class SendPage extends BasePage {
print(e.toString());
}
}
void applyOpenaliasOrUnstoppableDomains(BuildContext context) async {
const topLevelDomain = 'crypto';
final address = _addressController.text;
if (address.contains('.')) {
final name = address.split('.').last;
if (name.isNotEmpty) {
if (name == topLevelDomain) {
await applyUnstoppableDomainAddress(context);
} else {
await getOpenaliasRecord(context);
}
}
}
}
}

View file

@ -480,7 +480,7 @@
"moonpay_alert_text" : "Der Wert des Betrags muss größer oder gleich sein ${minAmount} ${fiatCurrency}",
"outdated_electrum_wallet_receive_warning": "Wenn diese Brieftasche einen 12-Wort-Seed hat und in Cake erstellt wurde, zahlen Sie KEINE Bitcoins in diese Brieftasche ein. Alle auf diese Wallet übertragenen BTC können verloren gehen. Erstellen Sie eine neue 24-Wort-Wallet (tippen Sie auf das Menü oben rechts, wählen Sie Wallets, wählen Sie Create New Wallet und dann Bitcoin) und verschieben Sie Ihre BTC SOFORT dorthin. Neue (24 Wörter) BTC-Wallets von Cake sind sicher",
"do_not_show_me": "Zeig mir das nicht noch einmal"
"do_not_show_me": "Zeig mir das nicht noch einmal",
"outdated_electrum_wallet_description" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.",
"understand" : "Ich verstehe",

View file

@ -483,7 +483,7 @@
"moonpay_alert_text" : "Value of the amount must be more or equal to ${minAmount} ${fiatCurrency}",
"outdated_electrum_wallet_receive_warning": "If this wallet has a 12-word seed and was created in Cake, DO NOT deposit Bitcoin into this wallet. Any BTC transferred to this wallet may be lost. Create a new 24-word wallet (tap the menu at the top right, select Wallets, choose Create New Wallet, then select Bitcoin) and IMMEDIATELY move your BTC there. New (24-word) BTC wallets from Cake are secure",
"do_not_show_me": "Do not show me this again"
"do_not_show_me": "Do not show me this again",
"address_detected" : "Address detected",
"address_from_domain" : "You got address from unstoppable domain ${domain}"