Skip to content

Commit a4d95c1

Browse files
committed
[trello.com/c/vawidi4o] Remove secret wallets storing in KVS
1 parent f33ff89 commit a4d95c1

10 files changed

+23
-13
lines changed

Adamant/Modules/Wallets/Adamant/AdmWalletService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
225225
.init(sentDate: nil, status: .notInitiated)
226226
}
227227

228-
func initWallet(withPassphrase: String, withPassword: String) async throws -> WalletAccount {
228+
func initWallet(withPassphrase: String, withPassword: String, storeInKVC: Bool) async throws -> WalletAccount {
229229
throw InternalAPIError.unknownError
230230
}
231231

Adamant/Modules/Wallets/Bitcoin/BtcWalletService.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ extension BtcWalletService {
445445
btcWallet = nil
446446
}
447447

448-
func initWallet(withPassphrase passphrase: String, withPassword password: String) async throws -> WalletAccount {
448+
func initWallet(withPassphrase passphrase: String, withPassword password: String, storeInKVC: Bool) async throws -> WalletAccount {
449449
guard let adamant = accountService.account else {
450450
throw WalletServiceError.notLogged
451451
}
@@ -483,6 +483,7 @@ extension BtcWalletService {
483483
NotificationCenter.default.post(name: self.serviceEnabledChanged, object: self)
484484
}
485485

486+
guard storeInKVC else { return eWallet }
486487
// MARK: 4. Save address into KVS
487488
let service = self
488489
do {

Adamant/Modules/Wallets/Dash/DashWalletService.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ extension DashWalletService {
300300
}
301301

302302
@MainActor
303-
func initWallet(withPassphrase passphrase: String, withPassword password: String) async throws -> WalletAccount {
303+
func initWallet(withPassphrase passphrase: String, withPassword password: String, storeInKVC: Bool) async throws -> WalletAccount {
304304
guard let adamant = accountService.account else {
305305
throw WalletServiceError.notLogged
306306
}
@@ -340,6 +340,8 @@ extension DashWalletService {
340340
NotificationCenter.default.post(name: self.serviceEnabledChanged, object: self)
341341
}
342342

343+
guard storeInKVC else { return eWallet }
344+
343345
// MARK: 4. Save address into KVS
344346
do {
345347
let address = try await getWalletAddress(byAdamantAddress: adamant.address)

Adamant/Modules/Wallets/Doge/DogeWalletService.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ extension DogeWalletService {
319319
dogeWallet = nil
320320
}
321321

322-
func initWallet(withPassphrase passphrase: String, withPassword password: String) async throws -> WalletAccount {
322+
func initWallet(withPassphrase passphrase: String, withPassword password: String, storeInKVC: Bool) async throws -> WalletAccount {
323323
guard let adamant = accountService.account else {
324324
throw WalletServiceError.notLogged
325325
}
@@ -358,6 +358,8 @@ extension DogeWalletService {
358358
NotificationCenter.default.post(name: self.serviceEnabledChanged, object: self)
359359
}
360360

361+
guard storeInKVC else { return eWallet }
362+
361363
// MARK: 4. Save address into KVS
362364
let service = self
363365
do {

Adamant/Modules/Wallets/ERC20/ERC20WalletService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ final class ERC20WalletService: WalletCoreProtocol, @unchecked Sendable {
368368

369369
// MARK: - WalletInitiatedWithPassphrase
370370
extension ERC20WalletService {
371-
func initWallet(withPassphrase passphrase: String, withPassword password: String) async throws -> WalletAccount {
371+
func initWallet(withPassphrase passphrase: String, withPassword password: String, storeInKVC: Bool) async throws -> WalletAccount {
372372

373373
// MARK: 1. Prepare
374374
setState(.notInitiated)

Adamant/Modules/Wallets/Ethereum/EthWalletService.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ final class EthWalletService: WalletCoreProtocol, WalletStaticCoreProtocol, Smar
403403

404404
// MARK: - WalletInitiatedWithPassphrase
405405
extension EthWalletService {
406-
func initWallet(withPassphrase passphrase: String, withPassword password: String) async throws -> WalletAccount {
406+
func initWallet(withPassphrase passphrase: String, withPassword password: String, storeInKVC: Bool) async throws -> WalletAccount {
407407
guard let adamant = accountService?.account else {
408408
throw WalletServiceError.notLogged
409409
}
@@ -444,6 +444,8 @@ extension EthWalletService {
444444
NotificationCenter.default.post(name: serviceEnabledChanged, object: self)
445445
}
446446

447+
guard storeInKVC else { return eWallet }
448+
447449
// MARK: 4. Save into KVS
448450
let service = self
449451
do {

Adamant/Modules/Wallets/Klayr/WalletService/KlyWalletService.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ final class KlyWalletService: WalletCoreProtocol, WalletStaticCoreProtocol, @unc
9999
// MARK: -
100100

101101
func initWallet(
102-
withPassphrase passphrase: String, withPassword password: String
102+
withPassphrase passphrase: String, withPassword password: String, storeInKVC: Bool
103103
) async throws -> WalletAccount {
104-
try await initWallet(passphrase: passphrase, password: password)
104+
try await initWallet(passphrase: passphrase, password: password, storeInKVC: storeInKVC)
105105
}
106106

107107
func setInitiationFailed(reason: String) {
@@ -413,7 +413,7 @@ private extension KlyWalletService {
413413

414414
// MARK: - Init Wallet
415415
private extension KlyWalletService {
416-
func initWallet(passphrase: String, password: String) async throws -> WalletAccount {
416+
func initWallet(passphrase: String, password: String, storeInKVC: Bool) async throws -> WalletAccount {
417417
guard let adamant = accountService.account else {
418418
throw WalletServiceError.notLogged
419419
}
@@ -465,6 +465,8 @@ private extension KlyWalletService {
465465
throw WalletServiceError.accountNotFound
466466
}
467467

468+
guard storeInKVC else { return eWallet }
469+
468470
// Save into KVS
469471

470472
do {

Adamant/Modules/Wallets/WalletsService/WalletCoreProtocol.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ protocol WalletCoreProtocol: AnyObject, Sendable {
305305
func updateStatus(for id: String, status: TransactionStatus?)
306306
func isExist(address: String) async throws -> Bool
307307
func statusInfoFor(transaction: CoinTransaction) async -> TransactionStatusInfo
308-
func initWallet(withPassphrase: String, withPassword: String) async throws -> WalletAccount
308+
func initWallet(withPassphrase: String, withPassword: String, storeInKVC: Bool) async throws -> WalletAccount
309309
func setInitiationFailed(reason: String)
310310
func shortDescription(for transaction: RichMessageTransaction) -> NSAttributedString
311311
func getFee(comment: String) -> Decimal

Adamant/Services/AdamantAccountService.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ extension AdamantAccountService {
423423
group.addTask {
424424
let result = try? await wallet.core.initWallet(
425425
withPassphrase: passphrase,
426-
withPassword: .empty
426+
withPassword: .empty,
427+
storeInKVC: true
427428
)
428429
return result
429430
}

Adamant/Services/AdamantSecretWalletsManager+SecretWalletsFactory.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import CommonKit
1010
import Swinject
1111

12-
//TODO: ‼️‼️‼️ Double check wallets initialization and dependencies injection while making the review ‼️‼️‼️
1312
extension AdamantSecretWalletsManager{
1413
struct SecretWalletsFactory {
1514
private let visibleWalletsService: VisibleWalletsService
@@ -73,7 +72,8 @@ extension AdamantSecretWalletsManager{
7372
taskGroup.addTask {
7473
_ = try? await wallet.core.initWallet(
7574
withPassphrase: passphrase,
76-
withPassword: password
75+
withPassword: password,
76+
storeInKVC: false
7777
)
7878
}
7979
}

0 commit comments

Comments
 (0)