Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lib/models/isar/exchange_cache/currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:isar_community/isar.dart';
import '../../../app_config.dart';
import '../../../services/exchange/change_now/change_now_exchange.dart';
import '../../../services/exchange/exchange.dart';
import '../../../services/exchange/exolix/exolix_exchange.dart';
import '../../../services/exchange/nanswap/nanswap_exchange.dart';
import '../../../services/exchange/trocador/trocador_exchange.dart';
import '../../../services/exchange/wizard_swap/wizard_swap_exchange.dart';
Expand Down Expand Up @@ -83,6 +84,8 @@ class Currency {
// already lower case ticker basically
const (ChangeNowExchange) => network,

const (ExolixExchange) => network.toLowerCase(),

// not used at the time being
// case const (SimpleSwapExchange):

Expand Down
2 changes: 2 additions & 0 deletions lib/pages/exchange_view/exchange_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import '../../services/exchange/change_now/change_now_exchange.dart';
import '../../services/exchange/exchange.dart';
import '../../services/exchange/exchange_data_loading_service.dart';
import '../../services/exchange/exchange_response.dart';
import '../../services/exchange/exolix/exolix_exchange.dart';
import '../../services/exchange/nanswap/nanswap_exchange.dart';
import '../../services/exchange/trocador/trocador_exchange.dart';
import '../../services/exchange/wizard_swap/wizard_swap_exchange.dart';
Expand Down Expand Up @@ -81,6 +82,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
} else {
return [
ChangeNowExchange.instance,
ExolixExchange.instance,
TrocadorExchange.instance,
NanswapExchange.instance,
WizardSwapExchange.instance,
Expand Down
19 changes: 3 additions & 16 deletions lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';

import '../../../app_config.dart';
import '../../../models/exchange/aggregate_currency.dart';
Expand All @@ -24,7 +23,6 @@ import '../../../themes/stack_colors.dart';
import '../../../utilities/amount/amount.dart';
import '../../../utilities/amount/amount_formatter.dart';
import '../../../utilities/amount/amount_unit.dart';
import '../../../utilities/assets.dart';
import '../../../utilities/enums/exchange_rate_type_enum.dart';
import '../../../utilities/logger.dart';
import '../../../utilities/text_styles.dart';
Expand All @@ -37,6 +35,7 @@ import '../../../widgets/desktop/primary_button.dart';
import '../../../widgets/dialogs/basic_dialog.dart';
import '../../../widgets/exchange/trocador/trocador_kyc_info_button.dart';
import '../../../widgets/exchange/trocador/trocador_rating_type_enum.dart';
import '../../../widgets/icon_widgets/exchange_icon.dart';

class ExchangeOption extends ConsumerStatefulWidget {
const ExchangeOption({
Expand Down Expand Up @@ -395,25 +394,13 @@ class _ProviderOptionState extends ConsumerState<ExchProviderOption> {
}
},
errorBuilder: (context, error, stackTrace) {
return SvgPicture.asset(
Assets.exchange.getIconFor(
exchangeName: widget.exchange.name,
),
width: isDesktop ? 32 : 24,
height: isDesktop ? 32 : 24,
);
return ExchangeIcon(exchange: widget.exchange);
},
width: isDesktop ? 32 : 24,
height: isDesktop ? 32 : 24,
),
)
: SvgPicture.asset(
Assets.exchange.getIconFor(
exchangeName: widget.exchange.name,
),
width: isDesktop ? 32 : 24,
height: isDesktop ? 32 : 24,
),
: ExchangeIcon(exchange: widget.exchange),
),
),
const SizedBox(width: 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import '../../../models/exchange/aggregate_currency.dart';
import '../../../providers/providers.dart';
import '../../../services/exchange/change_now/change_now_exchange.dart';
import '../../../services/exchange/exchange.dart';
import '../../../services/exchange/exolix/exolix_exchange.dart';
import '../../../services/exchange/nanswap/nanswap_exchange.dart';
import '../../../services/exchange/trocador/trocador_exchange.dart';
import '../../../services/exchange/wizard_swap/wizard_swap_exchange.dart';
Expand Down Expand Up @@ -97,6 +98,11 @@ class _ExchangeProviderOptionsState
sendCurrency: sendCurrency,
receiveCurrency: receivingCurrency,
);
final showExolix = exchangeSupported(
exchangeName: ExolixExchange.exchangeName,
sendCurrency: sendCurrency,
receiveCurrency: receivingCurrency,
);

