mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
pass around estimate instead of just rateId
This commit is contained in:
parent
da9b679d3c
commit
da9b921ddc
8 changed files with 30 additions and 24 deletions
|
@ -1,5 +1,6 @@
|
||||||
import 'package:decimal/decimal.dart';
|
import 'package:decimal/decimal.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:stackwallet/models/exchange/response_objects/estimate.dart';
|
||||||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||||
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
||||||
|
|
||||||
|
@ -39,13 +40,13 @@ class IncompleteExchangeModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String? _rateId;
|
Estimate? _estimate;
|
||||||
|
|
||||||
String? get rateId => _rateId;
|
Estimate? get estimate => _estimate;
|
||||||
|
|
||||||
set rateId(String? rateId) {
|
set estimate(Estimate? estimate) {
|
||||||
if (_rateId != rateId) {
|
if (_estimate != estimate) {
|
||||||
_rateId = rateId;
|
_estimate = estimate;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,6 @@ class IncompleteExchangeModel extends ChangeNotifier {
|
||||||
required this.rateType,
|
required this.rateType,
|
||||||
required this.reversed,
|
required this.reversed,
|
||||||
required this.walletInitiated,
|
required this.walletInitiated,
|
||||||
String? rateId,
|
Estimate? estimate,
|
||||||
}) : _rateId = rateId;
|
}) : _estimate = estimate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Estimate {
|
||||||
final bool reversed;
|
final bool reversed;
|
||||||
final String? warningMessage;
|
final String? warningMessage;
|
||||||
final String? rateId;
|
final String? rateId;
|
||||||
|
final String? exchangeProvider;
|
||||||
|
|
||||||
Estimate({
|
Estimate({
|
||||||
required this.estimatedAmount,
|
required this.estimatedAmount,
|
||||||
|
@ -14,6 +15,7 @@ class Estimate {
|
||||||
required this.reversed,
|
required this.reversed,
|
||||||
this.warningMessage,
|
this.warningMessage,
|
||||||
this.rateId,
|
this.rateId,
|
||||||
|
this.exchangeProvider,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Estimate.fromMap(Map<String, dynamic> map) {
|
factory Estimate.fromMap(Map<String, dynamic> map) {
|
||||||
|
@ -38,6 +40,7 @@ class Estimate {
|
||||||
"reversed": reversed,
|
"reversed": reversed,
|
||||||
"warningMessage": warningMessage,
|
"warningMessage": warningMessage,
|
||||||
"rateId": rateId,
|
"rateId": rateId,
|
||||||
|
"exchangeProvider": exchangeProvider,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -554,7 +554,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
? ref.read(exchangeFormStateProvider).receiveAmount!
|
? ref.read(exchangeFormStateProvider).receiveAmount!
|
||||||
: estimate.estimatedAmount,
|
: estimate.estimatedAmount,
|
||||||
rateType: rateType,
|
rateType: rateType,
|
||||||
rateId: estimate.rateId,
|
estimate: estimate,
|
||||||
reversed: estimate.reversed,
|
reversed: estimate.reversed,
|
||||||
walletInitiated: walletInitiated,
|
walletInitiated: walletInitiated,
|
||||||
);
|
);
|
||||||
|
|
|
@ -271,24 +271,26 @@ class _Step3ViewState extends ConsumerState<Step3View> {
|
||||||
? model.refundAddress!
|
? model.refundAddress!
|
||||||
: "",
|
: "",
|
||||||
refundExtraId: "",
|
refundExtraId: "",
|
||||||
rateId: model.rateId,
|
estimate: model.estimate,
|
||||||
reversed: model.reversed,
|
reversed: model.reversed,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.value == null) {
|
if (response.value == null) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
|
||||||
|
|
||||||
unawaited(showDialog<void>(
|
unawaited(
|
||||||
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (_) => StackDialog(
|
builder: (_) => StackDialog(
|
||||||
title: "Failed to create trade",
|
title: "Failed to create trade",
|
||||||
message:
|
message: response.exception
|
||||||
response.exception?.toString(),
|
?.toString(),
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ChangeNowExchange extends Exchange {
|
||||||
String? extraId,
|
String? extraId,
|
||||||
required String addressRefund,
|
required String addressRefund,
|
||||||
required String refundExtraId,
|
required String refundExtraId,
|
||||||
String? rateId,
|
Estimate? estimate,
|
||||||
required bool reversed,
|
required bool reversed,
|
||||||
}) async {
|
}) async {
|
||||||
late final ExchangeResponse<ExchangeTransaction> response;
|
late final ExchangeResponse<ExchangeTransaction> response;
|
||||||
|
@ -41,7 +41,7 @@ class ChangeNowExchange extends Exchange {
|
||||||
toTicker: to,
|
toTicker: to,
|
||||||
receivingAddress: addressTo,
|
receivingAddress: addressTo,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
rateId: rateId!,
|
rateId: estimate!.rateId!,
|
||||||
extraId: extraId ?? "",
|
extraId: extraId ?? "",
|
||||||
refundAddress: addressRefund,
|
refundAddress: addressRefund,
|
||||||
refundExtraId: refundExtraId,
|
refundExtraId: refundExtraId,
|
||||||
|
|
|
@ -69,7 +69,7 @@ abstract class Exchange {
|
||||||
String? extraId,
|
String? extraId,
|
||||||
required String addressRefund,
|
required String addressRefund,
|
||||||
required String refundExtraId,
|
required String refundExtraId,
|
||||||
String? rateId,
|
Estimate? estimate,
|
||||||
required bool reversed,
|
required bool reversed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class MajesticBankExchange extends Exchange {
|
||||||
String? extraId,
|
String? extraId,
|
||||||
required String addressRefund,
|
required String addressRefund,
|
||||||
required String refundExtraId,
|
required String refundExtraId,
|
||||||
String? rateId,
|
Estimate? estimate,
|
||||||
required bool reversed,
|
required bool reversed,
|
||||||
}) async {
|
}) async {
|
||||||
ExchangeResponse<MBOrder>? response;
|
ExchangeResponse<MBOrder>? response;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class SimpleSwapExchange extends Exchange {
|
||||||
String? extraId,
|
String? extraId,
|
||||||
required String addressRefund,
|
required String addressRefund,
|
||||||
required String refundExtraId,
|
required String refundExtraId,
|
||||||
String? rateId,
|
Estimate? estimate,
|
||||||
required bool reversed,
|
required bool reversed,
|
||||||
}) async {
|
}) async {
|
||||||
return await SimpleSwapAPI.instance.createNewExchange(
|
return await SimpleSwapAPI.instance.createNewExchange(
|
||||||
|
|
Loading…
Reference in a new issue