diff --git a/lib/app/features/wallets/model/swap_coin_data.f.dart b/lib/app/features/wallets/model/swap_coin_data.f.dart index 29ad81aec8..2d73278b79 100644 --- a/lib/app/features/wallets/model/swap_coin_data.f.dart +++ b/lib/app/features/wallets/model/swap_coin_data.f.dart @@ -17,7 +17,6 @@ class SwapCoinData with _$SwapCoinData { NetworkData? buyNetwork, SwapQuoteInfo? swapQuoteInfo, @Default(false) bool isQuoteLoading, - @Default(false) bool isQuoteError, @Default(0) double amount, BigInt? quoteAmount, Exception? quoteError, @@ -26,4 +25,6 @@ class SwapCoinData with _$SwapCoinData { const SwapCoinData._(); static const double defaultSlippage = 3; + + bool get isQuoteError => quoteError != null; } diff --git a/lib/app/features/wallets/providers/send_coins_notifier_provider.r.dart b/lib/app/features/wallets/providers/send_coins_notifier_provider.r.dart index 02c0ae194e..e7f448e593 100644 --- a/lib/app/features/wallets/providers/send_coins_notifier_provider.r.dart +++ b/lib/app/features/wallets/providers/send_coins_notifier_provider.r.dart @@ -26,7 +26,6 @@ import 'package:ion/app/features/wallets/model/transaction_details.f.dart'; import 'package:ion/app/features/wallets/model/transaction_status.f.dart'; import 'package:ion/app/features/wallets/model/transaction_type.dart'; import 'package:ion/app/features/wallets/model/transfer_result.f.dart'; -import 'package:ion/app/features/wallets/providers/send_asset_form_provider.r.dart'; import 'package:ion/app/features/wallets/providers/synced_coins_by_symbol_group_provider.r.dart'; import 'package:ion/app/features/wallets/providers/wallet_view_data_provider.r.dart'; import 'package:ion/app/services/logger/logger.dart'; @@ -57,8 +56,6 @@ class SendCoinsNotifier extends _$SendCoinsNotifier { state = const AsyncValue.loading(); state = await AsyncValue.guard(() async { - final form = ref.read(sendAssetFormControllerProvider); - final coinAssetData = _extractCoinAssetData(form); final (senderWallet, sendableAsset, selectedOption) = _validateFormComponents(form, coinAssetData); diff --git a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/components/conversion_info_row.dart b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/components/conversion_info_row.dart index d6a9a1c175..4391690592 100644 --- a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/components/conversion_info_row.dart +++ b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/components/conversion_info_row.dart @@ -133,6 +133,8 @@ class _ErrorState extends StatelessWidget { quoteError! as OkxException, ), InsufficientBalanceException() => context.i18n.error_swap_82000, + final AmountBelowMinimumException ex => + context.i18n.error_swap_amount_below_min(ex.minAmount, ex.symbol), _ => context.i18n.error_getting_swap_quote, }; } @@ -212,11 +214,13 @@ class _ErrorState extends StatelessWidget { size: 16.0.s, ), SizedBox(width: 5.0.s), - Text( - _getErrorMessage( - context, + Expanded( + child: Text( + _getErrorMessage( + context, + ), + style: textStyles.body2.copyWith(), ), - style: textStyles.body2.copyWith(), ), ], ), diff --git a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/exceptions/insufficient_balance_exception.dart b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/exceptions/insufficient_balance_exception.dart index a627e9338d..6dbac1eec6 100644 --- a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/exceptions/insufficient_balance_exception.dart +++ b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/exceptions/insufficient_balance_exception.dart @@ -1,3 +1,10 @@ // SPDX-License-Identifier: ice License 1.0 final class InsufficientBalanceException implements Exception {} + +final class AmountBelowMinimumException implements Exception { + AmountBelowMinimumException({required this.symbol, required this.minAmount}); + + final String symbol; + final String minAmount; +} diff --git a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/providers/swap_coins_controller_provider.r.dart b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/providers/swap_coins_controller_provider.r.dart index 50df410f93..7d83933390 100644 --- a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/providers/swap_coins_controller_provider.r.dart +++ b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/providers/swap_coins_controller_provider.r.dart @@ -21,6 +21,8 @@ import 'package:ion/app/services/ion_swap_client/ion_swap_client_provider.r.dart import 'package:ion/app/services/sentry/sentry_service.dart'; import 'package:ion/app/services/storage/local_storage.r.dart'; import 'package:ion_identity_client/ion_identity.dart'; +import 'package:ion_swap_client/exceptions/exolix_exceptions.dart'; +import 'package:ion_swap_client/exceptions/ion_swap_exception.dart'; import 'package:ion_swap_client/exceptions/okx_exceptions.dart'; import 'package:ion_swap_client/exceptions/relay_exception.dart'; import 'package:ion_swap_client/models/ion_swap_request.dart'; @@ -55,7 +57,6 @@ class SwapCoinsController extends _$SwapCoinsController { buyNetwork: null, swapQuoteInfo: null, amount: 0, - isQuoteError: false, isQuoteLoading: false, quoteAmount: null, quoteError: null, @@ -94,7 +95,6 @@ class SwapCoinsController extends _$SwapCoinsController { if (sellCoinInWallet.amount < amount) { state = state.copyWith( - isQuoteError: true, quoteError: InsufficientBalanceException(), swapQuoteInfo: null, ); @@ -474,31 +474,48 @@ class SwapCoinsController extends _$SwapCoinsController { swapCoinData: swapCoinParameters, ); + final isValidAmount = _validateAmount(swapCoinParameters.amount, swapQuoteInfo); + if (!isValidAmount) { + return; + } + state = state.copyWith( isQuoteLoading: false, swapQuoteInfo: swapQuoteInfo, - isQuoteError: false, quoteError: null, ); } catch (e, stackTrace) { - await SentryService.logException( - e, - stackTrace: stackTrace, - tag: 'get_swap_quote_failure', - ); - Exception? quoteError; - if (e is OkxException || e is RelayException) { + if (e is ExolixBelowMinimumException) { + state = state.copyWith( + isQuoteLoading: false, + swapQuoteInfo: null, + quoteError: AmountBelowMinimumException( + minAmount: e.minAmount.toString(), + symbol: (state.sellCoin?.abbreviation ?? '').toUpperCase(), + ), + ); + return; + } + + if (e is OkxException || e is RelayException || e is ExolixException) { quoteError = e as Exception; } state = state.copyWith( isQuoteLoading: false, swapQuoteInfo: null, - isQuoteError: true, quoteError: quoteError, ); + + if (e is! IonSwapException) { + await SentryService.logException( + e, + stackTrace: stackTrace, + tag: 'get_swap_quote_failure', + ); + } } } @@ -523,6 +540,38 @@ class SwapCoinsController extends _$SwapCoinsController { return null; } + bool _validateAmount(String userAmountStr, SwapQuoteInfo quoteInfo) { + final userAmount = double.tryParse(userAmountStr); + if (userAmount == null) return true; + + final (minAmountValue, minAmountStr) = switch (quoteInfo.source) { + SwapQuoteInfoSource.exolix when quoteInfo.exolixQuote != null => ( + quoteInfo.exolixQuote!.minAmount, + quoteInfo.exolixQuote!.minAmount.toString(), + ), + SwapQuoteInfoSource.letsExchange when quoteInfo.letsExchangeQuote != null => ( + double.tryParse(quoteInfo.letsExchangeQuote!.minAmount), + quoteInfo.letsExchangeQuote!.minAmount, + ), + _ => (null, '0'), + }; + + if (minAmountValue == null || userAmount >= minAmountValue) { + return true; + } + + state = state.copyWith( + swapQuoteInfo: null, + isQuoteLoading: false, + quoteError: AmountBelowMinimumException( + minAmount: minAmountStr, + symbol: (state.sellCoin?.abbreviation ?? '').toUpperCase(), + ), + ); + + return false; + } + Future getIsIonBscSwap() async { final (:swapQuoteInfo, :swapCoinParameters, :sellNetwork, :sellCoin) = await _getData(); diff --git a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/swap_coins_confirmation_page.dart b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/swap_coins_confirmation_page.dart index 511f55d8b3..9a83bec7ff 100644 --- a/lib/app/features/wallets/views/pages/coins_flow/swap_coins/swap_coins_confirmation_page.dart +++ b/lib/app/features/wallets/views/pages/coins_flow/swap_coins/swap_coins_confirmation_page.dart @@ -14,10 +14,13 @@ import 'package:ion/app/features/components/verify_identity/verify_identity_prom import 'package:ion/app/features/wallets/model/coins_group.f.dart'; import 'package:ion/app/features/wallets/model/network_data.f.dart'; import 'package:ion/app/features/wallets/providers/send_coins_notifier_provider.r.dart'; +import 'package:ion/app/features/wallets/utils/crypto_amount_converter.dart'; import 'package:ion/app/features/wallets/views/components/coin_icon_with_network.dart'; import 'package:ion/app/features/wallets/views/pages/coins_flow/swap_coins/providers/swap_coins_controller_provider.r.dart'; +import 'package:ion/app/features/wallets/views/utils/crypto_formatter.dart'; import 'package:ion/app/router/components/navigation_app_bar/navigation_app_bar.dart'; import 'package:ion/app/router/components/sheet_content/sheet_content.dart'; +import 'package:ion/app/utils/num.dart'; import 'package:ion/generated/assets.gen.dart'; import 'package:ion_identity_client/ion_identity.dart'; import 'package:ion_swap_client/models/swap_quote_info.m.dart'; @@ -227,12 +230,33 @@ class _SwapDetailsSection extends ConsumerWidget { final swapQuoteInfo = swapCoinsController.swapQuoteInfo; final sellCoin = swapCoinsController.sellCoin; final buyCoin = swapCoinsController.buyCoin; + final buyNetwork = swapCoinsController.buyNetwork; final priceImpact = swapQuoteInfo?.swapImpact; final slippage = swapCoinsController.slippage; final networkFee = swapQuoteInfo?.networkFee; final protocolFee = swapQuoteInfo?.protocolFee; final isVisibleMoreButton = priceImpact != null || networkFee != null || protocolFee != null; + // Format fees based on API source + String? formattedNetworkFee; + String? formattedProtocolFee; + + if (networkFee != null) { + formattedNetworkFee = _formatNetworkFee( + fee: networkFee, + source: swapQuoteInfo?.source, + network: buyNetwork, + ); + } + + if (protocolFee != null) { + formattedProtocolFee = _formatProtocolFee( + fee: protocolFee, + source: swapQuoteInfo?.source, + coin: buyCoin, + ); + } + return Stack( clipBehavior: Clip.none, children: [ @@ -245,10 +269,6 @@ class _SwapDetailsSection extends ConsumerWidget { decoration: BoxDecoration( color: colors.tertiaryBackground, borderRadius: BorderRadius.circular(16.0.s), - border: Border.all( - color: colors.onTertiaryFill, - width: 0.5, - ), ), child: Column( children: [ @@ -282,20 +302,20 @@ class _SwapDetailsSection extends ConsumerWidget { label: context.i18n.wallet_swap_confirmation_slippage, value: '${slippage.toStringAsFixed(1)}%', ), - if (networkFee != null) ...[ + if (formattedNetworkFee != null) ...[ _Divider(), _DetailRow( isVisible: showMoreDetails, label: context.i18n.wallet_swap_confirmation_network_fee, - value: networkFee, + value: formattedNetworkFee, ), ], - if (protocolFee != null) ...[ + if (formattedProtocolFee != null) ...[ _Divider(), _DetailRow( isVisible: showMoreDetails, label: context.i18n.wallet_swap_confirmation_protocol_fee, - value: protocolFee, + value: formattedProtocolFee, ), ], ], @@ -307,45 +327,59 @@ class _SwapDetailsSection extends ConsumerWidget { ), if (isVisibleMoreButton) Positioned.fill( - bottom: -10.0.s, + bottom: -25.0.s, child: Container( width: double.infinity, alignment: Alignment.bottomCenter, - height: 21.0.s, child: GestureDetector( onTap: onToggleDetails, child: Container( - width: 75.0.s, + // Invisible padding to expand tap area padding: EdgeInsets.symmetric( - horizontal: 12.0.s, - vertical: 4.0.s, + horizontal: 8.0.s, + vertical: 8.0.s, ), - decoration: BoxDecoration( - color: colors.tertiaryBackground, - borderRadius: BorderRadius.circular(9.0.s), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - showMoreDetails - ? context.i18n.wallet_swap_confirmation_less - : context.i18n.wallet_swap_confirmation_more, - style: textStyles.caption2.copyWith( - color: colors.primaryText, - ), + color: Colors.transparent, + child: Container( + padding: EdgeInsets.all(3.0.s), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(9.0.s), + color: colors.secondaryBackground, + ), + child: Container( + height: 21.0.s, + width: 75.0.s, + padding: EdgeInsets.symmetric( + horizontal: 12.0.s, ), - SizedBox(width: 4.0.s), - AnimatedRotation( - turns: showMoreDetails ? 0.5 : 0.0, - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - child: Assets.svg.iconArrowDown.icon( - color: colors.primaryText, - size: 16.0.s, - ), + decoration: BoxDecoration( + color: colors.tertiaryBackground, + borderRadius: BorderRadius.circular(9.0.s), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + showMoreDetails + ? context.i18n.wallet_swap_confirmation_less + : context.i18n.wallet_swap_confirmation_more, + style: textStyles.caption2.copyWith( + color: colors.primaryText, + ), + ), + SizedBox(width: 4.0.s), + AnimatedRotation( + turns: showMoreDetails ? 0.5 : 0.0, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + child: Assets.svg.iconArrowDown.icon( + color: colors.primaryText, + size: 16.0.s, + ), + ), + ], ), - ], + ), ), ), ), @@ -354,6 +388,105 @@ class _SwapDetailsSection extends ConsumerWidget { ], ); } + + /// Formats network fee based on API source: + /// - OKX: Converts from wei to native token (ETH/BNB) + /// - Relay: Already formatted, returns as-is + /// - LetsExchange: Formats with destination currency + String? _formatNetworkFee({ + required String? fee, + required SwapQuoteInfoSource? source, + required NetworkData? network, + }) { + if (fee == null || fee.isEmpty) return null; + + // Relay API already provides formatted fees with currency + if (source == SwapQuoteInfoSource.relay) { + return fee; + } + + // For LetsExchange: withdrawal_fee is in destination currency + // Note: Network fee formatting for LetsExchange would need coin info + // but withdrawal_fee is already a formatted string in destination currency + if (source == SwapQuoteInfoSource.letsExchange) { + return fee; + } + + try { + final feeValue = double.tryParse(fee); + if (feeValue == null) return fee; + + // For OKX API: estimateGasFee is in wei + if (source == SwapQuoteInfoSource.okx) { + // Convert from wei to native token (18 decimals) + final convertedFee = fromBlockchainUnits(fee, 18); + final nativeTokenSymbol = _getNativeTokenSymbol(network); + return formatCrypto(convertedFee, nativeTokenSymbol); + } + + // Default: return as-is + return fee; + } catch (e) { + // If parsing fails, return original value + return fee; + } + } + + /// Formats protocol fee based on API source: + /// - OKX: Formats as USD (tradeFee is estimated network fee in USD) + /// - Relay: Already formatted, returns as-is + /// - LetsExchange: Formats with destination currency + String? _formatProtocolFee({ + required String? fee, + required SwapQuoteInfoSource? source, + required CoinsGroup? coin, + }) { + if (fee == null || fee.isEmpty) return null; + + // Relay API already provides formatted fees with currency + if (source == SwapQuoteInfoSource.relay) { + return fee; + } + + try { + final feeValue = double.tryParse(fee); + if (feeValue == null) return fee; + + // For OKX API: tradeFee is estimated network fee in USD + if (source == SwapQuoteInfoSource.okx) { + return formatToCurrency(feeValue); + } + + // For LetsExchange: fee is in destination currency units + if (source == SwapQuoteInfoSource.letsExchange) { + if (coin == null) return fee; + return formatCrypto(feeValue, coin.abbreviation); + } + + // Default: format with currency + if (coin == null) return fee; + return formatCrypto(feeValue, coin.abbreviation); + } catch (e) { + // If parsing fails, return original value + return fee; + } + } + + /// Gets the native token symbol for the network (ETH, BNB, etc.) + String _getNativeTokenSymbol(NetworkData? network) { + if (network == null) return 'ETH'; + // Check network to determine native token + final networkId = network.id.toLowerCase(); + return switch (networkId) { + 'bsc' => 'BNB', + 'ethereum' => 'ETH', + 'polygon' => 'MATIC', + 'avalanche' => 'AVAX', + 'arbitrum' => 'ETH', + 'optimism' => 'ETH', + _ => 'ETH', // Default to ETH + }; + } } class _DetailRow extends StatelessWidget { diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index b283fc0bd2..22f70e4bf4 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -448,6 +448,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "الحد الأدنى لمبلغ التبادل عبر الشبكات هو {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_bg.arb b/lib/l10n/app_bg.arb index 7612d7b71a..57f68ad63a 100644 --- a/lib/l10n/app_bg.arb +++ b/lib/l10n/app_bg.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Минималната сума за обмен между мрежи е {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 65cfa92b29..3406e86968 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Der Mindestbetrag für netzwerkübergreifende Swaps beträgt {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 329dd71f2d..cb3fe26fcb 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Minimum cross-network swap amount is {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 2eee556e07..a8312d265d 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "El monto mínimo de intercambio entre redes es {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 28c230cb70..11ed8775b6 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Le montant minimum d'échange inter-réseau est de {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 0070bffbe1..83af98d002 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "L'importo minimo di swap cross-network è {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index 054d1bef38..ffac7d3b37 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Minimalna kwota wymiany między sieciami to {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_ro.arb b/lib/l10n/app_ro.arb index 8bdc3c9d05..192fb3b68f 100644 --- a/lib/l10n/app_ro.arb +++ b/lib/l10n/app_ro.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Suma minimă pentru swap cross-network este {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index 59e25ace3a..2dca82af44 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Минимальная сумма кросс-сетевого обмена составляет {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_tr.arb b/lib/l10n/app_tr.arb index e02299b954..ee30024fe3 100644 --- a/lib/l10n/app_tr.arb +++ b/lib/l10n/app_tr.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "Ağlar arası minimum takas miktarı {amount} {symbol}.", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 69ba677b96..608b74455d 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -442,6 +442,7 @@ "error_swap_82112": "The value difference from this transaction's quote route is higher, which may cause asset loss, It can be adjusted using the string age.", "error_swap_82116": "callData exceeds the maximum limit. Try again in 5 minutes.", "error_swap_82130": "The chain does not require authorized transactions and can be exchanged directly.", + "error_swap_amount_below_min": "跨网络交换的最小金额为 {amount} {symbol}。", "error_swap_amount_too_low": "The amount provided is below the minimum threshold required for a quote.", "error_swap_chain_disabled": "The origin or destination chain is currently disabled or unsupported.", "error_swap_coin_pair_not_found": "Coin pair not found", diff --git a/packages/ion_swap_client/lib/exceptions/exolix_exceptions.dart b/packages/ion_swap_client/lib/exceptions/exolix_exceptions.dart new file mode 100644 index 0000000000..95469961be --- /dev/null +++ b/packages/ion_swap_client/lib/exceptions/exolix_exceptions.dart @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: ice License 1.0 + +import 'package:ion_swap_client/exceptions/ion_swap_exception.dart'; + +class ExolixException extends IonSwapException { + const ExolixException([super.message]); +} + +class ExolixBelowMinimumException extends ExolixException { + const ExolixBelowMinimumException({ + required this.minAmount, + required String message, + }) : super(message); + + final num minAmount; +} diff --git a/packages/ion_swap_client/lib/models/approve_transaction_data.m.freezed.dart b/packages/ion_swap_client/lib/models/approve_transaction_data.m.freezed.dart index 2d5ead5197..e72e90cef8 100644 --- a/packages/ion_swap_client/lib/models/approve_transaction_data.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/approve_transaction_data.m.freezed.dart @@ -14,7 +14,8 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); -ApproveTransactionData _$ApproveTransactionDataFromJson(Map json) { +ApproveTransactionData _$ApproveTransactionDataFromJson( + Map json) { return _ApproveTransactionData.fromJson(json); } @@ -37,15 +38,20 @@ mixin _$ApproveTransactionData { /// @nodoc abstract class $ApproveTransactionDataCopyWith<$Res> { - factory $ApproveTransactionDataCopyWith( - ApproveTransactionData value, $Res Function(ApproveTransactionData) then) = + factory $ApproveTransactionDataCopyWith(ApproveTransactionData value, + $Res Function(ApproveTransactionData) then) = _$ApproveTransactionDataCopyWithImpl<$Res, ApproveTransactionData>; @useResult - $Res call({String data, String dexContractAddress, String gasLimit, String gasPrice}); + $Res call( + {String data, + String dexContractAddress, + String gasLimit, + String gasPrice}); } /// @nodoc -class _$ApproveTransactionDataCopyWithImpl<$Res, $Val extends ApproveTransactionData> +class _$ApproveTransactionDataCopyWithImpl<$Res, + $Val extends ApproveTransactionData> implements $ApproveTransactionDataCopyWith<$Res> { _$ApproveTransactionDataCopyWithImpl(this._value, this._then); @@ -89,19 +95,26 @@ class _$ApproveTransactionDataCopyWithImpl<$Res, $Val extends ApproveTransaction abstract class _$$ApproveTransactionDataImplCopyWith<$Res> implements $ApproveTransactionDataCopyWith<$Res> { factory _$$ApproveTransactionDataImplCopyWith( - _$ApproveTransactionDataImpl value, $Res Function(_$ApproveTransactionDataImpl) then) = + _$ApproveTransactionDataImpl value, + $Res Function(_$ApproveTransactionDataImpl) then) = __$$ApproveTransactionDataImplCopyWithImpl<$Res>; @override @useResult - $Res call({String data, String dexContractAddress, String gasLimit, String gasPrice}); + $Res call( + {String data, + String dexContractAddress, + String gasLimit, + String gasPrice}); } /// @nodoc class __$$ApproveTransactionDataImplCopyWithImpl<$Res> - extends _$ApproveTransactionDataCopyWithImpl<$Res, _$ApproveTransactionDataImpl> + extends _$ApproveTransactionDataCopyWithImpl<$Res, + _$ApproveTransactionDataImpl> implements _$$ApproveTransactionDataImplCopyWith<$Res> { __$$ApproveTransactionDataImplCopyWithImpl( - _$ApproveTransactionDataImpl _value, $Res Function(_$ApproveTransactionDataImpl) _then) + _$ApproveTransactionDataImpl _value, + $Res Function(_$ApproveTransactionDataImpl) _then) : super(_value, _then); /// Create a copy of ApproveTransactionData @@ -169,21 +182,25 @@ class _$ApproveTransactionDataImpl implements _ApproveTransactionData { (identical(other.data, data) || other.data == data) && (identical(other.dexContractAddress, dexContractAddress) || other.dexContractAddress == dexContractAddress) && - (identical(other.gasLimit, gasLimit) || other.gasLimit == gasLimit) && - (identical(other.gasPrice, gasPrice) || other.gasPrice == gasPrice)); + (identical(other.gasLimit, gasLimit) || + other.gasLimit == gasLimit) && + (identical(other.gasPrice, gasPrice) || + other.gasPrice == gasPrice)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, data, dexContractAddress, gasLimit, gasPrice); + int get hashCode => + Object.hash(runtimeType, data, dexContractAddress, gasLimit, gasPrice); /// Create a copy of ApproveTransactionData /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$ApproveTransactionDataImplCopyWith<_$ApproveTransactionDataImpl> get copyWith => - __$$ApproveTransactionDataImplCopyWithImpl<_$ApproveTransactionDataImpl>(this, _$identity); + _$$ApproveTransactionDataImplCopyWith<_$ApproveTransactionDataImpl> + get copyWith => __$$ApproveTransactionDataImplCopyWithImpl< + _$ApproveTransactionDataImpl>(this, _$identity); @override Map toJson() { @@ -216,6 +233,6 @@ abstract class _ApproveTransactionData implements ApproveTransactionData { /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$ApproveTransactionDataImplCopyWith<_$ApproveTransactionDataImpl> get copyWith => - throw _privateConstructorUsedError; + _$$ApproveTransactionDataImplCopyWith<_$ApproveTransactionDataImpl> + get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/ion_swap_client/lib/models/approve_transaction_data.m.g.dart b/packages/ion_swap_client/lib/models/approve_transaction_data.m.g.dart index 4c6d5ade2b..ce7d139207 100644 --- a/packages/ion_swap_client/lib/models/approve_transaction_data.m.g.dart +++ b/packages/ion_swap_client/lib/models/approve_transaction_data.m.g.dart @@ -6,7 +6,8 @@ part of 'approve_transaction_data.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ApproveTransactionDataImpl _$$ApproveTransactionDataImplFromJson(Map json) => +_$ApproveTransactionDataImpl _$$ApproveTransactionDataImplFromJson( + Map json) => _$ApproveTransactionDataImpl( data: json['data'] as String, dexContractAddress: json['dexContractAddress'] as String, @@ -14,7 +15,8 @@ _$ApproveTransactionDataImpl _$$ApproveTransactionDataImplFromJson(Map _$$ApproveTransactionDataImplToJson(_$ApproveTransactionDataImpl instance) => +Map _$$ApproveTransactionDataImplToJson( + _$ApproveTransactionDataImpl instance) => { 'data': instance.data, 'dexContractAddress': instance.dexContractAddress, diff --git a/packages/ion_swap_client/lib/models/chain_data.m.freezed.dart b/packages/ion_swap_client/lib/models/chain_data.m.freezed.dart index c92113bb66..cac97c8b53 100644 --- a/packages/ion_swap_client/lib/models/chain_data.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/chain_data.m.freezed.dart @@ -29,7 +29,8 @@ mixin _$ChainData { /// Create a copy of ChainData /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $ChainDataCopyWith get copyWith => throw _privateConstructorUsedError; + $ChainDataCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc @@ -41,7 +42,8 @@ abstract class $ChainDataCopyWith<$Res> { } /// @nodoc -class _$ChainDataCopyWithImpl<$Res, $Val extends ChainData> implements $ChainDataCopyWith<$Res> { +class _$ChainDataCopyWithImpl<$Res, $Val extends ChainData> + implements $ChainDataCopyWith<$Res> { _$ChainDataCopyWithImpl(this._value, this._then); // ignore: unused_field @@ -71,8 +73,10 @@ class _$ChainDataCopyWithImpl<$Res, $Val extends ChainData> implements $ChainDat } /// @nodoc -abstract class _$$ChainDataImplCopyWith<$Res> implements $ChainDataCopyWith<$Res> { - factory _$$ChainDataImplCopyWith(_$ChainDataImpl value, $Res Function(_$ChainDataImpl) then) = +abstract class _$$ChainDataImplCopyWith<$Res> + implements $ChainDataCopyWith<$Res> { + factory _$$ChainDataImplCopyWith( + _$ChainDataImpl value, $Res Function(_$ChainDataImpl) then) = __$$ChainDataImplCopyWithImpl<$Res>; @override @useResult @@ -80,9 +84,11 @@ abstract class _$$ChainDataImplCopyWith<$Res> implements $ChainDataCopyWith<$Res } /// @nodoc -class __$$ChainDataImplCopyWithImpl<$Res> extends _$ChainDataCopyWithImpl<$Res, _$ChainDataImpl> +class __$$ChainDataImplCopyWithImpl<$Res> + extends _$ChainDataCopyWithImpl<$Res, _$ChainDataImpl> implements _$$ChainDataImplCopyWith<$Res> { - __$$ChainDataImplCopyWithImpl(_$ChainDataImpl _value, $Res Function(_$ChainDataImpl) _then) + __$$ChainDataImplCopyWithImpl( + _$ChainDataImpl _value, $Res Function(_$ChainDataImpl) _then) : super(_value, _then); /// Create a copy of ChainData @@ -111,7 +117,8 @@ class __$$ChainDataImplCopyWithImpl<$Res> extends _$ChainDataCopyWithImpl<$Res, class _$ChainDataImpl implements _ChainData { _$ChainDataImpl({required this.name, required this.networkId}); - factory _$ChainDataImpl.fromJson(Map json) => _$$ChainDataImplFromJson(json); + factory _$ChainDataImpl.fromJson(Map json) => + _$$ChainDataImplFromJson(json); @override final String name; @@ -129,7 +136,8 @@ class _$ChainDataImpl implements _ChainData { (other.runtimeType == runtimeType && other is _$ChainDataImpl && (identical(other.name, name) || other.name == name) && - (identical(other.networkId, networkId) || other.networkId == networkId)); + (identical(other.networkId, networkId) || + other.networkId == networkId)); } @JsonKey(includeFromJson: false, includeToJson: false) @@ -153,9 +161,12 @@ class _$ChainDataImpl implements _ChainData { } abstract class _ChainData implements ChainData { - factory _ChainData({required final String name, required final int networkId}) = _$ChainDataImpl; + factory _ChainData( + {required final String name, + required final int networkId}) = _$ChainDataImpl; - factory _ChainData.fromJson(Map json) = _$ChainDataImpl.fromJson; + factory _ChainData.fromJson(Map json) = + _$ChainDataImpl.fromJson; @override String get name; @@ -166,5 +177,6 @@ abstract class _ChainData implements ChainData { /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$ChainDataImplCopyWith<_$ChainDataImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChainDataImplCopyWith<_$ChainDataImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/ion_swap_client/lib/models/chain_data.m.g.dart b/packages/ion_swap_client/lib/models/chain_data.m.g.dart index a234e7dde8..d60a018e84 100644 --- a/packages/ion_swap_client/lib/models/chain_data.m.g.dart +++ b/packages/ion_swap_client/lib/models/chain_data.m.g.dart @@ -6,12 +6,14 @@ part of 'chain_data.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ChainDataImpl _$$ChainDataImplFromJson(Map json) => _$ChainDataImpl( +_$ChainDataImpl _$$ChainDataImplFromJson(Map json) => + _$ChainDataImpl( name: json['name'] as String, networkId: (json['networkId'] as num).toInt(), ); -Map _$$ChainDataImplToJson(_$ChainDataImpl instance) => { +Map _$$ChainDataImplToJson(_$ChainDataImpl instance) => + { 'name': instance.name, 'networkId': instance.networkId, }; diff --git a/packages/ion_swap_client/lib/models/exolix_coin.m.freezed.dart b/packages/ion_swap_client/lib/models/exolix_coin.m.freezed.dart index a0c51cc47a..d573177e52 100644 --- a/packages/ion_swap_client/lib/models/exolix_coin.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/exolix_coin.m.freezed.dart @@ -30,19 +30,22 @@ mixin _$ExolixCoin { /// Create a copy of ExolixCoin /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $ExolixCoinCopyWith get copyWith => throw _privateConstructorUsedError; + $ExolixCoinCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ExolixCoinCopyWith<$Res> { - factory $ExolixCoinCopyWith(ExolixCoin value, $Res Function(ExolixCoin) then) = + factory $ExolixCoinCopyWith( + ExolixCoin value, $Res Function(ExolixCoin) then) = _$ExolixCoinCopyWithImpl<$Res, ExolixCoin>; @useResult $Res call({String code, String name, List networks}); } /// @nodoc -class _$ExolixCoinCopyWithImpl<$Res, $Val extends ExolixCoin> implements $ExolixCoinCopyWith<$Res> { +class _$ExolixCoinCopyWithImpl<$Res, $Val extends ExolixCoin> + implements $ExolixCoinCopyWith<$Res> { _$ExolixCoinCopyWithImpl(this._value, this._then); // ignore: unused_field @@ -77,8 +80,10 @@ class _$ExolixCoinCopyWithImpl<$Res, $Val extends ExolixCoin> implements $Exolix } /// @nodoc -abstract class _$$ExolixCoinImplCopyWith<$Res> implements $ExolixCoinCopyWith<$Res> { - factory _$$ExolixCoinImplCopyWith(_$ExolixCoinImpl value, $Res Function(_$ExolixCoinImpl) then) = +abstract class _$$ExolixCoinImplCopyWith<$Res> + implements $ExolixCoinCopyWith<$Res> { + factory _$$ExolixCoinImplCopyWith( + _$ExolixCoinImpl value, $Res Function(_$ExolixCoinImpl) then) = __$$ExolixCoinImplCopyWithImpl<$Res>; @override @useResult @@ -86,9 +91,11 @@ abstract class _$$ExolixCoinImplCopyWith<$Res> implements $ExolixCoinCopyWith<$R } /// @nodoc -class __$$ExolixCoinImplCopyWithImpl<$Res> extends _$ExolixCoinCopyWithImpl<$Res, _$ExolixCoinImpl> +class __$$ExolixCoinImplCopyWithImpl<$Res> + extends _$ExolixCoinCopyWithImpl<$Res, _$ExolixCoinImpl> implements _$$ExolixCoinImplCopyWith<$Res> { - __$$ExolixCoinImplCopyWithImpl(_$ExolixCoinImpl _value, $Res Function(_$ExolixCoinImpl) _then) + __$$ExolixCoinImplCopyWithImpl( + _$ExolixCoinImpl _value, $Res Function(_$ExolixCoinImpl) _then) : super(_value, _then); /// Create a copy of ExolixCoin @@ -121,10 +128,13 @@ class __$$ExolixCoinImplCopyWithImpl<$Res> extends _$ExolixCoinCopyWithImpl<$Res @JsonSerializable() class _$ExolixCoinImpl implements _ExolixCoin { _$ExolixCoinImpl( - {required this.code, required this.name, required final List networks}) + {required this.code, + required this.name, + required final List networks}) : _networks = networks; - factory _$ExolixCoinImpl.fromJson(Map json) => _$$ExolixCoinImplFromJson(json); + factory _$ExolixCoinImpl.fromJson(Map json) => + _$$ExolixCoinImplFromJson(json); @override final String code; @@ -155,8 +165,8 @@ class _$ExolixCoinImpl implements _ExolixCoin { @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => - Object.hash(runtimeType, code, name, const DeepCollectionEquality().hash(_networks)); + int get hashCode => Object.hash( + runtimeType, code, name, const DeepCollectionEquality().hash(_networks)); /// Create a copy of ExolixCoin /// with the given fields replaced by the non-null parameter values. @@ -180,7 +190,8 @@ abstract class _ExolixCoin implements ExolixCoin { required final String name, required final List networks}) = _$ExolixCoinImpl; - factory _ExolixCoin.fromJson(Map json) = _$ExolixCoinImpl.fromJson; + factory _ExolixCoin.fromJson(Map json) = + _$ExolixCoinImpl.fromJson; @override String get code; @@ -193,5 +204,6 @@ abstract class _ExolixCoin implements ExolixCoin { /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$ExolixCoinImplCopyWith<_$ExolixCoinImpl> get copyWith => throw _privateConstructorUsedError; + _$$ExolixCoinImplCopyWith<_$ExolixCoinImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/ion_swap_client/lib/models/exolix_coin.m.g.dart b/packages/ion_swap_client/lib/models/exolix_coin.m.g.dart index f27a845439..a8982e8230 100644 --- a/packages/ion_swap_client/lib/models/exolix_coin.m.g.dart +++ b/packages/ion_swap_client/lib/models/exolix_coin.m.g.dart @@ -6,7 +6,8 @@ part of 'exolix_coin.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ExolixCoinImpl _$$ExolixCoinImplFromJson(Map json) => _$ExolixCoinImpl( +_$ExolixCoinImpl _$$ExolixCoinImplFromJson(Map json) => + _$ExolixCoinImpl( code: json['code'] as String, name: json['name'] as String, networks: (json['networks'] as List) @@ -14,7 +15,8 @@ _$ExolixCoinImpl _$$ExolixCoinImplFromJson(Map json) => _$Exoli .toList(), ); -Map _$$ExolixCoinImplToJson(_$ExolixCoinImpl instance) => { +Map _$$ExolixCoinImplToJson(_$ExolixCoinImpl instance) => + { 'code': instance.code, 'name': instance.name, 'networks': instance.networks, diff --git a/packages/ion_swap_client/lib/models/exolix_error.m.dart b/packages/ion_swap_client/lib/models/exolix_error.m.dart new file mode 100644 index 0000000000..8e2da683e7 --- /dev/null +++ b/packages/ion_swap_client/lib/models/exolix_error.m.dart @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: ice License 1.0 + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'exolix_error.m.freezed.dart'; +part 'exolix_error.m.g.dart'; + +@freezed +class ExolixError with _$ExolixError { + factory ExolixError({ + required num fromAmount, + required num toAmount, + required String message, + required num minAmount, + }) = _ExolixError; + + factory ExolixError.fromJson(Map json) => _$ExolixErrorFromJson(json); +} diff --git a/packages/ion_swap_client/lib/models/exolix_error.m.freezed.dart b/packages/ion_swap_client/lib/models/exolix_error.m.freezed.dart new file mode 100644 index 0000000000..1f041a2394 --- /dev/null +++ b/packages/ion_swap_client/lib/models/exolix_error.m.freezed.dart @@ -0,0 +1,224 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'exolix_error.m.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +ExolixError _$ExolixErrorFromJson(Map json) { + return _ExolixError.fromJson(json); +} + +/// @nodoc +mixin _$ExolixError { + num get fromAmount => throw _privateConstructorUsedError; + num get toAmount => throw _privateConstructorUsedError; + String get message => throw _privateConstructorUsedError; + num get minAmount => throw _privateConstructorUsedError; + + /// Serializes this ExolixError to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ExolixError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ExolixErrorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ExolixErrorCopyWith<$Res> { + factory $ExolixErrorCopyWith( + ExolixError value, $Res Function(ExolixError) then) = + _$ExolixErrorCopyWithImpl<$Res, ExolixError>; + @useResult + $Res call({num fromAmount, num toAmount, String message, num minAmount}); +} + +/// @nodoc +class _$ExolixErrorCopyWithImpl<$Res, $Val extends ExolixError> + implements $ExolixErrorCopyWith<$Res> { + _$ExolixErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ExolixError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fromAmount = null, + Object? toAmount = null, + Object? message = null, + Object? minAmount = null, + }) { + return _then(_value.copyWith( + fromAmount: null == fromAmount + ? _value.fromAmount + : fromAmount // ignore: cast_nullable_to_non_nullable + as num, + toAmount: null == toAmount + ? _value.toAmount + : toAmount // ignore: cast_nullable_to_non_nullable + as num, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + minAmount: null == minAmount + ? _value.minAmount + : minAmount // ignore: cast_nullable_to_non_nullable + as num, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ExolixErrorImplCopyWith<$Res> + implements $ExolixErrorCopyWith<$Res> { + factory _$$ExolixErrorImplCopyWith( + _$ExolixErrorImpl value, $Res Function(_$ExolixErrorImpl) then) = + __$$ExolixErrorImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({num fromAmount, num toAmount, String message, num minAmount}); +} + +/// @nodoc +class __$$ExolixErrorImplCopyWithImpl<$Res> + extends _$ExolixErrorCopyWithImpl<$Res, _$ExolixErrorImpl> + implements _$$ExolixErrorImplCopyWith<$Res> { + __$$ExolixErrorImplCopyWithImpl( + _$ExolixErrorImpl _value, $Res Function(_$ExolixErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of ExolixError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fromAmount = null, + Object? toAmount = null, + Object? message = null, + Object? minAmount = null, + }) { + return _then(_$ExolixErrorImpl( + fromAmount: null == fromAmount + ? _value.fromAmount + : fromAmount // ignore: cast_nullable_to_non_nullable + as num, + toAmount: null == toAmount + ? _value.toAmount + : toAmount // ignore: cast_nullable_to_non_nullable + as num, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + minAmount: null == minAmount + ? _value.minAmount + : minAmount // ignore: cast_nullable_to_non_nullable + as num, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ExolixErrorImpl implements _ExolixError { + _$ExolixErrorImpl( + {required this.fromAmount, + required this.toAmount, + required this.message, + required this.minAmount}); + + factory _$ExolixErrorImpl.fromJson(Map json) => + _$$ExolixErrorImplFromJson(json); + + @override + final num fromAmount; + @override + final num toAmount; + @override + final String message; + @override + final num minAmount; + + @override + String toString() { + return 'ExolixError(fromAmount: $fromAmount, toAmount: $toAmount, message: $message, minAmount: $minAmount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ExolixErrorImpl && + (identical(other.fromAmount, fromAmount) || + other.fromAmount == fromAmount) && + (identical(other.toAmount, toAmount) || + other.toAmount == toAmount) && + (identical(other.message, message) || other.message == message) && + (identical(other.minAmount, minAmount) || + other.minAmount == minAmount)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, fromAmount, toAmount, message, minAmount); + + /// Create a copy of ExolixError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ExolixErrorImplCopyWith<_$ExolixErrorImpl> get copyWith => + __$$ExolixErrorImplCopyWithImpl<_$ExolixErrorImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ExolixErrorImplToJson( + this, + ); + } +} + +abstract class _ExolixError implements ExolixError { + factory _ExolixError( + {required final num fromAmount, + required final num toAmount, + required final String message, + required final num minAmount}) = _$ExolixErrorImpl; + + factory _ExolixError.fromJson(Map json) = + _$ExolixErrorImpl.fromJson; + + @override + num get fromAmount; + @override + num get toAmount; + @override + String get message; + @override + num get minAmount; + + /// Create a copy of ExolixError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ExolixErrorImplCopyWith<_$ExolixErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/ion_swap_client/lib/models/exolix_error.m.g.dart b/packages/ion_swap_client/lib/models/exolix_error.m.g.dart new file mode 100644 index 0000000000..3e254f4960 --- /dev/null +++ b/packages/ion_swap_client/lib/models/exolix_error.m.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'exolix_error.m.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ExolixErrorImpl _$$ExolixErrorImplFromJson(Map json) => + _$ExolixErrorImpl( + fromAmount: json['fromAmount'] as num, + toAmount: json['toAmount'] as num, + message: json['message'] as String, + minAmount: json['minAmount'] as num, + ); + +Map _$$ExolixErrorImplToJson(_$ExolixErrorImpl instance) => + { + 'fromAmount': instance.fromAmount, + 'toAmount': instance.toAmount, + 'message': instance.message, + 'minAmount': instance.minAmount, + }; diff --git a/packages/ion_swap_client/lib/models/exolix_network.m.freezed.dart b/packages/ion_swap_client/lib/models/exolix_network.m.freezed.dart index 7a27ef67e7..097608417d 100644 --- a/packages/ion_swap_client/lib/models/exolix_network.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/exolix_network.m.freezed.dart @@ -32,15 +32,22 @@ mixin _$ExolixNetwork { /// Create a copy of ExolixNetwork /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $ExolixNetworkCopyWith get copyWith => throw _privateConstructorUsedError; + $ExolixNetworkCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ExolixNetworkCopyWith<$Res> { - factory $ExolixNetworkCopyWith(ExolixNetwork value, $Res Function(ExolixNetwork) then) = + factory $ExolixNetworkCopyWith( + ExolixNetwork value, $Res Function(ExolixNetwork) then) = _$ExolixNetworkCopyWithImpl<$Res, ExolixNetwork>; @useResult - $Res call({String network, String name, String shortName, bool isDefault, String? contract}); + $Res call( + {String network, + String name, + String shortName, + bool isDefault, + String? contract}); } /// @nodoc @@ -90,13 +97,19 @@ class _$ExolixNetworkCopyWithImpl<$Res, $Val extends ExolixNetwork> } /// @nodoc -abstract class _$$ExolixNetworkImplCopyWith<$Res> implements $ExolixNetworkCopyWith<$Res> { +abstract class _$$ExolixNetworkImplCopyWith<$Res> + implements $ExolixNetworkCopyWith<$Res> { factory _$$ExolixNetworkImplCopyWith( _$ExolixNetworkImpl value, $Res Function(_$ExolixNetworkImpl) then) = __$$ExolixNetworkImplCopyWithImpl<$Res>; @override @useResult - $Res call({String network, String name, String shortName, bool isDefault, String? contract}); + $Res call( + {String network, + String name, + String shortName, + bool isDefault, + String? contract}); } /// @nodoc @@ -179,14 +192,18 @@ class _$ExolixNetworkImpl implements _ExolixNetwork { other is _$ExolixNetworkImpl && (identical(other.network, network) || other.network == network) && (identical(other.name, name) || other.name == name) && - (identical(other.shortName, shortName) || other.shortName == shortName) && - (identical(other.isDefault, isDefault) || other.isDefault == isDefault) && - (identical(other.contract, contract) || other.contract == contract)); + (identical(other.shortName, shortName) || + other.shortName == shortName) && + (identical(other.isDefault, isDefault) || + other.isDefault == isDefault) && + (identical(other.contract, contract) || + other.contract == contract)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, network, name, shortName, isDefault, contract); + int get hashCode => + Object.hash(runtimeType, network, name, shortName, isDefault, contract); /// Create a copy of ExolixNetwork /// with the given fields replaced by the non-null parameter values. @@ -212,7 +229,8 @@ abstract class _ExolixNetwork implements ExolixNetwork { required final bool isDefault, required final String? contract}) = _$ExolixNetworkImpl; - factory _ExolixNetwork.fromJson(Map json) = _$ExolixNetworkImpl.fromJson; + factory _ExolixNetwork.fromJson(Map json) = + _$ExolixNetworkImpl.fromJson; @override String get network; diff --git a/packages/ion_swap_client/lib/models/exolix_network.m.g.dart b/packages/ion_swap_client/lib/models/exolix_network.m.g.dart index 5b8419fcbc..841f885e1c 100644 --- a/packages/ion_swap_client/lib/models/exolix_network.m.g.dart +++ b/packages/ion_swap_client/lib/models/exolix_network.m.g.dart @@ -6,7 +6,8 @@ part of 'exolix_network.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ExolixNetworkImpl _$$ExolixNetworkImplFromJson(Map json) => _$ExolixNetworkImpl( +_$ExolixNetworkImpl _$$ExolixNetworkImplFromJson(Map json) => + _$ExolixNetworkImpl( network: json['network'] as String, name: json['name'] as String, shortName: json['shortName'] as String, @@ -14,7 +15,8 @@ _$ExolixNetworkImpl _$$ExolixNetworkImplFromJson(Map json) => _ contract: json['contract'] as String?, ); -Map _$$ExolixNetworkImplToJson(_$ExolixNetworkImpl instance) => { +Map _$$ExolixNetworkImplToJson(_$ExolixNetworkImpl instance) => + { 'network': instance.network, 'name': instance.name, 'shortName': instance.shortName, diff --git a/packages/ion_swap_client/lib/models/exolix_rate.m.freezed.dart b/packages/ion_swap_client/lib/models/exolix_rate.m.freezed.dart index 2207e1cef1..bf79ddbb52 100644 --- a/packages/ion_swap_client/lib/models/exolix_rate.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/exolix_rate.m.freezed.dart @@ -34,12 +34,14 @@ mixin _$ExolixRate { /// Create a copy of ExolixRate /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $ExolixRateCopyWith get copyWith => throw _privateConstructorUsedError; + $ExolixRateCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ExolixRateCopyWith<$Res> { - factory $ExolixRateCopyWith(ExolixRate value, $Res Function(ExolixRate) then) = + factory $ExolixRateCopyWith( + ExolixRate value, $Res Function(ExolixRate) then) = _$ExolixRateCopyWithImpl<$Res, ExolixRate>; @useResult $Res call( @@ -53,7 +55,8 @@ abstract class $ExolixRateCopyWith<$Res> { } /// @nodoc -class _$ExolixRateCopyWithImpl<$Res, $Val extends ExolixRate> implements $ExolixRateCopyWith<$Res> { +class _$ExolixRateCopyWithImpl<$Res, $Val extends ExolixRate> + implements $ExolixRateCopyWith<$Res> { _$ExolixRateCopyWithImpl(this._value, this._then); // ignore: unused_field @@ -108,8 +111,10 @@ class _$ExolixRateCopyWithImpl<$Res, $Val extends ExolixRate> implements $Exolix } /// @nodoc -abstract class _$$ExolixRateImplCopyWith<$Res> implements $ExolixRateCopyWith<$Res> { - factory _$$ExolixRateImplCopyWith(_$ExolixRateImpl value, $Res Function(_$ExolixRateImpl) then) = +abstract class _$$ExolixRateImplCopyWith<$Res> + implements $ExolixRateCopyWith<$Res> { + factory _$$ExolixRateImplCopyWith( + _$ExolixRateImpl value, $Res Function(_$ExolixRateImpl) then) = __$$ExolixRateImplCopyWithImpl<$Res>; @override @useResult @@ -124,9 +129,11 @@ abstract class _$$ExolixRateImplCopyWith<$Res> implements $ExolixRateCopyWith<$R } /// @nodoc -class __$$ExolixRateImplCopyWithImpl<$Res> extends _$ExolixRateCopyWithImpl<$Res, _$ExolixRateImpl> +class __$$ExolixRateImplCopyWithImpl<$Res> + extends _$ExolixRateCopyWithImpl<$Res, _$ExolixRateImpl> implements _$$ExolixRateImplCopyWith<$Res> { - __$$ExolixRateImplCopyWithImpl(_$ExolixRateImpl _value, $Res Function(_$ExolixRateImpl) _then) + __$$ExolixRateImplCopyWithImpl( + _$ExolixRateImpl _value, $Res Function(_$ExolixRateImpl) _then) : super(_value, _then); /// Create a copy of ExolixRate @@ -187,7 +194,8 @@ class _$ExolixRateImpl implements _ExolixRate { required this.withdrawMin, required this.maxAmount}); - factory _$ExolixRateImpl.fromJson(Map json) => _$$ExolixRateImplFromJson(json); + factory _$ExolixRateImpl.fromJson(Map json) => + _$$ExolixRateImplFromJson(json); @override final num fromAmount; @@ -214,19 +222,24 @@ class _$ExolixRateImpl implements _ExolixRate { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ExolixRateImpl && - (identical(other.fromAmount, fromAmount) || other.fromAmount == fromAmount) && - (identical(other.toAmount, toAmount) || other.toAmount == toAmount) && + (identical(other.fromAmount, fromAmount) || + other.fromAmount == fromAmount) && + (identical(other.toAmount, toAmount) || + other.toAmount == toAmount) && (identical(other.rate, rate) || other.rate == rate) && (identical(other.message, message) || other.message == message) && - (identical(other.minAmount, minAmount) || other.minAmount == minAmount) && - (identical(other.withdrawMin, withdrawMin) || other.withdrawMin == withdrawMin) && - (identical(other.maxAmount, maxAmount) || other.maxAmount == maxAmount)); + (identical(other.minAmount, minAmount) || + other.minAmount == minAmount) && + (identical(other.withdrawMin, withdrawMin) || + other.withdrawMin == withdrawMin) && + (identical(other.maxAmount, maxAmount) || + other.maxAmount == maxAmount)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, fromAmount, toAmount, rate, message, minAmount, withdrawMin, maxAmount); + int get hashCode => Object.hash(runtimeType, fromAmount, toAmount, rate, + message, minAmount, withdrawMin, maxAmount); /// Create a copy of ExolixRate /// with the given fields replaced by the non-null parameter values. @@ -254,7 +267,8 @@ abstract class _ExolixRate implements ExolixRate { required final num withdrawMin, required final num maxAmount}) = _$ExolixRateImpl; - factory _ExolixRate.fromJson(Map json) = _$ExolixRateImpl.fromJson; + factory _ExolixRate.fromJson(Map json) = + _$ExolixRateImpl.fromJson; @override num get fromAmount; @@ -275,5 +289,6 @@ abstract class _ExolixRate implements ExolixRate { /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$ExolixRateImplCopyWith<_$ExolixRateImpl> get copyWith => throw _privateConstructorUsedError; + _$$ExolixRateImplCopyWith<_$ExolixRateImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/ion_swap_client/lib/models/exolix_rate.m.g.dart b/packages/ion_swap_client/lib/models/exolix_rate.m.g.dart index 613bd9f59f..f2593bff75 100644 --- a/packages/ion_swap_client/lib/models/exolix_rate.m.g.dart +++ b/packages/ion_swap_client/lib/models/exolix_rate.m.g.dart @@ -6,7 +6,8 @@ part of 'exolix_rate.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ExolixRateImpl _$$ExolixRateImplFromJson(Map json) => _$ExolixRateImpl( +_$ExolixRateImpl _$$ExolixRateImplFromJson(Map json) => + _$ExolixRateImpl( fromAmount: json['fromAmount'] as num, toAmount: json['toAmount'] as num, rate: json['rate'] as num, @@ -16,7 +17,8 @@ _$ExolixRateImpl _$$ExolixRateImplFromJson(Map json) => _$Exoli maxAmount: json['maxAmount'] as num, ); -Map _$$ExolixRateImplToJson(_$ExolixRateImpl instance) => { +Map _$$ExolixRateImplToJson(_$ExolixRateImpl instance) => + { 'fromAmount': instance.fromAmount, 'toAmount': instance.toAmount, 'rate': instance.rate, diff --git a/packages/ion_swap_client/lib/models/exolix_transaction.m.freezed.dart b/packages/ion_swap_client/lib/models/exolix_transaction.m.freezed.dart index 3e1e96d0d6..812c2420f1 100644 --- a/packages/ion_swap_client/lib/models/exolix_transaction.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/exolix_transaction.m.freezed.dart @@ -31,7 +31,8 @@ mixin _$ExolixTransaction { /// Create a copy of ExolixTransaction /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $ExolixTransactionCopyWith get copyWith => throw _privateConstructorUsedError; + $ExolixTransactionCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc @@ -40,7 +41,8 @@ abstract class $ExolixTransactionCopyWith<$Res> { ExolixTransaction value, $Res Function(ExolixTransaction) then) = _$ExolixTransactionCopyWithImpl<$Res, ExolixTransaction>; @useResult - $Res call({String id, num amount, TransactionStatus status, String depositAddress}); + $Res call( + {String id, num amount, TransactionStatus status, String depositAddress}); } /// @nodoc @@ -85,21 +87,23 @@ class _$ExolixTransactionCopyWithImpl<$Res, $Val extends ExolixTransaction> } /// @nodoc -abstract class _$$ExolixTransactionImplCopyWith<$Res> implements $ExolixTransactionCopyWith<$Res> { - factory _$$ExolixTransactionImplCopyWith( - _$ExolixTransactionImpl value, $Res Function(_$ExolixTransactionImpl) then) = +abstract class _$$ExolixTransactionImplCopyWith<$Res> + implements $ExolixTransactionCopyWith<$Res> { + factory _$$ExolixTransactionImplCopyWith(_$ExolixTransactionImpl value, + $Res Function(_$ExolixTransactionImpl) then) = __$$ExolixTransactionImplCopyWithImpl<$Res>; @override @useResult - $Res call({String id, num amount, TransactionStatus status, String depositAddress}); + $Res call( + {String id, num amount, TransactionStatus status, String depositAddress}); } /// @nodoc class __$$ExolixTransactionImplCopyWithImpl<$Res> extends _$ExolixTransactionCopyWithImpl<$Res, _$ExolixTransactionImpl> implements _$$ExolixTransactionImplCopyWith<$Res> { - __$$ExolixTransactionImplCopyWithImpl( - _$ExolixTransactionImpl _value, $Res Function(_$ExolixTransactionImpl) _then) + __$$ExolixTransactionImplCopyWithImpl(_$ExolixTransactionImpl _value, + $Res Function(_$ExolixTransactionImpl) _then) : super(_value, _then); /// Create a copy of ExolixTransaction @@ -137,7 +141,10 @@ class __$$ExolixTransactionImplCopyWithImpl<$Res> @JsonSerializable() class _$ExolixTransactionImpl implements _ExolixTransaction { _$ExolixTransactionImpl( - {required this.id, required this.amount, required this.status, required this.depositAddress}); + {required this.id, + required this.amount, + required this.status, + required this.depositAddress}); factory _$ExolixTransactionImpl.fromJson(Map json) => _$$ExolixTransactionImplFromJson(json); @@ -170,7 +177,8 @@ class _$ExolixTransactionImpl implements _ExolixTransaction { @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, id, amount, status, depositAddress); + int get hashCode => + Object.hash(runtimeType, id, amount, status, depositAddress); /// Create a copy of ExolixTransaction /// with the given fields replaced by the non-null parameter values. @@ -178,7 +186,8 @@ class _$ExolixTransactionImpl implements _ExolixTransaction { @override @pragma('vm:prefer-inline') _$$ExolixTransactionImplCopyWith<_$ExolixTransactionImpl> get copyWith => - __$$ExolixTransactionImplCopyWithImpl<_$ExolixTransactionImpl>(this, _$identity); + __$$ExolixTransactionImplCopyWithImpl<_$ExolixTransactionImpl>( + this, _$identity); @override Map toJson() { @@ -195,7 +204,8 @@ abstract class _ExolixTransaction implements ExolixTransaction { required final TransactionStatus status, required final String depositAddress}) = _$ExolixTransactionImpl; - factory _ExolixTransaction.fromJson(Map json) = _$ExolixTransactionImpl.fromJson; + factory _ExolixTransaction.fromJson(Map json) = + _$ExolixTransactionImpl.fromJson; @override String get id; diff --git a/packages/ion_swap_client/lib/models/exolix_transaction.m.g.dart b/packages/ion_swap_client/lib/models/exolix_transaction.m.g.dart index 8114c42463..0c31d97291 100644 --- a/packages/ion_swap_client/lib/models/exolix_transaction.m.g.dart +++ b/packages/ion_swap_client/lib/models/exolix_transaction.m.g.dart @@ -6,7 +6,8 @@ part of 'exolix_transaction.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ExolixTransactionImpl _$$ExolixTransactionImplFromJson(Map json) => +_$ExolixTransactionImpl _$$ExolixTransactionImplFromJson( + Map json) => _$ExolixTransactionImpl( id: json['id'] as String, amount: json['amount'] as num, @@ -14,7 +15,8 @@ _$ExolixTransactionImpl _$$ExolixTransactionImplFromJson(Map js depositAddress: json['depositAddress'] as String, ); -Map _$$ExolixTransactionImplToJson(_$ExolixTransactionImpl instance) => +Map _$$ExolixTransactionImplToJson( + _$ExolixTransactionImpl instance) => { 'id': instance.id, 'amount': instance.amount, diff --git a/packages/ion_swap_client/lib/models/lets_exchange_coin.m.freezed.dart b/packages/ion_swap_client/lib/models/lets_exchange_coin.m.freezed.dart index 75c05ce9ce..4bb6d8f19b 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_coin.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_coin.m.freezed.dart @@ -32,12 +32,14 @@ mixin _$LetsExchangeCoin { /// Create a copy of LetsExchangeCoin /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $LetsExchangeCoinCopyWith get copyWith => throw _privateConstructorUsedError; + $LetsExchangeCoinCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $LetsExchangeCoinCopyWith<$Res> { - factory $LetsExchangeCoinCopyWith(LetsExchangeCoin value, $Res Function(LetsExchangeCoin) then) = + factory $LetsExchangeCoinCopyWith( + LetsExchangeCoin value, $Res Function(LetsExchangeCoin) then) = _$LetsExchangeCoinCopyWithImpl<$Res, LetsExchangeCoin>; @useResult $Res call( @@ -89,9 +91,10 @@ class _$LetsExchangeCoinCopyWithImpl<$Res, $Val extends LetsExchangeCoin> } /// @nodoc -abstract class _$$LetsExchangeCoinImplCopyWith<$Res> implements $LetsExchangeCoinCopyWith<$Res> { - factory _$$LetsExchangeCoinImplCopyWith( - _$LetsExchangeCoinImpl value, $Res Function(_$LetsExchangeCoinImpl) then) = +abstract class _$$LetsExchangeCoinImplCopyWith<$Res> + implements $LetsExchangeCoinCopyWith<$Res> { + factory _$$LetsExchangeCoinImplCopyWith(_$LetsExchangeCoinImpl value, + $Res Function(_$LetsExchangeCoinImpl) then) = __$$LetsExchangeCoinImplCopyWithImpl<$Res>; @override @useResult @@ -106,8 +109,8 @@ abstract class _$$LetsExchangeCoinImplCopyWith<$Res> implements $LetsExchangeCoi class __$$LetsExchangeCoinImplCopyWithImpl<$Res> extends _$LetsExchangeCoinCopyWithImpl<$Res, _$LetsExchangeCoinImpl> implements _$$LetsExchangeCoinImplCopyWith<$Res> { - __$$LetsExchangeCoinImplCopyWithImpl( - _$LetsExchangeCoinImpl _value, $Res Function(_$LetsExchangeCoinImpl) _then) + __$$LetsExchangeCoinImplCopyWithImpl(_$LetsExchangeCoinImpl _value, + $Res Function(_$LetsExchangeCoinImpl) _then) : super(_value, _then); /// Create a copy of LetsExchangeCoin @@ -181,14 +184,15 @@ class _$LetsExchangeCoinImpl implements _LetsExchangeCoin { other is _$LetsExchangeCoinImpl && (identical(other.code, code) || other.code == code) && (identical(other.name, name) || other.name == name) && - (identical(other.isActive, isActive) || other.isActive == isActive) && + (identical(other.isActive, isActive) || + other.isActive == isActive) && const DeepCollectionEquality().equals(other._networks, _networks)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, code, name, isActive, const DeepCollectionEquality().hash(_networks)); + int get hashCode => Object.hash(runtimeType, code, name, isActive, + const DeepCollectionEquality().hash(_networks)); /// Create a copy of LetsExchangeCoin /// with the given fields replaced by the non-null parameter values. @@ -196,7 +200,8 @@ class _$LetsExchangeCoinImpl implements _LetsExchangeCoin { @override @pragma('vm:prefer-inline') _$$LetsExchangeCoinImplCopyWith<_$LetsExchangeCoinImpl> get copyWith => - __$$LetsExchangeCoinImplCopyWithImpl<_$LetsExchangeCoinImpl>(this, _$identity); + __$$LetsExchangeCoinImplCopyWithImpl<_$LetsExchangeCoinImpl>( + this, _$identity); @override Map toJson() { @@ -208,12 +213,14 @@ class _$LetsExchangeCoinImpl implements _LetsExchangeCoin { abstract class _LetsExchangeCoin implements LetsExchangeCoin { factory _LetsExchangeCoin( - {required final String code, - required final String name, - @JsonKey(name: 'is_active') required final int isActive, - required final List networks}) = _$LetsExchangeCoinImpl; - - factory _LetsExchangeCoin.fromJson(Map json) = _$LetsExchangeCoinImpl.fromJson; + {required final String code, + required final String name, + @JsonKey(name: 'is_active') required final int isActive, + required final List networks}) = + _$LetsExchangeCoinImpl; + + factory _LetsExchangeCoin.fromJson(Map json) = + _$LetsExchangeCoinImpl.fromJson; @override String get code; diff --git a/packages/ion_swap_client/lib/models/lets_exchange_coin.m.g.dart b/packages/ion_swap_client/lib/models/lets_exchange_coin.m.g.dart index 6f584da311..0138c0981d 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_coin.m.g.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_coin.m.g.dart @@ -6,7 +6,8 @@ part of 'lets_exchange_coin.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$LetsExchangeCoinImpl _$$LetsExchangeCoinImplFromJson(Map json) => +_$LetsExchangeCoinImpl _$$LetsExchangeCoinImplFromJson( + Map json) => _$LetsExchangeCoinImpl( code: json['code'] as String, name: json['name'] as String, @@ -16,7 +17,8 @@ _$LetsExchangeCoinImpl _$$LetsExchangeCoinImplFromJson(Map json .toList(), ); -Map _$$LetsExchangeCoinImplToJson(_$LetsExchangeCoinImpl instance) => +Map _$$LetsExchangeCoinImplToJson( + _$LetsExchangeCoinImpl instance) => { 'code': instance.code, 'name': instance.name, diff --git a/packages/ion_swap_client/lib/models/lets_exchange_info.m.dart b/packages/ion_swap_client/lib/models/lets_exchange_info.m.dart index a1d81bebc0..709e1adaa7 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_info.m.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_info.m.dart @@ -9,7 +9,14 @@ part 'lets_exchange_info.m.g.dart'; class LetsExchangeInfo with _$LetsExchangeInfo { factory LetsExchangeInfo({ @JsonKey(name: 'rate_id') required String rateId, + @JsonKey(name: 'min_amount') required String minAmount, + @JsonKey(name: 'max_amount') required String maxAmount, + required String amount, + required String fee, required String rate, + required String profit, + @JsonKey(name: 'withdrawal_fee') required String withdrawalFee, + @JsonKey(name: 'extra_fee_amount') required String extraFeeAmount, }) = _LetsExchangeInfo; factory LetsExchangeInfo.fromJson(Map json) => _$LetsExchangeInfoFromJson(json); diff --git a/packages/ion_swap_client/lib/models/lets_exchange_info.m.freezed.dart b/packages/ion_swap_client/lib/models/lets_exchange_info.m.freezed.dart index 203bd5d912..998f55a80a 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_info.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_info.m.freezed.dart @@ -22,7 +22,18 @@ LetsExchangeInfo _$LetsExchangeInfoFromJson(Map json) { mixin _$LetsExchangeInfo { @JsonKey(name: 'rate_id') String get rateId => throw _privateConstructorUsedError; + @JsonKey(name: 'min_amount') + String get minAmount => throw _privateConstructorUsedError; + @JsonKey(name: 'max_amount') + String get maxAmount => throw _privateConstructorUsedError; + String get amount => throw _privateConstructorUsedError; + String get fee => throw _privateConstructorUsedError; String get rate => throw _privateConstructorUsedError; + String get profit => throw _privateConstructorUsedError; + @JsonKey(name: 'withdrawal_fee') + String get withdrawalFee => throw _privateConstructorUsedError; + @JsonKey(name: 'extra_fee_amount') + String get extraFeeAmount => throw _privateConstructorUsedError; /// Serializes this LetsExchangeInfo to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -40,7 +51,16 @@ abstract class $LetsExchangeInfoCopyWith<$Res> { LetsExchangeInfo value, $Res Function(LetsExchangeInfo) then) = _$LetsExchangeInfoCopyWithImpl<$Res, LetsExchangeInfo>; @useResult - $Res call({@JsonKey(name: 'rate_id') String rateId, String rate}); + $Res call( + {@JsonKey(name: 'rate_id') String rateId, + @JsonKey(name: 'min_amount') String minAmount, + @JsonKey(name: 'max_amount') String maxAmount, + String amount, + String fee, + String rate, + String profit, + @JsonKey(name: 'withdrawal_fee') String withdrawalFee, + @JsonKey(name: 'extra_fee_amount') String extraFeeAmount}); } /// @nodoc @@ -59,17 +79,52 @@ class _$LetsExchangeInfoCopyWithImpl<$Res, $Val extends LetsExchangeInfo> @override $Res call({ Object? rateId = null, + Object? minAmount = null, + Object? maxAmount = null, + Object? amount = null, + Object? fee = null, Object? rate = null, + Object? profit = null, + Object? withdrawalFee = null, + Object? extraFeeAmount = null, }) { return _then(_value.copyWith( rateId: null == rateId ? _value.rateId : rateId // ignore: cast_nullable_to_non_nullable as String, + minAmount: null == minAmount + ? _value.minAmount + : minAmount // ignore: cast_nullable_to_non_nullable + as String, + maxAmount: null == maxAmount + ? _value.maxAmount + : maxAmount // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as String, + fee: null == fee + ? _value.fee + : fee // ignore: cast_nullable_to_non_nullable + as String, rate: null == rate ? _value.rate : rate // ignore: cast_nullable_to_non_nullable as String, + profit: null == profit + ? _value.profit + : profit // ignore: cast_nullable_to_non_nullable + as String, + withdrawalFee: null == withdrawalFee + ? _value.withdrawalFee + : withdrawalFee // ignore: cast_nullable_to_non_nullable + as String, + extraFeeAmount: null == extraFeeAmount + ? _value.extraFeeAmount + : extraFeeAmount // ignore: cast_nullable_to_non_nullable + as String, ) as $Val); } } @@ -82,7 +137,16 @@ abstract class _$$LetsExchangeInfoImplCopyWith<$Res> __$$LetsExchangeInfoImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: 'rate_id') String rateId, String rate}); + $Res call( + {@JsonKey(name: 'rate_id') String rateId, + @JsonKey(name: 'min_amount') String minAmount, + @JsonKey(name: 'max_amount') String maxAmount, + String amount, + String fee, + String rate, + String profit, + @JsonKey(name: 'withdrawal_fee') String withdrawalFee, + @JsonKey(name: 'extra_fee_amount') String extraFeeAmount}); } /// @nodoc @@ -99,17 +163,52 @@ class __$$LetsExchangeInfoImplCopyWithImpl<$Res> @override $Res call({ Object? rateId = null, + Object? minAmount = null, + Object? maxAmount = null, + Object? amount = null, + Object? fee = null, Object? rate = null, + Object? profit = null, + Object? withdrawalFee = null, + Object? extraFeeAmount = null, }) { return _then(_$LetsExchangeInfoImpl( rateId: null == rateId ? _value.rateId : rateId // ignore: cast_nullable_to_non_nullable as String, + minAmount: null == minAmount + ? _value.minAmount + : minAmount // ignore: cast_nullable_to_non_nullable + as String, + maxAmount: null == maxAmount + ? _value.maxAmount + : maxAmount // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as String, + fee: null == fee + ? _value.fee + : fee // ignore: cast_nullable_to_non_nullable + as String, rate: null == rate ? _value.rate : rate // ignore: cast_nullable_to_non_nullable as String, + profit: null == profit + ? _value.profit + : profit // ignore: cast_nullable_to_non_nullable + as String, + withdrawalFee: null == withdrawalFee + ? _value.withdrawalFee + : withdrawalFee // ignore: cast_nullable_to_non_nullable + as String, + extraFeeAmount: null == extraFeeAmount + ? _value.extraFeeAmount + : extraFeeAmount // ignore: cast_nullable_to_non_nullable + as String, )); } } @@ -118,7 +217,15 @@ class __$$LetsExchangeInfoImplCopyWithImpl<$Res> @JsonSerializable() class _$LetsExchangeInfoImpl implements _LetsExchangeInfo { _$LetsExchangeInfoImpl( - {@JsonKey(name: 'rate_id') required this.rateId, required this.rate}); + {@JsonKey(name: 'rate_id') required this.rateId, + @JsonKey(name: 'min_amount') required this.minAmount, + @JsonKey(name: 'max_amount') required this.maxAmount, + required this.amount, + required this.fee, + required this.rate, + required this.profit, + @JsonKey(name: 'withdrawal_fee') required this.withdrawalFee, + @JsonKey(name: 'extra_fee_amount') required this.extraFeeAmount}); factory _$LetsExchangeInfoImpl.fromJson(Map json) => _$$LetsExchangeInfoImplFromJson(json); @@ -127,11 +234,29 @@ class _$LetsExchangeInfoImpl implements _LetsExchangeInfo { @JsonKey(name: 'rate_id') final String rateId; @override + @JsonKey(name: 'min_amount') + final String minAmount; + @override + @JsonKey(name: 'max_amount') + final String maxAmount; + @override + final String amount; + @override + final String fee; + @override final String rate; + @override + final String profit; + @override + @JsonKey(name: 'withdrawal_fee') + final String withdrawalFee; + @override + @JsonKey(name: 'extra_fee_amount') + final String extraFeeAmount; @override String toString() { - return 'LetsExchangeInfo(rateId: $rateId, rate: $rate)'; + return 'LetsExchangeInfo(rateId: $rateId, minAmount: $minAmount, maxAmount: $maxAmount, amount: $amount, fee: $fee, rate: $rate, profit: $profit, withdrawalFee: $withdrawalFee, extraFeeAmount: $extraFeeAmount)'; } @override @@ -140,12 +265,24 @@ class _$LetsExchangeInfoImpl implements _LetsExchangeInfo { (other.runtimeType == runtimeType && other is _$LetsExchangeInfoImpl && (identical(other.rateId, rateId) || other.rateId == rateId) && - (identical(other.rate, rate) || other.rate == rate)); + (identical(other.minAmount, minAmount) || + other.minAmount == minAmount) && + (identical(other.maxAmount, maxAmount) || + other.maxAmount == maxAmount) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.fee, fee) || other.fee == fee) && + (identical(other.rate, rate) || other.rate == rate) && + (identical(other.profit, profit) || other.profit == profit) && + (identical(other.withdrawalFee, withdrawalFee) || + other.withdrawalFee == withdrawalFee) && + (identical(other.extraFeeAmount, extraFeeAmount) || + other.extraFeeAmount == extraFeeAmount)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, rateId, rate); + int get hashCode => Object.hash(runtimeType, rateId, minAmount, maxAmount, + amount, fee, rate, profit, withdrawalFee, extraFeeAmount); /// Create a copy of LetsExchangeInfo /// with the given fields replaced by the non-null parameter values. @@ -167,7 +304,15 @@ class _$LetsExchangeInfoImpl implements _LetsExchangeInfo { abstract class _LetsExchangeInfo implements LetsExchangeInfo { factory _LetsExchangeInfo( {@JsonKey(name: 'rate_id') required final String rateId, - required final String rate}) = _$LetsExchangeInfoImpl; + @JsonKey(name: 'min_amount') required final String minAmount, + @JsonKey(name: 'max_amount') required final String maxAmount, + required final String amount, + required final String fee, + required final String rate, + required final String profit, + @JsonKey(name: 'withdrawal_fee') required final String withdrawalFee, + @JsonKey(name: 'extra_fee_amount') + required final String extraFeeAmount}) = _$LetsExchangeInfoImpl; factory _LetsExchangeInfo.fromJson(Map json) = _$LetsExchangeInfoImpl.fromJson; @@ -176,7 +321,25 @@ abstract class _LetsExchangeInfo implements LetsExchangeInfo { @JsonKey(name: 'rate_id') String get rateId; @override + @JsonKey(name: 'min_amount') + String get minAmount; + @override + @JsonKey(name: 'max_amount') + String get maxAmount; + @override + String get amount; + @override + String get fee; + @override String get rate; + @override + String get profit; + @override + @JsonKey(name: 'withdrawal_fee') + String get withdrawalFee; + @override + @JsonKey(name: 'extra_fee_amount') + String get extraFeeAmount; /// Create a copy of LetsExchangeInfo /// with the given fields replaced by the non-null parameter values. diff --git a/packages/ion_swap_client/lib/models/lets_exchange_info.m.g.dart b/packages/ion_swap_client/lib/models/lets_exchange_info.m.g.dart index eab5b393d2..849a0e503e 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_info.m.g.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_info.m.g.dart @@ -10,12 +10,26 @@ _$LetsExchangeInfoImpl _$$LetsExchangeInfoImplFromJson( Map json) => _$LetsExchangeInfoImpl( rateId: json['rate_id'] as String, + minAmount: json['min_amount'] as String, + maxAmount: json['max_amount'] as String, + amount: json['amount'] as String, + fee: json['fee'] as String, rate: json['rate'] as String, + profit: json['profit'] as String, + withdrawalFee: json['withdrawal_fee'] as String, + extraFeeAmount: json['extra_fee_amount'] as String, ); Map _$$LetsExchangeInfoImplToJson( _$LetsExchangeInfoImpl instance) => { 'rate_id': instance.rateId, + 'min_amount': instance.minAmount, + 'max_amount': instance.maxAmount, + 'amount': instance.amount, + 'fee': instance.fee, 'rate': instance.rate, + 'profit': instance.profit, + 'withdrawal_fee': instance.withdrawalFee, + 'extra_fee_amount': instance.extraFeeAmount, }; diff --git a/packages/ion_swap_client/lib/models/lets_exchange_network.m.freezed.dart b/packages/ion_swap_client/lib/models/lets_exchange_network.m.freezed.dart index d755ae15dd..812a1b35cb 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_network.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_network.m.freezed.dart @@ -94,8 +94,8 @@ class _$LetsExchangeNetworkCopyWithImpl<$Res, $Val extends LetsExchangeNetwork> /// @nodoc abstract class _$$LetsExchangeNetworkImplCopyWith<$Res> implements $LetsExchangeNetworkCopyWith<$Res> { - factory _$$LetsExchangeNetworkImplCopyWith( - _$LetsExchangeNetworkImpl value, $Res Function(_$LetsExchangeNetworkImpl) then) = + factory _$$LetsExchangeNetworkImplCopyWith(_$LetsExchangeNetworkImpl value, + $Res Function(_$LetsExchangeNetworkImpl) then) = __$$LetsExchangeNetworkImplCopyWithImpl<$Res>; @override @useResult @@ -110,8 +110,8 @@ abstract class _$$LetsExchangeNetworkImplCopyWith<$Res> class __$$LetsExchangeNetworkImplCopyWithImpl<$Res> extends _$LetsExchangeNetworkCopyWithImpl<$Res, _$LetsExchangeNetworkImpl> implements _$$LetsExchangeNetworkImplCopyWith<$Res> { - __$$LetsExchangeNetworkImplCopyWithImpl( - _$LetsExchangeNetworkImpl _value, $Res Function(_$LetsExchangeNetworkImpl) _then) + __$$LetsExchangeNetworkImplCopyWithImpl(_$LetsExchangeNetworkImpl _value, + $Res Function(_$LetsExchangeNetworkImpl) _then) : super(_value, _then); /// Create a copy of LetsExchangeNetwork @@ -180,14 +180,16 @@ class _$LetsExchangeNetworkImpl implements _LetsExchangeNetwork { other is _$LetsExchangeNetworkImpl && (identical(other.code, code) || other.code == code) && (identical(other.name, name) || other.name == name) && - (identical(other.isActive, isActive) || other.isActive == isActive) && + (identical(other.isActive, isActive) || + other.isActive == isActive) && (identical(other.contractAddress, contractAddress) || other.contractAddress == contractAddress)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, code, name, isActive, contractAddress); + int get hashCode => + Object.hash(runtimeType, code, name, isActive, contractAddress); /// Create a copy of LetsExchangeNetwork /// with the given fields replaced by the non-null parameter values. @@ -195,7 +197,8 @@ class _$LetsExchangeNetworkImpl implements _LetsExchangeNetwork { @override @pragma('vm:prefer-inline') _$$LetsExchangeNetworkImplCopyWith<_$LetsExchangeNetworkImpl> get copyWith => - __$$LetsExchangeNetworkImplCopyWithImpl<_$LetsExchangeNetworkImpl>(this, _$identity); + __$$LetsExchangeNetworkImplCopyWithImpl<_$LetsExchangeNetworkImpl>( + this, _$identity); @override Map toJson() { @@ -207,11 +210,11 @@ class _$LetsExchangeNetworkImpl implements _LetsExchangeNetwork { abstract class _LetsExchangeNetwork implements LetsExchangeNetwork { factory _LetsExchangeNetwork( - {required final String code, - required final String name, - @JsonKey(name: 'is_active') required final int isActive, - @JsonKey(name: 'contract_address') required final String? contractAddress}) = - _$LetsExchangeNetworkImpl; + {required final String code, + required final String name, + @JsonKey(name: 'is_active') required final int isActive, + @JsonKey(name: 'contract_address') + required final String? contractAddress}) = _$LetsExchangeNetworkImpl; factory _LetsExchangeNetwork.fromJson(Map json) = _$LetsExchangeNetworkImpl.fromJson; diff --git a/packages/ion_swap_client/lib/models/lets_exchange_network.m.g.dart b/packages/ion_swap_client/lib/models/lets_exchange_network.m.g.dart index cc1b3c5e5b..583e9adea4 100644 --- a/packages/ion_swap_client/lib/models/lets_exchange_network.m.g.dart +++ b/packages/ion_swap_client/lib/models/lets_exchange_network.m.g.dart @@ -6,7 +6,8 @@ part of 'lets_exchange_network.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$LetsExchangeNetworkImpl _$$LetsExchangeNetworkImplFromJson(Map json) => +_$LetsExchangeNetworkImpl _$$LetsExchangeNetworkImplFromJson( + Map json) => _$LetsExchangeNetworkImpl( code: json['code'] as String, name: json['name'] as String, @@ -14,7 +15,8 @@ _$LetsExchangeNetworkImpl _$$LetsExchangeNetworkImplFromJson(Map _$$LetsExchangeNetworkImplToJson(_$LetsExchangeNetworkImpl instance) => +Map _$$LetsExchangeNetworkImplToJson( + _$LetsExchangeNetworkImpl instance) => { 'code': instance.code, 'name': instance.name, diff --git a/packages/ion_swap_client/lib/models/okx_api_response.m.freezed.dart b/packages/ion_swap_client/lib/models/okx_api_response.m.freezed.dart index 95b6af3151..f9aa8ecbd0 100644 --- a/packages/ion_swap_client/lib/models/okx_api_response.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/okx_api_response.m.freezed.dart @@ -26,17 +26,20 @@ mixin _$OkxApiResponse { T get data => throw _privateConstructorUsedError; /// Serializes this OkxApiResponse to a JSON map. - Map toJson(Object? Function(T) toJsonT) => throw _privateConstructorUsedError; + Map toJson(Object? Function(T) toJsonT) => + throw _privateConstructorUsedError; /// Create a copy of OkxApiResponse /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $OkxApiResponseCopyWith> get copyWith => throw _privateConstructorUsedError; + $OkxApiResponseCopyWith> get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $OkxApiResponseCopyWith { - factory $OkxApiResponseCopyWith(OkxApiResponse value, $Res Function(OkxApiResponse) then) = + factory $OkxApiResponseCopyWith( + OkxApiResponse value, $Res Function(OkxApiResponse) then) = _$OkxApiResponseCopyWithImpl>; @useResult $Res call({String code, @JsonKey(name: 'data') T data}); @@ -74,9 +77,10 @@ class _$OkxApiResponseCopyWithImpl> } /// @nodoc -abstract class _$$OkxApiResponseImplCopyWith implements $OkxApiResponseCopyWith { - factory _$$OkxApiResponseImplCopyWith( - _$OkxApiResponseImpl value, $Res Function(_$OkxApiResponseImpl) then) = +abstract class _$$OkxApiResponseImplCopyWith + implements $OkxApiResponseCopyWith { + factory _$$OkxApiResponseImplCopyWith(_$OkxApiResponseImpl value, + $Res Function(_$OkxApiResponseImpl) then) = __$$OkxApiResponseImplCopyWithImpl; @override @useResult @@ -87,8 +91,8 @@ abstract class _$$OkxApiResponseImplCopyWith implements $OkxApiResponse class __$$OkxApiResponseImplCopyWithImpl extends _$OkxApiResponseCopyWithImpl> implements _$$OkxApiResponseImplCopyWith { - __$$OkxApiResponseImplCopyWithImpl( - _$OkxApiResponseImpl _value, $Res Function(_$OkxApiResponseImpl) _then) + __$$OkxApiResponseImplCopyWithImpl(_$OkxApiResponseImpl _value, + $Res Function(_$OkxApiResponseImpl) _then) : super(_value, _then); /// Create a copy of OkxApiResponse @@ -115,9 +119,11 @@ class __$$OkxApiResponseImplCopyWithImpl /// @nodoc @JsonSerializable(genericArgumentFactories: true) class _$OkxApiResponseImpl implements _OkxApiResponse { - _$OkxApiResponseImpl({required this.code, @JsonKey(name: 'data') required this.data}); + _$OkxApiResponseImpl( + {required this.code, @JsonKey(name: 'data') required this.data}); - factory _$OkxApiResponseImpl.fromJson(Map json, T Function(Object?) fromJsonT) => + factory _$OkxApiResponseImpl.fromJson( + Map json, T Function(Object?) fromJsonT) => _$$OkxApiResponseImplFromJson(json, fromJsonT); @override @@ -142,7 +148,8 @@ class _$OkxApiResponseImpl implements _OkxApiResponse { @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, code, const DeepCollectionEquality().hash(data)); + int get hashCode => + Object.hash(runtimeType, code, const DeepCollectionEquality().hash(data)); /// Create a copy of OkxApiResponse /// with the given fields replaced by the non-null parameter values. @@ -150,7 +157,8 @@ class _$OkxApiResponseImpl implements _OkxApiResponse { @override @pragma('vm:prefer-inline') _$$OkxApiResponseImplCopyWith> get copyWith => - __$$OkxApiResponseImplCopyWithImpl>(this, _$identity); + __$$OkxApiResponseImplCopyWithImpl>( + this, _$identity); @override Map toJson(Object? Function(T) toJsonT) { @@ -163,7 +171,8 @@ abstract class _OkxApiResponse implements OkxApiResponse { {required final String code, @JsonKey(name: 'data') required final T data}) = _$OkxApiResponseImpl; - factory _OkxApiResponse.fromJson(Map json, T Function(Object?) fromJsonT) = + factory _OkxApiResponse.fromJson( + Map json, T Function(Object?) fromJsonT) = _$OkxApiResponseImpl.fromJson; @override diff --git a/packages/ion_swap_client/lib/models/okx_swap_response.m.dart b/packages/ion_swap_client/lib/models/okx_swap_response.m.dart new file mode 100644 index 0000000000..76dceed275 --- /dev/null +++ b/packages/ion_swap_client/lib/models/okx_swap_response.m.dart @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: ice License 1.0 + +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ion_swap_client/models/okx_swap_transaction.m.dart'; + +part 'okx_swap_response.m.freezed.dart'; +part 'okx_swap_response.m.g.dart'; + +@freezed +class OkxSwapResponse with _$OkxSwapResponse { + factory OkxSwapResponse({ + required OkxSwapTransaction tx, + }) = _OkxSwapResponse; + + factory OkxSwapResponse.fromJson(Map json) => _$OkxSwapResponseFromJson(json); +} diff --git a/packages/ion_swap_client/lib/models/okx_swap_response.m.freezed.dart b/packages/ion_swap_client/lib/models/okx_swap_response.m.freezed.dart new file mode 100644 index 0000000000..ec30ceaf88 --- /dev/null +++ b/packages/ion_swap_client/lib/models/okx_swap_response.m.freezed.dart @@ -0,0 +1,181 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'okx_swap_response.m.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +OkxSwapResponse _$OkxSwapResponseFromJson(Map json) { + return _OkxSwapResponse.fromJson(json); +} + +/// @nodoc +mixin _$OkxSwapResponse { + OkxSwapTransaction get tx => throw _privateConstructorUsedError; + + /// Serializes this OkxSwapResponse to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OkxSwapResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OkxSwapResponseCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OkxSwapResponseCopyWith<$Res> { + factory $OkxSwapResponseCopyWith( + OkxSwapResponse value, $Res Function(OkxSwapResponse) then) = + _$OkxSwapResponseCopyWithImpl<$Res, OkxSwapResponse>; + @useResult + $Res call({OkxSwapTransaction tx}); + + $OkxSwapTransactionCopyWith<$Res> get tx; +} + +/// @nodoc +class _$OkxSwapResponseCopyWithImpl<$Res, $Val extends OkxSwapResponse> + implements $OkxSwapResponseCopyWith<$Res> { + _$OkxSwapResponseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OkxSwapResponse + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? tx = null, + }) { + return _then(_value.copyWith( + tx: null == tx + ? _value.tx + : tx // ignore: cast_nullable_to_non_nullable + as OkxSwapTransaction, + ) as $Val); + } + + /// Create a copy of OkxSwapResponse + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $OkxSwapTransactionCopyWith<$Res> get tx { + return $OkxSwapTransactionCopyWith<$Res>(_value.tx, (value) { + return _then(_value.copyWith(tx: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$OkxSwapResponseImplCopyWith<$Res> + implements $OkxSwapResponseCopyWith<$Res> { + factory _$$OkxSwapResponseImplCopyWith(_$OkxSwapResponseImpl value, + $Res Function(_$OkxSwapResponseImpl) then) = + __$$OkxSwapResponseImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({OkxSwapTransaction tx}); + + @override + $OkxSwapTransactionCopyWith<$Res> get tx; +} + +/// @nodoc +class __$$OkxSwapResponseImplCopyWithImpl<$Res> + extends _$OkxSwapResponseCopyWithImpl<$Res, _$OkxSwapResponseImpl> + implements _$$OkxSwapResponseImplCopyWith<$Res> { + __$$OkxSwapResponseImplCopyWithImpl( + _$OkxSwapResponseImpl _value, $Res Function(_$OkxSwapResponseImpl) _then) + : super(_value, _then); + + /// Create a copy of OkxSwapResponse + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? tx = null, + }) { + return _then(_$OkxSwapResponseImpl( + tx: null == tx + ? _value.tx + : tx // ignore: cast_nullable_to_non_nullable + as OkxSwapTransaction, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$OkxSwapResponseImpl implements _OkxSwapResponse { + _$OkxSwapResponseImpl({required this.tx}); + + factory _$OkxSwapResponseImpl.fromJson(Map json) => + _$$OkxSwapResponseImplFromJson(json); + + @override + final OkxSwapTransaction tx; + + @override + String toString() { + return 'OkxSwapResponse(tx: $tx)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OkxSwapResponseImpl && + (identical(other.tx, tx) || other.tx == tx)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, tx); + + /// Create a copy of OkxSwapResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OkxSwapResponseImplCopyWith<_$OkxSwapResponseImpl> get copyWith => + __$$OkxSwapResponseImplCopyWithImpl<_$OkxSwapResponseImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$OkxSwapResponseImplToJson( + this, + ); + } +} + +abstract class _OkxSwapResponse implements OkxSwapResponse { + factory _OkxSwapResponse({required final OkxSwapTransaction tx}) = + _$OkxSwapResponseImpl; + + factory _OkxSwapResponse.fromJson(Map json) = + _$OkxSwapResponseImpl.fromJson; + + @override + OkxSwapTransaction get tx; + + /// Create a copy of OkxSwapResponse + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OkxSwapResponseImplCopyWith<_$OkxSwapResponseImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/ion_swap_client/lib/models/okx_swap_response.m.g.dart b/packages/ion_swap_client/lib/models/okx_swap_response.m.g.dart new file mode 100644 index 0000000000..bbae1a6a8a --- /dev/null +++ b/packages/ion_swap_client/lib/models/okx_swap_response.m.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'okx_swap_response.m.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$OkxSwapResponseImpl _$$OkxSwapResponseImplFromJson( + Map json) => + _$OkxSwapResponseImpl( + tx: OkxSwapTransaction.fromJson(json['tx'] as Map), + ); + +Map _$$OkxSwapResponseImplToJson( + _$OkxSwapResponseImpl instance) => + { + 'tx': instance.tx, + }; diff --git a/packages/ion_swap_client/lib/models/okx_swap_transaction.m.dart b/packages/ion_swap_client/lib/models/okx_swap_transaction.m.dart new file mode 100644 index 0000000000..8f1809b25e --- /dev/null +++ b/packages/ion_swap_client/lib/models/okx_swap_transaction.m.dart @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: ice License 1.0 + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'okx_swap_transaction.m.freezed.dart'; +part 'okx_swap_transaction.m.g.dart'; + +@freezed +class OkxSwapTransaction with _$OkxSwapTransaction { + factory OkxSwapTransaction({ + required String data, + required String from, + required String to, + required String gas, + required String gasPrice, + required String value, + String? maxPriorityFeePerGas, + String? minReceiveAmount, + }) = _OkxSwapTransaction; + + factory OkxSwapTransaction.fromJson(Map json) => + _$OkxSwapTransactionFromJson(json); +} diff --git a/packages/ion_swap_client/lib/models/okx_swap_transaction.m.freezed.dart b/packages/ion_swap_client/lib/models/okx_swap_transaction.m.freezed.dart new file mode 100644 index 0000000000..9ad234a12f --- /dev/null +++ b/packages/ion_swap_client/lib/models/okx_swap_transaction.m.freezed.dart @@ -0,0 +1,313 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'okx_swap_transaction.m.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +OkxSwapTransaction _$OkxSwapTransactionFromJson(Map json) { + return _OkxSwapTransaction.fromJson(json); +} + +/// @nodoc +mixin _$OkxSwapTransaction { + String get data => throw _privateConstructorUsedError; + String get from => throw _privateConstructorUsedError; + String get to => throw _privateConstructorUsedError; + String get gas => throw _privateConstructorUsedError; + String get gasPrice => throw _privateConstructorUsedError; + String get value => throw _privateConstructorUsedError; + String? get maxPriorityFeePerGas => throw _privateConstructorUsedError; + String? get minReceiveAmount => throw _privateConstructorUsedError; + + /// Serializes this OkxSwapTransaction to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OkxSwapTransaction + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OkxSwapTransactionCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OkxSwapTransactionCopyWith<$Res> { + factory $OkxSwapTransactionCopyWith( + OkxSwapTransaction value, $Res Function(OkxSwapTransaction) then) = + _$OkxSwapTransactionCopyWithImpl<$Res, OkxSwapTransaction>; + @useResult + $Res call( + {String data, + String from, + String to, + String gas, + String gasPrice, + String value, + String? maxPriorityFeePerGas, + String? minReceiveAmount}); +} + +/// @nodoc +class _$OkxSwapTransactionCopyWithImpl<$Res, $Val extends OkxSwapTransaction> + implements $OkxSwapTransactionCopyWith<$Res> { + _$OkxSwapTransactionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OkxSwapTransaction + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? from = null, + Object? to = null, + Object? gas = null, + Object? gasPrice = null, + Object? value = null, + Object? maxPriorityFeePerGas = freezed, + Object? minReceiveAmount = freezed, + }) { + return _then(_value.copyWith( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as String, + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + to: null == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as String, + gas: null == gas + ? _value.gas + : gas // ignore: cast_nullable_to_non_nullable + as String, + gasPrice: null == gasPrice + ? _value.gasPrice + : gasPrice // ignore: cast_nullable_to_non_nullable + as String, + value: null == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String, + maxPriorityFeePerGas: freezed == maxPriorityFeePerGas + ? _value.maxPriorityFeePerGas + : maxPriorityFeePerGas // ignore: cast_nullable_to_non_nullable + as String?, + minReceiveAmount: freezed == minReceiveAmount + ? _value.minReceiveAmount + : minReceiveAmount // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$OkxSwapTransactionImplCopyWith<$Res> + implements $OkxSwapTransactionCopyWith<$Res> { + factory _$$OkxSwapTransactionImplCopyWith(_$OkxSwapTransactionImpl value, + $Res Function(_$OkxSwapTransactionImpl) then) = + __$$OkxSwapTransactionImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String data, + String from, + String to, + String gas, + String gasPrice, + String value, + String? maxPriorityFeePerGas, + String? minReceiveAmount}); +} + +/// @nodoc +class __$$OkxSwapTransactionImplCopyWithImpl<$Res> + extends _$OkxSwapTransactionCopyWithImpl<$Res, _$OkxSwapTransactionImpl> + implements _$$OkxSwapTransactionImplCopyWith<$Res> { + __$$OkxSwapTransactionImplCopyWithImpl(_$OkxSwapTransactionImpl _value, + $Res Function(_$OkxSwapTransactionImpl) _then) + : super(_value, _then); + + /// Create a copy of OkxSwapTransaction + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? from = null, + Object? to = null, + Object? gas = null, + Object? gasPrice = null, + Object? value = null, + Object? maxPriorityFeePerGas = freezed, + Object? minReceiveAmount = freezed, + }) { + return _then(_$OkxSwapTransactionImpl( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as String, + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + to: null == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as String, + gas: null == gas + ? _value.gas + : gas // ignore: cast_nullable_to_non_nullable + as String, + gasPrice: null == gasPrice + ? _value.gasPrice + : gasPrice // ignore: cast_nullable_to_non_nullable + as String, + value: null == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String, + maxPriorityFeePerGas: freezed == maxPriorityFeePerGas + ? _value.maxPriorityFeePerGas + : maxPriorityFeePerGas // ignore: cast_nullable_to_non_nullable + as String?, + minReceiveAmount: freezed == minReceiveAmount + ? _value.minReceiveAmount + : minReceiveAmount // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$OkxSwapTransactionImpl implements _OkxSwapTransaction { + _$OkxSwapTransactionImpl( + {required this.data, + required this.from, + required this.to, + required this.gas, + required this.gasPrice, + required this.value, + this.maxPriorityFeePerGas, + this.minReceiveAmount}); + + factory _$OkxSwapTransactionImpl.fromJson(Map json) => + _$$OkxSwapTransactionImplFromJson(json); + + @override + final String data; + @override + final String from; + @override + final String to; + @override + final String gas; + @override + final String gasPrice; + @override + final String value; + @override + final String? maxPriorityFeePerGas; + @override + final String? minReceiveAmount; + + @override + String toString() { + return 'OkxSwapTransaction(data: $data, from: $from, to: $to, gas: $gas, gasPrice: $gasPrice, value: $value, maxPriorityFeePerGas: $maxPriorityFeePerGas, minReceiveAmount: $minReceiveAmount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OkxSwapTransactionImpl && + (identical(other.data, data) || other.data == data) && + (identical(other.from, from) || other.from == from) && + (identical(other.to, to) || other.to == to) && + (identical(other.gas, gas) || other.gas == gas) && + (identical(other.gasPrice, gasPrice) || + other.gasPrice == gasPrice) && + (identical(other.value, value) || other.value == value) && + (identical(other.maxPriorityFeePerGas, maxPriorityFeePerGas) || + other.maxPriorityFeePerGas == maxPriorityFeePerGas) && + (identical(other.minReceiveAmount, minReceiveAmount) || + other.minReceiveAmount == minReceiveAmount)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, data, from, to, gas, gasPrice, + value, maxPriorityFeePerGas, minReceiveAmount); + + /// Create a copy of OkxSwapTransaction + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OkxSwapTransactionImplCopyWith<_$OkxSwapTransactionImpl> get copyWith => + __$$OkxSwapTransactionImplCopyWithImpl<_$OkxSwapTransactionImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$OkxSwapTransactionImplToJson( + this, + ); + } +} + +abstract class _OkxSwapTransaction implements OkxSwapTransaction { + factory _OkxSwapTransaction( + {required final String data, + required final String from, + required final String to, + required final String gas, + required final String gasPrice, + required final String value, + final String? maxPriorityFeePerGas, + final String? minReceiveAmount}) = _$OkxSwapTransactionImpl; + + factory _OkxSwapTransaction.fromJson(Map json) = + _$OkxSwapTransactionImpl.fromJson; + + @override + String get data; + @override + String get from; + @override + String get to; + @override + String get gas; + @override + String get gasPrice; + @override + String get value; + @override + String? get maxPriorityFeePerGas; + @override + String? get minReceiveAmount; + + /// Create a copy of OkxSwapTransaction + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OkxSwapTransactionImplCopyWith<_$OkxSwapTransactionImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/ion_swap_client/lib/models/okx_swap_transaction.m.g.dart b/packages/ion_swap_client/lib/models/okx_swap_transaction.m.g.dart new file mode 100644 index 0000000000..23930360c5 --- /dev/null +++ b/packages/ion_swap_client/lib/models/okx_swap_transaction.m.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'okx_swap_transaction.m.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$OkxSwapTransactionImpl _$$OkxSwapTransactionImplFromJson( + Map json) => + _$OkxSwapTransactionImpl( + data: json['data'] as String, + from: json['from'] as String, + to: json['to'] as String, + gas: json['gas'] as String, + gasPrice: json['gasPrice'] as String, + value: json['value'] as String, + maxPriorityFeePerGas: json['maxPriorityFeePerGas'] as String?, + minReceiveAmount: json['minReceiveAmount'] as String?, + ); + +Map _$$OkxSwapTransactionImplToJson( + _$OkxSwapTransactionImpl instance) => + { + 'data': instance.data, + 'from': instance.from, + 'to': instance.to, + 'gas': instance.gas, + 'gasPrice': instance.gasPrice, + 'value': instance.value, + 'maxPriorityFeePerGas': instance.maxPriorityFeePerGas, + 'minReceiveAmount': instance.minReceiveAmount, + }; diff --git a/packages/ion_swap_client/lib/models/relay_quote.m.dart b/packages/ion_swap_client/lib/models/relay_quote.m.dart index 00be7a871d..6fb81c8454 100644 --- a/packages/ion_swap_client/lib/models/relay_quote.m.dart +++ b/packages/ion_swap_client/lib/models/relay_quote.m.dart @@ -12,6 +12,7 @@ class RelayQuote with _$RelayQuote { factory RelayQuote({ required RelayQuoteDetails details, required List steps, + @JsonKey(name: 'fees') Map? fees, }) = _RelayQuote; factory RelayQuote.fromJson(Map json) => _$RelayQuoteFromJson(json); diff --git a/packages/ion_swap_client/lib/models/relay_quote.m.freezed.dart b/packages/ion_swap_client/lib/models/relay_quote.m.freezed.dart index b759dd3517..56748071d3 100644 --- a/packages/ion_swap_client/lib/models/relay_quote.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/relay_quote.m.freezed.dart @@ -22,6 +22,8 @@ RelayQuote _$RelayQuoteFromJson(Map json) { mixin _$RelayQuote { RelayQuoteDetails get details => throw _privateConstructorUsedError; List get steps => throw _privateConstructorUsedError; + @JsonKey(name: 'fees') + Map? get fees => throw _privateConstructorUsedError; /// Serializes this RelayQuote to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -39,7 +41,10 @@ abstract class $RelayQuoteCopyWith<$Res> { RelayQuote value, $Res Function(RelayQuote) then) = _$RelayQuoteCopyWithImpl<$Res, RelayQuote>; @useResult - $Res call({RelayQuoteDetails details, List steps}); + $Res call( + {RelayQuoteDetails details, + List steps, + @JsonKey(name: 'fees') Map? fees}); $RelayQuoteDetailsCopyWith<$Res> get details; } @@ -61,6 +66,7 @@ class _$RelayQuoteCopyWithImpl<$Res, $Val extends RelayQuote> $Res call({ Object? details = null, Object? steps = null, + Object? fees = freezed, }) { return _then(_value.copyWith( details: null == details @@ -71,6 +77,10 @@ class _$RelayQuoteCopyWithImpl<$Res, $Val extends RelayQuote> ? _value.steps : steps // ignore: cast_nullable_to_non_nullable as List, + fees: freezed == fees + ? _value.fees + : fees // ignore: cast_nullable_to_non_nullable + as Map?, ) as $Val); } @@ -93,7 +103,10 @@ abstract class _$$RelayQuoteImplCopyWith<$Res> __$$RelayQuoteImplCopyWithImpl<$Res>; @override @useResult - $Res call({RelayQuoteDetails details, List steps}); + $Res call( + {RelayQuoteDetails details, + List steps, + @JsonKey(name: 'fees') Map? fees}); @override $RelayQuoteDetailsCopyWith<$Res> get details; @@ -114,6 +127,7 @@ class __$$RelayQuoteImplCopyWithImpl<$Res> $Res call({ Object? details = null, Object? steps = null, + Object? fees = freezed, }) { return _then(_$RelayQuoteImpl( details: null == details @@ -124,6 +138,10 @@ class __$$RelayQuoteImplCopyWithImpl<$Res> ? _value._steps : steps // ignore: cast_nullable_to_non_nullable as List, + fees: freezed == fees + ? _value._fees + : fees // ignore: cast_nullable_to_non_nullable + as Map?, )); } } @@ -132,8 +150,11 @@ class __$$RelayQuoteImplCopyWithImpl<$Res> @JsonSerializable() class _$RelayQuoteImpl implements _RelayQuote { _$RelayQuoteImpl( - {required this.details, required final List steps}) - : _steps = steps; + {required this.details, + required final List steps, + @JsonKey(name: 'fees') final Map? fees}) + : _steps = steps, + _fees = fees; factory _$RelayQuoteImpl.fromJson(Map json) => _$$RelayQuoteImplFromJson(json); @@ -148,9 +169,20 @@ class _$RelayQuoteImpl implements _RelayQuote { return EqualUnmodifiableListView(_steps); } + final Map? _fees; + @override + @JsonKey(name: 'fees') + Map? get fees { + final value = _fees; + if (value == null) return null; + if (_fees is EqualUnmodifiableMapView) return _fees; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + @override String toString() { - return 'RelayQuote(details: $details, steps: $steps)'; + return 'RelayQuote(details: $details, steps: $steps, fees: $fees)'; } @override @@ -159,13 +191,17 @@ class _$RelayQuoteImpl implements _RelayQuote { (other.runtimeType == runtimeType && other is _$RelayQuoteImpl && (identical(other.details, details) || other.details == details) && - const DeepCollectionEquality().equals(other._steps, _steps)); + const DeepCollectionEquality().equals(other._steps, _steps) && + const DeepCollectionEquality().equals(other._fees, _fees)); } @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( - runtimeType, details, const DeepCollectionEquality().hash(_steps)); + runtimeType, + details, + const DeepCollectionEquality().hash(_steps), + const DeepCollectionEquality().hash(_fees)); /// Create a copy of RelayQuote /// with the given fields replaced by the non-null parameter values. @@ -185,8 +221,10 @@ class _$RelayQuoteImpl implements _RelayQuote { abstract class _RelayQuote implements RelayQuote { factory _RelayQuote( - {required final RelayQuoteDetails details, - required final List steps}) = _$RelayQuoteImpl; + {required final RelayQuoteDetails details, + required final List steps, + @JsonKey(name: 'fees') final Map? fees}) = + _$RelayQuoteImpl; factory _RelayQuote.fromJson(Map json) = _$RelayQuoteImpl.fromJson; @@ -195,6 +233,9 @@ abstract class _RelayQuote implements RelayQuote { RelayQuoteDetails get details; @override List get steps; + @override + @JsonKey(name: 'fees') + Map? get fees; /// Create a copy of RelayQuote /// with the given fields replaced by the non-null parameter values. diff --git a/packages/ion_swap_client/lib/models/relay_quote.m.g.dart b/packages/ion_swap_client/lib/models/relay_quote.m.g.dart index 750e5fe879..b9f0e66428 100644 --- a/packages/ion_swap_client/lib/models/relay_quote.m.g.dart +++ b/packages/ion_swap_client/lib/models/relay_quote.m.g.dart @@ -13,10 +13,12 @@ _$RelayQuoteImpl _$$RelayQuoteImplFromJson(Map json) => steps: (json['steps'] as List) .map((e) => RelayStep.fromJson(e as Map)) .toList(), + fees: json['fees'] as Map?, ); Map _$$RelayQuoteImplToJson(_$RelayQuoteImpl instance) => { 'details': instance.details, 'steps': instance.steps, + 'fees': instance.fees, }; diff --git a/packages/ion_swap_client/lib/models/relay_quote_details.m.dart b/packages/ion_swap_client/lib/models/relay_quote_details.m.dart index da3bb859e9..9c75038954 100644 --- a/packages/ion_swap_client/lib/models/relay_quote_details.m.dart +++ b/packages/ion_swap_client/lib/models/relay_quote_details.m.dart @@ -9,6 +9,7 @@ part 'relay_quote_details.m.g.dart'; class RelayQuoteDetails with _$RelayQuoteDetails { factory RelayQuoteDetails({ required String rate, + @JsonKey(name: 'priceImpact') String? priceImpact, }) = _RelayQuoteDetails; factory RelayQuoteDetails.fromJson(Map json) => diff --git a/packages/ion_swap_client/lib/models/relay_quote_details.m.freezed.dart b/packages/ion_swap_client/lib/models/relay_quote_details.m.freezed.dart index e478b474cd..5db8931b6f 100644 --- a/packages/ion_swap_client/lib/models/relay_quote_details.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/relay_quote_details.m.freezed.dart @@ -21,6 +21,8 @@ RelayQuoteDetails _$RelayQuoteDetailsFromJson(Map json) { /// @nodoc mixin _$RelayQuoteDetails { String get rate => throw _privateConstructorUsedError; + @JsonKey(name: 'priceImpact') + String? get priceImpact => throw _privateConstructorUsedError; /// Serializes this RelayQuoteDetails to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -38,7 +40,7 @@ abstract class $RelayQuoteDetailsCopyWith<$Res> { RelayQuoteDetails value, $Res Function(RelayQuoteDetails) then) = _$RelayQuoteDetailsCopyWithImpl<$Res, RelayQuoteDetails>; @useResult - $Res call({String rate}); + $Res call({String rate, @JsonKey(name: 'priceImpact') String? priceImpact}); } /// @nodoc @@ -57,12 +59,17 @@ class _$RelayQuoteDetailsCopyWithImpl<$Res, $Val extends RelayQuoteDetails> @override $Res call({ Object? rate = null, + Object? priceImpact = freezed, }) { return _then(_value.copyWith( rate: null == rate ? _value.rate : rate // ignore: cast_nullable_to_non_nullable as String, + priceImpact: freezed == priceImpact + ? _value.priceImpact + : priceImpact // ignore: cast_nullable_to_non_nullable + as String?, ) as $Val); } } @@ -75,7 +82,7 @@ abstract class _$$RelayQuoteDetailsImplCopyWith<$Res> __$$RelayQuoteDetailsImplCopyWithImpl<$Res>; @override @useResult - $Res call({String rate}); + $Res call({String rate, @JsonKey(name: 'priceImpact') String? priceImpact}); } /// @nodoc @@ -92,12 +99,17 @@ class __$$RelayQuoteDetailsImplCopyWithImpl<$Res> @override $Res call({ Object? rate = null, + Object? priceImpact = freezed, }) { return _then(_$RelayQuoteDetailsImpl( rate: null == rate ? _value.rate : rate // ignore: cast_nullable_to_non_nullable as String, + priceImpact: freezed == priceImpact + ? _value.priceImpact + : priceImpact // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -105,17 +117,21 @@ class __$$RelayQuoteDetailsImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$RelayQuoteDetailsImpl implements _RelayQuoteDetails { - _$RelayQuoteDetailsImpl({required this.rate}); + _$RelayQuoteDetailsImpl( + {required this.rate, @JsonKey(name: 'priceImpact') this.priceImpact}); factory _$RelayQuoteDetailsImpl.fromJson(Map json) => _$$RelayQuoteDetailsImplFromJson(json); @override final String rate; + @override + @JsonKey(name: 'priceImpact') + final String? priceImpact; @override String toString() { - return 'RelayQuoteDetails(rate: $rate)'; + return 'RelayQuoteDetails(rate: $rate, priceImpact: $priceImpact)'; } @override @@ -123,12 +139,14 @@ class _$RelayQuoteDetailsImpl implements _RelayQuoteDetails { return identical(this, other) || (other.runtimeType == runtimeType && other is _$RelayQuoteDetailsImpl && - (identical(other.rate, rate) || other.rate == rate)); + (identical(other.rate, rate) || other.rate == rate) && + (identical(other.priceImpact, priceImpact) || + other.priceImpact == priceImpact)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, rate); + int get hashCode => Object.hash(runtimeType, rate, priceImpact); /// Create a copy of RelayQuoteDetails /// with the given fields replaced by the non-null parameter values. @@ -148,7 +166,9 @@ class _$RelayQuoteDetailsImpl implements _RelayQuoteDetails { } abstract class _RelayQuoteDetails implements RelayQuoteDetails { - factory _RelayQuoteDetails({required final String rate}) = + factory _RelayQuoteDetails( + {required final String rate, + @JsonKey(name: 'priceImpact') final String? priceImpact}) = _$RelayQuoteDetailsImpl; factory _RelayQuoteDetails.fromJson(Map json) = @@ -156,6 +176,9 @@ abstract class _RelayQuoteDetails implements RelayQuoteDetails { @override String get rate; + @override + @JsonKey(name: 'priceImpact') + String? get priceImpact; /// Create a copy of RelayQuoteDetails /// with the given fields replaced by the non-null parameter values. diff --git a/packages/ion_swap_client/lib/models/relay_quote_details.m.g.dart b/packages/ion_swap_client/lib/models/relay_quote_details.m.g.dart index dbd8ea048e..66216cf382 100644 --- a/packages/ion_swap_client/lib/models/relay_quote_details.m.g.dart +++ b/packages/ion_swap_client/lib/models/relay_quote_details.m.g.dart @@ -10,10 +10,12 @@ _$RelayQuoteDetailsImpl _$$RelayQuoteDetailsImplFromJson( Map json) => _$RelayQuoteDetailsImpl( rate: json['rate'] as String, + priceImpact: json['priceImpact'] as String?, ); Map _$$RelayQuoteDetailsImplToJson( _$RelayQuoteDetailsImpl instance) => { 'rate': instance.rate, + 'priceImpact': instance.priceImpact, }; diff --git a/packages/ion_swap_client/lib/models/swap_chain_data.m.freezed.dart b/packages/ion_swap_client/lib/models/swap_chain_data.m.freezed.dart index 0f63e85295..87943ea0fe 100644 --- a/packages/ion_swap_client/lib/models/swap_chain_data.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/swap_chain_data.m.freezed.dart @@ -30,12 +30,14 @@ mixin _$SwapChainData { /// Create a copy of SwapChainData /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $SwapChainDataCopyWith get copyWith => throw _privateConstructorUsedError; + $SwapChainDataCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $SwapChainDataCopyWith<$Res> { - factory $SwapChainDataCopyWith(SwapChainData value, $Res Function(SwapChainData) then) = + factory $SwapChainDataCopyWith( + SwapChainData value, $Res Function(SwapChainData) then) = _$SwapChainDataCopyWithImpl<$Res, SwapChainData>; @useResult $Res call({int chainIndex, String chainName, String dexTokenApproveAddress}); @@ -78,7 +80,8 @@ class _$SwapChainDataCopyWithImpl<$Res, $Val extends SwapChainData> } /// @nodoc -abstract class _$$SwapChainDataImplCopyWith<$Res> implements $SwapChainDataCopyWith<$Res> { +abstract class _$$SwapChainDataImplCopyWith<$Res> + implements $SwapChainDataCopyWith<$Res> { factory _$$SwapChainDataImplCopyWith( _$SwapChainDataImpl value, $Res Function(_$SwapChainDataImpl) then) = __$$SwapChainDataImplCopyWithImpl<$Res>; @@ -125,7 +128,9 @@ class __$$SwapChainDataImplCopyWithImpl<$Res> @JsonSerializable() class _$SwapChainDataImpl implements _SwapChainData { _$SwapChainDataImpl( - {required this.chainIndex, required this.chainName, required this.dexTokenApproveAddress}); + {required this.chainIndex, + required this.chainName, + required this.dexTokenApproveAddress}); factory _$SwapChainDataImpl.fromJson(Map json) => _$$SwapChainDataImplFromJson(json); @@ -147,15 +152,18 @@ class _$SwapChainDataImpl implements _SwapChainData { return identical(this, other) || (other.runtimeType == runtimeType && other is _$SwapChainDataImpl && - (identical(other.chainIndex, chainIndex) || other.chainIndex == chainIndex) && - (identical(other.chainName, chainName) || other.chainName == chainName) && + (identical(other.chainIndex, chainIndex) || + other.chainIndex == chainIndex) && + (identical(other.chainName, chainName) || + other.chainName == chainName) && (identical(other.dexTokenApproveAddress, dexTokenApproveAddress) || other.dexTokenApproveAddress == dexTokenApproveAddress)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, chainIndex, chainName, dexTokenApproveAddress); + int get hashCode => + Object.hash(runtimeType, chainIndex, chainName, dexTokenApproveAddress); /// Create a copy of SwapChainData /// with the given fields replaced by the non-null parameter values. @@ -179,7 +187,8 @@ abstract class _SwapChainData implements SwapChainData { required final String chainName, required final String dexTokenApproveAddress}) = _$SwapChainDataImpl; - factory _SwapChainData.fromJson(Map json) = _$SwapChainDataImpl.fromJson; + factory _SwapChainData.fromJson(Map json) = + _$SwapChainDataImpl.fromJson; @override int get chainIndex; diff --git a/packages/ion_swap_client/lib/models/swap_chain_data.m.g.dart b/packages/ion_swap_client/lib/models/swap_chain_data.m.g.dart index bf0049688a..57984e11c8 100644 --- a/packages/ion_swap_client/lib/models/swap_chain_data.m.g.dart +++ b/packages/ion_swap_client/lib/models/swap_chain_data.m.g.dart @@ -6,13 +6,15 @@ part of 'swap_chain_data.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SwapChainDataImpl _$$SwapChainDataImplFromJson(Map json) => _$SwapChainDataImpl( +_$SwapChainDataImpl _$$SwapChainDataImplFromJson(Map json) => + _$SwapChainDataImpl( chainIndex: (json['chainIndex'] as num).toInt(), chainName: json['chainName'] as String, dexTokenApproveAddress: json['dexTokenApproveAddress'] as String, ); -Map _$$SwapChainDataImplToJson(_$SwapChainDataImpl instance) => { +Map _$$SwapChainDataImplToJson(_$SwapChainDataImpl instance) => + { 'chainIndex': instance.chainIndex, 'chainName': instance.chainName, 'dexTokenApproveAddress': instance.dexTokenApproveAddress, diff --git a/packages/ion_swap_client/lib/models/swap_coin.m.freezed.dart b/packages/ion_swap_client/lib/models/swap_coin.m.freezed.dart index 5f823c0610..120a95f1b5 100644 --- a/packages/ion_swap_client/lib/models/swap_coin.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/swap_coin.m.freezed.dart @@ -35,7 +35,8 @@ mixin _$SwapCoin { /// Create a copy of SwapCoin /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $SwapCoinCopyWith get copyWith => throw _privateConstructorUsedError; + $SwapCoinCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc @@ -44,13 +45,18 @@ abstract class $SwapCoinCopyWith<$Res> { _$SwapCoinCopyWithImpl<$Res, SwapCoin>; @useResult $Res call( - {String contractAddress, String code, int decimal, SwapNetwork network, String extraId}); + {String contractAddress, + String code, + int decimal, + SwapNetwork network, + String extraId}); $SwapNetworkCopyWith<$Res> get network; } /// @nodoc -class _$SwapCoinCopyWithImpl<$Res, $Val extends SwapCoin> implements $SwapCoinCopyWith<$Res> { +class _$SwapCoinCopyWithImpl<$Res, $Val extends SwapCoin> + implements $SwapCoinCopyWith<$Res> { _$SwapCoinCopyWithImpl(this._value, this._then); // ignore: unused_field @@ -105,22 +111,30 @@ class _$SwapCoinCopyWithImpl<$Res, $Val extends SwapCoin> implements $SwapCoinCo } /// @nodoc -abstract class _$$SwapCoinImplCopyWith<$Res> implements $SwapCoinCopyWith<$Res> { - factory _$$SwapCoinImplCopyWith(_$SwapCoinImpl value, $Res Function(_$SwapCoinImpl) then) = +abstract class _$$SwapCoinImplCopyWith<$Res> + implements $SwapCoinCopyWith<$Res> { + factory _$$SwapCoinImplCopyWith( + _$SwapCoinImpl value, $Res Function(_$SwapCoinImpl) then) = __$$SwapCoinImplCopyWithImpl<$Res>; @override @useResult $Res call( - {String contractAddress, String code, int decimal, SwapNetwork network, String extraId}); + {String contractAddress, + String code, + int decimal, + SwapNetwork network, + String extraId}); @override $SwapNetworkCopyWith<$Res> get network; } /// @nodoc -class __$$SwapCoinImplCopyWithImpl<$Res> extends _$SwapCoinCopyWithImpl<$Res, _$SwapCoinImpl> +class __$$SwapCoinImplCopyWithImpl<$Res> + extends _$SwapCoinCopyWithImpl<$Res, _$SwapCoinImpl> implements _$$SwapCoinImplCopyWith<$Res> { - __$$SwapCoinImplCopyWithImpl(_$SwapCoinImpl _value, $Res Function(_$SwapCoinImpl) _then) + __$$SwapCoinImplCopyWithImpl( + _$SwapCoinImpl _value, $Res Function(_$SwapCoinImpl) _then) : super(_value, _then); /// Create a copy of SwapCoin @@ -169,7 +183,8 @@ class _$SwapCoinImpl implements _SwapCoin { required this.network, required this.extraId}); - factory _$SwapCoinImpl.fromJson(Map json) => _$$SwapCoinImplFromJson(json); + factory _$SwapCoinImpl.fromJson(Map json) => + _$$SwapCoinImplFromJson(json); @override final String contractAddress; @@ -205,7 +220,8 @@ class _$SwapCoinImpl implements _SwapCoin { @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, contractAddress, code, decimal, network, extraId); + int get hashCode => Object.hash( + runtimeType, contractAddress, code, decimal, network, extraId); /// Create a copy of SwapCoin /// with the given fields replaced by the non-null parameter values. @@ -231,7 +247,8 @@ abstract class _SwapCoin implements SwapCoin { required final SwapNetwork network, required final String extraId}) = _$SwapCoinImpl; - factory _SwapCoin.fromJson(Map json) = _$SwapCoinImpl.fromJson; + factory _SwapCoin.fromJson(Map json) = + _$SwapCoinImpl.fromJson; @override String get contractAddress; @@ -251,5 +268,6 @@ abstract class _SwapCoin implements SwapCoin { /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$SwapCoinImplCopyWith<_$SwapCoinImpl> get copyWith => throw _privateConstructorUsedError; + _$$SwapCoinImplCopyWith<_$SwapCoinImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/ion_swap_client/lib/models/swap_coin.m.g.dart b/packages/ion_swap_client/lib/models/swap_coin.m.g.dart index 227a0f2866..90135adce4 100644 --- a/packages/ion_swap_client/lib/models/swap_coin.m.g.dart +++ b/packages/ion_swap_client/lib/models/swap_coin.m.g.dart @@ -6,7 +6,8 @@ part of 'swap_coin.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SwapCoinImpl _$$SwapCoinImplFromJson(Map json) => _$SwapCoinImpl( +_$SwapCoinImpl _$$SwapCoinImplFromJson(Map json) => + _$SwapCoinImpl( contractAddress: json['contractAddress'] as String, code: json['code'] as String, decimal: (json['decimal'] as num).toInt(), @@ -14,7 +15,8 @@ _$SwapCoinImpl _$$SwapCoinImplFromJson(Map json) => _$SwapCoinI extraId: json['extraId'] as String, ); -Map _$$SwapCoinImplToJson(_$SwapCoinImpl instance) => { +Map _$$SwapCoinImplToJson(_$SwapCoinImpl instance) => + { 'contractAddress': instance.contractAddress, 'code': instance.code, 'decimal': instance.decimal, diff --git a/packages/ion_swap_client/lib/models/swap_network.m.freezed.dart b/packages/ion_swap_client/lib/models/swap_network.m.freezed.dart index 4f24de3bf6..1e843d4840 100644 --- a/packages/ion_swap_client/lib/models/swap_network.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/swap_network.m.freezed.dart @@ -29,12 +29,14 @@ mixin _$SwapNetwork { /// Create a copy of SwapNetwork /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - $SwapNetworkCopyWith get copyWith => throw _privateConstructorUsedError; + $SwapNetworkCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $SwapNetworkCopyWith<$Res> { - factory $SwapNetworkCopyWith(SwapNetwork value, $Res Function(SwapNetwork) then) = + factory $SwapNetworkCopyWith( + SwapNetwork value, $Res Function(SwapNetwork) then) = _$SwapNetworkCopyWithImpl<$Res, SwapNetwork>; @useResult $Res call({String id, String name}); @@ -72,7 +74,8 @@ class _$SwapNetworkCopyWithImpl<$Res, $Val extends SwapNetwork> } /// @nodoc -abstract class _$$SwapNetworkImplCopyWith<$Res> implements $SwapNetworkCopyWith<$Res> { +abstract class _$$SwapNetworkImplCopyWith<$Res> + implements $SwapNetworkCopyWith<$Res> { factory _$$SwapNetworkImplCopyWith( _$SwapNetworkImpl value, $Res Function(_$SwapNetworkImpl) then) = __$$SwapNetworkImplCopyWithImpl<$Res>; @@ -85,7 +88,8 @@ abstract class _$$SwapNetworkImplCopyWith<$Res> implements $SwapNetworkCopyWith< class __$$SwapNetworkImplCopyWithImpl<$Res> extends _$SwapNetworkCopyWithImpl<$Res, _$SwapNetworkImpl> implements _$$SwapNetworkImplCopyWith<$Res> { - __$$SwapNetworkImplCopyWithImpl(_$SwapNetworkImpl _value, $Res Function(_$SwapNetworkImpl) _then) + __$$SwapNetworkImplCopyWithImpl( + _$SwapNetworkImpl _value, $Res Function(_$SwapNetworkImpl) _then) : super(_value, _then); /// Create a copy of SwapNetwork @@ -114,7 +118,8 @@ class __$$SwapNetworkImplCopyWithImpl<$Res> class _$SwapNetworkImpl implements _SwapNetwork { _$SwapNetworkImpl({required this.id, required this.name}); - factory _$SwapNetworkImpl.fromJson(Map json) => _$$SwapNetworkImplFromJson(json); + factory _$SwapNetworkImpl.fromJson(Map json) => + _$$SwapNetworkImplFromJson(json); @override final String id; @@ -156,9 +161,11 @@ class _$SwapNetworkImpl implements _SwapNetwork { } abstract class _SwapNetwork implements SwapNetwork { - factory _SwapNetwork({required final String id, required final String name}) = _$SwapNetworkImpl; + factory _SwapNetwork({required final String id, required final String name}) = + _$SwapNetworkImpl; - factory _SwapNetwork.fromJson(Map json) = _$SwapNetworkImpl.fromJson; + factory _SwapNetwork.fromJson(Map json) = + _$SwapNetworkImpl.fromJson; @override String get id; @@ -169,5 +176,6 @@ abstract class _SwapNetwork implements SwapNetwork { /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) - _$$SwapNetworkImplCopyWith<_$SwapNetworkImpl> get copyWith => throw _privateConstructorUsedError; + _$$SwapNetworkImplCopyWith<_$SwapNetworkImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/ion_swap_client/lib/models/swap_network.m.g.dart b/packages/ion_swap_client/lib/models/swap_network.m.g.dart index 563641ff4f..fb10c0ce69 100644 --- a/packages/ion_swap_client/lib/models/swap_network.m.g.dart +++ b/packages/ion_swap_client/lib/models/swap_network.m.g.dart @@ -6,12 +6,14 @@ part of 'swap_network.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SwapNetworkImpl _$$SwapNetworkImplFromJson(Map json) => _$SwapNetworkImpl( +_$SwapNetworkImpl _$$SwapNetworkImplFromJson(Map json) => + _$SwapNetworkImpl( id: json['id'] as String, name: json['name'] as String, ); -Map _$$SwapNetworkImplToJson(_$SwapNetworkImpl instance) => { +Map _$$SwapNetworkImplToJson(_$SwapNetworkImpl instance) => + { 'id': instance.id, 'name': instance.name, }; diff --git a/packages/ion_swap_client/lib/models/swap_quote_data.m.dart b/packages/ion_swap_client/lib/models/swap_quote_data.m.dart index 81e1bfb78b..beca00ffb2 100644 --- a/packages/ion_swap_client/lib/models/swap_quote_data.m.dart +++ b/packages/ion_swap_client/lib/models/swap_quote_data.m.dart @@ -16,6 +16,9 @@ class SwapQuoteData with _$SwapQuoteData { required String toTokenAmount, required OkxTokenInfo fromToken, required OkxTokenInfo toToken, + @JsonKey(name: 'priceImpactPercent') String? priceImpactPercent, + @JsonKey(name: 'estimateGasFee') String? estimateGasFee, + @JsonKey(name: 'tradeFee') String? tradeFee, }) = _SwapQuoteData; factory SwapQuoteData.fromJson(Map json) => _$SwapQuoteDataFromJson(json); diff --git a/packages/ion_swap_client/lib/models/swap_quote_data.m.freezed.dart b/packages/ion_swap_client/lib/models/swap_quote_data.m.freezed.dart index f0e4acee00..cfcc6cca39 100644 --- a/packages/ion_swap_client/lib/models/swap_quote_data.m.freezed.dart +++ b/packages/ion_swap_client/lib/models/swap_quote_data.m.freezed.dart @@ -25,6 +25,12 @@ mixin _$SwapQuoteData { String get toTokenAmount => throw _privateConstructorUsedError; OkxTokenInfo get fromToken => throw _privateConstructorUsedError; OkxTokenInfo get toToken => throw _privateConstructorUsedError; + @JsonKey(name: 'priceImpactPercent') + String? get priceImpactPercent => throw _privateConstructorUsedError; + @JsonKey(name: 'estimateGasFee') + String? get estimateGasFee => throw _privateConstructorUsedError; + @JsonKey(name: 'tradeFee') + String? get tradeFee => throw _privateConstructorUsedError; /// Serializes this SwapQuoteData to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -47,7 +53,10 @@ abstract class $SwapQuoteDataCopyWith<$Res> { String fromTokenAmount, String toTokenAmount, OkxTokenInfo fromToken, - OkxTokenInfo toToken}); + OkxTokenInfo toToken, + @JsonKey(name: 'priceImpactPercent') String? priceImpactPercent, + @JsonKey(name: 'estimateGasFee') String? estimateGasFee, + @JsonKey(name: 'tradeFee') String? tradeFee}); $OkxTokenInfoCopyWith<$Res> get fromToken; $OkxTokenInfoCopyWith<$Res> get toToken; @@ -73,6 +82,9 @@ class _$SwapQuoteDataCopyWithImpl<$Res, $Val extends SwapQuoteData> Object? toTokenAmount = null, Object? fromToken = null, Object? toToken = null, + Object? priceImpactPercent = freezed, + Object? estimateGasFee = freezed, + Object? tradeFee = freezed, }) { return _then(_value.copyWith( chainIndex: null == chainIndex @@ -95,6 +107,18 @@ class _$SwapQuoteDataCopyWithImpl<$Res, $Val extends SwapQuoteData> ? _value.toToken : toToken // ignore: cast_nullable_to_non_nullable as OkxTokenInfo, + priceImpactPercent: freezed == priceImpactPercent + ? _value.priceImpactPercent + : priceImpactPercent // ignore: cast_nullable_to_non_nullable + as String?, + estimateGasFee: freezed == estimateGasFee + ? _value.estimateGasFee + : estimateGasFee // ignore: cast_nullable_to_non_nullable + as String?, + tradeFee: freezed == tradeFee + ? _value.tradeFee + : tradeFee // ignore: cast_nullable_to_non_nullable + as String?, ) as $Val); } @@ -132,7 +156,10 @@ abstract class _$$SwapQuoteDataImplCopyWith<$Res> String fromTokenAmount, String toTokenAmount, OkxTokenInfo fromToken, - OkxTokenInfo toToken}); + OkxTokenInfo toToken, + @JsonKey(name: 'priceImpactPercent') String? priceImpactPercent, + @JsonKey(name: 'estimateGasFee') String? estimateGasFee, + @JsonKey(name: 'tradeFee') String? tradeFee}); @override $OkxTokenInfoCopyWith<$Res> get fromToken; @@ -158,6 +185,9 @@ class __$$SwapQuoteDataImplCopyWithImpl<$Res> Object? toTokenAmount = null, Object? fromToken = null, Object? toToken = null, + Object? priceImpactPercent = freezed, + Object? estimateGasFee = freezed, + Object? tradeFee = freezed, }) { return _then(_$SwapQuoteDataImpl( chainIndex: null == chainIndex @@ -180,6 +210,18 @@ class __$$SwapQuoteDataImplCopyWithImpl<$Res> ? _value.toToken : toToken // ignore: cast_nullable_to_non_nullable as OkxTokenInfo, + priceImpactPercent: freezed == priceImpactPercent + ? _value.priceImpactPercent + : priceImpactPercent // ignore: cast_nullable_to_non_nullable + as String?, + estimateGasFee: freezed == estimateGasFee + ? _value.estimateGasFee + : estimateGasFee // ignore: cast_nullable_to_non_nullable + as String?, + tradeFee: freezed == tradeFee + ? _value.tradeFee + : tradeFee // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -192,7 +234,10 @@ class _$SwapQuoteDataImpl implements _SwapQuoteData { required this.fromTokenAmount, required this.toTokenAmount, required this.fromToken, - required this.toToken}); + required this.toToken, + @JsonKey(name: 'priceImpactPercent') this.priceImpactPercent, + @JsonKey(name: 'estimateGasFee') this.estimateGasFee, + @JsonKey(name: 'tradeFee') this.tradeFee}); factory _$SwapQuoteDataImpl.fromJson(Map json) => _$$SwapQuoteDataImplFromJson(json); @@ -207,10 +252,19 @@ class _$SwapQuoteDataImpl implements _SwapQuoteData { final OkxTokenInfo fromToken; @override final OkxTokenInfo toToken; + @override + @JsonKey(name: 'priceImpactPercent') + final String? priceImpactPercent; + @override + @JsonKey(name: 'estimateGasFee') + final String? estimateGasFee; + @override + @JsonKey(name: 'tradeFee') + final String? tradeFee; @override String toString() { - return 'SwapQuoteData(chainIndex: $chainIndex, fromTokenAmount: $fromTokenAmount, toTokenAmount: $toTokenAmount, fromToken: $fromToken, toToken: $toToken)'; + return 'SwapQuoteData(chainIndex: $chainIndex, fromTokenAmount: $fromTokenAmount, toTokenAmount: $toTokenAmount, fromToken: $fromToken, toToken: $toToken, priceImpactPercent: $priceImpactPercent, estimateGasFee: $estimateGasFee, tradeFee: $tradeFee)'; } @override @@ -226,13 +280,27 @@ class _$SwapQuoteDataImpl implements _SwapQuoteData { other.toTokenAmount == toTokenAmount) && (identical(other.fromToken, fromToken) || other.fromToken == fromToken) && - (identical(other.toToken, toToken) || other.toToken == toToken)); + (identical(other.toToken, toToken) || other.toToken == toToken) && + (identical(other.priceImpactPercent, priceImpactPercent) || + other.priceImpactPercent == priceImpactPercent) && + (identical(other.estimateGasFee, estimateGasFee) || + other.estimateGasFee == estimateGasFee) && + (identical(other.tradeFee, tradeFee) || + other.tradeFee == tradeFee)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, chainIndex, fromTokenAmount, - toTokenAmount, fromToken, toToken); + int get hashCode => Object.hash( + runtimeType, + chainIndex, + fromTokenAmount, + toTokenAmount, + fromToken, + toToken, + priceImpactPercent, + estimateGasFee, + tradeFee); /// Create a copy of SwapQuoteData /// with the given fields replaced by the non-null parameter values. @@ -256,7 +324,10 @@ abstract class _SwapQuoteData implements SwapQuoteData { required final String fromTokenAmount, required final String toTokenAmount, required final OkxTokenInfo fromToken, - required final OkxTokenInfo toToken}) = _$SwapQuoteDataImpl; + required final OkxTokenInfo toToken, + @JsonKey(name: 'priceImpactPercent') final String? priceImpactPercent, + @JsonKey(name: 'estimateGasFee') final String? estimateGasFee, + @JsonKey(name: 'tradeFee') final String? tradeFee}) = _$SwapQuoteDataImpl; factory _SwapQuoteData.fromJson(Map json) = _$SwapQuoteDataImpl.fromJson; @@ -271,6 +342,15 @@ abstract class _SwapQuoteData implements SwapQuoteData { OkxTokenInfo get fromToken; @override OkxTokenInfo get toToken; + @override + @JsonKey(name: 'priceImpactPercent') + String? get priceImpactPercent; + @override + @JsonKey(name: 'estimateGasFee') + String? get estimateGasFee; + @override + @JsonKey(name: 'tradeFee') + String? get tradeFee; /// Create a copy of SwapQuoteData /// with the given fields replaced by the non-null parameter values. diff --git a/packages/ion_swap_client/lib/models/swap_quote_data.m.g.dart b/packages/ion_swap_client/lib/models/swap_quote_data.m.g.dart index 1043bf9d42..beba50bab9 100644 --- a/packages/ion_swap_client/lib/models/swap_quote_data.m.g.dart +++ b/packages/ion_swap_client/lib/models/swap_quote_data.m.g.dart @@ -6,18 +6,27 @@ part of 'swap_quote_data.m.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SwapQuoteDataImpl _$$SwapQuoteDataImplFromJson(Map json) => _$SwapQuoteDataImpl( +_$SwapQuoteDataImpl _$$SwapQuoteDataImplFromJson(Map json) => + _$SwapQuoteDataImpl( chainIndex: json['chainIndex'] as String, fromTokenAmount: json['fromTokenAmount'] as String, toTokenAmount: json['toTokenAmount'] as String, - fromToken: OkxTokenInfo.fromJson(json['fromToken'] as Map), + fromToken: + OkxTokenInfo.fromJson(json['fromToken'] as Map), toToken: OkxTokenInfo.fromJson(json['toToken'] as Map), + priceImpactPercent: json['priceImpactPercent'] as String?, + estimateGasFee: json['estimateGasFee'] as String?, + tradeFee: json['tradeFee'] as String?, ); -Map _$$SwapQuoteDataImplToJson(_$SwapQuoteDataImpl instance) => { +Map _$$SwapQuoteDataImplToJson(_$SwapQuoteDataImpl instance) => + { 'chainIndex': instance.chainIndex, 'fromTokenAmount': instance.fromTokenAmount, 'toTokenAmount': instance.toTokenAmount, 'fromToken': instance.fromToken, 'toToken': instance.toToken, + 'priceImpactPercent': instance.priceImpactPercent, + 'estimateGasFee': instance.estimateGasFee, + 'tradeFee': instance.tradeFee, }; diff --git a/packages/ion_swap_client/lib/repositories/exolix_repository.dart b/packages/ion_swap_client/lib/repositories/exolix_repository.dart index 6a27f1114d..05389bc32a 100644 --- a/packages/ion_swap_client/lib/repositories/exolix_repository.dart +++ b/packages/ion_swap_client/lib/repositories/exolix_repository.dart @@ -1,7 +1,9 @@ // SPDX-License-Identifier: ice License 1.0 import 'package:dio/dio.dart'; +import 'package:ion_swap_client/exceptions/exolix_exceptions.dart'; import 'package:ion_swap_client/models/exolix_coin.m.dart'; +import 'package:ion_swap_client/models/exolix_error.m.dart'; import 'package:ion_swap_client/models/exolix_rate.m.dart'; import 'package:ion_swap_client/models/exolix_transaction.m.dart'; @@ -33,20 +35,32 @@ class ExolixRepository { required String networkTo, required String amount, }) async { - final response = await _dio.get( - '/rate', - queryParameters: { - 'rateType': 'fixed', - 'coinFrom': coinFrom, - 'networkFrom': networkFrom, - 'coinTo': coinTo, - 'networkTo': networkTo, - 'amount': amount, - }, - ); + try { + final response = await _dio.get( + '/rate', + queryParameters: { + 'rateType': 'fixed', + 'coinFrom': coinFrom, + 'networkFrom': networkFrom, + 'coinTo': coinTo, + 'networkTo': networkTo, + 'amount': amount, + }, + ); - final data = response.data as Map; - return ExolixRate.fromJson(data); + final data = response.data as Map; + return ExolixRate.fromJson(data); + } on DioException catch (e) { + if (e.response?.statusCode == 422 && e.response?.data != null) { + final errorData = e.response!.data as Map; + final exolixError = ExolixError.fromJson(errorData); + throw ExolixBelowMinimumException( + minAmount: exolixError.minAmount, + message: exolixError.message, + ); + } + rethrow; + } } Future createTransaction({ diff --git a/packages/ion_swap_client/lib/repositories/lets_exchange_repository.dart b/packages/ion_swap_client/lib/repositories/lets_exchange_repository.dart index b053a221dd..0b56466593 100644 --- a/packages/ion_swap_client/lib/repositories/lets_exchange_repository.dart +++ b/packages/ion_swap_client/lib/repositories/lets_exchange_repository.dart @@ -65,7 +65,7 @@ class LetsExchangeRepository { 'network_to': networkTo, 'deposit_amount': depositAmount, 'affiliate_id': affiliateId, - 'withdrawal_address': withdrawalAddress, + 'withdrawal': withdrawalAddress, 'rate_id': rateId, 'withdrawal_extra_id': withdrawalExtraId, }, diff --git a/packages/ion_swap_client/lib/repositories/swap_okx_repository.dart b/packages/ion_swap_client/lib/repositories/swap_okx_repository.dart index b5743efb53..0bbfb1b3b4 100644 --- a/packages/ion_swap_client/lib/repositories/swap_okx_repository.dart +++ b/packages/ion_swap_client/lib/repositories/swap_okx_repository.dart @@ -3,6 +3,7 @@ import 'package:dio/dio.dart'; import 'package:ion_swap_client/models/approve_transaction_data.m.dart'; import 'package:ion_swap_client/models/okx_api_response.m.dart'; +import 'package:ion_swap_client/models/okx_swap_response.m.dart'; import 'package:ion_swap_client/models/swap_chain_data.m.dart'; import 'package:ion_swap_client/models/swap_quote_data.m.dart'; @@ -85,14 +86,15 @@ class SwapOkxRepository { ); } - Future swap({ + Future>> swap({ required String chainIndex, required String amount, required String toTokenAddress, required String fromTokenAddress, required String userWalletAddress, + String slippagePercent = '3', }) async { - await _dio.get( + final response = await _dio.get( '$_aggregatorBaseUrl/swap', queryParameters: { 'chainIndex': chainIndex, @@ -101,8 +103,20 @@ class SwapOkxRepository { 'fromTokenAddress': fromTokenAddress, 'toTokenAddress': toTokenAddress, 'userWalletAddress': userWalletAddress, + 'slippagePercent': slippagePercent, }, ); + + return OkxApiResponse.fromJson( + response.data as Map, + (json) => + (json as List?) + ?.map( + (e) => OkxSwapResponse.fromJson(e as Map), + ) + .toList() ?? + [], + ); } Future broadcastSwap({ diff --git a/packages/ion_swap_client/lib/service_locator/network_service_locator.dart b/packages/ion_swap_client/lib/service_locator/network_service_locator.dart index 0ad5c76031..8b066260ca 100644 --- a/packages/ion_swap_client/lib/service_locator/network_service_locator.dart +++ b/packages/ion_swap_client/lib/service_locator/network_service_locator.dart @@ -27,6 +27,14 @@ mixin _OkxDio { final dio = Dio( BaseOptions( baseUrl: config.okxApiUrl, + contentType: 'application/json', + headers: { + 'Accept': 'application/json', + 'User-Agent': 'ION-swap-client/1.0 (Dart/Flutter)', + }, + followRedirects: true, + maxRedirects: 5, + validateStatus: (status) => status != null && status >= 200 && status < 400, ), ); dio.interceptors.addAll(config.interceptors); @@ -58,6 +66,14 @@ mixin _RelayDio { final dio = Dio( BaseOptions( baseUrl: config.relayBaseUrl, + contentType: 'application/json', + headers: { + 'Accept': 'application/json', + 'User-Agent': 'ION-swap-client/1.0 (Dart/Flutter)', + }, + followRedirects: true, + maxRedirects: 5, + validateStatus: (status) => status != null && status >= 200 && status < 400, ), ); dio.interceptors.addAll(config.interceptors); @@ -80,6 +96,14 @@ mixin _LetsExchangeDio { final dio = Dio( BaseOptions( baseUrl: config.letsExchangeApiUrl, + contentType: 'application/json', + headers: { + 'Accept': 'application/json', + 'User-Agent': 'ION-swap-client/1.0 (Dart/Flutter)', + }, + followRedirects: true, + maxRedirects: 5, + validateStatus: (status) => status != null && status >= 200 && status < 400, ), ); dio.interceptors.addAll(config.interceptors); @@ -109,6 +133,14 @@ mixin _ExolixDio { final dio = Dio( BaseOptions( baseUrl: config.exolixApiUrl, + contentType: 'application/json', + headers: { + 'Accept': 'application/json', + 'User-Agent': 'ION-swap-client/1.0 (Dart/Flutter)', + }, + followRedirects: true, + maxRedirects: 5, + validateStatus: (status) => status != null && status >= 200 && status < 400, ), ); dio.interceptors.addAll(config.interceptors); diff --git a/packages/ion_swap_client/lib/services/bridge_service.dart b/packages/ion_swap_client/lib/services/bridge_service.dart index aac01b45c9..4c89b0c23c 100644 --- a/packages/ion_swap_client/lib/services/bridge_service.dart +++ b/packages/ion_swap_client/lib/services/bridge_service.dart @@ -9,6 +9,7 @@ import 'package:ion_swap_client/models/swap_coin_parameters.m.dart'; import 'package:ion_swap_client/models/swap_quote_info.m.dart'; import 'package:ion_swap_client/repositories/relay_api_repository.dart'; import 'package:ion_swap_client/services/swap_service.dart'; +import 'package:ion_swap_client/utils/crypto_amount_converter.dart'; class BridgeService { BridgeService({ @@ -61,7 +62,7 @@ class BridgeService { throw const CoinPairNotFoundException(); } - final swapAmount = _getSwapAmount( + final swapAmount = toBlockchainUnits( swapCoinData.amount, buyChain.currency.decimals, ); @@ -100,8 +101,4 @@ class BridgeService { } String get _nativeTokenAddress => '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'; - - String _getSwapAmount(String amount, int decimals) { - return (BigInt.from(double.parse(amount)) * BigInt.from(10).pow(decimals)).toString(); - } } diff --git a/packages/ion_swap_client/lib/services/cex_service.dart b/packages/ion_swap_client/lib/services/cex_service.dart index d252030aaa..33acedc9ee 100644 --- a/packages/ion_swap_client/lib/services/cex_service.dart +++ b/packages/ion_swap_client/lib/services/cex_service.dart @@ -82,6 +82,7 @@ class CexService { priceForSellTokenInBuyToken: exolixRateDouble, source: SwapQuoteInfoSource.exolix, exolixQuote: exolixRate, + // Note: Exolix API doesn't provide fee breakdown or price impact in rate response ); } @@ -90,6 +91,9 @@ class CexService { priceForSellTokenInBuyToken: letsExchangeRateDouble, source: SwapQuoteInfoSource.letsExchange, letsExchangeQuote: letsExchangeRate, + networkFee: letsExchangeRate.withdrawalFee, + protocolFee: letsExchangeRate.fee, + // Note: LetsExchange API doesn't provide price impact in the response ); } else if (exolixRate != null) { final exolixRateDouble = exolixRate.rate.toDouble(); @@ -99,6 +103,7 @@ class CexService { priceForSellTokenInBuyToken: exolixRateDouble, source: SwapQuoteInfoSource.exolix, exolixQuote: exolixRate, + // Note: Exolix API doesn't provide fee breakdown or price impact in rate response ); } else if (letsExchangeRate != null) { final letsExchangeRateDouble = num.parse(letsExchangeRate.rate).toDouble(); @@ -108,6 +113,9 @@ class CexService { priceForSellTokenInBuyToken: letsExchangeRateDouble, source: SwapQuoteInfoSource.letsExchange, letsExchangeQuote: letsExchangeRate, + networkFee: letsExchangeRate.withdrawalFee, + protocolFee: letsExchangeRate.fee, + // Note: LetsExchange API doesn't provide price impact in the response ); } @@ -287,11 +295,12 @@ class CexService { throw const IonSwapException('Exolix: Coins pair not found'); } + // Some networks have a bit different names from our naming, like BNB and BNB Smart Chain (BEP20) final sellNetwork = sellCoin.networks.firstWhereOrNull( - (e) => e.name.toLowerCase() == swapCoinData.sellCoin.network.name.toLowerCase(), + (e) => e.name.toLowerCase().contains(swapCoinData.sellCoin.network.name.toLowerCase()), ); final buyNetwork = buyCoin.networks.firstWhereOrNull( - (e) => e.name.toLowerCase() == swapCoinData.buyCoin.network.name.toLowerCase(), + (e) => e.name.toLowerCase().contains(swapCoinData.buyCoin.network.name.toLowerCase()), ); if (sellNetwork == null || buyNetwork == null) { diff --git a/packages/ion_swap_client/lib/services/dex_service.dart b/packages/ion_swap_client/lib/services/dex_service.dart index 03be750cd8..db42a54a02 100644 --- a/packages/ion_swap_client/lib/services/dex_service.dart +++ b/packages/ion_swap_client/lib/services/dex_service.dart @@ -5,12 +5,14 @@ import 'package:ion_swap_client/exceptions/ion_swap_exception.dart'; import 'package:ion_swap_client/exceptions/okx_exceptions.dart'; import 'package:ion_swap_client/models/chain_data.m.dart'; import 'package:ion_swap_client/models/okx_api_response.m.dart'; +import 'package:ion_swap_client/models/okx_swap_transaction.m.dart'; import 'package:ion_swap_client/models/swap_chain_data.m.dart'; import 'package:ion_swap_client/models/swap_coin_parameters.m.dart'; import 'package:ion_swap_client/models/swap_quote_data.m.dart'; import 'package:ion_swap_client/models/swap_quote_info.m.dart'; import 'package:ion_swap_client/repositories/chains_ids_repository.dart'; import 'package:ion_swap_client/repositories/swap_okx_repository.dart'; +import 'package:ion_swap_client/utils/crypto_amount_converter.dart'; class DexService { DexService({ @@ -22,8 +24,8 @@ class DexService { final SwapOkxRepository _swapOkxRepository; final ChainsIdsRepository _chainsIdsRepository; - // Returns true if swap was successful, false otherwise - Future tryToSwapDex({ + // Returns transaction data if swap was successful, null otherwise + Future tryToSwapDex({ required SwapCoinParameters swapCoinData, required SwapQuoteInfo swapQuoteInfo, }) async { @@ -35,11 +37,12 @@ class DexService { final sellTokenAddress = _getTokenAddressForOkx(swapCoinData.sellCoin.contractAddress); final buyTokenAddress = _getTokenAddressForOkx(swapCoinData.buyCoin.contractAddress); + final amount = toBlockchainUnits(swapCoinData.amount, int.parse(okxQuote.fromToken.decimal)); final approveTransactionResponse = await _swapOkxRepository.approveTransaction( chainIndex: okxQuote.chainIndex, tokenContractAddress: sellTokenAddress, - amount: swapCoinData.amount, + amount: amount, ); _processOkxResponse(approveTransactionResponse); @@ -49,20 +52,26 @@ class DexService { throw const IonSwapException('OKX: User sell address is required'); } - await _swapOkxRepository.swap( + final swapResponse = await _swapOkxRepository.swap( + amount: amount, chainIndex: okxQuote.chainIndex, - amount: swapCoinData.amount, toTokenAddress: buyTokenAddress, fromTokenAddress: sellTokenAddress, userWalletAddress: userSellAddress, ); + // Send swap transaction to the blockchain, triggering the swap smart contract await _swapOkxRepository.broadcastSwap( chainIndex: okxQuote.chainIndex, address: userSellAddress, ); - return true; + final swapDataList = _processOkxResponse(swapResponse); + if (swapDataList.isEmpty) { + throw const IonSwapException('OKX: No swap data returned'); + } + + return swapDataList.first.tx; } throw const IonSwapException('Failed to swap on Dex: Invalid quote source'); @@ -121,11 +130,12 @@ class DexService { final buyTokenAddress = _getTokenAddressForOkx(swapCoinData.buyCoin.contractAddress); if (okxChain != null) { + final amount = toBlockchainUnits(swapCoinData.amount, swapCoinData.sellCoin.decimal); final quotesResponse = await _swapOkxRepository.getQuotes( + amount: amount, chainIndex: okxChain.chainIndex, - amount: swapCoinData.amount, - fromTokenAddress: sellTokenAddress, toTokenAddress: buyTokenAddress, + fromTokenAddress: sellTokenAddress, ); final quotes = _processOkxResponse(quotesResponse); diff --git a/packages/ion_swap_client/lib/services/swap_service.dart b/packages/ion_swap_client/lib/services/swap_service.dart index e3c939cd1e..feca4d57f9 100644 --- a/packages/ion_swap_client/lib/services/swap_service.dart +++ b/packages/ion_swap_client/lib/services/swap_service.dart @@ -64,12 +64,13 @@ class SwapService { } if (swapCoinData.sellCoin.network.id == swapCoinData.buyCoin.network.id) { - final success = await _okxService.tryToSwapDex( + final txData = await _okxService.tryToSwapDex( swapCoinData: swapCoinData, swapQuoteInfo: swapQuoteInfo, ); - if (success) { + final isSuccessSwap = txData != null; + if (isSuccessSwap) { return; } } @@ -97,12 +98,44 @@ class SwapService { if (swapCoinData.isBridge) { final quote = await _bridgeService.getQuote(swapCoinData); + // Extract fees from Relay API response + String? networkFee; + String? protocolFee; + int? swapImpact; + + if (quote.fees != null) { + // Extract network fee from fees.gas + final gasFee = quote.fees!['gas'] as Map?; + if (gasFee != null) { + networkFee = gasFee['amountFormatted'] as String? ?? gasFee['amount']?.toString(); + } + + // Extract protocol fee from fees.relayer or fees.relayerService + final relayerFee = quote.fees!['relayer'] as Map?; + final relayerServiceFee = quote.fees!['relayerService'] as Map?; + if (relayerFee != null) { + protocolFee = + relayerFee['amountFormatted'] as String? ?? relayerFee['amount']?.toString(); + } else if (relayerServiceFee != null) { + protocolFee = relayerServiceFee['amountFormatted'] as String? ?? + relayerServiceFee['amount']?.toString(); + } + } + + // Extract price impact from details if available + if (quote.details.priceImpact != null) { + swapImpact = int.tryParse(quote.details.priceImpact!); + } + return SwapQuoteInfo( type: SwapQuoteInfoType.bridge, priceForSellTokenInBuyToken: double.parse(quote.details.rate), source: SwapQuoteInfoSource.relay, relayQuote: quote, relayDepositAmount: swapCoinData.amount, + swapImpact: swapImpact, + networkFee: networkFee, + protocolFee: protocolFee, ); } @@ -117,6 +150,10 @@ class SwapService { priceForSellTokenInBuyToken: quote.priceForSellTokenInBuyToken, source: SwapQuoteInfoSource.okx, okxQuote: quote, + swapImpact: + quote.priceImpactPercent != null ? int.tryParse(quote.priceImpactPercent!) : null, + networkFee: quote.estimateGasFee, + protocolFee: quote.tradeFee, ); } diff --git a/packages/ion_swap_client/lib/utils/crypto_amount_converter.dart b/packages/ion_swap_client/lib/utils/crypto_amount_converter.dart new file mode 100644 index 0000000000..4c40660a84 --- /dev/null +++ b/packages/ion_swap_client/lib/utils/crypto_amount_converter.dart @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: ice License 1.0 + +/// Converts a human-readable double value (e.g., '1.23') +/// into a blockchain-precise (e.g., '1230000000000000000'). +String toBlockchainUnits(String amount, int decimals) { + return (BigInt.from(double.parse(amount)) * BigInt.from(10).pow(decimals)).toString(); +}