mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-22 10:45:08 +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
|
||||
Future<BitcoinWallet> create(BitcoinNewWalletCredentials credentials) async {
|
||||
|
||||
// set the walletInfo's derivationInfo if not present:
|
||||
credentials.walletInfo!.derivationInfo ??= credentials.derivationInfo;
|
||||
|
||||
final wallet = await BitcoinWalletBase.create(
|
||||
mnemonic: await generateElectrumMnemonic(strength: 132),
|
||||
password: credentials.password!,
|
||||
|
|
|
@ -6,12 +6,15 @@ abstract class WalletCredentials {
|
|||
this.height,
|
||||
this.walletInfo,
|
||||
this.password,
|
||||
this.derivationInfo,
|
||||
});
|
||||
DerivationInfo? derivationInfo,
|
||||
}) {
|
||||
if (this.walletInfo != null && derivationInfo != null) {
|
||||
this.walletInfo!.derivationInfo = derivationInfo;
|
||||
}
|
||||
}
|
||||
|
||||
final String name;
|
||||
final int? height;
|
||||
String? password;
|
||||
WalletInfo? walletInfo;
|
||||
DerivationInfo? derivationInfo;
|
||||
}
|
||||
|
|
|
@ -355,6 +355,9 @@ abstract class NanoWalletBase
|
|||
}
|
||||
|
||||
walletInfo.derivationInfo ??= DerivationInfo(derivationType: derivationType);
|
||||
if (walletInfo.derivationInfo!.derivationType == null) {
|
||||
walletInfo.derivationInfo!.derivationType = derivationType;
|
||||
}
|
||||
|
||||
return NanoWallet(
|
||||
walletInfo: walletInfo,
|
||||
|
|
|
@ -31,10 +31,8 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
|||
String seedKey = NanoSeeds.generateSeed();
|
||||
String mnemonic = NanoUtil.seedToMnemonic(seedKey);
|
||||
|
||||
// set default if not present:
|
||||
DerivationType derivationType =
|
||||
credentials.derivationInfo?.derivationType ?? DerivationType.nano;
|
||||
credentials.walletInfo!.derivationInfo ??= DerivationInfo(derivationType: derivationType);
|
||||
// ensure default if not present:
|
||||
credentials.walletInfo!.derivationInfo ??= DerivationInfo(derivationType: DerivationType.nano);
|
||||
|
||||
final wallet = NanoWallet(
|
||||
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;
|
||||
|
||||
// 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 {
|
||||
final walletInfo =
|
||||
walletInfoSource.values.firstWhere((info) => info.id == WalletBase.idFor(name, getType()));
|
||||
|
||||
final wallet = await NanoWalletBase.open(
|
||||
name: name,
|
||||
password: password,
|
||||
|
|
|
@ -101,12 +101,12 @@ abstract class ExchangeTradeViewModelBase with Store {
|
|||
return;
|
||||
}
|
||||
|
||||
// sendViewModel.clearOutputs();
|
||||
// final output = sendViewModel.outputs.first;
|
||||
// output.address = trade.inputAddress ?? '';
|
||||
// output.setCryptoAmount(trade.amount);
|
||||
// sendViewModel.selectedCryptoCurrency = trade.from;
|
||||
// await sendViewModel.createTransaction();
|
||||
sendViewModel.clearOutputs();
|
||||
final output = sendViewModel.outputs.first;
|
||||
output.address = trade.inputAddress ?? '';
|
||||
output.setCryptoAmount(trade.amount);
|
||||
sendViewModel.selectedCryptoCurrency = trade.from;
|
||||
await sendViewModel.createTransaction();
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
@ -47,13 +47,6 @@ abstract class WalletCreationVMBase with Store {
|
|||
name = await generateName();
|
||||
}
|
||||
|
||||
if (options == null || options["derivationInfo"] == null) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
options["derivationInfo"] = getDefaultDerivation();
|
||||
}
|
||||
|
||||
walletCreationService.checkIfExists(name);
|
||||
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||
final path = await pathForWallet(name: name, type: type);
|
||||
|
@ -72,8 +65,9 @@ abstract class WalletCreationVMBase with Store {
|
|||
dirPath: dirPath,
|
||||
address: '',
|
||||
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven,
|
||||
derivationInfo: credentials.derivationInfo,
|
||||
derivationInfo: getDefaultDerivation(),
|
||||
);
|
||||
|
||||
credentials.walletInfo = walletInfo;
|
||||
final wallet = restoreWallet != null
|
||||
? await processFromRestoredWallet(credentials, restoreWallet)
|
||||
|
|
Loading…
Reference in a new issue