cake_wallet/lib/core/wallet_base.dart

70 lines
2 KiB
Dart
Raw Normal View History

2021-01-11 17:15:27 +00:00
import 'package:cake_wallet/entities/balance.dart';
import 'package:cake_wallet/entities/transaction_info.dart';
2021-01-27 13:51:51 +00:00
import 'package:cake_wallet/entities/transaction_priority.dart';
2020-06-01 18:13:56 +00:00
import 'package:flutter/foundation.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/wallet_info.dart';
2020-08-25 16:32:40 +00:00
import 'package:cake_wallet/core/pending_transaction.dart';
2020-06-20 07:10:00 +00:00
import 'package:cake_wallet/core/transaction_history.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/currency_for_wallet_type.dart';
2021-01-27 13:51:51 +00:00
import 'package:cake_wallet/entities/monero_transaction_priority.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/crypto_currency.dart';
import 'package:cake_wallet/entities/sync_status.dart';
import 'package:cake_wallet/entities/node.dart';
import 'package:cake_wallet/entities/wallet_type.dart';
2020-09-15 20:35:49 +00:00
abstract class WalletBase<
BalanceType extends Balance,
HistoryType extends TransactionHistoryBase,
TransactionType extends TransactionInfo> {
2020-09-15 20:35:49 +00:00
WalletBase(this.walletInfo);
static String idFor(String name, WalletType type) =>
walletTypeToString(type).toLowerCase() + '_' + name;
WalletInfo walletInfo;
WalletType get type => walletInfo.type;
2020-06-01 18:13:56 +00:00
2020-09-15 20:35:49 +00:00
CryptoCurrency get currency => currencyForWalletType(type);
2020-07-06 20:09:03 +00:00
2020-09-15 20:35:49 +00:00
String get id => walletInfo.id;
2020-06-01 18:13:56 +00:00
2020-09-15 20:35:49 +00:00
String get name => walletInfo.name;
2020-06-01 18:13:56 +00:00
2020-09-15 20:35:49 +00:00
String get address;
2020-06-01 18:13:56 +00:00
2020-09-15 20:35:49 +00:00
set address(String address);
2021-01-27 13:51:51 +00:00
BalanceType get balance;
2020-09-15 20:35:49 +00:00
SyncStatus get syncStatus;
set syncStatus(SyncStatus status);
2020-07-06 20:09:03 +00:00
String get seed;
Object get keys;
HistoryType transactionHistory;
2020-06-20 07:10:00 +00:00
2020-06-01 18:13:56 +00:00
Future<void> connectToNode({@required Node node});
2020-06-20 07:10:00 +00:00
2020-06-01 18:13:56 +00:00
Future<void> startSync();
2020-06-20 07:10:00 +00:00
2020-08-25 16:32:40 +00:00
Future<PendingTransaction> createTransaction(Object credentials);
2021-01-27 13:51:51 +00:00
int calculateEstimatedFee(TransactionPriority priority, int amount);
2020-06-20 07:10:00 +00:00
// void fetchTransactionsAsync(
// void Function(TransactionType transaction) onTransactionLoaded,
// {void Function() onFinished});
Future<Map<String, TransactionType>> fetchTransactions();
2020-06-01 18:13:56 +00:00
Future<void> save();
2020-09-21 11:50:26 +00:00
Future<void> rescan({int height});
void close();
2020-06-20 07:10:00 +00:00
}