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