Skip to content

fix: watch asset origin metadata#24488

Merged
pedronfigueiredo merged 3 commits intomainfrom
pnf/2395-watch-asset-origin
Jan 16, 2026
Merged

fix: watch asset origin metadata#24488
pedronfigueiredo merged 3 commits intomainfrom
pnf/2395-watch-asset-origin

Conversation

@pedronfigueiredo
Copy link
Copy Markdown
Contributor

@pedronfigueiredo pedronfigueiredo commented Jan 13, 2026

Pass page meta and origin into watchAsset approvals so the UI displays the requesting dapp instead of the active tab.

Description

Changelog

CHANGELOG entry:

Related issues

Fixes: https://github.com/MetaMask/mobile-planning/issues/2395

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Screenshot 2026-01-16 at 10 16 53

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Aligns watch-asset requests with the requesting dapp’s metadata so approvals display the correct origin.

  • Plumbs pageMeta (url/title/icon/channelId/analytics) through RPC middleware into wallet_watchAsset; derive origin from pageMeta.url or hostname.
  • In wallet_watchAsset, sanitize pageMeta via getSafeJson and forward origin, pageMeta, and requestMetadata to TokensController.watchAsset; adjust tests to assert these fields.
  • UI: ApproveTransactionHeader url now falls back to currentPageInformation?.url ?? activeTabUrl to show the requesting page.

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

@pedronfigueiredo pedronfigueiredo self-assigned this Jan 13, 2026
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner January 13, 2026 18:34
@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Jan 13, 2026
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner January 13, 2026 18:34
@pedronfigueiredo pedronfigueiredo added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Jan 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@pedronfigueiredo pedronfigueiredo changed the title Fix watch asset origin metadata fix: watch asset origin metadata Jan 13, 2026
@pedronfigueiredo pedronfigueiredo added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jan 14, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/2395-watch-asset-origin branch 2 times, most recently from cf50cd1 to 6ae90b2 Compare January 16, 2026 12:00
Pass page meta and origin into watchAsset approvals so the UI displays the requesting dapp instead of the active tab.
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/2395-watch-asset-origin branch from 6ae90b2 to 3051d87 Compare January 16, 2026 14:30
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions, SmokeConfirmationsRedesigned
  • Risk Level: medium
  • AI Confidence: 75%
click to see 🤖 AI reasoning details

The changes modify the wallet_watchAsset RPC method in the core RPCMethods directory, which is a critical path. The changes:

  1. wallet_watchAsset.ts: Adds pageMeta parameter and passes origin, pageMeta, and requestMetadata to TokensController.watchAsset(). This enhances metadata tracking for token watch requests.

  2. RPCMethodMiddleware.ts: Passes page metadata (URL, title, icon, channelId, analytics) to the wallet_watchAsset handler.

  3. WatchAssetRequest/index.js: Fixes the URL display in the confirmation header to use currentPageInformation?.url instead of activeTabUrl.

  4. wallet_watchAsset.test.ts: Updates unit tests for the new fields.

The E2E test import-tokens-via-asset-watcher.spec.ts directly tests this functionality using RegressionNetworkAbstractions tag. Since we need to select from smoke tags:

  • SmokeNetworkAbstractions: Selected because the asset watcher functionality is related to network abstractions (the regression test uses RegressionNetworkAbstractions), and the changes affect how dApps interact with the wallet to add tokens.

  • SmokeConfirmationsRedesigned: Selected because the WatchAssetRequest component is part of the confirmations flow (located in confirmations/legacy/components/), and the change affects how the origin URL is displayed in the ApproveTransactionHeader.

The changes are well-scoped with unit tests updated, but since they touch core RPC handling and confirmation UI, running these smoke tests provides adequate coverage.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
55.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit e84c163 Jan 16, 2026
172 of 175 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/2395-watch-asset-origin branch January 16, 2026 17:53
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
@metamaskbot metamaskbot added the release-7.63.0 Issue or pull request that will be included in release 7.63.0 label Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.63.0 Issue or pull request that will be included in release 7.63.0 size-S skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants