-
Notifications
You must be signed in to change notification settings - Fork 124
feat(mwa): API parity, auth cache, disconnect/reconnect UX #264
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
Open
Pratikkale26
wants to merge
4
commits into
magicblock-labs:main
Choose a base branch
from
Pratikkale26:feature/mwa-api-parity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6d9f699
feat(mwa): API parity, auth cache, disconnect/reconnect UX
Pratikkale26 093c785
docs: add pitch deck for Solana Seeker grant
Pratikkale26 2ae1ae9
fix(mwa): address all CodeRabbit review comments
Pratikkale26 1f6602f
fix(mwa): properly reference nested ResponseError class
Pratikkale26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| # 🎮 Unity Mobile Wallet Adapter SDK – API Parity & UX Improvements | ||
|
|
||
| > **Applicant:** Pratik Kale | ||
| > **GitHub:** https://github.com/Pratikkale26/Solana.Unity-SDK | ||
| > **Proposal for:** Solana Seeker – Unity Mobile Wallet Adapter SDK RFP | ||
|
|
||
| --- | ||
|
|
||
| ## 🧠 TL;DR | ||
|
|
||
| This proposal delivers full API parity for the Unity Mobile Wallet Adapter SDK, introduces a persistent authorization cache layer, and improves wallet lifecycle UX (connect, disconnect, reconnect). | ||
|
|
||
| The core SDK implementation is already completed and submitted as a Draft PR, significantly reducing execution risk. This grant focuses on productionizing the work through documentation, example apps, and final integration. | ||
|
|
||
| --- | ||
|
|
||
| ## 🔴 Problem | ||
|
|
||
| The current Mobile Wallet Adapter (MWA) implementation in the Unity SDK lacks key functionality already available in the React Native SDK. | ||
|
|
||
| As a result, Unity-based Solana mobile games suffer from poor wallet UX: | ||
|
|
||
| - Missing `deauthorize` and `get_capabilities` APIs | ||
| - No persistent auth token storage (tokens are lost on app restart) | ||
| - Users must re-approve wallet connections every session | ||
| - No clean disconnect or silent reconnect flow | ||
|
|
||
| This leads to: | ||
| - Friction in player onboarding | ||
| - Poor user retention | ||
| - Inconsistent developer experience compared to React Native | ||
|
|
||
| --- | ||
|
|
||
| ## ✅ Solution | ||
|
|
||
| This proposal introduces a complete upgrade to the Unity MWA stack, aligning it with React Native capabilities while improving developer ergonomics. | ||
|
|
||
| ### 1. API Parity | ||
|
|
||
| Added missing methods: | ||
| - `deauthorize` (revoke wallet session) | ||
| - `get_capabilities` (wallet feature detection) | ||
|
|
||
| Implemented in: | ||
| - `IAdapterOperations` | ||
| - `MobileWalletAdapterClient` | ||
|
|
||
| --- | ||
|
|
||
| ### 2. Extensible Auth Cache Layer | ||
|
|
||
| Introduced a pluggable caching system: | ||
|
|
||
| ```text | ||
| IMwaAuthCache | ||
| ├── PlayerPrefsAuthCache (default) | ||
| └── EncryptedAuthCache (extensible template) | ||
| ``` | ||
|
|
||
| Developers can inject custom secure storage: | ||
|
|
||
| ```csharp | ||
| var wallet = new SolanaWalletAdapter(options, authCache: new MySecureCache()); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 3. Seamless Reconnect UX | ||
|
|
||
| * `Login()` attempts silent `reauthorize` using cached token | ||
| * Falls back to full authorization only if needed | ||
|
|
||
| 👉 Eliminates repeated wallet approval popups | ||
|
|
||
| --- | ||
|
|
||
| ### 4. Clean Disconnect Flow | ||
|
|
||
| ```csharp | ||
| await wallet.DisconnectWallet(); // revokes token + clears cache | ||
| await wallet.ReconnectWallet(); // silent or full auth | ||
|
|
||
| wallet.OnWalletDisconnected += () => ShowConnectScreen(); | ||
| wallet.OnWalletReconnected += () => RestoreGameState(); | ||
|
|
||
| await wallet.GetCapabilities(); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 🔬 Proof of Work | ||
|
|
||
| The full implementation is already completed and submitted as a Draft PR: | ||
|
|
||
| 👉 [https://github.com/magicblock-labs/Solana.Unity-SDK/pull/264](https://github.com/magicblock-labs/Solana.Unity-SDK/pull/264) | ||
|
|
||
| This includes: | ||
|
|
||
| * API parity implementation | ||
| * Auth cache system | ||
| * Wallet lifecycle improvements | ||
| * Unit test coverage for cache layer | ||
|
|
||
| This significantly reduces delivery risk and ensures the grant funds are used for production readiness rather than initial development. | ||
|
|
||
| --- | ||
|
|
||
| ## 🛠 Scope of Work (Grant Deliverables) | ||
|
|
||
| The grant will fund the completion and productionization of this work: | ||
|
|
||
| | Deliverable | Timeline | | ||
| | ----------------------------------------------------------------------- | -------- | | ||
| | 📄 SDK Documentation (installation, API reference, cache customization) | Week 1–3 | | ||
| | 📱 Open-source Unity Android Example App (demonstrating full MWA flow) | Week 4–5 | | ||
| | 🔧 PR review cycles, fixes, and upstream merge support | Ongoing | | ||
|
|
||
| --- | ||
|
|
||
| ## 💰 Budget — $6,500 USD (in SKR) | ||
|
|
||
| | Item | Cost | | ||
| | -------------------------------------------------------------- | ---------- | | ||
| | Core SDK implementation (API parity, auth cache, lifecycle UX) | $2,200 | | ||
| | PR review rounds + integration polish | $800 | | ||
| | Full SDK documentation | $1,200 | | ||
| | Open-source Example Android App | $1,200 | | ||
| | Community support + post-merge maintenance | $600 | | ||
| | Buffer / contingency | $500 | | ||
| | **Total** | **$6,500** | | ||
|
|
||
| --- | ||
|
|
||
| ## 🚀 Impact | ||
|
|
||
| This upgrade improves the developer experience for Unity game developers building on Solana Mobile by: | ||
|
|
||
| * Enabling persistent wallet sessions across app restarts | ||
| * Reducing friction in player onboarding | ||
| * Providing API parity with the React Native SDK | ||
| * Making wallet lifecycle management predictable and production-ready | ||
|
|
||
| By aligning Unity tooling with Solana Mobile standards, this work helps unlock broader adoption of Solana in mobile gaming. | ||
|
|
||
| --- | ||
|
|
||
| ## 👤 About Me | ||
|
|
||
| **Pratik Kale** | ||
| Full-Stack Developer & Solana Builder | ||
|
|
||
| * GitHub: [https://github.com/Pratikkale26](https://github.com/Pratikkale26) | ||
| * Twitter: [https://x.com/PratikKale26](https://x.com/PratikKale26) | ||
|
|
||
| I focus on building developer tooling and infrastructure in the Solana ecosystem, with an emphasis on improving developer experience and real-world usability. | ||
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
45 changes: 45 additions & 0 deletions
45
Runtime/codebase/SolanaMobileStack/JsonRpcClient/Responses/WalletCapabilities.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| using System.Collections.Generic; | ||
| using Newtonsoft.Json; | ||
| using UnityEngine.Scripting; | ||
|
|
||
| // ReSharper disable once CheckNamespace | ||
|
|
||
| /// <summary> | ||
| /// Represents the capabilities reported by a connected wallet via the get_capabilities MWA endpoint. | ||
| /// All properties are optional — wallets may omit fields they do not support. | ||
| /// </summary> | ||
| [Preserve] | ||
| public class WalletCapabilities | ||
| { | ||
| /// <summary> | ||
| /// Maximum number of transaction payloads that can be signed in a single request. | ||
| /// Null if the wallet does not report this limit. | ||
| /// </summary> | ||
| [JsonProperty("max_transactions_per_request")] | ||
| public int? MaxTransactionsPerRequest { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Maximum number of message payloads that can be signed in a single request. | ||
| /// Null if the wallet does not report this limit. | ||
| /// </summary> | ||
| [JsonProperty("max_messages_per_request")] | ||
| public int? MaxMessagesPerRequest { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Supported Solana transaction versions (e.g. "legacy", "0"). | ||
| /// Null or empty if the wallet does not report this capability. | ||
| /// </summary> | ||
| [JsonProperty("supported_transaction_versions")] | ||
| public List<string> SupportedTransactionVersions { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Whether the wallet supports clone authorization, which allows | ||
| /// one authorization context to extend to another app instance. | ||
| /// Null if the wallet does not report this capability. | ||
| /// </summary> | ||
| [JsonProperty("supports_clone_authorization")] | ||
| public bool? SupportsCloneAuthorization { get; set; } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| [Preserve] | ||
| public WalletCapabilities() { } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
Runtime/codebase/SolanaMobileStack/JsonRpcClient/Responses/WalletCapabilities.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.