From d2cc8128847a8a9fd74f03844741b03af51970e5 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo <41484542+godilite@users.noreply.github.com> Date: Tue, 15 Mar 2022 10:11:53 +0100 Subject: [PATCH] Cw 45 implement yat sending (#269) * resolve YAT emoji * remove animation in route builder change YAT api * remove yat sending page * fix crypto address resolving * check if text is emoji * use getter for string extension hasOnlyEmojis * refactor parsed domain from address * update PR based on changes from code review * import missing dependencies --- lib/core/yat_service.dart | 47 ++++++ lib/di.dart | 6 + lib/entities/emoji_string_extension.dart | 25 ++++ lib/entities/parse_address_from_domain.dart | 81 ++++------ lib/entities/parsed_address.dart | 46 ++++++ lib/entities/yat_record.dart | 16 ++ lib/main.dart | 2 - lib/src/screens/dashboard/dashboard_page.dart | 18 --- lib/src/screens/exchange/exchange_page.dart | 4 +- lib/src/screens/send/send_page.dart | 12 +- lib/src/screens/yat/circle_clipper.dart | 15 -- lib/src/screens/yat/yat_alert.dart | 124 --------------- lib/src/screens/yat/yat_sending.dart | 141 ------------------ lib/view_model/send/output.dart | 3 +- .../settings/settings_view_model.dart | 1 - 15 files changed, 178 insertions(+), 363 deletions(-) create mode 100644 lib/core/yat_service.dart create mode 100644 lib/entities/emoji_string_extension.dart create mode 100644 lib/entities/yat_record.dart delete mode 100644 lib/src/screens/yat/circle_clipper.dart delete mode 100644 lib/src/screens/yat/yat_alert.dart delete mode 100644 lib/src/screens/yat/yat_sending.dart diff --git a/lib/core/yat_service.dart b/lib/core/yat_service.dart new file mode 100644 index 000000000..0383d4ba5 --- /dev/null +++ b/lib/core/yat_service.dart @@ -0,0 +1,47 @@ +import 'dart:convert'; + +import 'package:cake_wallet/entities/yat_record.dart'; +import 'package:http/http.dart'; + +class YatService { + static bool isDevMode = false; + + static String get apiUrl => + YatService.isDevMode ? YatService.apiDevUrl : YatService.apiReleaseUrl; + static const apiReleaseUrl = "https://a.y.at"; + static const apiDevUrl = 'https://yat.fyi'; + + static String lookupEmojiUrl(String emojiId) => + "$apiUrl/emoji_id/$emojiId/payment"; + + static const tags = { + 'XMR': '0x1001,0x1002', + 'BTC': '0x1003', + 'LTC': '0x3fff' + }; + + Future> fetchYatAddress(String emojiId, String ticker) async { + final formattedTicker = ticker.toUpperCase(); + final formattedEmojiId = emojiId.replaceAll(' ', ''); + final uri = Uri.parse(lookupEmojiUrl(formattedEmojiId)).replace( + queryParameters: { + "tags": tags[formattedTicker] + }); + + final yatRecords = []; + + try { + final response = await get(uri); + final resBody = json.decode(response.body) as Map; + + final results = resBody["result"] as Map; + results.forEach((dynamic key, dynamic value) { + yatRecords.add(YatRecord.fromJson(value as Map)); + }); + + return yatRecords; + } catch (_) { + return yatRecords; + } + } +} diff --git a/lib/di.dart b/lib/di.dart index b117a2a96..392480521 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -1,3 +1,5 @@ +import 'package:cake_wallet/core/yat_service.dart'; +import 'package:cake_wallet/entities/parse_address_from_domain.dart'; import 'package:cake_wallet/entities/wake_lock.dart'; import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/bitcoin/bitcoin.dart'; @@ -623,5 +625,9 @@ Future setup( getIt.registerFactory(() => WakeLock()); + getIt.registerFactory(() => YatService()); + + getIt.registerFactory(() => AddressResolver(yatService: getIt.get())); + _isSetupFinished = true; } diff --git a/lib/entities/emoji_string_extension.dart b/lib/entities/emoji_string_extension.dart new file mode 100644 index 000000000..da386dae1 --- /dev/null +++ b/lib/entities/emoji_string_extension.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; + +extension Emoji on String { + static final REGEX_EMOJI = RegExp( + r'[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}' + r'\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}' + r'-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}' + r'\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}' + r'-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}' + r'\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}' + r'-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}' + r'\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}' + r'-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}\u{200d}]+', + unicode: true, + ); + + bool _hasOnlyEmojis() { + final parsedText = this.replaceAll(' ', ''); + for (final c in Characters(parsedText)) + if (!REGEX_EMOJI.hasMatch(c)) return false; + return true; + } + /// Returns true if the given text contains only emojis. + bool get hasOnlyEmojis => _hasOnlyEmojis(); +} diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 056658067..76459d0e0 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -1,10 +1,17 @@ +import 'package:cake_wallet/core/yat_service.dart'; import 'package:cake_wallet/entities/openalias_record.dart'; import 'package:cake_wallet/entities/parsed_address.dart'; import 'package:cake_wallet/entities/unstoppable_domain_address.dart'; -import 'package:cake_wallet/store/yat/yat_store.dart'; -import 'package:cw_core/wallet_type.dart'; +import 'package:cake_wallet/entities/emoji_string_extension.dart'; +import 'package:flutter/foundation.dart'; -const unstoppableDomains = [ +class AddressResolver { + + AddressResolver({@required this.yatService}); + + final YatService yatService; + + static const unstoppableDomains = [ 'crypto', 'zil', 'x', @@ -17,57 +24,33 @@ const unstoppableDomains = [ 'blockchain' ]; -Future parseAddressFromDomain( - String domain, String ticker) async { - try { - final formattedName = OpenaliasRecord.formatDomainName(domain); - final domainParts = formattedName.split('.'); - final name = domainParts.last; - - if (domainParts.length <= 1 || domainParts.first.isEmpty || name.isEmpty) { - try { - final addresses = await fetchYatAddress(domain, ticker); - - if (addresses?.isEmpty ?? true) { - return ParsedAddress( - addresses: [domain], parseFrom: ParseFrom.yatRecord); - } - - return ParsedAddress( - addresses: addresses, name: domain, parseFrom: ParseFrom.yatRecord); - } catch (e) { - return ParsedAddress(addresses: [domain]); + Future resolve(String text, String ticker) async { + try { + if (text.hasOnlyEmojis) { + final addresses = await yatService.fetchYatAddress(text, ticker); + return ParsedAddress.fetchEmojiAddress(addresses: addresses, name: text); } - } + final formattedName = OpenaliasRecord.formatDomainName(text); + final domainParts = formattedName.split('.'); + final name = domainParts.last; - if (unstoppableDomains.any((domain) => name.contains(domain))) { - final address = await fetchUnstoppableDomainAddress(domain, ticker); - - if (address?.isEmpty ?? true) { - return ParsedAddress(addresses: [domain]); + if (domainParts.length <= 1 || domainParts.first.isEmpty || name.isEmpty) { + return ParsedAddress(addresses: [text]); } - return ParsedAddress( - addresses: [address], - name: domain, - parseFrom: ParseFrom.unstoppableDomains); + if (unstoppableDomains.any((domain) => name.contains(domain))) { + final address = await fetchUnstoppableDomainAddress(text, ticker); + return ParsedAddress.fetchUnstoppableDomainAddress(address: address, name: text); + } + + final record = await OpenaliasRecord.fetchAddressAndName( + formattedName: formattedName, ticker: ticker); + return ParsedAddress.fetchOpenAliasAddress(record: record, name: text); + + } catch (e) { + print(e.toString()); } - final record = await OpenaliasRecord.fetchAddressAndName( - formattedName: formattedName, ticker: ticker); - - if (record == null || record.address.contains(formattedName)) { - return ParsedAddress(addresses: [domain]); - } - - return ParsedAddress( - addresses: [record.address], - name: record.name, - description: record.description, - parseFrom: ParseFrom.openAlias); - } catch (e) { - print(e.toString()); + return ParsedAddress(addresses: [text]); } - - return ParsedAddress(addresses: [domain]); } diff --git a/lib/entities/parsed_address.dart b/lib/entities/parsed_address.dart index 11b87d9f5..2905ce89f 100644 --- a/lib/entities/parsed_address.dart +++ b/lib/entities/parsed_address.dart @@ -1,3 +1,7 @@ +import 'package:cake_wallet/entities/openalias_record.dart'; +import 'package:cake_wallet/entities/yat_record.dart'; +import 'package:flutter/material.dart'; + enum ParseFrom { unstoppableDomains, openAlias, yatRecord, notParsed } class ParsedAddress { @@ -12,4 +16,46 @@ class ParsedAddress { final String name; final String description; final ParseFrom parseFrom; + + factory ParsedAddress.fetchEmojiAddress({ + @required List addresses, + @required String name, + }){ + if (addresses?.isEmpty ?? true) { + return ParsedAddress( + addresses: [name], parseFrom: ParseFrom.yatRecord); + } + return ParsedAddress( + addresses: addresses.map((e) => e.address).toList(), + name: name, + parseFrom: ParseFrom.yatRecord, + ); + } + + factory ParsedAddress.fetchUnstoppableDomainAddress({ + @required String address, + @required String name, + }){ + if (address?.isEmpty ?? true) { + return ParsedAddress(addresses: [name]); + } + return ParsedAddress( + addresses: [address], + name: name, + parseFrom: ParseFrom.unstoppableDomains, + ); + } + + factory ParsedAddress.fetchOpenAliasAddress({@required OpenaliasRecord record, @required String name}){ + final formattedName = OpenaliasRecord.formatDomainName(name); + if (record == null || record.address.contains(formattedName)) { + return ParsedAddress(addresses: [name]); + } + return ParsedAddress( + addresses: [record.address], + name: record.name, + description: record.description, + parseFrom: ParseFrom.openAlias, + ); + } } diff --git a/lib/entities/yat_record.dart b/lib/entities/yat_record.dart new file mode 100644 index 000000000..4237518df --- /dev/null +++ b/lib/entities/yat_record.dart @@ -0,0 +1,16 @@ +class YatRecord { + String category; + String address; + + YatRecord({ + this.category, + this.address, + }); + + YatRecord.fromJson(Map json) { + address = json['address'] as String; + category = json['category'] as String; + } + + +} diff --git a/lib/main.dart b/lib/main.dart index 62a12ca90..749f02b66 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,9 +2,7 @@ import 'dart:async'; import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/entities/language_service.dart'; import 'package:cake_wallet/buy/order.dart'; -import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; import 'package:cake_wallet/store/yat/yat_store.dart'; -import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 1b75afb91..903666279 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -178,24 +178,6 @@ class DashboardPage extends BasePage { pages.add(TransactionsPage(dashboardViewModel: walletViewModel)); _isEffectsInstalled = true; - //if (walletViewModel.shouldShowYatPopup) { - // await Future.delayed(Duration(seconds: 1)); - - // if (currentRouteSettings.name == Routes.preSeed - // || currentRouteSettings.name == Routes.seed) { - // return; - // } - - // await showPopUp( - // context: context, - // builder: (BuildContext context) { - // return YatPopup( - // dashboardViewModel: walletViewModel, - // onClose: () => Navigator.of(context).pop()); - // }); - // walletViewModel.furtherShowYatPopup(false); - //} - autorun((_) async { if (!walletViewModel.isOutdatedElectrumWallet) { return; diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 1473d1547..39a274ccd 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -1,5 +1,5 @@ import 'dart:ui'; -import 'package:cake_wallet/entities/parsed_address.dart'; +import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/utils/debounce.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/wallet_type.dart'; @@ -790,7 +790,7 @@ class ExchangePage extends BasePage { Future fetchParsedAddress( BuildContext context, String domain, String ticker) async { - final parsedAddress = await parseAddressFromDomain(domain, ticker); + final parsedAddress = await getIt.get().resolve(domain, ticker); final address = await extractAddressFromParsed(context, parsedAddress); return address; } diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 71fba3b4f..8340641a4 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -1,6 +1,6 @@ import 'dart:ui'; +import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart'; import 'package:cake_wallet/src/screens/send/widgets/send_card.dart'; -import 'package:cake_wallet/src/screens/yat/widgets/yat_close_button.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/template_tile.dart'; import 'package:cake_wallet/view_model/send/output.dart'; @@ -22,9 +22,6 @@ import 'package:dotted_border/dotted_border.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; -import 'package:cake_wallet/store/yat/yat_store.dart'; -import 'package:cake_wallet/src/screens/yat/yat_sending.dart'; -import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart'; class SendPage extends BasePage { SendPage({@required this.sendViewModel}) : _formKey = GlobalKey(); @@ -304,11 +301,6 @@ class SendPage extends BasePage { await sendViewModel.createTransaction(); - if (!sendViewModel.isBatchSending && - sendViewModel.hasYat) { - Navigator.of(context) - .push(YatSending.createRoute(sendViewModel)); - } }, text: S.of(context).send, color: Theme.of(context).accentTextTheme.body2.color, @@ -345,7 +337,7 @@ class SendPage extends BasePage { } if (state is ExecutedSuccessfullyState && - !(!sendViewModel.isBatchSending && sendViewModel.hasYat)) { + !sendViewModel.isBatchSending) { WidgetsBinding.instance.addPostFrameCallback((_) { showPopUp( context: context, diff --git a/lib/src/screens/yat/circle_clipper.dart b/lib/src/screens/yat/circle_clipper.dart deleted file mode 100644 index 7009aaf95..000000000 --- a/lib/src/screens/yat/circle_clipper.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/material.dart'; - -class CircleClipper extends CustomClipper { - CircleClipper(this.center, this.radius); - - final Offset center; - final double radius; - - @override - Path getClip(Size size) => - Path()..addOval(Rect.fromCircle(radius: radius, center: center)); - - @override - bool shouldReclip(covariant CustomClipper oldClipper) => true; -} \ No newline at end of file diff --git a/lib/src/screens/yat/yat_alert.dart b/lib/src/screens/yat/yat_alert.dart deleted file mode 100644 index 9d68a2926..000000000 --- a/lib/src/screens/yat/yat_alert.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'package:cake_wallet/src/screens/yat/widgets/yat_bar.dart'; -import 'package:cake_wallet/src/widgets/primary_button.dart'; -import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; -import 'package:cake_wallet/store/yat/yat_store.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:cake_wallet/palette.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:cake_wallet/generated/i18n.dart'; -import 'package:lottie/lottie.dart'; - -class YatAlert extends StatelessWidget { - YatAlert(this.yatStore); - - final YatStore yatStore; - static const aspectRatioImage = 1.133; - final animation = Lottie.asset('assets/animation/anim1.json'); - - @override - Widget build(BuildContext context) { - final screenHeight = MediaQuery.of(context).size.height; - final screenWidth = MediaQuery.of(context).size.width; - - return Container( - height: screenHeight, - width: screenWidth, - color: Colors.white, - child: ScrollableWithBottomSection( - contentPadding: EdgeInsets.only(top: 40, bottom: 40), - content: Column( - children: [ - Container( - height: 45, - padding: EdgeInsets.only(left: 24, right: 24), - child: YatBar(onClose: () => Navigator.of(context).pop()) - ), - animation, - Container( - padding: EdgeInsets.only(left: 30, right: 30), - child: Column( - children: [ - Text( - S.of(context).yat_alert_title, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - fontFamily: 'Lato', - color: Colors.black, - decoration: TextDecoration.none, - ) - ), - Padding( - padding: EdgeInsets.only(top: 20), - child: Text( - S.of(context).yat_alert_content, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.normal, - fontFamily: 'Lato', - color: Colors.black, - decoration: TextDecoration.none, - ) - ) - ) - ] - ) - ) - ] - ), - bottomSectionPadding: EdgeInsets.fromLTRB(24, 0, 24, 40), - bottomSection: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - PrimaryIconButton( - text: S.of(context).get_your_yat, - textColor: Colors.white, - color: Palette.protectiveBlue, - borderColor: Palette.protectiveBlue, - iconColor: Colors.white, - iconBackgroundColor: Colors.transparent, - iconData: CupertinoIcons - .arrow_up_right_square, - mainAxisAlignment: MainAxisAlignment.end, - onPressed: () { - var createNewYatUrl = YatLink.startFlowUrl; - final createNewYatUrlParameters = - yatStore.defineQueryParameters(); - - if (createNewYatUrlParameters.isNotEmpty) { - createNewYatUrl += '?sub1=' + createNewYatUrlParameters; - } - - launch(createNewYatUrl, forceSafariVC: false); - }), - Padding( - padding: EdgeInsets.only(top: 24), - child: PrimaryIconButton( - text: S.of(context).connect_an_existing_yat, - textColor: Colors.black, - color: Palette.blueAlice, - borderColor: Palette.blueAlice, - iconColor: Colors.black, - iconBackgroundColor: Colors.transparent, - iconData: CupertinoIcons - .arrow_up_right_square, - mainAxisAlignment: MainAxisAlignment.end, - onPressed: () { - String url = YatLink.baseUrl + YatLink.signInSuffix; - final parameters = - yatStore.defineQueryParameters(); - if (parameters.isNotEmpty) { - url += YatLink.queryParameter + parameters; - } - launch(url, forceSafariVC: false); - }) - ) - ] - ), - ) - ); - } -} \ No newline at end of file diff --git a/lib/src/screens/yat/yat_sending.dart b/lib/src/screens/yat/yat_sending.dart deleted file mode 100644 index 1e6de793e..000000000 --- a/lib/src/screens/yat/yat_sending.dart +++ /dev/null @@ -1,141 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:mobx/mobx.dart'; -import 'package:cake_wallet/src/screens/yat/widgets/yat_close_button.dart'; -import 'package:cake_wallet/view_model/send/send_view_model_state.dart'; -import 'package:cake_wallet/src/screens/yat/circle_clipper.dart'; -import 'package:cake_wallet/src/screens/base_page.dart'; -import 'package:cake_wallet/generated/i18n.dart'; -import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; -import 'package:cake_wallet/utils/show_pop_up.dart'; -import 'package:cake_wallet/src/widgets/primary_button.dart'; -import 'package:cake_wallet/store/yat/yat_store.dart'; -import 'package:cake_wallet/core/execution_state.dart'; -import 'package:cake_wallet/view_model/send/send_view_model.dart'; - -class YatSending extends BasePage { - YatSending(this.sendViewModel); - - static Route createRoute(SendViewModel sendViewModel) { - return PageRouteBuilder( - transitionDuration: Duration(seconds: 1), - reverseTransitionDuration: Duration(seconds: 1), - opaque: false, - barrierDismissible: false, - pageBuilder: (context, animation, secondaryAnimation) => YatSending(sendViewModel), - transitionsBuilder: (context, animation, secondaryAnimation, child) { - final screenSize = MediaQuery.of(context).size; - final center = Offset(screenSize.width / 2, screenSize.height / 2); - final endRadius = screenSize.height * 1.2; - final tween = Tween(begin: 0.0, end: endRadius); - - return ClipPath( - clipper: CircleClipper(center, animation.drive(tween).value), - child: child, - ); - }, - ); - } - - final SendViewModel sendViewModel; - - @override - Color get titleColor => Colors.white; - - @override - bool get resizeToAvoidBottomInset => false; - - @override - bool get extendBodyBehindAppBar => true; - - @override - AppBarStyle get appBarStyle => AppBarStyle.transparent; - - @override - Widget trailing(context) => - YatCloseButton(onClose: () => Navigator.of(context).pop()); - - @override - Widget leading(BuildContext context) => Container(); - - @override - Widget body(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; - return Container( - color: Colors.black, - child: Stack( - children: [ - //Center( - // child:FutureBuilder( - // future: visualisationForEmojiId(sendViewModel.outputs.first.address), - // builder: (BuildContext context, AsyncSnapshot snapshot) { - // switch (snapshot.connectionState) { - // case ConnectionState.done: - // if (snapshot.hasError || snapshot.data.isEmpty) { - // return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white); - // } - - // return Image.network( - // snapshot.data, - // scale: 0.7, - // loadingBuilder: (Object z, Widget child, ImageChunkEvent loading) - // => loading != null - // ? CupertinoActivityIndicator(animating: true) - // : child); - // default: - // return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white); - // } - // }), - // ), - Positioned( - bottom: 20, - child: Container( - width: screenWidth, - padding: EdgeInsets.fromLTRB(20, 0, 20, 10), - child: Column(children: [ - Text( - 'You are sending ${sendViewModel.outputs.first.cryptoAmount} ${sendViewModel.currency.title} to ${sendViewModel.outputs.first.address}'.toUpperCase(), - style: TextStyle( - fontSize: 28, - decoration: TextDecoration.none, - color: Theme.of(context).accentTextTheme.display3.backgroundColor), - textAlign: TextAlign.center), - Container(height: 30), - LoadingPrimaryButton( - onPressed: () { - sendViewModel.commitTransaction(); - showPopUp( - context: context, - builder: (BuildContext popContext) { - return Observer(builder: (_) { - final state = sendViewModel.state; - - if (state is FailureState) { - Navigator.of(context).pop(); - } - - if (state is TransactionCommitted) { - return AlertWithOneAction( - alertTitle: '', - alertContent: S.of(popContext).send_success( - sendViewModel.currency - .toString()), - buttonText: S.of(popContext).ok, - buttonAction: () { - Navigator.of(popContext).pop(); - Navigator.of(context).pop(); - }); - } - - return Offstage(); - }); - }); - }, - text: S.of(context).confirm_sending, - color: Theme.of(context).accentTextTheme.body2.color, - textColor: Colors.white, - isLoading: sendViewModel.state is IsExecutingState || - sendViewModel.state is TransactionCommitting)])))])); - } -} \ No newline at end of file diff --git a/lib/view_model/send/output.dart b/lib/view_model/send/output.dart index eeca8fd2c..f8161a55f 100644 --- a/lib/view_model/send/output.dart +++ b/lib/view_model/send/output.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart'; import 'package:cake_wallet/entities/parse_address_from_domain.dart'; import 'package:cake_wallet/entities/parsed_address.dart'; @@ -216,7 +217,7 @@ abstract class OutputBase with Store { Future fetchParsedAddress(BuildContext context) async { final domain = address; final ticker = _wallet.currency.title.toLowerCase(); - parsedAddress = await parseAddressFromDomain(domain, ticker); + parsedAddress = await getIt.get().resolve(domain, ticker); extractedAddress = await extractAddressFromParsed(context, parsedAddress); note = parsedAddress.description; } diff --git a/lib/view_model/settings/settings_view_model.dart b/lib/view_model/settings/settings_view_model.dart index a07f7a87d..6f5bf8649 100644 --- a/lib/view_model/settings/settings_view_model.dart +++ b/lib/view_model/settings/settings_view_model.dart @@ -1,4 +1,3 @@ -import 'package:cake_wallet/src/screens/yat/yat_alert.dart'; import 'package:cake_wallet/store/yat/yat_store.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/settings/link_list_item.dart';