diff --git a/cw_solana/lib/solana_client.dart b/cw_solana/lib/solana_client.dart index 6ed8cab29..38f2864df 100644 --- a/cw_solana/lib/solana_client.dart +++ b/cw_solana/lib/solana_client.dart @@ -456,7 +456,7 @@ class SolanaWalletClient { funder: ownerKeypair, ); } catch (e) { - throw Exception('Insufficient lamports balance to complete this transaction'); + throw Exception('Insufficient SOL balance to complete this transaction'); } // Input by the user diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index aebf9ccd5..fdcd54c9c 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -77,6 +77,7 @@ class PreferencesKey { static const moneroSeedType = 'monero_seed_type'; static const clearnetDonationLink = 'clearnet_donation_link'; static const onionDonationLink = 'onion_donation_link'; + static const donationLinkWalletName = 'donation_link_wallet_name'; static const lastSeenAppVersion = 'last_seen_app_version'; static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard'; static const isNewInstall = 'is_new_install'; diff --git a/lib/src/screens/dashboard/pages/address_page.dart b/lib/src/screens/dashboard/pages/address_page.dart index c322843ef..3ac97740d 100644 --- a/lib/src/screens/dashboard/pages/address_page.dart +++ b/lib/src/screens/dashboard/pages/address_page.dart @@ -3,7 +3,6 @@ import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart'; import 'package:cake_wallet/themes/extensions/keyboard_theme.dart'; import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; -import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart'; import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart'; import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cw_core/receive_page_option.dart'; @@ -14,7 +13,6 @@ import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart'; import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/share_util.dart'; -import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/receive_option_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cw_core/wallet_type.dart'; @@ -171,8 +169,7 @@ class AddressPage extends BasePage { textSize: 14, height: 50, ); - } - else { + } else { return const SizedBox(); } }), @@ -204,8 +201,12 @@ class AddressPage extends BasePage { final sharedPreferences = getIt.get(); final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink); final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink); + final donationWalletName = + sharedPreferences.getString(PreferencesKey.donationLinkWalletName); - if (clearnetUrl != null && onionUrl != null) { + if (clearnetUrl != null && + onionUrl != null && + addressListViewModel.wallet.name == donationWalletName) { Navigator.pushNamed( context, Routes.anonPayReceivePage, diff --git a/lib/src/screens/receive/anonpay_invoice_page.dart b/lib/src/screens/receive/anonpay_invoice_page.dart index f33cdcc5b..2c66b95db 100644 --- a/lib/src/screens/receive/anonpay_invoice_page.dart +++ b/lib/src/screens/receive/anonpay_invoice_page.dart @@ -60,8 +60,7 @@ class AnonPayInvoicePage extends BasePage { @override Widget middle(BuildContext context) => PresentReceiveOptionPicker( - receiveOptionViewModel: receiveOptionViewModel, - color: titleColor(context)); + receiveOptionViewModel: receiveOptionViewModel, color: titleColor(context)); @override Widget trailing(BuildContext context) => TrailButton( @@ -87,30 +86,36 @@ class AnonPayInvoicePage extends BasePage { config: KeyboardActionsConfig( keyboardActionsPlatform: KeyboardActionsPlatform.IOS, keyboardBarColor: Theme.of(context).extension()!.keyboardBarColor, - nextFocus: false, - actions: [ - KeyboardActionsItem( - focusNode: _amountFocusNode, - toolbarButtons: [(_) => KeyboardDoneButton()], - ), - ]), - child: Container( - color: Theme.of(context).colorScheme.background, - child: ScrollableWithBottomSection( - contentPadding: EdgeInsets.only(bottom: 24), - content: Container( - decoration: responsiveLayoutUtil.shouldRenderMobileUI ? BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), - gradient: LinearGradient( - colors: [ - Theme.of(context).extension()!.firstGradientTopPanelColor, - Theme.of(context).extension()!.secondGradientTopPanelColor, - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, + nextFocus: false, + actions: [ + KeyboardActionsItem( + focusNode: _amountFocusNode, + toolbarButtons: [(_) => KeyboardDoneButton()], ), - ) : null, + ]), + child: Container( + color: Theme.of(context).colorScheme.background, + child: ScrollableWithBottomSection( + contentPadding: EdgeInsets.only(bottom: 24), + content: Container( + decoration: responsiveLayoutUtil.shouldRenderMobileUI + ? BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), + gradient: LinearGradient( + colors: [ + Theme.of(context) + .extension()! + .firstGradientTopPanelColor, + Theme.of(context) + .extension()! + .secondGradientTopPanelColor, + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + ) + : null, child: Observer(builder: (_) { return Padding( padding: EdgeInsets.fromLTRB(24, 120, 24, 0), @@ -143,9 +148,11 @@ class AnonPayInvoicePage extends BasePage { : S.of(context).anonpay_description("a donation link", "donate"), textAlign: TextAlign.center, style: TextStyle( - color: Theme.of(context).extension()!.receiveAmountColor, - fontWeight: FontWeight.w500, - fontSize: 12), + color: Theme.of(context) + .extension()! + .receiveAmountColor, + fontWeight: FontWeight.w500, + fontSize: 12), ), ), ), @@ -172,7 +179,7 @@ class AnonPayInvoicePage extends BasePage { anonInvoicePageViewModel.generateDonationLink(); } }, - color: Theme.of(context).primaryColor, + color: Theme.of(context).primaryColor, textColor: Colors.white, isLoading: anonInvoicePageViewModel.state is IsExecutingState, ), @@ -199,8 +206,12 @@ class AnonPayInvoicePage extends BasePage { final sharedPreferences = getIt.get(); final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink); final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink); + final donationWalletName = + sharedPreferences.getString(PreferencesKey.donationLinkWalletName); - if (clearnetUrl != null && onionUrl != null) { + if (clearnetUrl != null && + onionUrl != null && + anonInvoicePageViewModel.currentWalletName == donationWalletName) { Navigator.pushReplacementNamed(context, Routes.anonPayReceivePage, arguments: AnonpayDonationLinkInfo( clearnetUrl: clearnetUrl, diff --git a/lib/view_model/anon_invoice_page_view_model.dart b/lib/view_model/anon_invoice_page_view_model.dart index 187eea375..39992dca7 100644 --- a/lib/view_model/anon_invoice_page_view_model.dart +++ b/lib/view_model/anon_invoice_page_view_model.dart @@ -150,6 +150,7 @@ abstract class AnonInvoicePageViewModelBase with Store { await sharedPreferences.setString(PreferencesKey.clearnetDonationLink, result.clearnetUrl); await sharedPreferences.setString(PreferencesKey.onionDonationLink, result.onionUrl); + await sharedPreferences.setString(PreferencesKey.donationLinkWalletName, _wallet.name); state = ExecutedSuccessfullyState(payload: result); } @@ -163,10 +164,13 @@ abstract class AnonInvoicePageViewModelBase with Store { maximum = limit.max != null ? limit.max! / 4 : null; } + @computed + String get currentWalletName => _wallet.name; + @action void reset() { selectedCurrency = walletTypeToCryptoCurrency(_wallet.type); - cryptoCurrency = walletTypeToCryptoCurrency(_wallet.type); + cryptoCurrency = walletTypeToCryptoCurrency(_wallet.type); receipientEmail = ''; receipientName = ''; description = ''; @@ -177,7 +181,10 @@ abstract class AnonInvoicePageViewModelBase with Store { Future _getPreviousDonationLink() async { if (pageOption == ReceivePageOption.anonPayDonationLink) { final donationLink = sharedPreferences.getString(PreferencesKey.clearnetDonationLink); - if (donationLink != null) { + final donationLinkWalletName = + sharedPreferences.getString(PreferencesKey.donationLinkWalletName); + + if (donationLink != null && currentWalletName == donationLinkWalletName) { final url = Uri.parse(donationLink); url.queryParameters.forEach((key, value) { if (key == 'name') receipientName = value;