Skip to content

Conversation

@montelaidev
Copy link
Contributor

@montelaidev montelaidev commented Oct 30, 2025

Explanation

This PR adds traces to the Multichain Account Service.

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Adds configurable tracing with a fallback across the service and providers, wrapping account discovery in trace callbacks.

  • Core
    • MultichainAccountService now accepts config.trace and passes a TraceCallback to providers; defaults to traceFallback.
  • Providers
    • EvmAccountProvider: constructor accepts optional TraceCallback; discoverAccounts wrapped with TraceName.EvmDiscoverAccounts.
    • SnapAccountProvider: constructor accepts TraceCallback (default traceFallback); adds protected trace helper.
    • SolAccountProvider, TrxAccountProvider, BtcAccountProvider: constructors accept TraceCallback; discoverAccounts wrapped with TraceName.SnapDiscoverAccounts.
  • Analytics
    • Add src/analytics/traces.ts with traceFallback and src/constants/traces.ts with TraceName; export via src/analytics/index.ts.
  • Tests
    • Add/adjust tests to verify tracing callbacks and constructor args; minor event emission assertion improvements.
  • Changelog
    • Note optional tracing configuration (account discovery traced).

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

@montelaidev montelaidev requested review from a team as code owners October 30, 2025 10:02
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@montelaidev
Copy link
Contributor Author

@metamaskbot publish-preview

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-tree-controller": "2.0.0-preview-51709948",
  "@metamask-previews/accounts-controller": "34.0.0-preview-51709948",
  "@metamask-previews/address-book-controller": "7.0.0-preview-51709948",
  "@metamask-previews/announcement-controller": "8.0.0-preview-51709948",
  "@metamask-previews/app-metadata-controller": "2.0.0-preview-51709948",
  "@metamask-previews/approval-controller": "8.0.0-preview-51709948",
  "@metamask-previews/assets-controllers": "86.0.0-preview-51709948",
  "@metamask-previews/base-controller": "9.0.0-preview-51709948",
  "@metamask-previews/bridge-controller": "58.0.0-preview-51709948",
  "@metamask-previews/bridge-status-controller": "58.0.0-preview-51709948",
  "@metamask-previews/build-utils": "3.0.4-preview-51709948",
  "@metamask-previews/chain-agnostic-permission": "1.2.2-preview-51709948",
  "@metamask-previews/composable-controller": "12.0.0-preview-51709948",
  "@metamask-previews/controller-utils": "11.15.0-preview-51709948",
  "@metamask-previews/core-backend": "4.0.0-preview-51709948",
  "@metamask-previews/delegation-controller": "1.0.0-preview-51709948",
  "@metamask-previews/earn-controller": "9.0.0-preview-51709948",
  "@metamask-previews/eip-5792-middleware": "2.0.0-preview-51709948",
  "@metamask-previews/eip-7702-internal-rpc-middleware": "0.1.0-preview-51709948",
  "@metamask-previews/eip1193-permission-middleware": "1.0.2-preview-51709948",
  "@metamask-previews/ens-controller": "18.0.0-preview-51709948",
  "@metamask-previews/error-reporting-service": "3.0.0-preview-51709948",
  "@metamask-previews/eth-block-tracker": "14.0.0-preview-51709948",
  "@metamask-previews/eth-json-rpc-middleware": "21.0.0-preview-51709948",
  "@metamask-previews/eth-json-rpc-provider": "5.0.1-preview-51709948",
  "@metamask-previews/foundryup": "1.0.1-preview-51709948",
  "@metamask-previews/gas-fee-controller": "25.0.0-preview-51709948",
  "@metamask-previews/gator-permissions-controller": "0.3.0-preview-51709948",
  "@metamask-previews/json-rpc-engine": "10.1.1-preview-51709948",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.8-preview-51709948",
  "@metamask-previews/keyring-controller": "24.0.0-preview-51709948",
  "@metamask-previews/logging-controller": "7.0.0-preview-51709948",
  "@metamask-previews/message-manager": "14.0.0-preview-51709948",
  "@metamask-previews/messenger": "0.3.0-preview-51709948",
  "@metamask-previews/multichain-account-service": "2.0.0-preview-51709948",
  "@metamask-previews/multichain-api-middleware": "1.2.4-preview-51709948",
  "@metamask-previews/multichain-network-controller": "2.0.0-preview-51709948",
  "@metamask-previews/multichain-transactions-controller": "6.0.0-preview-51709948",
  "@metamask-previews/name-controller": "9.0.0-preview-51709948",
  "@metamask-previews/network-controller": "25.0.0-preview-51709948",
  "@metamask-previews/network-enablement-controller": "3.1.0-preview-51709948",
  "@metamask-previews/notification-services-controller": "19.0.0-preview-51709948",
  "@metamask-previews/permission-controller": "12.1.0-preview-51709948",
  "@metamask-previews/permission-log-controller": "5.0.0-preview-51709948",
  "@metamask-previews/phishing-controller": "15.0.0-preview-51709948",
  "@metamask-previews/polling-controller": "15.0.0-preview-51709948",
  "@metamask-previews/preferences-controller": "21.0.0-preview-51709948",
  "@metamask-previews/profile-sync-controller": "26.0.0-preview-51709948",
  "@metamask-previews/rate-limit-controller": "7.0.0-preview-51709948",
  "@metamask-previews/remote-feature-flag-controller": "2.0.0-preview-51709948",
  "@metamask-previews/sample-controllers": "3.0.0-preview-51709948",
  "@metamask-previews/seedless-onboarding-controller": "6.0.0-preview-51709948",
  "@metamask-previews/selected-network-controller": "25.0.0-preview-51709948",
  "@metamask-previews/shield-controller": "1.1.0-preview-51709948",
  "@metamask-previews/signature-controller": "35.0.0-preview-51709948",
  "@metamask-previews/subscription-controller": "3.1.0-preview-51709948",
  "@metamask-previews/token-search-discovery-controller": "4.0.0-preview-51709948",
  "@metamask-previews/transaction-controller": "61.1.0-preview-51709948",
  "@metamask-previews/transaction-pay-controller": "2.0.0-preview-51709948",
  "@metamask-previews/user-operation-controller": "40.0.0-preview-51709948"
}

@@ -0,0 +1,4 @@
export enum TraceName {
'SnapDiscoverAccounts' = 'Snap Discover Accounts',
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think Snap* is too generic. Since we're providing the providerName in the trace parameter, maybe we can just use DiscoverAccounts for any providers instead? And we always pass a providerName parameter?

{
name: TraceName.EvmDiscoverAccounts,
data: {
providerName: this.getName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd just rename providerName to provider in this context

const mockTrace = jest.fn().mockImplementation(async (request, fn) => {
expect(request.name).toBe('EVM Discover Accounts');
expect(request.data).toStrictEqual({
providerName: 'EVM',
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use the constant EVM_ACCOUNT_PROVIDER_NAME here

const mockTrace = jest.fn().mockImplementation(async (request, fn) => {
expect(request.name).toBe('EVM Discover Accounts');
expect(request.data).toStrictEqual({
providerName: 'EVM',
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, use the constant here too

Comment on lines 10 to 12
### Changed

- Adds an optional trace argument to MultichainAccountService and MultichainAccountWallet ([#7006](https://github.com/MetaMask/core/pull/7006))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Changed
- Adds an optional trace argument to MultichainAccountService and MultichainAccountWallet ([#7006](https://github.com/MetaMask/core/pull/7006))
### Added
- Add optional tracing configuration ([#7006](https://github.com/MetaMask/core/pull/7006))
- For now, only the account discovery is being traced.

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