cake_wallet/lib/zano/cw_zano.dart

145 lines
5.2 KiB
Dart
Raw Normal View History

2023-10-02 14:17:35 +00:00
part of 'zano.dart';
class CWZano extends Zano {
List<ZanoAsset> getZanoAssets(WalletBase wallet) => (wallet as ZanoWallet).zanoAssets.values.toList();
2024-03-15 12:42:27 +00:00
@override
2024-03-16 10:55:03 +00:00
Future<CryptoCurrency> addZanoAssetById(WalletBase wallet, String assetId) async => await (wallet as ZanoWallet).addZanoAssetById(assetId);
2024-03-15 12:42:27 +00:00
@override
2024-03-19 15:51:08 +00:00
Future<void> changeZanoAssetAvailability(WalletBase wallet, CryptoCurrency token) async => await (wallet as ZanoWallet).changeZanoAssetAvailability(token as ZanoAsset);
@override
2024-03-16 10:55:03 +00:00
Future<void> deleteZanoAsset(WalletBase wallet, CryptoCurrency token) async => await (wallet as ZanoWallet).deleteZanoAsset(token as ZanoAsset);
@override
2024-03-15 12:42:27 +00:00
Future<ZanoAsset?> getZanoAsset(WalletBase wallet, String assetId) async {
final zanoWallet = wallet as ZanoWallet;
2024-03-15 12:42:27 +00:00
return await zanoWallet.getZanoAsset(assetId);
}
2024-03-19 15:51:08 +00:00
// @override
// TransactionHistoryBase getTransactionHistory(Object wallet) {
// final zanoWallet = wallet as ZanoWallet;
// return zanoWallet.transactionHistory;
2024-03-19 15:51:08 +00:00
// }
2023-10-02 14:17:35 +00:00
@override
TransactionPriority getDefaultTransactionPriority() {
return MoneroTransactionPriority.automatic;
}
@override
TransactionPriority deserializeMoneroTransactionPriority({required int raw}) {
return MoneroTransactionPriority.deserialize(raw: raw);
}
@override
List<TransactionPriority> getTransactionPriorities() {
return MoneroTransactionPriority.all;
}
@override
List<String> getWordList(String language) {
assert(language.toLowerCase() == LanguageList.english.toLowerCase());
return EnglishMnemonics.words;
2023-10-02 14:17:35 +00:00
}
@override
WalletCredentials createZanoRestoreWalletFromKeysCredentials(
2024-03-16 10:55:03 +00:00
{required String name,
required String spendKey,
required String viewKey,
required String address,
required String password,
required String language,
required int height}) {
return ZanoRestoreWalletFromKeysCredentials(
name: name, spendKey: spendKey, viewKey: viewKey, address: address, password: password, language: language, height: height);
}
@override
2024-03-16 10:55:03 +00:00
WalletCredentials createZanoRestoreWalletFromSeedCredentials(
{required String name, required String password, required int height, required String mnemonic}) {
return ZanoRestoreWalletFromSeedCredentials(name: name, password: password, height: height, mnemonic: mnemonic);
}
@override
WalletCredentials createZanoNewWalletCredentials({required String name, String? password}) {
2023-11-17 17:40:23 +00:00
return ZanoNewWalletCredentials(name: name, password: password);
2023-10-02 14:17:35 +00:00
}
// @override
// Map<String, String> getKeys(Object wallet) {
// final zanoWallet = wallet as ZanoWallet;
// final keys = zanoWallet.keys;
// return <String, String>{
// 'privateSpendKey': keys.privateSpendKey,
// 'privateViewKey': keys.privateViewKey,
// 'publicSpendKey': keys.publicSpendKey,
// 'publicViewKey': keys.publicViewKey
// };
// }
2023-10-02 14:17:35 +00:00
@override
2024-03-16 10:55:03 +00:00
Object createZanoTransactionCredentials({required List<Output> outputs, required TransactionPriority priority, required CryptoCurrency currency}) {
return ZanoTransactionCredentials(
2024-03-16 10:55:03 +00:00
outputs: outputs
.map((out) => OutputInfo(
fiatAmount: out.fiatAmount,
cryptoAmount: out.cryptoAmount,
address: out.address,
note: out.note,
sendAll: out.sendAll,
extractedAddress: out.extractedAddress,
isParsedAddress: out.isParsedAddress,
formattedCryptoAmount: out.formattedCryptoAmount))
.toList(),
priority: priority as MoneroTransactionPriority,
currency: currency,
);
2023-10-02 14:17:35 +00:00
}
@override
2024-08-07 12:32:47 +00:00
double formatterIntAmountToDouble({required int amount, required CryptoCurrency currency, required bool forFee}) {
// fee always counted in zano with default decimal points
if (forFee) return ZanoFormatter.intAmountToDouble(amount);
if (currency is ZanoAsset) return ZanoFormatter.intAmountToDouble(amount, currency.decimalPoint);
return ZanoFormatter.intAmountToDouble(amount);
2023-10-02 14:17:35 +00:00
}
@override
int formatterParseAmount({required String amount, required CryptoCurrency currency}) {
if (currency is ZanoAsset) return ZanoFormatter.parseAmount(amount, currency.decimalPoint);
return ZanoFormatter.parseAmount(amount);
2023-10-02 14:17:35 +00:00
}
// @override
// int getTransactionInfoAccountId(TransactionInfo tx) {
// final zanoTransactionInfo = tx as ZanoTransactionInfo;
// return zanoTransactionInfo.accountIndex;
// }
2023-10-02 14:17:35 +00:00
@override
WalletService createZanoWalletService(Box<WalletInfo> walletInfoSource) {
return ZanoWalletService(walletInfoSource);
}
@override
2024-03-16 10:55:03 +00:00
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction) {
transaction as ZanoTransactionInfo;
if (transaction.tokenSymbol == CryptoCurrency.zano.title) {
return CryptoCurrency.zano;
}
wallet as ZanoWallet;
final asset = wallet.zanoAssets.values.firstWhereOrNull((element) => element.ticker == transaction.tokenSymbol);
return asset ?? CryptoCurrency.zano;
2023-10-02 14:17:35 +00:00
}
String getZanoAssetAddress(CryptoCurrency asset) => (asset as ZanoAsset).assetId;
@override
String getAddress(WalletBase wallet) => (wallet as ZanoWallet).walletAddresses.address;
2023-10-02 14:17:35 +00:00
}