From 75c2bf2db95cdde77589840acc00c2863e61af3e Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Wed, 21 Aug 2024 09:37:49 +0200 Subject: [PATCH] changes from review --- cw_monero/lib/api/wallet.dart | 13 ++++--------- cw_wownero/lib/api/wallet.dart | 13 ++++--------- lib/view_model/restore/restore_from_qr_vm.dart | 2 +- lib/view_model/restore/restore_wallet.dart | 2 ++ lib/view_model/wallet_keys_view_model.dart | 6 ------ 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index a752015e3..9a817d613 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -32,8 +32,7 @@ String getSeed() { // monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed); final cakepolyseed = monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.seed"); - final cakepassphrase = - monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); + final cakepassphrase = getPassphrase(); if (cakepolyseed != "") { return cakepolyseed; } @@ -46,8 +45,7 @@ String getSeed() { } String getSeedLegacy(String? language) { - final cakepassphrase = - monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); + final cakepassphrase = getPassphrase(); var legacy = monero.Wallet_seed(wptr!, seedOffset: cakepassphrase); switch (language) { case "Chinese (Traditional)": language = "Chinese (simplified)"; break; @@ -70,11 +68,8 @@ String getSeedLegacy(String? language) { return legacy; } -String? getPassphrase() { - final cakepassphrase = - monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); - if (cakepassphrase == "") return null; - return cakepassphrase; +String getPassphrase() { + return monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); } String getAddress({int accountIndex = 0, int addressIndex = 0}) => diff --git a/cw_wownero/lib/api/wallet.dart b/cw_wownero/lib/api/wallet.dart index c2135bc9d..89f79fa40 100644 --- a/cw_wownero/lib/api/wallet.dart +++ b/cw_wownero/lib/api/wallet.dart @@ -34,8 +34,7 @@ String getSeed() { // wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed); final cakepolyseed = wownero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.seed"); - final cakepassphrase = - wownero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); + final cakepassphrase = getPassphrase(); if (cakepolyseed != "") { return cakepolyseed; } @@ -48,8 +47,7 @@ String getSeed() { } String getSeedLegacy(String? language) { - final cakepassphrase = - wownero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); + final cakepassphrase = getPassphrase(); var legacy = wownero.Wallet_seed(wptr!, seedOffset: cakepassphrase); switch (language) { case "Chinese (Traditional)": language = "Chinese (simplified)"; break; @@ -72,11 +70,8 @@ String getSeedLegacy(String? language) { return legacy; } -String? getPassphrase() { - final cakepassphrase = - wownero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); - if (cakepassphrase == "") return null; - return cakepassphrase; +String getPassphrase() { + return wownero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase"); } String getAddress({int accountIndex = 0, int addressIndex = 1}) => diff --git a/lib/view_model/restore/restore_from_qr_vm.dart b/lib/view_model/restore/restore_from_qr_vm.dart index c23bc19f5..fade4fede 100644 --- a/lib/view_model/restore/restore_from_qr_vm.dart +++ b/lib/view_model/restore/restore_from_qr_vm.dart @@ -111,7 +111,7 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store height: restoreWallet.height ?? 0, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password, - passphrase: '', + passphrase: passphrase ?? '', ); case WalletType.bitcoin: case WalletType.litecoin: diff --git a/lib/view_model/restore/restore_wallet.dart b/lib/view_model/restore/restore_wallet.dart index 9559f586a..285788b01 100644 --- a/lib/view_model/restore/restore_wallet.dart +++ b/lib/view_model/restore/restore_wallet.dart @@ -48,12 +48,14 @@ class RestoredWallet { final height = json['height'] as String?; final mnemonic_seed = json['mnemonic_seed'] as String?; final seed = json['seed'] as String? ?? json['hexSeed'] as String?; + final passphrase = json['passphrase'] as String?; return RestoredWallet( restoreMode: json['mode'] as WalletRestoreMode, type: json['type'] as WalletType, address: json['address'] as String?, mnemonicSeed: mnemonic_seed ?? seed, height: height != null ? int.parse(height) : 0, + passphrase: passphrase ); } diff --git a/lib/view_model/wallet_keys_view_model.dart b/lib/view_model/wallet_keys_view_model.dart index 04fe3951c..1d5c27fed 100644 --- a/lib/view_model/wallet_keys_view_model.dart +++ b/lib/view_model/wallet_keys_view_model.dart @@ -102,12 +102,6 @@ abstract class WalletKeysViewModelBase with Store { title: S.current.wallet_recovery_height, value: restoreHeight.toString())); } - final passphrase = (_appStore.wallet as MoneroWalletBase).passphrase(); - if (passphrase != null) { - items.add(StandartListItem( - title: S.current.passphrase, - value: passphrase.toString())); - } } if (_appStore.wallet!.type == WalletType.haven) {