Skip to content

Commit

Permalink
address comments on 7715
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrouid committed Jun 27, 2024
1 parent 5fbbd0a commit a75e2d8
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions ERCS/erc-7715.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ type GrantPermissionsRequestParams = {
};
```

`account` is an optional field that identifies the account being targetted for this permissions request which is useful when a connection has been established and multiple accounts have been exposed.
`account` is an optional field that identifies the account being targetted for this permissions request which is useful when a connection has been established and multiple accounts have been exposed.

`chainId` is field that identifies that chain with EIP-155 which these permissions are contextual and all addressed can be found for the accounts and permissions.
`chainId` is field that identifies that chain with [EIP-155](./eip-155.md) which these permissions are contextual and all addressed can be found for the accounts and permissions.

`signer` is a field that identifies the key or account associated with the session or alternatively the wallet will manage the session. See the “Wallet-managed Sessions” section for details.

Expand Down Expand Up @@ -138,7 +138,7 @@ Request example:
required: true,
data: {
address: '0x...',
allowance: '500000000'
allowance: '0x1DCD6500'
}
},
{
Expand All @@ -154,7 +154,7 @@ Request example:
required: false,
data: {
address: '0x...',
allowance: '2000000000'
allowance: '0x77359400'
}
}
],
Expand All @@ -171,22 +171,24 @@ type GrantPermissionsResponse = {

expiry: number;

signerData: {
signerMeta?: {
userOpBuilder?: `0x${string}`;
managerAddress?: `0x${string}`;
delegationManager?: `0x${string}`;
};

factory?: `0x${string}`;

factoryData?: `0x${string}`;
accountMeta?: {
factory: `0x${string}`;
factoryData: `0x${string}`;
};

permissionsContext: string;
};
```

- `grantedPermissions` is a list of permissions that were granted. The wallet MUST grant `required` permissions if the request was approved.
- `expiry` is the expiry time that was granted. The wallet MAY grant a different expiry time than the one that the DApp requested.
- `factory` and `factoryData` are as defined in [ERC-4337](./eip-4337.md). They are either both specified, or none. If the account has not yet been deployed, the wallet MUST return `factory` and `factoryData`, and the DApp MUST deploy the account by calling the `factory` contract with `factoryData` as the calldata.
- `signerMeta` is dependent on the account type. If the signer type is `wallet` then it's not required. If the signer type is `key` or `keys` then `userOpBuilder` is required as defined in [ERC-7679](./eip-7679.md). If the signer type is `account` then `delegationManager` is required as defined in [ERC-7710](./eip-7710.md).
- `accountMeta` is optional but when present then fields for `factory` and `factoryData` are required as defined in [ERC-4337](./eip-4337.md). They are either both specified, or none. If the account has not yet been deployed, the wallet MUST return `accountMeta`, and the DApp MUST deploy the account by calling the `factory` contract with `factoryData` as the calldata.
- `permissionsContext` is an opaque string that identifies the session. It MAY be the `context` as defined in [ERC-7679](./eip-7679.md) and [ERC-7710](./eip-7710.md). See “Rationale” for details.

If the request is malformed or the wallet is unable/unwilling to grant permissions, wallet MUST return an error with a code as defined in [ERC-1193](./eip-1193.md).
Expand Down Expand Up @@ -215,7 +217,7 @@ If the request is malformed or the wallet is unable/unwilling to grant permissio
required: true,
data: {
address: '0x...',
allowance: '500000000'
allowance: '0x1DCD6500'
}
},
{
Expand All @@ -231,7 +233,7 @@ If the request is malformed or the wallet is unable/unwilling to grant permissio
required: false,
data: {
address: '0x...',
allowance: '1000000000'
allowance: '0x3B9ACA00'
}
}
],
Expand All @@ -244,7 +246,7 @@ If the request is malformed or the wallet is unable/unwilling to grant permissio

### `wallet_revokePermissions`

TODO
Permissions can be revoked by calling this method and the wallet will respond with an empty response when successful.

#### Request Specification

Expand Down Expand Up @@ -313,7 +315,7 @@ type NativeTokenTransferPermission = {
type: 'native-token-transfer';
policies: [...];
data: {
allowance: string; // uint256 value
allowance: '0x...'; // hex value
};
};

Expand All @@ -323,7 +325,7 @@ type ERC20TokenTransferPermission = {
policies: [...];
data: {
address: '0x...'; // erc20 contract
allowance: string; // uint256 value
allowance: '0x...'; // hex value
};
};

