CWA-169 | got trade amount from hive in morphtoken exchange provider

Oleksandr Sobol committed Feb 3, 2020 at 23:20 UTC 4ce032f183a63e6fd21911cfe9c6202e16971ed2
1 file changed +13 -6
lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart
+13 -6
@@ -1,4 +1,5 @@
1 import 'dart:convert';
2 +import 'package:hive/hive.dart';
3 import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
4 import 'package:flutter/foundation.dart';
5 import 'package:http/http.dart';
@@ -156,11 +157,17 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
157 final toCurrency = responseJSON['output']['asset'] as String;
158 final to = CryptoCurrency.fromString(toCurrency);
159 final inputAddress = responseJSON['input']['refund_address'] as String;
159 - final outputWeight = responseJSON['output']['weight'].toString();
160 final status = responseJSON['state'] as String;
161 final state = TradeState.deserialize(raw: status);
162 - final extraId = responseJSON['id'] as String;
163 - final outputTransaction = responseJSON['deposit_address'] as String;
162 +
163 + String amount = "";
164 + final trades = Hive.box<Trade>(Trade.boxName).values;
165 + for (final trade in trades) {
166 + if (trade.id == id) {
167 + amount = trade.amount;
168 + break;
169 + }
170 + }
171
172 return Trade(
173 id: id,
@@ -168,10 +175,10 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
175 to: to,
176 provider: description,
177 inputAddress: inputAddress,
171 - amount: outputWeight,
178 + amount: amount,
179 state: state,
173 - extraId: extraId,
174 - outputTransaction: outputTransaction);
180 + extraId: null,
181 + outputTransaction: null);
182 }
183
184 @override