cake_wallet/lib/zano/zano.dart

144 lines
5.7 KiB
Dart
Raw Normal View History

import 'package:cake_wallet/utils/language_list.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_zano/zano_asset.dart';
import 'package:cw_zano/zano_transaction_credentials.dart';
2023-10-02 14:17:35 +00:00
import 'package:mobx/mobx.dart';
import 'package:flutter/foundation.dart';
import 'package:cw_core/wallet_credentials.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/transaction_history.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/output_info.dart';
import 'package:cake_wallet/view_model/send/output.dart';
import 'package:cw_core/wallet_service.dart';
import 'package:hive/hive.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/monero_amount_format.dart';
import 'package:cw_core/monero_transaction_priority.dart';
import 'package:cw_zano/zano_wallet_service.dart';
import 'package:cw_zano/zano_wallet.dart';
import 'package:cw_zano/zano_transaction_info.dart';
import 'package:cw_zano/mnemonics/english.dart';
part 'cw_zano.dart';
Zano? zano = CWZano();
2023-11-17 17:40:23 +00:00
// class Account {
// Account({required this.id, required this.label});
// final int id;
// final String label;
// }
// class Subaddress {
// Subaddress({
// required this.id,
// required this.label,
// required this.address});
// final int id;
// final String label;
// final String address;
// }
2023-10-02 14:17:35 +00:00
class ZanoBalance extends Balance {
ZanoBalance({required this.fullBalance, required this.unlockedBalance})
: formattedFullBalance = zano!.formatterMoneroAmountToString(amount: fullBalance),
formattedUnlockedBalance =
zano!.formatterMoneroAmountToString(amount: unlockedBalance),
super(unlockedBalance, fullBalance);
ZanoBalance.fromString(
{required this.formattedFullBalance,
required this.formattedUnlockedBalance})
: fullBalance = zano!.formatterMoneroParseAmount(amount: formattedFullBalance),
unlockedBalance = zano!.formatterMoneroParseAmount(amount: formattedUnlockedBalance),
super(zano!.formatterMoneroParseAmount(amount: formattedUnlockedBalance),
zano!.formatterMoneroParseAmount(amount: formattedFullBalance));
final int fullBalance;
final int unlockedBalance;
final String formattedFullBalance;
final String formattedUnlockedBalance;
@override
String get formattedAvailableBalance => formattedUnlockedBalance;
@override
String get formattedAdditionalBalance => formattedFullBalance;
}
abstract class ZanoWalletDetails {
// FIX-ME: it's abstruct class
2023-11-17 17:40:23 +00:00
// @observable
// late Account account;
2023-10-02 14:17:35 +00:00
// FIX-ME: it's abstruct class
@observable
late ZanoBalance balance;
}
abstract class Zano {
2023-11-17 17:40:23 +00:00
/**ZanoAccountList getAccountList(Object wallet);*/
2023-10-02 14:17:35 +00:00
TransactionHistoryBase getTransactionHistory(Object wallet);
2023-11-17 17:40:23 +00:00
ZanoWalletDetails getZanoWalletDetails(Object wallet);
2023-10-02 14:17:35 +00:00
2023-12-16 12:19:11 +00:00
// String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
2023-10-02 14:17:35 +00:00
TransactionPriority getDefaultTransactionPriority();
TransactionPriority deserializeMoneroTransactionPriority({required int raw});
List<TransactionPriority> getTransactionPriorities();
List<String> getWordList(String language);
2023-10-02 14:17:35 +00:00
WalletCredentials createZanoRestoreWalletFromKeysCredentials({
required String name,
required String spendKey,
required String viewKey,
required String address,
required String password,
required String language,
required int height});
WalletCredentials createZanoRestoreWalletFromSeedCredentials({required String name, required String password, required int height, required String mnemonic});
2023-11-17 17:40:23 +00:00
WalletCredentials createZanoNewWalletCredentials({required String name, String password});
2023-10-02 14:17:35 +00:00
Map<String, String> getKeys(Object wallet);
2024-03-16 10:55:03 +00:00
Object createZanoTransactionCredentials({required List<Output> outputs, required TransactionPriority priority, required CryptoCurrency currency});
2023-10-02 14:17:35 +00:00
String formatterMoneroAmountToString({required int amount});
double formatterMoneroAmountToDouble({required int amount});
int formatterMoneroParseAmount({required String amount});
2023-11-17 17:40:23 +00:00
// Account getCurrentAccount(Object wallet);
// void setCurrentAccount(Object wallet, int id, String label);
2023-10-02 14:17:35 +00:00
void onStartup();
int getTransactionInfoAccountId(TransactionInfo tx);
WalletService createZanoWalletService(Box<WalletInfo> walletInfoSource);
2024-03-16 10:55:03 +00:00
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo tx);
List<ZanoAsset> getZanoAssets(WalletBase wallet);
String getZanoAssetAddress(CryptoCurrency asset);
Future<void> addZanoAsset(WalletBase wallet, CryptoCurrency token);
2024-03-15 12:42:27 +00:00
Future<CryptoCurrency> addZanoAssetById(WalletBase wallet, String assetId);
Future<void> deleteZanoAsset(WalletBase wallet, CryptoCurrency token);
Future<CryptoCurrency?> getZanoAsset(WalletBase wallet, String contractAddress);
2023-10-02 14:17:35 +00:00
}
2023-11-17 17:40:23 +00:00
// abstract class MoneroSubaddressList {
// ObservableList<Subaddress> get subaddresses;
// void update(Object wallet, {required int accountIndex});
// void refresh(Object wallet, {required int accountIndex});
// List<Subaddress> getAll(Object wallet);
// Future<void> addSubaddress(Object wallet, {required int accountIndex, required String label});
// Future<void> setLabelSubaddress(Object wallet,
// {required int accountIndex, required int addressIndex, required String label});
// }
// abstract class ZanoAccountList {
// ObservableList<Account> get accounts;
// void update(Object wallet);
// void refresh(Object wallet);
// List<Account> getAll(Object wallet);
// Future<void> addAccount(Object wallet, {required String label});
// Future<void> setLabelAccount(Object wallet, {required int accountIndex, required String label});
// }