Expand All @@ -333,7 +335,7 @@ type ERC721TokenTransferPermission = {
policies: [...];
data: {
address: '0x...'; // erc721 contract
tokenIds: string[]; // uint256 array
tokenIds: '0x...'[]; // hex value array
};
};

Expand All @@ -344,7 +346,7 @@ type ERC1155TokenTransferPermission = {
data: {
address: '0x...'; // erc1155 contract
allowances: {
[tokenId: string]: string; // uint256 value
[tokenId: string]: '0x...'; // hex value
}
};
};
Expand All @@ -358,7 +360,7 @@ type ERC1155TokenTransferPermission = {
type GasLimitPolicy = {
type: "gas-limit";
data: {
limit: string; // uint256 value
limit: "0x..."; // hex value
};
};

Expand All @@ -367,8 +369,8 @@ type CallLimitPolicy = {
type: "call-limit";
data: {
count: number;
}
}
};
};

// The number of calls the session can make during each interval
type RateLimitPolicy = {
Expand All @@ -383,7 +385,7 @@ type RateLimitPolicy = {
type NativeTokenSpendLimitPolicy = {
type: "spent-limit";
data: {
allowance: string; // uint256 value
allowance: "0x..."; // hex value
};
};
```
Expand Down Expand Up @@ -461,7 +463,7 @@ Example:

#### ERC-7679 with `Key` type signer

`wallet_grantPermissions` replies with `permissionsContext` and `userOpBuilder` address inside the `signerData` field. DApps can use that data with methods provided by [ERC-7679](./eip-7679.md) to build the [ERC-4337](./eip-4337.md) userOp.
`wallet_grantPermissions` replies with `permissionsContext` and `userOpBuilder` address inside the `signerMeta` field. DApps can use that data with methods provided by [ERC-7679](./eip-7679.md) to build the [ERC-4337](./eip-4337.md) userOp.

[ERC-7679](./eip-7679.md) UserOp Builder contract defines `bytes calldata context` parameter in all of its methods. It’s equivalent to the`permissionsContext` returned by the `wallet_grantPermissions` call.

Expand Down Expand Up @@ -512,7 +514,7 @@ sequenceDiagram

#### ERC-7710

When requesting permissions with a `type` of `account`, the returned data will be redeemable using the interfaces specified in ERC-7710. This allows the recipient of the permissions to use any account type (EOA or contract) to form a transaction or UserOp using whatever payment or relay infrastructure they prefer, by sending an internal message to the returned `permissions.signerData.managerAddress` and calling its `function redeemDelegation(bytes calldata _data, Action calldata _action) external;` function with the `_data` parameter set to the returned `permissions.permissionsContext`, and the `_action` data forming the message that the permissions recipient desires the user's account to emit, as defined by this struct:
When requesting permissions with a `type` of `account`, the returned data will be redeemable using the interfaces specified in ERC-7710. This allows the recipient of the permissions to use any account type (EOA or contract) to form a transaction or UserOp using whatever payment or relay infrastructure they prefer, by sending an internal message to the returned `permissions.signerMeta.delegationManager` and calling its `function redeemDelegation(bytes calldata _data, Action calldata _action) external;` function with the `_data` parameter set to the returned `permissions.permissionsContext`, and the `_action` data forming the message that the permissions recipient desires the user's account to emit, as defined by this struct:

```
struct Action {
Expand Down Expand Up @@ -541,31 +543,31 @@ const permissionsResponse = await bob.request({
type: 'native-token-transfer',
policies: [{
type: 'gas-limit',
data: 1e5
data: '0x0186A0'
}]
data: {
allowance: 1e18
allowance: '0x0DE0B6B3A7640000'
},
required: true
}],
expiry: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now
}]
});
// Extract the permissionsContext and managerAddress
// Extract the permissionsContext and delegationManager
const permissionsContext = permissionsResponse.permissionsContext;
const managerAddress = permissionsResponse.signerData.managerAddress;
const delegationManager = permissionsResponse.signerMeta.delegationManager;
// Alice forms the action she wants Bob's account to take
const action = {
to: alice.address,
value: 0.5e18
value: '0x06F05B59D3B20000'
data: '0x'
};
// Alice sends the transaction by calling redeemDelegation on Bob's account
const tx = await bob.sendTransaction({
to: managerAddress,
to: delegationManager,
data: bob.interface.encodeFunctionData('redeemDelegation', [
permissionsContext,
action
Expand Down

0 comments on commit a75e2d8

Please sign in to comment.