Skip to content

Commit

Permalink
Simplify origin handling
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Nov 15, 2024
1 parent 503050a commit 89fa924
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,10 @@ export class MultichainRoutingController extends BaseController<
if (protocolSnap) {
return this.messagingSystem.call('SnapController:handleRequest', {
snapId: protocolSnap.snapId,
origin: 'metamask',
origin,
request: {
method: '',
params: {
// We are overriding the origin here, so that the Snap gets the proper origin
// while the permissions check is skipped due to the requesting origin being metamask.
origin,
request,
scope,
},
Expand Down
9 changes: 2 additions & 7 deletions packages/snaps-execution-environments/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ export function getHandlerArguments(
case HandlerType.OnProtocolRequest: {
assertIsOnProtocolRequestArguments(request.params);

// For this specific handler we extract the origin from the parameters.
const {
origin: nestedOrigin,
request: nestedRequest,
scope,
} = request.params;
return { origin: nestedOrigin, request: nestedRequest, scope };
const { request: nestedRequest, scope } = request.params;
return { request: nestedRequest, scope };
}

case HandlerType.OnRpcRequest:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export function assertIsOnUserInputRequestArguments(
}

export const OnProtocolRequestArgumentsStruct = object({
origin: string(),
scope: ChainIdStruct,
request: JsonRpcRequestStruct,
});
Expand Down

0 comments on commit 89fa924

Please sign in to comment.