mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
Add trocador provider and password to transaction details
This commit is contained in:
parent
f770e095a1
commit
f1b0a5adb6
3 changed files with 67 additions and 43 deletions
|
@ -8,21 +8,25 @@ part 'trade.g.dart';
|
|||
|
||||
@HiveType(typeId: Trade.typeId)
|
||||
class Trade extends HiveObject {
|
||||
Trade(
|
||||
{required this.id,
|
||||
required this.amount,
|
||||
ExchangeProviderDescription? provider,
|
||||
CryptoCurrency? from,
|
||||
CryptoCurrency? to,
|
||||
TradeState? state,
|
||||
this.createdAt,
|
||||
this.expiredAt,
|
||||
this.inputAddress,
|
||||
this.extraId,
|
||||
this.outputTransaction,
|
||||
this.refundAddress,
|
||||
this.walletId,
|
||||
this.payoutAddress}) {
|
||||
Trade({
|
||||
required this.id,
|
||||
required this.amount,
|
||||
ExchangeProviderDescription? provider,
|
||||
CryptoCurrency? from,
|
||||
CryptoCurrency? to,
|
||||
TradeState? state,
|
||||
this.createdAt,
|
||||
this.expiredAt,
|
||||
this.inputAddress,
|
||||
this.extraId,
|
||||
this.outputTransaction,
|
||||
this.refundAddress,
|
||||
this.walletId,
|
||||
this.payoutAddress,
|
||||
this.password,
|
||||
this.providerId,
|
||||
this.providerName,
|
||||
}) {
|
||||
if (provider != null) {
|
||||
providerRaw = provider.raw;
|
||||
}
|
||||
|
@ -92,16 +96,23 @@ class Trade extends HiveObject {
|
|||
@HiveField(13)
|
||||
String? payoutAddress;
|
||||
|
||||
@HiveField(14)
|
||||
String? password;
|
||||
|
||||
@HiveField(15)
|
||||
String? providerId;
|
||||
|
||||
@HiveField(16)
|
||||
String? providerName;
|
||||
|
||||
static Trade fromMap(Map<String, Object?> map) {
|
||||
return Trade(
|
||||
id: map['id'] as String,
|
||||
provider: ExchangeProviderDescription.deserialize(
|
||||
raw: map['provider'] as int),
|
||||
provider: ExchangeProviderDescription.deserialize(raw: map['provider'] as int),
|
||||
from: CryptoCurrency.deserialize(raw: map['input'] as int),
|
||||
to: CryptoCurrency.deserialize(raw: map['output'] as int),
|
||||
createdAt: map['date'] != null
|
||||
? DateTime.fromMillisecondsSinceEpoch(map['date'] as int)
|
||||
: null,
|
||||
createdAt:
|
||||
map['date'] != null ? DateTime.fromMillisecondsSinceEpoch(map['date'] as int) : null,
|
||||
amount: map['amount'] as String,
|
||||
walletId: map['wallet_id'] as String);
|
||||
}
|
||||
|
|
|
@ -113,6 +113,9 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
|||
final state = TradeState.deserialize(raw: status);
|
||||
final payoutAddress = responseJSON['address_user'] as String;
|
||||
final date = responseJSON['date'] as String;
|
||||
final password = responseJSON['password'] as String;
|
||||
final providerId = responseJSON['id_provider'] as String;
|
||||
final providerName = responseJSON['provider'] as String;
|
||||
|
||||
return Trade(
|
||||
id: id,
|
||||
|
@ -122,6 +125,9 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
|||
inputAddress: inputAddress,
|
||||
refundAddress: refundAddress,
|
||||
state: state,
|
||||
password: password,
|
||||
providerId: providerId,
|
||||
providerName: providerName,
|
||||
createdAt: DateTime.tryParse(date)?.toLocal(),
|
||||
amount: responseJSON['amount_from']?.toString() ?? request.fromAmount,
|
||||
payoutAddress: payoutAddress);
|
||||
|
@ -208,6 +214,9 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
|||
final to = CryptoCurrency.fromString(responseJSON['ticker_to'] as String);
|
||||
final state = TradeState.deserialize(raw: responseJSON['status'] as String);
|
||||
final date = DateTime.parse(responseJSON['date'] as String);
|
||||
final password = responseJSON['password'] as String;
|
||||
final providerId = responseJSON['id_provider'] as String;
|
||||
final providerName = responseJSON['provider'] as String;
|
||||
|
||||
return Trade(
|
||||
id: id,
|
||||
|
@ -220,6 +229,9 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
|||
amount: fromAmount,
|
||||
state: state,
|
||||
payoutAddress: payoutAddress,
|
||||
password: password,
|
||||
providerId: providerId,
|
||||
providerName: providerName,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,16 +23,15 @@ import 'package:cake_wallet/src/screens/trade_details/trade_details_status_item.
|
|||
import 'package:url_launcher/url_launcher.dart';
|
||||
part 'trade_details_view_model.g.dart';
|
||||
|
||||
class TradeDetailsViewModel = TradeDetailsViewModelBase
|
||||
with _$TradeDetailsViewModel;
|
||||
class TradeDetailsViewModel = TradeDetailsViewModelBase with _$TradeDetailsViewModel;
|
||||
|
||||
abstract class TradeDetailsViewModelBase with Store {
|
||||
TradeDetailsViewModelBase({
|
||||
required Trade tradeForDetails,
|
||||
required this.trades,
|
||||
required this.settingsStore})
|
||||
: items = ObservableList<StandartListItem>(),
|
||||
trade = tradeForDetails {
|
||||
required this.settingsStore,
|
||||
}) : items = ObservableList<StandartListItem>(),
|
||||
trade = tradeForDetails {
|
||||
switch (trade.provider) {
|
||||
case ExchangeProviderDescription.xmrto:
|
||||
_provider = XMRTOExchangeProvider();
|
||||
|
@ -46,7 +45,7 @@ abstract class TradeDetailsViewModelBase with Store {
|
|||
case ExchangeProviderDescription.sideShift:
|
||||
_provider = SideShiftExchangeProvider();
|
||||
break;
|
||||
case ExchangeProviderDescription.simpleSwap:
|
||||
case ExchangeProviderDescription.simpleSwap:
|
||||
_provider = SimpleSwapExchangeProvider();
|
||||
break;
|
||||
case ExchangeProviderDescription.trocador:
|
||||
|
@ -100,12 +99,7 @@ abstract class TradeDetailsViewModelBase with Store {
|
|||
items.clear();
|
||||
|
||||
items.add(
|
||||
DetailsListStatusItem(
|
||||
title: S.current.trade_details_state,
|
||||
value: trade.state != null
|
||||
? trade.state.toString()
|
||||
: S.current.trade_details_fetching)
|
||||
);
|
||||
DetailsListStatusItem(title: S.current.trade_details_state, value: trade.state.toString()));
|
||||
|
||||
items.add(TradeDetailsListCardItem.tradeDetails(
|
||||
id: trade.id,
|
||||
|
@ -118,15 +112,11 @@ abstract class TradeDetailsViewModelBase with Store {
|
|||
},
|
||||
));
|
||||
|
||||
if (trade.provider != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.current.trade_details_provider,
|
||||
value: trade.provider.toString()));
|
||||
}
|
||||
items.add(StandartListItem(
|
||||
title: S.current.trade_details_provider, value: trade.provider.toString()));
|
||||
|
||||
if (trade.provider == ExchangeProviderDescription.changeNow) {
|
||||
final buildURL =
|
||||
'https://changenow.io/exchange/txs/${trade.id.toString()}';
|
||||
final buildURL = 'https://changenow.io/exchange/txs/${trade.id.toString()}';
|
||||
items.add(TrackTradeListItem(
|
||||
title: 'Track',
|
||||
value: buildURL,
|
||||
|
@ -137,14 +127,25 @@ abstract class TradeDetailsViewModelBase with Store {
|
|||
|
||||
if (trade.provider == ExchangeProviderDescription.sideShift) {
|
||||
final buildURL = 'https://sideshift.ai/orders/${trade.id.toString()}';
|
||||
items.add(TrackTradeListItem(
|
||||
title: 'Track', value: buildURL, onTap: () => launch(buildURL)));
|
||||
items.add(TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => launch(buildURL)));
|
||||
}
|
||||
|
||||
if (trade.provider == ExchangeProviderDescription.simpleSwap) {
|
||||
final buildURL = 'https://simpleswap.io/exchange?id=${trade.id.toString()}';
|
||||
items.add(TrackTradeListItem(
|
||||
title: 'Track', value: buildURL, onTap: () => launch(buildURL)));
|
||||
items.add(TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => launch(buildURL)));
|
||||
}
|
||||
|
||||
if (trade.provider == ExchangeProviderDescription.trocador) {
|
||||
final buildURL = 'https://trocador.app/en/checkout/${trade.id.toString()}';
|
||||
items.add(TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => launch(buildURL)));
|
||||
|
||||
items.add(StandartListItem(
|
||||
title: '${trade.providerName} ${S.current.id.toUpperCase()}',
|
||||
value: trade.providerId ?? ''));
|
||||
|
||||
if (trade.password != null && trade.password!.isNotEmpty)
|
||||
items.add(StandartListItem(
|
||||
title: '${trade.providerName} ${S.current.password}', value: trade.password ?? ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue