Skip to content

Commit 736cb8b

Browse files
committed
Replace erc20-token-revocation permission with token-approval-revocation permission
- bump @metamask/7715-permission-types from ^0.6.0 to ^0.7.1 - bump @metamask/gator-permissions-controller from ^4.10 to ^4.2.0 - bump @metamask/gator-permissions-snap from ^2.1.0 to ^2.2.0
1 parent 8d6c095 commit 736cb8b

23 files changed

Lines changed: 417 additions & 168 deletions

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
607607
- Fixed focus behavior in network list menu - menu button now properly toggles menu open/closed without focusing menu items (#39279)
608608
- Implement new bridge asset picker and read token data from new popular and search api endpoints (#37685)
609609
- Add polygon to the networks supporting smart transactions (#39614)
610-
- Adds support for ERC-7715 `wallet_requestExecutionPermissions` RPC method, with `erc20-token-revocation` permission type (#39417)
610+
- Adds support for ERC-7715 `wallet_requestExecutionPermissions` RPC method, with `token-approval-revocation` permission type (#39417)
611611

612612
### Changed
613613

@@ -774,8 +774,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
774774

775775
### Added
776776

777-
- Adds 'erc20-token-revocation' Advanced Permission type in Flask build only (#39008)
778-
- Added support for `erc20-token-revocation` permission (#38888)
777+
- Adds 'token-approval-revocation' Advanced Permission type in Flask build only (#39008)
778+
- Added support for `token-approval-revocation` permission (#38888)
779779
- Added recipient when signing a 7715 permission (#38934)
780780
- Adds a migration to cleanup user historical prices and removes cache for historical price fetching (#38892)
781781
- Added the discover button for Tron network (#38636)

app/_locales/en/messages.json

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/scripts/metamask-controller.test.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ describe('MetaMaskController', () => {
18051805
beforeEach(() => {
18061806
jest
18071807
.mocked(gatorPermissionFeatureFlags.getEnabledAdvancedPermissions)
1808-
.mockReturnValue(['erc20-token-revocation']);
1808+
.mockReturnValue(['token-approval-revocation']);
18091809
jest.mocked(forwardRequestToSnap).mockResolvedValue({});
18101810
});
18111811

@@ -1834,9 +1834,14 @@ describe('MetaMaskController', () => {
18341834
chainId,
18351835
to: '0x0000000000000000000000000000000000000000',
18361836
permission: {
1837-
type: 'erc20-token-revocation',
1837+
type: 'token-approval-revocation',
18381838
data: {
1839-
justification: 'A test permission request',
1839+
erc20Approve: true,
1840+
erc721Approve: true,
1841+
erc721SetApprovalForAll: true,
1842+
permit2Approve: true,
1843+
permit2Lockdown: true,
1844+
permit2InvalidateNonces: true,
18401845
},
18411846
isAdjustmentAllowed: true,
18421847
},
@@ -1952,7 +1957,7 @@ describe('MetaMaskController', () => {
19521957
});
19531958
jest
19541959
.mocked(gatorPermissionFeatureFlags.getEnabledAdvancedPermissions)
1955-
.mockReturnValue(['erc20-token-revocation']);
1960+
.mockReturnValue(['token-approval-revocation']);
19561961
});
19571962

19581963
/**
@@ -1992,8 +1997,8 @@ describe('MetaMaskController', () => {
19921997

19931998
it('omits permission types that are not enabled in the environment', async () => {
19941999
jest.mocked(forwardRequestToSnap).mockResolvedValue({
1995-
'erc20-token-revocation': {
1996-
ruleTypes: ['a'],
2000+
'token-approval-revocation': {
2001+
ruleTypes: ['expiry'],
19972002
},
19982003
'some-other-permission': {
19992004
ruleTypes: ['b'],
@@ -2003,79 +2008,79 @@ describe('MetaMaskController', () => {
20032008
const response = await getSupportedExecutionPermissions();
20042009

20052010
expect(response.result).toStrictEqual({
2006-
'erc20-token-revocation': {
2007-
ruleTypes: ['a'],
2011+
'token-approval-revocation': {
2012+
ruleTypes: ['expiry'],
20082013
chainIds: ['0x1', '0x5'],
20092014
},
20102015
});
20112016
});
20122017

20132018
it('fills chainIds from EIP-7702 supported chains when the kernel omits chainIds', async () => {
20142019
jest.mocked(forwardRequestToSnap).mockResolvedValue({
2015-
'erc20-token-revocation': {
2016-
ruleTypes: ['revoke'],
2020+
'token-approval-revocation': {
2021+
ruleTypes: ['expiry'],
20172022
},
20182023
});
20192024

20202025
const response = await getSupportedExecutionPermissions();
20212026

20222027
expect(response.result).toStrictEqual({
2023-
'erc20-token-revocation': {
2024-
ruleTypes: ['revoke'],
2028+
'token-approval-revocation': {
2029+
ruleTypes: ['expiry'],
20252030
chainIds: ['0x1', '0x5'],
20262031
},
20272032
});
20282033
});
20292034

20302035
it('lowercases and filters kernel chainIds to EIP-7702 supported chains', async () => {
20312036
jest.mocked(forwardRequestToSnap).mockResolvedValue({
2032-
'erc20-token-revocation': {
2033-
ruleTypes: ['revoke'],
2037+
'token-approval-revocation': {
2038+
ruleTypes: ['expiry'],
20342039
chainIds: ['0x1', '0X5', '0x99', '0xAA'],
20352040
},
20362041
});
20372042

20382043
const response = await getSupportedExecutionPermissions();
20392044

20402045
expect(response.result).toStrictEqual({
2041-
'erc20-token-revocation': {
2042-
ruleTypes: ['revoke'],
2046+
'token-approval-revocation': {
2047+
ruleTypes: ['expiry'],
20432048
chainIds: ['0x1', '0x5'],
20442049
},
20452050
});
20462051
});
20472052

20482053
it('keeps chainIds empty when the kernel sends an empty chainIds array', async () => {
20492054
jest.mocked(forwardRequestToSnap).mockResolvedValue({
2050-
'erc20-token-revocation': {
2051-
ruleTypes: ['revoke'],
2055+
'token-approval-revocation': {
2056+
ruleTypes: ['expiry'],
20522057
chainIds: [],
20532058
},
20542059
});
20552060

20562061
const response = await getSupportedExecutionPermissions();
20572062

20582063
expect(response.result).toStrictEqual({
2059-
'erc20-token-revocation': {
2060-
ruleTypes: ['revoke'],
2064+
'token-approval-revocation': {
2065+
ruleTypes: ['expiry'],
20612066
chainIds: [],
20622067
},
20632068
});
20642069
});
20652070

20662071
it('uses EIP-7702 supported chains when kernel chainIds is null', async () => {
20672072
jest.mocked(forwardRequestToSnap).mockResolvedValue({
2068-
'erc20-token-revocation': {
2069-
ruleTypes: ['revoke'],
2073+
'token-approval-revocation': {
2074+
ruleTypes: ['expiry'],
20702075
chainIds: null,
20712076
},
20722077
});
20732078

20742079
const response = await getSupportedExecutionPermissions();
20752080

20762081
expect(response.result).toStrictEqual({
2077-
'erc20-token-revocation': {
2078-
ruleTypes: ['revoke'],
2082+
'token-approval-revocation': {
2083+
ruleTypes: ['expiry'],
20792084
chainIds: ['0x1', '0x5'],
20802085
},
20812086
});

builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ buildTypes:
130130
- APPLE_FLASK_CLIENT_ID
131131
- GOOGLE_CLIENT_ID_REF: GOOGLE_FLASK_CLIENT_ID
132132
- APPLE_CLIENT_ID_REF: APPLE_FLASK_CLIENT_ID
133-
- GATOR_ENABLED_PERMISSION_TYPES: 'native-token-allowance,native-token-stream,native-token-periodic,erc20-token-allowance,erc20-token-stream,erc20-token-periodic,erc20-token-revocation'
133+
- GATOR_ENABLED_PERMISSION_TYPES: 'native-token-allowance,native-token-stream,native-token-periodic,erc20-token-allowance,erc20-token-stream,erc20-token-periodic,token-approval-revocation'
134134
- GATOR_PERMISSIONS_REVOCATION_ENABLED: true
135135

136136
isPrerelease: true

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
"@ledgerhq/hw-transport-webhid": "^6.31.0",
329329
"@material-ui/core": "^4.12.4",
330330
"@material-ui/pickers": "^3.3.11",
331-
"@metamask/7715-permission-types": "^0.6.0",
331+
"@metamask/7715-permission-types": "^0.7.1",
332332
"@metamask/abi-utils": "^3.0.0",
333333
"@metamask/account-api": "^1.0.4",
334334
"@metamask/account-tree-controller": "^7.2.0",
@@ -372,8 +372,8 @@
372372
"@metamask/eth-trezor-keyring": "^10.0.2",
373373
"@metamask/etherscan-link": "^3.0.0",
374374
"@metamask/gas-fee-controller": "^26.1.0",
375-
"@metamask/gator-permissions-controller": "^4.1.0",
376-
"@metamask/gator-permissions-snap": "^2.1.0",
375+
"@metamask/gator-permissions-controller": "^4.2.0",
376+
"@metamask/gator-permissions-snap": "^2.2.0",
377377
"@metamask/geolocation-controller": "^0.1.1",
378378
"@metamask/hw-wallet-sdk": "^0.8.0",
379379
"@metamask/institutional-wallet-snap": "1.5.0",

shared/lib/gator-permissions/feature-flags.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('getEnabledAdvancedPermissions', () => {
110110
'native-token-periodic',
111111
'erc20-token-periodic',
112112
'erc20-token-stream',
113-
'erc20-token-revocation',
113+
'token-approval-revocation',
114114
],
115115
},
116116
},

shared/lib/gator-permissions/gator-permissions-utils.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,17 @@ describe('gator-permissions-utils', () => {
420420
});
421421
});
422422

423-
it('should return correct metadata for erc20-token-revocation', () => {
423+
it('should return correct metadata for token-approval-revocation', () => {
424424
const result = getGatorPermissionDisplayMetadata(
425-
'erc20-token-revocation',
426-
{},
425+
'token-approval-revocation',
426+
{
427+
erc20Approve: true,
428+
erc721Approve: true,
429+
erc721SetApprovalForAll: true,
430+
permit2Approve: true,
431+
permit2Lockdown: true,
432+
permit2InvalidateNonces: true,
433+
},
427434
);
428435

429436
expect(result).toStrictEqual({

shared/lib/gator-permissions/gator-permissions-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ export function getGatorPermissionDisplayMetadata(
468468
};
469469
}
470470

471-
if (permissionType === 'erc20-token-revocation') {
471+
if (permissionType === 'token-approval-revocation') {
472472
return {
473473
displayNameKey: 'revokeTokenApprovals',
474474
amount: '',

shared/lib/gator-permissions/permission-detail-schema.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export type AmountField = BaseField<'amount', BigNumber> &
9494
/** A plain text row. */
9595
export type TextField = BaseField<'text', I18nValue> & TooltipFieldConfig;
9696

97+
/** A plain list row with verbatim (non-i18n) values. */
98+
export type RawListField = BaseField<'raw-list', string[]> & TooltipFieldConfig;
99+
97100
/** A date/time row. */
98101
export type DateField = BaseField<'date', number> & TooltipFieldConfig;
99102

@@ -136,6 +139,7 @@ export type NetworkField = {
136139
export type SchemaElement =
137140
| AmountField
138141
| TextField
142+
| RawListField
139143
| DateField
140144
| ExpiryField
141145
| DividerElement

0 commit comments

Comments
 (0)