mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
CAKE-192 | added verification of open alias and unstoppable domains in exchange_page.dart and send_page.dart
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user