@@ -311,19 +311,13 @@ final class TunnelManager: StorePaymentObserver {
311
311
operationQueue. addOperation ( operation)
312
312
}
313
313
314
- func setNewAccount( completion: @escaping ( Result < StoredAccountData , Error > ) -> Void ) {
315
- setAccount ( action: . new) { result in
316
- completion ( result. map { $0! } )
317
- }
314
+
315
+ func setNewAccount( ) async throws -> StoredAccountData {
316
+ try await setAccount ( action: . new) !
318
317
}
319
318
320
- func setExistingAccount(
321
- accountNumber: String ,
322
- completion: @escaping ( Result < StoredAccountData , Error > ) -> Void
323
- ) {
324
- setAccount ( action: . existing( accountNumber) ) { result in
325
- completion ( result. map { $0! } )
326
- }
319
+ func setExistingAccount( accountNumber: String ) async throws -> StoredAccountData {
320
+ try await setAccount ( action: . existing( accountNumber) ) !
327
321
}
328
322
329
323
private func setAccount(
@@ -373,13 +367,19 @@ final class TunnelManager: StorePaymentObserver {
373
367
374
368
operationQueue. addOperation ( operation)
375
369
}
376
-
377
- func unsetAccount( completionHandler: @escaping ( ) -> Void ) {
378
- setAccount ( action: . unset) { _ in
379
- completionHandler ( )
370
+
371
+ private func setAccount( action: SetAccountAction ) async throws -> StoredAccountData ? {
372
+ try await withCheckedThrowingContinuation { continuation in
373
+ setAccount ( action: action) { result in
374
+ continuation. resume ( with: result)
375
+ }
380
376
}
381
377
}
382
378
379
+ func unsetAccount( ) async {
380
+ _ = try ? await setAccount ( action: . unset)
381
+ }
382
+
383
383
func updateAccountData( _ completionHandler: ( ( Error ? ) -> Void ) ? = nil ) {
384
384
let operation = UpdateAccountDataOperation (
385
385
dispatchQueue: internalQueue,
@@ -435,13 +435,8 @@ final class TunnelManager: StorePaymentObserver {
435
435
return operation
436
436
}
437
437
438
- func deleteAccount(
439
- accountNumber: String ,
440
- completion: ( ( Error ? ) -> Void ) ? = nil
441
- ) {
442
- setAccount ( action: . delete( accountNumber) ) { result in
443
- completion ? ( result. error)
444
- }
438
+ func deleteAccount( accountNumber: String ) async throws {
439
+ _ = try await setAccount ( action: . delete( accountNumber) )
445
440
}
446
441
447
442
func updateDeviceData( _ completionHandler: ( ( Error ? ) -> Void ) ? = nil ) {
0 commit comments