mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 02:24:30 +00:00
MB doesn't store trade/order history indefinitely
This commit is contained in:
parent
c7bcabf328
commit
3982ca29a6
4 changed files with 77 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
import 'package:stackwallet/exceptions/sw_exception.dart';
|
||||
|
||||
enum ExchangeExceptionType { generic, serializeResponseError }
|
||||
enum ExchangeExceptionType { generic, serializeResponseError, orderNotFound }
|
||||
|
||||
class ExchangeException extends SWException {
|
||||
ExchangeExceptionType type;
|
||||
|
|
|
@ -377,13 +377,47 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
padding: isDesktop
|
||||
? const EdgeInsets.all(16)
|
||||
: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Status",
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
if (trade.exchangeName ==
|
||||
MajesticBankExchange.exchangeName &&
|
||||
trade.status == "Completed")
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => const StackOkDialog(
|
||||
title: "Trade Info",
|
||||
message:
|
||||
"Majestic Bank does not store order data indefinitely",
|
||||
),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.circleInfo,
|
||||
height: 20,
|
||||
width: 20,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.infoItemIcons,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
@ -395,8 +429,6 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
.colorForStatus(trade.status),
|
||||
),
|
||||
),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:stackwallet/exceptions/exchange/exchange_exception.dart';
|
||||
import 'package:stackwallet/exceptions/exchange/majestic_bank/mb_exception.dart';
|
||||
import 'package:stackwallet/exceptions/exchange/pair_unavailable_exception.dart';
|
||||
import 'package:stackwallet/models/exchange/majestic_bank/mb_limit.dart';
|
||||
import 'package:stackwallet/models/exchange/majestic_bank/mb_order.dart';
|
||||
|
@ -335,6 +336,15 @@ class MajesticBankAPI {
|
|||
final jsonObject = await _makeGetRequest(uri);
|
||||
final json = Map<String, dynamic>.from(jsonObject as Map);
|
||||
|
||||
if (json.length == 2) {
|
||||
return ExchangeResponse(
|
||||
exception: MBException(
|
||||
json["status"] as String,
|
||||
ExchangeExceptionType.orderNotFound,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final status = MBOrderStatus(
|
||||
orderId: json["trx"] as String,
|
||||
status: json["status"] as String,
|
||||
|
|
|
@ -282,6 +282,33 @@ class MajesticBankExchange extends Exchange {
|
|||
|
||||
return ExchangeResponse(value: updatedTrade);
|
||||
} else {
|
||||
if (response.exception?.type == ExchangeExceptionType.orderNotFound) {
|
||||
final updatedTrade = Trade(
|
||||
uuid: trade.uuid,
|
||||
tradeId: trade.tradeId,
|
||||
rateType: trade.rateType,
|
||||
direction: trade.direction,
|
||||
timestamp: trade.timestamp,
|
||||
updatedAt: DateTime.now(),
|
||||
payInCurrency: trade.payInCurrency,
|
||||
payInAmount: trade.payInAmount,
|
||||
payInAddress: trade.payInAddress,
|
||||
payInNetwork: trade.payInNetwork,
|
||||
payInExtraId: trade.payInExtraId,
|
||||
payInTxid: trade.payInTxid,
|
||||
payOutCurrency: trade.payOutCurrency,
|
||||
payOutAmount: trade.payOutAmount,
|
||||
payOutAddress: trade.payOutAddress,
|
||||
payOutNetwork: trade.payOutNetwork,
|
||||
payOutExtraId: trade.payOutExtraId,
|
||||
payOutTxid: trade.payOutTxid,
|
||||
refundAddress: trade.refundAddress,
|
||||
refundExtraId: trade.refundExtraId,
|
||||
status: "Completed",
|
||||
exchangeName: exchangeName,
|
||||
);
|
||||
return ExchangeResponse(value: updatedTrade);
|
||||
}
|
||||
return ExchangeResponse(exception: response.exception);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue