diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..e26d207 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,44 @@ +# Privy Unity SDK + +Unity SDK for Privy authentication and embedded wallet functionality. Distributed as a UPM package (`com.privy.unity-sdk`), targeting Unity 2022.3+. + +## Repository Structure + +``` +SDK/ # UPM package — runtime code, editor tools, native plugins +SampleApp/ # Unity project demonstrating SDK usage +docs/ # Developer documentation (releasing.md, native-code.md) +agent_docs/ # AI assistant reference docs (code conventions, PR review rules) +Format.csproj # Used for dotnet format (covers SDK/, excludes ExternalDependencies/) +version.txt # Canonical version (managed by release-please — do not edit manually) +``` + +For detailed SDK architecture, conventions, and patterns, see **[SDK/CLAUDE.md](SDK/CLAUDE.md)**. + +## Essential Commands + +```bash +# Format all SDK source (run before committing) +dotnet format Format.csproj +``` + +## Commit Conventions + +Use [Conventional Commits](https://www.conventionalcommits.org/) — `feat:`, `fix:`, `chore:`, `docs:`, etc. Release-please uses these to generate the changelog and determine the next version bump automatically. + +## Release Process + +1. Merge conventional-commit PRs into `main` +2. Release-please opens a release PR bumping `version.txt`, `SDK/package.json`, and `SDK/Runtime/Utils/SdkVersion.cs` +3. Review and merge the release PR — release-please then creates the GitHub Release and git tag + +See `docs/releasing.md` for the full release guide. + +## GitHub Actions + +| Workflow | Trigger | What it does | +| -------------------- | ------------ | ----------------------------------- | +| `claude.yml` | PR | Automated code review | +| `format-check.yml` | PR | Verifies `dotnet format` was run | +| `pr-title.yml` | PR | Enforces conventional commit format | +| `release-please.yml` | Push to main | Manages release PRs and tags | diff --git a/SDK/CLAUDE.md b/SDK/CLAUDE.md new file mode 100644 index 0000000..21bafe6 --- /dev/null +++ b/SDK/CLAUDE.md @@ -0,0 +1,40 @@ +# Privy Unity SDK — SDK/ + +Unity Package Manager package (`com.privy.unity-sdk`) providing authentication and embedded wallet functionality. Requires Unity 2022.3+. + +## Directory Structure + +``` +SDK/ +├── package.json # UPM package manifest (version, dependencies) +├── Runtime/ # All runtime C# source (included in player builds) +├── Editor/ # Editor-only scripts (excluded from player builds) +├── ExternalDependencies/ # Vendored third-party libraries (UnityWebView, jsoncanonicalizer) +└── Plugins/ # Native platform code (iOS Objective-C, WebGL .jslib) +``` + +## Architecture + +Every public service has a `public` interface (e.g. `ILoginWithEmail`) and a separate `internal` implementation (e.g. `LoginWithEmail`). SDK consumers only ever see interfaces and public models — never implementation classes. + +All dependencies are constructor-injected. See `docs/dependency-injection.md`. + +## Code Formatting + +```bash +dotnet format Format.csproj +``` + +Run before committing. `Format.csproj` covers `Runtime/` and `Editor/` but excludes `ExternalDependencies/`. + +## XML Documentation + +All `public` interfaces, methods, properties, and classes require `/// ` docs with `/// ` and `/// ` where applicable. + +## Versioning and Release + +See `docs/releasing.md`. Do not manually edit `version.txt`, `SDK/package.json`, or `SDK/Runtime/Utils/SdkVersion.cs`, and do not remove the `// x-release-please-start-version` / `// x-release-please-end` markers in `SdkVersion.cs`. + +## Native Plugins + +See `docs/native-code.md` for the ARC bridging guide, `MonoPInvokeCallback` pattern, and `DllImport`/`extern` usage. diff --git a/SampleApp/CLAUDE.md b/SampleApp/CLAUDE.md new file mode 100644 index 0000000..08c2301 --- /dev/null +++ b/SampleApp/CLAUDE.md @@ -0,0 +1,3 @@ +# SampleApp/ + +A Unity project that demonstrates SDK usage. It is not a published artifact — its purpose is to exercise the public API and serve as a reference for consumers. diff --git a/docs/dependency-injection.md b/docs/dependency-injection.md new file mode 100644 index 0000000..45a2303 --- /dev/null +++ b/docs/dependency-injection.md @@ -0,0 +1,19 @@ +# Dependency Injection + +The SDK uses manual constructor injection. There is no DI framework. + +## Wiring + +All service instantiation happens in `PrivyImpl`'s constructor. When adding a new service, instantiate it there and pass its dependencies explicitly. No service locators or static helpers beyond `PrivyManager`. + +## Constructor params + +Required dependencies must be null-checked: + +```csharp +_authDelegator = authDelegator ?? throw new ArgumentNullException(nameof(authDelegator)); +``` + +## Entry point + +`PrivyManager.Initialize(config)` is the only way to create an SDK instance — no other public constructors exist. It creates `PrivyImpl`, which owns the full dependency graph.