Skip to content

refactor: client #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 30, 2025
Merged
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
4 changes: 4 additions & 0 deletions BDKSwiftExampleWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
AE96F6622A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE96F6612A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift */; };
AE97E74D2E315A8F000A407D /* AddressType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE97E74C2E315A8F000A407D /* AddressType+Extensions.swift */; };
AEA0A6272E297203008A525B /* BitcoinDevKit in Frameworks */ = {isa = PBXBuildFile; productRef = AEA0A6262E297203008A525B /* BitcoinDevKit */; };
AEAA61BF2E380D62006ED2D0 /* Notification+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAA61BE2E380D62006ED2D0 /* Notification+Extensions.swift */; };
AEAB03112ABDDB86000C9528 /* FeeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAB03102ABDDB86000C9528 /* FeeViewModel.swift */; };
AEAB03132ABDDBF4000C9528 /* AmountViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEAB03122ABDDBF4000C9528 /* AmountViewModel.swift */; };
AEAF83B62B7BD4D10019B23B /* CodeScanner in Frameworks */ = {isa = PBXBuildFile; productRef = AEAF83B52B7BD4D10019B23B /* CodeScanner */; };
Expand Down Expand Up @@ -189,6 +190,7 @@
AE91CEEE2C0FDBC7000AAD20 /* CanonicalTx+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CanonicalTx+Extensions.swift"; sourceTree = "<group>"; };
AE96F6612A424C400055623C /* BDKSwiftExampleWalletReceiveViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BDKSwiftExampleWalletReceiveViewModelTests.swift; sourceTree = "<group>"; };
AE97E74C2E315A8F000A407D /* AddressType+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AddressType+Extensions.swift"; sourceTree = "<group>"; };
AEAA61BE2E380D62006ED2D0 /* Notification+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Notification+Extensions.swift"; sourceTree = "<group>"; };
AEAB03102ABDDB86000C9528 /* FeeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeeViewModel.swift; sourceTree = "<group>"; };
AEAB03122ABDDBF4000C9528 /* AmountViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmountViewModel.swift; sourceTree = "<group>"; };
AEB130C82A44E4850087785B /* TransactionDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionDetailView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -293,6 +295,7 @@
AE7F67062A744CE200CED561 /* Double+Extensions.swift */,
AEB159D42D51A8680006AE9E /* View+Extensions.swift */,
AE8D001B2D19F1760029C4C9 /* UIScreen+Extensions.swift */,
AEAA61BE2E380D62006ED2D0 /* Notification+Extensions.swift */,
AEE6C74D2ABCB48600442ADD /* BDK+Extensions */,
);
path = Extensions;
Expand Down Expand Up @@ -745,6 +748,7 @@
AEB130C92A44E4850087785B /* TransactionDetailView.swift in Sources */,
AE287E772C0F6D200036A748 /* Array+Extensions.swift in Sources */,
AE6715FD2A9AC056005C193F /* PriceServiceError.swift in Sources */,
AEAA61BF2E380D62006ED2D0 /* Notification+Extensions.swift in Sources */,
AE34DDAC2B6B31ED00F04AD4 /* WalletRecoveryView.swift in Sources */,
AE2ADD742B61E8F500C2A823 /* SettingsView.swift in Sources */,
AE2381AF2C605B1D00F6B00C /* ActivityListViewModel.swift in Sources */,
Expand Down
18 changes: 14 additions & 4 deletions BDKSwiftExampleWallet/App/BDKSwiftExampleWalletApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import SwiftUI
struct BDKSwiftExampleWalletApp: App {
@AppStorage("isOnboarding") var isOnboarding: Bool = true
@State private var navigationPath = NavigationPath()
@State private var refreshTrigger = UUID()

var body: some Scene {
WindowGroup {
NavigationStack(path: $navigationPath) {
let value = try? KeyClient.live.getBackupInfo()
if isOnboarding && (value == nil) {
OnboardingView(viewModel: .init(bdkClient: .live))
} else if !isOnboarding && (value == nil) {
if !walletExists {
OnboardingView(viewModel: .init(bdkClient: .live))
.onReceive(NotificationCenter.default.publisher(for: .walletCreated)) { _ in
refreshTrigger = UUID()
}
} else {
HomeView(viewModel: .init(bdkClient: .live), navigationPath: $navigationPath)
}
Expand All @@ -32,3 +33,12 @@ struct BDKSwiftExampleWalletApp: App {
}
}
}

extension BDKSwiftExampleWalletApp {
private var walletExists: Bool {
// Force re-evaluation by reading refreshTrigger and isOnboarding
let _ = refreshTrigger
let _ = isOnboarding
return (try? KeyClient.live.getBackupInfo()) != nil
}
}
12 changes: 12 additions & 0 deletions BDKSwiftExampleWallet/Extensions/Notification+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Notification+Extensions.swift
// BDKSwiftExampleWallet
//
// Created by Matthew Ramsden on 7/28/25.
//

import Foundation

extension Notification.Name {
static let walletCreated = Notification.Name("walletCreated")
}
27 changes: 19 additions & 8 deletions BDKSwiftExampleWallet/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sourceLanguage" : "en",
"strings" : {
" High • %lld" : {

},
" High Priority - %lld" : {
"extractionState" : "stale",
"localizations" : {
Expand All @@ -18,7 +21,7 @@
}
}
},
" High: %lld" : {
" Low • %lld" : {

},
" Low Priority - %lld" : {
Expand All @@ -37,9 +40,6 @@
}
}
}
},
" Low: %lld" : {

},
" Med Priority - %lld" : {
"extractionState" : "stale",
Expand All @@ -57,6 +57,9 @@
}
}
}
},
" Medium • %lld" : {

},
" No Priority - %lld" : {
"extractionState" : "stale",
Expand All @@ -75,7 +78,7 @@
}
}
},
" None: %lld" : {
" None %lld" : {

},
"- %llu sats" : {
Expand Down Expand Up @@ -532,6 +535,9 @@
}
}
}
},
"Creating..." : {

},
"Danger Zone" : {
"localizations" : {
Expand Down Expand Up @@ -665,8 +671,12 @@
}
}
}
},
"Fee Priority" : {

},
"Fees" : {
"extractionState" : "stale",
"localizations" : {
"fr" : {
"stringUnit" : {
Expand Down Expand Up @@ -723,9 +733,6 @@
}
}
}
},
"Med: %lld" : {

},
"Navigation Title" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -923,8 +930,12 @@
}
}
}
},
"powered by BDK" : {

},
"powered by Bitcoin Dev Kit" : {
"extractionState" : "stale",
"localizations" : {
"pt-BR" : {
"stringUnit" : {
Expand Down
Loading