Last active
March 4, 2023 03:46
-
-
Save ikwuoz/5edc7381d88d1c11a940e6e004d09b59 to your computer and use it in GitHub Desktop.
Interface ID calculations for EIP6160 standard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Minimal interface for role-based access control for smart contracts | |
| // -https://github.com/polytope-labs/EIPs/blob/master/EIPS/eip-5982.md | |
| interface IERC_ACL_CORE { | |
| function hasRole(bytes32 role, address account) external view returns (bool); | |
| function grantRole(bytes32 role, address account) external; | |
| function revokeRole(bytes32 role, address account) external; | |
| } | |
| // Interface for consistent mint and burning for token standards | |
| // -https://github.com/polytope-labs/EIPs/blob/master/EIPS/eip-5679.md | |
| interface IERC5679Ext20 { | |
| function mint(address _to, uint256 _amount, bytes calldata _data) external; | |
| function burn(address _from, uint256 _amount, bytes calldata _data) external; | |
| } | |
| // -https://github.com/polytope-labs/EIPs/blob/master/EIPS/eip-5679.md | |
| interface IERC5679Ext721 { | |
| function safeMint(address _to, uint256 _id, bytes calldata _data) external; | |
| function burn(address _from, uint256 _id, bytes calldata _data) external; | |
| } | |
| // -https://github.com/polytope-labs/EIPs/blob/master/EIPS/eip-5679.md | |
| interface IERC5679Ext1155 { | |
| function safeMint(address _to, uint256 _id, uint256 _amount, bytes calldata _data) external; | |
| function safeMintBatch(address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; | |
| function burn(address _from, uint256 _id, uint256 _amount, bytes[] calldata _data) external; | |
| function burnBatch(address _from, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata _data) external; | |
| } | |
| interface IERC6160Ext20 is IERC5679Ext20, IERC_ACL_CORE {} | |
| interface IERC6160Ext721 is IERC5679Ext721, IERC_ACL_CORE {} | |
| interface IERC6160Ext1155 is IERC5679Ext1155, IERC_ACL_CORE {} | |
| contract Calculate { | |
| // Calculates the EIP-165 identifer for IERC6160Ext20 | |
| // => 0xbbb8b47e | |
| function getIERC6160Ext20() external view returns(bytes4) { | |
| return type(IERC_ACL_CORE).interfaceId ^ type(IERC5679Ext20).interfaceId; | |
| } | |
| // Calculates the EIP-165 identifer for IERC6160Ext721 | |
| // => 0xa75a5a72 | |
| function getIERC6160Ext721() external view returns(bytes4) { | |
| return type(IERC_ACL_CORE).interfaceId ^ type(IERC5679Ext721).interfaceId; | |
| } | |
| // Calculates the EIP-165 identifer for IERC6160Ext1155 | |
| // => 0x9f77104c | |
| function getIERC6160Ext1155() external view returns(bytes4) { | |
| return type(IERC_ACL_CORE).interfaceId ^ type(IERC5679Ext1155).interfaceId; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment