add payout address item to confirmation screen

Serhii committed Jan 16, 2023 at 17:27 UTC b4249f21a9cd484a613c0a7706fa9b443791745e
5 files changed +22 -3
lib/exchange/changenow/changenow_exchange_provider.dart
+6 -2
@@ -143,6 +143,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
143 final inputAddress = responseJSON['payinAddress'] as String;
144 final refundAddress = responseJSON['refundAddress'] as String;
145 final extraId = responseJSON['payinExtraId'] as String?;
146 + final payoutAddress = responseJSON['payoutAddress'] as String;
147
148 return Trade(
149 id: id,
@@ -154,7 +155,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
155 extraId: extraId,
156 createdAt: DateTime.now(),
157 amount: responseJSON['fromAmount']?.toString() ?? _request.fromAmount,
157 - state: TradeState.created);
158 + state: TradeState.created,
159 + payoutAddress: payoutAddress);
160 }
161
162 @override
@@ -192,6 +194,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
194 final extraId = responseJSON['payinExtraId'] as String;
195 final outputTransaction = responseJSON['payoutHash'] as String;
196 final expiredAtRaw = responseJSON['validUntil'] as String;
197 + final payoutAddress = responseJSON['payoutAddress'] as String;
198 final expiredAt = DateTime.tryParse(expiredAtRaw)?.toLocal();
199
200 return Trade(
@@ -204,7 +207,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
207 state: state,
208 extraId: extraId,
209 expiredAt: expiredAt,
207 - outputTransaction: outputTransaction);
210 + outputTransaction: outputTransaction,
211 + payoutAddress: payoutAddress);
212 }
213
214 @override
lib/exchange/sideshift/sideshift_exchange_provider.dart
+3
@@ -150,6 +150,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
150 refundAddress: settleAddress,
151 state: TradeState.created,
152 amount: _request.depositAmount,
153 + payoutAddress: settleAddress,
154 createdAt: DateTime.now(),
155 );
156 }
@@ -244,6 +245,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
245 final inputAddress = responseJSON['depositAddress']['address'] as String;
246 final expectedSendAmount = responseJSON['depositAmount'].toString();
247 final deposits = responseJSON['deposits'] as List?;
248 + final settleAddress = responseJSON['settleAddress']['address'] as String;
249 TradeState? state;
250 String? status;
251
@@ -264,6 +266,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
266 amount: expectedSendAmount,
267 state: state,
268 expiredAt: expiredAt,
269 + payoutAddress: settleAddress
270 );
271 }
272
lib/exchange/simpleswap/simpleswap_exchange_provider.dart
+4
@@ -108,6 +108,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
108 final responseJSON = json.decode(response.body) as Map<String, dynamic>;
109 final id = responseJSON['id'] as String;
110 final inputAddress = responseJSON['address_from'] as String;
111 + final payoutAddress = responseJSON['address_to'] as String;
112 final settleAddress = responseJSON['user_refund_address'] as String;
113 final extraId = responseJSON['extra_id_from'] as String?;
114 return Trade(
@@ -120,6 +121,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
121 extraId: extraId,
122 state: TradeState.created,
123 amount: _request.amount,
124 + payoutAddress: payoutAddress,
125 createdAt: DateTime.now(),
126 );
127 }
@@ -189,6 +191,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
191 final expectedSendAmount = responseJSON['expected_amount'].toString();
192 final extraId = responseJSON['extra_id_from'] as String?;
193 final status = responseJSON['status'] as String;
194 + final payoutAddress = responseJSON['address_to'] as String;
195 final state = TradeState.deserialize(raw: status);
196
197 return Trade(
@@ -200,6 +203,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
203 inputAddress: inputAddress,
204 amount: expectedSendAmount,
205 state: state,
206 + payoutAddress: payoutAddress,
207 );
208 }
209
lib/exchange/trade.dart
+5 -1
@@ -21,7 +21,8 @@ class Trade extends HiveObject {
21 this.extraId,
22 this.outputTransaction,
23 this.refundAddress,
24 - this.walletId}) {
24 + this.walletId,
25 + this.payoutAddress}) {
26 if (provider != null) {
27 providerRaw = provider.raw;
28 }
@@ -88,6 +89,9 @@ class Trade extends HiveObject {
89 @HiveField(12)
90 String? walletId;
91
92 + @HiveField(13)
93 + String? payoutAddress;
94 +
95 static Trade fromMap(Map<String, Object?> map) {
96 return Trade(
97 id: map['id'] as String,
lib/view_model/exchange/exchange_trade_view_model.dart
+4
@@ -146,6 +146,10 @@ abstract class ExchangeTradeViewModelBase with Store {
146 title: S.current.send_to_this_address('${trade.from} ${trade.from.tag ?? ''}') + ':',
147 data: trade.inputAddress ?? '',
148 isCopied: true),
149 + ExchangeTradeItem(
150 + title: S.current.arrive_in_this_address('${trade.to} ${trade.to.tag ?? ''}') + ':',
151 + data: trade.payoutAddress ?? '',
152 + isCopied: true),
153 ]);
154 }
155 }