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,
|
funder: ownerKeypair,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception('Insufficient lamports balance to complete this transaction');
|
throw Exception('Insufficient SOL balance to complete this transaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input by the user
|
// Input by the user
|
||||||
|
|
|
@ -77,6 +77,7 @@ class PreferencesKey {
|
||||||
static const moneroSeedType = 'monero_seed_type';
|
static const moneroSeedType = 'monero_seed_type';
|
||||||
static const clearnetDonationLink = 'clearnet_donation_link';
|
static const clearnetDonationLink = 'clearnet_donation_link';
|
||||||
static const onionDonationLink = 'onion_donation_link';
|
static const onionDonationLink = 'onion_donation_link';
|
||||||
|
static const donationLinkWalletName = 'donation_link_wallet_name';
|
||||||
static const lastSeenAppVersion = 'last_seen_app_version';
|
static const lastSeenAppVersion = 'last_seen_app_version';
|
||||||
static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard';
|
static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard';
|
||||||
static const isNewInstall = 'is_new_install';
|
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/themes/extensions/keyboard_theme.dart';
|
||||||
import 'package:cake_wallet/di.dart';
|
import 'package:cake_wallet/di.dart';
|
||||||
import 'package:cake_wallet/src/screens/base_page.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/anonpay/anonpay_donation_link_info.dart';
|
||||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
import 'package:cw_core/receive_page_option.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/themes/theme_base.dart';
|
||||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||||
import 'package:cake_wallet/utils/share_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/receive_option_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
@ -171,8 +169,7 @@ class AddressPage extends BasePage {
|
||||||
textSize: 14,
|
textSize: 14,
|
||||||
height: 50,
|
height: 50,
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
@ -204,8 +201,12 @@ class AddressPage extends BasePage {
|
||||||
final sharedPreferences = getIt.get<SharedPreferences>();
|
final sharedPreferences = getIt.get<SharedPreferences>();
|
||||||
final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
||||||
final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink);
|
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(
|
Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
Routes.anonPayReceivePage,
|
Routes.anonPayReceivePage,
|
||||||
|
|
|
@ -60,8 +60,7 @@ class AnonPayInvoicePage extends BasePage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget middle(BuildContext context) => PresentReceiveOptionPicker(
|
Widget middle(BuildContext context) => PresentReceiveOptionPicker(
|
||||||
receiveOptionViewModel: receiveOptionViewModel,
|
receiveOptionViewModel: receiveOptionViewModel, color: titleColor(context));
|
||||||
color: titleColor(context));
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget trailing(BuildContext context) => TrailButton(
|
Widget trailing(BuildContext context) => TrailButton(
|
||||||
|
@ -87,30 +86,36 @@ class AnonPayInvoicePage extends BasePage {
|
||||||
config: KeyboardActionsConfig(
|
config: KeyboardActionsConfig(
|
||||||
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
||||||
keyboardBarColor: Theme.of(context).extension<KeyboardTheme>()!.keyboardBarColor,
|
keyboardBarColor: Theme.of(context).extension<KeyboardTheme>()!.keyboardBarColor,
|
||||||
nextFocus: false,
|
nextFocus: false,
|
||||||
actions: [
|
actions: [
|
||||||
KeyboardActionsItem(
|
KeyboardActionsItem(
|
||||||
focusNode: _amountFocusNode,
|
focusNode: _amountFocusNode,
|
||||||
toolbarButtons: [(_) => KeyboardDoneButton()],
|
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<ExchangePageTheme>()!.firstGradientTopPanelColor,
|
|
||||||
Theme.of(context).extension<ExchangePageTheme>()!.secondGradientTopPanelColor,
|
|
||||||
],
|
|
||||||
begin: Alignment.topLeft,
|
|
||||||
end: Alignment.bottomRight,
|
|
||||||
),
|
),
|
||||||
) : 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<ExchangePageTheme>()!
|
||||||
|
.firstGradientTopPanelColor,
|
||||||
|
Theme.of(context)
|
||||||
|
.extension<ExchangePageTheme>()!
|
||||||
|
.secondGradientTopPanelColor,
|
||||||
|
],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
child: Observer(builder: (_) {
|
child: Observer(builder: (_) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.fromLTRB(24, 120, 24, 0),
|
padding: EdgeInsets.fromLTRB(24, 120, 24, 0),
|
||||||
|
@ -143,9 +148,11 @@ class AnonPayInvoicePage extends BasePage {
|
||||||
: S.of(context).anonpay_description("a donation link", "donate"),
|
: S.of(context).anonpay_description("a donation link", "donate"),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).extension<ExchangePageTheme>()!.receiveAmountColor,
|
color: Theme.of(context)
|
||||||
fontWeight: FontWeight.w500,
|
.extension<ExchangePageTheme>()!
|
||||||
fontSize: 12),
|
.receiveAmountColor,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -172,7 +179,7 @@ class AnonPayInvoicePage extends BasePage {
|
||||||
anonInvoicePageViewModel.generateDonationLink();
|
anonInvoicePageViewModel.generateDonationLink();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
isLoading: anonInvoicePageViewModel.state is IsExecutingState,
|
isLoading: anonInvoicePageViewModel.state is IsExecutingState,
|
||||||
),
|
),
|
||||||
|
@ -199,8 +206,12 @@ class AnonPayInvoicePage extends BasePage {
|
||||||
final sharedPreferences = getIt.get<SharedPreferences>();
|
final sharedPreferences = getIt.get<SharedPreferences>();
|
||||||
final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
||||||
final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink);
|
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,
|
Navigator.pushReplacementNamed(context, Routes.anonPayReceivePage,
|
||||||
arguments: AnonpayDonationLinkInfo(
|
arguments: AnonpayDonationLinkInfo(
|
||||||
clearnetUrl: clearnetUrl,
|
clearnetUrl: clearnetUrl,
|
||||||
|
|
|
@ -150,6 +150,7 @@ abstract class AnonInvoicePageViewModelBase with Store {
|
||||||
|
|
||||||
await sharedPreferences.setString(PreferencesKey.clearnetDonationLink, result.clearnetUrl);
|
await sharedPreferences.setString(PreferencesKey.clearnetDonationLink, result.clearnetUrl);
|
||||||
await sharedPreferences.setString(PreferencesKey.onionDonationLink, result.onionUrl);
|
await sharedPreferences.setString(PreferencesKey.onionDonationLink, result.onionUrl);
|
||||||
|
await sharedPreferences.setString(PreferencesKey.donationLinkWalletName, _wallet.name);
|
||||||
|
|
||||||
state = ExecutedSuccessfullyState(payload: result);
|
state = ExecutedSuccessfullyState(payload: result);
|
||||||
}
|
}
|
||||||
|
@ -163,10 +164,13 @@ abstract class AnonInvoicePageViewModelBase with Store {
|
||||||
maximum = limit.max != null ? limit.max! / 4 : null;
|
maximum = limit.max != null ? limit.max! / 4 : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
String get currentWalletName => _wallet.name;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void reset() {
|
void reset() {
|
||||||
selectedCurrency = walletTypeToCryptoCurrency(_wallet.type);
|
selectedCurrency = walletTypeToCryptoCurrency(_wallet.type);
|
||||||
cryptoCurrency = walletTypeToCryptoCurrency(_wallet.type);
|
cryptoCurrency = walletTypeToCryptoCurrency(_wallet.type);
|
||||||
receipientEmail = '';
|
receipientEmail = '';
|
||||||
receipientName = '';
|
receipientName = '';
|
||||||
description = '';
|
description = '';
|
||||||
|
@ -177,7 +181,10 @@ abstract class AnonInvoicePageViewModelBase with Store {
|
||||||
Future<void> _getPreviousDonationLink() async {
|
Future<void> _getPreviousDonationLink() async {
|
||||||
if (pageOption == ReceivePageOption.anonPayDonationLink) {
|
if (pageOption == ReceivePageOption.anonPayDonationLink) {
|
||||||
final donationLink = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
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);
|
final url = Uri.parse(donationLink);
|
||||||
url.queryParameters.forEach((key, value) {
|
url.queryParameters.forEach((key, value) {
|
||||||
if (key == 'name') receipientName = value;
|
if (key == 'name') receipientName = value;
|
||||||
|
|
Loading…
Reference in a new issue