Skip to content
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
44 changes: 44 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -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 |
40 changes: 40 additions & 0 deletions SDK/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -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 `/// <summary>` docs with `/// <param>` and `/// <exception cref="">` 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.
3 changes: 3 additions & 0 deletions SampleApp/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions docs/dependency-injection.md
Original file line number Diff line number Diff line change
@@ -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.
Loading