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
+15 -8
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;
+22 -9
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);
}
}
}
}
}