mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
added dummy wallet & some zano implementation
This commit is contained in:
parent
7a00a5df95
commit
219f43a959
55 changed files with 1053 additions and 15 deletions
|
@ -200,6 +200,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> 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/dummy_icon.png');
|
||||
|
||||
|
||||
static final Map<int, CryptoCurrency> _rawCurrencyMap =
|
||||
|
|
|
@ -15,6 +15,8 @@ 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');
|
||||
|
|
|
@ -80,6 +80,8 @@ 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');
|
||||
}
|
||||
|
@ -133,6 +135,8 @@ class Node extends HiveObject with Keyable {
|
|||
return requestMoneroNode();
|
||||
case WalletType.ethereum:
|
||||
return requestElectrumServer();
|
||||
case WalletType.dummy:
|
||||
throw UnimplementedError();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ const walletTypes = [
|
|||
WalletType.haven,
|
||||
WalletType.ethereum,
|
||||
WalletType.zano,
|
||||
WalletType.dummy,
|
||||
];
|
||||
|
||||
@HiveType(typeId: WALLET_TYPE_TYPE_ID)
|
||||
|
@ -35,6 +36,9 @@ enum WalletType {
|
|||
|
||||
@HiveField(6)
|
||||
zano,
|
||||
|
||||
@HiveField(7)
|
||||
dummy,
|
||||
}
|
||||
|
||||
int serializeToInt(WalletType type) {
|
||||
|
@ -51,6 +55,8 @@ int serializeToInt(WalletType type) {
|
|||
return 4;
|
||||
case WalletType.zano:
|
||||
return 5;
|
||||
case WalletType.dummy:
|
||||
return 6;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -70,6 +76,8 @@ 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');
|
||||
|
@ -90,6 +98,8 @@ String walletTypeToString(WalletType type) {
|
|||
return 'Ethereum';
|
||||
case WalletType.zano:
|
||||
return 'Zano';
|
||||
case WalletType.dummy:
|
||||
return 'Dummy';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@ -109,6 +119,8 @@ String walletTypeToDisplayName(WalletType type) {
|
|||
return 'Ethereum (ETH)';
|
||||
case WalletType.zano:
|
||||
return 'Zano (ZANO)';
|
||||
case WalletType.dummy:
|
||||
return 'Dummy (DUMMY)';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@ -128,6 +140,8 @@ 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');
|
||||
|
|
30
cw_dummy/.gitignore
vendored
Normal file
30
cw_dummy/.gitignore
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
# 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/
|
10
cw_dummy/.metadata
Normal file
10
cw_dummy/.metadata
Normal file
|
@ -0,0 +1,10 @@
|
|||
# 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
|
3
cw_dummy/CHANGELOG.md
Normal file
3
cw_dummy/CHANGELOG.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
1
cw_dummy/LICENSE
Normal file
1
cw_dummy/LICENSE
Normal file
|
@ -0,0 +1 @@
|
|||
TODO: Add your license here.
|
39
cw_dummy/README.md
Normal file
39
cw_dummy/README.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/developing-packages).
|
||||
-->
|
||||
|
||||
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.
|
4
cw_dummy/analysis_options.yaml
Normal file
4
cw_dummy/analysis_options.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
7
cw_dummy/lib/cw_dummy.dart
Normal file
7
cw_dummy/lib/cw_dummy.dart
Normal file
|
@ -0,0 +1,7 @@
|
|||
library cw_dummy;
|
||||
|
||||
/// A Calculator.
|
||||
class Calculator {
|
||||
/// Returns [value] plus 1.
|
||||
int addOne(int value) => value + 1;
|
||||
}
|
14
cw_dummy/lib/dummy_balance.dart
Normal file
14
cw_dummy/lib/dummy_balance.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
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();
|
||||
|
||||
}
|
10
cw_dummy/lib/dummy_transaction_creation_credentials.dart
Normal file
10
cw_dummy/lib/dummy_transaction_creation_credentials.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
import 'package:cw_core/output_info.dart';
|
||||
|
||||
import 'dummy_transaction_priority.dart';
|
||||
|
||||
class DummyTransactionCreationCredentials {
|
||||
final List<OutputInfo> outputs;
|
||||
final DummyTransactionPriority? priority;
|
||||
|
||||
DummyTransactionCreationCredentials({required this.outputs, this.priority});
|
||||
}
|
28
cw_dummy/lib/dummy_transaction_history.dart
Normal file
28
cw_dummy/lib/dummy_transaction_history.dart
Normal file
|
@ -0,0 +1,28 @@
|
|||
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<DummyTransactionInfo> with Store {
|
||||
DummyTransactionHistoryBase() {
|
||||
transactions = ObservableMap<String, DummyTransactionInfo>();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save() async {
|
||||
throw UnimplementedError;
|
||||
}
|
||||
|
||||
@override
|
||||
void addOne(DummyTransactionInfo transaction) => transactions[transaction.id] = transaction;
|
||||
|
||||
@override
|
||||
void addMany(Map<String, DummyTransactionInfo> transactions) =>
|
||||
this.transactions.addAll(transactions);
|
||||
}
|
27
cw_dummy/lib/dummy_transaction_info.dart
Normal file
27
cw_dummy/lib/dummy_transaction_info.dart
Normal file
|
@ -0,0 +1,27 @@
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
20
cw_dummy/lib/dummy_transaction_priority.dart
Normal file
20
cw_dummy/lib/dummy_transaction_priority.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
import 'package:cw_core/transaction_priority.dart';
|
||||
|
||||
class DummyTransactionPriority extends TransactionPriority {
|
||||
const DummyTransactionPriority({required super.title, required super.raw});
|
||||
|
||||
static const List<DummyTransactionPriority> 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');
|
||||
}
|
||||
}
|
||||
}
|
72
cw_dummy/lib/dummy_wallet.dart
Normal file
72
cw_dummy/lib/dummy_wallet.dart
Normal file
|
@ -0,0 +1,72 @@
|
|||
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<DummyBalance,
|
||||
DummyTransactionHistory, DummyTransactionInfo> with Store {
|
||||
DummyWalletBase({required WalletInfo walletInfo}) : super(walletInfo) {}
|
||||
|
||||
@override
|
||||
int calculateEstimatedFee(TransactionPriority priority, int? amount) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> changePassword(String password) async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> close() async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> connectToNode({required Node node}) async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<PendingTransaction> createTransaction(Object credentials) async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<Map<String, DummyTransactionInfo>> fetchTransactions() async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> renameWalletFiles(String newWalletName) async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> rescan({required int height}) async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> save() async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> startSync() async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void>? updateBalance() => null;
|
||||
|
||||
@override
|
||||
@observable
|
||||
late ObservableMap<CryptoCurrency, DummyBalance> balance;
|
||||
|
||||
@override
|
||||
Object get keys => throw UnimplementedError("keys");
|
||||
|
||||
@override
|
||||
String get seed => "seed";
|
||||
|
||||
@override
|
||||
@observable
|
||||
late SyncStatus syncStatus;
|
||||
|
||||
@override
|
||||
late DummyWalletAddresses walletAddresses;
|
||||
}
|
23
cw_dummy/lib/dummy_wallet_addresses.dart
Normal file
23
cw_dummy/lib/dummy_wallet_addresses.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
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<void> init() async => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> updateAddressesInBox() async => throw UnimplementedError();
|
||||
|
||||
// TODO: from electrum wallet addresses implementation
|
||||
Future<void> generateNewAddress() async => throw UnimplementedError();
|
||||
}
|
18
cw_dummy/lib/dummy_wallet_creation_credentials.dart
Normal file
18
cw_dummy/lib/dummy_wallet_creation_credentials.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
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);
|
||||
}
|
||||
|
40
cw_dummy/lib/dummy_wallet_service.dart
Normal file
40
cw_dummy/lib/dummy_wallet_service.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
import 'package:cw_core/balance.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_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<DummyNewWalletCredentials, DummyRestoreWalletFromSeedCredentials, DummyRestoreWalletFromKeyCredentials> {
|
||||
DummyWalletService(this.walletInfoSource);
|
||||
|
||||
final Box<WalletInfo> walletInfoSource;
|
||||
|
||||
@override
|
||||
Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> create(DummyNewWalletCredentials credentials) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
WalletType getType() => WalletType.dummy;
|
||||
|
||||
@override
|
||||
Future<bool> isWalletExit(String name) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> openWallet(String name, String password) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> remove(String wallet) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> rename(String currentName, String password, String newName) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> restoreFromKeys(DummyRestoreWalletFromKeyCredentials credentials) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> restoreFromSeed(DummyRestoreWalletFromSeedCredentials credentials) => throw UnimplementedError();
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
/home/leo/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/
|
11
cw_dummy/linux/flutter/generated_plugin_registrant.cc
Normal file
11
cw_dummy/linux/flutter/generated_plugin_registrant.cc
Normal file
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
}
|
15
cw_dummy/linux/flutter/generated_plugin_registrant.h
Normal file
15
cw_dummy/linux/flutter/generated_plugin_registrant.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void fl_register_plugins(FlPluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
23
cw_dummy/linux/flutter/generated_plugins.cmake
Normal file
23
cw_dummy/linux/flutter/generated_plugins.cmake
Normal file
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# 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 $<TARGET_FILE:${plugin}_plugin>)
|
||||
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)
|
12
cw_dummy/macos/Flutter/GeneratedPluginRegistrant.swift
Normal file
12
cw_dummy/macos/Flutter/GeneratedPluginRegistrant.swift
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import path_provider_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
}
|
11
cw_dummy/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Normal file
11
cw_dummy/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Normal file
|
@ -0,0 +1,11 @@
|
|||
// 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
|
12
cw_dummy/macos/Flutter/ephemeral/flutter_export_environment.sh
Executable file
12
cw_dummy/macos/Flutter/ephemeral/flutter_export_environment.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/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"
|
67
cw_dummy/pubspec.yaml
Normal file
67
cw_dummy/pubspec.yaml
Normal file
|
@ -0,0 +1,67 @@
|
|||
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
|
||||
|
||||
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
|
12
cw_dummy/test/cw_dummy_test.dart
Normal file
12
cw_dummy/test/cw_dummy_test.dart
Normal file
|
@ -0,0 +1,12 @@
|
|||
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);
|
||||
});
|
||||
}
|
11
cw_dummy/windows/flutter/generated_plugin_registrant.cc
Normal file
11
cw_dummy/windows/flutter/generated_plugin_registrant.cc
Normal file
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
}
|
15
cw_dummy/windows/flutter/generated_plugin_registrant.h
Normal file
15
cw_dummy/windows/flutter/generated_plugin_registrant.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter/plugin_registry.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
23
cw_dummy/windows/flutter/generated_plugins.cmake
Normal file
23
cw_dummy/windows/flutter/generated_plugins.cmake
Normal file
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# 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 $<TARGET_FILE:${plugin}_plugin>)
|
||||
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)
|
|
@ -15,14 +15,17 @@ void __clear_cache(void* start, void* end) { }
|
|||
#endif
|
||||
|
||||
#include "plain_wallet_api.h"
|
||||
#include "plain_wallet_api_ex.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
//using namespace std::chrono_literals;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
const uint64_t MONERO_BLOCK_SIZE = 1000;
|
||||
//const uint64_t MONERO_BLOCK_SIZE = 1000;
|
||||
|
||||
struct Utf8Box
|
||||
{
|
||||
|
@ -61,19 +64,19 @@ extern "C"
|
|||
}
|
||||
};
|
||||
|
||||
struct HavenBalance
|
||||
struct ZanoBalance
|
||||
{
|
||||
uint64_t amount;
|
||||
char *assetType;
|
||||
|
||||
HavenBalance(char *_assetType, uint64_t _amount)
|
||||
ZanoBalance(char *_assetType, uint64_t _amount)
|
||||
{
|
||||
amount = _amount;
|
||||
assetType = _assetType;
|
||||
}
|
||||
};
|
||||
|
||||
struct HavenRate
|
||||
struct ZanoRate
|
||||
{
|
||||
uint64_t rate;
|
||||
char *assetType;
|
||||
|
@ -85,7 +88,7 @@ extern "C"
|
|||
}
|
||||
};
|
||||
|
||||
struct MoneroWalletListener : Monero::WalletListener
|
||||
/*struct MoneroWalletListener : Monero::WalletListener
|
||||
{
|
||||
uint64_t m_height;
|
||||
bool m_need_to_refresh;
|
||||
|
@ -153,6 +156,7 @@ extern "C"
|
|||
return m_height;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
struct TransactionInfoRow
|
||||
{
|
||||
|
@ -171,9 +175,9 @@ extern "C"
|
|||
|
||||
int64_t datetime;
|
||||
|
||||
TransactionInfoRow(Monero::TransactionInfo *transaction)
|
||||
TransactionInfoRow(wallet_public::wallet_transfer_info& wti)
|
||||
{
|
||||
amount = transaction->amount();
|
||||
amount = wti.subtransfers.
|
||||
fee = transaction->fee();
|
||||
blockHeight = transaction->blockHeight();
|
||||
subaddrAccount = transaction->subaddrAccount();
|
||||
|
@ -187,6 +191,7 @@ extern "C"
|
|||
hash = strdup(hash_str->c_str());
|
||||
paymentId = strdup(transaction->paymentId().c_str());
|
||||
assetType = strdup(transaction->assetType().c_str());
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
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';
|
||||
|
@ -32,6 +33,8 @@ class SeedValidator extends Validator<MnemonicItem> {
|
|||
return zano!.getMoneroWordList(language);
|
||||
case WalletType.ethereum:
|
||||
return ethereum!.getEthereumWordList(language);
|
||||
case WalletType.dummy:
|
||||
return dummy!.getDummyWordList();
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ 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';
|
||||
|
@ -792,6 +793,9 @@ Future<void> setup({
|
|||
return ethereum!.createEthereumWalletService(_walletInfoSource);
|
||||
case WalletType.zano:
|
||||
return zano!.createZanoWalletService(_walletInfoSource);
|
||||
case WalletType.dummy:
|
||||
return dummy!.createDummyWalletService(_walletInfoSource);
|
||||
|
||||
default:
|
||||
throw Exception(
|
||||
'Unexpected token: ${param1.toString()} for generating of WalletService');
|
||||
|
|
83
lib/dummy/cw_dummy.dart
Normal file
83
lib/dummy/cw_dummy.dart
Normal file
|
@ -0,0 +1,83 @@
|
|||
part of 'dummy.dart';
|
||||
|
||||
class CWDummy extends Dummy {
|
||||
@override
|
||||
List<String> getDummyWordList() => ["aaa", "bbb", "ccc"];
|
||||
|
||||
@override
|
||||
WalletService createDummyWalletService(Box<WalletInfo> 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<TransactionPriority> 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<Output> 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<void> generateNewAddress(Object wallet) async {
|
||||
final dummyWallet = wallet as DummyWallet;
|
||||
await dummyWallet.walletAddresses.generateNewAddress();
|
||||
}
|
||||
|
||||
@override
|
||||
String getAddress(WalletBase wallet) => (wallet as DummyWallet).walletAddresses.address;
|
||||
}
|
42
lib/dummy/dummy.dart
Normal file
42
lib/dummy/dummy.dart
Normal file
|
@ -0,0 +1,42 @@
|
|||
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<WalletInfo> walletInfoSource);
|
||||
TransactionPriority deserializeDummyTransactionPriority(int raw);
|
||||
List<String> getDummyWordList();
|
||||
List<TransactionPriority> 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<Output> outputs, required TransactionPriority priority});
|
||||
Future<void> generateNewAddress(Object wallet);
|
||||
String getAddress(WalletBase wallet);
|
||||
}
|
|
@ -27,6 +27,7 @@ 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<void> defaultSettingsMigration(
|
||||
{required int version,
|
||||
|
@ -317,6 +318,18 @@ Node? getEthereumDefaultNode({required Box<Node> nodes}) {
|
|||
?? nodes.values.firstWhereOrNull((node) => node.type == WalletType.ethereum);
|
||||
}
|
||||
|
||||
Node? getZanoDefaultNode({required Box<Node> nodes}) {
|
||||
return nodes.values.firstWhereOrNull(
|
||||
(Node node) => node.uriRaw == zanoDefaultNodeUri)
|
||||
?? nodes.values.firstWhereOrNull((node) => node.type == WalletType.zano);
|
||||
}
|
||||
|
||||
Node? getDummyDefaultNode({required Box<Node> nodes}) {
|
||||
return nodes.values.firstWhereOrNull(
|
||||
(Node node) => node.uriRaw == dummyDefaultNodeUri)
|
||||
?? nodes.values.firstWhereOrNull((node) => node.type == WalletType.dummy);
|
||||
}
|
||||
|
||||
Node getMoneroDefaultNode({required Box<Node> nodes}) {
|
||||
final timeZone = DateTime.now().timeZoneOffset.inHours;
|
||||
var nodeUri = '';
|
||||
|
@ -517,6 +530,8 @@ Future<void> 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(
|
||||
|
@ -528,6 +543,7 @@ Future<void> 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 =
|
||||
|
@ -575,6 +591,13 @@ Future<void> 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<void> resetBitcoinElectrumServer(
|
||||
|
|
|
@ -6,6 +6,7 @@ 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';
|
||||
|
@ -35,6 +36,8 @@ class PreferencesKey {
|
|||
static const havenTransactionPriority = 'current_fee_priority_haven';
|
||||
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';
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
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';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
||||
|
@ -17,6 +19,10 @@ List<TransactionPriority> priorityForWalletType(WalletType type) {
|
|||
return haven!.getTransactionPriorities();
|
||||
case WalletType.ethereum:
|
||||
return ethereum!.getTransactionPriorities();
|
||||
case WalletType.zano:
|
||||
return zano!.getTransactionPriorities();
|
||||
case WalletType.dummy:
|
||||
return dummy!.getTransactionPriorities();
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
|
|||
final litecoinIcon = Image.asset('assets/images/litecoin_icon.png', height: 24, width: 24);
|
||||
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/dummy_icon.png', height: 24, width: 24);
|
||||
final nonWalletTypeIcon = Image.asset('assets/images/close.png', height: 24, width: 24);
|
||||
|
||||
Image _newWalletImage(BuildContext context) => Image.asset(
|
||||
|
@ -141,6 +143,10 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
|
|||
return havenIcon;
|
||||
case WalletType.ethereum:
|
||||
return ethereumIcon;
|
||||
case WalletType.zano:
|
||||
return zanoIcon;
|
||||
case WalletType.dummy:
|
||||
return dummyIcon;
|
||||
default:
|
||||
return nonWalletTypeIcon;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
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.zanoIcon = Image.asset('assets/images/zano_icon.png'),
|
||||
this.dummyIcon = Image.asset('assets/images/dummy_icon.png');
|
||||
|
||||
final largeScreen = 731;
|
||||
|
||||
|
@ -49,6 +50,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
Image havenIcon;
|
||||
Image ethereumIcon;
|
||||
Image zanoIcon;
|
||||
Image dummyIcon;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -210,6 +212,8 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
return ethereumIcon;
|
||||
case WalletType.zano:
|
||||
return zanoIcon;
|
||||
case WalletType.dummy:
|
||||
return dummyIcon;
|
||||
default:
|
||||
throw Exception('No icon for ${type.toString()}');
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ class WalletListBodyState extends State<WalletListBody> {
|
|||
final nonWalletTypeIcon = Image.asset('assets/images/close.png', height: 24, width: 24);
|
||||
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/dummy_icon.png', height: 24, width: 24);
|
||||
final scrollController = ScrollController();
|
||||
final double tileHeight = 60;
|
||||
Flushbar<void>? _progressBar;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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';
|
||||
|
@ -12,6 +13,7 @@ import 'package:cake_wallet/entities/sort_balance_types.dart';
|
|||
import 'package:cake_wallet/view_model/settings/sync_mode.dart';
|
||||
import 'package:cake_wallet/utils/device_info.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/themes/theme_list.dart';
|
||||
|
@ -84,7 +86,10 @@ abstract class SettingsStoreBase with Store {
|
|||
TransactionPriority? initialMoneroTransactionPriority,
|
||||
TransactionPriority? initialHavenTransactionPriority,
|
||||
TransactionPriority? initialLitecoinTransactionPriority,
|
||||
TransactionPriority? initialEthereumTransactionPriority})
|
||||
TransactionPriority? initialEthereumTransactionPriority,
|
||||
TransactionPriority? initialZanoTransactionPriority,
|
||||
TransactionPriority? initialDummyTransactionPriority,
|
||||
})
|
||||
: nodes = ObservableMap<WalletType, Node>.of(nodes),
|
||||
_sharedPreferences = sharedPreferences,
|
||||
_backgroundTasks = backgroundTasks,
|
||||
|
@ -144,6 +149,14 @@ abstract class SettingsStoreBase with Store {
|
|||
priority[WalletType.ethereum] = initialEthereumTransactionPriority;
|
||||
}
|
||||
|
||||
if (initialZanoTransactionPriority != null) {
|
||||
priority[WalletType.zano] = initialZanoTransactionPriority;
|
||||
}
|
||||
|
||||
if (initialDummyTransactionPriority != null) {
|
||||
priority[WalletType.dummy] = initialDummyTransactionPriority;
|
||||
}
|
||||
|
||||
reaction(
|
||||
(_) => fiatCurrency,
|
||||
(FiatCurrency fiatCurrency) => sharedPreferences.setString(
|
||||
|
@ -172,6 +185,12 @@ abstract class SettingsStoreBase with Store {
|
|||
case WalletType.ethereum:
|
||||
key = PreferencesKey.ethereumTransactionPriority;
|
||||
break;
|
||||
case WalletType.zano:
|
||||
key = PreferencesKey.zanoTransactionPriority;
|
||||
break;
|
||||
case WalletType.dummy:
|
||||
key = PreferencesKey.dummyTransactionPriority;
|
||||
break;
|
||||
default:
|
||||
key = null;
|
||||
}
|
||||
|
@ -518,6 +537,8 @@ abstract class SettingsStoreBase with Store {
|
|||
TransactionPriority? havenTransactionPriority;
|
||||
TransactionPriority? litecoinTransactionPriority;
|
||||
TransactionPriority? ethereumTransactionPriority;
|
||||
TransactionPriority? zanoTransactionPriority;
|
||||
TransactionPriority? dummyTransactionPriority;
|
||||
|
||||
if (sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) {
|
||||
havenTransactionPriority = monero?.deserializeMoneroTransactionPriority(
|
||||
|
@ -531,12 +552,22 @@ abstract class SettingsStoreBase with Store {
|
|||
ethereumTransactionPriority = bitcoin?.deserializeLitecoinTransactionPriority(
|
||||
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority)!);
|
||||
}
|
||||
if (sharedPreferences.getInt(PreferencesKey.zanoTransactionPriority) != null) {
|
||||
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();
|
||||
havenTransactionPriority ??= monero?.getDefaultTransactionPriority();
|
||||
litecoinTransactionPriority ??= bitcoin?.getLitecoinTransactionPriorityMedium();
|
||||
ethereumTransactionPriority ??= ethereum?.getDefaultTransactionPriority();
|
||||
zanoTransactionPriority ??= zano?.getDefaultTransactionPriority();
|
||||
dummyTransactionPriority ??= dummy?.getDefaultTransactionPriority();
|
||||
|
||||
final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
|
||||
raw: sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey)!);
|
||||
|
@ -619,15 +650,14 @@ abstract class SettingsStoreBase with Store {
|
|||
final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey);
|
||||
final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey);
|
||||
final zanoNodeId = sharedPreferences.getInt(PreferencesKey.currentZanoNodeIdKey);
|
||||
//final zanoNodeId = 9;
|
||||
debugPrint("zanoNodeId $zanoNodeId");
|
||||
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);
|
||||
debugPrint("zanoNode $zanoNode");
|
||||
final dummyNode = nodeSource.get(dummyNodeId);
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
final deviceName = await _getDeviceName() ?? '';
|
||||
final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
|
||||
|
@ -663,6 +693,10 @@ 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);
|
||||
});
|
||||
|
@ -702,6 +736,8 @@ abstract class SettingsStoreBase with Store {
|
|||
initialBitcoinTransactionPriority: bitcoinTransactionPriority,
|
||||
initialHavenTransactionPriority: havenTransactionPriority,
|
||||
initialLitecoinTransactionPriority: litecoinTransactionPriority,
|
||||
initialZanoTransactionPriority: zanoTransactionPriority,
|
||||
initialDummyTransactionPriority: dummyTransactionPriority,
|
||||
initialShouldRequireTOTP2FAForAccessingWallet: shouldRequireTOTP2FAForAccessingWallet,
|
||||
initialShouldRequireTOTP2FAForSendsToContact: shouldRequireTOTP2FAForSendsToContact,
|
||||
initialShouldRequireTOTP2FAForSendsToNonContact: shouldRequireTOTP2FAForSendsToNonContact,
|
||||
|
@ -748,6 +784,16 @@ abstract class SettingsStoreBase with Store {
|
|||
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority)!) ??
|
||||
priority[WalletType.ethereum]!;
|
||||
}
|
||||
if (sharedPreferences.getInt(PreferencesKey.zanoTransactionPriority) != null) {
|
||||
priority[WalletType.zano] = zano?.deserializeMoneroTransactionPriority(
|
||||
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);
|
||||
|
@ -835,6 +881,7 @@ 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);
|
||||
|
@ -842,6 +889,7 @@ 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;
|
||||
|
@ -866,6 +914,10 @@ abstract class SettingsStoreBase with Store {
|
|||
if (zanoNode != null) {
|
||||
nodes[WalletType.zano] = zanoNode;
|
||||
}
|
||||
|
||||
if (dummyNode != null) {
|
||||
nodes[WalletType.dummy] = dummyNode;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
||||
|
@ -890,6 +942,9 @@ 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;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
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';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/transaction_direction.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
|
@ -92,6 +94,20 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
cryptoAmount: ethereum!.formatterEthereumAmountToDouble(transaction: transaction),
|
||||
price: price);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
final asset = zano!.assetOfTransaction(transaction);
|
||||
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
||||
amount = calculateFiatAmountRaw(
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ 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';
|
||||
|
@ -277,6 +278,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
|||
return transactionPriority == bitcoin!.getBitcoinTransactionPrioritySlow();
|
||||
case WalletType.litecoin:
|
||||
return transactionPriority == bitcoin!.getLitecoinTransactionPrioritySlow();
|
||||
case WalletType.zano:
|
||||
return transactionPriority == monero!.getMoneroTransactionPrioritySlow();
|
||||
case WalletType.dummy:
|
||||
return transactionPriority == dummy!.getDummyTransactionPrioritySlow();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -689,6 +694,16 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
|||
depositCurrency = CryptoCurrency.eth;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.zano:
|
||||
// TODO: !!!
|
||||
// depositCurrency = CryptoCurrency.zano;
|
||||
// receiveCurrency = ???
|
||||
throw UnimplementedError();
|
||||
case WalletType.dummy:
|
||||
// TODO: !!!
|
||||
// depositCurrency = CryptoCurrency.dummy;
|
||||
// receiveCurrency = ???
|
||||
throw UnimplementedError();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -772,6 +787,12 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
|||
case WalletType.litecoin:
|
||||
_settingsStore.priority[wallet.type] = bitcoin!.getLitecoinTransactionPriorityMedium();
|
||||
break;
|
||||
case WalletType.zano:
|
||||
_settingsStore.priority[wallet.type] = monero!.getMoneroTransactionPriorityAutomatic();
|
||||
break;
|
||||
case WalletType.dummy:
|
||||
_settingsStore.priority[wallet.type] = dummy!.getDummyTransactionPriorityMedium();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,12 @@ abstract class NodeListViewModelBase with Store {
|
|||
case WalletType.ethereum:
|
||||
node = getEthereumDefaultNode(nodes: _nodeSource)!;
|
||||
break;
|
||||
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}');
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
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';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
@ -94,6 +96,12 @@ abstract class OutputBase with Store {
|
|||
case WalletType.ethereum:
|
||||
_amount = ethereum!.formatterEthereumParseAmount(_cryptoAmount);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
_amount = zano!.formatterMoneroParseAmount(amount: _cryptoAmount);
|
||||
break;
|
||||
case WalletType.dummy:
|
||||
_amount = dummy!.formatterDummyParseAmount(amount: _cryptoAmount);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -128,9 +136,17 @@ abstract class OutputBase with Store {
|
|||
return haven!.formatterMoneroAmountToDouble(amount: fee);
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.zano) {
|
||||
return zano!.formatterMoneroAmountToDouble(amount: fee);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -240,6 +256,10 @@ abstract class OutputBase with Store {
|
|||
case WalletType.ethereum:
|
||||
maximumFractionDigits = 12;
|
||||
break;
|
||||
case WalletType.dummy:
|
||||
case WalletType.zano:
|
||||
// TODO: enter correct values
|
||||
throw UnimplementedError();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
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';
|
||||
|
@ -6,6 +7,7 @@ import 'package:cake_wallet/entities/wallet_contact.dart';
|
|||
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_template_view_model.dart';
|
||||
|
@ -378,6 +380,19 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
|||
|
||||
return ethereum!.createEthereumTransactionCredentials(outputs,
|
||||
priority: priority, currency: selectedCryptoCurrency);
|
||||
case WalletType.zano:
|
||||
final priority = _settingsStore.priority[wallet.type];
|
||||
if (priority == null) {
|
||||
throw Exception('Priority is null for wallet type: ${wallet.type}');
|
||||
}
|
||||
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}');
|
||||
}
|
||||
|
|
|
@ -47,6 +47,12 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
case WalletType.ethereum:
|
||||
_addEthereumListItems(tx, dateFormat);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
_addZanoListItems(tx, dateFormat);
|
||||
break;
|
||||
case WalletType.dummy:
|
||||
_addDummyListItems(tx, dateFormat);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -116,6 +122,10 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
return 'https://explorer.havenprotocol.org/search?value=${txId}';
|
||||
case WalletType.ethereum:
|
||||
return 'https://etherscan.io/tx/${txId}';
|
||||
case WalletType.zano:
|
||||
return 'https://example.com/${txId}';
|
||||
case WalletType.dummy:
|
||||
return 'https://example.com/${txId}';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@ -133,6 +143,10 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
return S.current.view_transaction_on + 'explorer.havenprotocol.org';
|
||||
case WalletType.ethereum:
|
||||
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 '';
|
||||
}
|
||||
|
@ -221,4 +235,28 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
|
||||
items.addAll(_items);
|
||||
}
|
||||
|
||||
void _addZanoListItems(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()!),
|
||||
]);
|
||||
}
|
||||
|
||||
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()!),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
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';
|
||||
|
@ -90,6 +91,11 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store {
|
|||
label: label);
|
||||
await wallet.save();
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.dummy) {
|
||||
await dummy!.generateNewAddress(wallet);
|
||||
await wallet.save();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _update() async {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
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';
|
||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/currency.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
@ -107,6 +109,38 @@ class EthereumURI extends PaymentURI {
|
|||
}
|
||||
}
|
||||
|
||||
class ZanoURI extends PaymentURI {
|
||||
ZanoURI({required String amount, required String address})
|
||||
: super(amount: amount, address: address);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
var base = 'zano:' + address;
|
||||
|
||||
if (amount.isNotEmpty) {
|
||||
base += '?amount=${amount.replaceAll(',', '.')}';
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -176,6 +210,14 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
|||
return EthereumURI(amount: amount, address: address.address);
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.zano) {
|
||||
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()}');
|
||||
}
|
||||
|
||||
|
@ -232,6 +274,12 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/transaction_direction.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
@ -104,6 +105,19 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_appStore.wallet!.type == WalletType.zano) {
|
||||
items.addAll([
|
||||
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<int?> _currentHeight() async {
|
||||
|
@ -113,6 +127,9 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
if (_appStore.wallet!.type == WalletType.monero) {
|
||||
return monero_wallet.getCurrentHeight();
|
||||
}
|
||||
if (_appStore.wallet!.type == WalletType.zano) {
|
||||
return await zano!.getCurrentHeight();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -128,6 +145,10 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
return 'haven-wallet';
|
||||
case WalletType.ethereum:
|
||||
return 'ethereum-wallet';
|
||||
case WalletType.zano:
|
||||
return 'zano-wallet';
|
||||
case WalletType.dummy:
|
||||
return 'dummy-wallet';
|
||||
default:
|
||||
throw Exception('Unexpected wallet type: ${_appStore.wallet!.toString()}');
|
||||
}
|
||||
|
@ -172,6 +193,8 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
return monero!.getHeigthByDate(date: date);
|
||||
} else if (type == WalletType.haven) {
|
||||
return haven!.getHeightByDate(date: date);
|
||||
} else if (type == WalletType.zano) {
|
||||
return zano!.getHeightByDate(date: date);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
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,6 +50,8 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
|||
case WalletType.zano:
|
||||
return zano!.createZanoNewWalletCredentials(
|
||||
name: name, language: "en");
|
||||
case WalletType.dummy:
|
||||
return dummy!.createDummyNewWalletCredentials(name: name);
|
||||
default:
|
||||
throw Exception('Unexpected type: ${type.toString()}');;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
|
@ -90,6 +92,15 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
name: name,
|
||||
mnemonic: seed,
|
||||
password: password);
|
||||
case WalletType.zano:
|
||||
return zano!.createZanoRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
password: password,
|
||||
height: height,
|
||||
mnemonic: seed);
|
||||
case WalletType.dummy:
|
||||
return dummy!.createDummyRestoreWalletFromSeedCredentials(
|
||||
name: name);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -122,6 +133,17 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
language: 'English');
|
||||
}
|
||||
|
||||
if (type == WalletType.zano) {
|
||||
return zano!.createZanoRestoreWalletFromKeysCredentials(
|
||||
name: name,
|
||||
height: height,
|
||||
spendKey: spendKey!,
|
||||
viewKey: viewKey!,
|
||||
address: address!,
|
||||
password: password,
|
||||
language: 'English');
|
||||
}
|
||||
|
||||
if (type == WalletType.ethereum) {
|
||||
return ethereum!.createEthereumRestoreWalletFromPrivateKey(
|
||||
name: name,
|
||||
|
@ -129,6 +151,10 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
password: password,
|
||||
);
|
||||
}
|
||||
|
||||
if (type == WalletType.dummy) {
|
||||
return dummy!.createDummyRestoreWalletFromKeyCredentials(name: name);
|
||||
}
|
||||
}
|
||||
|
||||
throw Exception('Unexpected type: ${type.toString()}');
|
||||
|
|
Loading…
Reference in a new issue