Skip to content

Commit 2b26f70

Browse files
committed
feat: add kyoto retry
1 parent 884c955 commit 2b26f70

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

BDKSwiftExampleWallet/View Model/WalletViewModel.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,13 @@ class WalletViewModel {
270270
await startSyncWithProgress()
271271
}
272272
}
273+
274+
/// Retry sync pipeline for Kyoto when a prior attempt failed.
275+
func retryKyotoSync() async {
276+
guard isKyotoClient else { return }
277+
await syncOrFullScan()
278+
getBalance()
279+
getTransactions()
280+
await getPrices()
281+
}
273282
}

BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ struct ActivityHomeHeaderView: View {
1818
let isKyotoConnected: Bool
1919
let currentBlockHeight: UInt32
2020

21+
/// Optional retry action used for Kyoto errors.
22+
let retryKyotoSync: (() -> Void)?
23+
2124
let showAllTransactions: () -> Void
2225

2326
var body: some View {
@@ -116,6 +119,13 @@ struct ActivityHomeHeaderView: View {
116119
}
117120
}
118121
.contentTransition(.symbolEffect(.replace.offUp))
122+
.contentShape(Rectangle()) // Expand tap target for retry on error
123+
.onTapGesture {
124+
guard isKyotoClient else { return }
125+
if case .error = walletSyncState {
126+
retryKyotoSync?()
127+
}
128+
}
119129

120130
}
121131
.foregroundStyle(.secondary)

BDKSwiftExampleWallet/View/WalletView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ struct WalletView: View {
5454
needsFullScan: viewModel.needsFullScan,
5555
isKyotoClient: viewModel.isKyotoClient,
5656
isKyotoConnected: viewModel.isKyotoConnected,
57-
currentBlockHeight: viewModel.currentBlockHeight
57+
currentBlockHeight: viewModel.currentBlockHeight,
58+
retryKyotoSync: {
59+
Task {
60+
await viewModel.retryKyotoSync()
61+
}
62+
}
5863
) {
5964
showAllTransactions = true
6065
}

0 commit comments

Comments
 (0)