Skip to content

Commit 54b8c0d

Browse files
committed
Revert "Add token-approval-revocation permission type and related RPC conversion"
This reverts commit 086175b.
1 parent 086175b commit 54b8c0d

9 files changed

Lines changed: 3 additions & 156 deletions

File tree

lib/delegatable-framework

packages/7715-permission-types/CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Added
11-
12-
- New permission type `token-approval-revocation`
13-
1410
## [0.6.0]
1511

1612
### Added

packages/7715-permission-types/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export type {
1010
Erc20TokenPeriodicPermission,
1111
Erc20TokenAllowancePermission,
1212
Erc20TokenRevocationPermission,
13-
TokenApprovalRevocationPermission,
1413
Rule,
1514
PermissionRequest,
1615
PermissionResponse,

packages/7715-permission-types/src/types.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,6 @@ export type Erc20TokenRevocationPermission = BasePermission & {
177177
data: MetaMaskBasePermissionData;
178178
};
179179

180-
/**
181-
* A permission to revoke token approvals.
182-
*/
183-
export type TokenApprovalRevocationPermission = BasePermission & {
184-
type: 'token-approval-revocation';
185-
data: MetaMaskBasePermissionData & {
186-
erc20Approve: boolean;
187-
erc721Approve: boolean;
188-
erc721SetApprovalForAll: boolean;
189-
permit2ApproveZero: boolean;
190-
permit2Lockdown: boolean;
191-
permit2InvalidateNonces: boolean;
192-
};
193-
};
194-
195180
/**
196181
* A custom permission.
197182
*
@@ -213,8 +198,7 @@ export type PermissionTypes =
213198
| Erc20TokenStreamPermission
214199
| Erc20TokenPeriodicPermission
215200
| Erc20TokenAllowancePermission
216-
| Erc20TokenRevocationPermission
217-
| TokenApprovalRevocationPermission;
201+
| Erc20TokenRevocationPermission;
218202

219203
// //////////////////////////////////////////////////
220204
// Permission Requests

packages/smart-accounts-kit/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- `CaveatBuilder` for `ApprovalRevocationEnforcer`, deployment address added to `SmartAccountsEnvironment` ([#226](https://github.com/metamask/smart-accounts-kit/pull/226))
13-
- ERC-7715 `token-approval-revocation` permission type
1413

1514
## [1.5.0]
1615

packages/smart-accounts-kit/src/actions/erc7715Mapping.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
PermissionRequest,
1010
PermissionTypes as RpcPermissionTypes,
1111
Rule,
12-
TokenApprovalRevocationPermission as RpcTokenApprovalRevocationPermission,
1312
} from '@metamask/7715-permission-types';
1413
import { getAddress, hexToNumber, isAddress, toHex, type Hex } from 'viem';
1514

@@ -28,7 +27,6 @@ import type {
2827
PermissionTypes as DeveloperPermissionTypes,
2928
RpcGetGrantedExecutionPermissionsResult,
3029
RpcGetSupportedExecutionPermissionsResult,
31-
TokenApprovalRevocationPermission,
3230
} from './erc7715Types';
3331

3432
// =============================================================================
@@ -158,11 +156,6 @@ function getPermissionRequestToRpcConverter(
158156
erc20TokenRevocationPermissionToRpc(
159157
permission as Erc20TokenRevocationPermission,
160158
);
161-
case 'token-approval-revocation':
162-
return (permission) =>
163-
tokenApprovalRevocationPermissionToRpc(
164-
permission as TokenApprovalRevocationPermission,
165-
);
166159
default:
167160
throw new Error(`Unsupported permission type: ${permissionType}`);
168161
}
@@ -414,44 +407,6 @@ function erc20TokenRevocationPermissionToRpc(
414407
};
415408
}
416409

417-
/**
418-
* Convert token approval revocation permission to RPC format.
419-
*
420-
* @param permission the token approval revocation permission
421-
* @returns the token approval revocation permission in RPC format
422-
*/
423-
function tokenApprovalRevocationPermissionToRpc(
424-
permission: TokenApprovalRevocationPermission,
425-
): RpcTokenApprovalRevocationPermission {
426-
const {
427-
data: {
428-
erc20Approve,
429-
erc721Approve,
430-
erc721SetApprovalForAll,
431-
permit2ApproveZero,
432-
permit2Lockdown,
433-
permit2InvalidateNonces,
434-
justification,
435-
},
436-
isAdjustmentAllowed,
437-
} = permission;
438-
439-
const data = {
440-
erc20Approve,
441-
erc721Approve,
442-
erc721SetApprovalForAll,
443-
permit2ApproveZero,
444-
permit2Lockdown,
445-
permit2InvalidateNonces,
446-
...(justification ? { justification } : {}),
447-
};
448-
return {
449-
type: 'token-approval-revocation',
450-
data,
451-
isAdjustmentAllowed,
452-
};
453-
}
454-
455410
// =============================================================================
456411
// RPC → Developer friendly types (response conversion)
457412
// =============================================================================

packages/smart-accounts-kit/src/actions/erc7715Types.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
PermissionResponse as RpcPermissionResponse,
55
Rule,
66
} from '@metamask/7715-permission-types';
7-
import type { ApprovalRevocationTerms } from '@metamask/delegation-core';
87
import type {
98
Client,
109
Account,
@@ -121,16 +120,6 @@ export type Erc20TokenRevocationPermission = BasePermission & {
121120
};
122121
};
123122

