diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 0c2b864dd..3dc12e6c4 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -7,34 +7,41 @@ const topLevelDomain = 'crypto'; Future parseAddressFromDomain( String domain, String ticker) async { try { - final domainParts = domain.split('.'); + final formattedName = OpenaliasRecord.formatDomainName(domain); + final domainParts = formattedName.split('.'); final name = domainParts.last; if (domainParts.length <= 1 || domainParts.first.isEmpty || name.isEmpty) { - return ParsedAddress(domain, ParseFrom.notParsed); + return ParsedAddress(address: domain); } if (name.contains(topLevelDomain)) { - final address = await fetchUnstoppableDomainAddress(domain, ticker); + final address = + await fetchUnstoppableDomainAddress(formattedName, ticker); if (address?.isEmpty ?? true) { - return ParsedAddress(domain, ParseFrom.notParsed); + return ParsedAddress(address: domain); } - return ParsedAddress(address, ParseFrom.unstoppableDomains); + return ParsedAddress( + address: address, + name: formattedName, + parseFrom: ParseFrom.unstoppableDomains); } - final record = await OpenaliasRecord.fetchAddressAndName( - OpenaliasRecord.formatDomainName(domain)); + final record = await OpenaliasRecord.fetchAddressAndName(formattedName); - if (record == null || record.address.contains(domain)) { - return ParsedAddress(domain, ParseFrom.notParsed); + if (record == null || record.address.contains(formattedName)) { + return ParsedAddress(address: domain); } - return ParsedAddress(record.address, ParseFrom.openAlias); + return ParsedAddress( + address: record.address, + name: record.name, + parseFrom: ParseFrom.openAlias); } catch (e) { print(e.toString()); } - return ParsedAddress(domain, ParseFrom.notParsed); + return ParsedAddress(address: domain); } \ No newline at end of file diff --git a/lib/entities/parsed_address.dart b/lib/entities/parsed_address.dart index f293d99c2..91fec6750 100644 --- a/lib/entities/parsed_address.dart +++ b/lib/entities/parsed_address.dart @@ -1,8 +1,12 @@ enum ParseFrom {unstoppableDomains, openAlias, notParsed} class ParsedAddress { - ParsedAddress(this.address, this.parseFrom); + ParsedAddress({ + this.address = '', + this.name = '', + this.parseFrom = ParseFrom.notParsed}); final String address; + final String name; final ParseFrom parseFrom; } \ No newline at end of file diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 693eade72..286134f16 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -787,13 +787,13 @@ class ExchangePage extends BasePage { showAddressAlert( context, S.of(context).address_detected, - S.of(context).address_from_domain(domain)); + S.of(context).address_from_domain(parsedAddress.name)); break; case ParseFrom.openAlias: showAddressAlert( context, S.of(context).openalias_alert_title, - S.of(context).openalias_alert_content(domain)); + S.of(context).openalias_alert_content(parsedAddress.name)); break; case ParseFrom.notParsed: break; diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 2aa4ebb82..aae86483c 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -767,13 +767,13 @@ class SendPage extends BasePage { showAddressAlert( context, S.of(context).address_detected, - S.of(context).address_from_domain(domain)); + S.of(context).address_from_domain(parsedAddress.name)); break; case ParseFrom.openAlias: showAddressAlert( context, S.of(context).openalias_alert_title, - S.of(context).openalias_alert_content(domain)); + S.of(context).openalias_alert_content(parsedAddress.name)); break; case ParseFrom.notParsed: break;