This commit is contained in:
fosse 2023-07-25 16:31:52 -04:00
parent 235a47b5fd
commit 7f93f816de
8 changed files with 2149 additions and 44 deletions

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,8 @@ class CWNano extends Nano {
@override
List<String> getNanoWordList(String language) {
throw UnimplementedError();
// throw UnimplementedError();
return NanoMnemomics.WORDLIST;
}
@override
@ -29,12 +30,23 @@ class CWNano extends Nano {
WalletCredentials createNanoNewWalletCredentials({
required String name,
String? password,
}) {
return NanoNewWalletCredentials(
name: name,
password: password,
);
}
}) =>
NanoNewWalletCredentials(
name: name,
password: password,
);
@override
WalletCredentials createNanoRestoreWalletFromSeedCredentials({
required String name,
required String mnemonic,
required String password,
}) =>
NanoRestoreWalletFromSeedCredentials(
name: name,
password: password,
mnemonic: mnemonic,
);
@override
TransactionHistoryBase getTransactionHistory(Object wallet) {

View file

@ -13,6 +13,7 @@ import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/transaction_history.dart';
import 'package:cw_core/wallet_service.dart';
import 'package:hive/hive.dart';
import 'package:cw_nano/nano_mnemonic.dart';
part 'cw_nano.dart';
@ -47,6 +48,12 @@ abstract class Nano {
String password,
});
WalletCredentials createNanoRestoreWalletFromSeedCredentials({
required String name,
required String mnemonic,
required String password,
});
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
void onStartup();

View file

