From 2b26f7081b3055faa6e9344f410cfd06743e1875 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 24 Nov 2025 08:19:04 -0600 Subject: [PATCH] feat: add kyoto retry --- BDKSwiftExampleWallet/View Model/WalletViewModel.swift | 9 +++++++++ .../View/Home/ActivityHomeHeaderView.swift | 10 ++++++++++ BDKSwiftExampleWallet/View/WalletView.swift | 7 ++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/BDKSwiftExampleWallet/View Model/WalletViewModel.swift b/BDKSwiftExampleWallet/View Model/WalletViewModel.swift index 9001d8ae..09aab6ac 100644 --- a/BDKSwiftExampleWallet/View Model/WalletViewModel.swift +++ b/BDKSwiftExampleWallet/View Model/WalletViewModel.swift @@ -270,4 +270,13 @@ class WalletViewModel { await startSyncWithProgress() } } + + /// Retry sync pipeline for Kyoto when a prior attempt failed. + func retryKyotoSync() async { + guard isKyotoClient else { return } + await syncOrFullScan() + getBalance() + getTransactions() + await getPrices() + } } diff --git a/BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift b/BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift index 4f81ba3e..891cb0ff 100644 --- a/BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift +++ b/BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift @@ -18,6 +18,9 @@ struct ActivityHomeHeaderView: View { let isKyotoConnected: Bool let currentBlockHeight: UInt32 + /// Optional retry action used for Kyoto errors. + let retryKyotoSync: (() -> Void)? + let showAllTransactions: () -> Void var body: some View { @@ -116,6 +119,13 @@ struct ActivityHomeHeaderView: View { } } .contentTransition(.symbolEffect(.replace.offUp)) + .contentShape(Rectangle()) // Expand tap target for retry on error + .onTapGesture { + guard isKyotoClient else { return } + if case .error = walletSyncState { + retryKyotoSync?() + } + } } .foregroundStyle(.secondary) diff --git a/BDKSwiftExampleWallet/View/WalletView.swift b/BDKSwiftExampleWallet/View/WalletView.swift index 495f9cfe..265393b6 100644 --- a/BDKSwiftExampleWallet/View/WalletView.swift +++ b/BDKSwiftExampleWallet/View/WalletView.swift @@ -54,7 +54,12 @@ struct WalletView: View { needsFullScan: viewModel.needsFullScan, isKyotoClient: viewModel.isKyotoClient, isKyotoConnected: viewModel.isKyotoConnected, - currentBlockHeight: viewModel.currentBlockHeight + currentBlockHeight: viewModel.currentBlockHeight, + retryKyotoSync: { + Task { + await viewModel.retryKyotoSync() + } + } ) { showAllTransactions = true }