Skip to content

Commit

Permalink
Update EIP-7303: Update eip-7303.md
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
kofujimura authored Aug 28, 2023
1 parent d12dfe4 commit dc1a490
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions EIPS/eip-7303.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S
3. To ascertain whether an account possesses the necessary role, it SHOULD be confirmed that the balance of the `control token` exceeds 0, utilizing the `balanceOf` method defined in ERC-721 or ERC-1155. Note that the `typeId` must be specified if an ERC-1155 token is used for the `balanceOf` method.
4. To grant a role to an account, a `control token` representing the privilege SHOULD be minted to the account using `safeMint` method defined in [ERC-5679](./eip-5679.md).
5. To revoke a role from an account, the `control token` representing the privilege SHOULD be burned using the `burn` method defined in ERC-5679.
6. A role in a compliant smart contract is represented in the format of `bytes32`. It's RECOMMENDED the value of such role is computed as a `keccak256` hash of a string of the role name, in this format: `bytes32 role = keccak256("<role_name>")`. such as `bytes32 role = keccak256("MINTER")`.
6. A role in a compliant smart contract is represented in the format of `bytes32`. It's RECOMMENDED the value of such role is computed as a `keccak256` hash of a string of the role name, in this format: `bytes32 role = keccak256("<role_name>")` such as `bytes32 role = keccak256("MINTER")`.

## Rationale

Expand Down Expand Up @@ -90,7 +90,7 @@ abstract contract ERC7303 {
* @param role byte32 The role which you want to grant.
* @param contractId address The address of contractId of which token the user required to own.
*/
function _grantRoleByERC721Token(bytes32 role, address contractId) internal {
function _grantRoleByERC721(bytes32 role, address contractId) internal {
require(
IERC165(contractId).supportsInterface(type(IERC721).interfaceId),
"ERC7303: provided contract does not support ERC721 interface"
Expand All @@ -103,9 +103,9 @@ abstract contract ERC7303 {
* Multiple calls are allowed, in this case the user must own at least one of the specified token.
* @param role byte32 The role which you want to grant.
* @param contractId address The address of contractId of which token the user required to own.
* @param typeId address The token type id that the user required to own.
* @param typeId uint256 The token type id that the user required to own.
*/
function _grantRoleByERC1155Token(bytes32 role, address contractId, uint256 typeId) internal {
function _grantRoleByERC1155(bytes32 role, address contractId, uint256 typeId) internal {
require(
IERC165(contractId).supportsInterface(type(IERC1155).interfaceId),
"ERC7303: provided contract does not support ERC1155 interface"
Expand Down Expand Up @@ -146,12 +146,12 @@ contract MyToken is ERC721, ERC7303 {
constructor() ERC721("MyToken", "MTK") {
// Specifies the deployed contractId of ERC721 control token.
_grantRoleByERC721Token(MINTER_ROLE, 0x...);
_grantRoleByERC721Token(BURNER_ROLE, 0x...);
_grantRoleByERC721(MINTER_ROLE, 0x...);
_grantRoleByERC721(BURNER_ROLE, 0x...);
// Specifies the deployed contractId and typeId of ERC1155 control token.
_grantRoleByERC1155Token(MINTER_ROLE, 0x..., ...);
_grantRoleByERC1155Token(BURNER_ROLE, 0x..., ...);
_grantRoleByERC1155(MINTER_ROLE, 0x..., ...);
_grantRoleByERC1155(BURNER_ROLE, 0x..., ...);
}
function safeMint(address to, uint256 tokenId, string memory uri)
Expand Down

0 comments on commit dc1a490

Please sign in to comment.