From 346a034d0a3b8cd41a508c4cd3cd7ecd0aaac5d2 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 12 Apr 2021 21:22:22 +0300 Subject: [PATCH 01/42] CAKE-306 | added MoonPay option for BTC buying; applied PreOrderPage to the app; created Wyre and MoonPay buy providers --- lib/buy/buy_amount.dart | 8 + lib/buy/buy_exception.dart | 12 + lib/buy/buy_provider.dart | 26 +++ lib/buy/buy_provider_description.dart | 21 ++ lib/buy/moonpay/moonpay_buy_provider.dart | 109 +++++++++ lib/{entities => buy}/order.dart | 11 +- lib/buy/wyre/wyre_buy_provider.dart | 161 ++++++++++++++ lib/di.dart | 19 +- lib/entities/wyre_service.dart | 39 +++- lib/main.dart | 2 +- lib/palette.dart | 1 + lib/router.dart | 8 +- lib/routes.dart | 1 + lib/src/screens/buy/pre_order_page.dart | 210 ++++++++++++++++++ .../screens/buy/widgets/buy_list_item.dart | 131 +++++++++++ lib/src/screens/dashboard/dashboard_page.dart | 40 +--- lib/src/screens/send/send_page.dart | 2 +- lib/store/dashboard/orders_store.dart | 2 +- lib/view_model/buy/buy_amount_view_model.dart | 28 +++ lib/view_model/buy/buy_item.dart | 29 +++ lib/view_model/buy/buy_view_model.dart | 81 +++++++ .../dashboard/dashboard_view_model.dart | 7 +- lib/view_model/dashboard/order_list_item.dart | 2 +- lib/view_model/order_details_view_model.dart | 2 +- lib/view_model/wyre_view_model.dart | 2 +- 25 files changed, 903 insertions(+), 51 deletions(-) create mode 100644 lib/buy/buy_amount.dart create mode 100644 lib/buy/buy_exception.dart create mode 100644 lib/buy/buy_provider.dart create mode 100644 lib/buy/buy_provider_description.dart create mode 100644 lib/buy/moonpay/moonpay_buy_provider.dart rename lib/{entities => buy}/order.dart (76%) create mode 100644 lib/buy/wyre/wyre_buy_provider.dart create mode 100644 lib/src/screens/buy/pre_order_page.dart create mode 100644 lib/src/screens/buy/widgets/buy_list_item.dart create mode 100644 lib/view_model/buy/buy_amount_view_model.dart create mode 100644 lib/view_model/buy/buy_item.dart create mode 100644 lib/view_model/buy/buy_view_model.dart diff --git a/lib/buy/buy_amount.dart b/lib/buy/buy_amount.dart new file mode 100644 index 000000000..d049c1e03 --- /dev/null +++ b/lib/buy/buy_amount.dart @@ -0,0 +1,8 @@ +import 'package:flutter/foundation.dart'; + +class BuyAmount { + BuyAmount({@required this.sourceAmount, @required this.destAmount}); + + final double sourceAmount; + final double destAmount; +} \ No newline at end of file diff --git a/lib/buy/buy_exception.dart b/lib/buy/buy_exception.dart new file mode 100644 index 000000000..28064fdfc --- /dev/null +++ b/lib/buy/buy_exception.dart @@ -0,0 +1,12 @@ +import 'package:flutter/foundation.dart'; +import 'package:cake_wallet/buy/buy_provider_description.dart'; + +class BuyException implements Exception { + BuyException({@required this.description, @required this.text}); + + final BuyProviderDescription description; + final String text; + + @override + String toString() => '${description.title}: $text'; +} \ No newline at end of file diff --git a/lib/buy/buy_provider.dart b/lib/buy/buy_provider.dart new file mode 100644 index 000000000..78ad54451 --- /dev/null +++ b/lib/buy/buy_provider.dart @@ -0,0 +1,26 @@ +import 'package:cake_wallet/buy/buy_amount.dart'; +import 'package:cake_wallet/buy/buy_provider_description.dart'; +import 'package:cake_wallet/buy/order.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; +import 'package:cake_wallet/entities/wallet_type.dart'; + +abstract class BuyProvider { + BuyProvider({this.wallet, this.isTestEnvironment}); + + final WalletBase wallet; + final bool isTestEnvironment; + + String get title; + BuyProviderDescription get description; + + WalletType get walletType => wallet.type; + String get walletAddress => wallet.address; + String get walletId => wallet.id; + + @override + String toString() => title; + + Future requestUrl(String amount, String sourceCurrency); + Future findOrderById(String id); + Future calculateAmount(String amount, String sourceCurrency); +} \ No newline at end of file diff --git a/lib/buy/buy_provider_description.dart b/lib/buy/buy_provider_description.dart new file mode 100644 index 000000000..46b3bcdc1 --- /dev/null +++ b/lib/buy/buy_provider_description.dart @@ -0,0 +1,21 @@ +import 'package:cake_wallet/entities/enumerable_item.dart'; + +class BuyProviderDescription extends EnumerableItem + with Serializable { + const BuyProviderDescription({String title, int raw}) + : super(title: title, raw: raw); + + static const wyre = BuyProviderDescription(title: 'Wyre', raw: 0); + static const moonPay = BuyProviderDescription(title: 'MoonPay', raw: 1); + + static BuyProviderDescription deserialize({int raw}) { + switch (raw) { + case 0: + return wyre; + case 1: + return moonPay; + default: + return null; + } + } +} \ No newline at end of file diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart new file mode 100644 index 000000000..972b2d2a4 --- /dev/null +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -0,0 +1,109 @@ +import 'dart:convert'; +import 'package:cake_wallet/buy/buy_exception.dart'; +import 'package:http/http.dart'; +import 'package:cake_wallet/buy/buy_amount.dart'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/buy_provider_description.dart'; +import 'package:cake_wallet/buy/order.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; +import 'package:cake_wallet/entities/wallet_type.dart'; +import 'package:cake_wallet/exchange/trade_state.dart'; +import 'package:cake_wallet/.secrets.g.dart' as secrets; + +class MoonPayBuyProvider extends BuyProvider { + MoonPayBuyProvider({WalletBase wallet, bool isTestEnvironment = false}) + : super(wallet: wallet, isTestEnvironment: isTestEnvironment) { + baseApiUrl = isTestEnvironment + ? _baseTestApiUrl + : _baseProductApiUrl; + } + + static const _baseTestApiUrl = 'https://buy-staging.moonpay.com'; + static const _baseProductApiUrl = 'https://api.moonpay.com'; + static const _currenciesSuffix = '/v3/currencies'; + static const _quoteSuffix = '/buy_quote'; + static const _transactionsSuffix = '/v1/transactions'; + static const _apiKey = secrets.moonPayApiKey; + + @override + String get title => 'MoonPay'; + + @override + BuyProviderDescription get description => BuyProviderDescription.moonPay; + + String get currencyCode => + walletTypeToCryptoCurrency(walletType).title.toLowerCase(); + + String baseApiUrl; + + @override + Future requestUrl(String amount, String sourceCurrency) async { + final enabledPaymentMethods = + 'credit_debit_card%2Capple_pay%2Cgoogle_pay%2Csamsung_pay' + '%2Csepa_bank_transfer%2Cgbp_bank_transfer%2Cgbp_open_banking_payment'; + + final originalUrl = baseApiUrl + '?apiKey=' + _apiKey + '¤cyCode=' + + currencyCode + '&enabledPaymentMethods=' + enabledPaymentMethods + + '&walletAddress=' + walletAddress + + '&baseCurrencyCode=' + sourceCurrency.toLowerCase() + + '&baseCurrencyAmount=' + amount + '&lockAmount=true' + + '&showAllCurrencies=false' + '&showWalletAddressForm=false'; + + return originalUrl; + } + + @override + Future calculateAmount(String amount, String sourceCurrency) async { + final url = baseApiUrl + _currenciesSuffix + '/$currencyCode' + + _quoteSuffix + '/?apiKey=' + _apiKey + + '&baseCurrencyAmount=' + amount + + '&baseCurrencyCode' + sourceCurrency.toLowerCase(); + + final response = await get(url); + + if (response.statusCode != 200) { + throw BuyException( + description: description, + text: 'Quote is not found!'); + } + + final responseJSON = json.decode(response.body) as Map; + final sourceAmount = responseJSON['totalAmount'] as double; + final destAmount = responseJSON['quoteCurrencyAmount'] as double; + + return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount); + } + + @override + Future findOrderById(String id) async { + final url = baseApiUrl + _transactionsSuffix + '/$id' + + '?apiKey=' + _apiKey; + + final response = await get(url); + + if (response.statusCode != 200) { + throw BuyException( + description: description, + text: 'Transaction $id is not found!'); + } + + final responseJSON = json.decode(response.body) as Map; + final status = responseJSON['status'] as String; + final state = TradeState.deserialize(raw: status.toLowerCase()); + final createdAt = responseJSON['createdAt'] as DateTime; + final amount = responseJSON['quoteCurrencyAmount'] as double; + + return Order( + id: id, + provider: description, + transferId: id, + from: 'USD', //FIXME + to: 'BTC', //FIXME + state: state, + createdAt: createdAt, + amount: amount.toString(), + receiveAddress: walletAddress, + walletId: walletId + ); + } +} \ No newline at end of file diff --git a/lib/entities/order.dart b/lib/buy/order.dart similarity index 76% rename from lib/entities/order.dart rename to lib/buy/order.dart index 1676edd99..54c13bd37 100644 --- a/lib/entities/order.dart +++ b/lib/buy/order.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:hive/hive.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/entities/format_amount.dart'; @@ -8,6 +9,7 @@ part 'order.g.dart'; class Order extends HiveObject { Order( {this.id, + BuyProviderDescription provider, this.transferId, this.from, this.to, @@ -16,7 +18,8 @@ class Order extends HiveObject { this.amount, this.receiveAddress, this.walletId}) - : stateRaw = state?.raw; + : providerRaw = provider?.raw, + stateRaw = state?.raw; static const typeId = 8; static const boxName = 'Orders'; @@ -51,5 +54,11 @@ class Order extends HiveObject { @HiveField(8) String walletId; + @HiveField(9) + int providerRaw; + + BuyProviderDescription get provider => + BuyProviderDescription.deserialize(raw: providerRaw); + String amountFormatted() => formatAmount(amount); } \ No newline at end of file diff --git a/lib/buy/wyre/wyre_buy_provider.dart b/lib/buy/wyre/wyre_buy_provider.dart new file mode 100644 index 000000000..0b94816b2 --- /dev/null +++ b/lib/buy/wyre/wyre_buy_provider.dart @@ -0,0 +1,161 @@ +import 'dart:convert'; +import 'package:cake_wallet/buy/buy_exception.dart'; +import 'package:http/http.dart'; +import 'package:cake_wallet/buy/buy_amount.dart'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/buy_provider_description.dart'; +import 'package:cake_wallet/buy/order.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; +import 'package:cake_wallet/entities/wallet_type.dart'; +import 'package:cake_wallet/exchange/trade_state.dart'; +import 'package:cake_wallet/.secrets.g.dart' as secrets; + +class WyreBuyProvider extends BuyProvider { + WyreBuyProvider({WalletBase wallet, bool isTestEnvironment = false}) + : super(wallet: wallet, isTestEnvironment: isTestEnvironment) { + baseApiUrl = isTestEnvironment + ? _baseTestApiUrl + : _baseProductApiUrl; + trackUrl = isTestEnvironment + ? _trackTestUrl + : _trackProductUrl; + } + + static const _baseTestApiUrl = 'https://api.testwyre.com'; + static const _baseProductApiUrl = 'https://api.sendwyre.com'; + static const _trackTestUrl = 'https://dash.testwyre.com/track/'; + static const _trackProductUrl = 'https://dash.sendwyre.com/track/'; + static const _ordersSuffix = '/v3/orders'; + static const _reserveSuffix = '/reserve'; + static const _quoteSuffix = '/quote/partner'; + static const _timeStampSuffix = '?timestamp='; + static const _transferSuffix = '/v2/transfer/'; + static const _trackSuffix = '/track'; + static const _secretKey = secrets.wyreSecretKey; + static const _accountId = secrets.wyreAccountId; + + @override + String get title => 'Wyre'; + + @override + BuyProviderDescription get description => BuyProviderDescription.wyre; + + String baseApiUrl; + String trackUrl; + + @override + Future requestUrl(String amount, String sourceCurrency) async { + final timestamp = DateTime.now().millisecondsSinceEpoch.toString(); + final url = baseApiUrl + _ordersSuffix + _reserveSuffix + + _timeStampSuffix + timestamp; + final body = { + 'amount': amount, + 'sourceCurrency': sourceCurrency, + 'destCurrency': walletTypeToCryptoCurrency(walletType).title, + 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, + 'referrerAccountId': _accountId, + 'lockFields': ['amount', 'sourceCurrency', 'destCurrency', 'dest'] + }; + + final response = await post(url, + headers: { + 'Authorization': 'Bearer $_secretKey', + 'Content-Type': 'application/json', + 'cache-control': 'no-cache' + }, + body: json.encode(body)); + + if (response.statusCode != 200) { + throw BuyException( + description: description, + text: 'Url $url is not found!'); + } + + final responseJSON = json.decode(response.body) as Map; + final urlFromResponse = responseJSON['url'] as String; + return urlFromResponse; + } + + @override + Future calculateAmount(String amount, String sourceCurrency) async { + final quoteUrl = baseApiUrl + _ordersSuffix + _quoteSuffix; + final body = { + 'amount': amount, + 'sourceCurrency': sourceCurrency, + 'destCurrency': walletTypeToCryptoCurrency(walletType).title, + 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, + 'accountId': _accountId, + 'country': 'US' //FIXME + }; + + final response = await post(quoteUrl, + headers: { + 'Authorization': 'Bearer $_secretKey', + 'Content-Type': 'application/json', + 'cache-control': 'no-cache' + }, + body: json.encode(body)); + + if (response.statusCode != 200) { + throw BuyException( + description: description, + text: 'Quote is not found!'); + } + + final responseJSON = json.decode(response.body) as Map; + final sourceAmount = responseJSON['sourceAmount'] as double; + final destAmount = responseJSON['destAmount'] as double; + + return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount); + } + + @override + Future findOrderById(String id) async { + final orderUrl = baseApiUrl + _ordersSuffix + '/$id'; + final orderResponse = await get(orderUrl); + + if (orderResponse.statusCode != 200) { + throw BuyException( + description: description, + text: 'Order $id is not found!'); + } + + final orderResponseJSON = + json.decode(orderResponse.body) as Map; + final transferId = orderResponseJSON['transferId'] as String; + final from = orderResponseJSON['sourceCurrency'] as String; + final to = orderResponseJSON['destCurrency'] as String; + final status = orderResponseJSON['status'] as String; + final state = TradeState.deserialize(raw: status.toLowerCase()); + final createdAtRaw = orderResponseJSON['createdAt'] as int; + final createdAt = + DateTime.fromMillisecondsSinceEpoch(createdAtRaw).toLocal(); + + final transferUrl = + baseApiUrl + _transferSuffix + transferId + _trackSuffix; + final transferResponse = await get(transferUrl); + + if (transferResponse.statusCode != 200) { + throw BuyException( + description: description, + text: 'Transfer $transferId is not found!'); + } + + final transferResponseJSON = + json.decode(transferResponse.body) as Map; + final amount = transferResponseJSON['destAmount'] as double; + + return Order( + id: id, + provider: description, + transferId: transferId, + from: from, + to: to, + state: state, + createdAt: createdAt, + amount: amount.toString(), + receiveAddress: walletAddress, + walletId: walletId + ); + } +} \ No newline at end of file diff --git a/lib/di.dart b/lib/di.dart index 66ac22231..8663b31de 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -4,7 +4,7 @@ import 'package:cake_wallet/core/wallet_service.dart'; import 'package:cake_wallet/entities/biometric_auth.dart'; import 'package:cake_wallet/entities/contact_record.dart'; import 'package:cake_wallet/entities/load_current_wallet.dart'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/entities/transaction_info.dart'; import 'package:cake_wallet/entities/wyre_service.dart'; @@ -15,7 +15,7 @@ import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/reactions/on_authentication_state_change.dart'; import 'package:cake_wallet/src/screens/backup/backup_page.dart'; import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart'; - +import 'package:cake_wallet/src/screens/buy/pre_order_page.dart'; import 'package:cake_wallet/src/screens/contact/contact_list_page.dart'; import 'package:cake_wallet/src/screens/contact/contact_page.dart'; import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart'; @@ -61,6 +61,8 @@ import 'package:cake_wallet/src/screens/subaddress/address_edit_or_create_page.d import 'package:cake_wallet/src/screens/wallet_list/wallet_list_page.dart'; import 'package:cake_wallet/store/wallet_list_store.dart'; import 'package:cake_wallet/view_model/backup_view_model.dart'; +import 'package:cake_wallet/view_model/buy/buy_amount_view_model.dart'; +import 'package:cake_wallet/view_model/buy/buy_view_model.dart'; import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart'; import 'package:cake_wallet/view_model/contact_list/contact_view_model.dart'; import 'package:cake_wallet/view_model/edit_backup_password_view_model.dart'; @@ -546,6 +548,19 @@ Future setup( WyrePage(getIt.get(), ordersStore: getIt.get(), url: url)); + getIt.registerFactory(() => BuyAmountViewModel()); + + getIt.registerFactory(() { + final wallet = getIt.get().wallet; + + return BuyViewModel(ordersSource, getIt.get(), + getIt.get(), wallet: wallet); + }); + + getIt.registerFactory(() { + return PreOrderPage(buyViewModel: getIt.get()); + }); + getIt.registerFactoryParam( (order, _) => OrderDetailsViewModel( wyreViewModel: getIt.get(), diff --git a/lib/entities/wyre_service.dart b/lib/entities/wyre_service.dart index b83bfce68..f45f33d44 100644 --- a/lib/entities/wyre_service.dart +++ b/lib/entities/wyre_service.dart @@ -5,7 +5,7 @@ import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; class WyreService { @@ -26,6 +26,7 @@ class WyreService { static const _trackProductUrl = 'https://dash.sendwyre.com/track/'; static const _ordersSuffix = '/v3/orders'; static const _reserveSuffix = '/reserve'; + static const _quoteSuffix = '/quote/partner'; static const _timeStampSuffix = '?timestamp='; static const _transferSuffix = '/v2/transfer/'; static const _trackSuffix = '/track'; @@ -47,10 +48,12 @@ class WyreService { final secretKey = secrets.wyreSecretKey; final accountId = secrets.wyreAccountId; final body = { + 'amount': '1', + 'sourceCurrency': 'USD', 'destCurrency': walletTypeToCryptoCurrency(walletType).title, 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, 'referrerAccountId': accountId, - 'lockFields': ['destCurrency', 'dest'] + 'lockFields': ['amount', 'sourceCurrency', 'destCurrency', 'dest'] }; final response = await post(url, @@ -113,4 +116,36 @@ class WyreService { walletId: walletId ); } + + Future getAmount() async { + final quoteUrl = baseApiUrl + _ordersSuffix + _quoteSuffix; + + final secretKey = secrets.wyreSecretKey; + final accountId = secrets.wyreAccountId; + final body = { + 'amount': '1', + 'sourceCurrency': 'USD', + 'destCurrency': walletTypeToCryptoCurrency(walletType).title, + 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, + 'accountId': accountId, + 'country': 'US' + }; + + final response = await post(quoteUrl, + headers: { + 'Authorization': 'Bearer $secretKey', + 'Content-Type': 'application/json', + 'cache-control': 'no-cache' + }, + body: json.encode(body)); + + if (response.statusCode != 200) { + throw WyreException('Quote is not found! '); + } + + final responseJSON = json.decode(response.body) as Map; + final amount = responseJSON['destAmount'] as double; + + return amount; + } } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 48b54c416..80b48f50b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ import 'package:cake_wallet/entities/language_service.dart'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; diff --git a/lib/palette.dart b/lib/palette.dart index 336f7b7f9..a26a27163 100644 --- a/lib/palette.dart +++ b/lib/palette.dart @@ -23,6 +23,7 @@ class Palette { static const Color persianRed = Color.fromRGBO(206, 55, 55, 1.0); static const Color blueCraiola = Color.fromRGBO(69, 110, 255, 1.0); static const Color blueGreyCraiola = Color.fromRGBO(106, 177, 207, 1.0); + static const Color greyBlueCraiola = Color.fromRGBO(116, 139, 219, 1.0); static const Color darkBlueCraiola = Color.fromRGBO(53, 86, 136, 1.0); static const Color pinkFlamingo = Color.fromRGBO(240, 60, 243, 1.0); static const Color redHat = Color.fromRGBO(209, 68, 37, 1.0); diff --git a/lib/router.dart b/lib/router.dart index 0474758e3..f8a3d454e 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -1,8 +1,9 @@ import 'package:cake_wallet/entities/contact_record.dart'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/src/screens/backup/backup_page.dart'; import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart'; +import 'package:cake_wallet/src/screens/buy/pre_order_page.dart'; import 'package:cake_wallet/src/screens/order_details/order_details_page.dart'; import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart'; import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart'; @@ -297,6 +298,11 @@ Route createRoute(RouteSettings settings) { builder: (_) => getIt.get(param1: settings.arguments as Order)); + case Routes.preOrder: + return MaterialPageRoute( + builder: (_) => + getIt.get()); + case Routes.wyre: return MaterialPageRoute( builder: (_) => diff --git a/lib/routes.dart b/lib/routes.dart index 2bf8ee7b7..88b9b8440 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -54,4 +54,5 @@ class Routes { static const support = '/support'; static const orderDetails = '/order_details'; static const wyre = '/wyre'; + static const preOrder = '/pre_order'; } \ No newline at end of file diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart new file mode 100644 index 000000000..e42b64790 --- /dev/null +++ b/lib/src/screens/buy/pre_order_page.dart @@ -0,0 +1,210 @@ +import 'dart:ui'; +import 'package:cake_wallet/buy/buy_amount.dart'; +import 'package:cake_wallet/src/screens/buy/widgets/buy_list_item.dart'; +import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; +import 'package:cake_wallet/view_model/buy/buy_view_model.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:keyboard_actions/keyboard_actions.dart'; +import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/base_page.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/generated/i18n.dart'; +import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; + +class PreOrderPage extends BasePage { + PreOrderPage({@required this.buyViewModel}) + : _amountFocus = FocusNode(), + _amountController = TextEditingController() { + + _amountController.addListener(() { + final amount = _amountController.text; + + if (amount != buyViewModel.buyAmountViewModel.amount) { + buyViewModel.buyAmountViewModel.amount = amount; + } + + if (buyViewModel.buyAmountViewModel.doubleAmount == 0.0) { + buyViewModel.selectedProvider = null; + } + }); + } + + final BuyViewModel buyViewModel; + final FocusNode _amountFocus; + final TextEditingController _amountController; + + @override + String get title => 'Buy Bitcoin'; + + @override + Color get titleColor => Colors.white; + + @override + bool get resizeToAvoidBottomInset => false; + + @override + bool get extendBodyBehindAppBar => true; + + @override + AppBarStyle get appBarStyle => AppBarStyle.transparent; + + @override + Widget body(BuildContext context) { + return KeyboardActions( + config: KeyboardActionsConfig( + keyboardActionsPlatform: KeyboardActionsPlatform.IOS, + keyboardBarColor: Theme.of(context).accentTextTheme.body2 + .backgroundColor, + nextFocus: false, + actions: [ + KeyboardActionsItem( + focusNode: _amountFocus, + toolbarButtons: [(_) => KeyboardDoneButton()], + ), + ]), + child: Container( + height: 0, + color: Theme.of(context).backgroundColor, + child: ScrollableWithBottomSection( + contentPadding: EdgeInsets.only(bottom: 24), + content: Column( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), + bottomRight: Radius.circular(24)), + gradient: LinearGradient(colors: [ + Theme.of(context).primaryTextTheme.subhead.color, + Theme.of(context) + .primaryTextTheme + .subhead + .decorationColor, + ], begin: Alignment.topLeft, end: Alignment.bottomRight), + ), + child: Padding( + padding: EdgeInsets.fromLTRB(100, 100, 100, 65), + child: BaseTextFormField( + focusNode: _amountFocus, + controller: _amountController, + keyboardType: + TextInputType.numberWithOptions( + signed: false, decimal: true), + inputFormatters: [ + FilteringTextInputFormatter + .allow(RegExp('^([0-9]+([.\,][0-9]{0,2})?|[.\,][0-9]{1,2})\$')) + ], + prefixIcon: Padding( + padding: EdgeInsets.only(top: 2), + child: + Text(buyViewModel.fiatCurrency.title + ': ', + style: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w600, + color: Colors.white, + )), + ), + hintText: '0.00', + borderColor: Theme.of(context) + .primaryTextTheme + .headline + .color, + textStyle: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w500, + color: Colors.white), + placeholderTextStyle: TextStyle( + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor, + fontWeight: FontWeight.w500, + fontSize: 36), + ) + ) + ), + Padding( + padding: EdgeInsets.only(top: 38, bottom: 18), + child: Text( + 'Buy with:', + textAlign: TextAlign.center, + style: TextStyle( + color: Theme.of(context).primaryTextTheme.title.color, + fontSize: 18, + fontWeight: FontWeight.w500 + ), + ) + ), + ...buyViewModel.items.map( + (item) => Observer(builder: (_) => FutureBuilder( + future: item.buyAmount, + builder: (context, AsyncSnapshot snapshot) { + double sourceAmount; + double destAmount; + + if (snapshot.hasData) { + sourceAmount = snapshot.data.sourceAmount; + destAmount = snapshot.data.destAmount; + } else { + sourceAmount = 0.0; + destAmount = 0.0; + } + + return Padding( + padding: + EdgeInsets.only(left: 15, top: 20, right: 15), + child: Observer(builder: (_) => BuyListItem( + selectedProvider: buyViewModel.selectedProvider, + provider: item.provider, + sourceAmount: sourceAmount, + sourceCurrency: buyViewModel.fiatCurrency, + destAmount: destAmount, + destCurrency: buyViewModel.cryptoCurrency, + onTap: + buyViewModel.buyAmountViewModel + .doubleAmount == 0.0 ? null : () { + buyViewModel.selectedProvider = item.provider; + sourceAmount > 0 + ? buyViewModel.isDisabled = false + : buyViewModel.isDisabled = true; + } + )) + ); + } + ),) + ) + ], + ), + bottomSectionPadding: + EdgeInsets.only(left: 24, right: 24, bottom: 24), + bottomSection: Observer(builder: (_) { + return LoadingPrimaryButton( + onPressed: buyViewModel.isRunning + ? null + : () { + buyViewModel.isRunning = true; + + // FIXME: Start WebView + + buyViewModel.isRunning = false; + }, + text: buyViewModel.selectedProvider == null + ? 'Buy' + : 'Buy with ${buyViewModel.selectedProvider + .description.title}', + color: Theme.of(context).accentTextTheme.body2.color, + textColor: Colors.white, + isLoading: buyViewModel.isRunning, + isDisabled: (buyViewModel.selectedProvider == null) || + buyViewModel.isDisabled + ); + }) + ) + ) + ); + } +} \ No newline at end of file diff --git a/lib/src/screens/buy/widgets/buy_list_item.dart b/lib/src/screens/buy/widgets/buy_list_item.dart new file mode 100644 index 000000000..fe198a350 --- /dev/null +++ b/lib/src/screens/buy/widgets/buy_list_item.dart @@ -0,0 +1,131 @@ +import 'package:cake_wallet/buy/buy_provider_description.dart'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/entities/crypto_currency.dart'; +import 'package:cake_wallet/entities/fiat_currency.dart'; +import 'package:cake_wallet/palette.dart'; +import 'package:flutter/material.dart'; + +class BuyListItem extends StatelessWidget { + BuyListItem({ + @required this.selectedProvider, + @required this.provider, + @required this.sourceAmount, + @required this.sourceCurrency, + @required this.destAmount, + @required this.destCurrency, + @required this.onTap + }); + + final _wyreIcon = + Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); + final _mooonPayIcon = + Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); + + final BuyProvider selectedProvider; + final BuyProvider provider; + final double sourceAmount; + final FiatCurrency sourceCurrency; + final double destAmount; + final CryptoCurrency destCurrency; + final void Function() onTap; + + @override + Widget build(BuildContext context) { + final providerIcon = _getProviderIcon(provider.description); + + final backgroundColor = selectedProvider != null + ? selectedProvider.description == provider.description + ? Palette.greyBlueCraiola + : Palette.shadowWhite + : Palette.shadowWhite; + + final primaryTextColor = selectedProvider != null + ? selectedProvider.description == provider.description + ? Colors.white + : Palette.darkGray + : Palette.darkGray; + + final secondaryTextColor = selectedProvider != null + ? selectedProvider.description == provider.description + ? Colors.white + : Palette.darkBlueCraiola + : Palette.darkBlueCraiola; + + return GestureDetector( + onTap: () => onTap?.call(), + child: Container( + height: 102, + padding: EdgeInsets.only( + left: 20, + right: 20 + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(25)), + color: backgroundColor + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (providerIcon != null) Padding( + padding: EdgeInsets.only(right: 10), + child: providerIcon + ), + Text( + provider.description.title, + style: TextStyle( + color: primaryTextColor, + fontSize: 24, + fontWeight: FontWeight.w500 + ), + ) + ], + ), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + '${destAmount?.toString()} ${destCurrency.title}', + style: TextStyle( + color: secondaryTextColor, + fontSize: 18, + fontWeight: FontWeight.w500 + ), + ), + Padding( + padding: EdgeInsets.only(top: 5), + child: Text( + '${sourceAmount?.toString()} ${sourceCurrency.title}', + style: TextStyle( + color: primaryTextColor, + fontSize: 18, + fontWeight: FontWeight.w500 + ), + ), + ) + ], + ) + ], + ), + ) + ); + } + + Image _getProviderIcon(BuyProviderDescription providerDescription) { + switch (providerDescription) { + case BuyProviderDescription.wyre: + return _wyreIcon; + case BuyProviderDescription.moonPay: + //return _mooonPayIcon; + return null; + default: + return null; + } + } +} \ No newline at end of file diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 172483ed0..9ea094dda 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -125,39 +125,13 @@ class DashboardPage extends BasePage { image: exchangeImage, title: S.of(context).exchange, route: Routes.exchange), - if (walletViewModel.type == WalletType.bitcoin) Observer( - builder: (_) => Stack( - clipBehavior: Clip.none, - alignment: Alignment.topCenter, - children: [ - if (walletViewModel.isRunningWebView) Positioned( - top: -5, - child: SpinKitRing( - color: Theme.of(context).buttonColor, - lineWidth: 3, - size: 70.0, - ), - ), - ActionButton( - image: buyImage, - title: S.of(context).buy, - onClick: walletViewModel.isRunningWebView - ? null - : () async { - try { - walletViewModel.isRunningWebView = true; - final url = - await walletViewModel.wyreViewModel.wyreUrl; - await Navigator.of(context) - .pushNamed(Routes.wyre, arguments: url); - walletViewModel.isRunningWebView = false; - } catch(e) { - print(e.toString()); - walletViewModel.isRunningWebView = false; - } - }) - ], - )), + if (walletViewModel.type == WalletType.bitcoin) ActionButton( + image: buyImage, + title: S.of(context).buy, + onClick: () { + Navigator.of(context).pushNamed(Routes.preOrder); + }, + ), ], )), ) diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 9fae0ec23..eb4153676 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -67,7 +67,7 @@ class SendPage extends BasePage { Color get titleColor => Colors.white; @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override bool get extendBodyBehindAppBar => true; diff --git a/lib/store/dashboard/orders_store.dart b/lib/store/dashboard/orders_store.dart index 01c2b13a9..d3fc94bda 100644 --- a/lib/store/dashboard/orders_store.dart +++ b/lib/store/dashboard/orders_store.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/view_model/dashboard/order_list_item.dart'; import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; diff --git a/lib/view_model/buy/buy_amount_view_model.dart b/lib/view_model/buy/buy_amount_view_model.dart new file mode 100644 index 000000000..e027166f9 --- /dev/null +++ b/lib/view_model/buy/buy_amount_view_model.dart @@ -0,0 +1,28 @@ +import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/entities/fiat_currency.dart'; + +part 'buy_amount_view_model.g.dart'; + +class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel; + +abstract class BuyAmountViewModelBase with Store { + BuyAmountViewModelBase() : amount = ''; + + @observable + String amount; + + FiatCurrency get fiatCurrency => FiatCurrency.usd; + + @computed + double get doubleAmount { + double _amount; + + try { + _amount = double.parse(amount.replaceAll(',', '.')) ?? 0.0; + } catch (e) { + _amount = 0.0; + } + + return _amount; + } +} \ No newline at end of file diff --git a/lib/view_model/buy/buy_item.dart b/lib/view_model/buy/buy_item.dart new file mode 100644 index 000000000..8d97597c4 --- /dev/null +++ b/lib/view_model/buy/buy_item.dart @@ -0,0 +1,29 @@ +import 'package:cake_wallet/buy/buy_amount.dart'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/entities/fiat_currency.dart'; +import 'package:cake_wallet/view_model/buy/buy_amount_view_model.dart'; + +class BuyItem { + BuyItem({this.provider, this.buyAmountViewModel}); + + final BuyProvider provider; + final BuyAmountViewModel buyAmountViewModel; + + double get amount => buyAmountViewModel.doubleAmount; + + FiatCurrency get fiatCurrency => buyAmountViewModel.fiatCurrency; + + Future get buyAmount async { + BuyAmount _buyAmount; + + try { + _buyAmount = await provider + .calculateAmount(amount?.toString(), fiatCurrency.title); + } catch (e) { + _buyAmount = BuyAmount(sourceAmount: 0.0, destAmount: 0.0); + print(e.toString()); + } + + return _buyAmount; + } +} \ No newline at end of file diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart new file mode 100644 index 000000000..6b24cadfa --- /dev/null +++ b/lib/view_model/buy/buy_view_model.dart @@ -0,0 +1,81 @@ +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; +import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart'; +import 'package:cake_wallet/entities/crypto_currency.dart'; +import 'package:cake_wallet/entities/fiat_currency.dart'; +import 'package:cake_wallet/entities/wallet_type.dart'; +import 'package:cake_wallet/view_model/buy/buy_item.dart'; +import 'package:flutter/foundation.dart'; +import 'package:hive/hive.dart'; +import 'package:cake_wallet/buy/order.dart'; +import 'package:cake_wallet/store/dashboard/orders_store.dart'; +import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; +import 'buy_amount_view_model.dart'; + +part 'buy_view_model.g.dart'; + +class BuyViewModel = BuyViewModelBase with _$BuyViewModel; + +abstract class BuyViewModelBase with Store { + BuyViewModelBase(this.ordersSource, this.ordersStore, this.buyAmountViewModel, + {@required this.wallet}) { + providerList = [ + WyreBuyProvider(wallet: wallet), + MoonPayBuyProvider(wallet: wallet) + ]; + items = providerList.map((provider) => + BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel)) + .toList(); + isRunning = false; + isDisabled = true; + } + + final Box ordersSource; + final OrdersStore ordersStore; + final BuyAmountViewModel buyAmountViewModel; + final WalletBase wallet; + + @observable + List providerList; + + @observable + BuyProvider selectedProvider; + + @observable + List items; + + @observable + bool isRunning; + + @observable + bool isDisabled; + + WalletType get type => wallet.type; + + double get doubleAmount => buyAmountViewModel.doubleAmount; + + FiatCurrency get fiatCurrency => buyAmountViewModel.fiatCurrency; + + CryptoCurrency get cryptoCurrency => walletTypeToCryptoCurrency(type); + + Future createOrder() async { + try { + final url = await selectedProvider + ?.requestUrl(doubleAmount?.toString(), fiatCurrency.title); + // FIXME: Start WebView + } catch (e) { + print(e.toString()); + } + } + + Future saveOrder(String orderId) async { + try { + final order = await selectedProvider?.findOrderById(orderId); + await ordersSource.add(order); + ordersStore.setOrder(order); + } catch (e) { + print(e.toString()); + } + } +} \ No newline at end of file diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 66fc53269..d471c866a 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; import 'package:cake_wallet/entities/balance.dart'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/transaction_history.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/monero/account.dart'; @@ -95,8 +95,6 @@ abstract class DashboardViewModelBase with Store { ] }; - isRunningWebView = false; - name = appStore.wallet?.name; wallet ??= appStore.wallet; type = wallet.type; @@ -162,9 +160,6 @@ abstract class DashboardViewModelBase with Store { @observable String subname; - @observable - bool isRunningWebView; - @computed String get address => wallet.address; diff --git a/lib/view_model/dashboard/order_list_item.dart b/lib/view_model/dashboard/order_list_item.dart index 7eeff4bd1..e4bb2cbd1 100644 --- a/lib/view_model/dashboard/order_list_item.dart +++ b/lib/view_model/dashboard/order_list_item.dart @@ -1,4 +1,4 @@ -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart'; diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 44367a19d..275247670 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; import 'package:cake_wallet/view_model/wyre_view_model.dart'; import 'package:mobx/mobx.dart'; diff --git a/lib/view_model/wyre_view_model.dart b/lib/view_model/wyre_view_model.dart index 8624cd0e6..2d5ab3315 100644 --- a/lib/view_model/wyre_view_model.dart +++ b/lib/view_model/wyre_view_model.dart @@ -1,7 +1,7 @@ import 'package:cake_wallet/entities/wyre_service.dart'; import 'package:flutter/foundation.dart'; import 'package:hive/hive.dart'; -import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/store/dashboard/orders_store.dart'; import 'package:mobx/mobx.dart'; From 19ffffa6ccd9462cc2722b841a8c236971801448 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 13 Apr 2021 21:40:44 +0300 Subject: [PATCH 02/42] CAKE-306 | applied buy_webview_page.dart to the app; fixed order_details_view_model.dart and order_row.dart; applied localization to the pre_order_page.dart; deleted unused files --- lib/buy/buy_provider.dart | 1 + lib/buy/get_buy_provider_icon.dart | 23 +++ lib/buy/moonpay/moonpay_buy_provider.dart | 5 + lib/buy/wyre/wyre_buy_provider.dart | 9 +- lib/di.dart | 35 ++-- lib/entities/wyre_exception.dart | 8 - lib/entities/wyre_service.dart | 151 ------------------ lib/router.dart | 6 +- lib/routes.dart | 2 +- lib/src/screens/buy/buy_webview_page.dart | 108 +++++++++++++ lib/src/screens/buy/pre_order_page.dart | 32 ++-- .../screens/buy/widgets/buy_list_item.dart | 21 +-- .../screens/dashboard/widgets/order_row.dart | 10 +- .../dashboard/widgets/transactions_page.dart | 1 + lib/src/screens/wyre/wyre_page.dart | 97 ----------- lib/view_model/buy/buy_view_model.dart | 14 +- .../dashboard/dashboard_view_model.dart | 6 +- lib/view_model/order_details_view_model.dart | 85 ++++++---- lib/view_model/wyre_view_model.dart | 34 ---- res/values/strings_de.arb | 5 +- res/values/strings_en.arb | 5 +- res/values/strings_es.arb | 5 +- res/values/strings_hi.arb | 5 +- res/values/strings_ja.arb | 5 +- res/values/strings_ko.arb | 5 +- res/values/strings_nl.arb | 5 +- res/values/strings_pl.arb | 5 +- res/values/strings_pt.arb | 5 +- res/values/strings_ru.arb | 5 +- res/values/strings_uk.arb | 5 +- res/values/strings_zh.arb | 5 +- 31 files changed, 310 insertions(+), 398 deletions(-) create mode 100644 lib/buy/get_buy_provider_icon.dart delete mode 100644 lib/entities/wyre_exception.dart delete mode 100644 lib/entities/wyre_service.dart create mode 100644 lib/src/screens/buy/buy_webview_page.dart delete mode 100644 lib/src/screens/wyre/wyre_page.dart delete mode 100644 lib/view_model/wyre_view_model.dart diff --git a/lib/buy/buy_provider.dart b/lib/buy/buy_provider.dart index 78ad54451..b908d7bc5 100644 --- a/lib/buy/buy_provider.dart +++ b/lib/buy/buy_provider.dart @@ -12,6 +12,7 @@ abstract class BuyProvider { String get title; BuyProviderDescription get description; + String get trackUrl; WalletType get walletType => wallet.type; String get walletAddress => wallet.address; diff --git a/lib/buy/get_buy_provider_icon.dart b/lib/buy/get_buy_provider_icon.dart new file mode 100644 index 000000000..d58fe19d4 --- /dev/null +++ b/lib/buy/get_buy_provider_icon.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:cake_wallet/buy/buy_provider_description.dart'; + +Image getBuyProviderIcon(BuyProviderDescription providerDescription) { + final _wyreIcon = + Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); + final _moonPayIcon = + Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); + + if (providerDescription != null) { + switch (providerDescription) { + case BuyProviderDescription.wyre: + return _wyreIcon; + case BuyProviderDescription.moonPay: + //return _moonPayIcon; + return null; + default: + return null; + } + } else { + return null; + } +} \ No newline at end of file diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index 972b2d2a4..2fde667e4 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -34,6 +34,11 @@ class MoonPayBuyProvider extends BuyProvider { String get currencyCode => walletTypeToCryptoCurrency(walletType).title.toLowerCase(); + @override + String get trackUrl => isTestEnvironment + ? '' + : ''; // FIXME + String baseApiUrl; @override diff --git a/lib/buy/wyre/wyre_buy_provider.dart b/lib/buy/wyre/wyre_buy_provider.dart index 0b94816b2..3a09be0f6 100644 --- a/lib/buy/wyre/wyre_buy_provider.dart +++ b/lib/buy/wyre/wyre_buy_provider.dart @@ -16,9 +16,6 @@ class WyreBuyProvider extends BuyProvider { baseApiUrl = isTestEnvironment ? _baseTestApiUrl : _baseProductApiUrl; - trackUrl = isTestEnvironment - ? _trackTestUrl - : _trackProductUrl; } static const _baseTestApiUrl = 'https://api.testwyre.com'; @@ -40,8 +37,12 @@ class WyreBuyProvider extends BuyProvider { @override BuyProviderDescription get description => BuyProviderDescription.wyre; + @override + String get trackUrl => isTestEnvironment + ? _trackTestUrl + : _trackProductUrl; + String baseApiUrl; - String trackUrl; @override Future requestUrl(String amount, String sourceCurrency) async { diff --git a/lib/di.dart b/lib/di.dart index 8663b31de..0b107fde4 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -7,7 +7,6 @@ import 'package:cake_wallet/entities/load_current_wallet.dart'; import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/entities/transaction_info.dart'; -import 'package:cake_wallet/entities/wyre_service.dart'; import 'package:cake_wallet/monero/monero_wallet_service.dart'; import 'package:cake_wallet/entities/contact.dart'; import 'package:cake_wallet/entities/node.dart'; @@ -15,6 +14,7 @@ import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/reactions/on_authentication_state_change.dart'; import 'package:cake_wallet/src/screens/backup/backup_page.dart'; import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart'; +import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart'; import 'package:cake_wallet/src/screens/buy/pre_order_page.dart'; import 'package:cake_wallet/src/screens/contact/contact_list_page.dart'; import 'package:cake_wallet/src/screens/contact/contact_page.dart'; @@ -42,7 +42,6 @@ import 'package:cake_wallet/src/screens/transaction_details/transaction_details_ import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart'; import 'package:cake_wallet/src/screens/exchange/exchange_page.dart'; import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart'; -import 'package:cake_wallet/src/screens/wyre/wyre_page.dart'; import 'package:cake_wallet/store/dashboard/orders_store.dart'; import 'package:cake_wallet/store/node_list_store.dart'; import 'package:cake_wallet/store/secret_store.dart'; @@ -91,7 +90,6 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart'; import 'package:cake_wallet/view_model/wallet_restore_view_model.dart'; import 'package:cake_wallet/view_model/wallet_seed_view_model.dart'; import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart'; -import 'package:cake_wallet/view_model/wyre_view_model.dart'; import 'package:flutter/widgets.dart'; import 'package:get_it/get_it.dart'; import 'package:hive/hive.dart'; @@ -241,8 +239,7 @@ Future setup( transactionFilterStore: getIt.get(), settingsStore: settingsStore, ordersSource: _ordersSource, - ordersStore: getIt.get(), - wyreViewModel: getIt.get())); + ordersStore: getIt.get())); getIt.registerFactory(() => AuthService( secureStorage: getIt.get(), @@ -534,20 +531,6 @@ Future setup( getIt.registerFactoryParam((Trade trade, _) => TradeDetailsPage(getIt.get(param1: trade))); - getIt.registerFactory(() { - final wallet = getIt.get().wallet; - return WyreService(wallet: wallet); - }); - - getIt.registerFactory(() { - return WyreViewModel(ordersSource, getIt.get(), - wyreService: getIt.get()); - }); - - getIt.registerFactoryParam((String url, _) => - WyrePage(getIt.get(), - ordersStore: getIt.get(), url: url)); - getIt.registerFactory(() => BuyAmountViewModel()); getIt.registerFactory(() { @@ -561,10 +544,18 @@ Future setup( return PreOrderPage(buyViewModel: getIt.get()); }); + getIt.registerFactoryParam((String url, _) => + BuyWebViewPage(getIt.get(), + ordersStore: getIt.get(), url: url)); + getIt.registerFactoryParam( - (order, _) => OrderDetailsViewModel( - wyreViewModel: getIt.get(), - orderForDetails: order)); + (order, _) { + final wallet = getIt.get().wallet; + + return OrderDetailsViewModel( + wallet: wallet, + orderForDetails: order); + }); getIt.registerFactoryParam((Order order, _) => OrderDetailsPage(getIt.get(param1: order))); diff --git a/lib/entities/wyre_exception.dart b/lib/entities/wyre_exception.dart deleted file mode 100644 index 85d9f5b60..000000000 --- a/lib/entities/wyre_exception.dart +++ /dev/null @@ -1,8 +0,0 @@ -class WyreException implements Exception { - WyreException(this.description); - - String description; - - @override - String toString() => description; -} \ No newline at end of file diff --git a/lib/entities/wyre_service.dart b/lib/entities/wyre_service.dart deleted file mode 100644 index f45f33d44..000000000 --- a/lib/entities/wyre_service.dart +++ /dev/null @@ -1,151 +0,0 @@ -import 'dart:convert'; -import 'package:cake_wallet/core/wallet_base.dart'; -import 'package:cake_wallet/entities/wyre_exception.dart'; -import 'package:cake_wallet/exchange/trade_state.dart'; -import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; -import 'package:cake_wallet/.secrets.g.dart' as secrets; -import 'package:cake_wallet/buy/order.dart'; -import 'package:cake_wallet/entities/wallet_type.dart'; - -class WyreService { - WyreService({ - @required this.wallet, - this.isTestEnvironment = false}) { - baseApiUrl = isTestEnvironment - ? _baseTestApiUrl - : _baseProductApiUrl; - trackUrl = isTestEnvironment - ? _trackTestUrl - : _trackProductUrl; - } - - static const _baseTestApiUrl = 'https://api.testwyre.com'; - static const _baseProductApiUrl = 'https://api.sendwyre.com'; - static const _trackTestUrl = 'https://dash.testwyre.com/track/'; - static const _trackProductUrl = 'https://dash.sendwyre.com/track/'; - static const _ordersSuffix = '/v3/orders'; - static const _reserveSuffix = '/reserve'; - static const _quoteSuffix = '/quote/partner'; - static const _timeStampSuffix = '?timestamp='; - static const _transferSuffix = '/v2/transfer/'; - static const _trackSuffix = '/track'; - - final bool isTestEnvironment; - final WalletBase wallet; - - WalletType get walletType => wallet.type; - String get walletAddress => wallet.address; - String get walletId => wallet.id; - - String baseApiUrl; - String trackUrl; - - Future getWyreUrl() async { - final timestamp = DateTime.now().millisecondsSinceEpoch.toString(); - final url = baseApiUrl + _ordersSuffix + _reserveSuffix + - _timeStampSuffix + timestamp; - final secretKey = secrets.wyreSecretKey; - final accountId = secrets.wyreAccountId; - final body = { - 'amount': '1', - 'sourceCurrency': 'USD', - 'destCurrency': walletTypeToCryptoCurrency(walletType).title, - 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, - 'referrerAccountId': accountId, - 'lockFields': ['amount', 'sourceCurrency', 'destCurrency', 'dest'] - }; - - final response = await post(url, - headers: { - 'Authorization': 'Bearer $secretKey', - 'Content-Type': 'application/json', - 'cache-control': 'no-cache' - }, - body: json.encode(body)); - - if (response.statusCode != 200) { - throw WyreException('Url $url is not found!'); - } - - final responseJSON = json.decode(response.body) as Map; - final urlFromResponse = responseJSON['url'] as String; - return urlFromResponse; - } - - Future findOrderById(String id) async { - final orderUrl = baseApiUrl + _ordersSuffix + '/$id'; - final orderResponse = await get(orderUrl); - - if (orderResponse.statusCode != 200) { - throw WyreException('Order $id is not found!'); - } - - final orderResponseJSON = - json.decode(orderResponse.body) as Map; - final transferId = orderResponseJSON['transferId'] as String; - final from = orderResponseJSON['sourceCurrency'] as String; - final to = orderResponseJSON['destCurrency'] as String; - final status = orderResponseJSON['status'] as String; - final state = TradeState.deserialize(raw: status.toLowerCase()); - final createdAtRaw = orderResponseJSON['createdAt'] as int; - final createdAt = - DateTime.fromMillisecondsSinceEpoch(createdAtRaw).toLocal(); - - final transferUrl = - baseApiUrl + _transferSuffix + transferId + _trackSuffix; - final transferResponse = await get(transferUrl); - - if (transferResponse.statusCode != 200) { - throw WyreException('Transfer $transferId is not found!'); - } - - final transferResponseJSON = - json.decode(transferResponse.body) as Map; - final amount = transferResponseJSON['destAmount'] as double; - - return Order( - id: id, - transferId: transferId, - from: from, - to: to, - state: state, - createdAt: createdAt, - amount: amount.toString(), - receiveAddress: walletAddress, - walletId: walletId - ); - } - - Future getAmount() async { - final quoteUrl = baseApiUrl + _ordersSuffix + _quoteSuffix; - - final secretKey = secrets.wyreSecretKey; - final accountId = secrets.wyreAccountId; - final body = { - 'amount': '1', - 'sourceCurrency': 'USD', - 'destCurrency': walletTypeToCryptoCurrency(walletType).title, - 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, - 'accountId': accountId, - 'country': 'US' - }; - - final response = await post(quoteUrl, - headers: { - 'Authorization': 'Bearer $secretKey', - 'Content-Type': 'application/json', - 'cache-control': 'no-cache' - }, - body: json.encode(body)); - - if (response.statusCode != 200) { - throw WyreException('Quote is not found! '); - } - - final responseJSON = json.decode(response.body) as Map; - final amount = responseJSON['destAmount'] as double; - - return amount; - } -} \ No newline at end of file diff --git a/lib/router.dart b/lib/router.dart index f8a3d454e..a3421fa69 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/src/screens/backup/backup_page.dart'; import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart'; +import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart'; import 'package:cake_wallet/src/screens/buy/pre_order_page.dart'; import 'package:cake_wallet/src/screens/order_details/order_details_page.dart'; import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart'; @@ -10,7 +11,6 @@ import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart'; import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart'; import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart'; import 'package:cake_wallet/src/screens/support/support_page.dart'; -import 'package:cake_wallet/src/screens/wyre/wyre_page.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart'; import 'package:flutter/cupertino.dart'; @@ -303,10 +303,10 @@ Route createRoute(RouteSettings settings) { builder: (_) => getIt.get()); - case Routes.wyre: + case Routes.buyWebView: return MaterialPageRoute( builder: (_) => - getIt.get(param1: settings.arguments as String)); + getIt.get(param1: settings.arguments as String)); case Routes.restoreWalletFromSeedDetails: final args = settings.arguments as List; diff --git a/lib/routes.dart b/lib/routes.dart index 88b9b8440..6ac75bceb 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -53,6 +53,6 @@ class Routes { static const restoreFromBackup = '/restore_from_backup'; static const support = '/support'; static const orderDetails = '/order_details'; - static const wyre = '/wyre'; static const preOrder = '/pre_order'; + static const buyWebView = '/buy_web_view'; } \ No newline at end of file diff --git a/lib/src/screens/buy/buy_webview_page.dart b/lib/src/screens/buy/buy_webview_page.dart new file mode 100644 index 000000000..91e93f902 --- /dev/null +++ b/lib/src/screens/buy/buy_webview_page.dart @@ -0,0 +1,108 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; +import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart'; +import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/palette.dart'; +import 'package:cake_wallet/src/screens/base_page.dart'; +import 'package:cake_wallet/store/dashboard/orders_store.dart'; +import 'package:cake_wallet/view_model/buy/buy_view_model.dart'; +import 'package:flutter/material.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +class BuyWebViewPage extends BasePage { + BuyWebViewPage(this.buyViewModel, + {@required this.ordersStore, @required this.url}); + + final OrdersStore ordersStore; + final String url; + final BuyViewModel buyViewModel; + + @override + String get title => S.current.buy; + + @override + Color get backgroundDarkColor => Colors.white; + + @override + Color get titleColor => Palette.darkBlueCraiola; + + @override + Widget body(BuildContext context) => + BuyWebViewPageBody(buyViewModel, ordersStore: ordersStore, url: url); +} + +class BuyWebViewPageBody extends StatefulWidget { + BuyWebViewPageBody(this.buyViewModel, {this.ordersStore, this.url}); + + final OrdersStore ordersStore; + final String url; + final BuyViewModel buyViewModel; + + @override + BuyWebViewPageBodyState createState() => BuyWebViewPageBodyState(); +} + +class BuyWebViewPageBodyState extends State { + String orderId; + WebViewController _webViewController; + GlobalKey _webViewkey; + Timer _timer; + bool _isSaving; + BuyProvider _provider; + + @override + void initState() { + super.initState(); + _webViewkey = GlobalKey(); + _isSaving = false; + widget.ordersStore.orderId = ''; + _provider = widget.buyViewModel.selectedProvider; + + if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); + + if (_provider is WyreBuyProvider) { + _timer?.cancel(); + _timer = Timer.periodic(Duration(seconds: 1), (timer) async { + + try { + if (_webViewController == null || _isSaving) { + return; + } + + final url = await _webViewController.currentUrl(); + + if (url.contains('completed')) { + final urlParts = url.split('/'); + orderId = urlParts.last; + widget.ordersStore.orderId = orderId; + + if (orderId.isNotEmpty) { + _isSaving = true; + await widget.buyViewModel.saveOrder(orderId); + timer.cancel(); + } + } + } catch (e) { + _isSaving = false; + print(e); + } + }); + } + + if (_provider is MoonPayBuyProvider) { + // FIXME: fetch orderId + } + } + + @override + Widget build(BuildContext context) { + return WebView( + key: _webViewkey, + initialUrl: widget.url, + javascriptMode: JavascriptMode.unrestricted, + onWebViewCreated: (WebViewController controller) => + setState(() => _webViewController = controller)); + } +} diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index e42b64790..0cf6a1f88 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -14,6 +14,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; +import 'package:mobx/mobx.dart'; class PreOrderPage extends BasePage { PreOrderPage({@required this.buyViewModel}) @@ -31,14 +32,22 @@ class PreOrderPage extends BasePage { buyViewModel.selectedProvider = null; } }); + + reaction((_) => buyViewModel.buyAmountViewModel.amount, (String amount) { + if (_amountController.text != amount) { + _amountController.text = amount; + } + }); } + static const _amountPattern = '^([0-9]+([.\,][0-9]{0,2})?|[.\,][0-9]{1,2})\$'; + final BuyViewModel buyViewModel; final FocusNode _amountFocus; final TextEditingController _amountController; @override - String get title => 'Buy Bitcoin'; + String get title => S.current.buy_bitcoin; @override Color get titleColor => Colors.white; @@ -96,7 +105,7 @@ class PreOrderPage extends BasePage { signed: false, decimal: true), inputFormatters: [ FilteringTextInputFormatter - .allow(RegExp('^([0-9]+([.\,][0-9]{0,2})?|[.\,][0-9]{1,2})\$')) + .allow(RegExp(_amountPattern)) ], prefixIcon: Padding( padding: EdgeInsets.only(top: 2), @@ -130,7 +139,7 @@ class PreOrderPage extends BasePage { Padding( padding: EdgeInsets.only(top: 38, bottom: 18), child: Text( - 'Buy with:', + S.of(context).buy_with + ':', textAlign: TextAlign.center, style: TextStyle( color: Theme.of(context).primaryTextTheme.title.color, @@ -185,16 +194,21 @@ class PreOrderPage extends BasePage { return LoadingPrimaryButton( onPressed: buyViewModel.isRunning ? null - : () { + : () async { buyViewModel.isRunning = true; - - // FIXME: Start WebView - + final url = + await buyViewModel.fetchUrl(); + if (url.isNotEmpty) { + await Navigator.of(context) + .pushNamed(Routes.buyWebView, arguments: url); + buyViewModel.reset(); + } buyViewModel.isRunning = false; }, text: buyViewModel.selectedProvider == null - ? 'Buy' - : 'Buy with ${buyViewModel.selectedProvider + ? S.of(context).buy + : S.of(context).buy_with + + ' ${buyViewModel.selectedProvider .description.title}', color: Theme.of(context).accentTextTheme.body2.color, textColor: Colors.white, diff --git a/lib/src/screens/buy/widgets/buy_list_item.dart b/lib/src/screens/buy/widgets/buy_list_item.dart index fe198a350..8ee3950aa 100644 --- a/lib/src/screens/buy/widgets/buy_list_item.dart +++ b/lib/src/screens/buy/widgets/buy_list_item.dart @@ -1,5 +1,5 @@ -import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/get_buy_provider_icon.dart'; import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/palette.dart'; @@ -16,11 +16,6 @@ class BuyListItem extends StatelessWidget { @required this.onTap }); - final _wyreIcon = - Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); - final _mooonPayIcon = - Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); - final BuyProvider selectedProvider; final BuyProvider provider; final double sourceAmount; @@ -31,7 +26,7 @@ class BuyListItem extends StatelessWidget { @override Widget build(BuildContext context) { - final providerIcon = _getProviderIcon(provider.description); + final providerIcon = getBuyProviderIcon(provider.description); final backgroundColor = selectedProvider != null ? selectedProvider.description == provider.description @@ -116,16 +111,4 @@ class BuyListItem extends StatelessWidget { ) ); } - - Image _getProviderIcon(BuyProviderDescription providerDescription) { - switch (providerDescription) { - case BuyProviderDescription.wyre: - return _wyreIcon; - case BuyProviderDescription.moonPay: - //return _mooonPayIcon; - return null; - default: - return null; - } - } } \ No newline at end of file diff --git a/lib/src/screens/dashboard/widgets/order_row.dart b/lib/src/screens/dashboard/widgets/order_row.dart index cfb2c88eb..49afa7a25 100644 --- a/lib/src/screens/dashboard/widgets/order_row.dart +++ b/lib/src/screens/dashboard/widgets/order_row.dart @@ -1,22 +1,26 @@ +import 'package:cake_wallet/buy/buy_provider_description.dart'; +import 'package:cake_wallet/buy/get_buy_provider_icon.dart'; import 'package:flutter/material.dart'; class OrderRow extends StatelessWidget { OrderRow({ @required this.onTap, + @required this.provider, this.from, this.to, this.createdAtFormattedDate, this.formattedAmount}); final VoidCallback onTap; + final BuyProviderDescription provider; final String from; final String to; final String createdAtFormattedDate; final String formattedAmount; - final wyreImage = - Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); @override Widget build(BuildContext context) { + final providerIcon = getBuyProviderIcon(provider); + return InkWell( onTap: onTap, child: Container( @@ -26,7 +30,7 @@ class OrderRow extends StatelessWidget { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ - wyreImage, + providerIcon ?? Offstage(), SizedBox(width: 12), Expanded( child: Column( diff --git a/lib/src/screens/dashboard/widgets/transactions_page.dart b/lib/src/screens/dashboard/widgets/transactions_page.dart index 482d23a75..942177b40 100644 --- a/lib/src/screens/dashboard/widgets/transactions_page.dart +++ b/lib/src/screens/dashboard/widgets/transactions_page.dart @@ -84,6 +84,7 @@ class TransactionsPage extends StatelessWidget { onTap: () => Navigator.of(context).pushNamed( Routes.orderDetails, arguments: order), + provider: order.provider, from: order.from, to: order.to, createdAtFormattedDate: diff --git a/lib/src/screens/wyre/wyre_page.dart b/lib/src/screens/wyre/wyre_page.dart deleted file mode 100644 index 1ba49da64..000000000 --- a/lib/src/screens/wyre/wyre_page.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'package:cake_wallet/generated/i18n.dart'; -import 'package:cake_wallet/palette.dart'; -import 'package:cake_wallet/src/screens/base_page.dart'; -import 'package:cake_wallet/store/dashboard/orders_store.dart'; -import 'package:cake_wallet/view_model/wyre_view_model.dart'; -import 'package:flutter/material.dart'; -import 'package:webview_flutter/webview_flutter.dart'; - -class WyrePage extends BasePage { - WyrePage(this.wyreViewModel, - {@required this.ordersStore, @required this.url}); - - final OrdersStore ordersStore; - final String url; - final WyreViewModel wyreViewModel; - - @override - String get title => S.current.buy; - - @override - Color get backgroundDarkColor => Colors.white; - - @override - Color get titleColor => Palette.darkBlueCraiola; - - @override - Widget body(BuildContext context) => - WyrePageBody(wyreViewModel, ordersStore: ordersStore, url: url); -} - -class WyrePageBody extends StatefulWidget { - WyrePageBody(this.wyreViewModel, {this.ordersStore, this.url}); - - final OrdersStore ordersStore; - final String url; - final WyreViewModel wyreViewModel; - - @override - WyrePageBodyState createState() => WyrePageBodyState(); -} - -class WyrePageBodyState extends State { - String orderId; - WebViewController _webViewController; - GlobalKey _webViewkey; - Timer _timer; - bool _isSaving; - - @override - void initState() { - super.initState(); - _webViewkey = GlobalKey(); - _isSaving = false; - widget.ordersStore.orderId = ''; - - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); - - _timer?.cancel(); - _timer = Timer.periodic(Duration(seconds: 1), (timer) async { - - try { - if (_webViewController == null || _isSaving) { - return; - } - - final url = await _webViewController.currentUrl(); - - if (url.contains('completed')) { - final urlParts = url.split('/'); - orderId = urlParts.last; - widget.ordersStore.orderId = orderId; - - if (orderId.isNotEmpty) { - _isSaving = true; - await widget.wyreViewModel.saveOrder(orderId); - timer.cancel(); - } - } - } catch (e) { - _isSaving = false; - print(e); - } - }); - } - - @override - Widget build(BuildContext context) { - return WebView( - key: _webViewkey, - initialUrl: widget.url, - javascriptMode: JavascriptMode.unrestricted, - onWebViewCreated: (WebViewController controller) => - setState(() => _webViewController = controller)); - } -} diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 6b24cadfa..10dd9a35a 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -59,14 +59,17 @@ abstract class BuyViewModelBase with Store { CryptoCurrency get cryptoCurrency => walletTypeToCryptoCurrency(type); - Future createOrder() async { + Future fetchUrl() async { + String _url = ''; + try { - final url = await selectedProvider + _url = await selectedProvider ?.requestUrl(doubleAmount?.toString(), fiatCurrency.title); - // FIXME: Start WebView } catch (e) { print(e.toString()); } + + return _url; } Future saveOrder(String orderId) async { @@ -78,4 +81,9 @@ abstract class BuyViewModelBase with Store { print(e.toString()); } } + + void reset() { + buyAmountViewModel.amount = ''; + selectedProvider = null; + } } \ No newline at end of file diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index d471c866a..10e6a5afd 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -28,7 +28,6 @@ import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/transaction_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_display_mode.dart'; -import 'package:cake_wallet/view_model/wyre_view_model.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; @@ -59,8 +58,7 @@ abstract class DashboardViewModelBase with Store { this.transactionFilterStore, this.settingsStore, this.ordersSource, - this.ordersStore, - this.wyreViewModel}) { + this.ordersStore}) { filterItems = { S.current.transactions: [ FilterItem( @@ -230,8 +228,6 @@ abstract class DashboardViewModelBase with Store { TransactionFilterStore transactionFilterStore; - WyreViewModel wyreViewModel; - Map> filterItems; bool get isBuyEnabled => settingsStore.isBitcoinBuyEnabled; diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 275247670..8e8ed3c18 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -1,12 +1,16 @@ import 'dart:async'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; -import 'package:cake_wallet/view_model/wyre_view_model.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; +import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; +import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart'; part 'order_details_view_model.g.dart'; @@ -14,16 +18,27 @@ class OrderDetailsViewModel = OrderDetailsViewModelBase with _$OrderDetailsViewModel; abstract class OrderDetailsViewModelBase with Store { - OrderDetailsViewModelBase({this.wyreViewModel, Order orderForDetails}) { + OrderDetailsViewModelBase({WalletBase wallet, Order orderForDetails}) { order = orderForDetails; + if (order.provider != null) { + switch (order.provider) { + case BuyProviderDescription.wyre: + _provider = WyreBuyProvider(wallet: wallet); + break; + case BuyProviderDescription.moonPay: + _provider = MoonPayBuyProvider(wallet: wallet); + break; + } + } + items = ObservableList(); _updateItems(); _updateOrder(); - _timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateOrder()); + timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateOrder()); } @observable @@ -32,21 +47,20 @@ abstract class OrderDetailsViewModelBase with Store { @observable ObservableList items; - WyreViewModel wyreViewModel; + BuyProvider _provider; - Timer _timer; + Timer timer; @action Future _updateOrder() async { try { - final updatedOrder = - await wyreViewModel.wyreService.findOrderById(order.id); - - updatedOrder.receiveAddress = order.receiveAddress; - updatedOrder.walletId = order.walletId; - order = updatedOrder; - - _updateItems(); + if (_provider != null) { + final updatedOrder = await _provider.findOrderById(order.id); + updatedOrder.receiveAddress = order.receiveAddress; + updatedOrder.walletId = order.walletId; + order = updatedOrder; + _updateItems(); + } } catch (e) { print(e.toString()); } @@ -54,8 +68,6 @@ abstract class OrderDetailsViewModelBase with Store { void _updateItems() { final dateFormat = DateFormatter.withCurrentLocal(); - final buildURL = - wyreViewModel.trackUrl + '${order.transferId}'; items?.clear(); @@ -68,18 +80,37 @@ abstract class OrderDetailsViewModelBase with Store { value: order.state != null ? order.state.toString() : S.current.trade_details_fetching), - TrackTradeListItem( - title: 'Track', - value: buildURL, - onTap: () { - launch(buildURL); - }), - StandartListItem( - title: S.current.trade_details_created_at, - value: dateFormat.format(order.createdAt).toString()), - StandartListItem( - title: S.current.trade_details_pair, - value: '${order.from} → ${order.to}') ]); + + if (order.provider != null) { + items.add( + StandartListItem( + title: 'Buy provider', + value: order.provider.title) + ); + } + + if (_provider.trackUrl.isNotEmpty) { + final buildURL = _provider.trackUrl + '${order.transferId}'; + items.add( + TrackTradeListItem( + title: 'Track', + value: buildURL, + onTap: () => launch(buildURL) + ) + ); + } + + items.add( + StandartListItem( + title: S.current.trade_details_created_at, + value: dateFormat.format(order.createdAt).toString()) + ); + + items.add( + StandartListItem( + title: S.current.trade_details_pair, + value: '${order.from} → ${order.to}') + ); } } \ No newline at end of file diff --git a/lib/view_model/wyre_view_model.dart b/lib/view_model/wyre_view_model.dart deleted file mode 100644 index 2d5ab3315..000000000 --- a/lib/view_model/wyre_view_model.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:cake_wallet/entities/wyre_service.dart'; -import 'package:flutter/foundation.dart'; -import 'package:hive/hive.dart'; -import 'package:cake_wallet/buy/order.dart'; -import 'package:cake_wallet/store/dashboard/orders_store.dart'; -import 'package:mobx/mobx.dart'; - -part 'wyre_view_model.g.dart'; - -class WyreViewModel = WyreViewModelBase with _$WyreViewModel; - -abstract class WyreViewModelBase with Store { - WyreViewModelBase(this.ordersSource, this.ordersStore, - {@required this.wyreService}); - - Future get wyreUrl => wyreService.getWyreUrl(); - - String get trackUrl => wyreService.trackUrl; - - final Box ordersSource; - final OrdersStore ordersStore; - - final WyreService wyreService; - - Future saveOrder(String orderId) async { - try { - final order = await wyreService.findOrderById(orderId); - await ordersSource.add(order); - ordersStore.setOrder(order); - } catch (e) { - print(e.toString()); - } - } -} \ No newline at end of file diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 6d1d66b84..14c692c0d 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Unbestätigt", "displayable" : "Anzeigebar", - "submit_request" : "Einen Antrag stellen" + "submit_request" : "Einen Antrag stellen", + + "buy_bitcoin" : "Bitcoin kaufen", + "buy_with" : "Kaufen mit" } \ No newline at end of file diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index b0d98b7c9..b2cebcca3 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Unconfirmed", "displayable" : "Displayable", - "submit_request" : "submit a request" + "submit_request" : "submit a request", + + "buy_bitcoin" : "Buy Bitcoin", + "buy_with" : "Buy with" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 190ad4304..20c6e1586 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Inconfirmado", "displayable" : "Visualizable", - "submit_request" : "presentar una solicitud" + "submit_request" : "presentar una solicitud", + + "buy_bitcoin" : "Comprar Bitcoin", + "buy_with" : "Compra con" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 6eac14e99..e93615549 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -469,5 +469,8 @@ "unconfirmed" : "अपुष्ट", "displayable" : "प्रदर्शन योग्य", - "submit_request" : "एक अनुरोध सबमिट करें" + "submit_request" : "एक अनुरोध सबमिट करें", + + "buy_bitcoin" : "बिटकॉइन खरीदें", + "buy_with" : "के साथ खरीदें" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 291d5afd3..113e60f46 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -469,5 +469,8 @@ "unconfirmed" : "未確認", "displayable" : "表示可能", - "submit_request" : "リクエストを送信する" + "submit_request" : "リクエストを送信する", + + "buy_bitcoin" : "ビットコインを購入する", + "buy_with" : "で購入" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 781df8d8a..e225f4746 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -469,5 +469,8 @@ "unconfirmed" : "미확인", "displayable" : "표시 가능", - "submit_request" : "요청을 제출" + "submit_request" : "요청을 제출", + + "buy_bitcoin" : "비트 코인 구매", + "buy_with" : "구매" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 9a6183efb..04c239ff4 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Niet bevestigd", "displayable" : "Weer te geven", - "submit_request" : "een verzoek indienen" + "submit_request" : "een verzoek indienen", + + "buy_bitcoin" : "Koop Bitcoin", + "buy_with" : "Koop met" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 6db66958e..542223c18 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Niepotwierdzony", "displayable" : "Wyświetlane", - "submit_request" : "złożyć wniosek" + "submit_request" : "złożyć wniosek", + + "buy_bitcoin" : "Kup Bitcoin", + "buy_with" : "Kup za pomocą" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 631be8f42..ea56dfca9 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Não confirmado", "displayable" : "Exibível", - "submit_request" : "enviar um pedido" + "submit_request" : "enviar um pedido", + + "buy_bitcoin" : "Compre Bitcoin", + "buy_with" : "Compre com" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 333a823d8..319a1753f 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Неподтвержденный", "displayable" : "Отображаемый", - "submit_request" : "отправить запрос" + "submit_request" : "отправить запрос", + + "buy_bitcoin" : "Купить Bitcoin", + "buy_with" : "Купить с помощью" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index cc10a2d89..06082f250 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -469,5 +469,8 @@ "unconfirmed" : "Непідтверджений", "displayable" : "Відображуваний", - "submit_request" : "надіслати запит" + "submit_request" : "надіслати запит", + + "buy_bitcoin" : "Купити Bitcoin", + "buy_with" : "Купити за допомогою" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 639babcbc..39f93ecb1 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -469,5 +469,8 @@ "unconfirmed" : "未经证实", "displayable" : "可显示", - "submit_request" : "提交請求" + "submit_request" : "提交請求", + + "buy_bitcoin" : "購買比特幣", + "buy_with" : "與一起購買" } \ No newline at end of file From 697fc7f5a59132a677c9af6b681a728a2640592e Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 14 Apr 2021 21:23:10 +0300 Subject: [PATCH 03/42] CAKE-306 | reworked buy_list_item.dart and pre_order_page.dart; added clear button to pre_order_page.dart; fixed order_row.dart and order_details_view_model.dart; added MoonPay statuses to trade_state.dart --- assets/images/moonpay-icon.png | Bin 0 -> 2015 bytes lib/buy/get_buy_provider_icon.dart | 5 +- lib/buy/moonpay/moonpay_buy_provider.dart | 5 +- lib/exchange/trade_state.dart | 14 +++ lib/src/screens/buy/buy_webview_page.dart | 18 +++- lib/src/screens/buy/pre_order_page.dart | 86 ++++++++++------- .../screens/buy/widgets/buy_list_item.dart | 91 +++++++++--------- .../screens/dashboard/widgets/order_row.dart | 6 +- lib/src/widgets/base_text_form_field.dart | 10 +- lib/view_model/order_details_view_model.dart | 5 +- 10 files changed, 148 insertions(+), 92 deletions(-) create mode 100644 assets/images/moonpay-icon.png diff --git a/assets/images/moonpay-icon.png b/assets/images/moonpay-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1fbc2b6fc67fbb9ceab8b7134328fe7416db7980 GIT binary patch literal 2015 zcmY*a3piWZ7C!N4Ns+cRG1U@jOi?7F7@3Gyij>5wLzGD*go*LUka~4|De4;P5uJ|e z)H~?IBdW$si!@%<2S(Milu||AGQBNTq%|k4Ywq3qTYLR`?SK7iuk)Sropg7qlPYvS z6aWBKvNOpO^k~pfN;|;S()V;K=oCWiD0TpFBWIVCsR-_ofzF;307&=}0M48RfORl* zW*z`eVF6$v008j$0D#~Y-1Z=V2WQzdaxjGg7=l;{P=xFS(jhX6jkGYqnqW~xC=!VzLEO;9^&OAL#bYqB zv9TtxW+stQAsACDD=Q2Zhr!{DL56X3d<2gfXB-iI=(EUwbx7>!z$gxv$BB$U%5<5m z$WuIP6iQZTdwjkpj}!b)rHJUQw!j84vJ;G{2^O=h4W<%gQM_9ehYePi=@U%}pP2s_ z+p0sr$cq2ZWj=TMDGIhqgc2~@kBtcZfh6yoOwt~pKf%f`n1ia3FR4h;S>KDoIe=@>dw z3LBHFuiUvVs;$+$@Xan?IV&5RIqS)ZiP=G0&6%mGR^pz62Prt#h)nd@&(TJW`%=Ze)a}n*@D1PiPd2d&Q*?eQf{zj=nyDH?Z6N^=!}O zoo-Q4^@7~8co!F!PN}qcC>}A;m7`-`{GzS0vXbVQ)`EN6+6pnZwDj`vK}4qIm8GK_-=!PgWZQirWx;H2jW<)WH=m7yXe2W z<@9Pci^ck=dO+ftH##|qSX*0b&gkxTrTWw9bo*J=skyn3w~(AnP2CUV^78V!?8Zh5 zx;Z`8c!j3*!8V;SvGL%+an-v$Jz0Nu zE8ILoLk;iqY|YHf2x*rFRngamhP<<{wzoSJj?>m*^nA@nX-bN!Fxbz_h@r?`7m~c- z=!3a}+;CH~=j!ynQ!z1)Q&Up|PoGk7R`m@vR!5Ox7me>8e)dOKLVP?~EEbQa3A-{g zM@M~Ut%$_gL`(I!g|8aPR;HmyGu*Q<9RGEUft^|DmFy!Aiwg?!GomgSK)jYFgWT71 zp|*|ih>or<^`F;RHk%mZV`DL2J$|D?=@vH`r`#<+N`2^)wABDJz=}GLb(d z3CzNDEeDsC+Rq^{^V8GGP9FCz<>uz)-6iN7Bc+zgLv}sVwYMRL1_q^9uj+gAhePw; zej%c_lx1WhG^B#}JO58`{=;ReGCf+&<0rDmoW7jAaJ4dM_fiqy*X2c>HC@f;n@;wjXD|t})zkK6ew}y3g6MTuDuBs8eiogk*0ohghli zACxXGF51%p-;4eCRllaM0!a)5$x{`6@zpjR$v_H9Td^gyiV>f`8>G?V6 QKeFEz`52W{YafvOH-BM2B>(^b literal 0 HcmV?d00001 diff --git a/lib/buy/get_buy_provider_icon.dart b/lib/buy/get_buy_provider_icon.dart index d58fe19d4..bbd599e24 100644 --- a/lib/buy/get_buy_provider_icon.dart +++ b/lib/buy/get_buy_provider_icon.dart @@ -5,15 +5,14 @@ Image getBuyProviderIcon(BuyProviderDescription providerDescription) { final _wyreIcon = Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); final _moonPayIcon = - Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); + Image.asset('assets/images/moonpay-icon.png', width: 36, height: 34); if (providerDescription != null) { switch (providerDescription) { case BuyProviderDescription.wyre: return _wyreIcon; case BuyProviderDescription.moonPay: - //return _moonPayIcon; - return null; + return _moonPayIcon; default: return null; } diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index 2fde667e4..5b2fd7326 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -94,8 +94,9 @@ class MoonPayBuyProvider extends BuyProvider { final responseJSON = json.decode(response.body) as Map; final status = responseJSON['status'] as String; - final state = TradeState.deserialize(raw: status.toLowerCase()); - final createdAt = responseJSON['createdAt'] as DateTime; + final state = TradeState.deserialize(raw: status); + final createdAtRaw = responseJSON['createdAt'] as String; + final createdAt = DateTime.parse(createdAtRaw).toLocal(); final amount = responseJSON['quoteCurrencyAmount'] as double; return Order( diff --git a/lib/exchange/trade_state.dart b/lib/exchange/trade_state.dart index 7095626b9..9f08b4df2 100644 --- a/lib/exchange/trade_state.dart +++ b/lib/exchange/trade_state.dart @@ -27,6 +27,12 @@ class TradeState extends EnumerableItem with Serializable { static const finished = TradeState(raw: 'finished', title: 'Finished'); static const waiting = TradeState(raw: 'waiting', title: 'Waiting'); static const processing = TradeState(raw: 'processing', title: 'Processing'); + static const waitingPayment = + TradeState(raw: 'waitingPayment', title: 'Waiting payment'); + static const waitingAuthorization = + TradeState(raw: 'waitingAuthorization', title: 'Waiting authorization'); + static const failed = TradeState(raw: 'failed', title: 'Failed'); + static const completed = TradeState(raw: 'completed', title: 'Completed'); static TradeState deserialize({String raw}) { switch (raw) { @@ -62,6 +68,14 @@ class TradeState extends EnumerableItem with Serializable { return waiting; case 'processing': return processing; + case 'waitingPayment': + return waitingPayment; + case 'waitingAuthorization': + return waitingAuthorization; + case 'failed': + return failed; + case 'completed': + return completed; default: return null; } diff --git a/lib/src/screens/buy/buy_webview_page.dart b/lib/src/screens/buy/buy_webview_page.dart index 91e93f902..d5ab59482 100644 --- a/lib/src/screens/buy/buy_webview_page.dart +++ b/lib/src/screens/buy/buy_webview_page.dart @@ -92,7 +92,23 @@ class BuyWebViewPageBodyState extends State { } if (_provider is MoonPayBuyProvider) { - // FIXME: fetch orderId + /*_timer?.cancel(); + _timer = Timer.periodic(Duration(seconds: 1), (timer) async { + + try { + if (_webViewController == null || _isSaving) { + return; + } + + final url = await _webViewController.currentUrl(); + print('MoonPay Url = $url'); + + timer.cancel(); + } catch (e) { + _isSaving = false; + print(e); + } + });*/ } } diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 0cf6a1f88..44162d7ec 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -14,6 +14,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; +import 'package:cake_wallet/src/widgets/trail_button.dart'; import 'package:mobx/mobx.dart'; class PreOrderPage extends BasePage { @@ -61,6 +62,13 @@ class PreOrderPage extends BasePage { @override AppBarStyle get appBarStyle => AppBarStyle.transparent; + @override + Widget trailing(context) => TrailButton( + caption: S.of(context).clear, + onPressed: () { + buyViewModel.reset(); + }); + @override Widget body(BuildContext context) { return KeyboardActions( @@ -96,43 +104,49 @@ class PreOrderPage extends BasePage { ], begin: Alignment.topLeft, end: Alignment.bottomRight), ), child: Padding( - padding: EdgeInsets.fromLTRB(100, 100, 100, 65), - child: BaseTextFormField( - focusNode: _amountFocus, - controller: _amountController, - keyboardType: - TextInputType.numberWithOptions( - signed: false, decimal: true), - inputFormatters: [ - FilteringTextInputFormatter - .allow(RegExp(_amountPattern)) - ], - prefixIcon: Padding( - padding: EdgeInsets.only(top: 2), - child: - Text(buyViewModel.fiatCurrency.title + ': ', - style: TextStyle( - fontSize: 36, - fontWeight: FontWeight.w600, - color: Colors.white, - )), - ), - hintText: '0.00', - borderColor: Theme.of(context) - .primaryTextTheme - .headline - .color, - textStyle: TextStyle( - fontSize: 36, - fontWeight: FontWeight.w500, - color: Colors.white), - placeholderTextStyle: TextStyle( - color: Theme.of(context) + padding: EdgeInsets.only(top: 100, bottom: 65), + child: Center( + child: Container( + width: 165, + child: BaseTextFormField( + focusNode: _amountFocus, + controller: _amountController, + keyboardType: + TextInputType.numberWithOptions( + signed: false, decimal: true), + inputFormatters: [ + FilteringTextInputFormatter + .allow(RegExp(_amountPattern)) + ], + prefixIcon: Padding( + padding: EdgeInsets.only(top: 2), + child: + Text(buyViewModel.fiatCurrency.title + ': ', + style: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w600, + color: Colors.white, + )), + ), + hintText: '0.00', + borderColor: Theme.of(context) .primaryTextTheme - .headline + .body2 .decorationColor, - fontWeight: FontWeight.w500, - fontSize: 36), + borderWidth: 0.5, + textStyle: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w500, + color: Colors.white), + placeholderTextStyle: TextStyle( + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor, + fontWeight: FontWeight.w500, + fontSize: 36), + ) + ) ) ) ), @@ -144,7 +158,7 @@ class PreOrderPage extends BasePage { style: TextStyle( color: Theme.of(context).primaryTextTheme.title.color, fontSize: 18, - fontWeight: FontWeight.w500 + fontWeight: FontWeight.bold ), ) ), diff --git a/lib/src/screens/buy/widgets/buy_list_item.dart b/lib/src/screens/buy/widgets/buy_list_item.dart index 8ee3950aa..7c18893a6 100644 --- a/lib/src/screens/buy/widgets/buy_list_item.dart +++ b/lib/src/screens/buy/widgets/buy_list_item.dart @@ -52,62 +52,67 @@ class BuyListItem extends StatelessWidget { height: 102, padding: EdgeInsets.only( left: 20, + //top: 33, right: 20 ), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(25)), color: backgroundColor ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, + child: Stack( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - if (providerIcon != null) Padding( - padding: EdgeInsets.only(right: 10), - child: providerIcon - ), - Text( - provider.description.title, - style: TextStyle( - color: primaryTextColor, - fontSize: 24, - fontWeight: FontWeight.w500 + Positioned( + top: 33, + left: 0, + right: 0, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (providerIcon != null) Padding( + padding: EdgeInsets.only(right: 10), + child: providerIcon + ), + Text( + provider.description.title, + style: TextStyle( + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold + ), + ) + ], ), - ) - ], - ), - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - '${destAmount?.toString()} ${destCurrency.title}', - style: TextStyle( - color: secondaryTextColor, - fontSize: 18, - fontWeight: FontWeight.w500 - ), - ), - Padding( - padding: EdgeInsets.only(top: 5), - child: Text( - '${sourceAmount?.toString()} ${sourceCurrency.title}', + Text( + '${destAmount?.toString()} ${destCurrency.title}', style: TextStyle( - color: primaryTextColor, - fontSize: 18, - fontWeight: FontWeight.w500 + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold ), ), - ) - ], + ], + ) + ), + Positioned( + top: 65, + right: 0, + child: Text( + '${sourceAmount?.toString()} ${sourceCurrency.title}', + style: TextStyle( + color: primaryTextColor, + fontSize: 16, + fontWeight: FontWeight.bold + ), + ), ) ], - ), + ) ) ); } diff --git a/lib/src/screens/dashboard/widgets/order_row.dart b/lib/src/screens/dashboard/widgets/order_row.dart index 49afa7a25..56a69122e 100644 --- a/lib/src/screens/dashboard/widgets/order_row.dart +++ b/lib/src/screens/dashboard/widgets/order_row.dart @@ -30,8 +30,10 @@ class OrderRow extends StatelessWidget { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ - providerIcon ?? Offstage(), - SizedBox(width: 12), + if (providerIcon != null) Padding( + padding: EdgeInsets.only(right: 12), + child: providerIcon, + ), Expanded( child: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/src/widgets/base_text_form_field.dart b/lib/src/widgets/base_text_form_field.dart index b9148bf2c..385cba8cd 100644 --- a/lib/src/widgets/base_text_form_field.dart +++ b/lib/src/widgets/base_text_form_field.dart @@ -26,7 +26,8 @@ class BaseTextFormField extends StatelessWidget { this.placeholderTextStyle, this.maxLength, this.focusNode, - this.initialValue}); + this.initialValue, + this.borderWidth = 1.0}); final TextEditingController controller; final TextInputType keyboardType; @@ -52,6 +53,7 @@ class BaseTextFormField extends StatelessWidget { final bool readOnly; final bool enableInteractiveSelection; final String initialValue; + final double borderWidth; @override Widget build(BuildContext context) { @@ -88,17 +90,17 @@ class BaseTextFormField extends StatelessWidget { borderSide: BorderSide( color: borderColor ?? Theme.of(context).primaryTextTheme.title.backgroundColor, - width: 1.0)), + width: borderWidth)), disabledBorder: UnderlineInputBorder( borderSide: BorderSide( color: borderColor ?? Theme.of(context).primaryTextTheme.title.backgroundColor, - width: 1.0)), + width: borderWidth)), enabledBorder: UnderlineInputBorder( borderSide: BorderSide( color: borderColor ?? Theme.of(context).primaryTextTheme.title.backgroundColor, - width: 1.0))), + width: borderWidth))), validator: validator, ); } diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 8e8ed3c18..328b0c93c 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -58,6 +58,9 @@ abstract class OrderDetailsViewModelBase with Store { final updatedOrder = await _provider.findOrderById(order.id); updatedOrder.receiveAddress = order.receiveAddress; updatedOrder.walletId = order.walletId; + if (order.provider != null) { + updatedOrder.providerRaw = order.provider.raw; + } order = updatedOrder; _updateItems(); } @@ -90,7 +93,7 @@ abstract class OrderDetailsViewModelBase with Store { ); } - if (_provider.trackUrl.isNotEmpty) { + if (_provider?.trackUrl?.isNotEmpty ?? false) { final buildURL = _provider.trackUrl + '${order.transferId}'; items.add( TrackTradeListItem( From 1c976bfaa12e6868b0773e7585992d014626a4a9 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Thu, 15 Apr 2021 20:10:23 +0300 Subject: [PATCH 04/42] CAKE-306 | applied _saveOrder() to buy_webview_page.dart; fixed moonpay_buy_provider.dart and wyre_buy_provider.dart; canceled timers on exchange_trade_page.dart, order_details_page.dart and trade_details_page.dart; reworked pre_order_page.dart --- lib/buy/moonpay/moonpay_buy_provider.dart | 9 +- lib/buy/wyre/wyre_buy_provider.dart | 3 +- lib/di.dart | 11 +- lib/router.dart | 5 +- lib/src/screens/buy/buy_webview_page.dart | 78 +++--- lib/src/screens/buy/pre_order_page.dart | 227 +++++++++--------- .../exchange_trade/exchange_trade_page.dart | 6 + .../order_details/order_details_page.dart | 29 ++- .../trade_details/trade_details_page.dart | 29 ++- lib/view_model/buy/buy_view_model.dart | 4 + .../exchange/exchange_trade_view_model.dart | 4 +- lib/view_model/trade_details_view_model.dart | 4 +- 12 files changed, 238 insertions(+), 171 deletions(-) diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index 5b2fd7326..240d6389e 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -23,6 +23,7 @@ class MoonPayBuyProvider extends BuyProvider { static const _currenciesSuffix = '/v3/currencies'; static const _quoteSuffix = '/buy_quote'; static const _transactionsSuffix = '/v1/transactions'; + static const _fiatCurrency = 'USD'; static const _apiKey = secrets.moonPayApiKey; @override @@ -35,9 +36,7 @@ class MoonPayBuyProvider extends BuyProvider { walletTypeToCryptoCurrency(walletType).title.toLowerCase(); @override - String get trackUrl => isTestEnvironment - ? '' - : ''; // FIXME + String get trackUrl => baseApiUrl + '/transaction_receipt?transactionId='; String baseApiUrl; @@ -103,8 +102,8 @@ class MoonPayBuyProvider extends BuyProvider { id: id, provider: description, transferId: id, - from: 'USD', //FIXME - to: 'BTC', //FIXME + from: _fiatCurrency, + to: currencyCode.toUpperCase(), state: state, createdAt: createdAt, amount: amount.toString(), diff --git a/lib/buy/wyre/wyre_buy_provider.dart b/lib/buy/wyre/wyre_buy_provider.dart index 3a09be0f6..77055c325 100644 --- a/lib/buy/wyre/wyre_buy_provider.dart +++ b/lib/buy/wyre/wyre_buy_provider.dart @@ -28,6 +28,7 @@ class WyreBuyProvider extends BuyProvider { static const _timeStampSuffix = '?timestamp='; static const _transferSuffix = '/v2/transfer/'; static const _trackSuffix = '/track'; + static const _countryCode = 'US'; static const _secretKey = secrets.wyreSecretKey; static const _accountId = secrets.wyreAccountId; @@ -86,7 +87,7 @@ class WyreBuyProvider extends BuyProvider { 'destCurrency': walletTypeToCryptoCurrency(walletType).title, 'dest': walletTypeToString(walletType).toLowerCase() + ':' + walletAddress, 'accountId': _accountId, - 'country': 'US' //FIXME + 'country': _countryCode }; final response = await post(quoteUrl, diff --git a/lib/di.dart b/lib/di.dart index 0b107fde4..2a33e6b11 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -544,9 +544,14 @@ Future setup( return PreOrderPage(buyViewModel: getIt.get()); }); - getIt.registerFactoryParam((String url, _) => - BuyWebViewPage(getIt.get(), - ordersStore: getIt.get(), url: url)); + getIt.registerFactoryParam( + (List args, _) { + final url = args.first as String; + final buyViewModel = args[1] as BuyViewModel; + + return BuyWebViewPage(buyViewModel: buyViewModel, + ordersStore: getIt.get(), url: url); + }); getIt.registerFactoryParam( (order, _) { diff --git a/lib/router.dart b/lib/router.dart index a3421fa69..e8650e34e 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart'; import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart'; import 'package:cake_wallet/src/screens/support/support_page.dart'; import 'package:cake_wallet/store/settings_store.dart'; +import 'package:cake_wallet/view_model/buy/buy_view_model.dart'; import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -304,9 +305,11 @@ Route createRoute(RouteSettings settings) { getIt.get()); case Routes.buyWebView: + final args = settings.arguments as List; + return MaterialPageRoute( builder: (_) => - getIt.get(param1: settings.arguments as String)); + getIt.get(param1: args)); case Routes.restoreWalletFromSeedDetails: final args = settings.arguments as List; diff --git a/lib/src/screens/buy/buy_webview_page.dart b/lib/src/screens/buy/buy_webview_page.dart index d5ab59482..9d2ba3698 100644 --- a/lib/src/screens/buy/buy_webview_page.dart +++ b/lib/src/screens/buy/buy_webview_page.dart @@ -12,8 +12,8 @@ import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class BuyWebViewPage extends BasePage { - BuyWebViewPage(this.buyViewModel, - {@required this.ordersStore, @required this.url}); + BuyWebViewPage({@required this.buyViewModel, + @required this.ordersStore, @required this.url}); final OrdersStore ordersStore; final String url; @@ -63,52 +63,11 @@ class BuyWebViewPageBodyState extends State { if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); if (_provider is WyreBuyProvider) { - _timer?.cancel(); - _timer = Timer.periodic(Duration(seconds: 1), (timer) async { - - try { - if (_webViewController == null || _isSaving) { - return; - } - - final url = await _webViewController.currentUrl(); - - if (url.contains('completed')) { - final urlParts = url.split('/'); - orderId = urlParts.last; - widget.ordersStore.orderId = orderId; - - if (orderId.isNotEmpty) { - _isSaving = true; - await widget.buyViewModel.saveOrder(orderId); - timer.cancel(); - } - } - } catch (e) { - _isSaving = false; - print(e); - } - }); + _saveOrder(keyword: 'completed', splitSymbol: '/'); } if (_provider is MoonPayBuyProvider) { - /*_timer?.cancel(); - _timer = Timer.periodic(Duration(seconds: 1), (timer) async { - - try { - if (_webViewController == null || _isSaving) { - return; - } - - final url = await _webViewController.currentUrl(); - print('MoonPay Url = $url'); - - timer.cancel(); - } catch (e) { - _isSaving = false; - print(e); - } - });*/ + _saveOrder(keyword: 'transactionId', splitSymbol: '='); } } @@ -121,4 +80,33 @@ class BuyWebViewPageBodyState extends State { onWebViewCreated: (WebViewController controller) => setState(() => _webViewController = controller)); } + + void _saveOrder({String keyword, String splitSymbol}) { + _timer?.cancel(); + _timer = Timer.periodic(Duration(seconds: 1), (timer) async { + + try { + if (_webViewController == null || _isSaving) { + return; + } + + final url = await _webViewController.currentUrl(); + + if (url.contains(keyword)) { + final urlParts = url.split(splitSymbol); + orderId = urlParts.last; + widget.ordersStore.orderId = orderId; + + if (orderId.isNotEmpty) { + _isSaving = true; + await widget.buyViewModel.saveOrder(orderId); + timer.cancel(); + } + } + } catch (e) { + _isSaving = false; + print(e); + } + }); + } } diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 44162d7ec..dbe03b07e 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -27,9 +27,6 @@ class PreOrderPage extends BasePage { if (amount != buyViewModel.buyAmountViewModel.amount) { buyViewModel.buyAmountViewModel.amount = amount; - } - - if (buyViewModel.buyAmountViewModel.doubleAmount == 0.0) { buyViewModel.selectedProvider = null; } }); @@ -38,6 +35,12 @@ class PreOrderPage extends BasePage { if (_amountController.text != amount) { _amountController.text = amount; } + if (amount.isEmpty) { + buyViewModel.selectedProvider = null; + buyViewModel.isShowProviderButtons = false; + } else { + buyViewModel.isShowProviderButtons = true; + } }); } @@ -88,120 +91,123 @@ class PreOrderPage extends BasePage { color: Theme.of(context).backgroundColor, child: ScrollableWithBottomSection( contentPadding: EdgeInsets.only(bottom: 24), - content: Column( + content: Observer(builder: (_) => Column( children: [ Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(24), - bottomRight: Radius.circular(24)), - gradient: LinearGradient(colors: [ - Theme.of(context).primaryTextTheme.subhead.color, - Theme.of(context) - .primaryTextTheme - .subhead - .decorationColor, - ], begin: Alignment.topLeft, end: Alignment.bottomRight), - ), - child: Padding( - padding: EdgeInsets.only(top: 100, bottom: 65), - child: Center( - child: Container( - width: 165, - child: BaseTextFormField( - focusNode: _amountFocus, - controller: _amountController, - keyboardType: - TextInputType.numberWithOptions( - signed: false, decimal: true), - inputFormatters: [ - FilteringTextInputFormatter - .allow(RegExp(_amountPattern)) - ], - prefixIcon: Padding( - padding: EdgeInsets.only(top: 2), - child: - Text(buyViewModel.fiatCurrency.title + ': ', - style: TextStyle( - fontSize: 36, - fontWeight: FontWeight.w600, - color: Colors.white, - )), - ), - hintText: '0.00', - borderColor: Theme.of(context) - .primaryTextTheme - .body2 - .decorationColor, - borderWidth: 0.5, - textStyle: TextStyle( - fontSize: 36, - fontWeight: FontWeight.w500, - color: Colors.white), - placeholderTextStyle: TextStyle( - color: Theme.of(context) - .primaryTextTheme - .headline - .decorationColor, - fontWeight: FontWeight.w500, - fontSize: 36), - ) - ) - ) - ) - ), - Padding( - padding: EdgeInsets.only(top: 38, bottom: 18), - child: Text( - S.of(context).buy_with + ':', - textAlign: TextAlign.center, - style: TextStyle( - color: Theme.of(context).primaryTextTheme.title.color, - fontSize: 18, - fontWeight: FontWeight.bold + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), + bottomRight: Radius.circular(24)), + gradient: LinearGradient(colors: [ + Theme.of(context).primaryTextTheme.subhead.color, + Theme.of(context) + .primaryTextTheme + .subhead + .decorationColor, + ], begin: Alignment.topLeft, end: Alignment.bottomRight), ), - ) + child: Padding( + padding: EdgeInsets.only(top: 100, bottom: 65), + child: Center( + child: Container( + width: 165, + child: BaseTextFormField( + focusNode: _amountFocus, + controller: _amountController, + keyboardType: + TextInputType.numberWithOptions( + signed: false, decimal: true), + inputFormatters: [ + FilteringTextInputFormatter + .allow(RegExp(_amountPattern)) + ], + prefixIcon: Padding( + padding: EdgeInsets.only(top: 2), + child: + Text(buyViewModel.fiatCurrency.title + ': ', + style: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w600, + color: Colors.white, + )), + ), + hintText: '0.00', + borderColor: Theme.of(context) + .primaryTextTheme + .body2 + .decorationColor, + borderWidth: 0.5, + textStyle: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w500, + color: Colors.white), + placeholderTextStyle: TextStyle( + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor, + fontWeight: FontWeight.w500, + fontSize: 36), + ) + ) + ) + ) ), - ...buyViewModel.items.map( - (item) => Observer(builder: (_) => FutureBuilder( - future: item.buyAmount, - builder: (context, AsyncSnapshot snapshot) { - double sourceAmount; - double destAmount; + if (buyViewModel.isShowProviderButtons) Padding( + padding: EdgeInsets.only(top: 38, bottom: 18), + child: Text( + S.of(context).buy_with + ':', + textAlign: TextAlign.center, + style: TextStyle( + color: Theme.of(context).primaryTextTheme.title.color, + fontSize: 18, + fontWeight: FontWeight.bold + ), + ) + ), + if (buyViewModel.isShowProviderButtons) + ...buyViewModel.items.map( + (item) => Observer(builder: (_) => FutureBuilder( + future: item.buyAmount, + builder: (context, AsyncSnapshot snapshot) { + double sourceAmount; + double destAmount; - if (snapshot.hasData) { - sourceAmount = snapshot.data.sourceAmount; - destAmount = snapshot.data.destAmount; - } else { - sourceAmount = 0.0; - destAmount = 0.0; + if (snapshot.hasData) { + sourceAmount = snapshot.data.sourceAmount; + destAmount = snapshot.data.destAmount; + } else { + sourceAmount = 0.0; + destAmount = 0.0; + } + + return Padding( + padding: + EdgeInsets.only(left: 15, top: 20, right: 15), + child: Observer(builder: (_) { + return BuyListItem( + selectedProvider: buyViewModel.selectedProvider, + provider: item.provider, + sourceAmount: sourceAmount, + sourceCurrency: buyViewModel.fiatCurrency, + destAmount: destAmount, + destCurrency: buyViewModel.cryptoCurrency, + onTap: + buyViewModel.buyAmountViewModel + .doubleAmount == 0.0 ? null : () { + buyViewModel.selectedProvider = item.provider; + sourceAmount > 0 + ? buyViewModel.isDisabled = false + : buyViewModel.isDisabled = true; + } + ); + }) + ); } - - return Padding( - padding: - EdgeInsets.only(left: 15, top: 20, right: 15), - child: Observer(builder: (_) => BuyListItem( - selectedProvider: buyViewModel.selectedProvider, - provider: item.provider, - sourceAmount: sourceAmount, - sourceCurrency: buyViewModel.fiatCurrency, - destAmount: destAmount, - destCurrency: buyViewModel.cryptoCurrency, - onTap: - buyViewModel.buyAmountViewModel - .doubleAmount == 0.0 ? null : () { - buyViewModel.selectedProvider = item.provider; - sourceAmount > 0 - ? buyViewModel.isDisabled = false - : buyViewModel.isDisabled = true; - } - )) - ); - } - ),) + )) ) ], - ), + )), bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSection: Observer(builder: (_) { @@ -214,7 +220,8 @@ class PreOrderPage extends BasePage { await buyViewModel.fetchUrl(); if (url.isNotEmpty) { await Navigator.of(context) - .pushNamed(Routes.buyWebView, arguments: url); + .pushNamed(Routes.buyWebView, + arguments: [url, buyViewModel]); buyViewModel.reset(); } buyViewModel.isRunning = false; diff --git a/lib/src/screens/exchange_trade/exchange_trade_page.dart b/lib/src/screens/exchange_trade/exchange_trade_page.dart index b4374cbb5..0a3b10e18 100644 --- a/lib/src/screens/exchange_trade/exchange_trade_page.dart +++ b/lib/src/screens/exchange_trade/exchange_trade_page.dart @@ -98,6 +98,12 @@ class ExchangeTradeState extends State { showInformation(widget.exchangeTradeViewModel, context); } + @override + void dispose() { + super.dispose(); + widget.exchangeTradeViewModel.timer?.cancel(); + } + @override Widget build(BuildContext context) { final copyImage = Image.asset('assets/images/copy_content.png', diff --git a/lib/src/screens/order_details/order_details_page.dart b/lib/src/screens/order_details/order_details_page.dart index 4122a1af5..293cf5e3d 100644 --- a/lib/src/screens/order_details/order_details_page.dart +++ b/lib/src/screens/order_details/order_details_page.dart @@ -19,7 +19,33 @@ class OrderDetailsPage extends BasePage { final OrderDetailsViewModel orderDetailsViewModel; @override - Widget body(BuildContext context) { + Widget body(BuildContext context) => + OrderDetailsPageBody(orderDetailsViewModel); +} + +class OrderDetailsPageBody extends StatefulWidget { + OrderDetailsPageBody(this.orderDetailsViewModel); + + final OrderDetailsViewModel orderDetailsViewModel; + + @override + OrderDetailsPageBodyState createState() => + OrderDetailsPageBodyState(orderDetailsViewModel); +} + +class OrderDetailsPageBodyState extends State { + OrderDetailsPageBodyState(this.orderDetailsViewModel); + + final OrderDetailsViewModel orderDetailsViewModel; + + @override + void dispose() { + super.dispose(); + orderDetailsViewModel.timer?.cancel(); + } + + @override + Widget build(BuildContext context) { return Observer(builder: (_) { return SectionStandardList( sectionCount: 1, @@ -44,4 +70,5 @@ class OrderDetailsPage extends BasePage { }); }); } + } \ No newline at end of file diff --git a/lib/src/screens/trade_details/trade_details_page.dart b/lib/src/screens/trade_details/trade_details_page.dart index e691e7f84..abf8e2873 100644 --- a/lib/src/screens/trade_details/trade_details_page.dart +++ b/lib/src/screens/trade_details/trade_details_page.dart @@ -19,7 +19,33 @@ class TradeDetailsPage extends BasePage { final TradeDetailsViewModel tradeDetailsViewModel; @override - Widget body(BuildContext context) { + Widget body(BuildContext context) => + TradeDetailsPageBody(tradeDetailsViewModel); +} + +class TradeDetailsPageBody extends StatefulWidget { + TradeDetailsPageBody(this.tradeDetailsViewModel); + + final TradeDetailsViewModel tradeDetailsViewModel; + + @override + TradeDetailsPageBodyState createState() => + TradeDetailsPageBodyState(tradeDetailsViewModel); +} + +class TradeDetailsPageBodyState extends State { + TradeDetailsPageBodyState(this.tradeDetailsViewModel); + + final TradeDetailsViewModel tradeDetailsViewModel; + + @override + void dispose() { + super.dispose(); + tradeDetailsViewModel.timer?.cancel(); + } + + @override + Widget build(BuildContext context) { return Observer(builder: (_) { return SectionStandardList( sectionCount: 1, @@ -44,4 +70,5 @@ class TradeDetailsPage extends BasePage { }); }); } + } diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 10dd9a35a..70d1cc556 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -29,6 +29,7 @@ abstract class BuyViewModelBase with Store { .toList(); isRunning = false; isDisabled = true; + isShowProviderButtons = false; } final Box ordersSource; @@ -51,6 +52,9 @@ abstract class BuyViewModelBase with Store { @observable bool isDisabled; + @observable + bool isShowProviderButtons; + WalletType get type => wallet.type; double get doubleAmount => buyAmountViewModel.doubleAmount; diff --git a/lib/view_model/exchange/exchange_trade_view_model.dart b/lib/view_model/exchange/exchange_trade_view_model.dart index a739b207f..7882c3dca 100644 --- a/lib/view_model/exchange/exchange_trade_view_model.dart +++ b/lib/view_model/exchange/exchange_trade_view_model.dart @@ -45,7 +45,7 @@ abstract class ExchangeTradeViewModelBase with Store { _updateTrade(); - _timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade()); + timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade()); } final WalletBase wallet; @@ -71,7 +71,7 @@ abstract class ExchangeTradeViewModelBase with Store { ExchangeProvider _provider; - Timer _timer; + Timer timer; @action Future confirmSending() async { diff --git a/lib/view_model/trade_details_view_model.dart b/lib/view_model/trade_details_view_model.dart index 9c88cb981..a367c17f4 100644 --- a/lib/view_model/trade_details_view_model.dart +++ b/lib/view_model/trade_details_view_model.dart @@ -39,7 +39,7 @@ abstract class TradeDetailsViewModelBase with Store { _updateTrade(); - _timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade()); + timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade()); } final Box trades; @@ -52,7 +52,7 @@ abstract class TradeDetailsViewModelBase with Store { ExchangeProvider _provider; - Timer _timer; + Timer timer; @action Future _updateTrade() async { From 9627590ba571dd9979117015ab815a66847dbdad Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Fri, 30 Apr 2021 11:08:25 +0300 Subject: [PATCH 05/42] CAKE-306 | fixed findOrderById() in the moonpay_buy_provider.dart; fixed saveOrder() in the buy_view_model.dart --- lib/buy/moonpay/moonpay_buy_provider.dart | 27 ++++++++++++++----- lib/buy/wyre/wyre_buy_provider.dart | 2 +- lib/di.dart | 4 +-- lib/view_model/buy/buy_view_model.dart | 4 ++- .../dashboard/dashboard_view_model.dart | 3 --- lib/view_model/order_details_view_model.dart | 9 +++++-- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index 240d6389e..c53eb9c0e 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'package:cake_wallet/buy/buy_exception.dart'; +import 'package:hive/hive.dart'; import 'package:http/http.dart'; import 'package:cake_wallet/buy/buy_amount.dart'; import 'package:cake_wallet/buy/buy_provider.dart'; @@ -11,9 +12,10 @@ import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; class MoonPayBuyProvider extends BuyProvider { - MoonPayBuyProvider({WalletBase wallet, bool isTestEnvironment = false}) + MoonPayBuyProvider({WalletBase wallet, this.ordersSource, + bool isTestEnvironment = false}) : super(wallet: wallet, isTestEnvironment: isTestEnvironment) { - baseApiUrl = isTestEnvironment + baseApiUrl = isTestEnvironment ? _baseTestApiUrl : _baseProductApiUrl; } @@ -23,7 +25,6 @@ class MoonPayBuyProvider extends BuyProvider { static const _currenciesSuffix = '/v3/currencies'; static const _quoteSuffix = '/buy_quote'; static const _transactionsSuffix = '/v1/transactions'; - static const _fiatCurrency = 'USD'; static const _apiKey = secrets.moonPayApiKey; @override @@ -38,6 +39,7 @@ class MoonPayBuyProvider extends BuyProvider { @override String get trackUrl => baseApiUrl + '/transaction_receipt?transactionId='; + final Box ordersSource; String baseApiUrl; @override @@ -58,7 +60,7 @@ class MoonPayBuyProvider extends BuyProvider { @override Future calculateAmount(String amount, String sourceCurrency) async { - final url = baseApiUrl + _currenciesSuffix + '/$currencyCode' + + final url = _baseProductApiUrl + _currenciesSuffix + '/$currencyCode' + _quoteSuffix + '/?apiKey=' + _apiKey + '&baseCurrencyAmount=' + amount + '&baseCurrencyCode' + sourceCurrency.toLowerCase(); @@ -80,7 +82,7 @@ class MoonPayBuyProvider extends BuyProvider { @override Future findOrderById(String id) async { - final url = baseApiUrl + _transactionsSuffix + '/$id' + + final url = _baseProductApiUrl + _transactionsSuffix + '/$id' + '?apiKey=' + _apiKey; final response = await get(url); @@ -98,12 +100,23 @@ class MoonPayBuyProvider extends BuyProvider { final createdAt = DateTime.parse(createdAtRaw).toLocal(); final amount = responseJSON['quoteCurrencyAmount'] as double; + var from = ''; + var to = ''; + + for (final order in ordersSource.values) { + if (order.id == id) { + from = order.from; + to = order.to; + break; + } + } + return Order( id: id, provider: description, transferId: id, - from: _fiatCurrency, - to: currencyCode.toUpperCase(), + from: from, + to: to, state: state, createdAt: createdAt, amount: amount.toString(), diff --git a/lib/buy/wyre/wyre_buy_provider.dart b/lib/buy/wyre/wyre_buy_provider.dart index 77055c325..f1100d130 100644 --- a/lib/buy/wyre/wyre_buy_provider.dart +++ b/lib/buy/wyre/wyre_buy_provider.dart @@ -80,7 +80,7 @@ class WyreBuyProvider extends BuyProvider { @override Future calculateAmount(String amount, String sourceCurrency) async { - final quoteUrl = baseApiUrl + _ordersSuffix + _quoteSuffix; + final quoteUrl = _baseProductApiUrl + _ordersSuffix + _quoteSuffix; final body = { 'amount': amount, 'sourceCurrency': sourceCurrency, diff --git a/lib/di.dart b/lib/di.dart index 2a33e6b11..60a20e52a 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -238,7 +238,6 @@ Future setup( tradeFilterStore: getIt.get(), transactionFilterStore: getIt.get(), settingsStore: settingsStore, - ordersSource: _ordersSource, ordersStore: getIt.get())); getIt.registerFactory(() => AuthService( @@ -536,7 +535,7 @@ Future setup( getIt.registerFactory(() { final wallet = getIt.get().wallet; - return BuyViewModel(ordersSource, getIt.get(), + return BuyViewModel(_ordersSource, getIt.get(), getIt.get(), wallet: wallet); }); @@ -559,6 +558,7 @@ Future setup( return OrderDetailsViewModel( wallet: wallet, + ordersSource: _ordersSource, orderForDetails: order); }); diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 70d1cc556..d0f2c2f6e 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -22,7 +22,7 @@ abstract class BuyViewModelBase with Store { {@required this.wallet}) { providerList = [ WyreBuyProvider(wallet: wallet), - MoonPayBuyProvider(wallet: wallet) + MoonPayBuyProvider(wallet: wallet, ordersSource: ordersSource) ]; items = providerList.map((provider) => BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel)) @@ -79,6 +79,8 @@ abstract class BuyViewModelBase with Store { Future saveOrder(String orderId) async { try { final order = await selectedProvider?.findOrderById(orderId); + order.from = fiatCurrency.title; + order.to = cryptoCurrency.title; await ordersSource.add(order); ordersStore.setOrder(order); } catch (e) { diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 10e6a5afd..ff1d2411d 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -57,7 +57,6 @@ abstract class DashboardViewModelBase with Store { this.tradeFilterStore, this.transactionFilterStore, this.settingsStore, - this.ordersSource, this.ordersStore}) { filterItems = { S.current.transactions: [ @@ -212,8 +211,6 @@ abstract class DashboardViewModelBase with Store { bool get hasRescan => wallet.type == WalletType.monero; - Box ordersSource; - BalanceViewModel balanceViewModel; AppStore appStore; diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 328b0c93c..0fb92a761 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/buy_provider.dart'; import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; +import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; @@ -18,7 +19,8 @@ class OrderDetailsViewModel = OrderDetailsViewModelBase with _$OrderDetailsViewModel; abstract class OrderDetailsViewModelBase with Store { - OrderDetailsViewModelBase({WalletBase wallet, Order orderForDetails}) { + OrderDetailsViewModelBase({WalletBase wallet, this.ordersSource, + Order orderForDetails}) { order = orderForDetails; if (order.provider != null) { @@ -27,7 +29,8 @@ abstract class OrderDetailsViewModelBase with Store { _provider = WyreBuyProvider(wallet: wallet); break; case BuyProviderDescription.moonPay: - _provider = MoonPayBuyProvider(wallet: wallet); + _provider = + MoonPayBuyProvider(wallet: wallet, ordersSource: ordersSource); break; } } @@ -41,6 +44,8 @@ abstract class OrderDetailsViewModelBase with Store { timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateOrder()); } + final Box ordersSource; + @observable Order order; From ae7ccacf29f6e25d73290c2e734ef4f1e44ae922 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Fri, 30 Apr 2021 13:12:00 +0300 Subject: [PATCH 06/42] CAKE-306 | fixed moonpay_buy_provider.dart, buy_view_model.dart and order_details_view_model.dart --- lib/buy/moonpay/moonpay_buy_provider.dart | 18 +----------------- lib/di.dart | 1 - lib/view_model/buy/buy_view_model.dart | 2 +- lib/view_model/order_details_view_model.dart | 11 ++++------- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index c53eb9c0e..eef0e941f 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -1,6 +1,5 @@ import 'dart:convert'; import 'package:cake_wallet/buy/buy_exception.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart'; import 'package:cake_wallet/buy/buy_amount.dart'; import 'package:cake_wallet/buy/buy_provider.dart'; @@ -12,8 +11,7 @@ import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; class MoonPayBuyProvider extends BuyProvider { - MoonPayBuyProvider({WalletBase wallet, this.ordersSource, - bool isTestEnvironment = false}) + MoonPayBuyProvider({WalletBase wallet, bool isTestEnvironment = false}) : super(wallet: wallet, isTestEnvironment: isTestEnvironment) { baseApiUrl = isTestEnvironment ? _baseTestApiUrl @@ -39,7 +37,6 @@ class MoonPayBuyProvider extends BuyProvider { @override String get trackUrl => baseApiUrl + '/transaction_receipt?transactionId='; - final Box ordersSource; String baseApiUrl; @override @@ -100,23 +97,10 @@ class MoonPayBuyProvider extends BuyProvider { final createdAt = DateTime.parse(createdAtRaw).toLocal(); final amount = responseJSON['quoteCurrencyAmount'] as double; - var from = ''; - var to = ''; - - for (final order in ordersSource.values) { - if (order.id == id) { - from = order.from; - to = order.to; - break; - } - } - return Order( id: id, provider: description, transferId: id, - from: from, - to: to, state: state, createdAt: createdAt, amount: amount.toString(), diff --git a/lib/di.dart b/lib/di.dart index 60a20e52a..e66d8516a 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -558,7 +558,6 @@ Future setup( return OrderDetailsViewModel( wallet: wallet, - ordersSource: _ordersSource, orderForDetails: order); }); diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index d0f2c2f6e..90dbd6cfa 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -22,7 +22,7 @@ abstract class BuyViewModelBase with Store { {@required this.wallet}) { providerList = [ WyreBuyProvider(wallet: wallet), - MoonPayBuyProvider(wallet: wallet, ordersSource: ordersSource) + MoonPayBuyProvider(wallet: wallet) ]; items = providerList.map((provider) => BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel)) diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 0fb92a761..d50469d4a 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -3,7 +3,6 @@ import 'package:cake_wallet/buy/buy_provider.dart'; import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; -import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; @@ -19,8 +18,7 @@ class OrderDetailsViewModel = OrderDetailsViewModelBase with _$OrderDetailsViewModel; abstract class OrderDetailsViewModelBase with Store { - OrderDetailsViewModelBase({WalletBase wallet, this.ordersSource, - Order orderForDetails}) { + OrderDetailsViewModelBase({WalletBase wallet, Order orderForDetails}) { order = orderForDetails; if (order.provider != null) { @@ -29,8 +27,7 @@ abstract class OrderDetailsViewModelBase with Store { _provider = WyreBuyProvider(wallet: wallet); break; case BuyProviderDescription.moonPay: - _provider = - MoonPayBuyProvider(wallet: wallet, ordersSource: ordersSource); + _provider = MoonPayBuyProvider(wallet: wallet); break; } } @@ -44,8 +41,6 @@ abstract class OrderDetailsViewModelBase with Store { timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateOrder()); } - final Box ordersSource; - @observable Order order; @@ -61,6 +56,8 @@ abstract class OrderDetailsViewModelBase with Store { try { if (_provider != null) { final updatedOrder = await _provider.findOrderById(order.id); + updatedOrder.from = order.from; + updatedOrder.to = order.to; updatedOrder.receiveAddress = order.receiveAddress; updatedOrder.walletId = order.walletId; if (order.provider != null) { From 7bbd530319b6dd43114695a89ba774b29b2a481e Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 10 May 2021 19:10:33 +0300 Subject: [PATCH 07/42] CAKE-297 | applied subaddress for incoming transaction --- lib/di.dart | 12 ++++++---- lib/monero/monero_transaction_info.dart | 5 +++- lib/monero/monero_wallet.dart | 5 ++++ .../transaction_details_view_model.dart | 24 +++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index 66ac22231..5af42cda0 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -482,10 +482,14 @@ Future setup( getIt .registerFactoryParam( - (TransactionInfo transactionInfo, _) => TransactionDetailsViewModel( - transactionInfo: transactionInfo, - transactionDescriptionBox: _transactionDescriptionBox, - settingsStore: getIt.get())); + (TransactionInfo transactionInfo, _) { + final wallet = getIt.get().wallet; + return TransactionDetailsViewModel( + transactionInfo: transactionInfo, + transactionDescriptionBox: _transactionDescriptionBox, + wallet: wallet, + settingsStore: getIt.get()); + }); getIt.registerFactoryParam( (TransactionInfo transactionInfo, _) => TransactionDetailsPage( diff --git a/lib/monero/monero_transaction_info.dart b/lib/monero/monero_transaction_info.dart index 71bc5957a..e28835fee 100644 --- a/lib/monero/monero_transaction_info.dart +++ b/lib/monero/monero_transaction_info.dart @@ -8,7 +8,7 @@ import 'package:cw_monero/transaction_history.dart'; class MoneroTransactionInfo extends TransactionInfo { MoneroTransactionInfo(this.id, this.height, this.direction, this.date, - this.isPending, this.amount, this.accountIndex, this.fee); + this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee); MoneroTransactionInfo.fromMap(Map map) : id = (map['hash'] ?? '') as String, @@ -21,6 +21,7 @@ class MoneroTransactionInfo extends TransactionInfo { isPending = parseBoolFromString(map['isPending'] as String), amount = map['amount'] as int, accountIndex = int.parse(map['accountIndex'] as String), + addressIndex = map['addressIndex'] as List, key = getTxKey((map['hash'] ?? '') as String), fee = map['fee'] as int ?? 0; @@ -33,6 +34,7 @@ class MoneroTransactionInfo extends TransactionInfo { isPending = row.isPending != 0, amount = row.getAmount(), accountIndex = row.subaddrAccount, + addressIndex = row.getSubaddrIndex(), key = getTxKey(row.getHash()), fee = row.fee; @@ -44,6 +46,7 @@ class MoneroTransactionInfo extends TransactionInfo { final bool isPending; final int amount; final int fee; + final List addressIndex; String recipientAddress; String key; diff --git a/lib/monero/monero_wallet.dart b/lib/monero/monero_wallet.dart index 0891100c8..0c1949037 100644 --- a/lib/monero/monero_wallet.dart +++ b/lib/monero/monero_wallet.dart @@ -262,6 +262,11 @@ abstract class MoneroWalletBase extends WalletBase with Store { await walletInfo.save(); } + String getTransactionAddress(int accountIndex, int addressIndex) => + monero_wallet.getAddress( + accountIndex: accountIndex, + addressIndex: addressIndex); + void _setListeners() { _listener?.stop(); _listener = monero_wallet.setListeners(_onNewBlock, _onNewTransaction); diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index 67822e207..51afb355d 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -1,10 +1,13 @@ import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/entities/transaction_info.dart'; import 'package:cake_wallet/monero/monero_transaction_info.dart'; +import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/blockexplorer_list_item.dart'; +import 'package:cake_wallet/entities/transaction_direction.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:hive/hive.dart'; @@ -22,6 +25,7 @@ abstract class TransactionDetailsViewModelBase with Store { TransactionDetailsViewModelBase( {this.transactionInfo, this.transactionDescriptionBox, + this.wallet, this.settingsStore}) : items = [] { showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false; @@ -56,6 +60,25 @@ abstract class TransactionDetailsViewModelBase with Store { StandartListItem(title: S.current.transaction_key, value: tx.key)); } + if ((tx.direction == TransactionDirection.incoming)&& + (wallet is MoneroWallet)) { + try { + final accountIndex = tx.accountIndex; + final addressIndex = tx.addressIndex; + final _wallet = wallet as MoneroWallet; + + for (var index in addressIndex) { + final address = _wallet.getTransactionAddress(accountIndex, index); + _items.add( + StandartListItem( + title: S.current.transaction_details_recipient_address, + value: address)); + } + } catch (e) { + print(e.toString()); + } + } + items.addAll(_items); } @@ -122,6 +145,7 @@ abstract class TransactionDetailsViewModelBase with Store { final TransactionInfo transactionInfo; final Box transactionDescriptionBox; final SettingsStore settingsStore; + final WalletBase wallet; final List items; bool showRecipientAddress; From 00d554273932aa3811816ce3f554facb66f5c2b8 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 10 May 2021 20:58:05 +0300 Subject: [PATCH 08/42] CAKE-321 | changed resizeToAvoidBottomPadding parameter to resizeToAvoidBottomInset --- lib/src/screens/dashboard/dashboard_page.dart | 2 +- lib/src/screens/exchange/exchange_page.dart | 2 +- lib/src/screens/exchange/exchange_template_page.dart | 2 +- lib/src/screens/receive/receive_page.dart | 3 +++ lib/src/screens/send/send_page.dart | 2 +- lib/src/screens/send/send_template_page.dart | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 172483ed0..ac5045a4f 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -42,7 +42,7 @@ class DashboardPage extends BasePage { child: scaffold); @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override Widget get endDrawer => MenuWidget(walletViewModel); diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 82d7dd80e..3eb23da3a 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -52,7 +52,7 @@ class ExchangePage extends BasePage { Color get titleColor => Colors.white; @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override bool get extendBodyBehindAppBar => true; diff --git a/lib/src/screens/exchange/exchange_template_page.dart b/lib/src/screens/exchange/exchange_template_page.dart index 5437703ce..ba628fe21 100644 --- a/lib/src/screens/exchange/exchange_template_page.dart +++ b/lib/src/screens/exchange/exchange_template_page.dart @@ -37,7 +37,7 @@ class ExchangeTemplatePage extends BasePage { Color get titleColor => Colors.white; @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override bool get extendBodyBehindAppBar => true; diff --git a/lib/src/screens/receive/receive_page.dart b/lib/src/screens/receive/receive_page.dart index 9201b9805..3b0344b1c 100644 --- a/lib/src/screens/receive/receive_page.dart +++ b/lib/src/screens/receive/receive_page.dart @@ -34,6 +34,9 @@ class ReceivePage extends BasePage { @override Color get backgroundDarkColor => Colors.transparent; + @override + bool get resizeToAvoidBottomInset => false; + final FocusNode _cryptoAmountFocus; @override diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 9fae0ec23..eb4153676 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -67,7 +67,7 @@ class SendPage extends BasePage { Color get titleColor => Colors.white; @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override bool get extendBodyBehindAppBar => true; diff --git a/lib/src/screens/send/send_template_page.dart b/lib/src/screens/send/send_template_page.dart index 6d3ac7132..c71b60803 100644 --- a/lib/src/screens/send/send_template_page.dart +++ b/lib/src/screens/send/send_template_page.dart @@ -34,7 +34,7 @@ class SendTemplatePage extends BasePage { Color get titleColor => Colors.white; @override - bool get resizeToAvoidBottomPadding => false; + bool get resizeToAvoidBottomInset => false; @override bool get extendBodyBehindAppBar => true; From 643da68048ddb1dab0b6718050fb711ca1757c10 Mon Sep 17 00:00:00 2001 From: M Date: Wed, 12 May 2021 18:06:39 +0300 Subject: [PATCH 09/42] Minor bug fixes. 4.2.1. --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ .../bitcoin_mnemonic_is_incorrect_exception.dart | 2 +- lib/bitcoin/electrum_transaction_history.dart | 2 +- lib/entities/wallet_type.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 79c69b9ed..27704e6a2 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -362,7 +362,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -379,7 +379,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.0; + MARKETING_VERSION = 4.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -505,7 +505,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -522,7 +522,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.0; + MARKETING_VERSION = 4.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -540,7 +540,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -557,7 +557,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.0; + MARKETING_VERSION = 4.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart b/lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart index 5171a4f05..8d0583ce5 100644 --- a/lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart +++ b/lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart @@ -1,5 +1,5 @@ class BitcoinMnemonicIsIncorrectException implements Exception { @override String toString() => - 'Bitcoin mnemonic has incorrect format. Mnemonic should contain 24 words separated by space.'; + 'Bitcoin mnemonic has incorrect format. Mnemonic should contain 12 or 24 words separated by space.'; } diff --git a/lib/bitcoin/electrum_transaction_history.dart b/lib/bitcoin/electrum_transaction_history.dart index 1d5e894c0..2aabf1304 100644 --- a/lib/bitcoin/electrum_transaction_history.dart +++ b/lib/bitcoin/electrum_transaction_history.dart @@ -35,7 +35,7 @@ abstract class ElectrumTransactionHistoryBase @override void addMany(Map transactions) => - this.transactions.addAll(transactions); + transactions.forEach((_, tx) => _updateOrInsert(tx)); @override Future save() async { diff --git a/lib/entities/wallet_type.dart b/lib/entities/wallet_type.dart index d59f336c0..b8a36e709 100644 --- a/lib/entities/wallet_type.dart +++ b/lib/entities/wallet_type.dart @@ -71,7 +71,7 @@ String walletTypeToDisplayName(WalletType type) { case WalletType.bitcoin: return 'Bitcoin (Electrum)'; case WalletType.litecoin: - return 'Litecoin'; + return 'Litecoin (Electrum)'; default: return ''; } diff --git a/pubspec.yaml b/pubspec.yaml index 27fb93b0d..136cf8610 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Cake Wallet. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 4.2.0+49 +version: 4.2.1+50 environment: sdk: ">=2.7.0 <3.0.0" From 8567f20809d73fd10204a9755c2ae3c2970df0dc Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 12 May 2021 19:34:36 +0300 Subject: [PATCH 10/42] CAKE-297 | fixed addressIndex --- lib/monero/monero_transaction_info.dart | 6 +++--- lib/view_model/transaction_details_view_model.dart | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/monero/monero_transaction_info.dart b/lib/monero/monero_transaction_info.dart index e28835fee..70f14879d 100644 --- a/lib/monero/monero_transaction_info.dart +++ b/lib/monero/monero_transaction_info.dart @@ -21,7 +21,7 @@ class MoneroTransactionInfo extends TransactionInfo { isPending = parseBoolFromString(map['isPending'] as String), amount = map['amount'] as int, accountIndex = int.parse(map['accountIndex'] as String), - addressIndex = map['addressIndex'] as List, + addressIndex = map['addressIndex'] as int, key = getTxKey((map['hash'] ?? '') as String), fee = map['fee'] as int ?? 0; @@ -34,7 +34,7 @@ class MoneroTransactionInfo extends TransactionInfo { isPending = row.isPending != 0, amount = row.getAmount(), accountIndex = row.subaddrAccount, - addressIndex = row.getSubaddrIndex(), + addressIndex = row.subaddrIndex, key = getTxKey(row.getHash()), fee = row.fee; @@ -46,7 +46,7 @@ class MoneroTransactionInfo extends TransactionInfo { final bool isPending; final int amount; final int fee; - final List addressIndex; + final int addressIndex; String recipientAddress; String key; diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index 51afb355d..2ec151a2c 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -66,9 +66,9 @@ abstract class TransactionDetailsViewModelBase with Store { final accountIndex = tx.accountIndex; final addressIndex = tx.addressIndex; final _wallet = wallet as MoneroWallet; - - for (var index in addressIndex) { - final address = _wallet.getTransactionAddress(accountIndex, index); + final address = + _wallet.getTransactionAddress(accountIndex, addressIndex); + if (address?.isNotEmpty ?? false) { _items.add( StandartListItem( title: S.current.transaction_details_recipient_address, From 9da3d837c3cab005c521d44d9cb67a5ef714dba5 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 12 May 2021 19:38:16 +0300 Subject: [PATCH 11/42] CAKE-297 | fixed subaddrIndex in the monero_api.cpp and transaction_info_row.dart --- cw_monero/ios/Classes/monero_api.cpp | 3 +++ cw_monero/lib/structs/transaction_info_row.dart | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cw_monero/ios/Classes/monero_api.cpp b/cw_monero/ios/Classes/monero_api.cpp index d0313a194..e25810502 100644 --- a/cw_monero/ios/Classes/monero_api.cpp +++ b/cw_monero/ios/Classes/monero_api.cpp @@ -134,6 +134,7 @@ extern "C" uint32_t subaddrAccount; int8_t direction; int8_t isPending; + uint32_t subaddrIndex; char *hash; char *paymentId; @@ -146,6 +147,8 @@ extern "C" fee = transaction->fee(); blockHeight = transaction->blockHeight(); subaddrAccount = transaction->subaddrAccount(); + std::set::iterator it = transaction->subaddrIndex().begin(); + subaddrIndex = *it; confirmations = transaction->confirmations(); datetime = static_cast(transaction->timestamp()); direction = transaction->direction(); diff --git a/cw_monero/lib/structs/transaction_info_row.dart b/cw_monero/lib/structs/transaction_info_row.dart index 0a0613a42..37b0d02e8 100644 --- a/cw_monero/lib/structs/transaction_info_row.dart +++ b/cw_monero/lib/structs/transaction_info_row.dart @@ -23,6 +23,9 @@ class TransactionInfoRow extends Struct { @Int8() int isPending; + @Uint32() + int subaddrIndex; + Pointer hash; Pointer paymentId; From 34ee2dd8e63812c93e462cdf388f713195fe7564 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 17 May 2021 21:22:49 +0300 Subject: [PATCH 12/42] CAKE-324 | added website and github links to support page --- assets/images/2.0x/github.png | Bin 0 -> 981 bytes assets/images/3.0x/github.png | Bin 0 -> 1539 bytes assets/images/github.png | Bin 0 -> 507 bytes lib/view_model/support_view_model.dart | 9 +++++++++ pubspec.lock | 6 +++--- pubspec.yaml | 2 +- 6 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 assets/images/2.0x/github.png create mode 100644 assets/images/3.0x/github.png create mode 100644 assets/images/github.png diff --git a/assets/images/2.0x/github.png b/assets/images/2.0x/github.png new file mode 100644 index 0000000000000000000000000000000000000000..e80b428e5149bbb5fbd33821aad08889020dea45 GIT binary patch literal 981 zcmV;`11kK9P);I`wYyamtzvukU%ky@CA;vHyMyyx}VUL#{=F?D9AX%cCCmP#NV!_zt#`k6@2EYPa4@j`xUFtt73s$h57UhVTcJsKftf}GGnnBj!a zIjjp2=YP-BB?Nj7a}+_IVqFUn2g@N}nOd0TBILoiP&%kU`F|#4T40u2!tXqml}iVy z2}!fuS7Zmwa^I&+?3mPqrV914FwZ-mvNEYaO=yBp?+48D)u&9FTJ=k4xKOVc=7}^T zQ4{(s)Z>>h$sHmc<|6`XLOnvgQgRv0Qsq%(B6!tQDHqfd}?XK>OzqlDdF^y-uSQNS1xD zJEfqu7a$}hN&p^Ic^m68`AaElBG)52Jl1e$a|gkRH+E)h2N=!QM6HK`!IC1$wj~Trww-5WFM$4SnCIIfzd)^pklBpV@U3 zcyHOA6yJ%spF4CD;$)^E1@@9(Tn%yW#5tAU9$F;c3eu*w1?I zq;zHq%wg9t{O!o}S}TwhbMABRIrn*<^V}C` z2x1S!!~UZEMB_yNinfckiAE41RTyrHXs+li(HzmN(Z7wew58F07OfL~Bzi~mv1kyx z2{T0xh~9=VMpmsCJtjI8yC{o9{h~jRkHI>%L$pS8rD#v=0$d{c48<7BrH!KHqJ2<9 zW{6%xxd!Xhr=rtQ6UK{f75#^5jn=Ln*dI92Fj@2-;xSme_%uEi5i(o!9pW@vOW%sl zMnudLZAIKhYiU??4I+Sx@2?m;z~@D)MPI?V3S}CH{cRBSik@}+{{mD9pPWM&JFu5K z+A(~(0>f{n%w5Af_63;f-Y0rh^dam~$AD<6r$4$Pzd6SHrRZRk#JzA| z{S7HT=TXrL(P9{5?(J#MM8q`FLec%Ar$iH=;}y8a{4`2{w|3HEzXox#3dz&`Tm+&C zjCsYMKynJoH%+TzyyySC`wNRME`xue{u}-&R|T3h)*UE_^@`4^*g_j-Nm?1?ByE9l zopR+o=!{17ATG{_e(ZN5CB8N8cIerPxcEZ!yRz-o@UMqzj)&Pa(Oj`-5GQoXwV~f4 zezSj7)>hXq)rstOQKH3#QHn*mYPp4behy_063UL2upH;h0IfX;{Gno%crCtjJC#&ooKh}s)CC>OER=c3l%PZ zP2*(~ZtA8^JD1G$qN9~<-$zDxYirj8?zGQAoOHn?TD9kL8!|FAMQ0SJf+kEW6Z&o1 z9lDlILk@h9vQtj)F2n&{ssW@M|BuLNbNZo_9aDp-pc1Hq=`h7QX~(`2Il(fizXArp zj4%tSs|d+%guUQVqi*EL8;(wB(9K9T>?YB*$Z@~Y0X>7IFlG89f#O=2>-!Pij*i-k z2w8shNy4C*etHDv-L1Wl53Ex;ZuE195N@!RGCxgi*iz1{G(V@U4X^qN#Q<68_mb!y zgmIndIk*c3L&S3_WLde&(IJEU&X8+0bc1~oVcd*#M$xEH2mVb*r>qy5)z+>{^gaB8 zy$NB=M|#5~iTfrKQ6Myqs|KULqwOj18*d51n2vl6cM(e9u7m+B=xEElJ>Mt&!O}KM z$@~=LXSByr5)5Hnj%Af5p*GnC9C1MOoXnlxo`$dwWDodTnmeO%{!~%mLmcfG4Qsx4UlQ3 zyJ6Ba?an2C<}{gvFhUJSw`nONf;&Qk@DH5j{KIX(FF+U}hU2nwCL*K@>Ax1EEW@#Y zy6QAnBHU8E5BfsoG7QJCuCy23vcd>s0M#0fU)!+|HH4`nCI^z10kc}Sf?EWyCp_@_aS7nrSbxsmp3X@iU82UF}Z19f00cO!> pQS`eoMr>$kXlQ6?XlQ8g@;@rJG-cns(Xs#l002ovPDHLkV1lV?-PQmA literal 0 HcmV?d00001 diff --git a/assets/images/github.png b/assets/images/github.png new file mode 100644 index 0000000000000000000000000000000000000000..847a269a242cee04d869e807632877991a87021a GIT binary patch literal 507 zcmVVK~#7F<&`@~ z13?gme_tTtvr%dTR-%tldM2{OBPyg6ksOSHjJ z9&u_YuH%jvgQYx9{IqD4R~_*oYRu_ODFmm; zRXd`_p4_PB&u$TWg1d5J-J@$%D`L%XSG{5V*Qg+3EyN()G$Gb+Izu~xcXR=JErx2W zn2gzwahK>qGN}nGhVq9@<~254^Xb&6s^@7F{#1t5Nz9}C>XFv(4!b0kDUpe_3{yoGsQg4MO xILIURxyXrTf1LN!A%;-_sS!8*Wenio>KDkvo5-G#DXRbg002ovPDHLkV1j&q+57+i literal 0 HcmV?d00001 diff --git a/lib/view_model/support_view_model.dart b/lib/view_model/support_view_model.dart index 1f80f476d..08044232e 100644 --- a/lib/view_model/support_view_model.dart +++ b/lib/view_model/support_view_model.dart @@ -24,6 +24,15 @@ abstract class SupportViewModelBase with Store { title: 'Email', linkTitle: 'support@cakewallet.com', link: 'mailto:support@cakewallet.com'), + LinkListItem( + title: 'Website', + linkTitle: 'cakewallet.com', + link: 'https://cakewallet.com'), + LinkListItem( + title: 'GitHub', + icon: 'assets/images/github.png', + linkTitle: 'APK update', + link: 'https://github.com/cake-tech/cake_wallet/releases'), LinkListItem( title: 'Telegram', icon: 'assets/images/Telegram.png', diff --git a/pubspec.lock b/pubspec.lock index 3ff596074..207f4b18a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,7 +70,7 @@ packages: path: "." ref: cake resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2" - url: "git@github.com:cake-tech/bech32.git" + url: "https://github.com/cake-tech/bech32.git" source: git version: "0.2.0" bip32: @@ -92,8 +92,8 @@ packages: description: path: "." ref: cake - resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7 - url: "git@github.com:cake-tech/bitcoin_flutter.git" + resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188 + url: "https://github.com/cake-tech/bitcoin_flutter.git" source: git version: "2.0.2" boolean_selector: diff --git a/pubspec.yaml b/pubspec.yaml index 27fb93b0d..4d1b63ceb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,7 +67,7 @@ dependencies: basic_utils: ^2.0.3 bitcoin_flutter: git: - url: git@github.com:cake-tech/bitcoin_flutter.git + url: https://github.com/cake-tech/bitcoin_flutter.git ref: cake get_it: ^6.0.0 connectivity: ^3.0.3 From 66e22c2d07bbcecc2853eee0bb28ab67974faf91 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 18 May 2021 19:14:42 +0300 Subject: [PATCH 13/42] CAKE-324 | fixed localization --- lib/view_model/support_view_model.dart | 2 +- res/values/strings_de.arb | 6 ++++-- res/values/strings_en.arb | 4 +++- res/values/strings_es.arb | 6 ++++-- res/values/strings_hi.arb | 6 ++++-- res/values/strings_hr.arb | 8 +++++--- res/values/strings_it.arb | 8 +++++--- res/values/strings_ja.arb | 6 ++++-- res/values/strings_ko.arb | 6 ++++-- res/values/strings_nl.arb | 6 ++++-- res/values/strings_pl.arb | 6 ++++-- res/values/strings_pt.arb | 6 ++++-- res/values/strings_ru.arb | 6 ++++-- res/values/strings_uk.arb | 6 ++++-- res/values/strings_zh.arb | 6 ++++-- 15 files changed, 58 insertions(+), 30 deletions(-) diff --git a/lib/view_model/support_view_model.dart b/lib/view_model/support_view_model.dart index 08044232e..1937b90ff 100644 --- a/lib/view_model/support_view_model.dart +++ b/lib/view_model/support_view_model.dart @@ -31,7 +31,7 @@ abstract class SupportViewModelBase with Store { LinkListItem( title: 'GitHub', icon: 'assets/images/github.png', - linkTitle: 'APK update', + linkTitle: S.current.apk_update, link: 'https://github.com/cake-tech/cake_wallet/releases'), LinkListItem( title: 'Telegram', diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 27c705d97..ed3520d17 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", + "understand" : "Ich verstehe", + + "apk_update" : "APK Update" } \ No newline at end of file diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 78ab7ec06..65dee6dbe 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -474,5 +474,7 @@ "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "understand" : "I understand", + + "apk_update" : "APK update" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 98ece5ce7..983146557 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Las nuevas carteras de Bitcoin creadas en Cake ahora tienen una semilla de 24 palabras. Es obligatorio que cree una nueva billetera de Bitcoin y transfiera todos sus fondos a la nueva billetera de 24 palabras, y deje de usar billeteras con una semilla de 12 palabras. Haga esto de inmediato para asegurar sus fondos.", + "understand" : "Entiendo", + + "apk_update" : "Actualización de APK" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 4f14f2a1a..889f21c3f 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "केक में बनाए गए नए बिटकॉइन वॉलेट में अब 24-शब्द का बीज है। यह अनिवार्य है कि आप एक नया बिटकॉइन वॉलेट बनाएं और अपने सभी फंड को नए 24-शब्द वाले वॉलेट में स्थानांतरित करें, और 12-शब्द बीज वाले वॉलेट का उपयोग करना बंद करें। कृपया अपने धन को सुरक्षित करने के लिए इसे तुरंत करें।", + "understand" : "मुझे समझ", + + "apk_update" : "APK अद्यतन" } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index d449fca1b..681917b03 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -471,8 +471,10 @@ "submit_request" : "podnesi zahtjev", - "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", + "buy_alert_content" : "Trenutno podržavamo samo kupnju Bitcoina. Da biste kupili Bitcoin, izradite ili prijeđite na svoj Bitcoin novčanik", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Novi Bitcoin novčanici stvoreni u Cakeu sada imaju sjeme od 24 riječi. Obavezno je stvoriti novi Bitcoin novčanik i prenijeti sva svoja sredstva u novi novčanik od 24 riječi te prestati koristiti novčanike s sjemenkom od 12 riječi. Učinite to odmah kako biste osigurali svoja sredstva.", + "understand" : "Razumijem", + + "apk_update" : "APK ažuriranje" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index e8c4da26d..1b10a0137 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -471,8 +471,10 @@ "submit_request" : "invia una richiesta", - "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", + "buy_alert_content" : "Attualmente supportiamo solo l'acquisto di Bitcoin. Per acquistare Bitcoin, crea o passa al tuo portafoglio Bitcoin", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "I nuovi portafogli Bitcoin creati in Cake ora hanno un seme di 24 parole. È obbligatorio creare un nuovo portafoglio Bitcoin e trasferire tutti i fondi nel nuovo portafoglio di 24 parole e smettere di usare portafogli con un seme di 12 parole. Ti preghiamo di farlo immediatamente per proteggere i tuoi fondi.", + "understand" : "Capisco", + + "apk_update" : "Aggiornamento APK" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 797cfe2c2..7d78e9313 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Cakeで作成された新しいビットコインウォレットには、24ワードのシードがあります。 新しいビットコインウォレットを作成し、すべての資金を新しい24ワードのウォレットに転送し、12ワードのシードを持つウォレットの使用を停止することが必須です。 あなたの資金を確保するためにこれをすぐに行ってください。", + "understand" : "わかります", + + "apk_update" : "APKアップデート" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index fddff1af5..3a10232a9 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Cake에서 생성 된 새로운 비트 코인 지갑에는 이제 24 단어 시드가 있습니다. 새로운 비트 코인 지갑을 생성하고 모든 자금을 새로운 24 단어 지갑으로 이체하고 12 단어 시드가있는 지갑 사용을 중지해야합니다. 자금을 확보하려면 즉시이 작업을 수행하십시오.", + "understand" : "이해 했어요", + + "apk_update" : "APK 업데이트" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 8d4b4bf1c..76b084428 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin. Om Bitcoin te kopen, moet u uw Bitcoin-portemonnee aanmaken of naar uw Bitcoin-portemonnee overschakelen", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Nieuwe Bitcoin-portefeuilles die in Cake zijn gemaakt, hebben nu een zaadje van 24 woorden. Het is verplicht dat u een nieuwe Bitcoin-portemonnee maakt en al uw geld overmaakt naar de nieuwe portemonnee van 24 woorden, en stopt met het gebruik van wallets met een seed van 12 woorden. Doe dit onmiddellijk om uw geld veilig te stellen.", + "understand" : "Ik begrijp het", + + "apk_update" : "APK-update" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index fca8328fc..5522713d7 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoinów. Aby kupić Bitcoin, utwórz lub przełącz się na swój portfel Bitcoin", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Nowe portfele Bitcoin utworzone w Cake mają teraz ziarno składające się z 24 słów. Konieczne jest utworzenie nowego portfela Bitcoin i przeniesienie wszystkich środków do nowego portfela na 24 słowa oraz zaprzestanie korzystania z portfeli z zalążkiem na 12 słów. Zrób to natychmiast, aby zabezpieczyć swoje fundusze.", + "understand" : "Rozumiem", + + "apk_update" : "Aktualizacja APK" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 8aa08e69c..c5c976113 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin. Para comprar Bitcoin, crie ou mude para sua carteira Bitcoin", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "As novas carteiras Bitcoin criadas no Cake agora têm uma semente de 24 palavras. É obrigatório que você crie uma nova carteira Bitcoin e transfira todos os seus fundos para a nova carteira de 24 palavras, e pare de usar carteiras com semente de 12 palavras. Faça isso imediatamente para garantir seus fundos.", + "understand" : "Entendo", + + "apk_update" : "Atualização de APK" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 4fe26f13c..1377b4fc0 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Новые биткойн-кошельки, созданные в Cake, теперь содержат мнемоническую фразу из 24 слов. Вы обязательно должны создать новый биткойн-кошелек и перевести все свои средства в новый кошелек из 24 слов, а также прекратить использование кошельков с мнемонической фразой из 12 слов. Пожалуйста, сделайте это немедленно, чтобы обезопасить свои средства.", + "understand" : "Понятно", + + "apk_update" : "Обновление APK" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 69d02a27e..e0c1fcc55 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -473,6 +473,8 @@ "buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "Нові біткойн-гаманці, створені в Cake, тепер містять мнемонічну фразу з 24 слів. Обов’язково стовріть новий біткойн-гаманець, переведіть всі кошти на новий гаманець із 24 слів і припиніть використання гаманців із мнемонічною фразою з 12 слів. Зробіть це негайно, щоб убезпечити свої кошти.", + "understand" : "Зрозуміло", + + "apk_update" : "Оновлення APK" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index e0a96561c..ddb1efda3 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -470,6 +470,8 @@ "submit_request" : "提交请求", "buy_alert_content" : "目前,我們僅支持購買比特幣。 要購買比特幣,請創建或切換到您的比特幣錢包", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "outdated_electrum_wallet_desceription" : "在Cake中創建的新比特幣錢包現在有一個24字的種子。 必須創建一個新的比特幣錢包,然後將所有資金轉移到新的24字錢包,並停止使用帶有12字種子的錢包。 請立即執行此操作以確保您的資金安全。", + "understand" : "我明白", + + "apk_update" : "APK更新" } \ No newline at end of file From 9ad276622fff62b8a4947f1a28b566c5c416b83b Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 18 May 2021 19:37:43 +0300 Subject: [PATCH 14/42] CAKE-297 | merged main branch into current --- lib/view_model/transaction_details_view_model.dart | 1 - pubspec.lock | 6 +++--- pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index 285a54607..49748f7f0 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/electrum_transaction_info.dart'; -//import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart'; import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/entities/transaction_info.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; diff --git a/pubspec.lock b/pubspec.lock index 3ff596074..207f4b18a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,7 +70,7 @@ packages: path: "." ref: cake resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2" - url: "git@github.com:cake-tech/bech32.git" + url: "https://github.com/cake-tech/bech32.git" source: git version: "0.2.0" bip32: @@ -92,8 +92,8 @@ packages: description: path: "." ref: cake - resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7 - url: "git@github.com:cake-tech/bitcoin_flutter.git" + resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188 + url: "https://github.com/cake-tech/bitcoin_flutter.git" source: git version: "2.0.2" boolean_selector: diff --git a/pubspec.yaml b/pubspec.yaml index 27fb93b0d..4d1b63ceb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,7 +67,7 @@ dependencies: basic_utils: ^2.0.3 bitcoin_flutter: git: - url: git@github.com:cake-tech/bitcoin_flutter.git + url: https://github.com/cake-tech/bitcoin_flutter.git ref: cake get_it: ^6.0.0 connectivity: ^3.0.3 From bb92fb3288bbf4b5b6d55e99b896e88454fb8aee Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Fri, 28 May 2021 17:58:10 +0300 Subject: [PATCH 15/42] CAKE-306 | merged main branch into current and resolved problems --- pubspec.lock | 6 +++--- pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 3ff596074..207f4b18a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,7 +70,7 @@ packages: path: "." ref: cake resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2" - url: "git@github.com:cake-tech/bech32.git" + url: "https://github.com/cake-tech/bech32.git" source: git version: "0.2.0" bip32: @@ -92,8 +92,8 @@ packages: description: path: "." ref: cake - resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7 - url: "git@github.com:cake-tech/bitcoin_flutter.git" + resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188 + url: "https://github.com/cake-tech/bitcoin_flutter.git" source: git version: "2.0.2" boolean_selector: diff --git a/pubspec.yaml b/pubspec.yaml index 4d1b63ceb..cf4cf4bfe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -151,4 +151,4 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages + # see https://flutter.dev/custom-fonts/#from-packages \ No newline at end of file From 9e1c151f85ce2d1d9b48fd1c40ac0057891b3b45 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 1 Jun 2021 21:03:35 +0300 Subject: [PATCH 16/42] CAKE-306 | fixed moonpay_buy_provider.dart; added onEnabled() method to moonpay_buy_provider.dart; checked is MoonPayBuyProvider enabled; added isMoonPayEnabled to settings_store.dart --- lib/buy/buy_amount.dart | 6 +- lib/buy/moonpay/moonpay_buy_provider.dart | 67 ++++++++++++++++++----- lib/di.dart | 13 ++++- lib/src/screens/buy/pre_order_page.dart | 46 +++++++++++++--- lib/store/settings_store.dart | 17 ++++++ lib/view_model/buy/buy_view_model.dart | 16 ++++-- 6 files changed, 135 insertions(+), 30 deletions(-) diff --git a/lib/buy/buy_amount.dart b/lib/buy/buy_amount.dart index d049c1e03..3cf3543d8 100644 --- a/lib/buy/buy_amount.dart +++ b/lib/buy/buy_amount.dart @@ -1,8 +1,12 @@ import 'package:flutter/foundation.dart'; class BuyAmount { - BuyAmount({@required this.sourceAmount, @required this.destAmount}); + BuyAmount({ + @required this.sourceAmount, + @required this.destAmount, + this.minAmount = 0}); final double sourceAmount; final double destAmount; + final int minAmount; } \ No newline at end of file diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index eef0e941f..22b349c79 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:crypto/crypto.dart'; import 'package:cake_wallet/buy/buy_exception.dart'; import 'package:http/http.dart'; import 'package:cake_wallet/buy/buy_amount.dart'; @@ -13,17 +14,18 @@ import 'package:cake_wallet/.secrets.g.dart' as secrets; class MoonPayBuyProvider extends BuyProvider { MoonPayBuyProvider({WalletBase wallet, bool isTestEnvironment = false}) : super(wallet: wallet, isTestEnvironment: isTestEnvironment) { - baseApiUrl = isTestEnvironment - ? _baseTestApiUrl - : _baseProductApiUrl; + baseUrl = isTestEnvironment ? _baseTestUrl : _baseProductUrl; } - static const _baseTestApiUrl = 'https://buy-staging.moonpay.com'; - static const _baseProductApiUrl = 'https://api.moonpay.com'; + static const _baseTestUrl = 'https://buy-staging.moonpay.com'; + static const _baseProductUrl = 'https://buy.moonpay.com'; + static const _apiUrl = 'https://api.moonpay.com'; static const _currenciesSuffix = '/v3/currencies'; static const _quoteSuffix = '/buy_quote'; static const _transactionsSuffix = '/v1/transactions'; + static const _countrySuffix = '/v3/countries'; static const _apiKey = secrets.moonPayApiKey; + static const _secretKey = secrets.moonPaySecretKey; @override String get title => 'MoonPay'; @@ -35,9 +37,9 @@ class MoonPayBuyProvider extends BuyProvider { walletTypeToCryptoCurrency(walletType).title.toLowerCase(); @override - String get trackUrl => baseApiUrl + '/transaction_receipt?transactionId='; + String get trackUrl => baseUrl + '/transaction_receipt?transactionId='; - String baseApiUrl; + String baseUrl; @override Future requestUrl(String amount, String sourceCurrency) async { @@ -45,22 +47,32 @@ class MoonPayBuyProvider extends BuyProvider { 'credit_debit_card%2Capple_pay%2Cgoogle_pay%2Csamsung_pay' '%2Csepa_bank_transfer%2Cgbp_bank_transfer%2Cgbp_open_banking_payment'; - final originalUrl = baseApiUrl + '?apiKey=' + _apiKey + '¤cyCode=' + + final suffix = '?apiKey=' + _apiKey + '¤cyCode=' + currencyCode + '&enabledPaymentMethods=' + enabledPaymentMethods + '&walletAddress=' + walletAddress + '&baseCurrencyCode=' + sourceCurrency.toLowerCase() + '&baseCurrencyAmount=' + amount + '&lockAmount=true' + '&showAllCurrencies=false' + '&showWalletAddressForm=false'; - return originalUrl; + final originalUrl = baseUrl + suffix; + + final messageBytes = utf8.encode(suffix); + final key = utf8.encode(_secretKey); + final hmac = Hmac(sha256, key); + final digest = hmac.convert(messageBytes); + final signature = base64.encode(digest.bytes); + final urlWithSignature = originalUrl + + '&signature=${Uri.encodeComponent(signature)}'; + + return isTestEnvironment ? originalUrl : urlWithSignature; } @override Future calculateAmount(String amount, String sourceCurrency) async { - final url = _baseProductApiUrl + _currenciesSuffix + '/$currencyCode' + + final url = _apiUrl + _currenciesSuffix + '/$currencyCode' + _quoteSuffix + '/?apiKey=' + _apiKey + '&baseCurrencyAmount=' + amount + - '&baseCurrencyCode' + sourceCurrency.toLowerCase(); + '&baseCurrencyCode=' + sourceCurrency.toLowerCase(); final response = await get(url); @@ -73,13 +85,17 @@ class MoonPayBuyProvider extends BuyProvider { final responseJSON = json.decode(response.body) as Map; final sourceAmount = responseJSON['totalAmount'] as double; final destAmount = responseJSON['quoteCurrencyAmount'] as double; + final minSourceAmount = responseJSON['baseCurrency']['minAmount'] as int; - return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount); + return BuyAmount( + sourceAmount: sourceAmount, + destAmount: destAmount, + minAmount: minSourceAmount); } @override Future findOrderById(String id) async { - final url = _baseProductApiUrl + _transactionsSuffix + '/$id' + + final url = _apiUrl + _transactionsSuffix + '/$id' + '?apiKey=' + _apiKey; final response = await get(url); @@ -108,4 +124,29 @@ class MoonPayBuyProvider extends BuyProvider { walletId: walletId ); } + + static Future onEnabled(String deviceCountryCode) async { + final url = _apiUrl + _countrySuffix; + var isBuyEnable = false; + + final response = await get(url); + + try { + final responseJSON = json.decode(response.body) as List; + + for (var element in responseJSON) { + final countryMap = element as Map; + final countryCode = countryMap['alpha2'] as String; + if (countryCode == deviceCountryCode) { + isBuyEnable = countryMap['isBuyAllowed'] as bool; + break; + } + } + } catch (e) { + isBuyEnable = false; + print(e.toString()); + } + + return isBuyEnable; + } } \ No newline at end of file diff --git a/lib/di.dart b/lib/di.dart index 675366209..c00cb129e 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart'; import 'package:cake_wallet/bitcoin/litecoin_wallet_service.dart'; +import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; import 'package:cake_wallet/core/backup_service.dart'; import 'package:cake_wallet/core/wallet_service.dart'; import 'package:cake_wallet/entities/biometric_auth.dart'; @@ -91,6 +92,7 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart'; import 'package:cake_wallet/view_model/wallet_restore_view_model.dart'; import 'package:cake_wallet/view_model/wallet_seed_view_model.dart'; import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart'; +import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/widgets.dart'; import 'package:get_it/get_it.dart'; import 'package:hive/hive.dart'; @@ -152,8 +154,14 @@ Future setup( final isBitcoinBuyEnabled = (secrets.wyreSecretKey?.isNotEmpty ?? false) && (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); + + final locale = await Devicelocale.currentLocale; + final deviceCountryCode = locale.split('_').last; + final isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + final settingsStore = await SettingsStoreBase.load( - nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled); + nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, + isMoonPayEnabled: isMoonPayEnabled); if (_isSetupFinished) { return; @@ -541,7 +549,8 @@ Future setup( final wallet = getIt.get().wallet; return BuyViewModel(_ordersSource, getIt.get(), - getIt.get(), wallet: wallet); + getIt.get(), getIt.get(), + wallet: wallet); }); getIt.registerFactory(() { diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index dbe03b07e..dd4832cc1 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -1,7 +1,11 @@ import 'dart:ui'; import 'package:cake_wallet/buy/buy_amount.dart'; +import 'package:cake_wallet/buy/buy_provider.dart'; +import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; import 'package:cake_wallet/src/screens/buy/widgets/buy_list_item.dart'; +import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; +import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/buy/buy_view_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -172,13 +176,16 @@ class PreOrderPage extends BasePage { builder: (context, AsyncSnapshot snapshot) { double sourceAmount; double destAmount; + int minAmount; if (snapshot.hasData) { sourceAmount = snapshot.data.sourceAmount; destAmount = snapshot.data.destAmount; + minAmount = snapshot.data.minAmount; } else { sourceAmount = 0.0; destAmount = 0.0; + minAmount = 0; } return Padding( @@ -192,14 +199,15 @@ class PreOrderPage extends BasePage { sourceCurrency: buyViewModel.fiatCurrency, destAmount: destAmount, destCurrency: buyViewModel.cryptoCurrency, - onTap: - buyViewModel.buyAmountViewModel - .doubleAmount == 0.0 ? null : () { - buyViewModel.selectedProvider = item.provider; - sourceAmount > 0 - ? buyViewModel.isDisabled = false - : buyViewModel.isDisabled = true; - } + onTap: ((buyViewModel.buyAmountViewModel + .doubleAmount != 0.0) && + (snapshot.hasData)) ? () => + onSelectBuyProvider( + context: context, + provider: item.provider, + sourceAmount: sourceAmount, + minAmount: minAmount + ) : null ); }) ); @@ -242,4 +250,26 @@ class PreOrderPage extends BasePage { ) ); } + + void onSelectBuyProvider({BuildContext context, BuyProvider provider, + double sourceAmount, int minAmount}) { + + if ((provider is MoonPayBuyProvider)&& + (buyViewModel.buyAmountViewModel.doubleAmount < minAmount)) { + showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: 'MoonPay', + alertContent: 'Value of the amount must be more than $minAmount ${buyViewModel.fiatCurrency.toString()}', + buttonText: S.of(context).ok, + buttonAction: () => Navigator.of(context).pop()); + }); + return; + } + buyViewModel.selectedProvider = provider; + sourceAmount > 0 + ? buyViewModel.isDisabled = false + : buyViewModel.isDisabled = true; + } } \ No newline at end of file diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index da2410378..2b26b2dd8 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/bitcoin/bitcoin_transaction_priority.dart'; +import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/entities/transaction_priority.dart'; import 'package:cake_wallet/themes/theme_base.dart'; @@ -18,6 +19,7 @@ import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/node.dart'; import 'package:cake_wallet/entities/monero_transaction_priority.dart'; import 'package:cake_wallet/entities/action_list_display_mode.dart'; +import 'package:cake_wallet/.secrets.g.dart' as secrets; part 'settings_store.g.dart'; @@ -39,6 +41,7 @@ abstract class SettingsStoreBase with Store { @required TransactionPriority initialBitcoinTransactionPriority, @required TransactionPriority initialMoneroTransactionPriority, @required this.isBitcoinBuyEnabled, + @required this.isMoonPayEnabled, this.actionlistDisplayMode}) { fiatCurrency = initialFiatCurrency; balanceDisplayMode = initialBalanceDisplayMode; @@ -147,9 +150,12 @@ abstract class SettingsStoreBase with Store { bool isBitcoinBuyEnabled; + bool isMoonPayEnabled; + static Future load( {@required Box nodeSource, @required bool isBitcoinBuyEnabled, + @required bool isMoonPayEnabled, FiatCurrency initialFiatCurrency = FiatCurrency.usd, MoneroTransactionPriority initialMoneroTransactionPriority = MoneroTransactionPriority.slow, @@ -221,6 +227,7 @@ abstract class SettingsStoreBase with Store { }, appVersion: packageInfo.version, isBitcoinBuyEnabled: isBitcoinBuyEnabled, + isMoonPayEnabled: isMoonPayEnabled, initialFiatCurrency: currentFiatCurrency, initialBalanceDisplayMode: currentBalanceDisplayMode, initialSaveRecipientAddress: shouldSaveRecipientAddress, @@ -242,8 +249,18 @@ abstract class SettingsStoreBase with Store { BitcoinTransactionPriority.medium, BalanceDisplayMode initialBalanceDisplayMode = BalanceDisplayMode.availableBalance}) async { + final isBitcoinBuyEnabled = (secrets.wyreSecretKey?.isNotEmpty ?? false) && + (secrets.wyreApiKey?.isNotEmpty ?? false) && + (secrets.wyreAccountId?.isNotEmpty ?? false); + + final locale = await Devicelocale.currentLocale; + final deviceCountryCode = locale.split('_').last; + final isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + final settings = await SettingsStoreBase.load( nodeSource: nodeSource, + isBitcoinBuyEnabled: isBitcoinBuyEnabled, + isMoonPayEnabled: isMoonPayEnabled, initialBalanceDisplayMode: initialBalanceDisplayMode, initialFiatCurrency: initialFiatCurrency, initialMoneroTransactionPriority: initialMoneroTransactionPriority, diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 90dbd6cfa..68afb9577 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -4,6 +4,7 @@ import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart'; import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; +import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/buy/buy_item.dart'; import 'package:flutter/foundation.dart'; import 'package:hive/hive.dart'; @@ -18,12 +19,14 @@ part 'buy_view_model.g.dart'; class BuyViewModel = BuyViewModelBase with _$BuyViewModel; abstract class BuyViewModelBase with Store { - BuyViewModelBase(this.ordersSource, this.ordersStore, this.buyAmountViewModel, - {@required this.wallet}) { - providerList = [ - WyreBuyProvider(wallet: wallet), - MoonPayBuyProvider(wallet: wallet) - ]; + BuyViewModelBase(this.ordersSource, this.ordersStore, this.settingsStore, + this.buyAmountViewModel, {@required this.wallet}) { + providerList = [WyreBuyProvider(wallet: wallet)]; + + if (settingsStore.isMoonPayEnabled ?? false) { + providerList.add(MoonPayBuyProvider(wallet: wallet)); + } + items = providerList.map((provider) => BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel)) .toList(); @@ -34,6 +37,7 @@ abstract class BuyViewModelBase with Store { final Box ordersSource; final OrdersStore ordersStore; + final SettingsStore settingsStore; final BuyAmountViewModel buyAmountViewModel; final WalletBase wallet; From 1bf6ef607765272239b8839b7f4191ad879a2ec9 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 09:56:06 +0300 Subject: [PATCH 17/42] CAKE-306 | applied localization to MoonPay alert --- lib/src/screens/buy/pre_order_page.dart | 4 +++- res/values/strings_de.arb | 3 ++- res/values/strings_en.arb | 3 ++- res/values/strings_es.arb | 3 ++- res/values/strings_hi.arb | 3 ++- res/values/strings_hr.arb | 3 ++- res/values/strings_it.arb | 3 ++- res/values/strings_ja.arb | 3 ++- res/values/strings_ko.arb | 3 ++- res/values/strings_nl.arb | 3 ++- res/values/strings_pl.arb | 3 ++- res/values/strings_pt.arb | 3 ++- res/values/strings_ru.arb | 3 ++- res/values/strings_uk.arb | 3 ++- res/values/strings_zh.arb | 3 ++- 15 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index dd4832cc1..39728c058 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -261,7 +261,9 @@ class PreOrderPage extends BasePage { builder: (BuildContext context) { return AlertWithOneAction( alertTitle: 'MoonPay', - alertContent: 'Value of the amount must be more than $minAmount ${buyViewModel.fiatCurrency.toString()}', + alertContent: S.of(context).moonpay_alert_text( + minAmount.toString(), + buyViewModel.fiatCurrency.toString()), buttonText: S.of(context).ok, buttonAction: () => Navigator.of(context).pop()); }); diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 6d689104f..d5b8a1a8d 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Bitcoin kaufen", - "buy_with" : "Kaufen mit" + "buy_with" : "Kaufen mit", + "moonpay_alert_text" : "Der Wert des Betrags muss größer oder gleich sein ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 2c4c2e28f..f2a045708 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Buy Bitcoin", - "buy_with" : "Buy with" + "buy_with" : "Buy with", + "moonpay_alert_text" : "Value of the amount must be more or equal to ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 2e07285db..5fc627bcd 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Comprar Bitcoin", - "buy_with" : "Compra con" + "buy_with" : "Compra con", + "moonpay_alert_text" : "El valor de la cantidad debe ser mayor o igual a ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 2430f2bce..7b2af2856 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "बिटकॉइन खरीदें", - "buy_with" : "के साथ खरीदें" + "buy_with" : "के साथ खरीदें", + "moonpay_alert_text" : "राशि का मूल्य अधिक है या करने के लिए बराबर होना चाहिए ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index d449fca1b..d0bce1c55 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -474,5 +474,6 @@ "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "understand" : "I understand", + "moonpay_alert_text" : "Vrijednost iznosa mora biti veća ili jednaka ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index e8c4da26d..6d54c2b78 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -474,5 +474,6 @@ "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", - "understand" : "I understand" + "understand" : "I understand", + "moonpay_alert_text" : "Il valore dell'importo deve essere maggiore o uguale a ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 1eeb07c27..bb1189653 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "ビットコインを購入する", - "buy_with" : "で購入" + "buy_with" : "で購入", + "moonpay_alert_text" : "金額の値は以上でなければなりません ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 91fd84b90..0774fe4de 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "비트 코인 구매", - "buy_with" : "구매" + "buy_with" : "구매", + "moonpay_alert_text" : "금액은 다음보다 크거나 같아야합니다 ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 653078810..82f9ec961 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Koop Bitcoin", - "buy_with" : "Koop met" + "buy_with" : "Koop met", + "moonpay_alert_text" : "Waarde van het bedrag moet meer of gelijk zijn aan ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 7b299afbf..dbef4aab6 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Kup Bitcoin", - "buy_with" : "Kup za pomocą" + "buy_with" : "Kup za pomocą", + "moonpay_alert_text" : "Wartość kwoty musi być większa lub równa ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index cc0d22ed2..270b02909 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Compre Bitcoin", - "buy_with" : "Compre com" + "buy_with" : "Compre com", + "moonpay_alert_text" : "O valor do montante deve ser maior ou igual a ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 63831b3d0..f29625aec 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Купить Bitcoin", - "buy_with" : "Купить с помощью" + "buy_with" : "Купить с помощью", + "moonpay_alert_text" : "Сумма должна быть больше или равна ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 879b52102..b101f81cd 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -477,5 +477,6 @@ "understand" : "I understand", "buy_bitcoin" : "Купити Bitcoin", - "buy_with" : "Купити за допомогою" + "buy_with" : "Купити за допомогою", + "moonpay_alert_text" : "Значення суми має бути більшим або дорівнювати ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 674a1ec48..9363e621c 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -474,5 +474,6 @@ "understand" : "I understand", "buy_bitcoin" : "購買比特幣", - "buy_with" : "與一起購買" + "buy_with" : "與一起購買", + "moonpay_alert_text" : "金額的價值必須大於或等於 ${minAmount} ${fiatCurrency}" } \ No newline at end of file From c8debf46efe52a6fc5246561ad021fc2b1149580 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 10:03:14 +0300 Subject: [PATCH 18/42] CAKE-306 | fixed pre_order_page.dart --- lib/src/screens/buy/pre_order_page.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 39728c058..1385ba3e5 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -199,9 +199,8 @@ class PreOrderPage extends BasePage { sourceCurrency: buyViewModel.fiatCurrency, destAmount: destAmount, destCurrency: buyViewModel.cryptoCurrency, - onTap: ((buyViewModel.buyAmountViewModel - .doubleAmount != 0.0) && - (snapshot.hasData)) ? () => + onTap: ((buyViewModel.doubleAmount != 0.0) + && (snapshot.hasData)) ? () => onSelectBuyProvider( context: context, provider: item.provider, From 6950ec54607c83bf56480f7505f4788542d4d195 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 10:27:28 +0300 Subject: [PATCH 19/42] CAKE-306 | merged main branch into current --- lib/src/screens/buy/pre_order_page.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 1385ba3e5..66aecfb2b 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -171,7 +171,8 @@ class PreOrderPage extends BasePage { ), if (buyViewModel.isShowProviderButtons) ...buyViewModel.items.map( - (item) => Observer(builder: (_) => FutureBuilder( + (item) => Observer(builder: (_) => + FutureBuilder( future: item.buyAmount, builder: (context, AsyncSnapshot snapshot) { double sourceAmount; @@ -193,7 +194,8 @@ class PreOrderPage extends BasePage { EdgeInsets.only(left: 15, top: 20, right: 15), child: Observer(builder: (_) { return BuyListItem( - selectedProvider: buyViewModel.selectedProvider, + selectedProvider: + buyViewModel.selectedProvider, provider: item.provider, sourceAmount: sourceAmount, sourceCurrency: buyViewModel.fiatCurrency, From 087579410e35094680d27372fad02bca09604b7d Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 12:28:18 +0300 Subject: [PATCH 20/42] CAKE-306 | increased width of the amount text field in the pre_order_page.dart --- lib/src/screens/buy/pre_order_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 66aecfb2b..ebda2dc8a 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -114,7 +114,7 @@ class PreOrderPage extends BasePage { padding: EdgeInsets.only(top: 100, bottom: 65), child: Center( child: Container( - width: 165, + width: 185, child: BaseTextFormField( focusNode: _amountFocus, controller: _amountController, From 7be3288d5322eaf66022478420f4109723961435 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 12:45:29 +0300 Subject: [PATCH 21/42] CAKE-324 | merged main branch into current --- res/values/strings_zh.arb | 1 + 1 file changed, 1 insertion(+) diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 61e6ed893..5faa8c840 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -468,6 +468,7 @@ "confirmed" : "已确认", "unconfirmed" : "未经证实", "displayable" : "可显示", + "submit_request" : "提交请求", "buy_alert_content" : "目前,我们仅支持购买比特币。要购买比特币,请创建或切换到您的比特币钱包", From 90d53c9f6e1393c827176e4fbaac32f036489b3c Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 16:52:58 +0300 Subject: [PATCH 22/42] CAKE-306 | fixed MoonPay icon for buy_list_item.dart and order_row.dart --- assets/images/moonpay-icon.png | Bin 2015 -> 1381 bytes lib/buy/get_buy_provider_icon.dart | 14 ++++++++--- lib/di.dart | 12 ++++++--- lib/src/screens/buy/pre_order_page.dart | 2 +- .../screens/buy/widgets/buy_list_item.dart | 23 ++++++++---------- .../screens/dashboard/widgets/order_row.dart | 9 ++++++- lib/store/settings_store.dart | 12 ++++++--- 7 files changed, 47 insertions(+), 25 deletions(-) diff --git a/assets/images/moonpay-icon.png b/assets/images/moonpay-icon.png index 1fbc2b6fc67fbb9ceab8b7134328fe7416db7980..3c0260108f3a8593b1d87f89a552499980d5ea2d 100644 GIT binary patch delta 873 zcmV-v1D5>X59JCWiBL{Q4GJ0x0000DNk~Le0000Y0000a2nGNE0PG&<-;p7a2}l3{ z0096107#L$9V#NA0{{d700031001Na0001f06F&n000SaNLh0L01FcU01FcV0GgZ_ zvjPEU0e=GKNklf7d&~_OT?3?cMpOW z6?_4Gg`7nZ6kkAzkw8$6t6W|g!wimUMIVn619)Ta= zH`oOCl7U?fhmJ*`9kAITD$QINVFS$(;B}pB7v~% z!f0YfU|>$i_gPol^}f#5Y@@d?q6W75$i}5~L#J2*z0j;@F zQ?A-gfRi|d{T9Tc`@Lh39m`7w^G3#V%;Gx_4w*mnQ+4IYOF-xe^l|VBNVL`EqG7^* z;%0o0@2C}>j#6uP1G(7OXe$6b2NIDOR)2ok!X+=jSh>RKa$iyt5Z_zn+}2ME@!O`5 zD=LUi?n1Z)&W-?@JyT)%FPp#ixO!YkhnJiAt|}Kf)lZFmF+hZ1AD_iOZOM{XW9wq& zc`o2Q5>M3G9^muN`Y?`zz#l+9Kdkm$Q4T$Cl2Rt(0Zz!rqiD}jS7RV&-6B1nyML0O z!z3yb@msM<@EXv3+h!%Ci1~>9MUIq|iO}4k%U1||W5G@?l`Ee29bMwYtn0)e?JkI* za7xe@flJd9)z`T8=Z-#x&WIg)l#>?%!%mUlfn`^6JquD2ue)U=l5hBUD+g?2webv)nssbF5dzK^lH6$%s|$W@s| zSZk{0hVdnLq$-Ju;`i8p^Ea}J*x2`9@4z1>{+vv34X26#0000 zN8*2?+uK{7X=7tUw6wH{*RNlTu&^-E)YK#v7k?Ku3esQC_@Tf|PEHCU;>X+DTLc6I z==R9S2qSR7TQWTxNibv>25oI^QCwUcMMOl9zrR0y|NfmY78)8#PEJm=yu3`GK7AtN z*^pQ$9v>g)9%&U?TU*1TBm=G8zLF7MRzP`@Bp#dl`(#gco(2!OD5K!>u&6@{La&oeek)nA^OH0N4 z{JhqA7u3g(A2pxl!ltICSVo7vGV{T~0W~)_Q&(3PZ-MBQp})dadOmCC5ice}6x>kzbsho&OjNl)>4hPk&NsYAVTe zKr=HlJcpUp4J4`7)>e+F!^1{7uIhJlz~$gBps2Ek!>+E z;}c%cb#`_};o;%b-Q7(xIkL2^IW!<_mo3I8;JC+nd3i~`zP{XtqsNSl+1XjNvJZIWcM=Gcw?8GJk*Yb}2zKp{I^3%b%Q_n2K_gDFIXN-(*nwkqSVz7H-7H z#}m%4zZLG*Fr(f9ArFBRKyFyPjH03jiZ{S(51;5X2P>^v|qKrdguw6FX?frPL`nE?g$X;1WFBIv=H zDE~-cFuA$8G&VNICxM#7%<>P4d<6=ExJ%)tiE|E7h)GfBC<0J*Rw3!3AcIfhmReq3 z&KHHCpdh=pO6kPvHDUWe(lSE&6xYO(k^efu6-Y*;2o4U`#ecpmD?~y<0vGkNT-E&T z?d?Kd09lvP$qhSR_W*%kDZt$ff1jwrAHdXuA|3_3YO7y)eG;-B*V8Ipy2FkSy=79V zrn~!%twLhMJqpF#^z=06EHD=o6i{AX9@paX>Z21Md80& diff --git a/lib/buy/get_buy_provider_icon.dart b/lib/buy/get_buy_provider_icon.dart index bbd599e24..f284b6f04 100644 --- a/lib/buy/get_buy_provider_icon.dart +++ b/lib/buy/get_buy_provider_icon.dart @@ -1,18 +1,24 @@ import 'package:flutter/material.dart'; import 'package:cake_wallet/buy/buy_provider_description.dart'; -Image getBuyProviderIcon(BuyProviderDescription providerDescription) { +Image getBuyProviderIcon(BuyProviderDescription providerDescription, + {bool isWhiteIconColor = false}) { + final _wyreIcon = Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); - final _moonPayIcon = - Image.asset('assets/images/moonpay-icon.png', width: 36, height: 34); + final _moonPayWhiteIcon = + Image.asset('assets/images/moonpay-icon.png', color: Colors.white, + width: 36, height: 34); + final _moonPayBlackIcon = + Image.asset('assets/images/moonpay-icon.png', color: Colors.black, + width: 36, height: 34); if (providerDescription != null) { switch (providerDescription) { case BuyProviderDescription.wyre: return _wyreIcon; case BuyProviderDescription.moonPay: - return _moonPayIcon; + return isWhiteIconColor ? _moonPayWhiteIcon : _moonPayBlackIcon; default: return null; } diff --git a/lib/di.dart b/lib/di.dart index c00cb129e..58523c474 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -155,9 +155,15 @@ Future setup( (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - final locale = await Devicelocale.currentLocale; - final deviceCountryCode = locale.split('_').last; - final isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + var isMoonPayEnabled = false; + try { + final locale = await Devicelocale.currentLocale; + final deviceCountryCode = locale.split('_').last; + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + } catch (e) { + isMoonPayEnabled = false; + print(e.toString()); + } final settingsStore = await SettingsStoreBase.load( nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index ebda2dc8a..cf6cca586 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -114,7 +114,7 @@ class PreOrderPage extends BasePage { padding: EdgeInsets.only(top: 100, bottom: 65), child: Center( child: Container( - width: 185, + width: 210, child: BaseTextFormField( focusNode: _amountFocus, controller: _amountController, diff --git a/lib/src/screens/buy/widgets/buy_list_item.dart b/lib/src/screens/buy/widgets/buy_list_item.dart index 7c18893a6..97eb88ec6 100644 --- a/lib/src/screens/buy/widgets/buy_list_item.dart +++ b/lib/src/screens/buy/widgets/buy_list_item.dart @@ -26,25 +26,22 @@ class BuyListItem extends StatelessWidget { @override Widget build(BuildContext context) { - final providerIcon = getBuyProviderIcon(provider.description); + final isSelected = selectedProvider?.description == provider.description; - final backgroundColor = selectedProvider != null - ? selectedProvider.description == provider.description + final providerIcon = getBuyProviderIcon(provider.description, + isWhiteIconColor: isSelected); + + final backgroundColor = isSelected ? Palette.greyBlueCraiola - : Palette.shadowWhite - : Palette.shadowWhite; + : Palette.shadowWhite; - final primaryTextColor = selectedProvider != null - ? selectedProvider.description == provider.description + final primaryTextColor = isSelected ? Colors.white - : Palette.darkGray - : Palette.darkGray; + : Palette.darkGray; - final secondaryTextColor = selectedProvider != null - ? selectedProvider.description == provider.description + final secondaryTextColor = isSelected ? Colors.white - : Palette.darkBlueCraiola - : Palette.darkBlueCraiola; + : Palette.darkBlueCraiola; return GestureDetector( onTap: () => onTap?.call(), diff --git a/lib/src/screens/dashboard/widgets/order_row.dart b/lib/src/screens/dashboard/widgets/order_row.dart index 56a69122e..9a7a61525 100644 --- a/lib/src/screens/dashboard/widgets/order_row.dart +++ b/lib/src/screens/dashboard/widgets/order_row.dart @@ -1,6 +1,9 @@ import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:cake_wallet/buy/get_buy_provider_icon.dart'; +import 'package:cake_wallet/themes/theme_base.dart'; import 'package:flutter/material.dart'; +import 'package:cake_wallet/di.dart'; +import 'package:cake_wallet/store/settings_store.dart'; class OrderRow extends StatelessWidget { OrderRow({ @@ -19,7 +22,11 @@ class OrderRow extends StatelessWidget { @override Widget build(BuildContext context) { - final providerIcon = getBuyProviderIcon(provider); + final currentTheme = getIt.get().currentTheme; + final isWhiteIconColor = currentTheme.type != ThemeType.light; + + final providerIcon = getBuyProviderIcon(provider, + isWhiteIconColor: isWhiteIconColor); return InkWell( onTap: onTap, diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 2b26b2dd8..be71b9f2c 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -253,9 +253,15 @@ abstract class SettingsStoreBase with Store { (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - final locale = await Devicelocale.currentLocale; - final deviceCountryCode = locale.split('_').last; - final isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + var isMoonPayEnabled = false; + try { + final locale = await Devicelocale.currentLocale; + final deviceCountryCode = locale.split('_').last; + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + } catch (e) { + isMoonPayEnabled = false; + print(e.toString()); + } final settings = await SettingsStoreBase.load( nodeSource: nodeSource, From ee6b8767d694cc67c3a9d2a3da574ea9e689ce00 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 2 Jun 2021 20:09:39 +0300 Subject: [PATCH 23/42] CAKE-306 | fixed settings_store.dart and di.dart --- lib/di.dart | 6 +++--- lib/store/settings_store.dart | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index 58523c474..b5bb7bfd3 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -155,7 +155,7 @@ Future setup( (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - var isMoonPayEnabled = false; + /*var isMoonPayEnabled = false; try { final locale = await Devicelocale.currentLocale; final deviceCountryCode = locale.split('_').last; @@ -163,11 +163,11 @@ Future setup( } catch (e) { isMoonPayEnabled = false; print(e.toString()); - } + }*/ final settingsStore = await SettingsStoreBase.load( nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: isMoonPayEnabled); + isMoonPayEnabled: true); if (_isSetupFinished) { return; diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index be71b9f2c..207a731c9 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -253,7 +253,7 @@ abstract class SettingsStoreBase with Store { (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - var isMoonPayEnabled = false; + /*var isMoonPayEnabled = false; try { final locale = await Devicelocale.currentLocale; final deviceCountryCode = locale.split('_').last; @@ -261,12 +261,12 @@ abstract class SettingsStoreBase with Store { } catch (e) { isMoonPayEnabled = false; print(e.toString()); - } + }*/ final settings = await SettingsStoreBase.load( nodeSource: nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: isMoonPayEnabled, + isMoonPayEnabled: true, initialBalanceDisplayMode: initialBalanceDisplayMode, initialFiatCurrency: initialFiatCurrency, initialMoneroTransactionPriority: initialMoneroTransactionPriority, From 8e62f2f81176282b8f8b1eba1461ca6b3e52d52e Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Thu, 3 Jun 2021 18:38:41 +0300 Subject: [PATCH 24/42] CAKE-341 | fixed scrollbar for currency_picker.dart; applied receive currency list to exchange_template_page.dart --- lib/src/screens/exchange/exchange_template_page.dart | 2 +- lib/src/screens/exchange/widgets/currency_picker.dart | 2 ++ pubspec.lock | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/screens/exchange/exchange_template_page.dart b/lib/src/screens/exchange/exchange_template_page.dart index 5437703ce..568e53cd5 100644 --- a/lib/src/screens/exchange/exchange_template_page.dart +++ b/lib/src/screens/exchange/exchange_template_page.dart @@ -176,7 +176,7 @@ class ExchangeTemplatePage extends BasePage { initialIsAddressEditable: exchangeViewModel.isReceiveAddressEnabled, isAmountEstimated: true, - currencies: CryptoCurrency.all, + currencies: exchangeViewModel.receiveCurrencies, onCurrencySelected: (currency) => exchangeViewModel.changeReceiveCurrency( currency: currency), diff --git a/lib/src/screens/exchange/widgets/currency_picker.dart b/lib/src/screens/exchange/widgets/currency_picker.dart index 5e22a17e8..59d53518e 100644 --- a/lib/src/screens/exchange/widgets/currency_picker.dart +++ b/lib/src/screens/exchange/widgets/currency_picker.dart @@ -45,6 +45,7 @@ class CurrencyPickerState extends State { color: Palette.darkBlueCraiola, ); final int crossAxisCount = 3; + final int maxNumberItemsInAlert = 12; final int itemsCount; final double backgroundHeight = 280; final double thumbHeight = 72; @@ -148,6 +149,7 @@ class CurrencyPickerState extends State { ); }) ), + if (itemsCount > maxNumberItemsInAlert) CakeScrollbar( backgroundHeight: backgroundHeight, thumbHeight: thumbHeight, diff --git a/pubspec.lock b/pubspec.lock index 3ff596074..207f4b18a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,7 +70,7 @@ packages: path: "." ref: cake resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2" - url: "git@github.com:cake-tech/bech32.git" + url: "https://github.com/cake-tech/bech32.git" source: git version: "0.2.0" bip32: @@ -92,8 +92,8 @@ packages: description: path: "." ref: cake - resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7 - url: "git@github.com:cake-tech/bitcoin_flutter.git" + resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188 + url: "https://github.com/cake-tech/bitcoin_flutter.git" source: git version: "2.0.2" boolean_selector: From b1cda209876ad78c4148cdb211abce9b2c55901e Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Thu, 3 Jun 2021 20:59:12 +0300 Subject: [PATCH 25/42] CAKE-336 | updated local_auth package and fixed isAuthenticated() method in the biometric_auth.dart --- lib/entities/biometric_auth.dart | 2 +- pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/entities/biometric_auth.dart b/lib/entities/biometric_auth.dart index ab5d62445..10a05ebff 100644 --- a/lib/entities/biometric_auth.dart +++ b/lib/entities/biometric_auth.dart @@ -7,7 +7,7 @@ class BiometricAuth { Future isAuthenticated() async { try { - return await _localAuth.authenticateWithBiometrics( + return await _localAuth.authenticate( localizedReason: S.current.biometric_auth_reason, useErrorDialogs: true, stickyAuth: false); diff --git a/pubspec.lock b/pubspec.lock index 207f4b18a..a520abbe3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -565,7 +565,7 @@ packages: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.1.6" logging: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4d1b63ceb..c3de221a9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,7 +49,7 @@ dependencies: path: ./cw_monero hive: ^1.4.4+1 hive_flutter: ^0.3.1 - local_auth: ^1.1.1 + local_auth: ^1.1.6 package_info: ^2.0.0 devicelocale: ^0.4.1 auto_size_text: ^2.1.0 From b2ece79334d0bcf4dd9ddd3f8667dd346b355a99 Mon Sep 17 00:00:00 2001 From: M Date: Fri, 4 Jun 2021 13:30:59 +0300 Subject: [PATCH 26/42] Added warning on receive screen for outdated electrum wallets. --- lib/entities/preferences_key.dart | 1 + lib/src/screens/dashboard/dashboard_page.dart | 3 +- .../dashboard/widgets/address_page.dart | 33 ++++++++++++++++++- lib/src/screens/receive/receive_page.dart | 1 + lib/store/settings_store.dart | 6 ++++ res/values/strings_de.arb | 5 ++- res/values/strings_en.arb | 5 ++- res/values/strings_es.arb | 5 ++- res/values/strings_hi.arb | 5 ++- res/values/strings_hr.arb | 5 ++- res/values/strings_it.arb | 5 ++- res/values/strings_ja.arb | 5 ++- res/values/strings_ko.arb | 5 ++- res/values/strings_nl.arb | 5 ++- res/values/strings_pl.arb | 5 ++- res/values/strings_pt.arb | 5 ++- res/values/strings_ru.arb | 5 ++- res/values/strings_uk.arb | 5 ++- res/values/strings_zh.arb | 5 ++- 19 files changed, 98 insertions(+), 16 deletions(-) diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index 6d55748cc..82db7d5d9 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -19,4 +19,5 @@ class PreferencesKey { 'current_default_settings_migration_version'; static const moneroTransactionPriority = 'current_fee_priority_monero'; static const bitcoinTransactionPriority = 'current_fee_priority_bitcoin'; + static const shouldShowReceiveWarning = 'should_show_receive_warning'; } diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 46a4185ce..d98751a57 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -167,7 +167,8 @@ class DashboardPage extends BasePage { return; } - pages.add(AddressPage(addressListViewModel: addressListViewModel)); + pages.add(AddressPage(addressListViewModel: addressListViewModel, + walletViewModel: walletViewModel)); pages.add(BalancePage(dashboardViewModel: walletViewModel)); pages.add(TransactionsPage(dashboardViewModel: walletViewModel)); diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index 7e4fb1c73..05dd9fb24 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -1,5 +1,10 @@ +import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; +import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; +import 'package:cake_wallet/store/settings_store.dart'; +import 'package:cake_wallet/utils/show_pop_up.dart'; +import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; import 'package:cake_wallet/src/screens/receive/widgets/qr_widget.dart'; @@ -7,17 +12,43 @@ import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:keyboard_actions/keyboard_actions.dart'; +import 'package:mobx/mobx.dart'; class AddressPage extends StatelessWidget { - AddressPage({@required this.addressListViewModel}) + AddressPage({@required this.addressListViewModel, + this.walletViewModel}) : _cryptoAmountFocus = FocusNode(); final WalletAddressListViewModel addressListViewModel; + final DashboardViewModel walletViewModel; final FocusNode _cryptoAmountFocus; @override Widget build(BuildContext context) { + autorun((_) async { + if (!walletViewModel.isOutdatedElectrumWallet + || !walletViewModel.settingsStore.shouldShowReceiveWarning) { + return; + } + + await Future.delayed(Duration(seconds: 1)); + await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithTwoActions( + alertTitle: S.of(context).pre_seed_title, + alertContent: S.of(context).outdated_electrum_wallet_receive_warning, + leftButtonText: S.of(context).understand, + actionLeftButton: () => Navigator.of(context).pop(), + rightButtonText: S.of(context).do_not_show_me, + actionRightButton: () { + walletViewModel.settingsStore.setShouldShowReceiveWarning(false); + Navigator.of(context).pop(); + }); + }); + }); + return KeyboardActions( autoScroll: false, disableScroll: true, diff --git a/lib/src/screens/receive/receive_page.dart b/lib/src/screens/receive/receive_page.dart index 9201b9805..718bc0c01 100644 --- a/lib/src/screens/receive/receive_page.dart +++ b/lib/src/screens/receive/receive_page.dart @@ -1,6 +1,7 @@ import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; +import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index da2410378..b61faee03 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -147,6 +147,12 @@ abstract class SettingsStoreBase with Store { bool isBitcoinBuyEnabled; + bool get shouldShowReceiveWarning => + _sharedPreferences.getBool(PreferencesKey.shouldShowReceiveWarning) ?? true; + + Future setShouldShowReceiveWarning(bool value) async => + _sharedPreferences.setBool(PreferencesKey.shouldShowReceiveWarning, value); + static Future load( {@required Box nodeSource, @required bool isBitcoinBuyEnabled, diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index ed3520d17..a89e69170 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", "understand" : "Ich verstehe", - "apk_update" : "APK Update" + "apk_update" : "APK Update", + + "outdated_electrum_wallet_receive_warning": "WARNUNG\nWenn diese Brieftasche einen Seed von 12 Wörtern hat, der in Cake Wallet erstellt wurde, zahlen Sie KEINE Bitcoins in diese Brieftasche ein. Ihr Bitcoin kann gestohlen werden. Erstellen Sie eine neue Brieftasche und verschieben Sie Ihr Geld SOFORT in die neue Brieftasche.", + "do_not_show_me": "Zeig mir das nicht noch einmal" } \ No newline at end of file diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 65dee6dbe..ecc562f9d 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", "understand" : "I understand", - "apk_update" : "APK update" + "apk_update" : "APK update", + + "outdated_electrum_wallet_receive_warning": "WARNING\nIf this wallet has a seed of 12 words which was created in Cake Wallet, DO NOT deposit Bitcoin in this wallet. Your Bitcoin can be at risk of getting stolen. Create a new wallet, and move your funds to the new wallet IMMEDIATELY.", + "do_not_show_me": "Do not show me this again" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 983146557..135be2c80 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Las nuevas carteras de Bitcoin creadas en Cake ahora tienen una semilla de 24 palabras. Es obligatorio que cree una nueva billetera de Bitcoin y transfiera todos sus fondos a la nueva billetera de 24 palabras, y deje de usar billeteras con una semilla de 12 palabras. Haga esto de inmediato para asegurar sus fondos.", "understand" : "Entiendo", - "apk_update" : "Actualización de APK" + "apk_update" : "Actualización de APK", + + "outdated_electrum_wallet_receive_warning": "ADVERTENCIA\nSi esta billetera tiene una semilla de 12 palabras que se creó en Cake Wallet, NO DEposite Bitcoin en esta billetera. Su Bitcoin puede estar en riesgo de ser robado. Cree una nueva billetera y mueva sus fondos a la nueva billetera INMEDIATAMENTE.", + "do_not_show_me": "no me muestres esto otra vez" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 889f21c3f..47ecbaa98 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "केक में बनाए गए नए बिटकॉइन वॉलेट में अब 24-शब्द का बीज है। यह अनिवार्य है कि आप एक नया बिटकॉइन वॉलेट बनाएं और अपने सभी फंड को नए 24-शब्द वाले वॉलेट में स्थानांतरित करें, और 12-शब्द बीज वाले वॉलेट का उपयोग करना बंद करें। कृपया अपने धन को सुरक्षित करने के लिए इसे तुरंत करें।", "understand" : "मुझे समझ", - "apk_update" : "APK अद्यतन" + "apk_update" : "APK अद्यतन", + + "outdated_electrum_wallet_receive_warning": "चेतावनी\nयदि इस वॉलेट में 12 शब्दों का बीज है जो केक वॉलेट में बनाया गया था, तो इस वॉलेट में बिटकॉइन जमा न करें। आपका बिटकॉइन चोरी होने का खतरा हो सकता है। एक नया वॉलेट बनाएं, और अपने फंड को तुरंत नए वॉलेट में ले जाएं।", + "do_not_show_me": "मुझे यह फिर न दिखाएं" } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 681917b03..dc6fbe4aa 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Novi Bitcoin novčanici stvoreni u Cakeu sada imaju sjeme od 24 riječi. Obavezno je stvoriti novi Bitcoin novčanik i prenijeti sva svoja sredstva u novi novčanik od 24 riječi te prestati koristiti novčanike s sjemenkom od 12 riječi. Učinite to odmah kako biste osigurali svoja sredstva.", "understand" : "Razumijem", - "apk_update" : "APK ažuriranje" + "apk_update" : "APK ažuriranje", + + "outdated_electrum_wallet_receive_warning": "UPOZORENJE\nAko ovaj novčanik sadrži izvor od 12 riječi koji je stvoren u novčaniku Cake, NEMOJTE polagati Bitcoin u ovaj novčanik. Vaš Bitcoin može biti u opasnosti od krađe. Stvorite novi novčanik i ODMAH premjestite sredstva u novi novčanik.", + "do_not_show_me": "Ne pokazuj mi ovo više" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 1b10a0137..861732fc4 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "I nuovi portafogli Bitcoin creati in Cake ora hanno un seme di 24 parole. È obbligatorio creare un nuovo portafoglio Bitcoin e trasferire tutti i fondi nel nuovo portafoglio di 24 parole e smettere di usare portafogli con un seme di 12 parole. Ti preghiamo di farlo immediatamente per proteggere i tuoi fondi.", "understand" : "Capisco", - "apk_update" : "Aggiornamento APK" + "apk_update" : "Aggiornamento APK", + + "outdated_electrum_wallet_receive_warning": "ATTENZIONE\nSe questo portafoglio ha un seme di 12 parole creato in Cake Wallet, NON depositare Bitcoin in questo portafoglio. Il tuo Bitcoin può essere a rischio di essere rubato. Crea un nuovo portafoglio e sposta i tuoi fondi nel nuovo portafoglio IMMEDIATAMENTE.", + "do_not_show_me": "Non mostrarmelo di nuovo" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 7d78e9313..320454372 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Cakeで作成された新しいビットコインウォレットには、24ワードのシードがあります。 新しいビットコインウォレットを作成し、すべての資金を新しい24ワードのウォレットに転送し、12ワードのシードを持つウォレットの使用を停止することが必須です。 あなたの資金を確保するためにこれをすぐに行ってください。", "understand" : "わかります", - "apk_update" : "APKアップデート" + "apk_update" : "APKアップデート", + + "outdated_electrum_wallet_receive_warning": "警告\nこのウォレットにCake Walletで作成された12ワードのシードがある場合、このウォレットにビットコインを入金しないでください。 ビットコインが盗まれる危険性があります。 新しいウォレットを作成し、すぐに新しいウォレットに資金を移動してください。", + "do_not_show_me": "また僕にこれを見せないでください" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 3a10232a9..d1af5c1e2 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Cake에서 생성 된 새로운 비트 코인 지갑에는 이제 24 단어 시드가 있습니다. 새로운 비트 코인 지갑을 생성하고 모든 자금을 새로운 24 단어 지갑으로 이체하고 12 단어 시드가있는 지갑 사용을 중지해야합니다. 자금을 확보하려면 즉시이 작업을 수행하십시오.", "understand" : "이해 했어요", - "apk_update" : "APK 업데이트" + "apk_update" : "APK 업데이트", + + "outdated_electrum_wallet_receive_warning": "경고\n이 지갑에 Cake Wallet에서 생성 된 12 단어의 시드가있는 경우이 지갑에 Bitcoin을 입금하지 마십시오. 귀하의 비트 코인은 도난 당할 위험이 있습니다. 새 지갑을 만들고 즉시 새 지갑으로 자금을 이동하십시오.", + "do_not_show_me": "나를 다시 표시하지 않음" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 76b084428..c1322c2ca 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Nieuwe Bitcoin-portefeuilles die in Cake zijn gemaakt, hebben nu een zaadje van 24 woorden. Het is verplicht dat u een nieuwe Bitcoin-portemonnee maakt en al uw geld overmaakt naar de nieuwe portemonnee van 24 woorden, en stopt met het gebruik van wallets met een seed van 12 woorden. Doe dit onmiddellijk om uw geld veilig te stellen.", "understand" : "Ik begrijp het", - "apk_update" : "APK-update" + "apk_update" : "APK-update", + + "outdated_electrum_wallet_receive_warning": "WAARSCHUWING\nAls deze portemonnee een seed van 12 woorden heeft die is gemaakt in Cake Wallet, stort dan GEEN Bitcoin in deze portemonnee. Uw Bitcoin kan het risico lopen te worden gestolen. Maak een nieuwe portemonnee en verplaats uw geld ONMIDDELLIJK naar de nieuwe portemonnee.", + "do_not_show_me": "laat me dit niet opnieuw zien" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 5522713d7..dd45292b7 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Nowe portfele Bitcoin utworzone w Cake mają teraz ziarno składające się z 24 słów. Konieczne jest utworzenie nowego portfela Bitcoin i przeniesienie wszystkich środków do nowego portfela na 24 słowa oraz zaprzestanie korzystania z portfeli z zalążkiem na 12 słów. Zrób to natychmiast, aby zabezpieczyć swoje fundusze.", "understand" : "Rozumiem", - "apk_update" : "Aktualizacja APK" + "apk_update" : "Aktualizacja APK", + + "outdated_electrum_wallet_receive_warning": "OSTRZEŻENIE\nJeśli ten portfel zawiera ziarno 12 słów, które zostało utworzone w portfelu Cake, NIE Wpłacaj Bitcoinów do tego portfela. Twój Bitcoin może być zagrożony kradzieżą. Utwórz nowy portfel i NATYCHMIAST przenieś swoje środki do nowego portfela.", + "do_not_show_me": "Nie pokazuj mi tego ponownie" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index c5c976113..e739f1553 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "As novas carteiras Bitcoin criadas no Cake agora têm uma semente de 24 palavras. É obrigatório que você crie uma nova carteira Bitcoin e transfira todos os seus fundos para a nova carteira de 24 palavras, e pare de usar carteiras com semente de 12 palavras. Faça isso imediatamente para garantir seus fundos.", "understand" : "Entendo", - "apk_update" : "Atualização de APK" + "apk_update" : "Atualização de APK", + + "outdated_electrum_wallet_receive_warning": "AVISO\nSe esta carteira tiver uma semente de 12 palavras que foi criada na Carteira Cake, NÃO deposite Bitcoin nesta carteira. Seu Bitcoin pode correr o risco de ser roubado. Crie uma nova carteira e mova seus fundos para a nova carteira IMEDIATAMENTE.", + "do_not_show_me": "não me mostre isso novamente" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 1377b4fc0..e5a08952e 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Новые биткойн-кошельки, созданные в Cake, теперь содержат мнемоническую фразу из 24 слов. Вы обязательно должны создать новый биткойн-кошелек и перевести все свои средства в новый кошелек из 24 слов, а также прекратить использование кошельков с мнемонической фразой из 12 слов. Пожалуйста, сделайте это немедленно, чтобы обезопасить свои средства.", "understand" : "Понятно", - "apk_update" : "Обновление APK" + "apk_update" : "Обновление APK", + + "outdated_electrum_wallet_receive_warning": "ПРЕДУПРЕЖДЕНИЕ\nЕсли этот кошелек был создан в Cake Wallet и имеет мнемоническую фразу из 12 слов, НЕ вносите биткойны в этот кошелек. Ваши биткойны могут быть украдены. Создайте новый кошелек и НЕМЕДЛЕННО переместите свои средства в новый кошелек.", + "do_not_show_me": "Не показывай мне это больше" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index e0c1fcc55..9828d12a1 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "Нові біткойн-гаманці, створені в Cake, тепер містять мнемонічну фразу з 24 слів. Обов’язково стовріть новий біткойн-гаманець, переведіть всі кошти на новий гаманець із 24 слів і припиніть використання гаманців із мнемонічною фразою з 12 слів. Зробіть це негайно, щоб убезпечити свої кошти.", "understand" : "Зрозуміло", - "apk_update" : "Оновлення APK" + "apk_update" : "Оновлення APK", + + "outdated_electrum_wallet_receive_warning": "ПОПЕРЕДЖЕННЯ\nЯкщо цей гаманець має мнемонічну фразу із 12 слів, та був створенний в Cake Wallet, НЕ переводьте біткойни в цей гаманець. Ваші біткойни ризикують бути вкраденими. Створіть новий гаманець і НЕГАЙНО переведіть свої біткоїни на новий гаманець.", + "do_not_show_me": "Не показуй мені це знову" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 5faa8c840..bb923f057 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -476,5 +476,8 @@ "outdated_electrum_wallet_desceription" : "在Cake创建的新比特币钱包现在有一个24字的种子。你必须创建一个新的比特币钱包,并将你所有的资金转移到新的24字钱包,并停止使用12字种子的钱包。请立即这样做以保证你的资金安全。", "understand" : "我已知晓", - "apk_update" : "APK更新" + "apk_update" : "APK更新", + + "outdated_electrum_wallet_receive_warning": "警告\n如果这个钱包有一个在 Cake Wallet 中创建的 12 个单词的种子,请不要在这个钱包中存入比特币。 您的比特币可能有被盗的风险。 创建一个新钱包,并立即将您的资金转移到新钱包中。", + "do_not_show_me": "不要再让我看这个了" } \ No newline at end of file From ff6e4d58f700738e5e14fdcd3d00ff1f20d93de2 Mon Sep 17 00:00:00 2001 From: M Date: Fri, 4 Jun 2021 18:25:17 +0300 Subject: [PATCH 27/42] Added push notifications, FCM. --- .gitignore | 5 +- android/app/build.gradle | 6 ++ android/app/src/main/AndroidManifest.xml | 2 +- .../cakewallet/cake_wallet/Application.java | 21 ++++ android/build.gradle | 1 + ios/Podfile | 1 + ios/Podfile.lock | 99 ++++++++++++++++++- ios/Runner.xcodeproj/project.pbxproj | 7 ++ ios/Runner/AppDelegate.swift | 4 + ios/Runner/Info.plist | 5 + ios/Runner/Runner.entitlements | 5 +- lib/di.dart | 7 +- lib/entities/push_notifications_service.dart | 45 +++++++++ .../dashboard/widgets/balance_page.dart | 1 + lib/utils/show_bar.dart | 16 ++- .../dashboard/dashboard_view_model.dart | 15 ++- pubspec.lock | 34 ++++++- pubspec.yaml | 1 + 18 files changed, 259 insertions(+), 16 deletions(-) create mode 100644 android/app/src/main/java/com/cakewallet/cake_wallet/Application.java create mode 100644 lib/entities/push_notifications_service.dart diff --git a/.gitignore b/.gitignore index 0580d006c..b5c6f1e12 100644 --- a/.gitignore +++ b/.gitignore @@ -97,4 +97,7 @@ android/app/.cxx/** ios/Flutter/.last_build_id /lib/generated/** #**# -/**/#**# \ No newline at end of file +/**/#**# + +**/google-services.json +**/GoogleService-Info.plist \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 0c6a46dc4..ee68ec0db 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -24,6 +24,10 @@ if (flutterVersionName == null) { apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +if (file("./google-services.json").exists()) { + apply plugin: 'com.google.gms.google-services' +} + def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { @@ -83,4 +87,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + implementation 'com.google.firebase:firebase-core:19.0.0' + implementation 'com.google.firebase:firebase-messaging:19.0.0' } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index abf27576f..c53d1ea7b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ - diff --git a/android/app/src/main/java/com/cakewallet/cake_wallet/Application.java b/android/app/src/main/java/com/cakewallet/cake_wallet/Application.java new file mode 100644 index 000000000..c3b51c14c --- /dev/null +++ b/android/app/src/main/java/com/cakewallet/cake_wallet/Application.java @@ -0,0 +1,21 @@ +package com.cakewallet.cake_wallet; + +import io.flutter.app.FlutterApplication; +import io.flutter.plugin.common.PluginRegistry; +import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback; +import io.flutter.plugins.GeneratedPluginRegistrant; +import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService; +import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin; + +public class Application extends FlutterApplication implements PluginRegistrantCallback { + @Override + public void onCreate() { + super.onCreate(); + FlutterFirebaseMessagingService.setPluginRegistrant(this); + } + + @Override + public void registerWith(PluginRegistry registry) { + FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")); + } +} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 0baed694d..0d11c6b94 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,6 +6,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.5.4' + classpath 'com.google.gms:google-services:4.3.8' } } diff --git a/ios/Podfile b/ios/Podfile index e26de900c..3cfff7b1d 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -36,6 +36,7 @@ target 'Runner' do # Cake Wallet (Legacy) pod 'CryptoSwift' + pod 'Firebase/Messaging', '6.33.0' end post_install do |installer| diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 879041cac..50f9b20d2 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -62,18 +62,84 @@ PODS: - file_picker (0.0.1): - DKImagePickerController/PhotoGallery - Flutter + - Firebase/CoreOnly (6.33.0): + - FirebaseCore (= 6.10.3) + - Firebase/Messaging (6.33.0): + - Firebase/CoreOnly + - FirebaseMessaging (~> 4.7.0) + - firebase_core (0.5.3): + - Firebase/CoreOnly (~> 6.33.0) + - Flutter + - firebase_messaging (7.0.3): + - Firebase/CoreOnly (~> 6.33.0) + - Firebase/Messaging (~> 6.33.0) + - firebase_core + - Flutter + - FirebaseCore (6.10.3): + - FirebaseCoreDiagnostics (~> 1.6) + - GoogleUtilities/Environment (~> 6.7) + - GoogleUtilities/Logger (~> 6.7) + - FirebaseCoreDiagnostics (1.7.0): + - GoogleDataTransport (~> 7.4) + - GoogleUtilities/Environment (~> 6.7) + - GoogleUtilities/Logger (~> 6.7) + - nanopb (~> 1.30906.0) + - FirebaseInstallations (1.7.0): + - FirebaseCore (~> 6.10) + - GoogleUtilities/Environment (~> 6.7) + - GoogleUtilities/UserDefaults (~> 6.7) + - PromisesObjC (~> 1.2) + - FirebaseInstanceID (4.8.0): + - FirebaseCore (~> 6.10) + - FirebaseInstallations (~> 1.6) + - GoogleUtilities/Environment (~> 6.7) + - GoogleUtilities/UserDefaults (~> 6.7) + - FirebaseMessaging (4.7.1): + - FirebaseCore (~> 6.10) + - FirebaseInstanceID (~> 4.7) + - GoogleUtilities/AppDelegateSwizzler (~> 6.7) + - GoogleUtilities/Environment (~> 6.7) + - GoogleUtilities/Reachability (~> 6.7) + - GoogleUtilities/UserDefaults (~> 6.7) + - Protobuf (>= 3.9.2, ~> 3.9) - Flutter (1.0.0) - flutter_secure_storage (3.3.1): - Flutter + - GoogleDataTransport (7.5.1): + - nanopb (~> 1.30906.0) + - GoogleUtilities/AppDelegateSwizzler (6.7.2): + - GoogleUtilities/Environment + - GoogleUtilities/Logger + - GoogleUtilities/Network + - GoogleUtilities/Environment (6.7.2): + - PromisesObjC (~> 1.2) + - GoogleUtilities/Logger (6.7.2): + - GoogleUtilities/Environment + - GoogleUtilities/Network (6.7.2): + - GoogleUtilities/Logger + - "GoogleUtilities/NSData+zlib" + - GoogleUtilities/Reachability + - "GoogleUtilities/NSData+zlib (6.7.2)" + - GoogleUtilities/Reachability (6.7.2): + - GoogleUtilities/Logger + - GoogleUtilities/UserDefaults (6.7.2): + - GoogleUtilities/Logger - local_auth (0.0.1): - Flutter - MTBBarcodeScanner (5.0.11) + - nanopb (1.30906.0): + - nanopb/decode (= 1.30906.0) + - nanopb/encode (= 1.30906.0) + - nanopb/decode (1.30906.0) + - nanopb/encode (1.30906.0) - package_info (0.0.1): - Flutter - path_provider (0.0.1): - Flutter - "permission_handler (5.1.0+2)": - Flutter + - PromisesObjC (1.2.12) + - Protobuf (3.17.0) - Reachability (3.2) - SDWebImage (5.9.1): - SDWebImage/Core (= 5.9.1) @@ -97,6 +163,9 @@ DEPENDENCIES: - devicelocale (from `.symlinks/plugins/devicelocale/ios`) - esys_flutter_share (from `.symlinks/plugins/esys_flutter_share/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) + - Firebase/Messaging (= 6.33.0) + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - Flutter (from `Flutter`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - local_auth (from `.symlinks/plugins/local_auth/ios`) @@ -113,7 +182,18 @@ SPEC REPOS: - CryptoSwift - DKImagePickerController - DKPhotoGallery + - Firebase + - FirebaseCore + - FirebaseCoreDiagnostics + - FirebaseInstallations + - FirebaseInstanceID + - FirebaseMessaging + - GoogleDataTransport + - GoogleUtilities - MTBBarcodeScanner + - nanopb + - PromisesObjC + - Protobuf - Reachability - SDWebImage - SwiftProtobuf @@ -132,6 +212,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/esys_flutter_share/ios" file_picker: :path: ".symlinks/plugins/file_picker/ios" + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" + firebase_messaging: + :path: ".symlinks/plugins/firebase_messaging/ios" Flutter: :path: Flutter flutter_secure_storage: @@ -163,13 +247,26 @@ SPEC CHECKSUMS: DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 esys_flutter_share: 403498dab005b36ce1f8d7aff377e81f0621b0b4 file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1 + Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5 + firebase_core: 5d6a02f3d85acd5f8321c2d6d62877626a670659 + firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75 + FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd + FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1 + FirebaseInstallations: 466c7b4d1f58fe16707693091da253726a731ed2 + FirebaseInstanceID: bd3ffc24367f901a43c063b36c640b345a4a5dd1 + FirebaseMessaging: 5eca4ef173de76253352511aafef774caa1cba2a Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec + GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833 + GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3 local_auth: 25938960984c3a7f6e3253e3f8d962fdd16852bd MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb + nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0 + PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97 + Protobuf: 7327d4444215b5f18e560a97f879ff5503c4581c Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SDWebImage: a990c053fff71e388a10f3357edb0be17929c9c5 share: 0b2c3e82132f5888bccca3351c504d0003b3b410 @@ -179,6 +276,6 @@ SPEC CHECKSUMS: url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b -PODFILE CHECKSUM: 5b5f101b119a1b6eb857c967d462832a9062dec4 +PODFILE CHECKSUM: f316539722a6f9dbb0d0f1065a27fa7ea38c6f88 COCOAPODS: 1.9.3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 27704e6a2..3bc5b5fb6 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0C37B8B926678E9100C6E5A9 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0C37B8B826678E9100C6E5A9 /* GoogleService-Info.plist */; }; 0C44A71A2518EF8000B570ED /* decrypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C44A7192518EF8000B570ED /* decrypt.swift */; }; 0C9D68C9264854B60011B691 /* secRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9D68C8264854B60011B691 /* secRandom.swift */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; @@ -19,6 +20,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 0C37B8B826678E9100C6E5A9 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 0C400E0F25B21ABB0025E469 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 0C44A7192518EF8000B570ED /* decrypt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = decrypt.swift; sourceTree = ""; }; 0C9986A3251A932F00D566FD /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -96,6 +98,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + 0C37B8B826678E9100C6E5A9 /* GoogleService-Info.plist */, 0C44A7182518EF4A00B570ED /* CakeWallet */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, @@ -191,6 +194,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0C37B8B926678E9100C6E5A9 /* GoogleService-Info.plist in Resources */, 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, @@ -365,6 +369,7 @@ CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; + EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -508,6 +513,7 @@ CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; + EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -543,6 +549,7 @@ CURRENT_PROJECT_VERSION = 41; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; + EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index e7c300079..2a3505ef9 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -7,6 +7,10 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + if #available(iOS 10.0, *) { + UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate + } + let controller : FlutterViewController = window?.rootViewController as! FlutterViewController let legacyMigrationChannel = FlutterMethodChannel( name: "com.cakewallet.cakewallet/legacy_wallet_migration", diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 970c892cd..267805951 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -37,6 +37,11 @@ Enable Face ID for fast and secure access to wallets and private keys NSPhotoLibraryUsageDescription We need access to documents folder for get acces to open/save backup file + UIBackgroundModes + + fetch + remote-notification + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements index 0c67376eb..903def2af 100644 --- a/ios/Runner/Runner.entitlements +++ b/ios/Runner/Runner.entitlements @@ -1,5 +1,8 @@ - + + aps-environment + development + diff --git a/lib/di.dart b/lib/di.dart index cae3a068f..a84a00c88 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -113,6 +113,7 @@ import 'package:cake_wallet/store/templates/exchange_template_store.dart'; import 'package:cake_wallet/entities/template.dart'; import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; +import 'package:cake_wallet/entities/push_notifications_service.dart'; final getIt = GetIt.instance; @@ -232,6 +233,9 @@ Future setup( settingsStore: getIt.get(), fiatConvertationStore: getIt.get())); + + getIt.registerFactory(() => PushNotificationsService()); + getIt.registerFactory(() => DashboardViewModel( balanceViewModel: getIt.get(), appStore: getIt.get(), @@ -241,7 +245,8 @@ Future setup( settingsStore: settingsStore, ordersSource: _ordersSource, ordersStore: getIt.get(), - wyreViewModel: getIt.get())); + wyreViewModel: getIt.get(), + pushNotificationsService: getIt.get())); getIt.registerFactory(() => AuthService( secureStorage: getIt.get(), diff --git a/lib/entities/push_notifications_service.dart b/lib/entities/push_notifications_service.dart new file mode 100644 index 000000000..5fe69153c --- /dev/null +++ b/lib/entities/push_notifications_service.dart @@ -0,0 +1,45 @@ +import 'dart:io'; +import 'package:cake_wallet/main.dart'; +import 'package:cake_wallet/utils/show_bar.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; + +class PushNotificationsService { + PushNotificationsService._(); + + factory PushNotificationsService() => _instance; + + static final PushNotificationsService _instance = PushNotificationsService._(); + static Future _onBackgroundMessage(Map message) async {} + final _firebaseMessaging = FirebaseMessaging(); + bool _initialized = false; + + Future init() async { + if (_initialized) { + return; + } + + _firebaseMessaging.requestNotificationPermissions(); + _firebaseMessaging.configure( + onMessage: (message) async { + Map alert = {}; + String msg = ''; + String title = ''; + + if (Platform.isIOS) { + alert = message['aps']['alert'] as Map ?? {}; + msg = alert['body'] as String ?? ''; + title = alert['title'] as String ?? ''; + } + + if (Platform.isAndroid) { + msg = message['notification']['body'] as String ?? ''; + title = message['notification']['title'] as String ?? ''; + } + + await showBar(navigatorKey.currentContext, msg, titleText: title, duration: null); + }, + onBackgroundMessage: _onBackgroundMessage); + + _initialized = true; + } +} \ No newline at end of file diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 1cd17d4c0..2498e2d5c 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; +import 'package:flutter/scheduler.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:auto_size_text/auto_size_text.dart'; diff --git a/lib/utils/show_bar.dart b/lib/utils/show_bar.dart index 8d2355e4f..64231b438 100644 --- a/lib/utils/show_bar.dart +++ b/lib/utils/show_bar.dart @@ -2,8 +2,11 @@ import 'package:flushbar/flushbar.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -Future showBar(BuildContext context, String text, - {bool isDark = false, Duration duration = const Duration(seconds: 1), bool isDismissible = true}) { +Future showBar(BuildContext context, String messageText, + {bool isDark = false, + Duration duration = const Duration(seconds: 1), + bool isDismissible = true, + String titleText}) { final bar = Flushbar( boxShadows: [ BoxShadow( @@ -14,9 +17,14 @@ Future showBar(BuildContext context, String text, backgroundColor: isDark ? Colors.black : Colors.white, borderRadius: 35, margin: EdgeInsets.all(50), - messageText: Text(text, + titleText: titleText != null + ? Text(titleText, + textAlign: TextAlign.center, + style: TextStyle(color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, fontSize: 24.0)) + : null, + messageText: Text(messageText, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? Colors.white : Colors.black)), + style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 16)), duration: duration, isDismissible: isDismissible, flushbarPosition: FlushbarPosition.TOP, diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 97ed234e6..90fbe4940 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -1,6 +1,7 @@ import 'package:cake_wallet/core/transaction_history.dart'; import 'package:cake_wallet/entities/balance.dart'; import 'package:cake_wallet/entities/order.dart'; +import 'package:cake_wallet/entities/push_notifications_service.dart'; import 'package:cake_wallet/monero/account.dart'; import 'package:cake_wallet/monero/monero_balance.dart'; import 'package:cake_wallet/monero/monero_transaction_info.dart'; @@ -44,7 +45,9 @@ abstract class DashboardViewModelBase with Store { this.settingsStore, this.ordersSource, this.ordersStore, - this.wyreViewModel}) { + this.wyreViewModel, + PushNotificationsService pushNotificationsService}) { + _pushNotificationsService = pushNotificationsService; filterItems = { S.current.transactions: [ FilterItem( @@ -133,6 +136,8 @@ abstract class DashboardViewModelBase with Store { return true; }); + + Future.delayed(Duration(seconds: 2), () => _pushNotificationsService.init()); } @observable @@ -227,18 +232,20 @@ abstract class DashboardViewModelBase with Store { bool get isBuyEnabled => settingsStore.isBitcoinBuyEnabled; + PushNotificationsService _pushNotificationsService; + ReactionDisposer _onMoneroAccountChangeReaction; ReactionDisposer _onMoneroBalanceChangeReaction; + @observable + bool isOutdatedElectrumWallet; + Future reconnect() async { final node = appStore.settingsStore.getCurrentNode(wallet.type); await wallet.connectToNode(node: node); } - @observable - bool isOutdatedElectrumWallet; - @action void _onWalletChange( WalletBase, diff --git a/pubspec.lock b/pubspec.lock index 3ff596074..28474d35c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,7 +70,7 @@ packages: path: "." ref: cake resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2" - url: "git@github.com:cake-tech/bech32.git" + url: "https://github.com/cake-tech/bech32.git" source: git version: "0.2.0" bip32: @@ -92,8 +92,8 @@ packages: description: path: "." ref: cake - resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7 - url: "git@github.com:cake-tech/bitcoin_flutter.git" + resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188 + url: "https://github.com/cake-tech/bitcoin_flutter.git" source: git version: "2.0.2" boolean_selector: @@ -362,6 +362,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.0-nullsafety.2" + firebase_core: + dependency: transitive + description: + name: firebase_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.3" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1+1" + firebase_messaging: + dependency: "direct main" + description: + name: firebase_messaging + url: "https://pub.dartlang.org" + source: hosted + version: "7.0.3" fixnum: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1fad1c4d9..352bb24bd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -78,6 +78,7 @@ dependencies: file_picker: ^3.0.0-nullsafety.2 unorm_dart: ^0.2.0 permission_handler: ^5.0.1+1 + firebase_messaging: ^7.0.3 dev_dependencies: flutter_test: From 8b0dcceb7b835f9a377355e66a71add33975d25c Mon Sep 17 00:00:00 2001 From: M Date: Fri, 4 Jun 2021 20:48:33 +0300 Subject: [PATCH 28/42] added background for qr image for bright theme. --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/src/screens/dashboard/widgets/address_page.dart | 4 +++- lib/src/screens/receive/receive_page.dart | 3 ++- lib/src/screens/receive/widgets/qr_widget.dart | 6 ++++-- pubspec.yaml | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 3bc5b5fb6..f916eac99 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -384,7 +384,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.1; + MARKETING_VERSION = 4.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -528,7 +528,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.1; + MARKETING_VERSION = 4.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -564,7 +564,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.1; + MARKETING_VERSION = 4.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index 05dd9fb24..51bb05a40 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/store/settings_store.dart'; +import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter/material.dart'; @@ -73,7 +74,8 @@ class AddressPage extends StatelessWidget { child: Observer(builder: (_) => QRWidget( addressListViewModel: addressListViewModel, amountTextFieldFocusNode: _cryptoAmountFocus, - isAmountFieldShow: !addressListViewModel.hasAccounts)) + isAmountFieldShow: !addressListViewModel.hasAccounts, + isBright: walletViewModel.settingsStore.currentTheme.type == ThemeType.bright)) ), Observer(builder: (_) { return addressListViewModel.hasAddressList diff --git a/lib/src/screens/receive/receive_page.dart b/lib/src/screens/receive/receive_page.dart index 718bc0c01..eed340eaa 100644 --- a/lib/src/screens/receive/receive_page.dart +++ b/lib/src/screens/receive/receive_page.dart @@ -125,7 +125,8 @@ class ReceivePage extends BasePage { child: QRWidget( addressListViewModel: addressListViewModel, isAmountFieldShow: true, - amountTextFieldFocusNode: _cryptoAmountFocus), + amountTextFieldFocusNode: _cryptoAmountFocus, + isBright: currentTheme.type == ThemeType.bright), ), Observer( builder: (_) => ListView.separated( diff --git a/lib/src/screens/receive/widgets/qr_widget.dart b/lib/src/screens/receive/widgets/qr_widget.dart index 4de923bad..47756cde7 100644 --- a/lib/src/screens/receive/widgets/qr_widget.dart +++ b/lib/src/screens/receive/widgets/qr_widget.dart @@ -13,7 +13,8 @@ class QRWidget extends StatelessWidget { QRWidget( {@required this.addressListViewModel, this.isAmountFieldShow = false, - this.amountTextFieldFocusNode}) + this.amountTextFieldFocusNode, + this.isBright}) : amountController = TextEditingController(), _formKey = GlobalKey() { amountController.addListener(() => addressListViewModel.amount = @@ -25,6 +26,7 @@ class QRWidget extends StatelessWidget { final TextEditingController amountController; final FocusNode amountTextFieldFocusNode; final GlobalKey _formKey; + final bool isBright; @override Widget build(BuildContext context) { @@ -55,7 +57,7 @@ class QRWidget extends StatelessWidget { ), child: QrImage( data: addressListViewModel.uri.toString(), - backgroundColor: Colors.transparent, + backgroundColor: isBright ? Colors.black : Colors.white, foregroundColor: Theme.of(context).accentTextTheme. display3.backgroundColor, ), diff --git a/pubspec.yaml b/pubspec.yaml index e57cafb5b..863cd68bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Cake Wallet. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 4.2.1+50 +version: 4.2.2+51 environment: sdk: ">=2.7.0 <3.0.0" From 080dd5c37f311be8f99ad82bcbef50a82b95a9e8 Mon Sep 17 00:00:00 2001 From: M Date: Fri, 4 Jun 2021 21:04:59 +0300 Subject: [PATCH 29/42] Changed project version to 4.2.3 --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f916eac99..d88278ddf 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 42; + CURRENT_PROJECT_VERSION = 43; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -384,7 +384,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.2; + MARKETING_VERSION = 4.2.3; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 42; + CURRENT_PROJECT_VERSION = 43; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -528,7 +528,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.2; + MARKETING_VERSION = 4.2.3; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 42; + CURRENT_PROJECT_VERSION = 43; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -564,7 +564,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.2.2; + MARKETING_VERSION = 4.2.3; PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/pubspec.yaml b/pubspec.yaml index 863cd68bc..6aac98f85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Cake Wallet. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 4.2.2+51 +version: 4.2.3+52 environment: sdk: ">=2.7.0 <3.0.0" From ad4022ac10612dd9a8d5f37d78dc211b9638df50 Mon Sep 17 00:00:00 2001 From: M Date: Mon, 7 Jun 2021 11:15:36 +0300 Subject: [PATCH 30/42] Fixed background color for qr image on receive screen for dark theme. --- lib/src/screens/receive/widgets/qr_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/screens/receive/widgets/qr_widget.dart b/lib/src/screens/receive/widgets/qr_widget.dart index 47756cde7..169a27124 100644 --- a/lib/src/screens/receive/widgets/qr_widget.dart +++ b/lib/src/screens/receive/widgets/qr_widget.dart @@ -57,7 +57,7 @@ class QRWidget extends StatelessWidget { ), child: QrImage( data: addressListViewModel.uri.toString(), - backgroundColor: isBright ? Colors.black : Colors.white, + backgroundColor: isBright ? Colors.black : Colors.transparent, foregroundColor: Theme.of(context).accentTextTheme. display3.backgroundColor, ), From 6ac8dabf87a8402bbc548367251680a83f077564 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 7 Jun 2021 14:28:53 +0300 Subject: [PATCH 31/42] CAKE-306 | fixed onEnabled() method in the moonpay_buy_provider.dart --- lib/buy/moonpay/moonpay_buy_provider.dart | 18 +++++------------- lib/di.dart | 10 ++++------ lib/store/settings_store.dart | 10 ++++------ 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index 22b349c79..65effe483 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -23,7 +23,7 @@ class MoonPayBuyProvider extends BuyProvider { static const _currenciesSuffix = '/v3/currencies'; static const _quoteSuffix = '/buy_quote'; static const _transactionsSuffix = '/v1/transactions'; - static const _countrySuffix = '/v3/countries'; + static const _ipAddressSuffix = '/v4/ip_address'; static const _apiKey = secrets.moonPayApiKey; static const _secretKey = secrets.moonPaySecretKey; @@ -125,23 +125,15 @@ class MoonPayBuyProvider extends BuyProvider { ); } - static Future onEnabled(String deviceCountryCode) async { - final url = _apiUrl + _countrySuffix; + static Future onEnabled() async { + final url = _apiUrl + _ipAddressSuffix + '?apiKey=' + _apiKey; var isBuyEnable = false; final response = await get(url); try { - final responseJSON = json.decode(response.body) as List; - - for (var element in responseJSON) { - final countryMap = element as Map; - final countryCode = countryMap['alpha2'] as String; - if (countryCode == deviceCountryCode) { - isBuyEnable = countryMap['isBuyAllowed'] as bool; - break; - } - } + final responseJSON = json.decode(response.body) as Map; + isBuyEnable = responseJSON['isBuyAllowed'] as bool; } catch (e) { isBuyEnable = false; print(e.toString()); diff --git a/lib/di.dart b/lib/di.dart index b5bb7bfd3..a4e922f7c 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -155,19 +155,17 @@ Future setup( (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - /*var isMoonPayEnabled = false; + var isMoonPayEnabled = false; try { - final locale = await Devicelocale.currentLocale; - final deviceCountryCode = locale.split('_').last; - isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(); } catch (e) { isMoonPayEnabled = false; print(e.toString()); - }*/ + } final settingsStore = await SettingsStoreBase.load( nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: true); + isMoonPayEnabled: isMoonPayEnabled); if (_isSetupFinished) { return; diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 207a731c9..206c3141b 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -253,20 +253,18 @@ abstract class SettingsStoreBase with Store { (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - /*var isMoonPayEnabled = false; + var isMoonPayEnabled = false; try { - final locale = await Devicelocale.currentLocale; - final deviceCountryCode = locale.split('_').last; - isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode); + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(); } catch (e) { isMoonPayEnabled = false; print(e.toString()); - }*/ + } final settings = await SettingsStoreBase.load( nodeSource: nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: true, + isMoonPayEnabled: isMoonPayEnabled, initialBalanceDisplayMode: initialBalanceDisplayMode, initialFiatCurrency: initialFiatCurrency, initialMoneroTransactionPriority: initialMoneroTransactionPriority, From d5d1afd89b62344332e0c2473d7154267041d41f Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 7 Jun 2021 16:40:25 +0300 Subject: [PATCH 32/42] CAKE-306 | merged main branch into current; added _fetchBuyItems() method to buy_view_model.dart; deleted isMoonPayEnabled parameter from settings_store.dart --- lib/di.dart | 14 +-------- lib/entities/push_notifications_service.dart | 2 +- lib/store/settings_store.dart | 16 ---------- lib/view_model/buy/buy_view_model.dart | 31 +++++++++++++------- res/values/strings_hr.arb | 2 ++ res/values/strings_it.arb | 2 ++ 6 files changed, 27 insertions(+), 40 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index eda81d899..0de43a76e 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -1,11 +1,9 @@ import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart'; import 'package:cake_wallet/bitcoin/litecoin_wallet_service.dart'; -import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; import 'package:cake_wallet/core/backup_service.dart'; import 'package:cake_wallet/core/wallet_service.dart'; import 'package:cake_wallet/entities/biometric_auth.dart'; import 'package:cake_wallet/entities/contact_record.dart'; -import 'package:cake_wallet/entities/load_current_wallet.dart'; import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/entities/transaction_info.dart'; @@ -92,7 +90,6 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart'; import 'package:cake_wallet/view_model/wallet_restore_view_model.dart'; import 'package:cake_wallet/view_model/wallet_seed_view_model.dart'; import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/widgets.dart'; import 'package:get_it/get_it.dart'; import 'package:hive/hive.dart'; @@ -156,17 +153,8 @@ Future setup( (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - var isMoonPayEnabled = false; - try { - isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(); - } catch (e) { - isMoonPayEnabled = false; - print(e.toString()); - } - final settingsStore = await SettingsStoreBase.load( - nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: isMoonPayEnabled); + nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled); if (_isSetupFinished) { return; diff --git a/lib/entities/push_notifications_service.dart b/lib/entities/push_notifications_service.dart index 5fe69153c..5fb68bae4 100644 --- a/lib/entities/push_notifications_service.dart +++ b/lib/entities/push_notifications_service.dart @@ -21,7 +21,7 @@ class PushNotificationsService { _firebaseMessaging.requestNotificationPermissions(); _firebaseMessaging.configure( onMessage: (message) async { - Map alert = {}; + Map alert = {}; String msg = ''; String title = ''; diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 206c3141b..66124a108 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/bitcoin_transaction_priority.dart'; -import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/entities/transaction_priority.dart'; import 'package:cake_wallet/themes/theme_base.dart'; @@ -9,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; import 'package:package_info/package_info.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -41,7 +39,6 @@ abstract class SettingsStoreBase with Store { @required TransactionPriority initialBitcoinTransactionPriority, @required TransactionPriority initialMoneroTransactionPriority, @required this.isBitcoinBuyEnabled, - @required this.isMoonPayEnabled, this.actionlistDisplayMode}) { fiatCurrency = initialFiatCurrency; balanceDisplayMode = initialBalanceDisplayMode; @@ -150,12 +147,9 @@ abstract class SettingsStoreBase with Store { bool isBitcoinBuyEnabled; - bool isMoonPayEnabled; - static Future load( {@required Box nodeSource, @required bool isBitcoinBuyEnabled, - @required bool isMoonPayEnabled, FiatCurrency initialFiatCurrency = FiatCurrency.usd, MoneroTransactionPriority initialMoneroTransactionPriority = MoneroTransactionPriority.slow, @@ -227,7 +221,6 @@ abstract class SettingsStoreBase with Store { }, appVersion: packageInfo.version, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: isMoonPayEnabled, initialFiatCurrency: currentFiatCurrency, initialBalanceDisplayMode: currentBalanceDisplayMode, initialSaveRecipientAddress: shouldSaveRecipientAddress, @@ -253,18 +246,9 @@ abstract class SettingsStoreBase with Store { (secrets.wyreApiKey?.isNotEmpty ?? false) && (secrets.wyreAccountId?.isNotEmpty ?? false); - var isMoonPayEnabled = false; - try { - isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(); - } catch (e) { - isMoonPayEnabled = false; - print(e.toString()); - } - final settings = await SettingsStoreBase.load( nodeSource: nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled, - isMoonPayEnabled: isMoonPayEnabled, initialBalanceDisplayMode: initialBalanceDisplayMode, initialFiatCurrency: initialFiatCurrency, initialMoneroTransactionPriority: initialMoneroTransactionPriority, diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 68afb9577..95739edd0 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -21,15 +21,9 @@ class BuyViewModel = BuyViewModelBase with _$BuyViewModel; abstract class BuyViewModelBase with Store { BuyViewModelBase(this.ordersSource, this.ordersStore, this.settingsStore, this.buyAmountViewModel, {@required this.wallet}) { - providerList = [WyreBuyProvider(wallet: wallet)]; - if (settingsStore.isMoonPayEnabled ?? false) { - providerList.add(MoonPayBuyProvider(wallet: wallet)); - } + _fetchBuyItems(); - items = providerList.map((provider) => - BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel)) - .toList(); isRunning = false; isDisabled = true; isShowProviderButtons = false; @@ -41,9 +35,6 @@ abstract class BuyViewModelBase with Store { final BuyAmountViewModel buyAmountViewModel; final WalletBase wallet; - @observable - List providerList; - @observable BuyProvider selectedProvider; @@ -96,4 +87,24 @@ abstract class BuyViewModelBase with Store { buyAmountViewModel.amount = ''; selectedProvider = null; } + + Future _fetchBuyItems() async { + final List _providerList = [WyreBuyProvider(wallet: wallet)]; + + var isMoonPayEnabled = false; + try { + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(); + } catch (e) { + isMoonPayEnabled = false; + print(e.toString()); + } + + if (isMoonPayEnabled) { + _providerList.add(MoonPayBuyProvider(wallet: wallet)); + } + + items = _providerList.map((provider) => + BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel)) + .toList(); + } } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 0eb24134c..1d3233d0e 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -478,5 +478,7 @@ "apk_update" : "APK ažuriranje", + "buy_bitcoin" : "Kupite Bitcoin", + "buy_with" : "Kupite s", "moonpay_alert_text" : "Vrijednost iznosa mora biti veća ili jednaka ${minAmount} ${fiatCurrency}" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 7f8dc6499..00d88efd8 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -478,5 +478,7 @@ "apk_update" : "Aggiornamento APK", + "buy_bitcoin" : "Acquista Bitcoin", + "buy_with" : "Acquista con", "moonpay_alert_text" : "Il valore dell'importo deve essere maggiore o uguale a ${minAmount} ${fiatCurrency}" } \ No newline at end of file From fcb1c891f6f845f49661dce5ed5a012de3386ff4 Mon Sep 17 00:00:00 2001 From: M Date: Mon, 7 Jun 2021 17:01:21 +0300 Subject: [PATCH 33/42] Changed web client for moonpay. --- lib/src/screens/buy/pre_order_page.dart | 38 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index cf6cca586..54eeebb6f 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -20,6 +20,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/src/widgets/trail_button.dart'; import 'package:mobx/mobx.dart'; +import 'package:url_launcher/url_launcher.dart'; class PreOrderPage extends BasePage { PreOrderPage({@required this.buyViewModel}) @@ -221,20 +222,7 @@ class PreOrderPage extends BasePage { EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSection: Observer(builder: (_) { return LoadingPrimaryButton( - onPressed: buyViewModel.isRunning - ? null - : () async { - buyViewModel.isRunning = true; - final url = - await buyViewModel.fetchUrl(); - if (url.isNotEmpty) { - await Navigator.of(context) - .pushNamed(Routes.buyWebView, - arguments: [url, buyViewModel]); - buyViewModel.reset(); - } - buyViewModel.isRunning = false; - }, + onPressed: () => onPresentProvider(context: context), text: buyViewModel.selectedProvider == null ? S.of(context).buy : S.of(context).buy_with + @@ -275,4 +263,26 @@ class PreOrderPage extends BasePage { ? buyViewModel.isDisabled = false : buyViewModel.isDisabled = true; } + + Future onPresentProvider({BuildContext context}) async { + if (buyViewModel.isRunning) { + return; + } + + buyViewModel.isRunning = true; + final url = await buyViewModel.fetchUrl(); + + if (url.isNotEmpty) { + if (buyViewModel.selectedProvider is MoonPayBuyProvider) { + if (await canLaunch(url)) await launch(url); + } else { + await Navigator.of(context) + .pushNamed(Routes.buyWebView, + arguments: [url, buyViewModel]); + } + } + + buyViewModel.reset(); + buyViewModel.isRunning = false; + } } \ No newline at end of file From 30e1fa81c751c807dd9be13c594cf27ffa787b9d Mon Sep 17 00:00:00 2001 From: M Date: Mon, 7 Jun 2021 21:44:58 +0300 Subject: [PATCH 34/42] Changed warning text for receive screen. --- lib/src/screens/dashboard/dashboard_page.dart | 2 +- res/values/strings_de.arb | 4 ++-- res/values/strings_en.arb | 4 ++-- res/values/strings_es.arb | 4 ++-- res/values/strings_hi.arb | 4 ++-- res/values/strings_hr.arb | 4 ++-- res/values/strings_it.arb | 4 ++-- res/values/strings_ja.arb | 4 ++-- res/values/strings_ko.arb | 4 ++-- res/values/strings_nl.arb | 4 ++-- res/values/strings_pl.arb | 4 ++-- res/values/strings_pt.arb | 4 ++-- res/values/strings_ru.arb | 4 ++-- res/values/strings_uk.arb | 4 ++-- res/values/strings_zh.arb | 4 ++-- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index d98751a57..e61c59887 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -184,7 +184,7 @@ class DashboardPage extends BasePage { return AlertWithOneAction( alertTitle: S.of(context).pre_seed_title, alertContent: - S.of(context).outdated_electrum_wallet_desceription, + S.of(context).outdated_electrum_wallet_description, buttonText: S.of(context).understand, buttonAction: () => Navigator.of(context).pop()); }); diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index a89e69170..589019014 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser", - "outdated_electrum_wallet_desceription" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", + "outdated_electrum_wallet_description" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", "understand" : "Ich verstehe", "apk_update" : "APK Update", - "outdated_electrum_wallet_receive_warning": "WARNUNG\nWenn diese Brieftasche einen Seed von 12 Wörtern hat, der in Cake Wallet erstellt wurde, zahlen Sie KEINE Bitcoins in diese Brieftasche ein. Ihr Bitcoin kann gestohlen werden. Erstellen Sie eine neue Brieftasche und verschieben Sie Ihr Geld SOFORT in die neue Brieftasche.", + "outdated_electrum_wallet_receive_warning": "Wenn diese Brieftasche einen 12-Wort-Seed hat und in Cake erstellt wurde, zahlen Sie KEINE Bitcoins in diese Brieftasche ein. Alle auf diese Wallet übertragenen BTC können verloren gehen. Erstellen Sie eine neue 24-Wort-Wallet (tippen Sie auf das Menü oben rechts, wählen Sie Wallets, wählen Sie Create New Wallet und dann Bitcoin) und verschieben Sie Ihre BTC SOFORT dorthin. Neue (24 Wörter) BTC-Wallets von Cake sind sicher", "do_not_show_me": "Zeig mir das nicht noch einmal" } \ No newline at end of file diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index ecc562f9d..ced47d339 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", - "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", + "outdated_electrum_wallet_description" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", "understand" : "I understand", "apk_update" : "APK update", - "outdated_electrum_wallet_receive_warning": "WARNING\nIf this wallet has a seed of 12 words which was created in Cake Wallet, DO NOT deposit Bitcoin in this wallet. Your Bitcoin can be at risk of getting stolen. Create a new wallet, and move your funds to the new wallet IMMEDIATELY.", + "outdated_electrum_wallet_receive_warning": "If this wallet has a 12-word seed and was created in Cake, DO NOT deposit Bitcoin into this wallet. Any BTC transferred to this wallet may be lost. Create a new 24-word wallet (tap the menu at the top right, select Wallets, choose Create New Wallet, then select Bitcoin) and IMMEDIATELY move your BTC there. New (24-word) BTC wallets from Cake are secure", "do_not_show_me": "Do not show me this again" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 135be2c80..cef0b6d60 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin", - "outdated_electrum_wallet_desceription" : "Las nuevas carteras de Bitcoin creadas en Cake ahora tienen una semilla de 24 palabras. Es obligatorio que cree una nueva billetera de Bitcoin y transfiera todos sus fondos a la nueva billetera de 24 palabras, y deje de usar billeteras con una semilla de 12 palabras. Haga esto de inmediato para asegurar sus fondos.", + "outdated_electrum_wallet_description" : "Las nuevas carteras de Bitcoin creadas en Cake ahora tienen una semilla de 24 palabras. Es obligatorio que cree una nueva billetera de Bitcoin y transfiera todos sus fondos a la nueva billetera de 24 palabras, y deje de usar billeteras con una semilla de 12 palabras. Haga esto de inmediato para asegurar sus fondos.", "understand" : "Entiendo", "apk_update" : "Actualización de APK", - "outdated_electrum_wallet_receive_warning": "ADVERTENCIA\nSi esta billetera tiene una semilla de 12 palabras que se creó en Cake Wallet, NO DEposite Bitcoin en esta billetera. Su Bitcoin puede estar en riesgo de ser robado. Cree una nueva billetera y mueva sus fondos a la nueva billetera INMEDIATAMENTE.", + "outdated_electrum_wallet_receive_warning": "Si esta billetera tiene una semilla de 12 palabras y se creó en Cake, NO deposite Bitcoin en esta billetera. Cualquier BTC transferido a esta billetera se puede perder. Cree una nueva billetera de 24 palabras (toque el menú en la parte superior derecha, seleccione Monederos, elija Crear nueva billetera, luego seleccione Bitcoin) e INMEDIATAMENTE mueva su BTC allí. Las nuevas carteras BTC (24 palabras) de Cake son seguras", "do_not_show_me": "no me muestres esto otra vez" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 47ecbaa98..909ee522e 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें", - "outdated_electrum_wallet_desceription" : "केक में बनाए गए नए बिटकॉइन वॉलेट में अब 24-शब्द का बीज है। यह अनिवार्य है कि आप एक नया बिटकॉइन वॉलेट बनाएं और अपने सभी फंड को नए 24-शब्द वाले वॉलेट में स्थानांतरित करें, और 12-शब्द बीज वाले वॉलेट का उपयोग करना बंद करें। कृपया अपने धन को सुरक्षित करने के लिए इसे तुरंत करें।", + "outdated_electrum_wallet_description" : "केक में बनाए गए नए बिटकॉइन वॉलेट में अब 24-शब्द का बीज है। यह अनिवार्य है कि आप एक नया बिटकॉइन वॉलेट बनाएं और अपने सभी फंड को नए 24-शब्द वाले वॉलेट में स्थानांतरित करें, और 12-शब्द बीज वाले वॉलेट का उपयोग करना बंद करें। कृपया अपने धन को सुरक्षित करने के लिए इसे तुरंत करें।", "understand" : "मुझे समझ", "apk_update" : "APK अद्यतन", - "outdated_electrum_wallet_receive_warning": "चेतावनी\nयदि इस वॉलेट में 12 शब्दों का बीज है जो केक वॉलेट में बनाया गया था, तो इस वॉलेट में बिटकॉइन जमा न करें। आपका बिटकॉइन चोरी होने का खतरा हो सकता है। एक नया वॉलेट बनाएं, और अपने फंड को तुरंत नए वॉलेट में ले जाएं।", + "outdated_electrum_wallet_receive_warning": "अगर इस वॉलेट में 12 शब्दों का बीज है और इसे केक में बनाया गया है, तो इस वॉलेट में बिटकॉइन जमा न करें। इस वॉलेट में स्थानांतरित किया गया कोई भी बीटीसी खो सकता है। एक नया 24-शब्द वॉलेट बनाएं (ऊपर दाईं ओर स्थित मेनू पर टैप करें, वॉलेट चुनें, नया वॉलेट बनाएं चुनें, फिर बिटकॉइन चुनें) और तुरंत अपना बीटीसी वहां ले जाएं। केक से नए (24-शब्द) बीटीसी वॉलेट सुरक्षित हैं", "do_not_show_me": "मुझे यह फिर न दिखाएं" } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index dc6fbe4aa..682cfd5f8 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Trenutno podržavamo samo kupnju Bitcoina. Da biste kupili Bitcoin, izradite ili prijeđite na svoj Bitcoin novčanik", - "outdated_electrum_wallet_desceription" : "Novi Bitcoin novčanici stvoreni u Cakeu sada imaju sjeme od 24 riječi. Obavezno je stvoriti novi Bitcoin novčanik i prenijeti sva svoja sredstva u novi novčanik od 24 riječi te prestati koristiti novčanike s sjemenkom od 12 riječi. Učinite to odmah kako biste osigurali svoja sredstva.", + "outdated_electrum_wallet_description" : "Novi Bitcoin novčanici stvoreni u Cakeu sada imaju sjeme od 24 riječi. Obavezno je stvoriti novi Bitcoin novčanik i prenijeti sva svoja sredstva u novi novčanik od 24 riječi te prestati koristiti novčanike s sjemenkom od 12 riječi. Učinite to odmah kako biste osigurali svoja sredstva.", "understand" : "Razumijem", "apk_update" : "APK ažuriranje", - "outdated_electrum_wallet_receive_warning": "UPOZORENJE\nAko ovaj novčanik sadrži izvor od 12 riječi koji je stvoren u novčaniku Cake, NEMOJTE polagati Bitcoin u ovaj novčanik. Vaš Bitcoin može biti u opasnosti od krađe. Stvorite novi novčanik i ODMAH premjestite sredstva u novi novčanik.", + "outdated_electrum_wallet_receive_warning": "Ako ovaj novčanik sadrži sjeme od 12 riječi i stvoren je u Torti, NEMOJTE polagati Bitcoin u ovaj novčanik. Bilo koji BTC prebačen u ovaj novčanik može se izgubiti. Stvorite novi novčanik od 24 riječi (taknite izbornik u gornjem desnom dijelu, odaberite Novčanici, odaberite Stvori novi novčanik, a zatim odaberite Bitcoin) i ODMAH premjestite svoj BTC tamo. Novi BTC novčanici (s 24 riječi) tvrtke Cake sigurni su", "do_not_show_me": "Ne pokazuj mi ovo više" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 861732fc4..d883891ea 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Attualmente supportiamo solo l'acquisto di Bitcoin. Per acquistare Bitcoin, crea o passa al tuo portafoglio Bitcoin", - "outdated_electrum_wallet_desceription" : "I nuovi portafogli Bitcoin creati in Cake ora hanno un seme di 24 parole. È obbligatorio creare un nuovo portafoglio Bitcoin e trasferire tutti i fondi nel nuovo portafoglio di 24 parole e smettere di usare portafogli con un seme di 12 parole. Ti preghiamo di farlo immediatamente per proteggere i tuoi fondi.", + "outdated_electrum_wallet_description" : "I nuovi portafogli Bitcoin creati in Cake ora hanno un seme di 24 parole. È obbligatorio creare un nuovo portafoglio Bitcoin e trasferire tutti i fondi nel nuovo portafoglio di 24 parole e smettere di usare portafogli con un seme di 12 parole. Ti preghiamo di farlo immediatamente per proteggere i tuoi fondi.", "understand" : "Capisco", "apk_update" : "Aggiornamento APK", - "outdated_electrum_wallet_receive_warning": "ATTENZIONE\nSe questo portafoglio ha un seme di 12 parole creato in Cake Wallet, NON depositare Bitcoin in questo portafoglio. Il tuo Bitcoin può essere a rischio di essere rubato. Crea un nuovo portafoglio e sposta i tuoi fondi nel nuovo portafoglio IMMEDIATAMENTE.", + "outdated_electrum_wallet_receive_warning": "Se questo portafoglio ha un seme di 12 parole ed è stato creato in Cake, NON depositare Bitcoin in questo portafoglio. Qualsiasi BTC trasferito su questo portafoglio potrebbe andare perso. Crea un nuovo portafoglio di 24 parole (tocca il menu in alto a destra, seleziona Portafogli, scegli Crea nuovo portafoglio, quindi seleziona Bitcoin) e sposta IMMEDIATAMENTE lì il tuo BTC. I nuovi portafogli BTC (24 parole) di Cake sono sicuri", "do_not_show_me": "Non mostrarmelo di nuovo" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 320454372..ff299e3e7 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください", - "outdated_electrum_wallet_desceription" : "Cakeで作成された新しいビットコインウォレットには、24ワードのシードがあります。 新しいビットコインウォレットを作成し、すべての資金を新しい24ワードのウォレットに転送し、12ワードのシードを持つウォレットの使用を停止することが必須です。 あなたの資金を確保するためにこれをすぐに行ってください。", + "outdated_electrum_wallet_description" : "Cakeで作成された新しいビットコインウォレットには、24ワードのシードがあります。 新しいビットコインウォレットを作成し、すべての資金を新しい24ワードのウォレットに転送し、12ワードのシードを持つウォレットの使用を停止することが必須です。 あなたの資金を確保するためにこれをすぐに行ってください。", "understand" : "わかります", "apk_update" : "APKアップデート", - "outdated_electrum_wallet_receive_warning": "警告\nこのウォレットにCake Walletで作成された12ワードのシードがある場合、このウォレットにビットコインを入金しないでください。 ビットコインが盗まれる危険性があります。 新しいウォレットを作成し、すぐに新しいウォレットに資金を移動してください。", + "outdated_electrum_wallet_receive_warning": "このウォレットに 12 ワードのシードがあり、Cake で作成された場合、このウォレットにビットコインを入金しないでください。 このウォレットに転送された BTC は失われる可能性があります。 新しい 24 ワードのウォレットを作成し (右上のメニューをタップし、[ウォレット]、[新しいウォレットの作成]、[ビットコイン] の順に選択)、すぐに BTC をそこに移動します。 Cake の新しい (24 ワード) BTC ウォレットは安全です", "do_not_show_me": "また僕にこれを見せないでください" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index d1af5c1e2..ee0fe69bd 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오", - "outdated_electrum_wallet_desceription" : "Cake에서 생성 된 새로운 비트 코인 지갑에는 이제 24 단어 시드가 있습니다. 새로운 비트 코인 지갑을 생성하고 모든 자금을 새로운 24 단어 지갑으로 이체하고 12 단어 시드가있는 지갑 사용을 중지해야합니다. 자금을 확보하려면 즉시이 작업을 수행하십시오.", + "outdated_electrum_wallet_description" : "Cake에서 생성 된 새로운 비트 코인 지갑에는 이제 24 단어 시드가 있습니다. 새로운 비트 코인 지갑을 생성하고 모든 자금을 새로운 24 단어 지갑으로 이체하고 12 단어 시드가있는 지갑 사용을 중지해야합니다. 자금을 확보하려면 즉시이 작업을 수행하십시오.", "understand" : "이해 했어요", "apk_update" : "APK 업데이트", - "outdated_electrum_wallet_receive_warning": "경고\n이 지갑에 Cake Wallet에서 생성 된 12 단어의 시드가있는 경우이 지갑에 Bitcoin을 입금하지 마십시오. 귀하의 비트 코인은 도난 당할 위험이 있습니다. 새 지갑을 만들고 즉시 새 지갑으로 자금을 이동하십시오.", + "outdated_electrum_wallet_receive_warning": "이 지갑에 12 단어 시드가 있고 Cake에서 생성 된 경우이 지갑에 비트 코인을 입금하지 마십시오. 이 지갑으로 전송 된 모든 BTC는 손실 될 수 있습니다. 새로운 24 단어 지갑을 생성하고 (오른쪽 상단의 메뉴를 탭하고 지갑을 선택한 다음 새 지갑 생성을 선택한 다음 비트 코인을 선택하십시오) 즉시 BTC를 그곳으로 이동하십시오. Cake의 새로운 (24 단어) BTC 지갑은 안전합니다", "do_not_show_me": "나를 다시 표시하지 않음" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index c1322c2ca..94cb121ac 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin. Om Bitcoin te kopen, moet u uw Bitcoin-portemonnee aanmaken of naar uw Bitcoin-portemonnee overschakelen", - "outdated_electrum_wallet_desceription" : "Nieuwe Bitcoin-portefeuilles die in Cake zijn gemaakt, hebben nu een zaadje van 24 woorden. Het is verplicht dat u een nieuwe Bitcoin-portemonnee maakt en al uw geld overmaakt naar de nieuwe portemonnee van 24 woorden, en stopt met het gebruik van wallets met een seed van 12 woorden. Doe dit onmiddellijk om uw geld veilig te stellen.", + "outdated_electrum_wallet_description" : "Nieuwe Bitcoin-portefeuilles die in Cake zijn gemaakt, hebben nu een zaadje van 24 woorden. Het is verplicht dat u een nieuwe Bitcoin-portemonnee maakt en al uw geld overmaakt naar de nieuwe portemonnee van 24 woorden, en stopt met het gebruik van wallets met een seed van 12 woorden. Doe dit onmiddellijk om uw geld veilig te stellen.", "understand" : "Ik begrijp het", "apk_update" : "APK-update", - "outdated_electrum_wallet_receive_warning": "WAARSCHUWING\nAls deze portemonnee een seed van 12 woorden heeft die is gemaakt in Cake Wallet, stort dan GEEN Bitcoin in deze portemonnee. Uw Bitcoin kan het risico lopen te worden gestolen. Maak een nieuwe portemonnee en verplaats uw geld ONMIDDELLIJK naar de nieuwe portemonnee.", + "outdated_electrum_wallet_receive_warning": "Als deze portemonnee een seed van 12 woorden heeft en is gemaakt in Cake, stort dan GEEN Bitcoin in deze portemonnee. Elke BTC die naar deze portemonnee is overgebracht, kan verloren gaan. Maak een nieuwe portemonnee van 24 woorden (tik op het menu rechtsboven, selecteer Portefeuilles, kies Nieuwe portemonnee maken en selecteer vervolgens Bitcoin) en verplaats je BTC ONMIDDELLIJK daar. Nieuwe (24-woorden) BTC-portefeuilles van Cake zijn veilig", "do_not_show_me": "laat me dit niet opnieuw zien" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index dd45292b7..39af76e06 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoinów. Aby kupić Bitcoin, utwórz lub przełącz się na swój portfel Bitcoin", - "outdated_electrum_wallet_desceription" : "Nowe portfele Bitcoin utworzone w Cake mają teraz ziarno składające się z 24 słów. Konieczne jest utworzenie nowego portfela Bitcoin i przeniesienie wszystkich środków do nowego portfela na 24 słowa oraz zaprzestanie korzystania z portfeli z zalążkiem na 12 słów. Zrób to natychmiast, aby zabezpieczyć swoje fundusze.", + "outdated_electrum_wallet_description" : "Nowe portfele Bitcoin utworzone w Cake mają teraz ziarno składające się z 24 słów. Konieczne jest utworzenie nowego portfela Bitcoin i przeniesienie wszystkich środków do nowego portfela na 24 słowa oraz zaprzestanie korzystania z portfeli z zalążkiem na 12 słów. Zrób to natychmiast, aby zabezpieczyć swoje fundusze.", "understand" : "Rozumiem", "apk_update" : "Aktualizacja APK", - "outdated_electrum_wallet_receive_warning": "OSTRZEŻENIE\nJeśli ten portfel zawiera ziarno 12 słów, które zostało utworzone w portfelu Cake, NIE Wpłacaj Bitcoinów do tego portfela. Twój Bitcoin może być zagrożony kradzieżą. Utwórz nowy portfel i NATYCHMIAST przenieś swoje środki do nowego portfela.", + "outdated_electrum_wallet_receive_warning": "Jeśli ten portfel ma 12-wyrazowy seed i został utworzony w Cake, NIE Wpłacaj Bitcoina do tego portfela. Wszelkie BTC przeniesione do tego portfela mogą zostać utracone. Utwórz nowy portfel z 24 słowami (dotknij menu w prawym górnym rogu, wybierz Portfele, wybierz Utwórz nowy portfel, a następnie Bitcoin) i NATYCHMIAST przenieś tam swoje BTC. Nowe (24 słowa) portfele BTC firmy Cake są bezpieczne", "do_not_show_me": "Nie pokazuj mi tego ponownie" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index e739f1553..3bca970c5 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin. Para comprar Bitcoin, crie ou mude para sua carteira Bitcoin", - "outdated_electrum_wallet_desceription" : "As novas carteiras Bitcoin criadas no Cake agora têm uma semente de 24 palavras. É obrigatório que você crie uma nova carteira Bitcoin e transfira todos os seus fundos para a nova carteira de 24 palavras, e pare de usar carteiras com semente de 12 palavras. Faça isso imediatamente para garantir seus fundos.", + "outdated_electrum_wallet_description" : "As novas carteiras Bitcoin criadas no Cake agora têm uma semente de 24 palavras. É obrigatório que você crie uma nova carteira Bitcoin e transfira todos os seus fundos para a nova carteira de 24 palavras, e pare de usar carteiras com semente de 12 palavras. Faça isso imediatamente para garantir seus fundos.", "understand" : "Entendo", "apk_update" : "Atualização de APK", - "outdated_electrum_wallet_receive_warning": "AVISO\nSe esta carteira tiver uma semente de 12 palavras que foi criada na Carteira Cake, NÃO deposite Bitcoin nesta carteira. Seu Bitcoin pode correr o risco de ser roubado. Crie uma nova carteira e mova seus fundos para a nova carteira IMEDIATAMENTE.", + "outdated_electrum_wallet_receive_warning": "Se esta carteira tiver uma semente de 12 palavras e foi criada no Cake, NÃO deposite Bitcoin nesta carteira. Qualquer BTC transferido para esta carteira pode ser perdido. Crie uma nova carteira de 24 palavras (toque no menu no canto superior direito, selecione Carteiras, escolha Criar Nova Carteira e selecione Bitcoin) e mova IMEDIATAMENTE seu BTC para lá. As novas carteiras BTC (24 palavras) da Cake são seguras", "do_not_show_me": "não me mostre isso novamente" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index e5a08952e..e1d25b4f2 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек", - "outdated_electrum_wallet_desceription" : "Новые биткойн-кошельки, созданные в Cake, теперь содержат мнемоническую фразу из 24 слов. Вы обязательно должны создать новый биткойн-кошелек и перевести все свои средства в новый кошелек из 24 слов, а также прекратить использование кошельков с мнемонической фразой из 12 слов. Пожалуйста, сделайте это немедленно, чтобы обезопасить свои средства.", + "outdated_electrum_wallet_description" : "Новые биткойн-кошельки, созданные в Cake, теперь содержат мнемоническую фразу из 24 слов. Вы обязательно должны создать новый биткойн-кошелек и перевести все свои средства в новый кошелек из 24 слов, а также прекратить использование кошельков с мнемонической фразой из 12 слов. Пожалуйста, сделайте это немедленно, чтобы обезопасить свои средства.", "understand" : "Понятно", "apk_update" : "Обновление APK", - "outdated_electrum_wallet_receive_warning": "ПРЕДУПРЕЖДЕНИЕ\nЕсли этот кошелек был создан в Cake Wallet и имеет мнемоническую фразу из 12 слов, НЕ вносите биткойны в этот кошелек. Ваши биткойны могут быть украдены. Создайте новый кошелек и НЕМЕДЛЕННО переместите свои средства в новый кошелек.", + "outdated_electrum_wallet_receive_warning": "Если этот кошелек имеет мнемоническую фразу из 12 слов и был создан в Cake, НЕ переводите биткойны на этот кошелек. Любые BTC, переведенные на этот кошелек, могут быть потеряны. Создайте новый кошелек с мнемоническои фразы из 24 слов (коснитесь меню в правом верхнем углу, выберите «Кошельки», выберите «Создать новый кошелек», затем выберите «Bitcoin») и НЕМЕДЛЕННО переведите туда свои BTC. Новые (24 слова) кошельки BTC от Cake безопасны", "do_not_show_me": "Не показывай мне это больше" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 9828d12a1..41317aa7a 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець", - "outdated_electrum_wallet_desceription" : "Нові біткойн-гаманці, створені в Cake, тепер містять мнемонічну фразу з 24 слів. Обов’язково стовріть новий біткойн-гаманець, переведіть всі кошти на новий гаманець із 24 слів і припиніть використання гаманців із мнемонічною фразою з 12 слів. Зробіть це негайно, щоб убезпечити свої кошти.", + "outdated_electrum_wallet_description" : "Нові біткойн-гаманці, створені в Cake, тепер містять мнемонічну фразу з 24 слів. Обов’язково стовріть новий біткойн-гаманець, переведіть всі кошти на новий гаманець із 24 слів і припиніть використання гаманців із мнемонічною фразою з 12 слів. Зробіть це негайно, щоб убезпечити свої кошти.", "understand" : "Зрозуміло", "apk_update" : "Оновлення APK", - "outdated_electrum_wallet_receive_warning": "ПОПЕРЕДЖЕННЯ\nЯкщо цей гаманець має мнемонічну фразу із 12 слів, та був створенний в Cake Wallet, НЕ переводьте біткойни в цей гаманець. Ваші біткойни ризикують бути вкраденими. Створіть новий гаманець і НЕГАЙНО переведіть свої біткоїни на новий гаманець.", + "outdated_electrum_wallet_receive_warning": "Якщо цей гаманець має мнемонічну фразу з 12 слів і був створений у Cake, НЕ переводьте біткойни на цей гаманець. Будь-які BTC, переведений на цей гаманець, можуть бути втраченими. Створіть новий гаманець з мнемонічною фразою з 24 слів (торкніться меню у верхньому правому куті, виберіть Гаманці, виберіть Створити новий гаманець, потім виберіть Bitcoin) і НЕГАЙНО переведіть туди свії BTC. Нові (з мнемонічною фразою з 24 слів) гаманці BTC від Cake надійно захищені", "do_not_show_me": "Не показуй мені це знову" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index bb923f057..7418e77f5 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -473,11 +473,11 @@ "buy_alert_content" : "目前,我们仅支持购买比特币。要购买比特币,请创建或切换到您的比特币钱包", - "outdated_electrum_wallet_desceription" : "在Cake创建的新比特币钱包现在有一个24字的种子。你必须创建一个新的比特币钱包,并将你所有的资金转移到新的24字钱包,并停止使用12字种子的钱包。请立即这样做以保证你的资金安全。", + "outdated_electrum_wallet_description" : "在Cake创建的新比特币钱包现在有一个24字的种子。你必须创建一个新的比特币钱包,并将你所有的资金转移到新的24字钱包,并停止使用12字种子的钱包。请立即这样做以保证你的资金安全。", "understand" : "我已知晓", "apk_update" : "APK更新", - "outdated_electrum_wallet_receive_warning": "警告\n如果这个钱包有一个在 Cake Wallet 中创建的 12 个单词的种子,请不要在这个钱包中存入比特币。 您的比特币可能有被盗的风险。 创建一个新钱包,并立即将您的资金转移到新钱包中。", + "outdated_electrum_wallet_receive_warning": "如果这个钱包有一个 12 字的种子并且是在 Cake 中创建的,不要将比特币存入这个钱包。 任何转移到此钱包的 BTC 都可能丢失。 创建一个新的 24 字钱包(点击右上角的菜单,选择钱包,选择创建新钱包,然后选择比特币)并立即将您的 BTC 移到那里。 Cake 的新(24 字)BTC 钱包是安全的", "do_not_show_me": "不要再让我看这个了" } \ No newline at end of file From b2b7a8bfc085bf026315e9619ba1f4eea49e16dc Mon Sep 17 00:00:00 2001 From: M Date: Mon, 7 Jun 2021 22:11:09 +0300 Subject: [PATCH 35/42] Changed build versions. --- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index d88278ddf..669f89870 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 43; + CURRENT_PROJECT_VERSION = 44; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 43; + CURRENT_PROJECT_VERSION = 44; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 43; + CURRENT_PROJECT_VERSION = 44; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; diff --git a/pubspec.yaml b/pubspec.yaml index 299dc8628..a7ccb572b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Cake Wallet. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 4.2.3+52 +version: 4.2.3+53 environment: sdk: ">=2.7.0 <3.0.0" From 6268cf3788c7bc4cf99199cf58374c7892b2f499 Mon Sep 17 00:00:00 2001 From: M Date: Tue, 8 Jun 2021 17:19:54 +0300 Subject: [PATCH 36/42] Changed ios project settings. --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 669f89870..e5aaa7e04 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,10 +366,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 44; + CURRENT_PROJECT_VERSION = 45; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; - EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; + EXCLUDED_SOURCE_FILE_NAMES = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -510,10 +510,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 44; + CURRENT_PROJECT_VERSION = 45; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; - EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; + EXCLUDED_SOURCE_FILE_NAMES = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -546,10 +546,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 44; + CURRENT_PROJECT_VERSION = 45; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; - EXCLUDED_SOURCE_FILE_NAMES = "\"$(SRCROOT)/Runner/GoogleService-Info.plist\""; + EXCLUDED_SOURCE_FILE_NAMES = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", From 81b34a30e77b8b8041d708a435e8a00bfb090fa4 Mon Sep 17 00:00:00 2001 From: M Date: Tue, 8 Jun 2021 23:06:22 +0300 Subject: [PATCH 37/42] Changes for buy page for bitcoin and litecoin. Added listeners for notifications from resume and launch. --- ios/Runner.xcodeproj/project.pbxproj | 6 +-- lib/entities/push_notifications_service.dart | 40 ++++++++++--------- lib/src/screens/buy/pre_order_page.dart | 4 +- lib/src/screens/dashboard/dashboard_page.dart | 8 ++-- lib/view_model/buy/buy_view_model.dart | 6 ++- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index e5aaa7e04..fd2a469c4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 45; + CURRENT_PROJECT_VERSION = 46; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 45; + CURRENT_PROJECT_VERSION = 46; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 45; + CURRENT_PROJECT_VERSION = 46; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; diff --git a/lib/entities/push_notifications_service.dart b/lib/entities/push_notifications_service.dart index 5fb68bae4..bf5226af3 100644 --- a/lib/entities/push_notifications_service.dart +++ b/lib/entities/push_notifications_service.dart @@ -10,6 +10,25 @@ class PushNotificationsService { static final PushNotificationsService _instance = PushNotificationsService._(); static Future _onBackgroundMessage(Map message) async {} + static Future _showNotification(Map message) async { + Map alert = {}; + String msg = ''; + String title = ''; + + if (Platform.isIOS) { + alert = message['aps']['alert'] as Map ?? {}; + msg = alert['body'] as String ?? ''; + title = alert['title'] as String ?? ''; + } + + if (Platform.isAndroid) { + msg = message['notification']['body'] as String ?? ''; + title = message['notification']['title'] as String ?? ''; + } + + await showBar(navigatorKey.currentContext, msg, titleText: title, duration: null); + } + final _firebaseMessaging = FirebaseMessaging(); bool _initialized = false; @@ -20,24 +39,9 @@ class PushNotificationsService { _firebaseMessaging.requestNotificationPermissions(); _firebaseMessaging.configure( - onMessage: (message) async { - Map alert = {}; - String msg = ''; - String title = ''; - - if (Platform.isIOS) { - alert = message['aps']['alert'] as Map ?? {}; - msg = alert['body'] as String ?? ''; - title = alert['title'] as String ?? ''; - } - - if (Platform.isAndroid) { - msg = message['notification']['body'] as String ?? ''; - title = message['notification']['title'] as String ?? ''; - } - - await showBar(navigatorKey.currentContext, msg, titleText: title, duration: null); - }, + onMessage: (message) async => _showNotification(message), + onLaunch: (message) async => _showNotification(message), + onResume: (message) async => _showNotification(message), onBackgroundMessage: _onBackgroundMessage); _initialized = true; diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 54eeebb6f..7f18873a3 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -73,9 +73,7 @@ class PreOrderPage extends BasePage { @override Widget trailing(context) => TrailButton( caption: S.of(context).clear, - onPressed: () { - buyViewModel.reset(); - }); + onPressed: () => buyViewModel.reset()); @override Widget body(BuildContext context) { diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 5e21b88e8..9ec03ea19 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -180,10 +180,7 @@ class DashboardPage extends BasePage { final walletType = walletViewModel.type; switch (walletType) { - case WalletType.bitcoin: - Navigator.of(context).pushNamed(Routes.preOrder); - break; - default: + case WalletType.monero: await showPopUp( context: context, builder: (BuildContext context) { @@ -194,6 +191,9 @@ class DashboardPage extends BasePage { buttonAction: () => Navigator.of(context).pop()); }); break; + default: + Navigator.of(context).pushNamed(Routes.preOrder); + break; } } } diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 95739edd0..270d6213a 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -89,7 +89,11 @@ abstract class BuyViewModelBase with Store { } Future _fetchBuyItems() async { - final List _providerList = [WyreBuyProvider(wallet: wallet)]; + final List _providerList = []; + + if (wallet.type == WalletType.bitcoin) { + _providerList.add(WyreBuyProvider(wallet: wallet)); + } var isMoonPayEnabled = false; try { From 48066ce916342345ed805973d9ee5a2a91510b0a Mon Sep 17 00:00:00 2001 From: M Date: Wed, 9 Jun 2021 00:39:11 +0300 Subject: [PATCH 38/42] Changed alert for non supported crypto currencies for fiat buying. --- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- res/values/strings_de.arb | 2 +- res/values/strings_en.arb | 2 +- res/values/strings_es.arb | 2 +- res/values/strings_hi.arb | 2 +- res/values/strings_hr.arb | 2 +- res/values/strings_it.arb | 2 +- res/values/strings_ja.arb | 2 +- res/values/strings_ko.arb | 2 +- res/values/strings_nl.arb | 2 +- res/values/strings_pl.arb | 2 +- res/values/strings_pt.arb | 2 +- res/values/strings_ru.arb | 2 +- res/values/strings_uk.arb | 2 +- res/values/strings_zh.arb | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index fd2a469c4..c65672da1 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 30cd18602..b8bab3533 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -471,7 +471,7 @@ "submit_request" : "Einen Antrag stellen", - "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser", + "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin und Litecoin. Um Bitcoin oder Litecoin zu kaufen, erstellen oder wechseln Sie bitte zu Ihrem Bitcoin- oder Litecoin-Wallet.", "outdated_electrum_wallet_description" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", "understand" : "Ich verstehe", diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 4973b8d7b..adb82ecb2 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -471,7 +471,7 @@ "submit_request" : "submit a request", - "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet", + "buy_alert_content" : "Currently we only support the purchase of Bitcoin and Litecoin. To buy Bitcoin or Litecoin, please create or switch to your Bitcoin or Litecoin wallet.", "outdated_electrum_wallet_description" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.", "understand" : "I understand", diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index e51e18530..e54a997a4 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -471,7 +471,7 @@ "submit_request" : "presentar una solicitud", - "buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin", + "buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin y Litecoin. Para comprar Bitcoin o Litecoin, cree o cambie a su billetera Bitcoin o Litecoin.", "outdated_electrum_wallet_description" : "Las nuevas carteras de Bitcoin creadas en Cake ahora tienen una semilla de 24 palabras. Es obligatorio que cree una nueva billetera de Bitcoin y transfiera todos sus fondos a la nueva billetera de 24 palabras, y deje de usar billeteras con una semilla de 12 palabras. Haga esto de inmediato para asegurar sus fondos.", "understand" : "Entiendo", diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index f8bd3f54d..7ef15cc8e 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -471,7 +471,7 @@ "submit_request" : "एक अनुरोध सबमिट करें", - "buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें", + "buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन और लिटकोइन की खरीद का समर्थन करते हैं। बिटकॉइन या लाइटकोइन खरीदने के लिए, कृपया अपना बिटकॉइन या लाइटकोइन वॉलेट बनाएं या स्विच करें।", "outdated_electrum_wallet_description" : "केक में बनाए गए नए बिटकॉइन वॉलेट में अब 24-शब्द का बीज है। यह अनिवार्य है कि आप एक नया बिटकॉइन वॉलेट बनाएं और अपने सभी फंड को नए 24-शब्द वाले वॉलेट में स्थानांतरित करें, और 12-शब्द बीज वाले वॉलेट का उपयोग करना बंद करें। कृपया अपने धन को सुरक्षित करने के लिए इसे तुरंत करें।", "understand" : "मुझे समझ", diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 3ca23cdcd..100311903 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -471,7 +471,7 @@ "submit_request" : "podnesi zahtjev", - "buy_alert_content" : "Trenutno podržavamo samo kupnju Bitcoina. Da biste kupili Bitcoin, izradite ili prijeđite na svoj Bitcoin novčanik", + "buy_alert_content" : "Trenutno podržavamo samo kupnju Bitcoina i Litecoina. Da biste kupili Bitcoin ili Litecoin, stvorite ili pređite na svoj Bitcoin ili Litecoin novčanik.", "outdated_electrum_wallet_description" : "Novi Bitcoin novčanici stvoreni u Cakeu sada imaju sjeme od 24 riječi. Obavezno je stvoriti novi Bitcoin novčanik i prenijeti sva svoja sredstva u novi novčanik od 24 riječi te prestati koristiti novčanike s sjemenkom od 12 riječi. Učinite to odmah kako biste osigurali svoja sredstva.", "understand" : "Razumijem", diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 3fd09985f..2ce76646e 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -471,7 +471,7 @@ "submit_request" : "invia una richiesta", - "buy_alert_content" : "Attualmente supportiamo solo l'acquisto di Bitcoin. Per acquistare Bitcoin, crea o passa al tuo portafoglio Bitcoin", + "buy_alert_content" : "Attualmente supportiamo solo l'acquisto di Bitcoin e Litecoin. Per acquistare Bitcoin o Litecoin, crea o passa al tuo portafoglio Bitcoin o Litecoin.", "outdated_electrum_wallet_description" : "I nuovi portafogli Bitcoin creati in Cake ora hanno un seme di 24 parole. È obbligatorio creare un nuovo portafoglio Bitcoin e trasferire tutti i fondi nel nuovo portafoglio di 24 parole e smettere di usare portafogli con un seme di 12 parole. Ti preghiamo di farlo immediatamente per proteggere i tuoi fondi.", "understand" : "Capisco", diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 009b34ab2..0702398a7 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -471,7 +471,7 @@ "submit_request" : "リクエストを送信する", - "buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください", + "buy_alert_content" : "現在、ビットコインとライトコインの購入のみをサポートしています。 ビットコインまたはライトコインを購入するには、ビットコインまたはライトコインのウォレットを作成するか、ウォレットに切り替えてください。", "outdated_electrum_wallet_description" : "Cakeで作成された新しいビットコインウォレットには、24ワードのシードがあります。 新しいビットコインウォレットを作成し、すべての資金を新しい24ワードのウォレットに転送し、12ワードのシードを持つウォレットの使用を停止することが必須です。 あなたの資金を確保するためにこれをすぐに行ってください。", "understand" : "わかります", diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 0714d96f4..0659b7fbc 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -471,7 +471,7 @@ "submit_request" : "요청을 제출", - "buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오", + "buy_alert_content" : "현재 우리는 비트 코인과 라이트 코인 구매 만 지원합니다. 비트 코인 또는 라이트 코인을 구매하려면 비트 코인 또는 라이트 코인 지갑을 생성하거나 전환하십시오.", "outdated_electrum_wallet_description" : "Cake에서 생성 된 새로운 비트 코인 지갑에는 이제 24 단어 시드가 있습니다. 새로운 비트 코인 지갑을 생성하고 모든 자금을 새로운 24 단어 지갑으로 이체하고 12 단어 시드가있는 지갑 사용을 중지해야합니다. 자금을 확보하려면 즉시이 작업을 수행하십시오.", "understand" : "이해 했어요", diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 1fcb547d5..2e6459d25 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -471,7 +471,7 @@ "submit_request" : "een verzoek indienen", - "buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin. Om Bitcoin te kopen, moet u uw Bitcoin-portemonnee aanmaken of naar uw Bitcoin-portemonnee overschakelen", + "buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin en Litecoin. Om Bitcoin of Litecoin te kopen, maakt u uw Bitcoin- of Litecoin-portemonnee aan of schakelt u over naar deze.", "outdated_electrum_wallet_description" : "Nieuwe Bitcoin-portefeuilles die in Cake zijn gemaakt, hebben nu een zaadje van 24 woorden. Het is verplicht dat u een nieuwe Bitcoin-portemonnee maakt en al uw geld overmaakt naar de nieuwe portemonnee van 24 woorden, en stopt met het gebruik van wallets met een seed van 12 woorden. Doe dit onmiddellijk om uw geld veilig te stellen.", "understand" : "Ik begrijp het", diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 92b4817e1..e28bad8dc 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -471,7 +471,7 @@ "submit_request" : "złożyć wniosek", - "buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoinów. Aby kupić Bitcoin, utwórz lub przełącz się na swój portfel Bitcoin", + "buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoin i Litecoin. Aby kupić Bitcoin lub Litecoin, utwórz lub przełącz się na swój portfel Bitcoin lub Litecoin.", "outdated_electrum_wallet_description" : "Nowe portfele Bitcoin utworzone w Cake mają teraz ziarno składające się z 24 słów. Konieczne jest utworzenie nowego portfela Bitcoin i przeniesienie wszystkich środków do nowego portfela na 24 słowa oraz zaprzestanie korzystania z portfeli z zalążkiem na 12 słów. Zrób to natychmiast, aby zabezpieczyć swoje fundusze.", "understand" : "Rozumiem", diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index a7f1802d3..872a102e4 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -471,7 +471,7 @@ "submit_request" : "enviar um pedido", - "buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin. Para comprar Bitcoin, crie ou mude para sua carteira Bitcoin", + "buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin e Litecoin. Para comprar Bitcoin ou Litecoin, crie ou troque para sua carteira Bitcoin ou Litecoin.", "outdated_electrum_wallet_description" : "As novas carteiras Bitcoin criadas no Cake agora têm uma semente de 24 palavras. É obrigatório que você crie uma nova carteira Bitcoin e transfira todos os seus fundos para a nova carteira de 24 palavras, e pare de usar carteiras com semente de 12 palavras. Faça isso imediatamente para garantir seus fundos.", "understand" : "Entendo", diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 86201463e..1828c36c3 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -471,7 +471,7 @@ "submit_request" : "отправить запрос", - "buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек", + "buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin и Litecoin. Чтобы купить Bitcoin или Litecoin, создайте или переключитесь на свой Bitcoin или Litecoin кошелек.", "outdated_electrum_wallet_description" : "Новые биткойн-кошельки, созданные в Cake, теперь содержат мнемоническую фразу из 24 слов. Вы обязательно должны создать новый биткойн-кошелек и перевести все свои средства в новый кошелек из 24 слов, а также прекратить использование кошельков с мнемонической фразой из 12 слов. Пожалуйста, сделайте это немедленно, чтобы обезопасить свои средства.", "understand" : "Понятно", diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index d89922159..2becc69ab 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -471,7 +471,7 @@ "submit_request" : "надіслати запит", - "buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець", + "buy_alert_content" : "В даний час ми підтримуємо лише придбання Bitcoin та Litecoin. Щоб купити Bitcoin або Litecoin, будь ласка, створіть або перейдіть на свій гаманець Bitcoin або Litecoin.", "outdated_electrum_wallet_description" : "Нові біткойн-гаманці, створені в Cake, тепер містять мнемонічну фразу з 24 слів. Обов’язково стовріть новий біткойн-гаманець, переведіть всі кошти на новий гаманець із 24 слів і припиніть використання гаманців із мнемонічною фразою з 12 слів. Зробіть це негайно, щоб убезпечити свої кошти.", "understand" : "Зрозуміло", diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index ea859ae00..6046fae70 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -471,7 +471,7 @@ "submit_request" : "提交请求", - "buy_alert_content" : "目前,我们仅支持购买比特币。要购买比特币,请创建或切换到您的比特币钱包", + "buy_alert_content" : "目前我们只支持购买比特币和莱特币。 要购买比特币或莱特币,请创建或切换到您的比特币或莱特币钱包。", "outdated_electrum_wallet_description" : "在Cake创建的新比特币钱包现在有一个24字的种子。你必须创建一个新的比特币钱包,并将你所有的资金转移到新的24字钱包,并停止使用12字种子的钱包。请立即这样做以保证你的资金安全。", "understand" : "我已知晓", From f62ec8dc023ff6ced83088639f7aef9e07a70341 Mon Sep 17 00:00:00 2001 From: M Date: Wed, 9 Jun 2021 01:12:16 +0300 Subject: [PATCH 39/42] Changed ios project version. --- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index c65672da1..75818920e 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; From b5cacbc1c1d58eb301055c06bb2186df8f568219 Mon Sep 17 00:00:00 2001 From: M Date: Wed, 9 Jun 2021 15:05:05 +0300 Subject: [PATCH 40/42] Fixes for buy screen title. --- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- lib/src/screens/buy/pre_order_page.dart | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 75818920e..6f6193063 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -366,7 +366,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -510,7 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = 32J6BB6VUS; ENABLE_BITCODE = NO; EXCLUDED_SOURCE_FILE_NAMES = ""; diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 7f18873a3..474276d79 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:cake_wallet/buy/buy_amount.dart'; import 'package:cake_wallet/buy/buy_provider.dart'; import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart'; +import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/src/screens/buy/widgets/buy_list_item.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; @@ -56,7 +57,7 @@ class PreOrderPage extends BasePage { final TextEditingController _amountController; @override - String get title => S.current.buy_bitcoin; + String get title => S.current.buy + ' ' + walletTypeToString(buyViewModel.wallet.type); @override Color get titleColor => Colors.white; From b76c3c1373b4d032b59cdaf4f5680b1ed949cfd3 Mon Sep 17 00:00:00 2001 From: Zy143L Date: Sat, 12 Jun 2021 23:51:15 +0800 Subject: [PATCH 41/42] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20strings=5Fzh.arb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update --- res/values/strings_zh.arb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 6046fae70..af19ca386 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -169,7 +169,7 @@ "restore_recover" : "恢复", "restore_wallet_restore_description" : "钱包还原说明", "restore_new_seed" : "新种子", - "restore_active_seed" : "活性种子", + "restore_active_seed" : "活动种子", "restore_bitcoin_description_from_seed" : "从24个文字的组成码恢复您的钱包", "restore_bitcoin_description_from_keys" : "从私钥中生成的WIF字符串恢复您钱包", "restore_bitcoin_title_from_keys" : "从WIF还原", @@ -267,7 +267,7 @@ "trade_details_title" : "交易明细", "trade_details_id" : "ID", "trade_details_state" : "条件", - "trade_details_fetching" : "正在取得", + "trade_details_fetching" : "正在获取", "trade_details_provider" : "提供者", "trade_details_created_at" : "创建于", "trade_details_pair" : "对", @@ -322,7 +322,7 @@ "error_text_crypto_currency" : "小数位数\n必须小于或等于12", "error_text_minimal_limit" : "未创建 ${provider} 交易。 金额小于最小值:${min} ${currency}", "error_text_maximum_limit" : "未创建 ${provider} 交易。 金额大于最大值:${max} ${currency}", - "error_text_limits_loading_failed" : "未创建 ${provider} 交易。 限制加载失敗", + "error_text_limits_loading_failed" : "未创建 ${provider} 交易。 限制加载失败", "error_text_template" : "模板名称和地址不能包含`,' \" 符号\n并且必须在1到106个字符之间", @@ -478,10 +478,10 @@ "apk_update" : "APK更新", - "buy_bitcoin" : "購買比特幣", - "buy_with" : "與一起購買", - "moonpay_alert_text" : "金額的價值必須大於或等於 ${minAmount} ${fiatCurrency}", + "buy_bitcoin" : "购买比特币", + "buy_with" : "一起购买", + "moonpay_alert_text" : "金额的价值必须大于或等于 ${minAmount} ${fiatCurrency}", "outdated_electrum_wallet_receive_warning": "如果这个钱包有一个 12 字的种子并且是在 Cake 中创建的,不要将比特币存入这个钱包。 任何转移到此钱包的 BTC 都可能丢失。 创建一个新的 24 字钱包(点击右上角的菜单,选择钱包,选择创建新钱包,然后选择比特币)并立即将您的 BTC 移到那里。 Cake 的新(24 字)BTC 钱包是安全的", - "do_not_show_me": "不要再让我看这个了" + "do_not_show_me": "不再提示" } \ No newline at end of file From 074bb753e410736e2c3a1e9261b19d75720ce9c3 Mon Sep 17 00:00:00 2001 From: Dennis Vaupel Date: Sun, 13 Jun 2021 19:52:54 +0200 Subject: [PATCH 42/42] Improve German translation --- res/values/strings_de.arb | 354 +++++++++++++++++++------------------- 1 file changed, 177 insertions(+), 177 deletions(-) diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index b8bab3533..e2d835f70 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -1,8 +1,8 @@ { - "welcome" : "Willkommen zu", + "welcome" : "Willkommen bei", "cake_wallet" : "Cake Wallet", - "first_wallet_text" : "tolle Brieftasche zum Monero und Bitcoin", - "please_make_selection" : "Bitte treffen Sie unten eine Auswahl zu Erstellen oder Wiederherstellen Ihrer Brieftasche.", + "first_wallet_text" : "Eine großartige Wallet für Monero und Bitcoin", + "please_make_selection" : "Bitte treffen Sie unten eine Auswahl zum Erstellen oder Wiederherstellen Ihrer Wallet.", "create_new" : "Neue Wallet erstellen", "restore_wallet" : "Wallet wiederherstellen", @@ -18,9 +18,9 @@ "please_select" : "Bitte auswählen:", "cancel" : "Abbrechen", "ok" : "OK", - "contact_name" : "Name des Ansprechpartners", + "contact_name" : "Name des Kontakts", "reset" : "Zurücksetzen", - "save" : "speichern", + "save" : "Speichern", "address_remove_contact" : "Kontakt entfernen", "address_remove_content" : "Sind Sie sicher, dass Sie den ausgewählten Kontakt entfernen möchten?", @@ -30,88 +30,88 @@ "failed_authentication" : "Authentifizierung fehlgeschlagen. ${state_error}", - "wallet_menu" : "Brieftaschen-Menü", - "Blocks_remaining" : "${status} Verbleibende Blöcke", - "please_try_to_connect_to_another_node" : "Bitte versuchen Sie, eine Verbindung zu einem anderen Knoten herzustellen", + "wallet_menu" : "Wallet-Menü", + "Blocks_remaining" : "${status} verbleibende Blöcke", + "please_try_to_connect_to_another_node" : "Bitte versuchen Sie, sich mit einem anderen Knoten zu verbinden", "xmr_hidden" : "Versteckt", "xmr_available_balance" : "Verfügbares Guthaben", - "xmr_full_balance" : "Volle Balance", + "xmr_full_balance" : "Gesamtguthaben", "send" : "Senden", - "receive" : "Erhalten", + "receive" : "Empfangen", "transactions" : "Transaktionen", "incoming" : "Eingehend", "outgoing" : "Ausgehend", "transactions_by_date" : "Transaktionen nach Datum", - "trades" : "Handel", + "trades" : "Börsen", "filters" : "Filter", "today" : "Heute", "yesterday" : "Gestern", "received" : "Empfangen", - "sent" : "Geschickt", - "pending" : " (steht aus)", + "sent" : "Versendet", + "pending" : " (ausstehend)", "rescan" : "Erneut scannen", "reconnect" : "Erneut verbinden", "wallets" : "Wallets", "show_seed" : "Seed zeigen", - "show_keys" : "Samen/Schlüssel anzeigen", + "show_keys" : "Seed/Schlüssel anzeigen", "address_book_menu" : "Adressbuch", - "reconnection" : "Wiederverbindung", - "reconnect_alert_text" : "Sind Sie sicher, dass Sie die Verbindung wiederherstellen möchten?", + "reconnection" : "Neu verbinden", + "reconnect_alert_text" : "Sind Sie sicher, dass Sie sich neu verbinden möchten?", - "exchange" : "Austausch", - "clear" : "klar", + "exchange" : "Umwechseln", + "clear" : "Zurücksetzen", "refund_address" : "Rückerstattungsadresse", - "change_exchange_provider" : "Wechseln Sie den Exchange-Anbieter", + "change_exchange_provider" : "Exchange-Anbieter ändern", "you_will_send" : "Konvertieren von", "you_will_get" : "Konvertieren zu", "amount_is_guaranteed" : "Der Empfangsbetrag ist garantiert", "amount_is_estimate" : "Der empfangene Betrag ist eine Schätzung", - "powered_by" : "Unterstützt von ${title}", - "error" : "Error", + "powered_by" : "Ermöglicht durch ${title}", + "error" : "Fehler", "estimated" : "Geschätzt", - "min_value" : "Mindest: ${value} ${currency}", + "min_value" : "Min: ${value} ${currency}", "max_value" : "Max: ${value} ${currency}", "change_currency" : "Währung ändern", "copy_id" : "ID kopieren", - "exchange_result_write_down_trade_id" : "Bitte kopieren oder notieren Sie die Handel-ID, um fortzufahren.", - "trade_id" : "Handel-ID:", + "exchange_result_write_down_trade_id" : "Bitte kopieren oder notieren Sie die Handels-ID, um fortzufahren.", + "trade_id" : "Handels-ID:", "copied_to_clipboard" : "In die Zwischenablage kopiert", - "saved_the_trade_id" : "Ich habe die Geschäfts-ID gespeichert", - "fetching" : "holen", + "saved_the_trade_id" : "Ich habe die Handels-ID gespeichert", + "fetching" : "Frage ab", "id" : "ID: ", - "amount" : "Menge: ", - "payment_id" : "Zahlungs ID: ", + "amount" : "Betrag: ", + "payment_id" : "Zahlungs-ID: ", "status" : "Status: ", "offer_expires_in" : "Angebot läuft ab in: ", - "trade_is_powered_by" : "Dieser Handel wird betrieben von ${provider}", + "trade_is_powered_by" : "Dieser Handel wird angeboten von ${provider}", "copy_address" : "Adresse kopieren", - "exchange_result_confirm" : "Durch Drücken von Bestätigen wird gesendet ${fetchingLabel} ${from} von Ihrer Brieftasche aus angerufen ${walletName} an die unten angegebene Adresse. Oder Sie können von Ihrem externen Portemonnaie an die unten angegebene Adresse / QR-Code senden.\n\nBitte bestätigen Sie, um fortzufahren, oder gehen Sie zurück, um die Beträge zu änderns.", + "exchange_result_confirm" : "Durch Drücken von \"Bestätigen\" wird ${fetchingLabel} ${from} von Ihrer Wallet namens ${walletName} an die unten angegebene Adresse gesendet. Alternativ können Sie von einer externen Wallet an die unten angegebene Adresse / QR-Code senden.\n\nBitte bestätigen Sie, um fortzufahren, oder gehen Sie zurück, um die Beträge zu ändern.", "exchange_result_description" : "Sie müssen mindestens ${fetchingLabel} ${from} an die auf der nächsten Seite angegebene Adresse senden. Wenn Sie einen Betrag unter ${fetchingLabel} ${from} senden, wird dieser möglicherweise nicht konvertiert und möglicherweise nicht erstattet.", - "exchange_result_write_down_ID" : "*Bitte kopieren oder notieren Sie Ihren oben gezeigten Ausweis.", + "exchange_result_write_down_ID" : "*Bitte kopieren oder notieren Sie sich die oben gezeigte ID.", "confirm" : "Bestätigen", - "confirm_sending" : "Bestätigen Sie das Senden", - "commit_transaction_amount_fee" : "Transaktion festschreiben\nMenge: ${amount}\nGebühr: ${fee}", + "confirm_sending" : "Senden bestätigen", + "commit_transaction_amount_fee" : "Transaktion absenden\nBetrag: ${amount}\nGebühr: ${fee}", "sending" : "Senden", "transaction_sent" : "Transaktion gesendet!", "expired" : "Abgelaufen", "time" : "${minutes}m ${seconds}s", - "send_xmr" : "Senden XMR", + "send_xmr" : "XMR senden", "exchange_new_template" : "Neue Vorlage", - "faq" : "FAQ", + "faq" : "Häufig gestellte Fragen", "enter_your_pin" : "PIN eingeben", - "loading_your_wallet" : "Laden Sie Ihre Brieftasche", + "loading_your_wallet" : "Wallet wird geladen", - "new_wallet" : "Neues Wallet", + "new_wallet" : "Neue Wallet", "wallet_name" : "Walletname", - "continue_text" : "Fortsetzen", - "choose_wallet_currency" : "Bitte wählen Sie die Brieftaschenwährung:", + "continue_text" : "Weiter", + "choose_wallet_currency" : "Bitte wählen Sie die Währung der Wallet:", "node_new" : "Neuer Knoten", @@ -121,27 +121,27 @@ "password" : "Passwort", "nodes" : "Knoten", "node_reset_settings_title" : "Einstellungen zurücksetzen", - "nodes_list_reset_to_default_message" : "Möchten Sie die Einstellungen wirklich auf die Standardeinstellungen zurücksetzen?", - "change_current_node" : "Möchten Sie den aktuellen Knoten wirklich auf ändern? ${node}?", - "change" : "Veränderung", + "nodes_list_reset_to_default_message" : "Möchten Sie wirklich die Standardeinstellungen wiederherstellen?", + "change_current_node" : "Möchten Sie den aktuellen Knoten wirklich zu ${node}? ändern?", + "change" : "Ändern", "remove_node" : "Knoten entfernen", "remove_node_message" : "Möchten Sie den ausgewählten Knoten wirklich entfernen?", - "remove" : "Löschen", + "remove" : "Entfernen", "delete" : "Löschen", "add_new_node" : "Neuen Knoten hinzufügen", - "change_current_node_title" : "Ändern Sie den aktuellen Knoten", + "change_current_node_title" : "Aktuellen Knoten ändern", "node_test" : "Test", "node_connection_successful" : "Die Verbindung war erfolgreich", "node_connection_failed" : "Verbindung fehlgeschlagen", - "new_node_testing" : "Neuer Knotentest", + "new_node_testing" : "Neuen Knoten testen", - "use" : "Verwenden Sie ", - "digit_pin" : "-stelliger PIN", + "use" : "Wechsel zu ", + "digit_pin" : "-stellige PIN", "share_address" : "Adresse teilen ", - "receive_amount" : "Menge", + "receive_amount" : "Betrag", "subaddresses" : "Unteradressen", "addresses" : "Adressen", "scan_qr_code" : "Scannen Sie den QR-Code, um die Adresse zu erhalten", @@ -152,78 +152,78 @@ "restore_restore_wallet" : "Wallet wiederherstellen", - "restore_title_from_seed_keys" : "Vom Seed / Schlüssel wiederherstellen", - "restore_description_from_seed_keys" : "Holen Sie sich Ihr Wallet von Seed / Schlüsseln zurück, die Sie an einem sicheren Ort aufbewahrt haben", - "restore_next" : "Nächster", + "restore_title_from_seed_keys" : "Aus Seed/Schlüssel wiederherstellen", + "restore_description_from_seed_keys" : "Stellen Sie Ihr Wallet aus Seed/Schlüsseln wieder her, die Sie sicher aufbewahrt haben", + "restore_next" : "Weiter", "restore_title_from_backup" : "Aus einer Sicherungsdatei wiederherstellen", - "restore_description_from_backup" : "Sie können die gesamte Cake Wallet-App von wiederherstellen Ihre Sicherungsdatei", - "restore_seed_keys_restore" : "Seed / Schlüssel wiederherstellen", + "restore_description_from_backup" : "Sie können die gesamte Cake Wallet-App aus Ihrer Sicherungsdatei wiederherstellen", + "restore_seed_keys_restore" : "Seed/Schlüssel wiederherstellen", "restore_title_from_seed" : "Aus Seed wiederherstellen", - "restore_description_from_seed" : "Stellen Sie Ihr Wallet aus den 25 Wörtern wieder her oder 13-Wort-Kombinationscode", - "restore_title_from_keys" : "Wiederherstellen von Schlüsseln", - "restore_description_from_keys" : "Stellen Sie Ihr Wallet von generiert wieder her Tastenanschläge, die von Ihren privaten Schlüsseln gespeichert wurden", + "restore_description_from_seed" : "Stellen Sie Ihre Wallet aus den 25 Wörtern oder dem 13-Wort-Kombinationscode wieder her", + "restore_title_from_keys" : "Aus Schlüsseln wiederherstellen", + "restore_description_from_keys" : "Stellen Sie Ihr Wallet aus generierten Tastenanschlägen her, die von Ihren privaten Schlüsseln gespeichert wurden", "restore_wallet_name" : "Walletname", "restore_address" : "Adresse", - "restore_view_key_private" : "Schlüssel anzeigen(geheim)", - "restore_spend_key_private" : "Schlüssel ausgeben (geheim)", - "restore_recover" : "Genesen", - "restore_wallet_restore_description" : "Beschreibung zur Wiederherstellung der Brieftasche", + "restore_view_key_private" : "View Key (geheim)", + "restore_spend_key_private" : "Spend Key (geheim)", + "restore_recover" : "Wiederherstellen", + "restore_wallet_restore_description" : "Beschreibung zur Wallet-Wiederherstellung", "restore_new_seed" : "Neuer Seed", - "restore_active_seed" : "Aktives Seed", + "restore_active_seed" : "Aktiver Seed", "restore_bitcoin_description_from_seed" : "Stellen Sie Ihre Brieftasche aus dem 24-Wort-Kombinationscode wieder her", "restore_bitcoin_description_from_keys" : "Stellen Sie Ihre Brieftasche aus der generierten WIF-Zeichenfolge aus Ihren privaten Schlüsseln wieder her", "restore_bitcoin_title_from_keys" : "Aus WIF wiederherstellen", - "restore_from_date_or_blockheight" : "Bitte geben Sie einige Tage vor dem Erstellen dieser Brieftasche ein Datum ein. Oder wenn Sie die Blockhöhe kennen, geben Sie sie stattdessen ein", + "restore_from_date_or_blockheight" : "Bitte geben Sie ein Datum ein, das einige Tage vor dem Erstellen dieser Brieftasche liegt. Oder wenn Sie die Blockhöhe kennen, geben Sie stattdessen diese ein", - "seed_reminder" : "Bitte notieren Sie diese, falls Sie Ihr Telefon verlieren oder abwischen", + "seed_reminder" : "Bitte notieren Sie diese für den Fall, dass Sie Ihr Telefon verlieren oder es kaputtgeht", "seed_title" : "Seed", - "seed_share" : "Teilen Sie Seed", + "seed_share" : "Seed teilen", "copy" : "Kopieren", - "seed_language_choose" : "Bitte wählen Sie die Ausgangssprache:", - "seed_choose" : "Wählen Sie die Ausgangssprache", - "seed_language_next" : "Nächster", + "seed_language_choose" : "Bitte wählen Sie die Sprache des Seeds:", + "seed_choose" : "Seed-Sprache auswählen", + "seed_language_next" : "Weiter", "seed_language_english" : "Englisch", "seed_language_chinese" : "Chinesisch", "seed_language_dutch" : "Niederländisch", - "seed_language_german" : "Deutsche", + "seed_language_german" : "Deutsch", "seed_language_japanese" : "Japanisch", "seed_language_portuguese" : "Portugiesisch", "seed_language_russian" : "Russisch", "seed_language_spanish" : "Spanisch", - "send_title" : "Senden Sie", - "send_your_wallet" : "Deine Geldbörse", + "send_title" : "Senden", + "send_your_wallet" : "Ihre Wallet", "send_address" : "${cryptoCurrency}-Adresse", - "send_payment_id" : "Zahlungs ID (wahlweise)", - "all" : "ALLE", - "send_error_minimum_value" : "Der Mindestbetrag beträgt 0,01", - "send_error_currency" : "Die Währung kann nur Zahlen enthalten", + "send_payment_id" : "Zahlungs-ID (optional)", + "all" : "ALLES", + "send_error_minimum_value" : "Der Mindestbetrag ist 0,01", + "send_error_currency" : "Die Währung darf nur Zahlen enthalten", "send_estimated_fee" : "Geschätzte Gebühr:", - "send_priority" : "Derzeit ist die Gebühr auf festgelegt ${transactionPriority} priorität.\nDie Transaktionspriorität kann in den Einstellungen angepasst werden", - "send_creating_transaction" : "Transaktion erstellen", + "send_priority" : "Derzeit ist ${transactionPriority} als Gebührenpriorität eingestellt.\nDie Transaktionspriorität kann in den Einstellungen angepasst werden", + "send_creating_transaction" : "Erstelle Transaktion", "send_templates" : "Vorlagen", "send_new" : "Neu", - "send_amount" : "Menge:", + "send_amount" : "Betrag:", "send_fee" : "Gebühr:", "send_name" : "Name", - "send_got_it" : "Ich habs", + "send_got_it" : "Verstanden", "send_sending" : "Senden...", - "send_success" : "Ihr ${crypto} wurde erfolgreich gesendet", + "send_success" : "Ihr ${crypto} wurde erfolgreich versendet", - "settings_title" : "die Einstellungen", + "settings_title" : "Einstellungen", "settings_nodes" : "Knoten", "settings_current_node" : "Aktueller Knoten", - "settings_wallets" : "Brieftaschen", - "settings_display_balance_as" : "Kontostand anzeigen als", + "settings_wallets" : "Wallets", + "settings_display_balance_as" : "Kontostand anzeigen in", "settings_currency" : "Währung", "settings_fee_priority" : "Gebührenpriorität", "settings_save_recipient_address" : "Empfängeradresse speichern", - "settings_personal" : "persönlich", + "settings_personal" : "Persönlich", "settings_change_pin" : "PIN ändern", "settings_change_language" : "Sprache ändern", "settings_allow_biometrical_authentication" : "Biometrische Authentifizierung zulassen", @@ -232,10 +232,10 @@ "settings_trades" : "Handel", "settings_display_on_dashboard_list" : "Anzeige in der Dashboard-Liste", "settings_all" : "ALLE", - "settings_only_trades" : "Nur Trades", + "settings_only_trades" : "Nur Handel", "settings_only_transactions" : "Nur Transaktionen", "settings_none" : "Keiner", - "settings_support" : "Unterstützung", + "settings_support" : "Unterstützen", "settings_terms_and_conditions" : "Geschäftsbedingungen", "pin_is_incorrect" : "PIN ist falsch", @@ -245,61 +245,61 @@ "setup_successful" : "Ihre PIN wurde erfolgreich eingerichtet!", - "wallet_keys" : "Brieftaschensamen / Schlüssel", - "wallet_seed" : "Brieftaschensamen", - "private_key" : "Privat Schlüssel", + "wallet_keys" : "Wallet-Seed/-Schlüssel", + "wallet_seed" : "Wallet-Seed", + "private_key" : "Privater Schlüssel", "public_key" : "Öffentlicher Schlüssel", - "view_key_private" : "Schlüssel anzeigen (eheim)", - "view_key_public" : "Schlüssel anzeigen (Öffentlichkeit)", - "spend_key_private" : "Schlüssel ausgeben (geheim)", - "spend_key_public" : "Schlüssel ausgeben (Öffentlichkeit)", - "copied_key_to_clipboard" : "Kopiert ${key} Zur Zwischenablage", + "view_key_private" : "View Key (geheim)", + "view_key_public" : "View Key (öffentlich)", + "spend_key_private" : "Spend Key (geheim)", + "spend_key_public" : "Spend Key (öffentlich)", + "copied_key_to_clipboard" : "${key} in Zwischenablage kopiert", "new_subaddress_title" : "Neue Adresse", - "new_subaddress_label_name" : "Markenname", + "new_subaddress_label_name" : "Bezeichnung", "new_subaddress_create" : "Erstellen", "subaddress_title" : "Unteradressenliste", - "trade_details_title" : "Handel Einzelheiten", + "trade_details_title" : "Handelsdetails", "trade_details_id" : "ID", - "trade_details_state" : "Zustand", - "trade_details_fetching" : "Holen", + "trade_details_state" : "Status", + "trade_details_fetching" : "Wird ermittelt", "trade_details_provider" : "Anbieter", - "trade_details_created_at" : "Hergestellt in", + "trade_details_created_at" : "Erzeugt am", "trade_details_pair" : "Paar", "trade_details_copied" : "${title} in die Zwischenablage kopiert", - "trade_history_title" : "Handelsgeschichte", + "trade_history_title" : "Handelsverlauf", "transaction_details_title" : "Transaktionsdetails", "transaction_details_transaction_id" : "Transaktions-ID", "transaction_details_date" : "Datum", "transaction_details_height" : "Höhe", - "transaction_details_amount" : "Menge", + "transaction_details_amount" : "Betrag", "transaction_details_fee" : "Gebühr", "transaction_details_copied" : "${title} in die Zwischenablage kopiert", "transaction_details_recipient_address" : "Empfängeradresse", - "wallet_list_title" : "Monero Wallet", + "wallet_list_title" : "Monero-Wallet", "wallet_list_create_new_wallet" : "Neue Wallet erstellen", "wallet_list_restore_wallet" : "Wallet wiederherstellen", - "wallet_list_load_wallet" : "Wallet einlegen", - "wallet_list_loading_wallet" : "Wird geladen ${wallet_name} Wallet", - "wallet_list_failed_to_load" : "Laden fehlgeschlagen ${wallet_name} Wallet. ${error}", - "wallet_list_removing_wallet" : "Entfernen ${wallet_name} Wallet", - "wallet_list_failed_to_remove" : "Fehler beim Entfernen ${wallet_name} Wallet. ${error}", + "wallet_list_load_wallet" : "Wallet laden", + "wallet_list_loading_wallet" : "Wallet ${wallet_name} wird geladen", + "wallet_list_failed_to_load" : "Laden der Wallet ${wallet_name} fehlgeschlagen. ${error}", + "wallet_list_removing_wallet" : "Wallet ${wallet_name} wird entfernt", + "wallet_list_failed_to_remove" : "Fehler beim Entfernen der Wallet ${wallet_name}. ${error}", "widgets_address" : "Adresse", - "widgets_restore_from_blockheight" : "Aus Blockhöhe wiederherstellen", - "widgets_restore_from_date" : "Vom Datum wiederherstellen", + "widgets_restore_from_blockheight" : "Ab Blockhöhe wiederherstellen", + "widgets_restore_from_date" : "Ab Datum wiederherstellen", "widgets_or" : "oder", "widgets_seed" : "Seed", @@ -307,56 +307,56 @@ "router_no_route" : "Keine Route definiert für ${name}", - "error_text_account_name" : "Der Kontoname darf nur Wallet und Zahlen enthalten\nund muss zwischen 1 und 15 Zeichen lang sein", - "error_text_contact_name" : "Kontaktname darf nicht enthalten sein ` , ' \" Symbole\nund muss zwischen 1 und 32 Zeichen lang sein", - "error_text_address" : "Die Walletadresse muss dem Typ entsprechen\nder Kryptowährung", + "error_text_account_name" : "Der Kontoname darf nur Buchstaben und Zahlen enthalten\nund muss zwischen 1 und 15 Zeichen lang sein", + "error_text_contact_name" : "Kontaktname darf nicht die Zeichen ` , ' \" enthalten\nund muss zwischen 1 und 32 Zeichen lang sein", + "error_text_address" : "Die Walletadresse muss dem Typ der Kryptowährung\nentsprechen", "error_text_node_address" : "Bitte geben Sie eine iPv4-Adresse ein", - "error_text_node_port" : "Der Knotenport kann nur Nummern zwischen 0 und 65535 enthalten", - "error_text_payment_id" : "Die Zahlungs-ID kann nur 16 bis 64 hexadezimale Zeichen enthalten", - "error_text_xmr" : "Der XMR-Wert kann das verfügbare Guthaben nicht überschreiten.\nDie Anzahl der Nachkommastellen muss kleiner oder gleich 12 sein", + "error_text_node_port" : "Der Knotenport darf nur Nummern zwischen 0 und 65535 enthalten", + "error_text_payment_id" : "Die Zahlungs-ID darf nur 16 bis 64 hexadezimale Zeichen enthalten", + "error_text_xmr" : "Der XMR-Wert darf das verfügbare Guthaben nicht überschreiten.\nDie Anzahl der Nachkommastellen muss kleiner oder gleich 12 sein", "error_text_fiat" : "Der Wert des Betrags darf den verfügbaren Kontostand nicht überschreiten.\nDie Anzahl der Nachkommastellen muss kleiner oder gleich 2 sein", - "error_text_subaddress_name" : "Der Name der Unteradresse darf nicht enthalten sein ` , ' \" symbole\nund muss zwischen 1 und 20 Zeichen lang sein", - "error_text_amount" : "Betrag kann nur Zahlen enthalten", - "error_text_wallet_name" : "Der Wallet darf nur Buchstaben und Zahlen enthalten\nund muss zwischen 1 und 15 Zeichen lang sein", + "error_text_subaddress_name" : "Der Name der Unteradresse darf nicht die Zeichen ` , ' \" enthalten\nund muss zwischen 1 und 20 Zeichen lang sein", + "error_text_amount" : "Betrag darf nur Zahlen enthalten", + "error_text_wallet_name" : "Der Walletname darf nur Buchstaben und Zahlen enthalten\nund muss zwischen 1 und 15 Zeichen lang sein", "error_text_keys" : "Walletschlüssel können nur 64 hexadezimale Zeichen enthalten", "error_text_crypto_currency" : "Die Anzahl der Nachkommastellen\nmuss kleiner oder gleich 12 sein.", - "error_text_minimal_limit" : "Handel für ${provider} wird nicht erstellt. Menge ist weniger als minimal: ${min} ${currency}", - "error_text_maximum_limit" : "Handel für ${provider} wird nicht erstellt. Menge ist mehr als maximal: ${max} ${currency}", + "error_text_minimal_limit" : "Handel für ${provider} wird nicht erstellt. Menge ist unter dem Minimum: ${min} ${currency}", + "error_text_maximum_limit" : "Handel für ${provider} wird nicht erstellt. Menge ist über dem Maximum: ${max} ${currency}", "error_text_limits_loading_failed" : "Handel für ${provider} wird nicht erstellt. Das Laden der Limits ist fehlgeschlagen", - "error_text_template" : "Vorlagenname und Adresse dürfen nicht enthalten ` , ' \" symbole\nund muss zwischen 1 und 106 Zeichen lang sein", + "error_text_template" : "Vorlagenname und Adresse dürfen nicht die Zeichen ` , ' \" enthalten\nund müssen zwischen 1 und 106 Zeichen lang sein", - "auth_store_ban_timeout" : "Auszeit verbieten", + "auth_store_ban_timeout" : "ban_timeout", "auth_store_banned_for" : "Gebannt für ", - "auth_store_banned_minutes" : " Protokoll", - "auth_store_incorrect_password" : "Falsches PIN", - "wallet_store_monero_wallet" : "Monero Wallet", - "wallet_restoration_store_incorrect_seed_length" : "Falsche Samenlänge", + "auth_store_banned_minutes" : " Minuten", + "auth_store_incorrect_password" : "Falsche PIN", + "wallet_store_monero_wallet" : "Monero-Wallet", + "wallet_restoration_store_incorrect_seed_length" : "Falsche Seed-Länge", - "full_balance" : "Volle Balance", + "full_balance" : "Gesamtguthaben", "available_balance" : "Verfügbares Guthaben", - "hidden_balance" : "Verstecktes Gleichgewicht", + "hidden_balance" : "Verstecktes Guthaben", - "sync_status_syncronizing" : "SYNCHRONISIERUNG", + "sync_status_syncronizing" : "SYNCHRONISIERE", "sync_status_syncronized" : "SYNCHRONISIERT", "sync_status_not_connected" : "NICHT VERBUNDEN", - "sync_status_starting_sync" : "STARTEN DER SYNCHRONISIERUNG", + "sync_status_starting_sync" : "STARTE SYNCHRONISIERUNG", "sync_status_failed_connect" : "GETRENNT", - "sync_status_connecting" : "ANSCHLUSS", - "sync_status_connected" : "IN VERBINDUNG GEBRACHT", + "sync_status_connecting" : "VERBINDEN", + "sync_status_connected" : "VERBUNDEN", - "transaction_priority_slow" : "Schleppend", - "transaction_priority_regular" : "Regulär", + "transaction_priority_slow" : "Langsam", + "transaction_priority_regular" : "Normal", "transaction_priority_medium" : "Mittel", "transaction_priority_fast" : "Schnell", "transaction_priority_fastest" : "Am schnellsten", "trade_for_not_created" : "Handel für ${title} wird nicht erstellt.", - "trade_not_created" : "Handel nicht angelegt.", + "trade_not_created" : "Handel nicht erstellt.", "trade_id_not_found" : "Handel ${tradeId} von ${title} nicht gefunden.", "trade_not_found" : "Handel nicht gefunden.", @@ -364,28 +364,28 @@ "trade_state_pending" : "Steht aus", "trade_state_confirming" : "Bestätigung", "trade_state_trading" : "Handel", - "trade_state_traded" : "Handeln", - "trade_state_complete" : "Komplett", - "trade_state_to_be_created" : "Geschaffen werden", + "trade_state_traded" : "Gehandelt", + "trade_state_complete" : "Abgeschlossen", + "trade_state_to_be_created" : "Noch nicht erstellt", "trade_state_unpaid" : "Unbezahlt", "trade_state_underpaid" : "Unterbezahlt", "trade_state_paid_unconfirmed" : "Unbestätigt bezahlt", "trade_state_paid" : "Bezahlt", - "trade_state_btc_sent" : "geschickt", - "trade_state_timeout" : "Auszeit", + "trade_state_btc_sent" : "Btc gesendet", + "trade_state_timeout" : "Timeout", "trade_state_created" : "Erstellt", "trade_state_finished" : "Fertig", "change_language" : "Sprache ändern", - "change_language_to" : "Ändern Sie die Sprache in ${language}?", + "change_language_to" : "Sprache zu ${language} ändern?", "paste" : "Einfügen", - "restore_from_seed_placeholder" : "Bitte geben Sie hier Ihren Code ein", + "restore_from_seed_placeholder" : "Seed bitte hier eingeben oder einfügen", "add_new_word" : "Neues Wort hinzufügen", "incorrect_seed" : "Der eingegebene Text ist ungültig.", "biometric_auth_reason" : "Scannen Sie Ihren Fingerabdruck zur Authentifizierung", - "version" : "Ausführung ${currentVersion}", + "version" : "Version ${currentVersion}", "openalias_alert_title" : "XMR-Empfänger erkannt", "openalias_alert_content" : "Sie senden Geld an\n${recipient_name}", @@ -398,90 +398,90 @@ "template" : "Vorlage", "confirm_delete_template" : "Diese Aktion löscht diese Vorlage. Möchten Sie fortfahren?", - "confirm_delete_wallet" : "Diese Aktion löscht diese Brieftasche. Möchten Sie fortfahren?", + "confirm_delete_wallet" : "Diese Aktion löscht diese Wallet. Möchten Sie fortfahren?", "picker_description" : "Um ChangeNOW oder MorphToken zu wählen, ändern Sie bitte zuerst Ihr Handelspaar", - "change_wallet_alert_title" : "Ändern Sie die aktuelle Brieftasche", - "change_wallet_alert_content" : "Möchten Sie die aktuelle Brieftasche in ändern ${wallet_name}?", + "change_wallet_alert_title" : "Aktuelle Wallet ändern", + "change_wallet_alert_content" : "Möchten Sie die aktuelle Wallet zu ${wallet_name} ändern?", - "creating_new_wallet" : "Neue Brieftasche erstellen", - "creating_new_wallet_error" : "Error: ${description}", + "creating_new_wallet" : "Neue Wallet erstellen", + "creating_new_wallet_error" : "Fehler: ${description}", - "seed_alert_title" : "Beachtung", - "seed_alert_content" : "Der Samen ist der einzige Weg, um Ihren Geldbeutel wiederzugewinnen. Hast du es aufgeschrieben?", - "seed_alert_back" : "Geh zurück", + "seed_alert_title" : "Achtung", + "seed_alert_content" : "Der Seed ist der einzige Weg, Ihre Wallet wiederherzustellen. Haben Sie ihn aufgeschrieben?", + "seed_alert_back" : "Zurückgehen", "seed_alert_yes" : "Ja, habe ich", - "exchange_sync_alert_content" : "Bitte warten Sie, bis Ihre Brieftasche synchronisiert ist", + "exchange_sync_alert_content" : "Bitte warten Sie, bis Ihre Wallet synchronisiert ist", "pre_seed_title" : "WICHTIG", - "pre_seed_description" : "Auf der nächsten Seite sehen Sie eine Reihe von ${words} Wörtern. Dies ist Ihr einzigartiger und privater Samen und der EINZIGE Weg, um Ihren Geldbeutel im Falle eines Verlusts oder einer Fehlfunktion wiederherzustellen. Es liegt in IHRER Verantwortung, es aufzuschreiben und an einem sicheren Ort außerhalb der Cake Wallet App aufzubewahren.", - "pre_seed_button_text" : "Ich verstehe. Zeig mir meinen Samen", + "pre_seed_description" : "Auf der nächsten Seite sehen Sie eine Reihe von ${words} Wörtern. Dies ist Ihr einzigartiger und privater Seed und der EINZIGE Weg, um Ihre Wallet im Falle eines Verlusts oder einer Fehlfunktion wiederherzustellen. Es liegt in IHRER Verantwortung, ihn aufzuschreiben und an einem sicheren Ort außerhalb der Cake Wallet-App aufzubewahren.", + "pre_seed_button_text" : "Verstanden. Zeig mir meinen Seed", "xmr_to_error" : "XMR.TO-Fehler", "xmr_to_error_description" : "Ungültiger Betrag. Höchstgrenze 8 Stellen nach dem Dezimalpunkt", - "provider_error" : "${provider} Error", + "provider_error" : "${provider}-Fehler", - "use_ssl" : "Verwenden Sie SSL", + "use_ssl" : "SSL verwenden", "color_theme" : "Farbthema", - "light_theme" : "Licht", - "bright_theme" : "Hell", + "light_theme" : "Hell", + "bright_theme" : "Strahlend hell", "dark_theme" : "Dunkel", - "enter_your_note" : "Geben Sie Ihre Notiz ein…", - "note_optional" : "Hinweis (optional)", - "note_tap_to_change" : "Hinweis (zum Ändern tippen)", + "enter_your_note" : "Geben Sie Ihre Bemerkung ein…", + "note_optional" : "Bemerkung (optional)", + "note_tap_to_change" : "Bemerkung (zum Ändern tippen)", "transaction_key" : "Transaktionsschlüssel", "confirmations" : "Bestätigungen", "recipient_address" : "Empfängeradresse", - "extra_id" : "Zusätzliche ID:", + "extra_id" : "Extra ID:", "destination_tag" : "Ziel-Tag:", "memo" : "Memo:", - "backup" : "Backup", + "backup" : "Sicherung", "change_password" : "Passwort ändern", "backup_password" : "Passwort sichern", - "write_down_backup_password" : "Bitte notieren Sie sich Ihr Sicherungskennwort, das für den Import Ihrer Sicherungsdateien verwendet wird.", - "export_backup" : "Backup exportieren", - "save_backup_password" : "Bitte stellen Sie sicher, dass Sie Ihr Sicherungskennwort gespeichert haben. Ohne diese können Sie Ihre Sicherungsdateien nicht importieren.", - "backup_file" : "Sicherungskopie", + "write_down_backup_password" : "Bitte notieren Sie sich Ihr Sicherungskennwort, das für den Import Ihrer Sicherungsdateien gebraucht wird.", + "export_backup" : "Sicherung exportieren", + "save_backup_password" : "Bitte stellen Sie sicher, dass Sie Ihr Sicherungskennwort gespeichert haben. Ohne dieses können Sie Ihre Sicherungsdateien nicht importieren.", + "backup_file" : "Sicherungsdatei", "edit_backup_password" : "Sicherungskennwort bearbeiten", "save_backup_password_alert" : "Sicherungskennwort speichern", "change_backup_password_alert" : "Ihre vorherigen Sicherungsdateien können nicht mit einem neuen Sicherungskennwort importiert werden. Das neue Sicherungskennwort wird nur für neue Sicherungsdateien verwendet. Sind Sie sicher, dass Sie das Sicherungskennwort ändern möchten?", - "enter_backup_password" : "Geben Sie hier das Sicherungskennwort ein", - "select_backup_file" : "Wählen Sie die Sicherungsdatei", + "enter_backup_password" : "Sicherungskennwort hier eingeben", + "select_backup_file" : "Sicherungsdatei auswählen", "import" : "Importieren", "please_select_backup_file" : "Bitte wählen Sie die Sicherungsdatei und geben Sie das Sicherungskennwort ein.", - "fixed_rate" : "Fester Zinssatz", - "fixed_rate_alert" : "Sie können den Empfangsbetrag eingeben, wenn der Festpreismodus aktiviert ist. Möchten Sie in den Festpreismodus wechseln?", + "fixed_rate" : "Feste Rate", + "fixed_rate_alert" : "Sie können den Empfangsbetrag eingeben, wenn der Festratenmodus aktiviert ist. Möchten Sie in den Festratenmodus wechseln?", "xlm_extra_info" : "Bitte vergessen Sie nicht, die Memo-ID anzugeben, während Sie die XLM-Transaktion für den Austausch senden", "xrp_extra_info" : "Bitte vergessen Sie nicht, das Ziel-Tag anzugeben, während Sie die XRP-Transaktion für den Austausch senden", - "exchange_incorrect_current_wallet_for_xmr" : "Wenn Sie XMR von Ihrem Cake Wallet Monero-Guthaben austauschen möchten, wechseln Sie bitte zuerst zu Ihrem Monero Wallet.", + "exchange_incorrect_current_wallet_for_xmr" : "Wenn Sie XMR von Ihrem Cake Wallet Monero-Guthaben umtauschen möchten, wechseln Sie bitte zuerst zu Ihrer Monero-Wallet.", "confirmed" : "Bestätigt", "unconfirmed" : "Unbestätigt", "displayable" : "Anzeigebar", - "submit_request" : "Einen Antrag stellen", + "submit_request" : "Eine Anfrage stellen", "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin und Litecoin. Um Bitcoin oder Litecoin zu kaufen, erstellen oder wechseln Sie bitte zu Ihrem Bitcoin- oder Litecoin-Wallet.", - "outdated_electrum_wallet_description" : "Neue Bitcoin-Geldbörsen, die in Cake erstellt wurden, haben jetzt einen Startwert von 24 Wörtern. Es ist obligatorisch, dass Sie eine neue Bitcoin-Brieftasche erstellen, Ihr gesamtes Geld in die neue 24-Wörter-Brieftasche überweisen und keine Brieftaschen mit einem 12-Wörter-Startwert mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", + "outdated_electrum_wallet_description" : "Neue Bitcoin-Wallets, die in Cake erstellt wurden, haben jetzt einen 24-Wort-Seed. Sie müssen eine neue Bitcoin-Wallet erstellen, Ihr gesamtes Geld in die neue 24-Wort-Wallet überweisen und keine Wallet mit einem 12-Wort-Seed mehr verwenden. Bitte tun Sie dies sofort, um Ihr Geld zu sichern.", "understand" : "Ich verstehe", - "apk_update" : "APK Update", + "apk_update" : "APK-Update", "buy_bitcoin" : "Bitcoin kaufen", "buy_with" : "Kaufen mit", - "moonpay_alert_text" : "Der Wert des Betrags muss größer oder gleich sein ${minAmount} ${fiatCurrency}", + "moonpay_alert_text" : "Der Wert des Betrags muss größer oder gleich ${minAmount} ${fiatCurrency} sein", - "outdated_electrum_wallet_receive_warning": "Wenn diese Brieftasche einen 12-Wort-Seed hat und in Cake erstellt wurde, zahlen Sie KEINE Bitcoins in diese Brieftasche ein. Alle auf diese Wallet übertragenen BTC können verloren gehen. Erstellen Sie eine neue 24-Wort-Wallet (tippen Sie auf das Menü oben rechts, wählen Sie Wallets, wählen Sie Create New Wallet und dann Bitcoin) und verschieben Sie Ihre BTC SOFORT dorthin. Neue (24 Wörter) BTC-Wallets von Cake sind sicher", + "outdated_electrum_wallet_receive_warning": "Wenn diese Brieftasche einen 12-Wort-Seed hat und in Cake erstellt wurde, zahlen Sie KEINE Bitcoins in diese Brieftasche ein. Alle auf diese Wallet übertragenen BTC können verloren gehen. Erstellen Sie eine neue 24-Wort-Wallet (tippen Sie auf das Menü oben rechts, wählen Sie Wallets, wählen Sie Neue Wallet erstellen und dann Bitcoin) und verschieben Sie Ihre BTC SOFORT dorthin. Neue (24-Wort-)BTC-Wallets von Cake sind sicher", "do_not_show_me": "Zeig mir das nicht noch einmal" -} \ No newline at end of file +}