From 0848ede37f8062478afa30ff8417ef5d54320b50 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 31 Mar 2021 20:02:44 +0300 Subject: [PATCH] CAKE-305 | fixed transfer to wyre next btc address --- lib/di.dart | 4 +--- lib/entities/wyre_service.dart | 15 ++++++++++----- lib/view_model/wyre_view_model.dart | 10 +--------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index 520556d83..66ac22231 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -534,13 +534,11 @@ Future setup( getIt.registerFactory(() { final wallet = getIt.get().wallet; - return WyreService(walletType: wallet.type, walletAddress: wallet.address); + return WyreService(wallet: wallet); }); getIt.registerFactory(() { - final wallet = getIt.get().wallet; return WyreViewModel(ordersSource, getIt.get(), - walletId: wallet.id, address: wallet.address, type: wallet.type, wyreService: getIt.get()); }); diff --git a/lib/entities/wyre_service.dart b/lib/entities/wyre_service.dart index c3cef07c8..b83bfce68 100644 --- a/lib/entities/wyre_service.dart +++ b/lib/entities/wyre_service.dart @@ -1,4 +1,5 @@ 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'; @@ -9,8 +10,7 @@ import 'package:cake_wallet/entities/wallet_type.dart'; class WyreService { WyreService({ - @required this.walletType, - @required this.walletAddress, + @required this.wallet, this.isTestEnvironment = false}) { baseApiUrl = isTestEnvironment ? _baseTestApiUrl @@ -31,8 +31,11 @@ class WyreService { static const _trackSuffix = '/track'; final bool isTestEnvironment; - final WalletType walletType; - final String walletAddress; + final WalletBase wallet; + + WalletType get walletType => wallet.type; + String get walletAddress => wallet.address; + String get walletId => wallet.id; String baseApiUrl; String trackUrl; @@ -105,7 +108,9 @@ class WyreService { to: to, state: state, createdAt: createdAt, - amount: amount.toString() + amount: amount.toString(), + receiveAddress: walletAddress, + walletId: walletId ); } } \ No newline at end of file diff --git a/lib/view_model/wyre_view_model.dart b/lib/view_model/wyre_view_model.dart index de0bb5065..8624cd0e6 100644 --- a/lib/view_model/wyre_view_model.dart +++ b/lib/view_model/wyre_view_model.dart @@ -2,7 +2,6 @@ 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/entities/wallet_type.dart'; import 'package:cake_wallet/store/dashboard/orders_store.dart'; import 'package:mobx/mobx.dart'; @@ -12,8 +11,7 @@ class WyreViewModel = WyreViewModelBase with _$WyreViewModel; abstract class WyreViewModelBase with Store { WyreViewModelBase(this.ordersSource, this.ordersStore, - {@required this.walletId, @required this.address, @required this.type, - @required this.wyreService}); + {@required this.wyreService}); Future get wyreUrl => wyreService.getWyreUrl(); @@ -22,17 +20,11 @@ abstract class WyreViewModelBase with Store { final Box ordersSource; final OrdersStore ordersStore; - final String walletId; - final WalletType type; - final String address; - final WyreService wyreService; Future saveOrder(String orderId) async { try { final order = await wyreService.findOrderById(orderId); - order.receiveAddress = address; - order.walletId = walletId; await ordersSource.add(order); ordersStore.setOrder(order); } catch (e) {