add payout address item to confirmation screen

This commit is contained in:
Serhii 2023-01-16 17:27:49 +02:00
parent 7f37bd3d59
commit b4249f21a9
5 changed files with 22 additions and 3 deletions

View file

@ -143,6 +143,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final inputAddress = responseJSON['payinAddress'] as String;
final refundAddress = responseJSON['refundAddress'] as String;
final extraId = responseJSON['payinExtraId'] as String?;
final payoutAddress = responseJSON['payoutAddress'] as String;
return Trade(
id: id,
@ -154,7 +155,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
extraId: extraId,
createdAt: DateTime.now(),
amount: responseJSON['fromAmount']?.toString() ?? _request.fromAmount,
state: TradeState.created);
state: TradeState.created,
payoutAddress: payoutAddress);
}
@override
@ -192,6 +194,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final extraId = responseJSON['payinExtraId'] as String;
final outputTransaction = responseJSON['payoutHash'] as String;
final expiredAtRaw = responseJSON['validUntil'] as String;
final payoutAddress = responseJSON['payoutAddress'] as String;
final expiredAt = DateTime.tryParse(expiredAtRaw)?.toLocal();
return Trade(
@ -204,7 +207,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
state: state,
extraId: extraId,
expiredAt: expiredAt,
outputTransaction: outputTransaction);
outputTransaction: outputTransaction,
payoutAddress: payoutAddress);
}
@override

View file

@ -150,6 +150,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
refundAddress: settleAddress,
state: TradeState.created,
amount: _request.depositAmount,
payoutAddress: settleAddress,
createdAt: DateTime.now(),
);
}
@ -244,6 +245,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
final inputAddress = responseJSON['depositAddress']['address'] as String;
final expectedSendAmount = responseJSON['depositAmount'].toString();
final deposits = responseJSON['deposits'] as List?;
final settleAddress = responseJSON['settleAddress']['address'] as String;
TradeState? state;
String? status;
@ -264,6 +266,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
amount: expectedSendAmount,
state: state,
expiredAt: expiredAt,
payoutAddress: settleAddress
);
}

View file

@ -108,6 +108,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final id = responseJSON['id'] as String;
final inputAddress = responseJSON['address_from'] as String;
final payoutAddress = responseJSON['address_to'] as String;
final settleAddress = responseJSON['user_refund_address'] as String;
final extraId = responseJSON['extra_id_from'] as String?;
return Trade(
@ -120,6 +121,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
extraId: extraId,
state: TradeState.created,
amount: _request.amount,
payoutAddress: payoutAddress,
createdAt: DateTime.now(),
);
}
@ -189,6 +191,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
final expectedSendAmount = responseJSON['expected_amount'].toString();
final extraId = responseJSON['extra_id_from'] as String?;
final status = responseJSON['status'] as String;
final payoutAddress = responseJSON['address_to'] as String;
final state = TradeState.deserialize(raw: status);
return Trade(
@ -200,6 +203,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
inputAddress: inputAddress,
amount: expectedSendAmount,
state: state,
payoutAddress: payoutAddress,
);
}

View file

@ -21,7 +21,8 @@ class Trade extends HiveObject {
this.extraId,
this.outputTransaction,
this.refundAddress,
this.walletId}) {
this.walletId,
this.payoutAddress}) {
if (provider != null) {
providerRaw = provider.raw;
}
@ -88,6 +89,9 @@ class Trade extends HiveObject {
@HiveField(12)
String? walletId;
@HiveField(13)
String? payoutAddress;
static Trade fromMap(Map<String, Object?> map) {
return Trade(
id: map['id'] as String,

View file

@ -146,6 +146,10 @@ abstract class ExchangeTradeViewModelBase with Store {
title: S.current.send_to_this_address('${trade.from} ${trade.from.tag ?? ''}') + ':',
data: trade.inputAddress ?? '',
isCopied: true),
ExchangeTradeItem(
title: S.current.arrive_in_this_address('${trade.to} ${trade.to.tag ?? ''}') + ':',
data: trade.payoutAddress ?? '',
isCopied: true),
]);
}
}