Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions BDKSwiftExampleWallet/View Model/WalletViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
10 changes: 10 additions & 0 deletions BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion BDKSwiftExampleWallet/View/WalletView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down