mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-21 06:38:49 +00:00
refactor fixes
This commit is contained in:
parent
8e130166ac
commit
95e7ee1cbb
6 changed files with 20 additions and 28 deletions
|
@ -46,10 +46,6 @@ class BitcoinWalletService extends WalletService<BitcoinNewWalletCredentials,
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinWallet> create(BitcoinNewWalletCredentials credentials) async {
|
Future<BitcoinWallet> create(BitcoinNewWalletCredentials credentials) async {
|
||||||
|
|
||||||
// set the walletInfo's derivationInfo if not present:
|
|
||||||
credentials.walletInfo!.derivationInfo ??= credentials.derivationInfo;
|
|
||||||
|
|
||||||
final wallet = await BitcoinWalletBase.create(
|
final wallet = await BitcoinWalletBase.create(
|
||||||
mnemonic: await generateElectrumMnemonic(strength: 132),
|
mnemonic: await generateElectrumMnemonic(strength: 132),
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
|
|
|
@ -6,12 +6,15 @@ abstract class WalletCredentials {
|
||||||
this.height,
|
this.height,
|
||||||
this.walletInfo,
|
this.walletInfo,
|
||||||
this.password,
|
this.password,
|
||||||
this.derivationInfo,
|
DerivationInfo? derivationInfo,
|
||||||
});
|
}) {
|
||||||
|
if (this.walletInfo != null && derivationInfo != null) {
|
||||||
|
this.walletInfo!.derivationInfo = derivationInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final int? height;
|
final int? height;
|
||||||
String? password;
|
String? password;
|
||||||
WalletInfo? walletInfo;
|
WalletInfo? walletInfo;
|
||||||
DerivationInfo? derivationInfo;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,6 +355,9 @@ abstract class NanoWalletBase
|
||||||
}
|
}
|
||||||
|
|
||||||
walletInfo.derivationInfo ??= DerivationInfo(derivationType: derivationType);
|
walletInfo.derivationInfo ??= DerivationInfo(derivationType: derivationType);
|
||||||
|
if (walletInfo.derivationInfo!.derivationType == null) {
|
||||||
|
walletInfo.derivationInfo!.derivationType = derivationType;
|
||||||
|
}
|
||||||
|
|
||||||
return NanoWallet(
|
return NanoWallet(
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
|
|
|
@ -31,10 +31,8 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
||||||
String seedKey = NanoSeeds.generateSeed();
|
String seedKey = NanoSeeds.generateSeed();
|
||||||
String mnemonic = NanoUtil.seedToMnemonic(seedKey);
|
String mnemonic = NanoUtil.seedToMnemonic(seedKey);
|
||||||
|
|
||||||
// set default if not present:
|
// ensure default if not present:
|
||||||
DerivationType derivationType =
|
credentials.walletInfo!.derivationInfo ??= DerivationInfo(derivationType: DerivationType.nano);
|
||||||
credentials.derivationInfo?.derivationType ?? DerivationType.nano;
|
|
||||||
credentials.walletInfo!.derivationInfo ??= DerivationInfo(derivationType: derivationType);
|
|
||||||
|
|
||||||
final wallet = NanoWallet(
|
final wallet = NanoWallet(
|
||||||
walletInfo: credentials.walletInfo!,
|
walletInfo: credentials.walletInfo!,
|
||||||
|
@ -89,9 +87,6 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the walletInfo's derivationInfo if not present:
|
|
||||||
credentials.walletInfo!.derivationInfo ??= credentials.derivationInfo;
|
|
||||||
|
|
||||||
String? mnemonic;
|
String? mnemonic;
|
||||||
|
|
||||||
// we can't derive the mnemonic from the key in all cases, only if it's a "nano" seed
|
// we can't derive the mnemonic from the key in all cases, only if it's a "nano" seed
|
||||||
|
@ -153,6 +148,7 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
||||||
Future<NanoWallet> openWallet(String name, String password) async {
|
Future<NanoWallet> openWallet(String name, String password) async {
|
||||||
final walletInfo =
|
final walletInfo =
|
||||||
walletInfoSource.values.firstWhere((info) => info.id == WalletBase.idFor(name, getType()));
|
walletInfoSource.values.firstWhere((info) => info.id == WalletBase.idFor(name, getType()));
|
||||||
|
|
||||||
final wallet = await NanoWalletBase.open(
|
final wallet = await NanoWalletBase.open(
|
||||||
name: name,
|
name: name,
|
||||||
password: password,
|
password: password,
|
||||||
|
|
|
@ -101,12 +101,12 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendViewModel.clearOutputs();
|
sendViewModel.clearOutputs();
|
||||||
// final output = sendViewModel.outputs.first;
|
final output = sendViewModel.outputs.first;
|
||||||
// output.address = trade.inputAddress ?? '';
|
output.address = trade.inputAddress ?? '';
|
||||||
// output.setCryptoAmount(trade.amount);
|
output.setCryptoAmount(trade.amount);
|
||||||
// sendViewModel.selectedCryptoCurrency = trade.from;
|
sendViewModel.selectedCryptoCurrency = trade.from;
|
||||||
// await sendViewModel.createTransaction();
|
await sendViewModel.createTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
|
@ -47,13 +47,6 @@ abstract class WalletCreationVMBase with Store {
|
||||||
name = await generateName();
|
name = await generateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options == null || options["derivationInfo"] == null) {
|
|
||||||
if (options == null) {
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
options["derivationInfo"] = getDefaultDerivation();
|
|
||||||
}
|
|
||||||
|
|
||||||
walletCreationService.checkIfExists(name);
|
walletCreationService.checkIfExists(name);
|
||||||
final dirPath = await pathForWalletDir(name: name, type: type);
|
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||||
final path = await pathForWallet(name: name, type: type);
|
final path = await pathForWallet(name: name, type: type);
|
||||||
|
@ -72,8 +65,9 @@ abstract class WalletCreationVMBase with Store {
|
||||||
dirPath: dirPath,
|
dirPath: dirPath,
|
||||||
address: '',
|
address: '',
|
||||||
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven,
|
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven,
|
||||||
derivationInfo: credentials.derivationInfo,
|
derivationInfo: getDefaultDerivation(),
|
||||||
);
|
);
|
||||||
|
|
||||||
credentials.walletInfo = walletInfo;
|
credentials.walletInfo = walletInfo;
|
||||||
final wallet = restoreWallet != null
|
final wallet = restoreWallet != null
|
||||||
? await processFromRestoredWallet(credentials, restoreWallet)
|
? await processFromRestoredWallet(credentials, restoreWallet)
|
||||||
|
|
Loading…
Reference in a new issue