Skip to content

Commit bf157ae

Browse files
committed
Move execution-permissions to delegations to be more general purpose
1 parent a6ffc4a commit bf157ae

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

packages/signature-controller/src/SignatureController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
decodePermissionFromRequest,
5858
isDelegationRequest,
5959
validateExecutionPermissionMetadata,
60-
} from './utils/execution-permissions';
60+
} from './utils/delegations';
6161
import {
6262
normalizePersonalMessageParams,
6363
normalizeTypedMessageParams,

packages/signature-controller/src/utils/execution-permissions.test.ts renamed to packages/signature-controller/src/utils/delegations.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {
55
decodePermissionFromRequest,
66
isDelegationRequest,
77
validateExecutionPermissionMetadata,
8-
} from './execution-permissions';
8+
} from './delegations';
99
import type { SignatureControllerMessenger } from '../SignatureController';
1010
import type { MessageParamsTyped, MessageParamsTypedData } from '../types';
1111

12-
describe('execution-permissions utils', () => {
12+
describe('delegations utils', () => {
1313
describe('isDelegationRequest', () => {
1414
it('returns true for object data with primaryType Delegation', () => {
1515
const result = isDelegationRequest({

packages/signature-controller/src/utils/execution-permissions.ts renamed to packages/signature-controller/src/utils/delegations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ const DELEGATION_PRIMARY_TYPE = 'Delegation';
1616
* Accepts either a pre-parsed typed data object or a JSON string. If a string is
1717
* provided, it is parsed. Returns true when the `primaryType` is "Delegation".
1818
*
19-
* @param params - Wrapper object for parameters.
20-
* @param params.data - EIP-712 typed data object or its JSON string representation.
19+
* @param data - EIP-712 typed data object or its JSON string representation.
20+
*
2121
* @returns True if the typed message is a Delegation request; otherwise false.
22-
* @throws {Error} If the `data` argument is a string that cannot be parsed as valid JSON.
2322
*/
2423
export function isDelegationRequest(data: MessageParamsTypedData): boolean {
2524
const { primaryType } = data;
@@ -35,9 +34,10 @@ export function isDelegationRequest(data: MessageParamsTypedData): boolean {
3534
* context to the permissions controller via the supplied messenger.
3635
*
3736
* @param params - Wrapper object for parameters.
38-
* @param params.messageParams - The typed message parameters to decode.
3937
* @param params.messenger - Messenger used to call the permissions controller.
4038
* @param params.origin - The origin of the request.
39+
* @param params.data - The typed data to decode.
40+
*
4141
* @returns A decoded permission, or `undefined` if no permission can be derived.
4242
* @throws {Error} If required metadata (origin or justification) is missing or invalid.
4343
*/
@@ -70,7 +70,7 @@ export function decodePermissionFromRequest({
7070
)
7171
)
7272
) {
73-
return;
73+
return undefined;
7474
}
7575

7676
const decodedPermission = messenger.call(

packages/signature-controller/src/utils/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Json } from '@metamask/utils';
1010
import { type Hex } from '@metamask/utils';
1111
import { validate } from 'jsonschema';
1212

13-
import { isDelegationRequest } from './execution-permissions';
13+
import { isDelegationRequest } from './delegations';
1414
import type {
1515
MessageParamsPersonal,
1616
MessageParamsTyped,

0 commit comments

Comments
 (0)