Skip to content

Commit b774f47

Browse files
committed
[trello.com/c/kie7Tdnq] Refactor AdamantWalletStoreService to support Combine framework.
Apply minor comment fixes for clarity.
1 parent 2a19009 commit b774f47

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

Adamant/ServiceProtocols/WalletsStoreService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2025 Adamant. All rights reserved.
77
//
88

9-
protocol WalletStoreServiceProtocol: AnyObject {
9+
protocol WalletStoreServiceProtocol {
1010
func sorted(includeInvisible: Bool) -> [WalletService]
1111
func isInvisible(_ wallet: WalletService) -> Bool
1212
}

Adamant/Services/AdamantAccountService.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class AdamantAccountService: AccountService, @unchecked Sendable {
2323

2424
weak var notificationsService: NotificationsService?
2525
weak var pushNotificationsTokenService: PushNotificationsTokenService?
26-
weak var walletsStoreService: WalletStoreServiceProtocol?
26+
var walletsStoreService: WalletStoreServiceProtocol?
2727

2828
// MARK: Properties
2929

@@ -270,12 +270,8 @@ extension AdamantAccountService {
270270
}
271271
}
272272

273-
if updateOnlyVisible {
274-
for wallet in wallets.filter({ !($0.core is AdmWalletService) }) where !(walletsStoreService?.isInvisible(wallet) ?? false) {
275-
wallet.core.update()
276-
}
277-
} else {
278-
for wallet in wallets.filter({ !($0.core is AdmWalletService) }) {
273+
for wallet in wallets where !(wallet.core is AdmWalletService) {
274+
if !updateOnlyVisible || !(walletsStoreService?.isInvisible(wallet) ?? false) {
279275
wallet.core.update()
280276
}
281277
}

Adamant/Services/AdamantWalletsStoreService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2025 Adamant. All rights reserved.
77
//
88

9-
final class AdamantWalletStoreService: WalletStoreServiceProtocol {
9+
struct AdamantWalletStoreService: WalletStoreServiceProtocol {
1010
let visibleWalletsService: VisibleWalletsService
1111
let walletServiceCompose: WalletServiceCompose
1212

Adamant/Services/DataProviders/AdamantWalletStoreServiceProvider.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import Combine
1212

1313
protocol WalletStoreServiceProviderProtocol: WalletStoreServiceProtocol {
1414
@MainActor
15-
var currentWalletPublisher: AnyObservable<WalletStoreServiceProtocol> { get }
15+
var currentWalletPublisher: AnyObservable<Void> { get }
1616
}
1717

1818
final class AdamantWalletStoreServiceProvider: WalletStoreServiceProviderProtocol {
1919
private let secretWalletsManager: AdamantSecretWalletsManagerProtocol
2020

21-
@ObservableValue private(set) var currentWallet: WalletStoreServiceProtocol
2221
private var cancellables = Set<AnyCancellable>()
2322

24-
var currentWalletPublisher: AnyObservable<WalletStoreServiceProtocol> {
25-
$currentWallet.eraseToAnyPublisher()
23+
@ObservableValue private var currentWallet: WalletStoreServiceProtocol
24+
var currentWalletPublisher: AnyObservable<Void> {
25+
$currentWallet.map { _ in () }.eraseToAnyPublisher()
2626
}
2727

2828
init(secretWalletsManager: AdamantSecretWalletsManagerProtocol) {

Adamant/Services/SecretWalletsService.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extension AdamantSecretWalletsManager {
2020

2121
final class AdamantSecretWalletsManager: AdamantSecretWalletsManagerProtocol {
2222
private let secretWalletsFactory: SecretWalletsFactory
23+
private let lock = NSLock()
2324

2425
init(
2526
walletsStoreService: WalletStoreServiceProtocol,
@@ -37,8 +38,6 @@ final class AdamantSecretWalletsManager: AdamantSecretWalletsManagerProtocol {
3738
$state.eraseToAnyPublisher()
3839
}
3940

40-
private let lock = NSLock()
41-
4241
// MARK: - Manage state
4342
func createSecretWallet(withPassword password: String) {
4443
let wallet = secretWalletsFactory.makeSecretWallet(withPassword: password)

0 commit comments

Comments
 (0)