cake_wallet/lib/exchange/provider/exchange_provider.dart
Rafael fd9018bcc4
Cw 598 fixes for electrum based wallets (#1344)
* fix: address book addresses, bch builder, exchange all fee estimation, bch coin control

* feat: new error framework for Electrum messages

* build: cw_bitcoin.dart

* feat: error improvements, localization, fix exchange amount mismatch

* chore: misc comment & print [skip ci]

* feat: refactor & simplify sendAll vs regular tx estimation and creation

- Since there were so many conditions inside a single function to alter its behavior if sendAll or not, it is easier and more readable to have separate sendAll and estimateTx functions that behave separately

* fix: wrong LTC dust

* feat: fee rate confirmation

* fix: wrong createTrade value when isSendAll is enabled

* fix bitcoin cash address parsing [skip ci]

* fix: form no amount validator, address book with multiple entries, exchange all below min error

* fix: improve string, fix sending with dust inputs at the top

* fix: two change outputs when re-estimating

* fix: sendAll with a little dust adds fees

* chore: sanity check [skip ci]

* fix: if the fee is higher than estimated

* Minor enhancement [skip ci]

---------

Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-03-29 20:51:34 +02:00

44 lines
1.2 KiB
Dart

import 'package:cake_wallet/exchange/exchange_pair.dart';
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
import 'package:cake_wallet/exchange/limits.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/exchange/trade_request.dart';
import 'package:cw_core/crypto_currency.dart';
abstract class ExchangeProvider {
ExchangeProvider({required this.pairList});
String get title;
List<ExchangePair> pairList;
ExchangeProviderDescription get description;
bool get isAvailable;
bool get isEnabled;
bool get supportsFixedRate;
bool get supportsOnionAddress => false;
@override
String toString() => title;
Future<Limits> fetchLimits(
{required CryptoCurrency from, required CryptoCurrency to, required bool isFixedRateMode});
Future<Trade> createTrade(
{required TradeRequest request, required bool isFixedRateMode, required bool isSendAll});
Future<Trade> findTradeById({required String id});
Future<double> fetchRate(
{required CryptoCurrency from,
required CryptoCurrency to,
required double amount,
required bool isFixedRateMode,
required bool isReceiveAmount});
Future<bool> checkIsAvailable();
}