Skip to content

Conversation

@pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Jan 13, 2026

Handle optional origin/pageMeta inputs in watchAsset approvals. Add tests covering empty-string origin fallbacks and requestMetadata precedence.

Explanation

References

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

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

Enhances watchAsset approval flow with origin/page metadata handling and safer defaults.

  • TokensController.watchAsset accepts optional origin, pageMeta, and requestMetadata; origin resolves via getNonEmptyString with fallback to ORIGIN_METAMASK, and pageMeta is forwarded in requestData.metadata
  • Extends SuggestedAssetMeta and adds WatchAssetRequestMetadata; imports Json; new getNonEmptyString helper
  • Approval request now normalizes empty image to null
  • Refactors multiple || to ?? and adds trim checks when defaulting token image URLs
  • Tests added for empty-string origin fallback and requestMetadata.origin precedence
  • Changelog updated to note watchAsset origin/page metadata support

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

@pedronfigueiredo pedronfigueiredo self-assigned this Jan 13, 2026
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners January 13, 2026 17:58
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/2395-watch-asset-origin branch from 68edcc9 to 2e6bd15 Compare January 13, 2026 18:21
@pedronfigueiredo pedronfigueiredo changed the title Add watchAsset origin metadata fallbacks feat: Add watchAsset origin metadata fallbacks Jan 13, 2026
sahar-fehri
sahar-fehri previously approved these changes Jan 14, 2026
Handle optional origin/pageMeta inputs in watchAsset approvals.
Add tests covering empty-string origin fallbacks and requestMetadata precedence.
Avoid empty-string origins without using logical OR defaults.
Switch default-value fallbacks to nullish or explicit checks to satisfy lint.
Use array shorthand syntax and satisfy prettier formatting in TokensController.
sahar-fehri
sahar-fehri previously approved these changes Jan 14, 2026
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 14, 2026
Merged via the queue into main with commit 81972f6 Jan 14, 2026
290 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/2395-watch-asset-origin branch January 14, 2026 10:33
cursor bot pushed a commit that referenced this pull request Jan 14, 2026
Resolved merge conflict in CHANGELOG.md by combining:
- TokensController.watchAsset metadata fallbacks from main (#7612)
- CurrencyRateController refactor entry from this branch (#7606)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants