From 086175bacefc248fd4d632f89bf402fc6a28ed76 Mon Sep 17 00:00:00 2001 From: MJ Kiwi Date: Mon, 18 May 2026 16:50:25 +1200 Subject: [PATCH 1/5] Add token-approval-revocation permission type and related RPC conversion --- lib/delegatable-framework | 2 +- packages/7715-permission-types/CHANGELOG.md | 4 + packages/7715-permission-types/src/index.ts | 1 + packages/7715-permission-types/src/types.ts | 18 ++++- packages/smart-accounts-kit/CHANGELOG.md | 1 + .../src/actions/erc7715Mapping.ts | 45 ++++++++++++ .../src/actions/erc7715Types.ts | 14 +++- .../smart-accounts-kit/src/actions/index.ts | 1 + .../test/actions/erc7715Mapping.test.ts | 73 +++++++++++++++++++ 9 files changed, 156 insertions(+), 3 deletions(-) diff --git a/lib/delegatable-framework b/lib/delegatable-framework index d0ebab53..2f21b6ba 160000 --- a/lib/delegatable-framework +++ b/lib/delegatable-framework @@ -1 +1 @@ -Subproject commit d0ebab5386503824730fdc0e48924f362d8290d0 +Subproject commit 2f21b6babc4bfb44cab84a730ac1b16a757eeaef diff --git a/packages/7715-permission-types/CHANGELOG.md b/packages/7715-permission-types/CHANGELOG.md index dbd27396..820869f9 100644 --- a/packages/7715-permission-types/CHANGELOG.md +++ b/packages/7715-permission-types/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- New permission type `token-approval-revocation` + ## [0.6.0] ### Added diff --git a/packages/7715-permission-types/src/index.ts b/packages/7715-permission-types/src/index.ts index 72608ed7..cb4553a4 100644 --- a/packages/7715-permission-types/src/index.ts +++ b/packages/7715-permission-types/src/index.ts @@ -10,6 +10,7 @@ export type { Erc20TokenPeriodicPermission, Erc20TokenAllowancePermission, Erc20TokenRevocationPermission, + TokenApprovalRevocationPermission, Rule, PermissionRequest, PermissionResponse, diff --git a/packages/7715-permission-types/src/types.ts b/packages/7715-permission-types/src/types.ts index e9ba4680..ca790312 100644 --- a/packages/7715-permission-types/src/types.ts +++ b/packages/7715-permission-types/src/types.ts @@ -177,6 +177,21 @@ export type Erc20TokenRevocationPermission = BasePermission & { data: MetaMaskBasePermissionData; }; +/** + * A permission to revoke token approvals. + */ +export type TokenApprovalRevocationPermission = BasePermission & { + type: 'token-approval-revocation'; + data: MetaMaskBasePermissionData & { + erc20Approve: boolean; + erc721Approve: boolean; + erc721SetApprovalForAll: boolean; + permit2ApproveZero: boolean; + permit2Lockdown: boolean; + permit2InvalidateNonces: boolean; + }; +}; + /** * A custom permission. * @@ -198,7 +213,8 @@ export type PermissionTypes = | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission - | Erc20TokenRevocationPermission; + | Erc20TokenRevocationPermission + | TokenApprovalRevocationPermission; // ////////////////////////////////////////////////// // Permission Requests diff --git a/packages/smart-accounts-kit/CHANGELOG.md b/packages/smart-accounts-kit/CHANGELOG.md index a8ee6786..2d2f2bea 100644 --- a/packages/smart-accounts-kit/CHANGELOG.md +++ b/packages/smart-accounts-kit/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `CaveatBuilder` for `ApprovalRevocationEnforcer`, deployment address added to `SmartAccountsEnvironment` ([#226](https://github.com/metamask/smart-accounts-kit/pull/226)) +- ERC-7715 `token-approval-revocation` permission type ## [1.5.0] diff --git a/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts b/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts index eb2676bd..d401cec5 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts @@ -9,6 +9,7 @@ import type { PermissionRequest, PermissionTypes as RpcPermissionTypes, Rule, + TokenApprovalRevocationPermission as RpcTokenApprovalRevocationPermission, } from '@metamask/7715-permission-types'; import { getAddress, hexToNumber, isAddress, toHex, type Hex } from 'viem'; @@ -27,6 +28,7 @@ import type { PermissionTypes as DeveloperPermissionTypes, RpcGetGrantedExecutionPermissionsResult, RpcGetSupportedExecutionPermissionsResult, + TokenApprovalRevocationPermission, } from './erc7715Types'; // ============================================================================= @@ -156,6 +158,11 @@ function getPermissionRequestToRpcConverter( erc20TokenRevocationPermissionToRpc( permission as Erc20TokenRevocationPermission, ); + case 'token-approval-revocation': + return (permission) => + tokenApprovalRevocationPermissionToRpc( + permission as TokenApprovalRevocationPermission, + ); default: throw new Error(`Unsupported permission type: ${permissionType}`); } @@ -407,6 +414,44 @@ function erc20TokenRevocationPermissionToRpc( }; } +/** + * Convert token approval revocation permission to RPC format. + * + * @param permission the token approval revocation permission + * @returns the token approval revocation permission in RPC format + */ +function tokenApprovalRevocationPermissionToRpc( + permission: TokenApprovalRevocationPermission, +): RpcTokenApprovalRevocationPermission { + const { + data: { + erc20Approve, + erc721Approve, + erc721SetApprovalForAll, + permit2ApproveZero, + permit2Lockdown, + permit2InvalidateNonces, + justification, + }, + isAdjustmentAllowed, + } = permission; + + const data = { + erc20Approve, + erc721Approve, + erc721SetApprovalForAll, + permit2ApproveZero, + permit2Lockdown, + permit2InvalidateNonces, + ...(justification ? { justification } : {}), + }; + return { + type: 'token-approval-revocation', + data, + isAdjustmentAllowed, + }; +} + // ============================================================================= // RPC → Developer friendly types (response conversion) // ============================================================================= diff --git a/packages/smart-accounts-kit/src/actions/erc7715Types.ts b/packages/smart-accounts-kit/src/actions/erc7715Types.ts index e7780a36..abae84bb 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Types.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Types.ts @@ -4,6 +4,7 @@ import type { PermissionResponse as RpcPermissionResponse, Rule, } from '@metamask/7715-permission-types'; +import type { ApprovalRevocationTerms } from '@metamask/delegation-core'; import type { Client, Account, @@ -120,6 +121,16 @@ export type Erc20TokenRevocationPermission = BasePermission & { }; }; +/** + * Token approval revocation permission. + */ +export type TokenApprovalRevocationPermission = BasePermission & { + type: 'token-approval-revocation'; + data: ApprovalRevocationTerms & { + justification?: string; + }; +}; + /** * Permission types. */ @@ -130,7 +141,8 @@ export type PermissionTypes = | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission - | Erc20TokenRevocationPermission; + | Erc20TokenRevocationPermission + | TokenApprovalRevocationPermission; /** * Parameters for a single permission request (input to requestExecutionPermissions). diff --git a/packages/smart-accounts-kit/src/actions/index.ts b/packages/smart-accounts-kit/src/actions/index.ts index a3892ca1..bd1adecf 100644 --- a/packages/smart-accounts-kit/src/actions/index.ts +++ b/packages/smart-accounts-kit/src/actions/index.ts @@ -92,6 +92,7 @@ export { type Erc20TokenPeriodicPermission, type Erc20TokenAllowancePermission, type Erc20TokenRevocationPermission, + type TokenApprovalRevocationPermission, type RpcGetSupportedExecutionPermissionsResult, type RpcGetGrantedExecutionPermissionsResult, type RpcSupportedPermissionInfo, diff --git a/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts b/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts index 5ccf6bcb..982c1a37 100644 --- a/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts +++ b/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts @@ -190,6 +190,38 @@ describe('erc7715Mapping', () => { }, }); }); + + it('preserves token-approval-revocation data, including false flags', () => { + const rpcPermission = { + type: 'token-approval-revocation', + isAdjustmentAllowed: true, + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + } as const; + + const result = permissionTypeFromRpc(rpcPermission); + + expect(result).toStrictEqual({ + type: 'token-approval-revocation', + isAdjustmentAllowed: true, + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + }); + }); }); describe('permissionResponsesFromRpc', () => { @@ -772,6 +804,47 @@ describe('erc7715Mapping', () => { }); }); + it('converts token-approval-revocation: preserves all flags', () => { + const permissionRequest = { + chainId: 1, + permission: { + type: 'token-approval-revocation', + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + isAdjustmentAllowed: true, + }, + to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', + } as const; + + const result = permissionRequestToRpc(permissionRequest); + + expect(result).toStrictEqual({ + chainId: '0x1', + permission: { + type: 'token-approval-revocation', + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + isAdjustmentAllowed: true, + }, + to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', + rules: [], + }); + }); + it('throws for unsupported permission type', () => { const permissionRequest = { chainId: 1, From 2a1f1030703d2a0332871f38599392cb08ec866f Mon Sep 17 00:00:00 2001 From: MJ Kiwi Date: Mon, 18 May 2026 16:56:15 +1200 Subject: [PATCH 2/5] feat: add token approval revocation permission type --- packages/7715-permission-types/CHANGELOG.md | 4 + packages/7715-permission-types/src/index.ts | 1 + packages/7715-permission-types/src/types.ts | 18 ++++- packages/smart-accounts-kit/CHANGELOG.md | 4 + .../src/actions/erc7715Mapping.ts | 45 ++++++++++++ .../src/actions/erc7715Types.ts | 14 +++- .../smart-accounts-kit/src/actions/index.ts | 1 + .../test/actions/erc7715Mapping.test.ts | 73 +++++++++++++++++++ 8 files changed, 158 insertions(+), 2 deletions(-) diff --git a/packages/7715-permission-types/CHANGELOG.md b/packages/7715-permission-types/CHANGELOG.md index dbd27396..820869f9 100644 --- a/packages/7715-permission-types/CHANGELOG.md +++ b/packages/7715-permission-types/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- New permission type `token-approval-revocation` + ## [0.6.0] ### Added diff --git a/packages/7715-permission-types/src/index.ts b/packages/7715-permission-types/src/index.ts index 72608ed7..cb4553a4 100644 --- a/packages/7715-permission-types/src/index.ts +++ b/packages/7715-permission-types/src/index.ts @@ -10,6 +10,7 @@ export type { Erc20TokenPeriodicPermission, Erc20TokenAllowancePermission, Erc20TokenRevocationPermission, + TokenApprovalRevocationPermission, Rule, PermissionRequest, PermissionResponse, diff --git a/packages/7715-permission-types/src/types.ts b/packages/7715-permission-types/src/types.ts index e9ba4680..ca790312 100644 --- a/packages/7715-permission-types/src/types.ts +++ b/packages/7715-permission-types/src/types.ts @@ -177,6 +177,21 @@ export type Erc20TokenRevocationPermission = BasePermission & { data: MetaMaskBasePermissionData; }; +/** + * A permission to revoke token approvals. + */ +export type TokenApprovalRevocationPermission = BasePermission & { + type: 'token-approval-revocation'; + data: MetaMaskBasePermissionData & { + erc20Approve: boolean; + erc721Approve: boolean; + erc721SetApprovalForAll: boolean; + permit2ApproveZero: boolean; + permit2Lockdown: boolean; + permit2InvalidateNonces: boolean; + }; +}; + /** * A custom permission. * @@ -198,7 +213,8 @@ export type PermissionTypes = | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission - | Erc20TokenRevocationPermission; + | Erc20TokenRevocationPermission + | TokenApprovalRevocationPermission; // ////////////////////////////////////////////////// // Permission Requests diff --git a/packages/smart-accounts-kit/CHANGELOG.md b/packages/smart-accounts-kit/CHANGELOG.md index 926837ed..79025f8c 100644 --- a/packages/smart-accounts-kit/CHANGELOG.md +++ b/packages/smart-accounts-kit/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- ERC-7715 `token-approval-revocation` permission type + ## [1.5.0] ### Added diff --git a/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts b/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts index eb2676bd..d401cec5 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts @@ -9,6 +9,7 @@ import type { PermissionRequest, PermissionTypes as RpcPermissionTypes, Rule, + TokenApprovalRevocationPermission as RpcTokenApprovalRevocationPermission, } from '@metamask/7715-permission-types'; import { getAddress, hexToNumber, isAddress, toHex, type Hex } from 'viem'; @@ -27,6 +28,7 @@ import type { PermissionTypes as DeveloperPermissionTypes, RpcGetGrantedExecutionPermissionsResult, RpcGetSupportedExecutionPermissionsResult, + TokenApprovalRevocationPermission, } from './erc7715Types'; // ============================================================================= @@ -156,6 +158,11 @@ function getPermissionRequestToRpcConverter( erc20TokenRevocationPermissionToRpc( permission as Erc20TokenRevocationPermission, ); + case 'token-approval-revocation': + return (permission) => + tokenApprovalRevocationPermissionToRpc( + permission as TokenApprovalRevocationPermission, + ); default: throw new Error(`Unsupported permission type: ${permissionType}`); } @@ -407,6 +414,44 @@ function erc20TokenRevocationPermissionToRpc( }; } +/** + * Convert token approval revocation permission to RPC format. + * + * @param permission the token approval revocation permission + * @returns the token approval revocation permission in RPC format + */ +function tokenApprovalRevocationPermissionToRpc( + permission: TokenApprovalRevocationPermission, +): RpcTokenApprovalRevocationPermission { + const { + data: { + erc20Approve, + erc721Approve, + erc721SetApprovalForAll, + permit2ApproveZero, + permit2Lockdown, + permit2InvalidateNonces, + justification, + }, + isAdjustmentAllowed, + } = permission; + + const data = { + erc20Approve, + erc721Approve, + erc721SetApprovalForAll, + permit2ApproveZero, + permit2Lockdown, + permit2InvalidateNonces, + ...(justification ? { justification } : {}), + }; + return { + type: 'token-approval-revocation', + data, + isAdjustmentAllowed, + }; +} + // ============================================================================= // RPC → Developer friendly types (response conversion) // ============================================================================= diff --git a/packages/smart-accounts-kit/src/actions/erc7715Types.ts b/packages/smart-accounts-kit/src/actions/erc7715Types.ts index e7780a36..abae84bb 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Types.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Types.ts @@ -4,6 +4,7 @@ import type { PermissionResponse as RpcPermissionResponse, Rule, } from '@metamask/7715-permission-types'; +import type { ApprovalRevocationTerms } from '@metamask/delegation-core'; import type { Client, Account, @@ -120,6 +121,16 @@ export type Erc20TokenRevocationPermission = BasePermission & { }; }; +/** + * Token approval revocation permission. + */ +export type TokenApprovalRevocationPermission = BasePermission & { + type: 'token-approval-revocation'; + data: ApprovalRevocationTerms & { + justification?: string; + }; +}; + /** * Permission types. */ @@ -130,7 +141,8 @@ export type PermissionTypes = | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission - | Erc20TokenRevocationPermission; + | Erc20TokenRevocationPermission + | TokenApprovalRevocationPermission; /** * Parameters for a single permission request (input to requestExecutionPermissions). diff --git a/packages/smart-accounts-kit/src/actions/index.ts b/packages/smart-accounts-kit/src/actions/index.ts index a3892ca1..bd1adecf 100644 --- a/packages/smart-accounts-kit/src/actions/index.ts +++ b/packages/smart-accounts-kit/src/actions/index.ts @@ -92,6 +92,7 @@ export { type Erc20TokenPeriodicPermission, type Erc20TokenAllowancePermission, type Erc20TokenRevocationPermission, + type TokenApprovalRevocationPermission, type RpcGetSupportedExecutionPermissionsResult, type RpcGetGrantedExecutionPermissionsResult, type RpcSupportedPermissionInfo, diff --git a/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts b/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts index 5ccf6bcb..982c1a37 100644 --- a/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts +++ b/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts @@ -190,6 +190,38 @@ describe('erc7715Mapping', () => { }, }); }); + + it('preserves token-approval-revocation data, including false flags', () => { + const rpcPermission = { + type: 'token-approval-revocation', + isAdjustmentAllowed: true, + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + } as const; + + const result = permissionTypeFromRpc(rpcPermission); + + expect(result).toStrictEqual({ + type: 'token-approval-revocation', + isAdjustmentAllowed: true, + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + }); + }); }); describe('permissionResponsesFromRpc', () => { @@ -772,6 +804,47 @@ describe('erc7715Mapping', () => { }); }); + it('converts token-approval-revocation: preserves all flags', () => { + const permissionRequest = { + chainId: 1, + permission: { + type: 'token-approval-revocation', + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + isAdjustmentAllowed: true, + }, + to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', + } as const; + + const result = permissionRequestToRpc(permissionRequest); + + expect(result).toStrictEqual({ + chainId: '0x1', + permission: { + type: 'token-approval-revocation', + data: { + erc20Approve: true, + erc721Approve: false, + erc721SetApprovalForAll: true, + permit2ApproveZero: false, + permit2Lockdown: true, + permit2InvalidateNonces: false, + justification: 'Revoke token approvals', + }, + isAdjustmentAllowed: true, + }, + to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', + rules: [], + }); + }); + it('throws for unsupported permission type', () => { const permissionRequest = { chainId: 1, From 54b8c0d38fb0ca71ae84f91b435a051537750d46 Mon Sep 17 00:00:00 2001 From: MJ Kiwi Date: Mon, 18 May 2026 16:56:54 +1200 Subject: [PATCH 3/5] Revert "Add token-approval-revocation permission type and related RPC conversion" This reverts commit 086175bacefc248fd4d632f89bf402fc6a28ed76. --- lib/delegatable-framework | 2 +- packages/7715-permission-types/CHANGELOG.md | 4 - packages/7715-permission-types/src/index.ts | 1 - packages/7715-permission-types/src/types.ts | 18 +---- packages/smart-accounts-kit/CHANGELOG.md | 1 - .../src/actions/erc7715Mapping.ts | 45 ------------ .../src/actions/erc7715Types.ts | 14 +--- .../smart-accounts-kit/src/actions/index.ts | 1 - .../test/actions/erc7715Mapping.test.ts | 73 ------------------- 9 files changed, 3 insertions(+), 156 deletions(-) diff --git a/lib/delegatable-framework b/lib/delegatable-framework index 2f21b6ba..d0ebab53 160000 --- a/lib/delegatable-framework +++ b/lib/delegatable-framework @@ -1 +1 @@ -Subproject commit 2f21b6babc4bfb44cab84a730ac1b16a757eeaef +Subproject commit d0ebab5386503824730fdc0e48924f362d8290d0 diff --git a/packages/7715-permission-types/CHANGELOG.md b/packages/7715-permission-types/CHANGELOG.md index 820869f9..dbd27396 100644 --- a/packages/7715-permission-types/CHANGELOG.md +++ b/packages/7715-permission-types/CHANGELOG.md @@ -7,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Added - -- New permission type `token-approval-revocation` - ## [0.6.0] ### Added diff --git a/packages/7715-permission-types/src/index.ts b/packages/7715-permission-types/src/index.ts index cb4553a4..72608ed7 100644 --- a/packages/7715-permission-types/src/index.ts +++ b/packages/7715-permission-types/src/index.ts @@ -10,7 +10,6 @@ export type { Erc20TokenPeriodicPermission, Erc20TokenAllowancePermission, Erc20TokenRevocationPermission, - TokenApprovalRevocationPermission, Rule, PermissionRequest, PermissionResponse, diff --git a/packages/7715-permission-types/src/types.ts b/packages/7715-permission-types/src/types.ts index ca790312..e9ba4680 100644 --- a/packages/7715-permission-types/src/types.ts +++ b/packages/7715-permission-types/src/types.ts @@ -177,21 +177,6 @@ export type Erc20TokenRevocationPermission = BasePermission & { data: MetaMaskBasePermissionData; }; -/** - * A permission to revoke token approvals. - */ -export type TokenApprovalRevocationPermission = BasePermission & { - type: 'token-approval-revocation'; - data: MetaMaskBasePermissionData & { - erc20Approve: boolean; - erc721Approve: boolean; - erc721SetApprovalForAll: boolean; - permit2ApproveZero: boolean; - permit2Lockdown: boolean; - permit2InvalidateNonces: boolean; - }; -}; - /** * A custom permission. * @@ -213,8 +198,7 @@ export type PermissionTypes = | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission - | Erc20TokenRevocationPermission - | TokenApprovalRevocationPermission; + | Erc20TokenRevocationPermission; // ////////////////////////////////////////////////// // Permission Requests diff --git a/packages/smart-accounts-kit/CHANGELOG.md b/packages/smart-accounts-kit/CHANGELOG.md index 2d2f2bea..a8ee6786 100644 --- a/packages/smart-accounts-kit/CHANGELOG.md +++ b/packages/smart-accounts-kit/CHANGELOG.md @@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `CaveatBuilder` for `ApprovalRevocationEnforcer`, deployment address added to `SmartAccountsEnvironment` ([#226](https://github.com/metamask/smart-accounts-kit/pull/226)) -- ERC-7715 `token-approval-revocation` permission type ## [1.5.0] diff --git a/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts b/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts index d401cec5..eb2676bd 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Mapping.ts @@ -9,7 +9,6 @@ import type { PermissionRequest, PermissionTypes as RpcPermissionTypes, Rule, - TokenApprovalRevocationPermission as RpcTokenApprovalRevocationPermission, } from '@metamask/7715-permission-types'; import { getAddress, hexToNumber, isAddress, toHex, type Hex } from 'viem'; @@ -28,7 +27,6 @@ import type { PermissionTypes as DeveloperPermissionTypes, RpcGetGrantedExecutionPermissionsResult, RpcGetSupportedExecutionPermissionsResult, - TokenApprovalRevocationPermission, } from './erc7715Types'; // ============================================================================= @@ -158,11 +156,6 @@ function getPermissionRequestToRpcConverter( erc20TokenRevocationPermissionToRpc( permission as Erc20TokenRevocationPermission, ); - case 'token-approval-revocation': - return (permission) => - tokenApprovalRevocationPermissionToRpc( - permission as TokenApprovalRevocationPermission, - ); default: throw new Error(`Unsupported permission type: ${permissionType}`); } @@ -414,44 +407,6 @@ function erc20TokenRevocationPermissionToRpc( }; } -/** - * Convert token approval revocation permission to RPC format. - * - * @param permission the token approval revocation permission - * @returns the token approval revocation permission in RPC format - */ -function tokenApprovalRevocationPermissionToRpc( - permission: TokenApprovalRevocationPermission, -): RpcTokenApprovalRevocationPermission { - const { - data: { - erc20Approve, - erc721Approve, - erc721SetApprovalForAll, - permit2ApproveZero, - permit2Lockdown, - permit2InvalidateNonces, - justification, - }, - isAdjustmentAllowed, - } = permission; - - const data = { - erc20Approve, - erc721Approve, - erc721SetApprovalForAll, - permit2ApproveZero, - permit2Lockdown, - permit2InvalidateNonces, - ...(justification ? { justification } : {}), - }; - return { - type: 'token-approval-revocation', - data, - isAdjustmentAllowed, - }; -} - // ============================================================================= // RPC → Developer friendly types (response conversion) // ============================================================================= diff --git a/packages/smart-accounts-kit/src/actions/erc7715Types.ts b/packages/smart-accounts-kit/src/actions/erc7715Types.ts index abae84bb..e7780a36 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Types.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Types.ts @@ -4,7 +4,6 @@ import type { PermissionResponse as RpcPermissionResponse, Rule, } from '@metamask/7715-permission-types'; -import type { ApprovalRevocationTerms } from '@metamask/delegation-core'; import type { Client, Account, @@ -121,16 +120,6 @@ export type Erc20TokenRevocationPermission = BasePermission & { }; }; -/** - * Token approval revocation permission. - */ -export type TokenApprovalRevocationPermission = BasePermission & { - type: 'token-approval-revocation'; - data: ApprovalRevocationTerms & { - justification?: string; - }; -}; - /** * Permission types. */ @@ -141,8 +130,7 @@ export type PermissionTypes = | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission - | Erc20TokenRevocationPermission - | TokenApprovalRevocationPermission; + | Erc20TokenRevocationPermission; /** * Parameters for a single permission request (input to requestExecutionPermissions). diff --git a/packages/smart-accounts-kit/src/actions/index.ts b/packages/smart-accounts-kit/src/actions/index.ts index bd1adecf..a3892ca1 100644 --- a/packages/smart-accounts-kit/src/actions/index.ts +++ b/packages/smart-accounts-kit/src/actions/index.ts @@ -92,7 +92,6 @@ export { type Erc20TokenPeriodicPermission, type Erc20TokenAllowancePermission, type Erc20TokenRevocationPermission, - type TokenApprovalRevocationPermission, type RpcGetSupportedExecutionPermissionsResult, type RpcGetGrantedExecutionPermissionsResult, type RpcSupportedPermissionInfo, diff --git a/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts b/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts index 982c1a37..5ccf6bcb 100644 --- a/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts +++ b/packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts @@ -190,38 +190,6 @@ describe('erc7715Mapping', () => { }, }); }); - - it('preserves token-approval-revocation data, including false flags', () => { - const rpcPermission = { - type: 'token-approval-revocation', - isAdjustmentAllowed: true, - data: { - erc20Approve: true, - erc721Approve: false, - erc721SetApprovalForAll: true, - permit2ApproveZero: false, - permit2Lockdown: true, - permit2InvalidateNonces: false, - justification: 'Revoke token approvals', - }, - } as const; - - const result = permissionTypeFromRpc(rpcPermission); - - expect(result).toStrictEqual({ - type: 'token-approval-revocation', - isAdjustmentAllowed: true, - data: { - erc20Approve: true, - erc721Approve: false, - erc721SetApprovalForAll: true, - permit2ApproveZero: false, - permit2Lockdown: true, - permit2InvalidateNonces: false, - justification: 'Revoke token approvals', - }, - }); - }); }); describe('permissionResponsesFromRpc', () => { @@ -804,47 +772,6 @@ describe('erc7715Mapping', () => { }); }); - it('converts token-approval-revocation: preserves all flags', () => { - const permissionRequest = { - chainId: 1, - permission: { - type: 'token-approval-revocation', - data: { - erc20Approve: true, - erc721Approve: false, - erc721SetApprovalForAll: true, - permit2ApproveZero: false, - permit2Lockdown: true, - permit2InvalidateNonces: false, - justification: 'Revoke token approvals', - }, - isAdjustmentAllowed: true, - }, - to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', - } as const; - - const result = permissionRequestToRpc(permissionRequest); - - expect(result).toStrictEqual({ - chainId: '0x1', - permission: { - type: 'token-approval-revocation', - data: { - erc20Approve: true, - erc721Approve: false, - erc721SetApprovalForAll: true, - permit2ApproveZero: false, - permit2Lockdown: true, - permit2InvalidateNonces: false, - justification: 'Revoke token approvals', - }, - isAdjustmentAllowed: true, - }, - to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', - rules: [], - }); - }); - it('throws for unsupported permission type', () => { const permissionRequest = { chainId: 1, From 330589e0a6d655966cf5b868c95f2a75cf3f191a Mon Sep 17 00:00:00 2001 From: MJ Kiwi Date: Mon, 18 May 2026 17:37:37 +1200 Subject: [PATCH 4/5] fix: link changelog entries to PR --- packages/7715-permission-types/CHANGELOG.md | 2 +- packages/smart-accounts-kit/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/7715-permission-types/CHANGELOG.md b/packages/7715-permission-types/CHANGELOG.md index 820869f9..e1e3ebde 100644 --- a/packages/7715-permission-types/CHANGELOG.md +++ b/packages/7715-permission-types/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- New permission type `token-approval-revocation` +- New permission type `token-approval-revocation` ([#232](https://github.com/MetaMask/smart-accounts-kit/pull/232)) ## [0.6.0] diff --git a/packages/smart-accounts-kit/CHANGELOG.md b/packages/smart-accounts-kit/CHANGELOG.md index fae5bac8..f3b03161 100644 --- a/packages/smart-accounts-kit/CHANGELOG.md +++ b/packages/smart-accounts-kit/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- ERC-7715 `token-approval-revocation` permission type +- ERC-7715 `token-approval-revocation` permission type ([#232](https://github.com/MetaMask/smart-accounts-kit/pull/232)) - `CaveatBuilder` for `ApprovalRevocationEnforcer`, deployment address added to `SmartAccountsEnvironment` ([#226](https://github.com/metamask/smart-accounts-kit/pull/226)) ## [1.5.0] From 56a4a807f4e2792de19cf1fa9e7bbd19597182b5 Mon Sep 17 00:00:00 2001 From: MJ Kiwi Date: Mon, 18 May 2026 18:40:35 +1200 Subject: [PATCH 5/5] feat: deprecate erc20-token-revocation in favor of token-approval-revocation --- lib/delegatable-framework | 2 +- packages/7715-permission-types/CHANGELOG.md | 4 ++++ packages/7715-permission-types/src/types.ts | 5 +++++ packages/smart-accounts-kit/CHANGELOG.md | 4 ++++ packages/smart-accounts-kit/src/actions/erc7715Types.ts | 5 +++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/delegatable-framework b/lib/delegatable-framework index d0ebab53..2f21b6ba 160000 --- a/lib/delegatable-framework +++ b/lib/delegatable-framework @@ -1 +1 @@ -Subproject commit d0ebab5386503824730fdc0e48924f362d8290d0 +Subproject commit 2f21b6babc4bfb44cab84a730ac1b16a757eeaef diff --git a/packages/7715-permission-types/CHANGELOG.md b/packages/7715-permission-types/CHANGELOG.md index e1e3ebde..f179ffbf 100644 --- a/packages/7715-permission-types/CHANGELOG.md +++ b/packages/7715-permission-types/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - New permission type `token-approval-revocation` ([#232](https://github.com/MetaMask/smart-accounts-kit/pull/232)) +### Deprecated + +- Deprecated `erc20-token-revocation` in favor of `token-approval-revocation`. + ## [0.6.0] ### Added diff --git a/packages/7715-permission-types/src/types.ts b/packages/7715-permission-types/src/types.ts index ca790312..0ddd4804 100644 --- a/packages/7715-permission-types/src/types.ts +++ b/packages/7715-permission-types/src/types.ts @@ -171,8 +171,13 @@ export type Erc20TokenAllowancePermission = BasePermission & { /** * A permission to revoke an ERC20 token allowance. + * + * @deprecated Use {@link TokenApprovalRevocationPermission} instead. */ export type Erc20TokenRevocationPermission = BasePermission & { + /** + * @deprecated Use `token-approval-revocation` instead. + */ type: 'erc20-token-revocation'; data: MetaMaskBasePermissionData; }; diff --git a/packages/smart-accounts-kit/CHANGELOG.md b/packages/smart-accounts-kit/CHANGELOG.md index f3b03161..b8e523e6 100644 --- a/packages/smart-accounts-kit/CHANGELOG.md +++ b/packages/smart-accounts-kit/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ERC-7715 `token-approval-revocation` permission type ([#232](https://github.com/MetaMask/smart-accounts-kit/pull/232)) - `CaveatBuilder` for `ApprovalRevocationEnforcer`, deployment address added to `SmartAccountsEnvironment` ([#226](https://github.com/metamask/smart-accounts-kit/pull/226)) +### Deprecated + +- Deprecated `erc20-token-revocation` in favor of `token-approval-revocation`. + ## [1.5.0] ### Added diff --git a/packages/smart-accounts-kit/src/actions/erc7715Types.ts b/packages/smart-accounts-kit/src/actions/erc7715Types.ts index abae84bb..c9bab66c 100644 --- a/packages/smart-accounts-kit/src/actions/erc7715Types.ts +++ b/packages/smart-accounts-kit/src/actions/erc7715Types.ts @@ -113,8 +113,13 @@ export type Erc20TokenAllowancePermission = BasePermission & { /** * ERC-20 token revocation permission. + * + * @deprecated Use {@link TokenApprovalRevocationPermission} instead. */ export type Erc20TokenRevocationPermission = BasePermission & { + /** + * @deprecated Use `token-approval-revocation` instead. + */ type: 'erc20-token-revocation'; data: { justification?: string;