Skip to content

Conversation

@ccharly
Copy link
Contributor

@ccharly ccharly commented Nov 28, 2025

Explanation

Snap requests are now delayed after the onboarding, to avoid starting requests "too soon" on the clients, we now have a logic to wait for the Snap platform to be ready.

This makes sure that any calls that uses retries or timeouts will start their calls AFTER the Snap platform is ready to process anything.

We stumbled upon this bug during the concurrent requests/Snap state inconsistency investigation. Initial account providers requests were usually timing out because they were hitting their limit because they were starting a bit "late" since the Snap platform was not ready yet. (This was also still causing concurrent requests, despite the maxConcurrency: 1, since Snaps were still processing the timed out request while receiving new ones).

To future-proof this and fully await for the Snap platform to be ready, we now send 1 simple Snap request and wait for it to be executed (being successful or not). Then, we start processing all Snap requests with our usual logic (timeouts, semaphore, retries, etc...)

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Waits for the Snap platform to be ready before any provider operations, renaming abstract create/discover methods to run* and updating providers/tests accordingly.

  • Core (SnapAccountProvider)
    • Add ensureSnapPlatformIsReady (singleton promise) and call it in constructor and before createAccounts, discoverAccounts, resyncAccounts, and Snap keyring access.
    • Implement readiness ping via KeyringRpcMethod.GetAccount/ListAccounts through KeyringClient.
    • Base now implements createAccounts/discoverAccounts to await readiness, delegating to new abstract runCreateAccounts/runDiscoverAccounts.
    • Add helper BaseBip44AccountProvider.getAnyAccount() to support fast ping selection.
  • Providers
    • Update SolAccountProvider, BtcAccountProvider, TrxAccountProvider to use runCreateAccounts/runDiscoverAccounts (renamed from createAccounts/discoverAccounts).
  • Tests
    • Introduce mock providers overriding readiness wait; add tests for platform readiness behavior; update existing tests to new method names and messaging mocks.
  • Changelog
    • Document added Snap readiness wait and BREAKING rename of abstract methods.

Written by Cursor Bugbot for commit 0ccef45. This will update automatically on new commits. Configure here.


readonly #trace: TraceCallback;

protected static ensureSnapPlatformIsReadyPromise: Promise<void> | null =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly using a protected static here so we can write tests and update this without exposing it completely publicly (consumers could still hack this easily though..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Should we have a 1 promise per Snap? This would allow to wait for the Snap to be ready rather than the Snap platform itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the snap be ready if the platform is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so yes, so I think we can keep this as-is!

abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;

abstract createAccounts(options: {
abstract runCreateAccounts(options: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now providers have to implements those run* methods, so we can automatically call this.ensureSnapPlatformIsReady for any of those actions.

@ccharly ccharly changed the title Cc/fix/account providers wait for snap platform fix(multichain-account-service): wait for Snap platform to be ready Nov 28, 2025
@ccharly ccharly changed the title fix(multichain-account-service): wait for Snap platform to be ready fix(multichain-account-service)!: wait for Snap platform to be ready Dec 1, 2025
@ccharly ccharly marked this pull request as ready for review December 1, 2025 15:13
@ccharly ccharly requested review from a team as code owners December 1, 2025 15:13
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.

3 participants