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) {