-
Notifications
You must be signed in to change notification settings - Fork 87
Add featured and single wallet options to Reown integration #244
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
Conversation
Introduces support for 'featuredWalletIds' and 'singleWalletId' in ReownOptions, allowing more granular control over wallet selection in the Reown wallet integration. Updates the PlaygroundManager example to showcase these new options and adds an OAuthProvider enum for improved social login handling. Also updates Reown package dependencies to version 1.5.1.
WalkthroughAdds OAuth provider selection and social wallet support; extends Reown options with FeaturedWalletIds, SingleWalletId, and TryResumeSession plus validation; updates Reown interactive and direct connection flows to honor new options; bumps multiple com.reown.* packages from 1.5.0 to 1.5.1. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Playground as PlaygroundManager
participant Manager as ThirdwebManagerBase
participant Reown as ReownWallet
participant AppKit
rect rgb(245,245,245)
Note over User,AppKit: Direct single-wallet flow (SingleWalletId set)
User->>Playground: Select Reown wallet
Playground->>Manager: ConnectWallet(reownOptions with SingleWalletId)
Manager->>Reown: Create(..., singleWalletId)
Reown->>Reown: Null included/excluded/featured in AppKitConfig
Reown->>AppKit: ConnectAsync(singleWalletId)
AppKit->>User: Direct connect (no modal)
end
rect rgb(240,250,240)
Note over User,AppKit: Featured-wallets / modal flow
User->>Playground: Select Reown wallet
Playground->>Manager: ConnectWallet(reownOptions with FeaturedWalletIds)
Manager->>Reown: Create(..., featuredWalletIds)
Reown->>Reown: Populate AppKitConfig.featuredWalletIds
Reown->>AppKit: OpenModal()
AppKit->>User: Show modal with featured wallets
end
rect rgb(250,240,245)
Note over User,Playground: OAuth social flow
User->>Playground: Choose Social provider
Playground->>Playground: Map OAuthProvider -> AuthProvider (fallback Google)
Playground->>Playground: Build InAppWalletOptions(authProvider)
Playground->>User: Trigger OAuth sign-in via InApp wallet
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Assets/Thirdweb/Examples/Scripts/PlaygroundManager.cs (1)
149-151: Guard against enum drift at runtime.
Enum.Parsewill throw ifOAuthProviderever gains a value thatAuthProviderdoesn’t recognize. UsingEnum.TryParsewith a safe fallback (e.g.,AuthProvider.Default) would keep the playground from hard-crashing during demos while still supporting future additions.- var parsedOAuthProvider = (AuthProvider)System.Enum.Parse(typeof(AuthProvider), this.Social.ToString()); + if (!System.Enum.TryParse<AuthProvider>(this.Social.ToString(), out var parsedOAuthProvider)) + { + parsedOAuthProvider = AuthProvider.Default; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
Assets/Thirdweb/Examples/Scripts/PlaygroundManager.cs(4 hunks)Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs(2 hunks)Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs(5 hunks)Packages/manifest.json(1 hunks)Packages/packages-lock.json(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Assets/Thirdweb/Examples/Scripts/PlaygroundManager.cs (2)
Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs (4)
WalletOptions(233-248)InAppWalletOptions(22-43)ReownOptions(184-209)SmartWalletOptions(134-151)Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs (2)
ReownWallet(14-355)ReownWallet(24-24)
🔇 Additional comments (1)
Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs (1)
301-308: Graceful direct-connect fallback looks solid.Nice touch using
singleWalletIdto try a directConnectAsyncbefore falling back to the modal—captures the single-wallet UX without breaking existing multi-wallet behavior.
Replaces Enum.Parse with Enum.TryParse for social auth provider selection. Defaults to Google provider if parsing fails, preventing potential runtime errors.
Introduces a tryResumeSession boolean to ReownOptions and propagates it through the wallet initialization flow. This allows control over whether to attempt resuming an existing session when initializing the Reown wallet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs (3)
178-186: Serialize cleanly; ignore nulls for new fields.To reduce noise in persisted JSON (PlayerPrefs) and API payloads, ignore nulls for optional fields.
- [JsonProperty("featuredWalletIds")] + [JsonProperty("featuredWalletIds", NullValueHandling = NullValueHandling.Ignore)] public string[] FeaturedWalletIds; - [JsonProperty("singleWalletId")] + [JsonProperty("singleWalletId", NullValueHandling = NullValueHandling.Ignore)] public string SingleWalletId;
200-203: Tighten validation; treat whitespace as null and allow empty arrays.Current check blocks even empty arrays and allows whitespace-only SingleWalletId. Prefer non-empty arrays and non-blank single ID.
- if (singleWalletId != null && (includedWalletIds != null || excludedWalletIds != null || featuredWalletIds != null)) + singleWalletId = string.IsNullOrWhiteSpace(singleWalletId) ? null : singleWalletId; + var hasIncluded = (includedWalletIds?.Length ?? 0) > 0; + var hasExcluded = (excludedWalletIds?.Length ?? 0) > 0; + var hasFeatured = (featuredWalletIds?.Length ?? 0) > 0; + if (singleWalletId != null && (hasIncluded || hasExcluded || hasFeatured)) { throw new ArgumentException("singleWalletId cannot be used with includedWalletIds, excludedWalletIds, or featuredWalletIds."); }
211-213: Defensive copies for arrays.Clone arrays to avoid external mutation after construction.
- this.FeaturedWalletIds = featuredWalletIds; - this.SingleWalletId = singleWalletId; + this.FeaturedWalletIds = featuredWalletIds?.ToArray(); + this.SingleWalletId = singleWalletId; this.TryResumeSession = tryResumeSession;Add once at file top:
using System.Linq;Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs (3)
60-63: Handle blank SingleWalletId and keep arrays when blank.Use IsNullOrWhiteSpace so whitespace doesn’t null out arrays.
- includedWalletIds = singleWalletId == null ? includedWalletIds : null, - excludedWalletIds = singleWalletId == null ? excludedWalletIds : null, - featuredWalletIds = singleWalletId == null ? featuredWalletIds : null, + includedWalletIds = string.IsNullOrWhiteSpace(singleWalletId) ? includedWalletIds : null, + excludedWalletIds = string.IsNullOrWhiteSpace(singleWalletId) ? excludedWalletIds : null, + featuredWalletIds = string.IsNullOrWhiteSpace(singleWalletId) ? featuredWalletIds : null,
275-275: Optional: support cancellation in wait helper.Consider accepting a CancellationToken to allow callers to abort before timeout (e.g., scene unload).
- private static async Task<bool> WaitForInteractiveConnectionAsync(TimeSpan timeout, string singleWalletId = null) + private static async Task<bool> WaitForInteractiveConnectionAsync(TimeSpan timeout, string singleWalletId = null, System.Threading.CancellationToken cancellationToken = default)Then compose a
var cancelTask = ThirdwebTask.Run(cancellationToken);(or equivalent) and include it inTask.WhenAny(...). If no helper exists, you can create aTaskCompletionSource<bool>that completes on token cancellation.
302-309: Fallback to modal if direct connect fails.
AppKit.ConnectAsync(singleWalletId)exceptions will currently bubble and abort the flow. Prefer graceful degradation to the modal when the single wallet ID is invalid/unavailable.- if (singleWalletId != null) - { - await AppKit.ConnectAsync(singleWalletId); - } - else - { - AppKit.OpenModal(); - } + if (!string.IsNullOrWhiteSpace(singleWalletId)) + { + try + { + await AppKit.ConnectAsync(singleWalletId); + } + catch (Exception e) + { + ThirdwebDebug.LogWarning($"Reown direct connect failed ({singleWalletId}): {e.Message}. Falling back to modal."); + AppKit.OpenModal(); + } + } + else + { + AppKit.OpenModal(); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs(2 hunks)Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs(6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs (1)
Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs (5)
Task(376-384)Task(390-585)Task(587-601)Task(603-643)Task(645-658)
🔇 Additional comments (5)
Assets/Thirdweb/Runtime/Unity/ThirdwebManagerBase.cs (2)
451-455: LGTM: Reown.Create passthrough extended parameters.The new arguments are correctly forwarded under THIRDWEB_REOWN.
194-198: No positional constructor calls found—concern does not apply.The verification found all
ReownOptionscall sites use either the default constructor or named arguments. Zero positional argument invocations exist, so parameter reordering poses no risk of subtle misbinding.Assets/Thirdweb/Runtime/Unity/Wallets/Reown/ReownWallet.cs (3)
79-79: LGTM: Resume only when allowed.Gating session resume on TryResumeSession is correct and non-breaking.
88-88: LGTM: Direct-connect when SingleWalletId provided.Passing singleWalletId into the interactive wait aligns with the new flow.
35-39: Create(...) API change is safe: internal call uses named arguments.Verification found only one call site in the repo (
ThirdwebManagerBase.cs:442), which correctly uses named arguments:wallet = await ReownWallet.Create( client: this.Client, activeChainId: walletOptions.ChainId, projectId: walletOptions.ReownOptions.ProjectId, ...All new parameters lack defaults, so any external positional callers would fail at compile time—standard breaking change behavior requiring recompilation.
Introduces support for 'featuredWalletIds' and 'singleWalletId' in ReownOptions, allowing more granular control over wallet selection in the Reown wallet integration. Updates the PlaygroundManager example to showcase these new options and adds an OAuthProvider enum for improved social login handling. Also updates Reown package dependencies to version 1.5.1.
PR-Codex overview
This PR focuses on updating the version of several
com.reownpackages in themanifest.jsonand modifying theReownOptionsclass and related methods to include new properties. It also introduces a newOAuthProviderenum and updates wallet connection logic.Detailed summary
com.reownpackage versions from1.5.0to1.5.1inPackages/manifest.json.FeaturedWalletIds,SingleWalletId,TryResumeSessiontoReownOptions.ReownOptionsto validatesingleWalletIdusage.OAuthProviderenum inPlaygroundManager.Wallet_Socialmethod to parseSocialproperty intoAuthProvider.Wallet_External_Directmethod for direct wallet connections.Summary by CodeRabbit
New Features
Chores