From 3c2953a71864eb5a43da6a96db28379ad17c522c Mon Sep 17 00:00:00 2001 From: leo1234 Date: Wed, 6 Mar 2024 14:48:59 +0800 Subject: [PATCH] updated zano ApiCalls, removed dummy --- cw_core/lib/crypto_currency.dart | 1 - cw_core/lib/currency_for_wallet_type.dart | 2 - cw_core/lib/node.dart | 4 - cw_core/lib/wallet_type.dart | 14 - cw_dummy/.gitignore | 30 -- cw_dummy/.metadata | 10 - cw_dummy/CHANGELOG.md | 3 - cw_dummy/LICENSE | 1 - cw_dummy/README.md | 39 -- cw_dummy/analysis_options.yaml | 4 - cw_dummy/lib/cw_dummy.dart | 7 - cw_dummy/lib/dummy_balance.dart | 14 - ...ummy_transaction_creation_credentials.dart | 10 - cw_dummy/lib/dummy_transaction_history.dart | 28 -- cw_dummy/lib/dummy_transaction_info.dart | 27 -- cw_dummy/lib/dummy_transaction_priority.dart | 20 - cw_dummy/lib/dummy_wallet.dart | 72 ---- cw_dummy/lib/dummy_wallet_addresses.dart | 23 -- .../dummy_wallet_creation_credentials.dart | 18 - cw_dummy/lib/dummy_wallet_service.dart | 43 --- .../.plugin_symlinks/path_provider_linux | 1 - .../flutter/generated_plugin_registrant.cc | 11 - .../flutter/generated_plugin_registrant.h | 15 - .../linux/flutter/generated_plugins.cmake | 23 -- .../Flutter/GeneratedPluginRegistrant.swift | 12 - .../ephemeral/Flutter-Generated.xcconfig | 11 - .../ephemeral/flutter_export_environment.sh | 12 - cw_dummy/pubspec.yaml | 70 ---- cw_dummy/test/cw_dummy_test.dart | 12 - .../flutter/generated_plugin_registrant.cc | 11 - .../flutter/generated_plugin_registrant.h | 15 - .../windows/flutter/generated_plugins.cmake | 23 -- cw_shared_external/pubspec.lock | 112 +++--- cw_zano/lib/api/calls.dart | 351 ------------------ .../model/get_recent_txs_and_info_params.dart | 8 +- cw_zano/lib/api/wallet.dart | 96 ++--- cw_zano/lib/pending_zano_transaction.dart | 40 +- cw_zano/lib/zano_utils.dart | 5 +- cw_zano/lib/zano_wallet.dart | 140 ++++--- cw_zano/lib/zano_wallet_service.dart | 15 +- lib/core/seed_validator.dart | 3 - lib/di.dart | 3 - lib/dummy/cw_dummy.dart | 83 ----- lib/dummy/dummy.dart | 42 --- lib/entities/default_settings_migration.dart | 17 - lib/entities/preferences_key.dart | 2 - lib/entities/priority_for_wallet_type.dart | 3 - .../desktop_wallet_selection_dropdown.dart | 3 - .../dashboard/widgets/menu_widget.dart | 6 +- .../screens/wallet_list/wallet_list_page.dart | 1 - lib/store/settings_store.dart | 36 -- .../dashboard/transaction_list_item.dart | 8 - .../exchange/exchange_view_model.dart | 11 - .../node_list/node_list_view_model.dart | 3 - lib/view_model/send/output.dart | 9 - lib/view_model/send/send_view_model.dart | 7 - .../transaction_details_view_model.dart | 19 - ...let_address_edit_or_create_view_model.dart | 6 - .../wallet_address_list_view_model.dart | 27 -- lib/view_model/wallet_keys_view_model.dart | 9 - lib/view_model/wallet_new_vm.dart | 3 - lib/view_model/wallet_restore_view_model.dart | 8 - 62 files changed, 244 insertions(+), 1418 deletions(-) delete mode 100644 cw_dummy/.gitignore delete mode 100644 cw_dummy/.metadata delete mode 100644 cw_dummy/CHANGELOG.md delete mode 100644 cw_dummy/LICENSE delete mode 100644 cw_dummy/README.md delete mode 100644 cw_dummy/analysis_options.yaml delete mode 100644 cw_dummy/lib/cw_dummy.dart delete mode 100644 cw_dummy/lib/dummy_balance.dart delete mode 100644 cw_dummy/lib/dummy_transaction_creation_credentials.dart delete mode 100644 cw_dummy/lib/dummy_transaction_history.dart delete mode 100644 cw_dummy/lib/dummy_transaction_info.dart delete mode 100644 cw_dummy/lib/dummy_transaction_priority.dart delete mode 100644 cw_dummy/lib/dummy_wallet.dart delete mode 100644 cw_dummy/lib/dummy_wallet_addresses.dart delete mode 100644 cw_dummy/lib/dummy_wallet_creation_credentials.dart delete mode 100644 cw_dummy/lib/dummy_wallet_service.dart delete mode 120000 cw_dummy/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux delete mode 100644 cw_dummy/linux/flutter/generated_plugin_registrant.cc delete mode 100644 cw_dummy/linux/flutter/generated_plugin_registrant.h delete mode 100644 cw_dummy/linux/flutter/generated_plugins.cmake delete mode 100644 cw_dummy/macos/Flutter/GeneratedPluginRegistrant.swift delete mode 100644 cw_dummy/macos/Flutter/ephemeral/Flutter-Generated.xcconfig delete mode 100755 cw_dummy/macos/Flutter/ephemeral/flutter_export_environment.sh delete mode 100644 cw_dummy/pubspec.yaml delete mode 100644 cw_dummy/test/cw_dummy_test.dart delete mode 100644 cw_dummy/windows/flutter/generated_plugin_registrant.cc delete mode 100644 cw_dummy/windows/flutter/generated_plugin_registrant.h delete mode 100644 cw_dummy/windows/flutter/generated_plugins.cmake delete mode 100644 cw_zano/lib/api/calls.dart delete mode 100644 lib/dummy/cw_dummy.dart delete mode 100644 lib/dummy/dummy.dart diff --git a/cw_core/lib/crypto_currency.dart b/cw_core/lib/crypto_currency.dart index ae274c219..25ce1a564 100644 --- a/cw_core/lib/crypto_currency.dart +++ b/cw_core/lib/crypto_currency.dart @@ -200,7 +200,6 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen static const dydx = CryptoCurrency(title: 'DYDX', tag: 'ETH', fullName: 'dYdX', raw: 84, name: 'dydx', iconPath: 'assets/images/dydx_icon.png'); static const steth = CryptoCurrency(title: 'STETH', tag: 'ETH', fullName: 'Lido Staked Ethereum', raw: 85, name: 'steth', iconPath: 'assets/images/steth_icon.png'); static const zano = CryptoCurrency(title: 'ZANO', tag: 'ZANO', fullName: 'Zano', raw: 86, name: 'zano', iconPath: 'assets/images/zano_icon.png'); - static const dummy = CryptoCurrency(title: 'DUMMY', tag: 'DUMMY', fullName: 'Dummy', raw: 87, name: 'dummy', iconPath: 'assets/images/zano_icon.png'); static final Map _rawCurrencyMap = diff --git a/cw_core/lib/currency_for_wallet_type.dart b/cw_core/lib/currency_for_wallet_type.dart index 2e5e9b5c9..b2f6d356f 100644 --- a/cw_core/lib/currency_for_wallet_type.dart +++ b/cw_core/lib/currency_for_wallet_type.dart @@ -15,8 +15,6 @@ CryptoCurrency currencyForWalletType(WalletType type) { return CryptoCurrency.eth; case WalletType.zano: return CryptoCurrency.zano; - case WalletType.dummy: - return CryptoCurrency.dummy; default: throw Exception( 'Unexpected wallet type: ${type.toString()} for CryptoCurrency currencyForWalletType'); diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index 06a86c74d..66655899d 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -80,8 +80,6 @@ class Node extends HiveObject with Keyable { return Uri.http(uriRaw, ''); case WalletType.ethereum: return Uri.https(uriRaw, ''); - case WalletType.dummy: - return Uri.https(uriRaw, ''); default: throw Exception('Unexpected type ${type.toString()} for Node uri'); } @@ -135,8 +133,6 @@ class Node extends HiveObject with Keyable { return requestZanoNode(); case WalletType.ethereum: return requestElectrumServer(); - case WalletType.dummy: - throw UnimplementedError(); default: return false; } diff --git a/cw_core/lib/wallet_type.dart b/cw_core/lib/wallet_type.dart index 0b26bde73..022b181b9 100644 --- a/cw_core/lib/wallet_type.dart +++ b/cw_core/lib/wallet_type.dart @@ -11,7 +11,6 @@ const walletTypes = [ WalletType.haven, WalletType.ethereum, WalletType.zano, - WalletType.dummy, ]; @HiveType(typeId: WALLET_TYPE_TYPE_ID) @@ -36,9 +35,6 @@ enum WalletType { @HiveField(6) zano, - - @HiveField(7) - dummy, } int serializeToInt(WalletType type) { @@ -55,8 +51,6 @@ int serializeToInt(WalletType type) { return 4; case WalletType.zano: return 5; - case WalletType.dummy: - return 6; default: return -1; } @@ -76,8 +70,6 @@ WalletType deserializeFromInt(int raw) { return WalletType.ethereum; case 5: return WalletType.zano; - case 6: - return WalletType.dummy; default: throw Exception( 'Unexpected token: $raw for WalletType deserializeFromInt'); @@ -98,8 +90,6 @@ String walletTypeToString(WalletType type) { return 'Ethereum'; case WalletType.zano: return 'Zano'; - case WalletType.dummy: - return 'Dummy'; default: return ''; } @@ -119,8 +109,6 @@ String walletTypeToDisplayName(WalletType type) { return 'Ethereum (ETH)'; case WalletType.zano: return 'Zano (ZANO)'; - case WalletType.dummy: - return 'Dummy (DUMMY)'; default: return ''; } @@ -140,8 +128,6 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) { return CryptoCurrency.zano; case WalletType.ethereum: return CryptoCurrency.eth; - case WalletType.dummy: - return CryptoCurrency.dummy; default: throw Exception( 'Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency'); diff --git a/cw_dummy/.gitignore b/cw_dummy/.gitignore deleted file mode 100644 index 96486fd93..000000000 --- a/cw_dummy/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -.packages -build/ diff --git a/cw_dummy/.metadata b/cw_dummy/.metadata deleted file mode 100644 index fa347fc6a..000000000 --- a/cw_dummy/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 - channel: stable - -project_type: package diff --git a/cw_dummy/CHANGELOG.md b/cw_dummy/CHANGELOG.md deleted file mode 100644 index 41cc7d819..000000000 --- a/cw_dummy/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/cw_dummy/LICENSE b/cw_dummy/LICENSE deleted file mode 100644 index ba75c69f7..000000000 --- a/cw_dummy/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/cw_dummy/README.md b/cw_dummy/README.md deleted file mode 100644 index 02fe8ecab..000000000 --- a/cw_dummy/README.md +++ /dev/null @@ -1,39 +0,0 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. - -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. diff --git a/cw_dummy/analysis_options.yaml b/cw_dummy/analysis_options.yaml deleted file mode 100644 index a5744c1cf..000000000 --- a/cw_dummy/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/cw_dummy/lib/cw_dummy.dart b/cw_dummy/lib/cw_dummy.dart deleted file mode 100644 index 126c12a36..000000000 --- a/cw_dummy/lib/cw_dummy.dart +++ /dev/null @@ -1,7 +0,0 @@ -library cw_dummy; - -/// A Calculator. -class Calculator { - /// Returns [value] plus 1. - int addOne(int value) => value + 1; -} diff --git a/cw_dummy/lib/dummy_balance.dart b/cw_dummy/lib/dummy_balance.dart deleted file mode 100644 index b6352850b..000000000 --- a/cw_dummy/lib/dummy_balance.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cw_core/balance.dart'; - -class DummyBalance extends Balance { - DummyBalance(super.available, super.additional); - - @override - // TODO: implement formattedAdditionalBalance - String get formattedAdditionalBalance => throw UnimplementedError(); - - @override - // TODO: implement formattedAvailableBalance - String get formattedAvailableBalance => throw UnimplementedError(); - -} \ No newline at end of file diff --git a/cw_dummy/lib/dummy_transaction_creation_credentials.dart b/cw_dummy/lib/dummy_transaction_creation_credentials.dart deleted file mode 100644 index 75de84938..000000000 --- a/cw_dummy/lib/dummy_transaction_creation_credentials.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:cw_core/output_info.dart'; - -import 'dummy_transaction_priority.dart'; - -class DummyTransactionCreationCredentials { - final List outputs; - final DummyTransactionPriority? priority; - - DummyTransactionCreationCredentials({required this.outputs, this.priority}); -} diff --git a/cw_dummy/lib/dummy_transaction_history.dart b/cw_dummy/lib/dummy_transaction_history.dart deleted file mode 100644 index ac8655091..000000000 --- a/cw_dummy/lib/dummy_transaction_history.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:mobx/mobx.dart'; -import 'package:cw_core/transaction_history.dart'; - -import 'dummy_transaction_info.dart'; - -part 'dummy_transaction_history.g.dart'; - -class DummyTransactionHistory = DummyTransactionHistoryBase - with _$DummyTransactionHistory; - -abstract class DummyTransactionHistoryBase - extends TransactionHistoryBase with Store { - DummyTransactionHistoryBase() { - transactions = ObservableMap(); - } - - @override - Future save() async { - throw UnimplementedError; - } - - @override - void addOne(DummyTransactionInfo transaction) => transactions[transaction.id] = transaction; - - @override - void addMany(Map transactions) => - this.transactions.addAll(transactions); -} diff --git a/cw_dummy/lib/dummy_transaction_info.dart b/cw_dummy/lib/dummy_transaction_info.dart deleted file mode 100644 index 71461d26e..000000000 --- a/cw_dummy/lib/dummy_transaction_info.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:cw_core/transaction_info.dart'; - -class DummyTransactionInfo extends TransactionInfo { - @override - String amountFormatted() { - // TODO: implement amountFormatted - throw UnimplementedError(); - } - - @override - void changeFiatAmount(String amount) { - // TODO: implement changeFiatAmount - } - - @override - String? feeFormatted() { - // TODO: implement feeFormatted - throw UnimplementedError(); - } - - @override - String fiatAmount() { - // TODO: implement fiatAmount - throw UnimplementedError(); - } - -} \ No newline at end of file diff --git a/cw_dummy/lib/dummy_transaction_priority.dart b/cw_dummy/lib/dummy_transaction_priority.dart deleted file mode 100644 index 46f1d5a70..000000000 --- a/cw_dummy/lib/dummy_transaction_priority.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:cw_core/transaction_priority.dart'; - -class DummyTransactionPriority extends TransactionPriority { - const DummyTransactionPriority({required super.title, required super.raw}); - - static const List all = [slow, medium, fast]; - - static const slow = DummyTransactionPriority(title: 'Slow', raw: 0); - static const medium = DummyTransactionPriority(title: 'Medium', raw: 1); - static const fast = DummyTransactionPriority(title: 'Fast', raw: 2); - - static DummyTransactionPriority deserialize({required int raw}) { - switch (raw) { - case 0: return slow; - case 1: return medium; - case 2: return fast; - default: throw Exception('Unexpected token: $raw for DummyTransactionPriority deserialize'); - } - } -} \ No newline at end of file diff --git a/cw_dummy/lib/dummy_wallet.dart b/cw_dummy/lib/dummy_wallet.dart deleted file mode 100644 index c937fa61f..000000000 --- a/cw_dummy/lib/dummy_wallet.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'package:cw_core/crypto_currency.dart'; -import 'package:cw_core/node.dart'; -import 'package:cw_core/pending_transaction.dart'; -import 'package:cw_core/sync_status.dart'; -import 'package:cw_core/transaction_priority.dart'; -import 'package:cw_core/wallet_info.dart'; -import 'package:mobx/mobx.dart'; -import 'package:cw_core/wallet_base.dart'; - -import 'dummy_balance.dart'; -import 'dummy_transaction_history.dart'; -import 'dummy_transaction_info.dart'; -import 'dummy_wallet_addresses.dart'; - -part 'dummy_wallet.g.dart'; - -class DummyWallet = DummyWalletBase with _$DummyWallet; - -abstract class DummyWalletBase extends WalletBase with Store { - DummyWalletBase({required WalletInfo walletInfo}) : super(walletInfo) {} - - @override - int calculateEstimatedFee(TransactionPriority priority, int? amount) => throw UnimplementedError(); - - @override - Future changePassword(String password) async => throw UnimplementedError(); - - @override - Future close() async => throw UnimplementedError(); - - @override - Future connectToNode({required Node node}) async => throw UnimplementedError(); - - @override - Future createTransaction(Object credentials) async => throw UnimplementedError(); - - @override - Future> fetchTransactions() async => throw UnimplementedError(); - - @override - Future renameWalletFiles(String newWalletName) async => throw UnimplementedError(); - - @override - Future rescan({required int height}) async => throw UnimplementedError(); - - @override - Future save() async => throw UnimplementedError(); - - @override - Future startSync() async => throw UnimplementedError(); - - @override - Future? updateBalance() => null; - - @override - @observable - late ObservableMap balance; - - @override - Object get keys => throw UnimplementedError("keys"); - - @override - String get seed => "seed"; - - @override - @observable - late SyncStatus syncStatus; - - @override - late DummyWalletAddresses walletAddresses; -} diff --git a/cw_dummy/lib/dummy_wallet_addresses.dart b/cw_dummy/lib/dummy_wallet_addresses.dart deleted file mode 100644 index 9e6fbfb4c..000000000 --- a/cw_dummy/lib/dummy_wallet_addresses.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:mobx/mobx.dart'; -import 'package:cw_core/wallet_addresses.dart'; - -part 'dummy_wallet_addresses.g.dart'; - -class DummyWalletAddresses = DummyWalletAddressesBase with _$DummyWalletAddresses; - -abstract class DummyWalletAddressesBase extends WalletAddresses with Store { - DummyWalletAddressesBase(super.walletInfo); - - @override - @observable - late String address; - - @override - Future init() async => throw UnimplementedError(); - - @override - Future updateAddressesInBox() async => throw UnimplementedError(); - - // TODO: from electrum wallet addresses implementation - Future generateNewAddress() async => throw UnimplementedError(); -} \ No newline at end of file diff --git a/cw_dummy/lib/dummy_wallet_creation_credentials.dart b/cw_dummy/lib/dummy_wallet_creation_credentials.dart deleted file mode 100644 index 7fc48d037..000000000 --- a/cw_dummy/lib/dummy_wallet_creation_credentials.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cw_core/wallet_credentials.dart'; -import 'package:cw_core/wallet_info.dart'; - -class DummyNewWalletCredentials extends WalletCredentials { - DummyNewWalletCredentials({required String name, WalletInfo? walletInfo}) - : super(name: name, walletInfo: walletInfo); -} - -class DummyRestoreWalletFromSeedCredentials extends WalletCredentials { - DummyRestoreWalletFromSeedCredentials({required String name, WalletInfo? walletInfo}) - : super(name: name, walletInfo: walletInfo); -} - -class DummyRestoreWalletFromKeyCredentials extends WalletCredentials { - DummyRestoreWalletFromKeyCredentials({required String name, WalletInfo? walletInfo}) - : super(name: name, walletInfo: walletInfo); -} - diff --git a/cw_dummy/lib/dummy_wallet_service.dart b/cw_dummy/lib/dummy_wallet_service.dart deleted file mode 100644 index 85a71dbf5..000000000 --- a/cw_dummy/lib/dummy_wallet_service.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:cw_core/balance.dart'; -import 'package:cw_core/pathForWallet.dart'; -import 'package:cw_core/transaction_history.dart'; -import 'package:cw_core/transaction_info.dart'; -import 'package:cw_core/wallet_base.dart'; -import 'package:cw_core/wallet_credentials.dart'; -import 'package:cw_core/wallet_info.dart'; -import 'package:cw_core/wallet_service.dart'; -import 'package:cw_core/wallet_type.dart'; - -import 'package:hive/hive.dart'; -import 'dummy_wallet_creation_credentials.dart'; - - -class DummyWalletService extends WalletService { - DummyWalletService(this.walletInfoSource); - - final Box walletInfoSource; - - @override - Future, TransactionInfo>> create(WalletCredentials credentials) => throw UnimplementedError(); - - @override - WalletType getType() => WalletType.dummy; - - @override - Future isWalletExit(String name) => throw UnimplementedError(); - - @override - Future, TransactionInfo>> openWallet(String name, String password) => throw UnimplementedError(); - - @override - Future remove(String wallet) => throw UnimplementedError(); - - @override - Future rename(String currentName, String password, String newName) => throw UnimplementedError(); - - @override - Future, TransactionInfo>> restoreFromKeys(DummyRestoreWalletFromKeyCredentials credentials) => throw UnimplementedError(); - - @override - Future, TransactionInfo>> restoreFromSeed(DummyRestoreWalletFromSeedCredentials credentials) => throw UnimplementedError(); -} \ No newline at end of file diff --git a/cw_dummy/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux b/cw_dummy/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux deleted file mode 120000 index 5f46c0555..000000000 --- a/cw_dummy/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux +++ /dev/null @@ -1 +0,0 @@ -/home/leo/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ \ No newline at end of file diff --git a/cw_dummy/linux/flutter/generated_plugin_registrant.cc b/cw_dummy/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index e71a16d23..000000000 --- a/cw_dummy/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void fl_register_plugins(FlPluginRegistry* registry) { -} diff --git a/cw_dummy/linux/flutter/generated_plugin_registrant.h b/cw_dummy/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc..000000000 --- a/cw_dummy/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/cw_dummy/linux/flutter/generated_plugins.cmake b/cw_dummy/linux/flutter/generated_plugins.cmake deleted file mode 100644 index 2e1de87a7..000000000 --- a/cw_dummy/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/cw_dummy/macos/Flutter/GeneratedPluginRegistrant.swift b/cw_dummy/macos/Flutter/GeneratedPluginRegistrant.swift deleted file mode 100644 index e777c67df..000000000 --- a/cw_dummy/macos/Flutter/GeneratedPluginRegistrant.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// Generated file. Do not edit. -// - -import FlutterMacOS -import Foundation - -import path_provider_foundation - -func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) -} diff --git a/cw_dummy/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/cw_dummy/macos/Flutter/ephemeral/Flutter-Generated.xcconfig deleted file mode 100644 index 78a963b83..000000000 --- a/cw_dummy/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/home/leo/flutter -FLUTTER_APPLICATION_PATH=/opt/android/cake_wallet/cw_dummy -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=0.0.1 -FLUTTER_BUILD_NUMBER=0.0.1 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/cw_dummy/macos/Flutter/ephemeral/flutter_export_environment.sh b/cw_dummy/macos/Flutter/ephemeral/flutter_export_environment.sh deleted file mode 100755 index fba94197d..000000000 --- a/cw_dummy/macos/Flutter/ephemeral/flutter_export_environment.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/home/leo/flutter" -export "FLUTTER_APPLICATION_PATH=/opt/android/cake_wallet/cw_dummy" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=0.0.1" -export "FLUTTER_BUILD_NUMBER=0.0.1" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/cw_dummy/pubspec.yaml b/cw_dummy/pubspec.yaml deleted file mode 100644 index ae3d9135e..000000000 --- a/cw_dummy/pubspec.yaml +++ /dev/null @@ -1,70 +0,0 @@ -name: cw_dummy -description: A new Flutter package project. -version: 0.0.1 -homepage: -publish_to: none - -environment: - sdk: ">=2.17.5 <3.0.0" - flutter: ">=1.20.0" - -dependencies: - flutter: - sdk: flutter - ffi: ^2.0.1 - http: ^1.1.0 - path_provider: ^2.0.11 - mobx: ^2.0.7+4 - flutter_mobx: ^2.0.6+1 - intl: ^0.18.0 - cw_core: - path: ../cw_core - - cw_zano: - path: ../cw_zano - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - build_runner: ^2.1.11 - mobx_codegen: ^2.0.7 - build_resolvers: ^2.0.9 - hive_generator: ^1.1.3 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/cw_dummy/test/cw_dummy_test.dart b/cw_dummy/test/cw_dummy_test.dart deleted file mode 100644 index 3d74bbf1c..000000000 --- a/cw_dummy/test/cw_dummy_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -import 'package:cw_dummy/cw_dummy.dart'; - -void main() { - test('adds one to input values', () { - final calculator = Calculator(); - expect(calculator.addOne(2), 3); - expect(calculator.addOne(-7), -6); - expect(calculator.addOne(0), 1); - }); -} diff --git a/cw_dummy/windows/flutter/generated_plugin_registrant.cc b/cw_dummy/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 8b6d4680a..000000000 --- a/cw_dummy/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void RegisterPlugins(flutter::PluginRegistry* registry) { -} diff --git a/cw_dummy/windows/flutter/generated_plugin_registrant.h b/cw_dummy/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a..000000000 --- a/cw_dummy/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/cw_dummy/windows/flutter/generated_plugins.cmake b/cw_dummy/windows/flutter/generated_plugins.cmake deleted file mode 100644 index b93c4c30c..000000000 --- a/cw_dummy/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/cw_shared_external/pubspec.lock b/cw_shared_external/pubspec.lock index ef01c9f9a..440f635ed 100644 --- a/cw_shared_external/pubspec.lock +++ b/cw_shared_external/pubspec.lock @@ -5,51 +5,50 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.1" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -60,27 +59,46 @@ packages: description: flutter source: sdk version: "0.0.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.15" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" + source: hosted + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -90,58 +108,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=1.20.0" diff --git a/cw_zano/lib/api/calls.dart b/cw_zano/lib/api/calls.dart deleted file mode 100644 index 8dc6939a6..000000000 --- a/cw_zano/lib/api/calls.dart +++ /dev/null @@ -1,351 +0,0 @@ -import 'dart:ffi'; -import 'dart:convert'; - -import 'package:cw_zano/api/convert_utf8_to_string.dart'; -import 'package:cw_zano/api/model/get_recent_txs_and_info_params.dart'; -import 'package:cw_zano/api/model/transfer_params.dart'; -import 'package:cw_zano/api/structs/utf8_box.dart'; -import 'package:cw_zano/api/zano_api.dart'; -import 'package:ffi/ffi.dart'; -import 'package:flutter/foundation.dart'; - -// bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error) -final _setupNodeNative = - zanoApi.lookup>('setup_node').asFunction<_SetupNode>(); -typedef _setup_node = Int8 Function( - Pointer, Pointer?, Pointer?, Int8, Int8, Pointer); -typedef _SetupNode = int Function( - Pointer, Pointer?, Pointer?, int, int, Pointer); - -// char * create_wallet(char *path, char *password, char *language, int32_t networkType, char *error) -final _createWalletNative = - zanoApi.lookup>('create_wallet').asFunction<_CreateWallet>(); -typedef _create_wallet = Pointer Function( - Pointer, Pointer, Pointer, Int32, Pointer); -typedef _CreateWallet = Pointer Function( - Pointer, Pointer, Pointer, int, Pointer); - -// char* async_call(char* method_name, uint64_t instance_id, char* params) -final _asyncCallNative = - zanoApi.lookup>('async_call').asFunction<_AsyncCall>(); -typedef _async_call = Pointer Function(Pointer, Int64, Pointer); -typedef _AsyncCall = Pointer Function( - Pointer methodName, int hWallet, Pointer params); - -// char* get_wallet_status(uint64_t hwallet) -final _getWalletStatusNative = zanoApi - .lookup>('get_wallet_status') - .asFunction<_GetWalletStatus>(); -typedef _get_wallet_status = Pointer Function(Int64); -typedef _GetWalletStatus = Pointer Function(int hWallet); - -// char *get_wallet_info(uint64_t hwallet) -final _getWalletInfoNative = zanoApi - .lookup>('get_wallet_info') - .asFunction<_GetWalletInfo>(); -typedef _get_wallet_info = Pointer Function(Int64); -typedef _GetWalletInfo = Pointer Function(int hWallet); - -// char* get_connectivity_status() -final _getConnectivityStatusNative = zanoApi - .lookup>('get_connectivity_status') - .asFunction<_GetConnectivityStatus>(); -typedef _get_connectivity_status = Pointer Function(); -typedef _GetConnectivityStatus = Pointer Function(); - -// char* get_version() -final _getVersionNative = - zanoApi.lookup>('get_version').asFunction<_GetVersion>(); -typedef _get_version = Pointer Function(); -typedef _GetVersion = Pointer Function(); - -// char * load_wallet(char *path, char *password, int32_t nettype) -final _loadWalletNative = - zanoApi.lookup>('load_wallet').asFunction<_LoadWallet>(); -typedef _load_wallet = Pointer Function(Pointer, Pointer, Int8); -typedef _LoadWallet = Pointer Function(Pointer, Pointer, int); - -// char* try_pull_result(uint64_t job_id) -final _tryPullResultNative = zanoApi - .lookup>('try_pull_result') - .asFunction<_TryPullResult>(); -typedef _try_pull_result = Pointer Function(Int64); -typedef _TryPullResult = Pointer Function(int hWallet); - -// void close_wallet(uint64_t hwallet) -final _closeWalletNative = - zanoApi.lookup>('close_wallet').asFunction<_closeWalletStatus>(); -typedef _close_wallet = Void Function(Int64); -typedef _closeWalletStatus = void Function(int hWallet); - -// uint64_t get_current_tx_fee(uint64_t priority) -final _getCurrentTxFeeNative = zanoApi - .lookup>('get_current_tx_fee') - .asFunction<_getCurrentTxFee>(); -typedef _get_current_tx_fee = Int64 Function(Int64); -typedef _getCurrentTxFee = int Function(int priority); - -// char * restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error) -final _restoreWalletFromSeedNative = zanoApi - .lookup>('restore_wallet_from_seed') - .asFunction<_RestoreWalletFromSeed>(); -typedef _restore_wallet_from_seed = Pointer Function( - Pointer, Pointer, Pointer, Int32, Int64, Pointer); -typedef _RestoreWalletFromSeed = Pointer Function( - Pointer, Pointer, Pointer, int, int, Pointer); - -// char* set_password(uint64_t hwallet, char *password, Utf8Box &error) -final _setPasswordNative = - zanoApi.lookup>('set_password').asFunction<_SetPassword>(); -typedef _set_password = Pointer Function(Int64 hWallet, Pointer password, Pointer error); -typedef _SetPassword = Pointer Function(int hWallet, Pointer password, Pointer error); - -String setPassword({required int hWallet, required String password}) { - final passwordPointer = password.toNativeUtf8(); - final errorMessagePointer = calloc(); - final result = - convertUTF8ToString(pointer: _setPasswordNative(hWallet, passwordPointer, errorMessagePointer)); - calloc.free(passwordPointer); - - /*if (!changed) { - final message = errorMessagePointer.ref.getValue(); - calloc.free(errorMessagePointer); - throw Exception(message); - }*/ - - calloc.free(errorMessagePointer); - return result; -} - -// is_wallet_exist(char *path) -final _isWalletExistNative = zanoApi - .lookup>('is_wallet_exist') - .asFunction<_IsWalletExist>(); -typedef _is_wallet_exist = Int8 Function(Pointer); -typedef _IsWalletExist = int Function(Pointer); - -bool isWalletExist({required String path}) { - final pathPointer = path.toNativeUtf8(); - final isExist = _isWalletExistNative(pathPointer) != 0; - calloc.free(pathPointer); - return isExist; -} - -// char* get_address_info(char* address) -final _getAddressInfoNative = zanoApi - .lookup>('get_address_info') - .asFunction<_GetAddressInfo>(); -typedef _get_address_info = Pointer Function(Pointer password); -typedef _GetAddressInfo = Pointer Function(Pointer address); - -String getAddressInfo(String address) { - debugPrint('get address info $address'); - final addressPointer = address.toNativeUtf8(); - final result = - convertUTF8ToString(pointer: _getAddressInfoNative(addressPointer)); - debugPrint('get address info result $result'); - calloc.free(addressPointer); - return result; -} - -bool setupNode({ - required String address, - String? login, - String? password, - bool useSSL = false, - bool isLightWallet = false, - /*String? socksProxyAddress*/ -}) { - final addressPointer = address.toNativeUtf8(); - Pointer? loginPointer; - Pointer? passwordPointer; - - if (login != null) { - loginPointer = login.toNativeUtf8(); - } - - if (password != null) { - passwordPointer = password.toNativeUtf8(); - } - - final errorMessagePointer = ''.toNativeUtf8(); - debugPrint( - "setup_node address $address login $login password $password useSSL $useSSL isLightWallet $isLightWallet"); - final isSetupNode = _setupNodeNative(addressPointer, loginPointer, passwordPointer, - _boolToInt(useSSL), _boolToInt(isLightWallet), errorMessagePointer) != - 0; - debugPrint("setup_node result $isSetupNode"); - - calloc.free(addressPointer); - - if (loginPointer != null) { - calloc.free(loginPointer); - } - - if (passwordPointer != null) { - calloc.free(passwordPointer); - } - - return isSetupNode; -} - -String asyncCall({required String methodName, required int hWallet, required String params}) { - final methodNamePointer = methodName.toNativeUtf8(); - final paramsPointer = params.toNativeUtf8(); - - debugPrint('async_call method_name $methodName hWallet $hWallet params $params'); - final result = - convertUTF8ToString(pointer: _asyncCallNative(methodNamePointer, hWallet, paramsPointer)); - - calloc.free(methodNamePointer); - calloc.free(paramsPointer); - - return result; -} - -String createWallet( - {required String path, required String password, required String language, int nettype = 0}) { - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final languagePointer = language.toNativeUtf8(); - final errorMessagePointer = ''.toNativeUtf8(); - debugPrint('create_wallet path $path password $password language $language'); - final result = convertUTF8ToString( - pointer: _createWalletNative( - pathPointer, passwordPointer, languagePointer, nettype, errorMessagePointer)); - debugPrint('create_wallet result $result'); - calloc.free(pathPointer); - calloc.free(passwordPointer); - calloc.free(languagePointer); - - return result; -} - -Future invokeMethod(int hWallet, String methodName, String params) async { - debugPrint('invoke method $methodName params $params'); - final invokeResult = asyncCall( - methodName: 'invoke', - hWallet: hWallet, - params: json.encode({ - 'method': methodName, - 'params': params, - })); - debugPrint('invoke result $invokeResult'); - final map = json.decode(invokeResult); - if (map['job_id'] != null) { - await Future.delayed(Duration(seconds: 3)); - final result = tryPullResult(map['job_id'] as int); - return result; - } - return invokeResult; -} - -Future store(int hWallet) async { - return await invokeMethod(hWallet, 'store', '{}'); -} - -Future transfer(int hWallet, TransferParams params) async { - final invokeResult = await asyncCall( - methodName: 'invoke', - hWallet: hWallet, - params: '{"method": "transfer","params": ${jsonEncode(params)}}', - ); - debugPrint('invoke result $invokeResult'); - var map = json.decode(invokeResult); - if (map['job_id'] != null) { - // TODO: fixit - await Future.delayed(Duration(seconds: 3)); - final result = tryPullResult(map['job_id'] as int); - return result; - } - return invokeResult; -} - -Future getRecentTxsAndInfo( - {required int hWallet, - required int offset, - required int count, - bool updateProvisionInfo = true}) async { - return await invokeMethod( - hWallet, - 'get_recent_txs_and_info', - json.encode( - GetRecentTxsAndInfoParams( - offset: offset, - count: count, - updateProvisionInfo: updateProvisionInfo, - ), - ), - ); -} - -String getWalletStatus(int hWallet) { - debugPrint('get_wallet_status hWallet $hWallet'); - final result = convertUTF8ToString(pointer: _getWalletStatusNative(hWallet)); - debugPrint('get_wallet_status result $result'); - return result; -} - -void closeWallet(int hWallet) { - debugPrint('close_wallet hWallet $hWallet'); - _closeWalletNative(hWallet); -} - -int getCurrentTxFee(int priority) { - debugPrint('get_current_tx_fee priority $priority'); - final result = _getCurrentTxFeeNative(priority); - debugPrint('get_current_tx_fee result $result'); - return result; -} - -String getWalletInfo(int hWallet) { - debugPrint('get_wallet_info hWallet $hWallet'); - final result = convertUTF8ToString(pointer: _getWalletInfoNative(hWallet)); - debugPrint('get_wallet_info result $result'); - return result; -} - -String getConnectivityStatus() { - final result = convertUTF8ToString(pointer: _getConnectivityStatusNative()); - debugPrint('get_connectivity_status result $result'); - return result; -} - -String getVersion() { - final result = convertUTF8ToString(pointer: _getVersionNative()); - debugPrint('get_version result $result'); - return result; -} - -String restoreWalletFromSeed(String path, String password, String seed) { - debugPrint('restore_wallet_from_seed path $path password $password seed $seed'); - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final seedPointer = seed.toNativeUtf8(); - final errorMessagePointer = ''.toNativeUtf8(); - final result = convertUTF8ToString( - pointer: _restoreWalletFromSeedNative( - pathPointer, passwordPointer, seedPointer, 0, 0, errorMessagePointer)); - debugPrint('restore wallet from seed result $result'); - return result; -} - -String loadWallet(String path, String password, int nettype) { - debugPrint('load_wallet path $path password $password nettype $nettype'); - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final result = convertUTF8ToString( - pointer: _loadWalletNative(pathPointer, passwordPointer, nettype), - ); - debugPrint('load_wallet result $result'); - return result; -} - -String tryPullResult(int jobId) { - debugPrint('try_pull_result jobId $jobId'); - final result = convertUTF8ToString(pointer: _tryPullResultNative(jobId)); - debugPrint('try_pull_result result $result'); - return result; -} - -int _boolToInt(bool value) => value ? 1 : 0; diff --git a/cw_zano/lib/api/model/get_recent_txs_and_info_params.dart b/cw_zano/lib/api/model/get_recent_txs_and_info_params.dart index 9866e4418..ea90e5003 100644 --- a/cw_zano/lib/api/model/get_recent_txs_and_info_params.dart +++ b/cw_zano/lib/api/model/get_recent_txs_and_info_params.dart @@ -3,11 +3,11 @@ class GetRecentTxsAndInfoParams { final int count; final bool updateProvisionInfo; - GetRecentTxsAndInfoParams({required this.offset, required this.count, required this.updateProvisionInfo}); + GetRecentTxsAndInfoParams({required this.offset, required this.count, this.updateProvisionInfo = true}); Map toJson() => { - "offset": offset, - "count": count, - "update_provision_info": updateProvisionInfo, + 'offset': offset, + 'count': count, + 'update_provision_info': updateProvisionInfo, }; } \ No newline at end of file diff --git a/cw_zano/lib/api/wallet.dart b/cw_zano/lib/api/wallet.dart index 712f45459..bafef1151 100644 --- a/cw_zano/lib/api/wallet.dart +++ b/cw_zano/lib/api/wallet.dart @@ -2,7 +2,8 @@ import 'dart:async'; import 'dart:convert'; import 'package:cw_core/crypto_currency.dart'; -import 'package:cw_zano/api/calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart'; import 'package:cw_zano/api/model/get_wallet_info_result.dart'; import 'package:cw_zano/api/model/get_wallet_status_result.dart'; import 'package:cw_zano/api/model/zano_wallet_keys.dart'; @@ -12,13 +13,13 @@ import 'package:flutter/foundation.dart'; import 'package:mobx/mobx.dart' as mobx; int getCurrentHeight(int hWallet) { - final json = calls.getWalletStatus(hWallet); + final json = ApiCalls.getWalletStatus(hWallet: hWallet); final walletStatus = GetWalletStatusResult.fromJson(jsonDecode(json) as Map); return walletStatus.currentWalletHeight; } int getNodeHeightSync(int hWallet) { - final json = calls.getWalletStatus(hWallet); + final json = ApiCalls.getWalletStatus(hWallet: hWallet); final walletStatus = GetWalletStatusResult.fromJson(jsonDecode(json) as Map); return walletStatus.currentDaemonHeight; } @@ -37,13 +38,13 @@ class SyncListener { int _lastKnownBlockHeight; int _initialSyncHeight; - Future getNodeHeightOrUpdate(int hWallet, int baseHeight) async { - if (_cachedBlockchainHeight < baseHeight || _cachedBlockchainHeight == 0) { - _cachedBlockchainHeight = await compute(getNodeHeightSync, hWallet); - } + // Future getNodeHeightOrUpdate(int hWallet, int baseHeight) async { + // if (_cachedBlockchainHeight < baseHeight || _cachedBlockchainHeight == 0) { + // _cachedBlockchainHeight = await compute(getNodeHeightSync, hWallet); + // } - return _cachedBlockchainHeight; - } + // return _cachedBlockchainHeight; + // } void start(ZanoWalletBase wallet, int hWallet) async { _cachedBlockchainHeight = 0; @@ -54,53 +55,56 @@ class SyncListener { onNewTransaction?.call(); }*/ - var syncHeight = getCurrentHeight(hWallet); + var json = ApiCalls.getWalletStatus(hWallet: hWallet); + final status = GetWalletStatusResult.fromJson(jsonDecode(json) as Map); + // You can call getWalletInfo ONLY if getWalletStatus returns NOT is in long refresh and wallet state is 2 (ready) + if (!status.isInLongRefresh && status.walletState == 2) { + final syncHeight = status.currentWalletHeight; - final json = calls.getWalletInfo(hWallet); - final result = GetWalletInfoResult.fromJson(jsonDecode(json) as Map); - wallet.seed = result.wiExtended.seed; - wallet.keys = ZanoWalletKeys( - privateSpendKey: result.wiExtended.spendPrivateKey, - privateViewKey: result.wiExtended.viewPrivateKey, - publicSpendKey: result.wiExtended.spendPublicKey, - publicViewKey: result.wiExtended.viewPublicKey, - ); + json = ApiCalls.getWalletInfo(hWallet); + final result = GetWalletInfoResult.fromJson(jsonDecode(json) as Map); + wallet.seed = result.wiExtended.seed; + wallet.keys = ZanoWalletKeys( + privateSpendKey: result.wiExtended.spendPrivateKey, + privateViewKey: result.wiExtended.viewPrivateKey, + publicSpendKey: result.wiExtended.spendPublicKey, + publicViewKey: result.wiExtended.viewPublicKey, + ); - final balance = result.wi.balances.first; - wallet.assetId = balance.assetInfo.assetId; - wallet.balance = mobx.ObservableMap.of( - {CryptoCurrency.zano: ZanoBalance(total: balance.total, unlocked: balance.unlocked)}); + final balance = result.wi.balances.first; + wallet.assetId = balance.assetInfo.assetId; + wallet.balance = mobx.ObservableMap.of({CryptoCurrency.zano: ZanoBalance(total: balance.total, unlocked: balance.unlocked)}); - if (_initialSyncHeight <= 0) { - _initialSyncHeight = syncHeight; + if (_initialSyncHeight <= 0) { + _initialSyncHeight = syncHeight; + } + + final bchHeight = status.currentDaemonHeight; + + if (_lastKnownBlockHeight == syncHeight) { + return; + } + + _lastKnownBlockHeight = syncHeight; + final track = bchHeight - _initialSyncHeight; + final diff = track - (bchHeight - syncHeight); + final ptc = diff <= 0 ? 0.0 : diff / track; + final left = bchHeight - syncHeight; + + if (syncHeight < 0 || left < 0) { + return; + } + + // 1. Actual new height; 2. Blocks left to finish; 3. Progress in percents; + onNewBlock.call(syncHeight, left, ptc); } - - final bchHeight = await getNodeHeightOrUpdate(hWallet, syncHeight); - - if (_lastKnownBlockHeight == syncHeight || syncHeight == null) { - return; - } - - _lastKnownBlockHeight = syncHeight; - final track = bchHeight - _initialSyncHeight; - final diff = track - (bchHeight - syncHeight); - final ptc = diff <= 0 ? 0.0 : diff / track; - final left = bchHeight - syncHeight; - - if (syncHeight < 0 || left < 0) { - return; - } - - // 1. Actual new height; 2. Blocks left to finish; 3. Progress in percents; - onNewBlock?.call(syncHeight, left, ptc); }); } void stop() => _updateSyncInfoTimer?.cancel(); } -SyncListener setListeners( - void Function(int, int, double) onNewBlock, void Function() onNewTransaction) { +SyncListener setListeners(void Function(int, int, double) onNewBlock, void Function() onNewTransaction) { final listener = SyncListener(onNewBlock, onNewTransaction); /**setListenerNative();*/ return listener; diff --git a/cw_zano/lib/pending_zano_transaction.dart b/cw_zano/lib/pending_zano_transaction.dart index b3a293784..9cc22c573 100644 --- a/cw_zano/lib/pending_zano_transaction.dart +++ b/cw_zano/lib/pending_zano_transaction.dart @@ -7,13 +7,13 @@ import 'package:cw_zano/api/model/transfer_result.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/amount_converter.dart'; import 'package:cw_core/pending_transaction.dart'; -import 'package:cw_zano/api/calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart' as calls; import 'package:cw_zano/zano_wallet.dart'; class PendingZanoTransaction with PendingTransaction { PendingZanoTransaction( {required this.zanoWallet, - required this.fee, + required this.fee, required this.intAmount, //required this.stringAmount, required this.hWallet, @@ -50,26 +50,24 @@ class PendingZanoTransaction with PendingTransaction { @override Future commit() async { - final result = await calls.transfer( - hWallet, - TransferParams( - destinations: [ - Destination( - amount: intAmount.toString(), - address: address, - assetId: assetId, - ) - ], - fee: fee, - mixin: zanoMixin, - paymentId: '', - comment: comment, - pushPayer: false, - hideReceiver: false, - )); - print('transfer result $result'); + final params = TransferParams( + destinations: [ + Destination( + amount: intAmount.toString(), + address: address, + assetId: assetId, + ) + ], + fee: fee, + mixin: zanoMixin, + paymentId: '', + comment: comment, + pushPayer: false, + hideReceiver: false, + ); + final result = await zanoWallet.invokeMethod(hWallet, 'transfer', params); final map = jsonDecode(result); - if (map['result'] != null && map['result']['result'] != null ) { + if (map['result'] != null && map['result']['result'] != null) { transferResult = TransferResult.fromJson( map['result']['result'] as Map, ); diff --git a/cw_zano/lib/zano_utils.dart b/cw_zano/lib/zano_utils.dart index 54235e3fa..4127a96ab 100644 --- a/cw_zano/lib/zano_utils.dart +++ b/cw_zano/lib/zano_utils.dart @@ -1,13 +1,12 @@ import 'dart:convert'; - -import 'package:cw_zano/api/calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart'; import 'package:cw_zano/api/model/get_address_info_result.dart'; class ZanoUtils { static bool validateAddress(String address) { try { final result = GetAddressInfoResult.fromJson( - jsonDecode(calls.getAddressInfo(address)) as Map, + jsonDecode(ApiCalls.getAddressInfo(address: address)) as Map, ); return result.valid; } catch (err) { diff --git a/cw_zano/lib/zano_wallet.dart b/cw_zano/lib/zano_wallet.dart index b071cb67b..85a158c12 100644 --- a/cw_zano/lib/zano_wallet.dart +++ b/cw_zano/lib/zano_wallet.dart @@ -13,8 +13,11 @@ import 'package:cw_core/sync_status.dart'; import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_info.dart'; -import 'package:cw_zano/api/calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart'; +import 'package:cw_zano/api/model/get_recent_txs_and_info_params.dart'; import 'package:cw_zano/api/model/history.dart'; +import 'package:cw_zano/api/model/store_result.dart'; import 'package:cw_zano/api/model/zano_wallet_keys.dart'; import 'package:cw_zano/api/wallet.dart' as zano_wallet; import 'package:cw_zano/api/zano_api.dart'; @@ -37,11 +40,9 @@ class ZanoWallet = ZanoWalletBase with _$ZanoWallet; typedef _load_wallet = Pointer Function(Pointer, Pointer, Int8); typedef _LoadWallet = Pointer Function(Pointer, Pointer, int); - const int zanoMixin = 10; -abstract class ZanoWalletBase - extends WalletBase with Store { +abstract class ZanoWalletBase extends WalletBase with Store { ZanoWalletBase(WalletInfo walletInfo) : balance = ObservableMap.of({CryptoCurrency.zano: ZanoBalance(total: 0, unlocked: 0)}), _isTransactionUpdating = false, @@ -64,6 +65,8 @@ abstract class ZanoWalletBase String assetId = ''; static const int _autoSaveInterval = 30; + static const _statusDelivered = 'delivered'; + static const _maxAttempts = 10; @override ZanoWalletAddresses walletAddresses; @@ -80,8 +83,7 @@ abstract class ZanoWalletBase String seed = ''; @override - ZanoWalletKeys keys = ZanoWalletKeys( - privateSpendKey: '', privateViewKey: '', publicSpendKey: '', publicViewKey: ''); + ZanoWalletKeys keys = ZanoWalletKeys(privateSpendKey: '', privateViewKey: '', publicSpendKey: '', publicViewKey: ''); zano_wallet.SyncListener? _listener; /**ReactionDisposer? _onAccountChangeReaction;*/ @@ -100,6 +102,7 @@ abstract class ZanoWalletBase Future init(String address) async { await walletAddresses.init(); await walletAddresses.updateAddress(address); + ///balance.addAll(getZanoBalance(/**accountIndex: walletAddresses.account?.id ?? 0*/)); _setListeners(); await updateTransactions(); @@ -112,8 +115,7 @@ abstract class ZanoWalletBase } } - _autoSaveTimer = - Timer.periodic(Duration(seconds: _autoSaveInterval), (_) async => await save()); + _autoSaveTimer = Timer.periodic(Duration(seconds: _autoSaveInterval), (_) async => await save()); } @override @@ -130,7 +132,7 @@ abstract class ZanoWalletBase Future connectToNode({required Node node}) async { try { syncStatus = ConnectingSyncStatus(); - await calls.setupNode( + await ApiCalls.setupNode( address: "195.201.107.230:33336", // node.uriRaw, login: "", // node.login, password: "", // node.password, @@ -169,15 +171,11 @@ abstract class ZanoWalletBase Future createTransaction(Object credentials) async { final creds = credentials as ZanoTransactionCreationCredentials; final output = creds.outputs.first; - final address = output.isParsedAddress && (output.extractedAddress?.isNotEmpty ?? false) - ? output.extractedAddress! - : output.address; + final address = output.isParsedAddress && (output.extractedAddress?.isNotEmpty ?? false) ? output.extractedAddress! : output.address; final stringAmount = output.sendAll ? null : output.cryptoAmount!.replaceAll(',', '.'); final fee = calculateEstimatedFee(creds.priority); final intAmount = (double.parse(stringAmount!) * pow(10, 12)).toInt(); - final transaction = PendingZanoTransaction(fee: fee, intAmount: intAmount, - hWallet: hWallet, address: address, assetId: assetId, - comment: output.note ?? '', zanoWallet: this); + final transaction = PendingZanoTransaction(fee: fee, intAmount: intAmount, hWallet: hWallet, address: address, assetId: assetId, comment: output.note ?? '', zanoWallet: this); return transaction; /*final _credentials = credentials as ZanoTransactionCreationCredentials; @@ -251,14 +249,31 @@ abstract class ZanoWalletBase @override int calculateEstimatedFee(TransactionPriority priority, [int? amount = null]) { - return calls.getCurrentTxFee(priority.raw); + return ApiCalls.getCurrentTxFee(priority: priority.raw); } @override Future save() async { - await walletAddresses.updateAddressesInBox(); - await backupWalletFiles(name); - await calls.store(hWallet); + try { + await walletAddresses.updateAddressesInBox(); + await backupWalletFiles(name); + await store(); + } catch (e) { + print('Error while saving Zano wallet file ${e.toString()}'); + } + } + + Future store() async { + try { + final json = await invokeMethod(hWallet, 'store', '{}'); + final map = jsonDecode(json) as Map; + if (map['result'] == null || map['result']['result'] == null) { + throw 'store empty response'; + } + final _ = StoreResult.fromJson(map['result']['result'] as Map); + } catch (e) { + print(e.toString()); + } } @override @@ -287,7 +302,7 @@ abstract class ZanoWalletBase @override Future changePassword(String password) async { - calls.setPassword(hWallet: hWallet, password: password); + ApiCalls.setPassword(hWallet: hWallet, password: password); } Future setAsRecovered() async { @@ -310,34 +325,52 @@ abstract class ZanoWalletBase } Future _refreshTransactions() async { - final result = await calls.getRecentTxsAndInfo(hWallet: hWallet, offset: 0, count: 30); - final map = jsonDecode(result); - if (map == null || map["result"] == null || map["result"]["result"] == null) { - return; + try { + final result = await invokeMethod(hWallet, 'get_recent_txs_and_info', GetRecentTxsAndInfoParams(offset: 0, count: 30)); + final map = jsonDecode(result) as Map?; + if (map == null) { + print('get_recent_txs_and_info empty response'); + return; + } + + final resultData = map['result']; + if (resultData == null) { + print('get_recent_txs_and_info empty response'); + return; + } + + if (resultData['error'] != null) { + print('get_recent_txs_and_info error ${resultData['error']}'); + return; + } + + final transfers = resultData['result']?['transfers'] as List?; + if (transfers == null) { + print('get_recent_txs_and_info empty transfers'); + return; + } + + history = transfers.map((e) => History.fromJson(e as Map)).toList(); + } catch (e) { + print(e.toString()); } - if (map["result"]["result"]["transfers"] != null) - history = (map["result"]["result"]["transfers"] as List) - .map((e) => History.fromJson(e as Map)) - .toList(); } @override Future> fetchTransactions() async { - //zano_transaction_history.refreshTransactions(); - await _refreshTransactions(); - return history - .map((history) => ZanoTransactionInfo.fromHistory(history)) - .fold>({}, - (Map acc, ZanoTransactionInfo tx) { - acc[tx.id] = tx; - return acc; - }); - // return _getAllTransactions(null) - // .fold>({}, - // (Map acc, ZanoTransactionInfo tx) { - // acc[tx.id] = tx; - // return acc; - // }); + try { + await _refreshTransactions(); + return history.map((history) => ZanoTransactionInfo.fromHistory(history)).fold>( + {}, + (Map acc, ZanoTransactionInfo tx) { + acc[tx.id] = tx; + return acc; + }, + ); + } catch (e) { + print(e); + return {}; + } } Future updateTransactions() async { @@ -432,8 +465,7 @@ abstract class ZanoWalletBase } } - final _loadWalletNative = - zanoApi.lookup>('load_wallet').asFunction<_LoadWallet>(); + final _loadWalletNative = zanoApi.lookup>('load_wallet').asFunction<_LoadWallet>(); String loadWallet(String path, String password) { print('load_wallet path $path password $password'); @@ -451,4 +483,22 @@ abstract class ZanoWalletBase calloc.free(pointer); return str; } + + Future invokeMethod(int hWallet, String methodName, Object params) async { + var invokeResult = ApiCalls.asyncCall(methodName: 'invoke', hWallet: hWallet, params: '{"method": "$methodName","params": ${jsonEncode(params)}}'); + var map = jsonDecode(invokeResult) as Map; + int attempts = 0; + if (map['job_id'] != null) { + final jobId = map['job_id'] as int; + do { + await Future.delayed(Duration(milliseconds: attempts < 2 ? 100 : 500)); + final result = ApiCalls.tryPullResult(jobId); + map = jsonDecode(result) as Map; + if (map['status'] != null && map['status'] == _statusDelivered && map['result'] != null) { + return result; + } + } while (++attempts < _maxAttempts); + } + return invokeResult; + } } diff --git a/cw_zano/lib/zano_wallet_service.dart b/cw_zano/lib/zano_wallet_service.dart index d057c72ff..0651b32da 100644 --- a/cw_zano/lib/zano_wallet_service.dart +++ b/cw_zano/lib/zano_wallet_service.dart @@ -10,7 +10,8 @@ import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_service.dart'; import 'package:cw_core/wallet_type.dart'; -import 'package:cw_zano/api/calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart' as calls; +import 'package:cw_zano/api/api_calls.dart'; import 'package:cw_zano/api/consts.dart'; import 'package:cw_zano/api/exceptions/already_exists_exception.dart'; import 'package:cw_zano/api/exceptions/create_wallet_exception.dart'; @@ -72,12 +73,12 @@ class ZanoWalletService extends WalletService; if (map['result'] == null) throw CreateWalletException(''); final createWalletResult = CreateWalletResult.fromJson(map['result'] as Map); _parseCreateWalletResult(createWalletResult, wallet); - await calls.store(hWallet); + await wallet.store(); await wallet.init(createWalletResult.wi.address); return wallet; } catch (e) { @@ -91,7 +92,7 @@ class ZanoWalletService extends WalletService isWalletExit(String name) async { try { final path = await pathForWallet(name: name, type: getType()); - return calls.isWalletExist(path: path); + return ApiCalls.isWalletExist(path: path); } catch (e) { // TODO: Implement Exception for wallet list service. print('ZanoWalletsManager Error: $e'); @@ -118,7 +119,7 @@ class ZanoWalletService extends WalletService); _parseCreateWalletResult(createWalletResult, wallet); - await calls.store(hWallet); + await wallet.store(); await wallet.init(createWalletResult.wi.address); return wallet; } catch (e) { @@ -180,13 +181,13 @@ class ZanoWalletService extends WalletService; if (map['result'] != null) { final createWalletResult = CreateWalletResult.fromJson(map['result'] as Map); _parseCreateWalletResult(createWalletResult, wallet); - await calls.store(hWallet); + await wallet.store(); await wallet.init(createWalletResult.wi.address); return wallet; } else if (map['error'] != null) { diff --git a/lib/core/seed_validator.dart b/lib/core/seed_validator.dart index 2c0c78cdf..cbacf49a7 100644 --- a/lib/core/seed_validator.dart +++ b/lib/core/seed_validator.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/haven/haven.dart'; import 'package:cake_wallet/zano/zano.dart'; @@ -33,8 +32,6 @@ class SeedValidator extends Validator { return zano!.getWordList(language); case WalletType.ethereum: return ethereum!.getEthereumWordList(language); - case WalletType.dummy: - return dummy!.getDummyWordList(); default: return []; } diff --git a/lib/di.dart b/lib/di.dart index 29406339c..fc8bf512e 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -5,7 +5,6 @@ import 'package:cake_wallet/buy/onramper/onramper_buy_provider.dart'; import 'package:cake_wallet/buy/payfura/payfura_buy_provider.dart'; import 'package:cake_wallet/buy/robinhood/robinhood_buy_provider.dart'; import 'package:cake_wallet/core/yat_service.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/entities/background_tasks.dart'; import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart'; @@ -793,8 +792,6 @@ Future setup({ return ethereum!.createEthereumWalletService(_walletInfoSource); case WalletType.zano: return zano!.createZanoWalletService(_walletInfoSource); - case WalletType.dummy: - return dummy!.createDummyWalletService(_walletInfoSource); default: throw Exception( diff --git a/lib/dummy/cw_dummy.dart b/lib/dummy/cw_dummy.dart deleted file mode 100644 index f0772959b..000000000 --- a/lib/dummy/cw_dummy.dart +++ /dev/null @@ -1,83 +0,0 @@ -part of 'dummy.dart'; - -class CWDummy extends Dummy { - @override - List getDummyWordList() => ["aaa", "bbb", "ccc"]; - - @override - WalletService createDummyWalletService(Box walletInfoSource) => - DummyWalletService(walletInfoSource); - - @override - WalletCredentials createDummyNewWalletCredentials( - {required String name, WalletInfo? walletInfo}) => - DummyNewWalletCredentials(name: name, walletInfo: walletInfo); - - @override - WalletCredentials createDummyRestoreWalletFromSeedCredentials( - {required String name, WalletInfo? walletInfo}) => - DummyRestoreWalletFromSeedCredentials(name: name, walletInfo: walletInfo); - - @override - WalletCredentials createDummyRestoreWalletFromKeyCredentials( - {required String name, WalletInfo? walletInfo}) => - DummyRestoreWalletFromKeyCredentials(name: name, walletInfo: walletInfo); - - @override - List getTransactionPriorities() => - DummyTransactionPriority.all; - - @override - TransactionPriority deserializeDummyTransactionPriority(int raw) => - DummyTransactionPriority.deserialize(raw: raw); - - @override - TransactionPriority getDefaultTransactionPriority() => - DummyTransactionPriority.fast; - - @override - CryptoCurrency assetOfTransaction(TransactionInfo tx) { - final transaction = tx as DummyTransactionInfo; - // TODO: !!! - return CryptoCurrency.dummy; - } - - @override - String formatterDummyAmountToString({required int amount}) => - throw UnimplementedError(); - - @override - TransactionPriority getDummyTransactionPrioritySlow() => - DummyTransactionPriority.slow; - - @override - TransactionPriority getDummyTransactionPriorityMedium() => - DummyTransactionPriority.medium; - - @override - double formatterDummyAmountToDouble({required int amount}) => throw UnimplementedError(); - - @override - int formatterDummyParseAmount({required String amount}) => throw UnimplementedError(); - - @override - Object createDummyTransactionCreationCredentials({required List outputs, required TransactionPriority priority}) => - DummyTransactionCreationCredentials(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 DummyTransactionPriority); - - @override - Future generateNewAddress(Object wallet) async { - final dummyWallet = wallet as DummyWallet; - await dummyWallet.walletAddresses.generateNewAddress(); - } - - @override - String getAddress(WalletBase wallet) => (wallet as DummyWallet).walletAddresses.address; -} diff --git a/lib/dummy/dummy.dart b/lib/dummy/dummy.dart deleted file mode 100644 index 884db3f1d..000000000 --- a/lib/dummy/dummy.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:cake_wallet/view_model/send/output.dart'; -import 'package:cw_core/crypto_currency.dart'; -import 'package:cw_core/output_info.dart'; -import 'package:cw_core/transaction_info.dart'; -import 'package:cw_core/transaction_priority.dart'; -import 'package:cw_core/wallet_base.dart'; -import 'package:cw_core/wallet_credentials.dart'; -import 'package:cw_core/wallet_info.dart'; -import 'package:cw_core/wallet_service.dart'; -import 'package:cw_dummy/dummy_transaction_info.dart'; -import 'package:cw_dummy/dummy_transaction_priority.dart'; -import 'package:cw_dummy/dummy_wallet.dart'; -import 'package:cw_dummy/dummy_wallet_creation_credentials.dart'; -import 'package:cw_dummy/dummy_transaction_creation_credentials.dart'; -import 'package:cw_dummy/dummy_wallet_service.dart'; -import 'package:hive/hive.dart'; - -part 'cw_dummy.dart'; - -Dummy? dummy = CWDummy(); - -abstract class Dummy { - WalletCredentials createDummyNewWalletCredentials( - {required String name, WalletInfo? walletInfo}); - WalletCredentials createDummyRestoreWalletFromKeyCredentials( - {required String name, WalletInfo? walletInfo}); - WalletCredentials createDummyRestoreWalletFromSeedCredentials( - {required String name, WalletInfo? walletInfo}); - WalletService createDummyWalletService(Box walletInfoSource); - TransactionPriority deserializeDummyTransactionPriority(int raw); - List getDummyWordList(); - List getTransactionPriorities(); - TransactionPriority getDefaultTransactionPriority(); - CryptoCurrency assetOfTransaction(TransactionInfo tx); - double formatterDummyAmountToDouble({required int amount}); - TransactionPriority getDummyTransactionPrioritySlow(); - TransactionPriority getDummyTransactionPriorityMedium(); - int formatterDummyParseAmount({required String amount}); - Object createDummyTransactionCreationCredentials({required List outputs, required TransactionPriority priority}); - Future generateNewAddress(Object wallet); - String getAddress(WalletBase wallet); -} diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 65d2615a7..dacbe63d5 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -27,7 +27,6 @@ const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002'; const havenDefaultNodeUri = 'nodes.havenprotocol.org:443'; const ethereumDefaultNodeUri = 'ethereum.publicnode.com'; const zanoDefaultNodeUri = 'zano.org'; -const dummyDefaultNodeUri = 'example.com'; Future defaultSettingsMigration( {required int version, @@ -324,12 +323,6 @@ Node? getZanoDefaultNode({required Box nodes}) { ?? nodes.values.firstWhereOrNull((node) => node.type == WalletType.zano); } -Node? getDummyDefaultNode({required Box nodes}) { - return nodes.values.firstWhereOrNull( - (Node node) => node.uriRaw == dummyDefaultNodeUri) - ?? nodes.values.firstWhereOrNull((node) => node.type == WalletType.dummy); -} - Node getMoneroDefaultNode({required Box nodes}) { final timeZone = DateTime.now().timeZoneOffset.inHours; var nodeUri = ''; @@ -530,8 +523,6 @@ Future checkCurrentNodes( .getInt(PreferencesKey.currentEthereumNodeIdKey); final currentZanoNodeId = sharedPreferences .getInt(PreferencesKey.currentZanoNodeIdKey); - final currentDummyNodeId = sharedPreferences - .getInt(PreferencesKey.currentDummyNodeIdKey); final currentMoneroNode = nodeSource.values.firstWhereOrNull( (node) => node.key == currentMoneroNodeId); final currentBitcoinElectrumServer = nodeSource.values.firstWhereOrNull( @@ -543,7 +534,6 @@ Future checkCurrentNodes( final currentEthereumNodeServer = nodeSource.values.firstWhereOrNull( (node) => node.key == currentEthereumNodeId); final currentZanoNode = nodeSource.values.firstWhereOrNull((node) => node.key == currentZanoNodeId); - final currentDummyNode = nodeSource.values.firstWhereOrNull((node) => node.key == currentDummyNodeId); if (currentMoneroNode == null) { final newCakeWalletNode = @@ -591,13 +581,6 @@ Future checkCurrentNodes( await sharedPreferences.setInt( PreferencesKey.currentZanoNodeIdKey, node.key as int); } - - if (currentDummyNode == null) { - final node = Node(uri: dummyDefaultNodeUri, type: WalletType.dummy); - await nodeSource.add(node); - await sharedPreferences.setInt( - PreferencesKey.currentDummyNodeIdKey, node.key as int); - } } Future resetBitcoinElectrumServer( diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index 5bdab9e76..97fffcf5f 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -6,7 +6,6 @@ class PreferencesKey { static const currentLitecoinElectrumSererIdKey = 'current_node_id_ltc'; static const currentHavenNodeIdKey = 'current_node_id_xhv'; static const currentZanoNodeIdKey = 'current_node_id_zano'; - static const currentDummyNodeIdKey = 'current_node_id_dummy'; static const currentEthereumNodeIdKey = 'current_node_id_eth'; static const currentFiatCurrencyKey = 'current_fiat_currency'; static const currentTransactionPriorityKeyLegacy = 'current_fee_priority'; @@ -37,7 +36,6 @@ class PreferencesKey { static const litecoinTransactionPriority = 'current_fee_priority_litecoin'; static const ethereumTransactionPriority = 'current_fee_priority_ethereum'; static const zanoTransactionPriority = 'current_fee_priority_zano'; - static const dummyTransactionPriority = 'current_fee_priority_dummy'; static const shouldShowReceiveWarning = 'should_show_receive_warning'; static const shouldShowYatPopup = 'should_show_yat_popup'; static const moneroWalletPasswordUpdateV1Base = 'monero_wallet_update_v1'; diff --git a/lib/entities/priority_for_wallet_type.dart b/lib/entities/priority_for_wallet_type.dart index 59bf63ceb..54c1d2c2a 100644 --- a/lib/entities/priority_for_wallet_type.dart +++ b/lib/entities/priority_for_wallet_type.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/haven/haven.dart'; import 'package:cake_wallet/monero/monero.dart'; @@ -21,8 +20,6 @@ List priorityForWalletType(WalletType type) { return ethereum!.getTransactionPriorities(); case WalletType.zano: return zano!.getTransactionPriorities(); - case WalletType.dummy: - return dummy!.getTransactionPriorities(); default: return []; } diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart index 2bd0e2eec..32f60394b 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart @@ -34,7 +34,6 @@ class _DesktopWalletSelectionDropDownState extends State Image.asset( @@ -145,8 +144,6 @@ class _DesktopWalletSelectionDropDownState extends State { this.litecoinIcon = Image.asset('assets/images/litecoin_menu.png'), this.havenIcon = Image.asset('assets/images/haven_menu.png'), this.ethereumIcon = Image.asset('assets/images/eth_icon.png'), - this.zanoIcon = Image.asset('assets/images/zano_icon.png'), - this.dummyIcon = Image.asset('assets/images/zano_icon.png'); + this.zanoIcon = Image.asset('assets/images/zano_icon.png'); final largeScreen = 731; @@ -50,7 +49,6 @@ class MenuWidgetState extends State { Image havenIcon; Image ethereumIcon; Image zanoIcon; - Image dummyIcon; @override void initState() { @@ -212,8 +210,6 @@ class MenuWidgetState extends State { return ethereumIcon; case WalletType.zano: return zanoIcon; - case WalletType.dummy: - return dummyIcon; default: throw Exception('No icon for ${type.toString()}'); } diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index 747c01008..edca592c0 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -49,7 +49,6 @@ class WalletListBodyState extends State { final havenIcon = Image.asset('assets/images/haven_logo.png', height: 24, width: 24); final ethereumIcon = Image.asset('assets/images/eth_icon.png', height: 24, width: 24); final zanoIcon = Image.asset('assets/images/zano_icon.png', height: 24, width: 24); - final dummyIcon = Image.asset('assets/images/zano_icon.png', height: 24, width: 24); final scrollController = ScrollController(); final double tileHeight = 60; Flushbar? _progressBar; diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 5bf8cf332..3d6cd2884 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:cake_wallet/bitcoin/bitcoin.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart'; import 'package:cake_wallet/entities/buy_provider_types.dart'; import 'package:cake_wallet/entities/cake_2fa_preset_options.dart'; @@ -88,7 +87,6 @@ abstract class SettingsStoreBase with Store { TransactionPriority? initialLitecoinTransactionPriority, TransactionPriority? initialEthereumTransactionPriority, TransactionPriority? initialZanoTransactionPriority, - TransactionPriority? initialDummyTransactionPriority, }) : nodes = ObservableMap.of(nodes), _sharedPreferences = sharedPreferences, @@ -153,10 +151,6 @@ abstract class SettingsStoreBase with Store { priority[WalletType.zano] = initialZanoTransactionPriority; } - if (initialDummyTransactionPriority != null) { - priority[WalletType.dummy] = initialDummyTransactionPriority; - } - reaction( (_) => fiatCurrency, (FiatCurrency fiatCurrency) => sharedPreferences.setString( @@ -188,9 +182,6 @@ abstract class SettingsStoreBase with Store { case WalletType.zano: key = PreferencesKey.zanoTransactionPriority; break; - case WalletType.dummy: - key = PreferencesKey.dummyTransactionPriority; - break; default: key = null; } @@ -538,7 +529,6 @@ abstract class SettingsStoreBase with Store { TransactionPriority? litecoinTransactionPriority; TransactionPriority? ethereumTransactionPriority; TransactionPriority? zanoTransactionPriority; - TransactionPriority? dummyTransactionPriority; if (sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) { havenTransactionPriority = monero?.deserializeMoneroTransactionPriority( @@ -556,10 +546,6 @@ abstract class SettingsStoreBase with Store { zanoTransactionPriority = monero?.deserializeMoneroTransactionPriority( raw: sharedPreferences.getInt(PreferencesKey.zanoTransactionPriority)!); } - if (sharedPreferences.getInt(PreferencesKey.dummyTransactionPriority) != null) { - dummyTransactionPriority = dummy?.deserializeDummyTransactionPriority( - sharedPreferences.getInt(PreferencesKey.dummyTransactionPriority)!); - } moneroTransactionPriority ??= monero?.getDefaultTransactionPriority(); bitcoinTransactionPriority ??= bitcoin?.getMediumTransactionPriority(); @@ -567,7 +553,6 @@ abstract class SettingsStoreBase with Store { litecoinTransactionPriority ??= bitcoin?.getLitecoinTransactionPriorityMedium(); ethereumTransactionPriority ??= ethereum?.getDefaultTransactionPriority(); zanoTransactionPriority ??= zano?.getDefaultTransactionPriority(); - dummyTransactionPriority ??= dummy?.getDefaultTransactionPriority(); final currentBalanceDisplayMode = BalanceDisplayMode.deserialize( raw: sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey)!); @@ -650,14 +635,12 @@ abstract class SettingsStoreBase with Store { final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey); final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey); final zanoNodeId = sharedPreferences.getInt(PreferencesKey.currentZanoNodeIdKey); - final dummyNodeId = sharedPreferences.getInt(PreferencesKey.currentDummyNodeIdKey); final moneroNode = nodeSource.get(nodeId); final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId); final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId); final havenNode = nodeSource.get(havenNodeId); final ethereumNode = nodeSource.get(ethereumNodeId); final zanoNode = nodeSource.get(zanoNodeId); - final dummyNode = nodeSource.get(dummyNodeId); final packageInfo = await PackageInfo.fromPlatform(); final deviceName = await _getDeviceName() ?? ''; final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true; @@ -693,10 +676,6 @@ abstract class SettingsStoreBase with Store { nodes[WalletType.zano] = zanoNode; } - if (dummyNode != null) { - nodes[WalletType.dummy] = dummyNode; - } - final savedSyncMode = SyncMode.all.firstWhere((element) { return element.type.index == (sharedPreferences.getInt(PreferencesKey.syncModeKey) ?? 1); }); @@ -737,7 +716,6 @@ abstract class SettingsStoreBase with Store { initialHavenTransactionPriority: havenTransactionPriority, initialLitecoinTransactionPriority: litecoinTransactionPriority, initialZanoTransactionPriority: zanoTransactionPriority, - initialDummyTransactionPriority: dummyTransactionPriority, initialShouldRequireTOTP2FAForAccessingWallet: shouldRequireTOTP2FAForAccessingWallet, initialShouldRequireTOTP2FAForSendsToContact: shouldRequireTOTP2FAForSendsToContact, initialShouldRequireTOTP2FAForSendsToNonContact: shouldRequireTOTP2FAForSendsToNonContact, @@ -789,11 +767,6 @@ abstract class SettingsStoreBase with Store { raw: sharedPreferences.getInt(PreferencesKey.zanoTransactionPriority)!) ?? priority[WalletType.zano]!; } - if (sharedPreferences.getInt(PreferencesKey.dummyTransactionPriority) != null) { - priority[WalletType.dummy] = dummy?.deserializeDummyTransactionPriority( - sharedPreferences.getInt(PreferencesKey.dummyTransactionPriority)!) ?? - priority[WalletType.dummy]!; - } final generateSubaddresses = sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey); @@ -881,7 +854,6 @@ abstract class SettingsStoreBase with Store { sharedPreferences.getInt(PreferencesKey.currentLitecoinElectrumSererIdKey); final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey); final zanoNodeId = sharedPreferences.getInt(PreferencesKey.currentZanoNodeIdKey); - final dummyNodeId = sharedPreferences.getInt(PreferencesKey.currentDummyNodeIdKey); final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey); final moneroNode = nodeSource.get(nodeId); final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId); @@ -889,7 +861,6 @@ abstract class SettingsStoreBase with Store { final havenNode = nodeSource.get(havenNodeId); final ethereumNode = nodeSource.get(ethereumNodeId); final zanoNode = nodeSource.get(zanoNodeId); - final dummyNode = nodeSource.get(dummyNodeId); if (moneroNode != null) { nodes[WalletType.monero] = moneroNode; @@ -914,10 +885,6 @@ abstract class SettingsStoreBase with Store { if (zanoNode != null) { nodes[WalletType.zano] = zanoNode; } - - if (dummyNode != null) { - nodes[WalletType.dummy] = dummyNode; - } } Future _saveCurrentNode(Node node, WalletType walletType) async { @@ -942,9 +909,6 @@ abstract class SettingsStoreBase with Store { case WalletType.zano: await _sharedPreferences.setInt(PreferencesKey.currentZanoNodeIdKey, node.key as int); break; - case WalletType.dummy: - await _sharedPreferences.setInt(PreferencesKey.currentDummyNodeIdKey, node.key as int); - break; default: break; } diff --git a/lib/view_model/dashboard/transaction_list_item.dart b/lib/view_model/dashboard/transaction_list_item.dart index d5c85c793..95d769d55 100644 --- a/lib/view_model/dashboard/transaction_list_item.dart +++ b/lib/view_model/dashboard/transaction_list_item.dart @@ -1,4 +1,3 @@ -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; @@ -101,13 +100,6 @@ class TransactionListItem extends ActionListItem with Keyable { cryptoAmount: zano!.formatterMoneroAmountToDouble(amount: transaction.amount), price: price); break; - case WalletType.dummy: - final asset = dummy!.assetOfTransaction(transaction); - final price = balanceViewModel.fiatConvertationStore.prices[asset]; - amount = calculateFiatAmountRaw( - cryptoAmount: dummy!.formatterDummyAmountToDouble(amount: transaction.amount), - price: price); - break; default: break; } diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 754fff23c..85ae46155 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -3,7 +3,6 @@ import 'dart:collection'; import 'dart:convert'; import 'package:cake_wallet/core/wallet_change_listener_view_model.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart'; import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/entities/wallet_contact.dart'; @@ -280,8 +279,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with return transactionPriority == bitcoin!.getLitecoinTransactionPrioritySlow(); case WalletType.zano: return transactionPriority == monero!.getMoneroTransactionPrioritySlow(); - case WalletType.dummy: - return transactionPriority == dummy!.getDummyTransactionPrioritySlow(); default: return false; } @@ -698,11 +695,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with depositCurrency = CryptoCurrency.zano; receiveCurrency = CryptoCurrency.btc; break; - case WalletType.dummy: - // TODO: !!! - // depositCurrency = CryptoCurrency.dummy; - // receiveCurrency = ??? - throw UnimplementedError(); default: break; } @@ -789,9 +781,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with case WalletType.zano: _settingsStore.priority[wallet.type] = monero!.getMoneroTransactionPriorityAutomatic(); break; - case WalletType.dummy: - _settingsStore.priority[wallet.type] = dummy!.getDummyTransactionPriorityMedium(); - break; default: break; } diff --git a/lib/view_model/node_list/node_list_view_model.dart b/lib/view_model/node_list/node_list_view_model.dart index 8805962ce..abf97eb3e 100644 --- a/lib/view_model/node_list/node_list_view_model.dart +++ b/lib/view_model/node_list/node_list_view_model.dart @@ -69,9 +69,6 @@ abstract class NodeListViewModelBase with Store { case WalletType.zano: node = getZanoDefaultNode(nodes: _nodeSource)!; break; - case WalletType.dummy: - node = getDummyDefaultNode(nodes: _nodeSource)!; - break; default: throw Exception('Unexpected wallet type: ${_appStore.wallet!.type}'); } diff --git a/lib/view_model/send/output.dart b/lib/view_model/send/output.dart index ff2164f7f..bb451b321 100644 --- a/lib/view_model/send/output.dart +++ b/lib/view_model/send/output.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/di.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart'; import 'package:cake_wallet/entities/parse_address_from_domain.dart'; import 'package:cake_wallet/entities/parsed_address.dart'; @@ -99,9 +98,6 @@ abstract class OutputBase with Store { case WalletType.zano: _amount = zano!.formatterMoneroParseAmount(amount: _cryptoAmount); break; - case WalletType.dummy: - _amount = dummy!.formatterDummyParseAmount(amount: _cryptoAmount); - break; default: break; } @@ -143,10 +139,6 @@ abstract class OutputBase with Store { if (_wallet.type == WalletType.ethereum) { return ethereum!.formatterEthereumAmountToDouble(amount: BigInt.from(fee)); } - - if (_wallet.type == WalletType.dummy) { - return dummy!.formatterDummyAmountToDouble(amount: fee); - } } catch (e) { print(e.toString()); } @@ -256,7 +248,6 @@ abstract class OutputBase with Store { case WalletType.ethereum: maximumFractionDigits = 12; break; - case WalletType.dummy: case WalletType.zano: maximumFractionDigits = 12; break; diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 743d0f7be..1dded82b1 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/core/wallet_change_listener_view_model.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/entities/contact_record.dart'; import 'package:cake_wallet/entities/priority_for_wallet_type.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; @@ -387,12 +386,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor } return zano!.createZanoTransactionCreationCredentials( outputs: outputs, priority: priority, assetType: selectedCryptoCurrency.title); - case WalletType.dummy: - final priority = _settingsStore.priority[wallet.type]; - if (priority == null) { - throw Exception('Priority is null for wallet type: ${wallet.type}'); - } - return dummy!.createDummyTransactionCreationCredentials(outputs: outputs, priority: priority); default: throw Exception('Unexpected wallet type: ${wallet.type}'); } diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index 7a28ecef7..7d201139b 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -50,9 +50,6 @@ abstract class TransactionDetailsViewModelBase with Store { case WalletType.zano: _addZanoListItems(tx, dateFormat); break; - case WalletType.dummy: - _addDummyListItems(tx, dateFormat); - break; default: break; } @@ -124,8 +121,6 @@ abstract class TransactionDetailsViewModelBase with Store { return 'https://etherscan.io/tx/${txId}'; case WalletType.zano: return 'https://testnet-explorer.zano.org/transaction/${txId}'; - case WalletType.dummy: - return 'https://example.com/${txId}'; default: return ''; } @@ -145,8 +140,6 @@ abstract class TransactionDetailsViewModelBase with Store { return S.current.view_transaction_on + 'etherscan.io'; case WalletType.zano: return S.current.view_transaction_on + 'zano'; - case WalletType.dummy: - return S.current.view_transaction_on + 'dummy'; default: return ''; } @@ -247,16 +240,4 @@ abstract class TransactionDetailsViewModelBase with Store { StandartListItem(title: S.current.transaction_details_fee, value: tx.feeFormatted()!), ]); } - - void _addDummyListItems(TransactionInfo tx, DateFormat dateFormat) { - items.addAll([ - StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id), - StandartListItem( - title: S.current.transaction_details_date, value: dateFormat.format(tx.date)), - StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'), - StandartListItem(title: S.current.transaction_details_amount, value: tx.amountFormatted()), - if (tx.feeFormatted()?.isNotEmpty ?? false) - StandartListItem(title: S.current.transaction_details_fee, value: tx.feeFormatted()!), - ]); - } } diff --git a/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart b/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart index bb056bb5a..a4eb3d386 100644 --- a/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart +++ b/lib/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart @@ -1,4 +1,3 @@ -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart'; import 'package:mobx/mobx.dart'; import 'package:flutter/foundation.dart'; @@ -91,11 +90,6 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store { label: label); await wallet.save(); } - - if (wallet.type == WalletType.dummy) { - await dummy!.generateNewAddress(wallet); - await wallet.save(); - } } Future _update() async { diff --git a/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart b/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart index a3c1b360f..47ea05017 100644 --- a/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart +++ b/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/core/wallet_change_listener_view_model.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; @@ -125,22 +124,6 @@ class ZanoURI extends PaymentURI { } } -class DummyURI extends PaymentURI { - DummyURI({required String amount, required String address}) - : super(amount: amount, address: address); - - @override - String toString() { - var base = 'dummy:' + address; - - if (amount.isNotEmpty) { - base += '?amount=${amount.replaceAll(',', '.')}'; - } - - return base; - } -} - abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewModel with Store { WalletAddressListViewModelBase({ required AppStore appStore, @@ -214,10 +197,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo return ZanoURI(amount: amount, address: address.address); } - if (wallet.type == WalletType.dummy) { - return DummyURI(amount: amount, address: address.address); - } - throw Exception('Unexpected type: ${type.toString()}'); } @@ -274,12 +253,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress)); } - if (wallet.type == WalletType.dummy) { - final primaryAddress = dummy!.getAddress(wallet); - - addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress)); - } - return addressList; } diff --git a/lib/view_model/wallet_keys_view_model.dart b/lib/view_model/wallet_keys_view_model.dart index 0a01893cf..7a5b93062 100644 --- a/lib/view_model/wallet_keys_view_model.dart +++ b/lib/view_model/wallet_keys_view_model.dart @@ -111,13 +111,6 @@ abstract class WalletKeysViewModelBase with Store { StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!), ]); } - - if (_appStore.wallet!.type == WalletType.dummy) { - items.addAll([ - StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!), - ]); - } - } Future _currentHeight() async { @@ -147,8 +140,6 @@ abstract class WalletKeysViewModelBase with Store { return 'ethereum-wallet'; case WalletType.zano: return 'zano-wallet'; - case WalletType.dummy: - return 'dummy-wallet'; default: throw Exception('Unexpected wallet type: ${_appStore.wallet!.toString()}'); } diff --git a/lib/view_model/wallet_new_vm.dart b/lib/view_model/wallet_new_vm.dart index eec60c883..e64f086de 100644 --- a/lib/view_model/wallet_new_vm.dart +++ b/lib/view_model/wallet_new_vm.dart @@ -1,4 +1,3 @@ -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/view_model/restore/restore_wallet.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/zano/zano.dart'; @@ -49,8 +48,6 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store { return ethereum!.createEthereumNewWalletCredentials(name: name); case WalletType.zano: return zano!.createZanoNewWalletCredentials(name: name); - case WalletType.dummy: - return dummy!.createDummyNewWalletCredentials(name: name); default: throw Exception('Unexpected type: ${type.toString()}');; } diff --git a/lib/view_model/wallet_restore_view_model.dart b/lib/view_model/wallet_restore_view_model.dart index 0378e5971..fccd3443b 100644 --- a/lib/view_model/wallet_restore_view_model.dart +++ b/lib/view_model/wallet_restore_view_model.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart'; -import 'package:cake_wallet/dummy/dummy.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/zano/zano.dart'; import 'package:hive/hive.dart'; @@ -98,9 +97,6 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store { password: password, height: height, mnemonic: seed); - case WalletType.dummy: - return dummy!.createDummyRestoreWalletFromSeedCredentials( - name: name); default: break; } @@ -151,10 +147,6 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store { password: password, ); } - - if (type == WalletType.dummy) { - return dummy!.createDummyRestoreWalletFromKeyCredentials(name: name); - } } throw Exception('Unexpected type: ${type.toString()}');