@ -30,7 +30,10 @@ class MenuWidgetState extends State<MenuWidget> {
this.bitcoinIcon = Image.asset('assets/images/bitcoin_menu.png'),
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.ethereumIcon = Image.asset('assets/images/eth_icon.png'),
this.nanoIcon = Image.asset('assets/images/eth_icon.png'),
this.bananoIcon = Image.asset('assets/images/eth_icon.png');
final largeScreen = 731;
@ -48,6 +51,9 @@ class MenuWidgetState extends State<MenuWidget> {
Image litecoinIcon;
Image havenIcon;
Image ethereumIcon;
Image nanoIcon;
Image bananoIcon;
@override
void initState() {
@ -217,6 +223,10 @@ class MenuWidgetState extends State<MenuWidget> {
return havenIcon;
case WalletType.ethereum:
return ethereumIcon;
case WalletType.nano:
return nanoIcon;
case WalletType.banano:
return bananoIcon;
default:
throw Exception('No icon for ${type.toString()}');
}

View file

@ -18,10 +18,9 @@ part 'wallet_restoration_from_keys_vm.g.dart';
class WalletRestorationFromKeysVM = WalletRestorationFromKeysVMBase
with _$WalletRestorationFromKeysVM;
abstract class WalletRestorationFromKeysVMBase extends WalletCreationVM
with Store {
WalletRestorationFromKeysVMBase(AppStore appStore,
WalletCreationService walletCreationService, Box<WalletInfo> walletInfoSource,
abstract class WalletRestorationFromKeysVMBase extends WalletCreationVM with Store {
WalletRestorationFromKeysVMBase(AppStore appStore, WalletCreationService walletCreationService,
Box<WalletInfo> walletInfoSource,
{required WalletType type, required this.language})
: height = 0,
viewKey = '',
@ -64,8 +63,8 @@ abstract class WalletRestorationFromKeysVMBase extends WalletCreationVM
spendKey: spendKey,
height: height);
case WalletType.bitcoin:
return bitcoin!.createBitcoinRestoreWalletFromWIFCredentials(
name: name, password: password, wif: wif);
return bitcoin!
.createBitcoinRestoreWalletFromWIFCredentials(name: name, password: password, wif: wif);
default:
throw Exception('Unexpected type: ${type.toString()}');
}

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/nano/nano.dart';
import 'package:cake_wallet/view_model/restore/restore_wallet.dart';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
@ -18,10 +19,9 @@ part 'wallet_restoration_from_seed_vm.g.dart';
class WalletRestorationFromSeedVM = WalletRestorationFromSeedVMBase
with _$WalletRestorationFromSeedVM;
abstract class WalletRestorationFromSeedVMBase extends WalletCreationVM
with Store {
WalletRestorationFromSeedVMBase(AppStore appStore,
WalletCreationService walletCreationService, Box<WalletInfo> walletInfoSource,
abstract class WalletRestorationFromSeedVMBase extends WalletCreationVM with Store {
WalletRestorationFromSeedVMBase(AppStore appStore, WalletCreationService walletCreationService,
Box<WalletInfo> walletInfoSource,
{required WalletType type, required this.language, this.seed = ''})
: height = 0,
super(appStore, walletInfoSource, walletCreationService, type: type, isRecovery: true);
@ -47,6 +47,9 @@ abstract class WalletRestorationFromSeedVMBase extends WalletCreationVM
case WalletType.bitcoin:
return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
name: name, mnemonic: seed, password: password);
case WalletType.nano:
return nano!.createNanoRestoreWalletFromSeedCredentials(
name: name, mnemonic: seed, password: password);
default:
throw Exception('Unexpected type: ${type.toString()}');
}

View file

@ -1,7 +1,5 @@
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/core/mnemonic_length.dart';
import 'package:cake_wallet/view_model/restore/restore_wallet.dart';
import 'package:flutter/foundation.dart';
import 'package:cake_wallet/nano/nano.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
@ -19,9 +17,7 @@ import 'package:cake_wallet/view_model/restore/restore_mode.dart';
part 'wallet_restore_view_model.g.dart';
class WalletRestoreViewModel = WalletRestoreViewModelBase
with _$WalletRestoreViewModel;
class WalletRestoreViewModel = WalletRestoreViewModelBase with _$WalletRestoreViewModel;
abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
WalletRestoreViewModelBase(AppStore appStore, WalletCreationService walletCreationService,
@ -35,8 +31,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
isButtonEnabled = false,
mode = WalletRestoreMode.seed,
super(appStore, walletInfoSource, walletCreationService, type: type, isRecovery: true) {
isButtonEnabled =
!hasSeedLanguageSelector && !hasBlockchainHeightLanguageSelector;
isButtonEnabled = !hasSeedLanguageSelector && !hasBlockchainHeightLanguageSelector;
walletCreationService.changeWalletType(type: type);
}
@ -53,7 +48,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
@observable
bool isButtonEnabled;
@override
WalletCredentials getCredentials(dynamic options) {
final password = generateWalletPassword();
@ -66,31 +61,22 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
switch (type) {
case WalletType.monero:
return monero!.createMoneroRestoreWalletFromSeedCredentials(
name: name,
height: height,
mnemonic: seed,
password: password);
name: name, height: height, mnemonic: seed, password: password);
case WalletType.bitcoin:
return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
password: password);
name: name, mnemonic: seed, password: password);
case WalletType.litecoin:
return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
password: password);
name: name, mnemonic: seed, password: password);
case WalletType.haven:
return haven!.createHavenRestoreWalletFromSeedCredentials(
name: name,
height: height,
mnemonic: seed,
password: password);
name: name, height: height, mnemonic: seed, password: password);
case WalletType.ethereum:
return ethereum!.createEthereumRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
password: password);
name: name, mnemonic: seed, password: password);
case WalletType.nano:
return nano!.createNanoRestoreWalletFromSeedCredentials(
name: name, mnemonic: seed, password: password);
default:
break;
}

View file

@ -604,6 +604,12 @@ abstract class Nano {
required String name,
String password,
});
WalletCredentials createNanoRestoreWalletFromSeedCredentials({
required String name,
required String mnemonic,
required String password,
});
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);