return RoundedWhiteContainer(
padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12),
Expand All @@ -106,6 +112,7 @@ class _ExchangeProviderOptionsState
child: SortedExchangeProviders(
exchangees: [
if (showChangeNow) ChangeNowExchange.instance,
if (showExolix) ExolixExchange.instance,
if (showTrocador) TrocadorExchange.instance,
if (showNanswap) NanswapExchange.instance,
if (showWizardSwap) WizardSwapExchange.instance,
Expand Down
14 changes: 13 additions & 1 deletion lib/pages/exchange_view/trade_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import '../../providers/providers.dart';
import '../../route_generator.dart';
import '../../services/exchange/change_now/change_now_exchange.dart';
import '../../services/exchange/exchange.dart';
import '../../services/exchange/exolix/exolix_exchange.dart';
import '../../services/exchange/nanswap/nanswap_exchange.dart';
import '../../services/exchange/simpleswap/simpleswap_exchange.dart';
import '../../services/exchange/trocador/trocador_exchange.dart';
Expand Down Expand Up @@ -119,17 +120,21 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
String _fetchIconAssetForStatus(String statusString, IThemeAssets assets) {
ChangeNowTransactionStatus? status;
try {
if (statusString.toLowerCase().startsWith("waiting")) {
if (statusString.toLowerCase().startsWith("waiting") ||
statusString.toLowerCase() == "wait") {
statusString = "Waiting";
}
status = changeNowTransactionStatusFromStringIgnoreCase(statusString);
} on ArgumentError catch (_) {
switch (statusString.toLowerCase()) {
case "confirmed": // exolix case
case "confirmation": // exolix case
case "funds confirming":
case "processing payment":
return assets.txExchangePending;

case "completed":
case "success": // exolix case
return assets.txExchange;

default:
Expand Down Expand Up @@ -168,6 +173,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
sentFromStack ||
!(trade.status == "New" ||
trade.status == "new" ||
trade.status == "wait" ||
trade.status == "Waiting" ||
trade.status == "waiting" ||
trade.status == "Refunded" ||
Expand All @@ -178,6 +184,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
trade.status == "expired" ||
trade.status == "Failed" ||
trade.status == "failed" ||
trade.status == "overdue" ||
trade.status.toLowerCase().startsWith("waiting"));

//todo: check if print needed
Expand All @@ -202,6 +209,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
(trade.status == "New" ||
trade.status == "new" ||
trade.status == "waiting" ||
trade.status == "wait" ||
trade.status == "Waiting");

return ConditionalParent(
Expand Down Expand Up @@ -1162,6 +1170,10 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
url =
"https://www.wizardswap.io/api/exchange/${trade.tradeId}";
break;
case ExolixExchange.exchangeName:
url =
"https://exolix.com/transaction/${trade.tradeId}";
break;

default:
if (trade.exchangeName.startsWith(
Expand Down
4 changes: 4 additions & 0 deletions lib/services/exchange/exchange.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import '../../models/exchange/response_objects/trade.dart';
import '../../models/isar/exchange_cache/currency.dart';
import 'change_now/change_now_exchange.dart';
import 'exchange_response.dart';
import 'exolix/exolix_exchange.dart';
import 'nanswap/nanswap_exchange.dart';
import 'simpleswap/simpleswap_exchange.dart';
import 'trocador/trocador_exchange.dart';
Expand All @@ -38,6 +39,8 @@ abstract class Exchange {
return NanswapExchange.instance;
case WizardSwapExchange.exchangeName:
return WizardSwapExchange.instance;
case ExolixExchange.exchangeName:
return ExolixExchange.instance;
default:
final split = name.split(" ");
if (split.length >= 2) {
Expand Down Expand Up @@ -110,6 +113,7 @@ abstract class Exchange {
static List<Exchange> get exchangesWithTorSupport => [
// MajesticBankExchange.instance,
TrocadorExchange.instance,
ExolixExchange.instance, // Maybe??
NanswapExchange.instance, // Maybe??
];

Expand Down
25 changes: 25 additions & 0 deletions lib/services/exchange/exchange_data_loading_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import '../../utilities/logger.dart';
import '../../utilities/prefs.dart';
import '../../utilities/stack_file_system.dart';
import 'change_now/change_now_exchange.dart';
import 'exolix/exolix_exchange.dart';
import 'nanswap/nanswap_exchange.dart';
import 'trocador/trocador_exchange.dart';
import 'wizard_swap/wizard_swap_exchange.dart';
Expand Down Expand Up @@ -209,6 +210,7 @@ class ExchangeDataLoadingService {
loadTrocadorCurrencies(),
loadNanswapCurrencies(),
loadWizardSwapCurrencies(),
loadExolixCurrencies(),
];

// If using Tor, don't load data for exchanges which don't support Tor.
Expand Down Expand Up @@ -460,6 +462,29 @@ class ExchangeDataLoadingService {
}
}

Future<void> loadExolixCurrencies() async {
if (_isar == null) {
await initDB();
}
final responseCurrencies = await ExolixExchange.instance.getAllCurrencies(
false,
);

if (responseCurrencies.value != null) {
await (await isar).writeTxn(() async {
final idsToDelete = await (await isar).currencies
.where()
.exchangeNameEqualTo(ExolixExchange.exchangeName)
.idProperty()
.findAll();
await (await isar).currencies.deleteAll(idsToDelete);
await (await isar).currencies.putAll(responseCurrencies.value!);
});
} else {
Logging.instance.w("loadExolixCurrencies: $responseCurrencies");
}
}

// Future<void> loadMajesticBankPairs() async {
// final exchange = MajesticBankExchange.instance;
//
Expand Down
6 changes: 6 additions & 0 deletions lib/services/exchange/exolix/api/dto/exolix_base_dto.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
abstract class ExolixBaseDto {
Map<String, dynamic> toMap();

@override
String toString() => toMap().toString();
}
51 changes: 51 additions & 0 deletions lib/services/exchange/exolix/api/dto/exolix_coin_info.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'exolix_base_dto.dart';

/// The "coinFrom" / "coinTo" sub-object inside a transaction.
class ExolixCoinInfo extends ExolixBaseDto {
final String coinCode;
final String coinName;
final String network;
final String networkName;
final String? networkShortName;
final String? icon;
final String? memoName;
final String? contract;

ExolixCoinInfo({
required this.coinCode,
required this.coinName,
required this.network,
required this.networkName,
required this.networkShortName,
required this.icon,
required this.memoName,
required this.contract,
});

factory ExolixCoinInfo.fromJson(Map<String, dynamic> json) {
return ExolixCoinInfo(
coinCode: json["coinCode"] as String? ?? "",
coinName: json["coinName"] as String? ?? "",
network: json["network"] as String? ?? "",
networkName: json["networkName"] as String? ?? "",
networkShortName: json["networkShortName"] as String?,
icon: json["icon"] as String?,
memoName: json["memoName"] as String?,
contract: json["contract"] as String?,
);
}

@override
Map<String, dynamic> toMap() {
return {
"coinCode": coinCode,
"coinName": coinName,
"network": network,
"networkName": networkName,
"networkShortName": networkShortName,
"icon": icon,
"memoName": memoName,
"contract": contract,
};
}
}
51 changes: 51 additions & 0 deletions lib/services/exchange/exolix/api/dto/exolix_currency.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'exolix_base_dto.dart';
import 'exolix_network.dart';

/// A currency entry.
class ExolixCurrency extends ExolixBaseDto {
final String code;
final String name;
final String? icon;
final String? notes;

/// Only populated when the listing was requested with withNetworks=true.
final List<ExolixNetwork> networks;

ExolixCurrency({
required this.code,
required this.name,
required this.icon,
required this.notes,
required this.networks,
});

factory ExolixCurrency.fromJson(Map<String, dynamic> json) {
final dynamic rawNetworks = json["networks"];
final List<ExolixNetwork> nets = (rawNetworks is List)
? rawNetworks
.map(
(e) =>
ExolixNetwork.fromJson(Map<String, dynamic>.from(e as Map)),
)
.toList()
: [];
return ExolixCurrency(
code: json["code"] as String? ?? "",
name: json["name"] as String? ?? "",
icon: json["icon"] as String?,
notes: json["notes"] as String?,
networks: nets,
);
}

@override
Map<String, dynamic> toMap() {
return {
"code": code,
"name": name,
"icon": icon,
"notes": notes,
"networks": networks.map((n) => n.toMap()).toList(),
};
}
}
21 changes: 21 additions & 0 deletions lib/services/exchange/exolix/api/dto/exolix_hash.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'exolix_base_dto.dart';

/// A transaction hash sub-object (hashIn / hashOut).
class ExolixHash extends ExolixBaseDto {
final String? hash;
final String? link;

ExolixHash({required this.hash, required this.link});

factory ExolixHash.fromJson(Map<String, dynamic> json) {
return ExolixHash(
hash: json["hash"] as String?,
link: json["link"] as String?,
);
}

@override
Map<String, dynamic> toMap() {
return {"hash": hash, "link": link};
}
}
Loading
Loading