mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
CAKE-306 | fixed moonpay_buy_provider.dart, buy_view_model.dart and order_details_view_model.dart
This commit is contained in:
parent
9627590ba5
commit
ae7ccacf29
4 changed files with 6 additions and 26 deletions
|
@ -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<Order> 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(),
|
||||
|
|
|
@ -558,7 +558,6 @@ Future setup(
|
|||
|
||||
return OrderDetailsViewModel(
|
||||
wallet: wallet,
|
||||
ordersSource: _ordersSource,
|
||||
orderForDetails: order);
|
||||
});
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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<Order> 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) {
|
||||
|
|
Loading…
Reference in a new issue