From 9fac88f26026d1ed19f5ebeebd4a183dc94f9447 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 01:17:38 +0700 Subject: [PATCH 01/20] Change the order of parameters --- assets/eip-6366/contracts/EIP6366Core.sol | 14 +++++++------- .../contracts/interfaces/IEIP6366Core.sol | 10 +++++++--- assets/eip-6366/example/APermissionToken.sol | 18 +++++++++++++----- assets/eip-6366/example/APermissioned.sol | 6 +++--- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/assets/eip-6366/contracts/EIP6366Core.sol b/assets/eip-6366/contracts/EIP6366Core.sol index b3818e7fd324c3..91e54d64a954f7 100644 --- a/assets/eip-6366/contracts/EIP6366Core.sol +++ b/assets/eip-6366/contracts/EIP6366Core.sol @@ -57,10 +57,10 @@ contract EIP6366Core is IEIP6366Core { * @param _permission Checking permission set */ function permissionRequire( - uint256 _required, - uint256 _permission + uint256 _permission, + uint256 _required ) external view virtual override returns (bool isPermissioned) { - return _permissionRequire(_required, _permission); + return _permissionRequire(_permission, _required); } /** @@ -159,8 +159,8 @@ contract EIP6366Core is IEIP6366Core { } function _permissionRequire( - uint256 _required, - uint256 _permission + uint256 _permission, + uint256 _required ) internal pure returns (bool isPermissioned) { return _required == _permission & _required; } @@ -172,8 +172,8 @@ contract EIP6366Core is IEIP6366Core { ) internal view returns (bool isPermissioned) { return _permissionRequire( - _required, - _permissionOf(_actor) | _delegated(_owner, _actor) + _permissionOf(_actor) | _delegated(_owner, _actor), + _required ); } diff --git a/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol b/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol index a8d4143466b6fc..ea4f6fba22ad31 100644 --- a/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol +++ b/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol @@ -5,7 +5,11 @@ pragma solidity ^0.8.7; * @dev Defined the interface of the core of EIP6366 that MUST to be implemented */ interface IEIP6366Core { - event Transfer(address indexed _from, address indexed _to, uint256 _value); + event Transfer( + address indexed _from, + address indexed _to, + uint256 indexed _permission + ); event Approval( address indexed _owner, @@ -28,8 +32,8 @@ interface IEIP6366Core { ) external view returns (uint256 permission); function permissionRequire( - uint256 _required, - uint256 _permission + uint256 _permission, + uint256 _required ) external view returns (bool isPermissioned); function hasPermission( diff --git a/assets/eip-6366/example/APermissionToken.sol b/assets/eip-6366/example/APermissionToken.sol index 2f37dfa8993261..7929293437890c 100644 --- a/assets/eip-6366/example/APermissionToken.sol +++ b/assets/eip-6366/example/APermissionToken.sol @@ -55,7 +55,7 @@ contract APermissionToken is EIP6366Core, EIP6366Meta { */ modifier allow(uint256 required) { address owner = msg.sender; - if (!_permissionRequire(required, _permissionOf(owner))) { + if (!_permissionRequire(_permissionOf(owner), required)) { revert IEIP6366Error.AccessDenied(owner, owner, required); } _; @@ -65,7 +65,7 @@ contract APermissionToken is EIP6366Core, EIP6366Meta { * @dev Deny blacklisted address */ modifier notBlacklisted() { - if (_permissionRequire(PERMISSION_DENIED, _permissionOf(msg.sender))) { + if (_permissionRequire(_permissionOf(msg.sender), PERMISSION_DENIED)) { revert IEIP6366Error.AccessDenied( msg.sender, msg.sender, @@ -79,8 +79,16 @@ contract APermissionToken is EIP6366Core, EIP6366Meta { * @dev Construct ERC-6366 */ constructor() EIP6366Meta("Ecosystem A Permission Token", "APT") { - _setDescription(PERMISSION_DENIED, "PERMISSION_DENIED", "Blacklisted address"); - _setDescription(PERMISSION_VOTE, "PERMISSION_VOTE", "Permission owner able to vote"); + _setDescription( + PERMISSION_DENIED, + "PERMISSION_DENIED", + "Blacklisted address" + ); + _setDescription( + PERMISSION_VOTE, + "PERMISSION_VOTE", + "Permission owner able to vote" + ); _setDescription( PERMISSION_TRANSFER, "PERMISSION_TRANSFER", @@ -111,7 +119,7 @@ contract APermissionToken is EIP6366Core, EIP6366Meta { "ROLE_OPERATOR", "Operator role can execute and vote" ); - + // Assign master permission to deployer _mint(msg.sender, PERMISSION_MASTER); } diff --git a/assets/eip-6366/example/APermissioned.sol b/assets/eip-6366/example/APermissioned.sol index 409f2f9853cd58..ee05d69f4d8e63 100644 --- a/assets/eip-6366/example/APermissioned.sol +++ b/assets/eip-6366/example/APermissioned.sol @@ -55,7 +55,7 @@ contract APermissioned { * @dev Allow the actor who has required permission */ modifier allowOwner(uint256 _required) { - if (!opt.permissionRequire(_required, opt.permissionOf(msg.sender))) { + if (!opt.permissionRequire(opt.permissionOf(msg.sender), _required)) { revert IEIP6366Error.AccessDenied( msg.sender, msg.sender, @@ -71,8 +71,8 @@ contract APermissioned { modifier notBlacklisted() { if ( opt.permissionRequire( - PERMISSION_DENIED, - opt.permissionOf(msg.sender) + opt.permissionOf(msg.sender), + PERMISSION_DENIED ) ) { revert IEIP6366Error.AccessDenied( From 1c59d45792a9de627654dc354ab9719fa277c4f8 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 01:17:52 +0700 Subject: [PATCH 02/20] Update eip-6366 to make it more clear --- EIPS/eip-6366.md | 124 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 104 insertions(+), 20 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 1a1af11bb8076a..71d09ee23c8d16 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -29,69 +29,153 @@ _Note_ The following specifications use syntax from Solidity `0.8.7` (or above) ### Core Interface -Compliant contracts MUST implement `IEIP6366Core`. +Compliant contracts MUST implement `IEIP6366Core`. It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-bit_based_permission](./bit_based_permission.md). ```solidity interface IEIP6366Core { - event Transfer(address indexed _from, address indexed _to, uint256 _value); + /** + * MUST trigger when `_permission` are transferred, including `zero` permission transfers. + * @param _from Permission owner + * @param _to Receiver + * @param _permission Subset permission of permission owner + */ + event Transfer(address indexed _from, address indexed _to, uint256 indexed _permission); + + /** + * MUST trigger on any successful call to `approve(address _delegatee, uint256 _permission)`. + * @param _owner Permission owner + * @param _delegatee Delegatee + * @param _permission Subset permission of permission owner + */ event Approval(address indexed _owner, address indexed _delegatee, uint256 _permission); + /** + * Transfers a subset `_permission` of permission to address `_to`. + * The function SHOULD revert if the message caller’s account permission does not have the subset + * of the transferring permissions. The function SHOULD revert if any of transferring permissions are + * existing on target `_to` address. + * @param _to Receiver + * @param _permission Subset permission of permission owner + */ function transfer(address _to, uint256 _permission) external returns (bool success); + + /** + * Allows `_delegatee` to act for the permission owner's behalf, up to the `_permission`. + * If this function is called again it overwrites the current granted with `_permission`. + * `approve()` method SHOULD `revert` if granting `_permission` permission is not + * a subset of all available permission of permission owner. + * @param _delegatee Delegatee + * @param _permission Subset permission of permission owner + */ function approve(address _delegatee, uint256 _permission) external returns (bool success); + /** + * Returns the account's permissions of the given `_owner` address. + */ function permissionOf(address _owner) external view returns (uint256 permission); - function permissionRequire(uint256 _required, uint256 _permission) external view returns (bool isPermissioned); + + /** + * Returns `true` if `_required` is a subset of `_permission` otherwise return `false`. + * @param _permission Checking permission set + * @param _required Required set of permission + */ + function permissionRequire(uint256 _permission, uint256 _required) external view returns (bool isPermissioned); + + /** + * Returns `true` if `_required` permission is a subset of `_actor`'s permissions or a subset of his delegated + * permission granted by the `_owner`. + * @param _owner Permission owner + * @param _actor Actor is acting for owner's behalf + * @param _required Required set of permission + */ function hasPermission(address _owner, address _actor, uint256 _required) external view returns (bool isPermissioned); + + /** + * Returns the subset permission of the `_owner` address were granted to `_delegatee` address. + * @param _owner Permission owner + * @param _delegatee Delegatee + */ function delegated(address _owner, address _delegatee) external view returns (uint256 permission); } ``` -1. It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-bit_based_permission](./bit_based_permission.md). -2. `transfer(address _to, uint256 _permission)` transfers a subset of `_permission` permission to address `_to`, and MUST emit the `Transfer` event. The function SHOULD `revert` if the message caller's account permission does not have the subset of the transferring permission. The function SHOULD `revert` if any of transferring permission is existing on target `_to` address. Transfers of `0` permission MUST be treated as normal transfers and emit the `Transfer` event. -3. `approve(address _delegatee, uint256 _permission)` allows `_delegatee` to act for the permission owner's behalf, up to the `_permission` permission, and MUST emit the `Approval` event. If this function is called again it overwrites the current granted with `_permission`. `_permission` MUST be a subset of all available permission of permission owner. `approve()` method SHOULD `revert` if granting `_permission` permission is not a subset of all available permission of permission owner. -4. `permissionOf(address _owner)` returns the account permission of the given `_owner` address. -5. `permissionRequire(uint256 _required, uint256 _permission)` returns `true` if `_required` permission is a subset of `_permission` permission otherwise return `false`. -6. `hasPermission(address _owner, address _actor, uint256 _required)` returns `true` if `_required` permission is a subset of `_actor`'s permissions or a subset of his delegated permissions granted by the `_owner`. -7. `delegated(address _owner, address _delegatee)` returns the subset permission of the `_owner` address were granted to `_delegatee` address. -8. A token contract which creates new tokens SHOULD emit a `Transfer` event with the `_from` address set to `address(0x00)` when tokens are created. - ### Metadata Interface It is RECOMMENDED for compliant contracts to implement the optional extension `IEIP6366Meta`. +SHOULD define a description for the base permissions and main combinaison. +SHOULD NOT define a description for every subcombinaison of permissions possible. ```solidity interface IEIP6366Meta { + /** + * Structure of permission description + * @param _permission Permission + * @param _name Name of permission + * @param _description Description of permission + */ struct PermissionDescription { uint256 permission; string name; string description; } + /** + * MUST trigger when description is updated. + * @param _permission Permission + * @param _name Name of permission + * @param _description Description of permission + */ event UpdatePermissionDescription(uint256 indexed _permission, string indexed _name, string indexed _description); + /** + * Returns the name of the token - e.g. `"OpenPermissionToken"`. + */ function name() external view returns (string memory); + + /** + * Returns the symbol of the token. E.g. `"OPT"`. + */ function symbol() external view returns (string memory); + + /** + * Return a description of a permission, at a given `_permission`. + * @param _permission Permission + */ function getDescription(uint256 _permission) external view returns (PermissionDescription memory description); - function setDescription(uint256 _permission, string memory _name, string memory _description) external returns (bool success); + /** + * Return `true` if the description was set otherwise return `false`. It MUST emit `UpdatePermissionDescription` event. + * @param _permission Permission + * @param _name Name of permission + * @param _description Description of permission + */ + function setDescription( + uint256 _permission, + string memory _name, + string memory _description + ) external returns (bool success); } ``` -1. `name()` returns the name of the token - e.g. `"OpenPermissionToken"`. -2. `symbol()` returns the symbol of the token. E.g. `"OPT"`. -3. `getDescription(uint256 _permission)` return the description of a permission. -4. `setDescription(uint256 _permission, string memory _name, string memory _description)` return `true` if the description was set otherwise return `false`. It MUST emit `UpdatePermissionDescription` event. -5. SHOULD define a description for the base permissions and main combinaison. -6. SHOULD NOT define a description for every subcombinaison of permissions possible. - ### Error Interface SHOULD NOT expected `IEIP6366Error` interface was implemented. ```solidity interface IEIP6366Error { + /** + * Owner or actor do not have required permission + */ error AccessDenied(address _owner, address _actor, uint256 _permission); + + /** + * Conflict between permission set + */ error DuplicatedPermission(uint256 _permission); + + /** + * Data out of range + */ error OutOfRange(); } ``` From 96923c3603e6cb2e4203256ab371ad830fda84b8 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 01:26:21 +0700 Subject: [PATCH 03/20] Link eip-6366 to eip-6617 --- EIPS/eip-6366.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 71d09ee23c8d16..f62fd8c874b72e 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -8,12 +8,12 @@ status: Draft type: Standards Track category: ERC created: 2022-01-19 -requires: bit_based_permission +requires: 6617 --- ## Abstract -This EIP offers an alternative to Access Control Lists (ACLs) for granting authorization and enhancing security. An `uint256` is used to store permission of given address in a ecosystem. Each permission is represented by a single bit in `uint256` as described in [eip-bit_based_permission](./bit_based_permission.md). Bitwise operators and bitmasks are used to determine the access right which is much more efficient and flexible than `string` or `keccak256` comparison. +This EIP offers an alternative to Access Control Lists (ACLs) for granting authorization and enhancing security. An `uint256` is used to store permission of given address in a ecosystem. Each permission is represented by a single bit in `uint256` as described in [eip-6617](./eip-6617.md). Bitwise operators and bitmasks are used to determine the access right which is much more efficient and flexible than `string` or `keccak256` comparison. ## Motivation @@ -29,7 +29,7 @@ _Note_ The following specifications use syntax from Solidity `0.8.7` (or above) ### Core Interface -Compliant contracts MUST implement `IEIP6366Core`. It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-bit_based_permission](./bit_based_permission.md). +Compliant contracts MUST implement `IEIP6366Core`. It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-6617](./eip-6617.md). ```solidity interface IEIP6366Core { From abc08b580302de5b3e7831d96fbd9b70cc67ceb4 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:40:24 +0700 Subject: [PATCH 04/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index f62fd8c874b72e..9704dcff99397f 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -36,7 +36,7 @@ interface IEIP6366Core { /** * MUST trigger when `_permission` are transferred, including `zero` permission transfers. * @param _from Permission owner - * @param _to Receiver + * @param _to Permission receiver * @param _permission Subset permission of permission owner */ event Transfer(address indexed _from, address indexed _to, uint256 indexed _permission); From 1982babdb107c318c40caa572e514abf79312346 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:41:15 +0700 Subject: [PATCH 05/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 9704dcff99397f..860832f64de525 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -37,7 +37,7 @@ interface IEIP6366Core { * MUST trigger when `_permission` are transferred, including `zero` permission transfers. * @param _from Permission owner * @param _to Permission receiver - * @param _permission Subset permission of permission owner + * @param _permission Transferred subset permission of permission owner */ event Transfer(address indexed _from, address indexed _to, uint256 indexed _permission); From 9a5bd6693467b9b3f8bdc2e4397872096a9e1696 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:41:22 +0700 Subject: [PATCH 06/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 860832f64de525..cc91bcc1eb9299 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -29,7 +29,9 @@ _Note_ The following specifications use syntax from Solidity `0.8.7` (or above) ### Core Interface -Compliant contracts MUST implement `IEIP6366Core`. It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-6617](./eip-6617.md). +Compliant contracts MUST implement `IEIP6366Core`. + +It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-6617](./eip-6617.md). ```solidity interface IEIP6366Core { From 708f15ca543dff00cc7dbaa1bb1557b21c316bf7 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:41:32 +0700 Subject: [PATCH 07/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index cc91bcc1eb9299..93fcc4ab4b5ede 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -47,7 +47,7 @@ interface IEIP6366Core { * MUST trigger on any successful call to `approve(address _delegatee, uint256 _permission)`. * @param _owner Permission owner * @param _delegatee Delegatee - * @param _permission Subset permission of permission owner + * @param _permission Approved subset permission of permission owner */ event Approval(address indexed _owner, address indexed _delegatee, uint256 _permission); From 324d617a002ebfd3ea1b39bf4b4477d8733be551 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:41:50 +0700 Subject: [PATCH 08/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 93fcc4ab4b5ede..c4d30e3e438b54 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -72,7 +72,7 @@ interface IEIP6366Core { function approve(address _delegatee, uint256 _permission) external returns (bool success); /** - * Returns the account's permissions of the given `_owner` address. + * Returns the permissions of the given `_owner` address. */ function permissionOf(address _owner) external view returns (uint256 permission); From df0ac8ccd2767116f3bb0a3b8092a5d7aeb55302 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:42:04 +0700 Subject: [PATCH 09/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index c4d30e3e438b54..823c1bc953b125 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -87,7 +87,7 @@ interface IEIP6366Core { * Returns `true` if `_required` permission is a subset of `_actor`'s permissions or a subset of his delegated * permission granted by the `_owner`. * @param _owner Permission owner - * @param _actor Actor is acting for owner's behalf + * @param _actor Actor who acts on behalf of the owner * @param _required Required set of permission */ function hasPermission(address _owner, address _actor, uint256 _required) external view returns (bool isPermissioned); From b56e1710cc7b7fb576cc0e915bae3d8546dbc6a5 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:42:22 +0700 Subject: [PATCH 10/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 823c1bc953b125..52e95878fe6e45 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -104,6 +104,7 @@ interface IEIP6366Core { ### Metadata Interface It is RECOMMENDED for compliant contracts to implement the optional extension `IEIP6366Meta`. + SHOULD define a description for the base permissions and main combinaison. SHOULD NOT define a description for every subcombinaison of permissions possible. From 4474a7ba91b86cf179b8bb1ae4b339b7877696f4 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:42:35 +0700 Subject: [PATCH 11/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 52e95878fe6e45..ef077ffa75de3b 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -106,6 +106,7 @@ interface IEIP6366Core { It is RECOMMENDED for compliant contracts to implement the optional extension `IEIP6366Meta`. SHOULD define a description for the base permissions and main combinaison. + SHOULD NOT define a description for every subcombinaison of permissions possible. ```solidity From c7ecdc2cf019a08be37e10faf4d7c8e7b798c6b3 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:42:46 +0700 Subject: [PATCH 12/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index ef077ffa75de3b..9bfe31f948dcc6 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -114,8 +114,8 @@ interface IEIP6366Meta { /** * Structure of permission description * @param _permission Permission - * @param _name Name of permission - * @param _description Description of permission + * @param _name Name of the permission + * @param _description Description of the permission */ struct PermissionDescription { uint256 permission; From 996e8b5ffe97e30e05db955c725896d687992818 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:43:02 +0700 Subject: [PATCH 13/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 9bfe31f948dcc6..7908f0005da9aa 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -124,10 +124,10 @@ interface IEIP6366Meta { } /** - * MUST trigger when description is updated. + * MUST trigger when the description is updated. * @param _permission Permission - * @param _name Name of permission - * @param _description Description of permission + * @param _name Name of the permission + * @param _description Description of the permission */ event UpdatePermissionDescription(uint256 indexed _permission, string indexed _name, string indexed _description); From 2ca565c20bd76602fcb1d5db8107c3bb9a852c0d Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:43:16 +0700 Subject: [PATCH 14/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index 7908f0005da9aa..e393f46222a9ac 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -142,7 +142,7 @@ interface IEIP6366Meta { function symbol() external view returns (string memory); /** - * Return a description of a permission, at a given `_permission`. + * Returns the description of a given `_permission`. * @param _permission Permission */ function getDescription(uint256 _permission) external view returns (PermissionDescription memory description); From 6207af9a6ca5e24b9299d132cf11cd1e5baddda0 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:43:28 +0700 Subject: [PATCH 15/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index e393f46222a9ac..e99ea0f07ec16b 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -150,8 +150,8 @@ interface IEIP6366Meta { /** * Return `true` if the description was set otherwise return `false`. It MUST emit `UpdatePermissionDescription` event. * @param _permission Permission - * @param _name Name of permission - * @param _description Description of permission + * @param _name Name of the permission + * @param _description Description of the permission */ function setDescription( uint256 _permission, From 2c9e67ebac64a58d6718a196ae25212f70a91a9a Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:43:38 +0700 Subject: [PATCH 16/20] Update EIPS/eip-6366.md Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- EIPS/eip-6366.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index e99ea0f07ec16b..d388807e9feb11 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -168,7 +168,7 @@ SHOULD NOT expected `IEIP6366Error` interface was implemented. ```solidity interface IEIP6366Error { /** - * Owner or actor do not have required permission + * The owner or actor does not have the required permission */ error AccessDenied(address _owner, address _actor, uint256 _permission); From dfec00967d97e3407892bc90044f57e8f2848462 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:43:46 +0700 Subject: [PATCH 17/20] Update assets/eip-6366/example/APermissionToken.sol Co-authored-by: Victor Dusart <43795504+vdusart@users.noreply.github.com> --- assets/eip-6366/example/APermissionToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/eip-6366/example/APermissionToken.sol b/assets/eip-6366/example/APermissionToken.sol index 7929293437890c..79f7193e9d99a8 100644 --- a/assets/eip-6366/example/APermissionToken.sol +++ b/assets/eip-6366/example/APermissionToken.sol @@ -87,7 +87,7 @@ contract APermissionToken is EIP6366Core, EIP6366Meta { _setDescription( PERMISSION_VOTE, "PERMISSION_VOTE", - "Permission owner able to vote" + "Permission owner can vote" ); _setDescription( PERMISSION_TRANSFER, From 7d54dbabced1eb5aff940477b61691aa49700b8d Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 10:47:55 +0700 Subject: [PATCH 18/20] Update example of permission token --- assets/eip-6366/example/APermissionToken.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/eip-6366/example/APermissionToken.sol b/assets/eip-6366/example/APermissionToken.sol index 79f7193e9d99a8..c6b09c3c950d72 100644 --- a/assets/eip-6366/example/APermissionToken.sol +++ b/assets/eip-6366/example/APermissionToken.sol @@ -92,22 +92,22 @@ contract APermissionToken is EIP6366Core, EIP6366Meta { _setDescription( PERMISSION_TRANSFER, "PERMISSION_TRANSFER", - "Permission owner able to transfer" + "Permission owner can transfer" ); _setDescription( PERMISSION_EXECUTE, "PERMISSION_EXECUTE", - "Permission owner able to execute" + "Permission owner can execute" ); _setDescription( PERMISSION_CREATE, "PERMISSION_CREATE", - "Permission owner able to create" + "Permission owner can create" ); _setDescription( PERMISSION_MASTER, "PERMISSION_MASTER", - "Permission owner able to mint and update description" + "Permission owner can mint and update description" ); _setDescription( ROLE_ADMIN, From 14c51e367182ab1d3fecfc3d2aaa9c2ec39abb00 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 15:16:08 +0700 Subject: [PATCH 19/20] Update missing indexed parameters and code format --- EIPS/eip-6366.md | 56 +++++++++---------- .../contracts/interfaces/IEIP6366Core.sol | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index d388807e9feb11..ea7ce489af5d9c 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -37,27 +37,27 @@ It is RECOMMENDED to define each permission as a power of `2` so that we can che interface IEIP6366Core { /** * MUST trigger when `_permission` are transferred, including `zero` permission transfers. - * @param _from Permission owner - * @param _to Permission receiver - * @param _permission Transferred subset permission of permission owner + * @param _from Permission owner + * @param _to Permission receiver + * @param _permission Transferred subset permission of permission owner */ event Transfer(address indexed _from, address indexed _to, uint256 indexed _permission); /** * MUST trigger on any successful call to `approve(address _delegatee, uint256 _permission)`. - * @param _owner Permission owner - * @param _delegatee Delegatee - * @param _permission Approved subset permission of permission owner + * @param _owner Permission owner + * @param _delegatee Delegatee + * @param _permission Approved subset permission of permission owner */ - event Approval(address indexed _owner, address indexed _delegatee, uint256 _permission); + event Approval(address indexed _owner, address indexed _delegatee, uint256 indexed _permission); /** * Transfers a subset `_permission` of permission to address `_to`. * The function SHOULD revert if the message caller’s account permission does not have the subset * of the transferring permissions. The function SHOULD revert if any of transferring permissions are * existing on target `_to` address. - * @param _to Receiver - * @param _permission Subset permission of permission owner + * @param _to Permission receiver + * @param _permission Subset permission of permission owner */ function transfer(address _to, uint256 _permission) external returns (bool success); @@ -66,8 +66,8 @@ interface IEIP6366Core { * If this function is called again it overwrites the current granted with `_permission`. * `approve()` method SHOULD `revert` if granting `_permission` permission is not * a subset of all available permission of permission owner. - * @param _delegatee Delegatee - * @param _permission Subset permission of permission owner + * @param _delegatee Delegatee + * @param _permission Subset permission of permission owner */ function approve(address _delegatee, uint256 _permission) external returns (bool success); @@ -78,24 +78,24 @@ interface IEIP6366Core { /** * Returns `true` if `_required` is a subset of `_permission` otherwise return `false`. - * @param _permission Checking permission set - * @param _required Required set of permission + * @param _permission Checking permission set + * @param _required Required set of permission */ function permissionRequire(uint256 _permission, uint256 _required) external view returns (bool isPermissioned); /** * Returns `true` if `_required` permission is a subset of `_actor`'s permissions or a subset of his delegated * permission granted by the `_owner`. - * @param _owner Permission owner - * @param _actor Actor who acts on behalf of the owner - * @param _required Required set of permission + * @param _owner Permission owner + * @param _actor Actor who acts on behalf of the owner + * @param _required Required set of permission */ function hasPermission(address _owner, address _actor, uint256 _required) external view returns (bool isPermissioned); /** * Returns the subset permission of the `_owner` address were granted to `_delegatee` address. - * @param _owner Permission owner - * @param _delegatee Delegatee + * @param _owner Permission owner + * @param _delegatee Delegatee */ function delegated(address _owner, address _delegatee) external view returns (uint256 permission); } @@ -113,9 +113,9 @@ SHOULD NOT define a description for every subcombinaison of permissions possible interface IEIP6366Meta { /** * Structure of permission description - * @param _permission Permission - * @param _name Name of the permission - * @param _description Description of the permission + * @param _permission Permission + * @param _name Name of the permission + * @param _description Description of the permission */ struct PermissionDescription { uint256 permission; @@ -125,9 +125,9 @@ interface IEIP6366Meta { /** * MUST trigger when the description is updated. - * @param _permission Permission - * @param _name Name of the permission - * @param _description Description of the permission + * @param _permission Permission + * @param _name Name of the permission + * @param _description Description of the permission */ event UpdatePermissionDescription(uint256 indexed _permission, string indexed _name, string indexed _description); @@ -143,15 +143,15 @@ interface IEIP6366Meta { /** * Returns the description of a given `_permission`. - * @param _permission Permission + * @param _permission Permission */ function getDescription(uint256 _permission) external view returns (PermissionDescription memory description); /** * Return `true` if the description was set otherwise return `false`. It MUST emit `UpdatePermissionDescription` event. - * @param _permission Permission - * @param _name Name of the permission - * @param _description Description of the permission + * @param _permission Permission + * @param _name Name of the permission + * @param _description Description of the permission */ function setDescription( uint256 _permission, diff --git a/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol b/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol index ea4f6fba22ad31..c9abc6a8533076 100644 --- a/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol +++ b/assets/eip-6366/contracts/interfaces/IEIP6366Core.sol @@ -14,7 +14,7 @@ interface IEIP6366Core { event Approval( address indexed _owner, address indexed _delegatee, - uint256 _permission + uint256 indexed _permission ); function transfer( From 59559317be889b256a0a54f294361dd62938faa2 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 9 Mar 2023 15:19:22 +0700 Subject: [PATCH 20/20] Update following new style guide for reference ERC https://github.com/ethereum/EIPs/pull/6603 --- EIPS/eip-6366.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-6366.md b/EIPS/eip-6366.md index ea7ce489af5d9c..36407fceb129c9 100644 --- a/EIPS/eip-6366.md +++ b/EIPS/eip-6366.md @@ -13,7 +13,7 @@ requires: 6617 ## Abstract -This EIP offers an alternative to Access Control Lists (ACLs) for granting authorization and enhancing security. An `uint256` is used to store permission of given address in a ecosystem. Each permission is represented by a single bit in `uint256` as described in [eip-6617](./eip-6617.md). Bitwise operators and bitmasks are used to determine the access right which is much more efficient and flexible than `string` or `keccak256` comparison. +This EIP offers an alternative to Access Control Lists (ACLs) for granting authorization and enhancing security. An `uint256` is used to store permission of given address in a ecosystem. Each permission is represented by a single bit in `uint256` as described in [ERC-6617](./eip-6617.md). Bitwise operators and bitmasks are used to determine the access right which is much more efficient and flexible than `string` or `keccak256` comparison. ## Motivation @@ -31,7 +31,7 @@ _Note_ The following specifications use syntax from Solidity `0.8.7` (or above) Compliant contracts MUST implement `IEIP6366Core`. -It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [eip-6617](./eip-6617.md). +It is RECOMMENDED to define each permission as a power of `2` so that we can check for the relationship between sets of permissions using [ERC-6617](./eip-6617.md). ```solidity interface IEIP6366Core {