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

This commit is contained in:
Oleksandr Sobol 2020-02-03 23:20:14 +02:00
parent 6333b9a6ff
commit 4ce032f183

View file

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart'; import 'package:cake_wallet/src/domain/exchange/trade_not_found_exeption.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
@ -156,11 +157,17 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
final toCurrency = responseJSON['output']['asset'] as String; final toCurrency = responseJSON['output']['asset'] as String;
final to = CryptoCurrency.fromString(toCurrency); final to = CryptoCurrency.fromString(toCurrency);
final inputAddress = responseJSON['input']['refund_address'] as String; final inputAddress = responseJSON['input']['refund_address'] as String;
final outputWeight = responseJSON['output']['weight'].toString();
final status = responseJSON['state'] as String; final status = responseJSON['state'] as String;
final state = TradeState.deserialize(raw: status); final state = TradeState.deserialize(raw: status);
final extraId = responseJSON['id'] as String;
final outputTransaction = responseJSON['deposit_address'] as String; String amount = "";
final trades = Hive.box<Trade>(Trade.boxName).values;
for (final trade in trades) {
if (trade.id == id) {
amount = trade.amount;
break;
}
}
return Trade( return Trade(
id: id, id: id,
@ -168,10 +175,10 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
to: to, to: to,
provider: description, provider: description,
inputAddress: inputAddress, inputAddress: inputAddress,
amount: outputWeight, amount: amount,
state: state, state: state,
extraId: extraId, extraId: null,
outputTransaction: outputTransaction); outputTransaction: null);
} }
@override @override