124-
/**
125-
* Token approval revocation permission.
126-
*/
127-
export type TokenApprovalRevocationPermission = BasePermission & {
128-
type: 'token-approval-revocation';
129-
data: ApprovalRevocationTerms & {
130-
justification?: string;
131-
};
132-
};
133-
134123
/**
135124
* Permission types.
136125
*/
@@ -141,8 +130,7 @@ export type PermissionTypes =
141130
| Erc20TokenStreamPermission
142131
| Erc20TokenPeriodicPermission
143132
| Erc20TokenAllowancePermission
144-
| Erc20TokenRevocationPermission
145-
| TokenApprovalRevocationPermission;
133+
| Erc20TokenRevocationPermission;
146134

147135
/**
148136
* Parameters for a single permission request (input to requestExecutionPermissions).

packages/smart-accounts-kit/src/actions/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ export {
9292
type Erc20TokenPeriodicPermission,
9393
type Erc20TokenAllowancePermission,
9494
type Erc20TokenRevocationPermission,
95-
type TokenApprovalRevocationPermission,
9695
type RpcGetSupportedExecutionPermissionsResult,
9796
type RpcGetGrantedExecutionPermissionsResult,
9897
type RpcSupportedPermissionInfo,

packages/smart-accounts-kit/test/actions/erc7715Mapping.test.ts

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -190,38 +190,6 @@ describe('erc7715Mapping', () => {
190190
},
191191
});
192192
});
193-
194-
it('preserves token-approval-revocation data, including false flags', () => {
195-
const rpcPermission = {
196-
type: 'token-approval-revocation',
197-
isAdjustmentAllowed: true,
198-
data: {
199-
erc20Approve: true,
200-
erc721Approve: false,
201-
erc721SetApprovalForAll: true,
202-
permit2ApproveZero: false,
203-
permit2Lockdown: true,
204-
permit2InvalidateNonces: false,
205-
justification: 'Revoke token approvals',
206-
},
207-
} as const;
208-
209-
const result = permissionTypeFromRpc(rpcPermission);
210-
211-
expect(result).toStrictEqual({
212-
type: 'token-approval-revocation',
213-
isAdjustmentAllowed: true,
214-
data: {
215-
erc20Approve: true,
216-
erc721Approve: false,
217-
erc721SetApprovalForAll: true,
218-
permit2ApproveZero: false,
219-
permit2Lockdown: true,
220-
permit2InvalidateNonces: false,
221-
justification: 'Revoke token approvals',
222-
},
223-
});
224-
});
225193
});
226194

227195
describe('permissionResponsesFromRpc', () => {
@@ -804,47 +772,6 @@ describe('erc7715Mapping', () => {
804772
});
805773
});
806774

807-
it('converts token-approval-revocation: preserves all flags', () => {
808-
const permissionRequest = {
809-
chainId: 1,
810-
permission: {
811-
type: 'token-approval-revocation',
812-
data: {
813-
erc20Approve: true,
814-
erc721Approve: false,
815-
erc721SetApprovalForAll: true,
816-
permit2ApproveZero: false,
817-
permit2Lockdown: true,
818-
permit2InvalidateNonces: false,
819-
justification: 'Revoke token approvals',
820-
},
821-
isAdjustmentAllowed: true,
822-
},
823-
to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
824-
} as const;
825-
826-
const result = permissionRequestToRpc(permissionRequest);
827-
828-
expect(result).toStrictEqual({
829-
chainId: '0x1',
830-
permission: {
831-
type: 'token-approval-revocation',
832-
data: {
833-
erc20Approve: true,
834-
erc721Approve: false,
835-
erc721SetApprovalForAll: true,
836-
permit2ApproveZero: false,
837-
permit2Lockdown: true,
838-
permit2InvalidateNonces: false,
839-
justification: 'Revoke token approvals',
840-
},
841-
isAdjustmentAllowed: true,
842-
},
843-
to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
844-
rules: [],
845-
});
846-
});
847-
848775
it('throws for unsupported permission type', () => {
849776
const permissionRequest = {
850777
chainId: 1,

0 commit comments

Comments
 (0)