Skip to content

Support isolated SequenceLogin instances for dual sessions - #351

Open
tolgahan-arikan wants to merge 3 commits into
masterfrom
feature/dual-session-support
Open

tolgahan-arikan wants to merge 3 commits into
masterfrom
feature/dual-session-support

Conversation

@tolgahan-arikan

@tolgahan-arikan tolgahan-arikan commented Nov 5, 2026 •

Copy link
Copy Markdown

Adds opt-in support for holding a second embedded-wallet session alongside the default one, so an existing account can be authenticated while the current guest wallet stays usable (TapNation guest-reward merge).

Related: 0xsequence/issue-tracker#7344, 0xsequence/issue-tracker#7348

Changes

  • SequenceLogin.CreateIsolatedInstance(string storageNamespace, ...): non-singleton instance.
    • Session stored under {company}-{product}-{namespace}-SessionWallet.
    • Raises per-instance OnSessionWalletCreated / OnSessionRecoveryFailed; does not raise the static SequenceWallet.OnWalletCreated / OnFailedToRecoverSession, so EmbeddedWalletAdapter and SessionManager stay on the default session.
    • No auto-federation; no writes to WaaSLoginMethod / LoginEmail PlayerPrefs.
  • PromoteToDefaultSession(SequenceWallet): writes the session to the default key, clears the namespaced key, clears federation mode on the default instance, raises SequenceWallet.OnWalletCreated. Closing the previous (guest) session stays with the caller, after transfers confirm.
  • ClearStoredSession(): removes an instance's stored session.
  • TryToRestoreSessionAsync listens to the per-instance events (default instance still raises the static ones).
  • SequenceWallet keeps its session key and owning login. On account federation it persists its own key under its owner's namespace; previously it stored the singleton's current session key, which is wrong once two sessions exist.
  • Default GetInstance() behaviour unchanged.

Verification

Batchmode harness Assets/Editor/DualSessionVerification (Unity 2022.3.62f2, dev WaaS, each phase a separate editor process; not NUnit because StoreSessionKey() disables storage during test runs):

  • setup 13/13, restart 8/8, final 2/2: guest on default + guest on isolated instance, backend sessions, storage keys, adapter/event isolation, transfer from guest, restore after restart, guest sign-out isolation, promotion, restore of promoted account.
  • email-create 2/2, email-merge 15/15: guest live, existing email account authenticated on isolated instance, wrong OTP rejected without side effects, auth returns the existing wallet, transfer guest → existing wallet, guest closed, promotion, adapter switched.
  • Existing EditMode tests (SequenceLoginTests, WaaSWalletUnitTests, InitiateEmailSignInUnitTests, WaaSToWalletAdapterUnitTests, IntentSenderTests, JwtHelperTests): 16/64 pass, identical per test to master (failures are environment/config).

Not covered

  • ERC-20/721/1155 transfers with real balances, balance pagination, fees (only zero-value native tx tested).
  • Interrupted transfer / retry reconciliation.
  • Email-conflict path when federating into the guest.
  • iOS Keychain / Android Keystore (editor storage is PlayerPrefs).
  • Backport to 4.6.7 (TapNation's reported version).

Version Increment

Please ensure you have incremented the package version in the package.json as necessary.

  • I have incremented the package.json according to semantic versioning
  • No version increment is needed; the change does not impact SDK or Sample code/assets

Docs Checklist

Please ensure you have addressed documentation updates if needed as part of this PR:

  • I have created a separate PR on the sequence docs repository for documentation updates: Link to docs PR
  • No documentation update is needed for this change.

Adds SequenceLogin.CreateIsolatedInstance(namespace) so a second wallet
session (e.g. an existing email account) can be authenticated while the
default instance keeps the current guest session.

- Isolated instances store their session under a namespaced secure
  storage key, raise per-instance OnSessionWalletCreated /
  OnSessionRecoveryFailed instead of the static SequenceWallet events,
  skip auto-federation and do not write the last-login PlayerPrefs.
- PromoteToDefaultSession(wallet) moves the session to the default key,
  clears federation mode and raises SequenceWallet.OnWalletCreated so
  EmbeddedWalletAdapter / SessionManager switch to it.
- ClearStoredSession() removes an instance's stored session.
- SequenceWallet keeps its own session key and owning login; on account
  federation it persists its own key instead of the singleton's current
  session key.
- Default GetInstance() behaviour is unchanged.

Adds a batchmode verification harness (Assets/Editor/DualSessionVerification)
that runs the guest + second-account flow across separate editor processes.
@tolgahan-arikan
tolgahan-arikan requested a review from a team November 5, 2026 15:32
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying sequence-unity with  Cloudflare Pages  Cloudflare Pages

Latest commit: f27f0c7
Status: ✅  Deploy successful!
Preview URL: https://e31f4ddd.sequence-unity.pages.dev
Branch Preview URL: https://feature-dual-session-support.sequence-unity.pages.dev

View logs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant