Internalize factory layer and remove crossmintService from public API#89
Open
tomas-martins-crossmint wants to merge 4 commits into
Open
Conversation
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Sources/CrossmintClient/SwiftUI/CrossmintSDK.swift:41
**Dead stored property after `init`**
`sdk` is used exclusively during initialization to copy out `authManager`, `crossmintWallets()`, and `isProductionEnvironment`. After `init`, no method in this class ever reads `sdk` again, yet the stored reference keeps the entire `CrossmintClientSDK` instance — with its `crossmintService`, `secureStorage`, etc. — alive for the singleton's lifetime. Since all necessary values are now stored individually, `sdk` itself serves no purpose. It could be a local `let` inside `init` rather than a stored property, letting the `CrossmintClientSDK` instance be freed (its retained sub-objects like `authManager` survive through the other stored properties regardless).
Reviews (1): Last reviewed commit: "Remove nonisolated(unsafe) from _shared ..." | Re-trigger Greptile |
1e86d28 to
4452a83
Compare
Contributor
|
Reviews (2): Last reviewed commit: "Remove nonisolated(unsafe) from _shared ..." | Re-trigger Greptile |
…Service visibility
4452a83 to
825253b
Compare
Contributor
|
Reviews (3): Last reviewed commit: "Remove nonisolated(unsafe) from _shared ..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CrossmintClient,ClientSDK, andCrossmintClientSDKwere public but created a confusing second entry point into the SDK: a developer reading the public API could reasonably wonder whether to useCrossmintClient.sdk()orCrossmintSDK.shared(), and what the difference was.crossmintService: CrossmintServicealso leaked the raw HTTP client publicly, letting callers bypass auth and error handling entirely. No other Crossmint SDK exposes anything like it.This pull request makes those types internal and removes the service leak, without changing any observable behavior.
Changes
CrossmintClient,ClientSDK, andCrossmintClientSDKinternal soCrossmintSDKis the only public entry pointcrossmintService: CrossmintServicefrom the public API;isProductionEnvironmentis now a storedBoolderived at init time@_exported import CrossmintServiceso consumers no longer get allCrossmintServicetypes injected into their namespacecrossmintServiceprivateinsideCrossmintClientSDKasync throwsfromlogout()since the implementation was never async or throwingnonisolated(unsafe)fromCrossmintSDK._sharedsince the class is@MainActorand the compiler already enforces single actor access