mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
more fixes
This commit is contained in:
parent
6a63e08e74
commit
a15a1053a4
5 changed files with 23 additions and 16 deletions
|
@ -250,7 +250,7 @@ Node? getEthereumDefaultNode({required Box<Node> nodes}) {
|
|||
|
||||
Node? getNanoDefaultNode({required Box<Node> nodes}) {
|
||||
return nodes.values.firstWhereOrNull((Node node) => node.uriRaw == nanoDefaultNodeUri) ??
|
||||
nodes.values.firstWhereOrNull((node) => node.type == WalletType.ethereum);
|
||||
nodes.values.firstWhereOrNull((node) => node.type == WalletType.nano);
|
||||
}
|
||||
|
||||
Node getMoneroDefaultNode({required Box<Node> nodes}) {
|
||||
|
@ -430,6 +430,7 @@ Future<void> checkCurrentNodes(Box<Node> nodeSource, SharedPreferences sharedPre
|
|||
sharedPreferences.getInt(PreferencesKey.currentLitecoinElectrumSererIdKey);
|
||||
final currentHavenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey);
|
||||
final currentEthereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey);
|
||||
final currentNanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
|
||||
final currentMoneroNode =
|
||||
nodeSource.values.firstWhereOrNull((node) => node.key == currentMoneroNodeId);
|
||||
final currentBitcoinElectrumServer =
|
||||
|
@ -440,6 +441,8 @@ Future<void> checkCurrentNodes(Box<Node> nodeSource, SharedPreferences sharedPre
|
|||
nodeSource.values.firstWhereOrNull((node) => node.key == currentHavenNodeId);
|
||||
final currentEthereumNodeServer =
|
||||
nodeSource.values.firstWhereOrNull((node) => node.key == currentEthereumNodeId);
|
||||
final currentNanoNodeServer =
|
||||
nodeSource.values.firstWhereOrNull((node) => node.key == currentNanoNodeId);
|
||||
|
||||
if (currentMoneroNode == null) {
|
||||
final newCakeWalletNode = Node(uri: newCakeWalletMoneroUri, type: WalletType.monero);
|
||||
|
@ -473,11 +476,11 @@ Future<void> checkCurrentNodes(Box<Node> nodeSource, SharedPreferences sharedPre
|
|||
await sharedPreferences.setInt(PreferencesKey.currentEthereumNodeIdKey, node.key as int);
|
||||
}
|
||||
|
||||
if (currentEthereumNodeServer == null) {
|
||||
final node = Node(uri: ethereumDefaultNodeUri, type: WalletType.ethereum);
|
||||
if (currentNanoNodeServer == null) {
|
||||
final node = Node(uri: nanoDefaultNodeUri, type: WalletType.nano);
|
||||
await nodeSource.add(node);
|
||||
await sharedPreferences.setInt(
|
||||
PreferencesKey.currentEthereumNodeIdKey, node.key as int);
|
||||
PreferencesKey.currentNanoNodeIdKey, node.key as int);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ class WalletRestoreChooseDerivationPage extends BasePage {
|
|||
child: CircularProgressIndicator(),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text('Error: ${snapshot.error}');
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return Text('Error! No derivations available!');
|
||||
return Center(child: Text('Error! No derivations available!'));
|
||||
} else {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
|
@ -62,8 +62,10 @@ class WalletRestoreChooseDerivationPage extends BasePage {
|
|||
title: Center(
|
||||
child: Text(
|
||||
"${derivation.derivationType.toString().split('.').last}",
|
||||
style:
|
||||
Theme.of(context).primaryTextTheme.labelMedium!.copyWith(fontSize: 18),
|
||||
style: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.labelMedium!
|
||||
.copyWith(fontSize: 18),
|
||||
),
|
||||
),
|
||||
subtitle: Column(
|
||||
|
|
|
@ -281,6 +281,7 @@ class WalletRestorePage extends BasePage {
|
|||
}
|
||||
|
||||
credentials['derivationType'] = this.derivationType;
|
||||
credentials['walletType'] = walletRestoreViewModel.type;
|
||||
|
||||
return credentials;
|
||||
}
|
||||
|
|
|
@ -33,16 +33,15 @@ abstract class WalletRestoreChooseDerivationViewModelBase with Store {
|
|||
|
||||
Future<List<Derivation>> get derivations async {
|
||||
var list = <Derivation>[];
|
||||
var walletType = credentials["walletType"] as WalletType;
|
||||
var appStore = getIt.get<AppStore>();
|
||||
var node = appStore.settingsStore.getCurrentNode(appStore.wallet!.type);
|
||||
switch ((await getIt.get<AppStore>().wallet!.type)) {
|
||||
var node = appStore.settingsStore.getCurrentNode(walletType);
|
||||
switch (walletType) {
|
||||
case WalletType.nano:
|
||||
String? mnemonic = credentials['seed'] as String?;
|
||||
String? seedKey = credentials['seedKey'] as String?;
|
||||
var bip39Info = await NanoWalletService.getInfoFromSeedOrMnemonic(DerivationType.bip39,
|
||||
mnemonic: mnemonic,
|
||||
seedKey: seedKey,
|
||||
node: node);
|
||||
mnemonic: mnemonic, seedKey: seedKey, node: node);
|
||||
var standardInfo = await NanoWalletService.getInfoFromSeedOrMnemonic(
|
||||
DerivationType.nano,
|
||||
mnemonic: mnemonic,
|
||||
|
@ -50,7 +49,7 @@ abstract class WalletRestoreChooseDerivationViewModelBase with Store {
|
|||
node: node,
|
||||
);
|
||||
|
||||
if (standardInfo["address"] != null) {
|
||||
if (standardInfo["balance"] != null) {
|
||||
list.add(Derivation(
|
||||
NanoUtil.getRawAsUsableString(standardInfo["balance"] as String, NanoUtil.rawPerNano),
|
||||
standardInfo["address"] as String,
|
||||
|
@ -77,6 +76,7 @@ abstract class WalletRestoreChooseDerivationViewModelBase with Store {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,9 +138,10 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
Future<List<DerivationType>> getDerivationType(dynamic options) async {
|
||||
final seedKey = options['seedKey'] as String?;
|
||||
final mnemonic = options['seed'] as String?;
|
||||
WalletType walletType = options['walletType'] as WalletType;
|
||||
var appStore = getIt.get<AppStore>();
|
||||
var node = appStore.settingsStore.getCurrentNode(appStore.wallet!.type);
|
||||
|
||||
var node = appStore.settingsStore.getCurrentNode(walletType);
|
||||
|
||||
switch (type) {
|
||||
// case WalletType.bitcoin:
|
||||
// return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
|
||||
|
|
Loading…
Reference in a new issue