Skip to content

feat: Add originMetadata to requests - #4093

Merged
FrederikBolding merged 11 commits into
mainfrom
fb/add-origin-metadata
Aug 10, 2026
Merged

FrederikBolding merged 11 commits into
mainfrom
fb/add-origin-metadata

Conversation

@FrederikBolding

@FrederikBolding FrederikBolding commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Add an originMetadata field to handlers arguments that also contain origin. This should only be used when the origin is using a non-verifiable transport.

https://consensyssoftware.atlassian.net/browse/WPC-1195


Note

Medium Risk
Touches the full inbound RPC path to Snaps and expands handler APIs; behavior is backward-compatible (optional field, null default) but Snaps may start relying on self-reported origin data for UX or policy.

Overview
Introduces OriginMetadata in snaps-sdk (transport, selfReportedOrigin) and threads optional originMetadata from multichain routing and SnapController through ExecutionService into the snap executor.

Snap handlers that already receive origin now also get originMetadata: OriginMetadata | null (defaults to null when omitted): onRpcRequest, onKeyringRequest, onProtocolRequest, and lifecycle hooks (onInstall, onUpdate, onStart, onActive, onInactive). JSDoc states this is for transports that cannot verify the origin.

SnapRpcHookArgs, snapRpc validation, and getHandlerArguments are updated accordingly; simulation/jest expectations include originMetadata: null when not provided. Browser tests cover passing metadata through multiple handler types.

Reviewed by Cursor Bugbot for commit ff3d47c. Bugbot is set up for automated code reviews on this repo. Configure here.

@FrederikBolding
FrederikBolding force-pushed the fb/add-origin-metadata branch from a7d0d59 to 992ae4b Compare August 5, 2026 10:14
@FrederikBolding
FrederikBolding force-pushed the fb/add-origin-metadata branch from 157e037 to 5a770b9 Compare August 5, 2026 10:42
@codecov

codecov Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (a2ea600) to head (ff3d47c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4093   +/-   ##
=======================================
  Coverage   98.59%   98.59%           
=======================================
  Files         428      429    +1     
  Lines       12485    12495   +10     
  Branches     1975     1976    +1     
=======================================
+ Hits        12310    12320   +10     
  Misses        175      175           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

case HandlerType.OnActive:
case HandlerType.OnInactive:
return { origin };
return { origin, originMetadata };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we get originMetadata on these ? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was thinking in case we ever allow installation/update of Snaps on mobile, we would want to pass originMetadata there as well. Though we could remove this for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't mind keeping it, that makes sense

@FrederikBolding
FrederikBolding marked this pull request as ready for review August 10, 2026 08:50
@FrederikBolding
FrederikBolding requested a review from a team as a code owner August 10, 2026 08:50
@FrederikBolding
FrederikBolding added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 71f182e Aug 10, 2026
132 checks passed
@FrederikBolding
FrederikBolding deleted the fb/add-origin-metadata branch August 10, 2026 08:51
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.

2 participants