Skip to content

Commit 521eca2

Browse files
authored
Add ERC-7715 execution permission methods (#311)
* Add ERC-7715 execution permission methods Add OpenRPC definitions for the ERC-7715 execution permission methods and their supporting schemas: - wallet_requestExecutionPermissions - wallet_getGrantedExecutionPermissions - wallet_getSupportedExecutionPermissions - wallet_revokeExecutionPermission These methods are already implemented in the wallet (via the permissions kernel Snap) and reachable over the EIP-1193 provider, but they are absent from the OpenRPC document. As a result they are not included in `KnownRpcMethods.eip155` (which `@metamask/chain-agnostic-permission` derives from this document), so they cannot be authorized in a CAIP-25 session and fail with an "unauthorized" error when invoked via the Multichain API (`wallet_invokeMethod`) — e.g. when used through MetaMask Connect. Adding them here makes them authorizable over the Multichain API, matching the existing EIP-1193 behaviour. * Remove duplicate `address` field from ExecutionPermissionRequest The schema defined both `address` and `from` with identical descriptions. ERC-7715 only specifies `from`, so drop `address` and clarify the `from` description to match the spec. * Address review: align ERC-7715 spec with wallet implementation - Remove wallet_revokeExecutionPermission (not wired in extension/mobile; handler throws methodNotSupported with no processRevokeExecutionPermission hook) - Drop unsupported top-level request fields (signer, expiry); expiry is an expiry rule on the wire, not a top-level field - Require isAdjustmentAllowed on ExecutionPermission and to on ExecutionPermissionRequest (both required by 7715-permission-types) - Require context/dependencies/delegationManager on the response and factory/factoryData on dependency entries (needed to redeem permissions) - Demonstrate the expiry rule in the request/response examples * Require rules and use future expiry in ERC-7715 examples Add `rules` to ExecutionPermissionRequest.required (the permissions-kernel Snap requires it; pass `[]` for no constraints) and bump the example expiry timestamps to a future date so copied examples don't request an already-expired permission. * Add startTime to periodic example; clarify amount types - Add `startTime` to the native-token-periodic example (request + result); it marks the start of the first period - Fix the ExecutionPermission `data` description: token amounts are hex, but timestamps/durations are numbers (seconds)
1 parent 30e6e10 commit 521eca2

2 files changed

Lines changed: 264 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Add ERC-7715 execution permission methods: `wallet_requestExecutionPermissions`, `wallet_getGrantedExecutionPermissions`, and `wallet_getSupportedExecutionPermissions`, along with the `ExecutionPermission`, `ExecutionPermissionRule`, `ExecutionPermissionRequest`, and `ExecutionPermissionResponse` schemas ([#311](https://github.com/MetaMask/api-specs/pull/311))
810

911
## [0.14.0]
1012
### Added

openrpc.yaml

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,146 @@ methods:
781781
'0xaa36a7':
782782
atomic:
783783
status: ready
784+
- name: wallet_requestExecutionPermissions
785+
tags:
786+
- $ref: '#/components/tags/MetaMask'
787+
- $ref: '#/components/tags/Experimental'
788+
- $ref: '#/components/tags/Multichain'
789+
summary: Requests ERC-7715 execution permissions.
790+
description: >-
791+
Requests that the user grant one or more ERC-7715 execution permissions,
792+
allowing a delegate account to perform a constrained set of actions on
793+
behalf of the user's account. Specified by
794+
[ERC-7715](https://eips.ethereum.org/EIPS/eip-7715).
795+
params:
796+
- name: Permission requests
797+
required: true
798+
description: An array of execution permission requests.
799+
schema:
800+
type: array
801+
items:
802+
$ref: '#/components/schemas/ExecutionPermissionRequest'
803+
result:
804+
name: Granted permissions
805+
description: An array of the granted execution permissions.
806+
schema:
807+
type: array
808+
items:
809+
$ref: '#/components/schemas/ExecutionPermissionResponse'
810+
errors:
811+
- $ref: '#/components/errors/InvalidParams'
812+
- $ref: '#/components/errors/UserRejected'
813+
- $ref: '#/components/errors/Unauthorized'
814+
examples:
815+
- name: wallet_requestExecutionPermissions example
816+
params:
817+
- name: Permission requests
818+
value:
819+
- chainId: '0xaa36a7'
820+
to: '0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7'
821+
permission:
822+
type: native-token-periodic
823+
isAdjustmentAllowed: true
824+
data:
825+
periodAmount: '0x38d7ea4c68000'
826+
periodDuration: 86400
827+
startTime: 1798761600
828+
justification: Permission to transfer 0.001 ETH every day
829+
rules:
830+
- type: expiry
831+
data:
832+
timestamp: 1893456000
833+
result:
834+
name: Granted permissions
835+
value:
836+
- chainId: '0xaa36a7'
837+
to: '0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7'
838+
permission:
839+
type: native-token-periodic
840+
isAdjustmentAllowed: true
841+
data:
842+
periodAmount: '0x38d7ea4c68000'
843+
periodDuration: 86400
844+
startTime: 1798761600
845+
justification: Permission to transfer 0.001 ETH every day
846+
rules:
847+
- type: expiry
848+
data:
849+
timestamp: 1893456000
850+
context: '0x00000000000000000000000000000000000000000000000000000000000000'
851+
delegationManager: '0x2D48e6f5Ae053e4E918d2be53570961D880905F2'
852+
dependencies: []
853+
- name: wallet_getGrantedExecutionPermissions
854+
tags:
855+
- $ref: '#/components/tags/MetaMask'
856+
- $ref: '#/components/tags/Experimental'
857+
- $ref: '#/components/tags/Multichain'
858+
summary: Gets granted ERC-7715 execution permissions.
859+
description: >-
860+
Returns the ERC-7715 execution permissions that the user has previously
861+
granted to the requesting dapp. Specified by
862+
[ERC-7715](https://eips.ethereum.org/EIPS/eip-7715).
863+
params: []
864+
result:
865+
name: Granted permissions
866+
description: An array of the granted execution permissions.
867+
schema:
868+
type: array
869+
items:
870+
$ref: '#/components/schemas/ExecutionPermissionResponse'
871+
errors:
872+
- $ref: '#/components/errors/Unauthorized'
873+
examples:
874+
- name: wallet_getGrantedExecutionPermissions example
875+
params: []
876+
result:
877+
name: Granted permissions
878+
value: []
879+
- name: wallet_getSupportedExecutionPermissions
880+
tags:
881+
- $ref: '#/components/tags/MetaMask'
882+
- $ref: '#/components/tags/Experimental'
883+
- $ref: '#/components/tags/Multichain'
884+
summary: Gets supported ERC-7715 execution permissions.
885+
description: >-
886+
Returns the ERC-7715 execution permission types supported by the wallet,
887+
keyed by permission type, including the chain IDs and rule types each
888+
permission supports. Specified by
889+
[ERC-7715](https://eips.ethereum.org/EIPS/eip-7715).
890+
params: []
891+
result:
892+
name: Supported permissions
893+
description: >-
894+
An object keyed by permission type. Each entry describes the chain IDs
895+
and rule types supported for that permission type.
896+
schema:
897+
type: object
898+
additionalProperties:
899+
type: object
900+
properties:
901+
chainIds:
902+
description: The chain IDs that support the permission type.
903+
type: array
904+
items:
905+
$ref: '#/components/schemas/uint'
906+
ruleTypes:
907+
description: The rule types supported for the permission type.
908+
type: array
909+
items:
910+
type: string
911+
errors:
912+
- $ref: '#/components/errors/Unauthorized'
913+
examples:
914+
- name: wallet_getSupportedExecutionPermissions example
915+
params: []
916+
result:
917+
name: Supported permissions
918+
value:
919+
native-token-periodic:
920+
chainIds:
921+
- '0xaa36a7'
922+
ruleTypes:
923+
- expiry
784924
- name: eth_requestAccounts
785925
tags:
786926
- $ref: '#/components/tags/MetaMask'
@@ -1262,6 +1402,128 @@ components:
12621402
Dapps can use this object to communicate with the wallet about
12631403
supported capabilities.
12641404
type: object
1405+
ExecutionPermission:
1406+
title: ExecutionPermission
1407+
description: >-
1408+
An ERC-7715 execution permission. The `type` determines the shape of the
1409+
`data` object (for example `native-token-periodic`, `native-token-stream`,
1410+
`erc20-token-periodic`, `erc20-token-allowance`).
1411+
type: object
1412+
required:
1413+
- type
1414+
- isAdjustmentAllowed
1415+
- data
1416+
properties:
1417+
type:
1418+
description: The permission type.
1419+
type: string
1420+
isAdjustmentAllowed:
1421+
description: >-
1422+
Whether the wallet is allowed to adjust the requested permission
1423+
(for example to a lower allowance) before granting it.
1424+
type: boolean
1425+
data:
1426+
description: >-
1427+
Permission-type-specific data. Token amounts are `0x`-prefixed
1428+
hexadecimal strings; timestamps and durations are numbers (seconds).
1429+
type: object
1430+
additionalProperties: true
1431+
properties:
1432+
justification:
1433+
description: A human-readable explanation of why the permission is requested.
1434+
type: string
1435+
ExecutionPermissionRule:
1436+
title: ExecutionPermissionRule
1437+
description: >-
1438+
A rule that constrains an ERC-7715 execution permission, such as an
1439+
`expiry`, `redeemer`, or `payee` rule.
1440+
type: object
1441+
required:
1442+
- type
1443+
- data
1444+
properties:
1445+
type:
1446+
description: The rule type.
1447+
type: string
1448+
data:
1449+
description: Rule-type-specific data.
1450+
type: object
1451+
additionalProperties: true
1452+
ExecutionPermissionRequest:
1453+
title: ExecutionPermissionRequest
1454+
description: An object describing a single ERC-7715 execution permission request.
1455+
type: object
1456+
required:
1457+
- chainId
1458+
- to
1459+
- permission
1460+
- rules
1461+
properties:
1462+
chainId:
1463+
description: >-
1464+
The [EIP-155](https://eips.ethereum.org/EIPS/eip-155) chain ID the
1465+
permission applies to, as a `0x`-prefixed hexadecimal string.
1466+
$ref: '#/components/schemas/uint'
1467+
from:
1468+
description: >-
1469+
(Optional) The account the permission should be granted from. Useful
1470+
when a connection has been established and multiple accounts have
1471+
been exposed; lets the user choose which account to grant the
1472+
permission for.
1473+
$ref: '#/components/schemas/address'
1474+
to:
1475+
description: The address the permission is granted to (the redeemer/delegate).
1476+
$ref: '#/components/schemas/address'
1477+
permission:
1478+
$ref: '#/components/schemas/ExecutionPermission'
1479+
rules:
1480+
description: >-
1481+
An array of rules constraining the permission. Time-bounded
1482+
permissions are expressed as an `expiry` rule (with a UNIX
1483+
`timestamp` in its `data`) rather than a top-level field. Pass an
1484+
empty array to apply no constraints.
1485+
type: array
1486+
items:
1487+
$ref: '#/components/schemas/ExecutionPermissionRule'
1488+
ExecutionPermissionResponse:
1489+
title: ExecutionPermissionResponse
1490+
description: >-
1491+
A granted ERC-7715 execution permission. Contains the original request
1492+
fields plus the data needed to redeem the permission.
1493+
allOf:
1494+
- $ref: '#/components/schemas/ExecutionPermissionRequest'
1495+
- type: object
1496+
required:
1497+
- context
1498+
- dependencies
1499+
- delegationManager
1500+
properties:
1501+
context:
1502+
description: >-
1503+
An opaque `0x`-prefixed context used to identify and redeem the
1504+
granted permission.
1505+
$ref: '#/components/schemas/bytes'
1506+
delegationManager:
1507+
description: The address of the delegation manager contract.
1508+
$ref: '#/components/schemas/address'
1509+
dependencies:
1510+
description: >-
1511+
Account deployment dependencies required to redeem the
1512+
permission (for example a smart account factory and its data).
1513+
type: array
1514+
items:
1515+
title: ExecutionPermissionDependency
1516+
type: object
1517+
required:
1518+
- factory
1519+
- factoryData
1520+
properties:
1521+
factory:
1522+
description: The address of the account factory contract.
1523+
$ref: '#/components/schemas/address'
1524+
factoryData:
1525+
description: The calldata to pass to the account factory.
1526+
$ref: '#/components/schemas/bytes'
12651527
AddEthereumChainParameter:
12661528
title: Chain
12671529
description: Object containing information about the chain to add.

0 commit comments

Comments
 (0)