@@ -55,6 +55,18 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
55
55
var qqPrefix : String {
56
56
return Self . qqPrefix
57
57
}
58
+
59
+ var balanceCheckInterval : Int ? {
60
+ Self . balanceCheckInterval
61
+ }
62
+
63
+ var balanceValidInterval : Int ? {
64
+ Self . balanceValidInterval
65
+ }
66
+
67
+ var balanceCheckIntervalNewAccount : Int ? {
68
+ Self . coinInfo? . balanceCheckIntervalNewAccount
69
+ }
58
70
59
71
var nodeGroups : [ NodeGroup ] {
60
72
[ . adm]
@@ -72,7 +84,7 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
72
84
var vibroService : VibroService !
73
85
74
86
// MARK: - Notifications
75
- let walletUpdatedNotification = Notification . Name ( " adamant.admWallet.updated " )
87
+ let adamantAccount = Notification . Name ( " adamant.admWallet.walletUpdated " )
76
88
let serviceEnabledChanged = Notification . Name ( " adamant.admWallet.enabledChanged " )
77
89
let transactionFeeUpdated = Notification . Name ( " adamant.admWallet.feeUpdated " )
78
90
let serviceStateChanged = Notification . Name ( " adamant.admWallet.stateChanged " )
@@ -130,7 +142,7 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
130
142
// MARK: - Logic
131
143
override init ( ) {
132
144
super. init ( )
133
-
145
+
134
146
// Notifications
135
147
addObservers ( )
136
148
}
@@ -149,6 +161,13 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
149
161
self ? . admWallet = nil
150
162
}
151
163
. store ( in: & subscriptions)
164
+
165
+ NotificationCenter . default
166
+ . notifications ( named: . AdamantAccountService. walletUpdated, object: nil )
167
+ . sink { [ weak self] _ in
168
+ self ? . update ( )
169
+ }
170
+ . store ( in: & subscriptions)
152
171
}
153
172
154
173
func updateWithRefreshUIBalance( ) {
@@ -180,8 +199,10 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
180
199
181
200
admWallet? . isBalanceInitialized = !accountService. isBalanceExpired
182
201
183
- if let wallet = wallet {
184
- postUpdateNotification ( with: wallet)
202
+ if wallet != nil {
203
+ Task { @MainActor in
204
+ walletUpdateSender. send ( )
205
+ }
185
206
}
186
207
187
208
if isRaised {
@@ -199,17 +220,6 @@ final class AdmWalletService: NSObject, WalletCoreProtocol, WalletStaticCoreProt
199
220
addressRegex. perfectMatch ( with: address) ? . valid : . invalid( description: nil )
200
221
}
201
222
202
- private func postUpdateNotification( with wallet: WalletAccount ) {
203
- NotificationCenter . default. post (
204
- name: walletUpdatedNotification,
205
- object: self ,
206
- userInfo: [ AdamantUserInfoKey . WalletService. wallet: wallet]
207
- )
208
- Task { @MainActor in
209
- walletUpdateSender. send ( )
210
- }
211
- }
212
-
213
223
func getWalletAddress( byAdamantAddress address: String ) async throws -> String {
214
224
return address
215
225
}
@@ -248,7 +258,9 @@ extension AdmWalletService: NSFetchedResultsControllerDelegate {
248
258
249
259
if newCount != wallet. notifications {
250
260
wallet. notifications = newCount
251
- postUpdateNotification ( with: wallet)
261
+ Task { @MainActor in
262
+ walletUpdateSender. send ( )
263
+ }
252
264
}
253
265
}
254
266
}
0 commit comments