mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
fix donation link saved regardless of the current wallet (#1491)
Some checks are pending
Cache Dependencies / test (push) Waiting to run
Some checks are pending
Cache Dependencies / test (push) Waiting to run
This commit is contained in:
parent
1690f6af1e
commit
4a0096985a
5 changed files with 58 additions and 38 deletions
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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<SharedPreferences>();
|
||||
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,
|
||||
|
|
|
@ -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(
|
||||
|
@ -99,18 +98,24 @@ class AnonPayInvoicePage extends BasePage {
|
|||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: Container(
|
||||
decoration: responsiveLayoutUtil.shouldRenderMobileUI ? BoxDecoration(
|
||||
decoration: responsiveLayoutUtil.shouldRenderMobileUI
|
||||
? BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Theme.of(context).extension<ExchangePageTheme>()!.firstGradientTopPanelColor,
|
||||
Theme.of(context).extension<ExchangePageTheme>()!.secondGradientTopPanelColor,
|
||||
Theme.of(context)
|
||||
.extension<ExchangePageTheme>()!
|
||||
.firstGradientTopPanelColor,
|
||||
Theme.of(context)
|
||||
.extension<ExchangePageTheme>()!
|
||||
.secondGradientTopPanelColor,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
) : null,
|
||||
)
|
||||
: null,
|
||||
child: Observer(builder: (_) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 120, 24, 0),
|
||||
|
@ -143,7 +148,9 @@ class AnonPayInvoicePage extends BasePage {
|
|||
: S.of(context).anonpay_description("a donation link", "donate"),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<ExchangePageTheme>()!.receiveAmountColor,
|
||||
color: Theme.of(context)
|
||||
.extension<ExchangePageTheme>()!
|
||||
.receiveAmountColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12),
|
||||
),
|
||||
|
@ -199,8 +206,12 @@ class AnonPayInvoicePage extends BasePage {
|
|||
final sharedPreferences = getIt.get<SharedPreferences>();
|
||||
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,
|
||||
|
|
|
@ -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,6 +164,9 @@ 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);
|
||||
|
@ -177,7 +181,10 @@ abstract class AnonInvoicePageViewModelBase with Store {
|
|||
Future<void> _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;
|
||||
|
|
Loading…
Reference in a new issue