forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an interface folder that lists common interfaces (OpenZeppelin#2517)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
- Loading branch information
Showing
30 changed files
with
507 additions
and
113 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @dev External interface of AccessControl declared to support ERC165 detection. | ||
*/ | ||
interface IAccessControl { | ||
/** | ||
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` | ||
* | ||
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite | ||
* {RoleAdminChanged} not being emitted signaling this. | ||
* | ||
* _Available since v3.1._ | ||
*/ | ||
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); | ||
|
||
/** | ||
* @dev Emitted when `account` is granted `role`. | ||
* | ||
* `sender` is the account that originated the contract call, an admin role | ||
* bearer except when using {AccessControl-_setupRole}. | ||
*/ | ||
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); | ||
|
||
/** | ||
* @dev Emitted when `account` is revoked `role`. | ||
* | ||
* `sender` is the account that originated the contract call: | ||
* - if using `revokeRole`, it is the admin role bearer | ||
* - if using `renounceRole`, it is the role bearer (i.e. `account`) | ||
*/ | ||
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); | ||
|
||
/** | ||
* @dev Returns `true` if `account` has been granted `role`. | ||
*/ | ||
function hasRole(bytes32 role, address account) external view returns (bool); | ||
|
||
/** | ||
* @dev Returns the admin role that controls `role`. See {grantRole} and | ||
* {revokeRole}. | ||
* | ||
* To change a role's admin, use {AccessControl-_setRoleAdmin}. | ||
*/ | ||
function getRoleAdmin(bytes32 role) external view returns (bytes32); | ||
|
||
/** | ||
* @dev Grants `role` to `account`. | ||
* | ||
* If `account` had not been already granted `role`, emits a {RoleGranted} | ||
* event. | ||
* | ||
* Requirements: | ||
* | ||
* - the caller must have ``role``'s admin role. | ||
*/ | ||
function grantRole(bytes32 role, address account) external; | ||
|
||
/** | ||
* @dev Revokes `role` from `account`. | ||
* | ||
* If `account` had been granted `role`, emits a {RoleRevoked} event. | ||
* | ||
* Requirements: | ||
* | ||
* - the caller must have ``role``'s admin role. | ||
*/ | ||
function revokeRole(bytes32 role, address account) external; | ||
|
||
/** | ||
* @dev Revokes `role` from the calling account. | ||
* | ||
* Roles are often managed via {grantRole} and {revokeRole}: this function's | ||
* purpose is to provide a mechanism for accounts to lose their privileges | ||
* if they are compromised (such as when a trusted device is misplaced). | ||
* | ||
* If the calling account had been granted `role`, emits a {RoleRevoked} | ||
* event. | ||
* | ||
* Requirements: | ||
* | ||
* - the caller must be `account`. | ||
*/ | ||
function renounceRole(bytes32 role, address account) external; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "./IAccessControl.sol"; | ||
|
||
/** | ||
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection. | ||
*/ | ||
interface IAccessControlEnumerable is IAccessControl { | ||
/** | ||
* @dev Returns one of the accounts that have `role`. `index` must be a | ||
* value between 0 and {getRoleMemberCount}, non-inclusive. | ||
* | ||
* Role bearers are not sorted in any particular way, and their ordering may | ||
* change at any point. | ||
* | ||
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure | ||
* you perform all queries on the same block. See the following | ||
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] | ||
* for more information. | ||
*/ | ||
function getRoleMember(bytes32 role, uint256 index) external view returns (address); | ||
|
||
/** | ||
* @dev Returns the number of accounts that have `role`. Can be used | ||
* together with {getRoleMember} to enumerate all bearers of a role. | ||
*/ | ||
function getRoleMemberCount(bytes32 role) external view returns (uint256); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../token/ERC1155/IERC1155.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../token/ERC1155/extensions/IERC1155MetadataURI.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../token/ERC1155/IERC1155Receiver.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "./IERC20.sol"; | ||
import "./IERC165.sol"; | ||
|
||
interface IERC1363 is IERC165, IERC20 { | ||
/* | ||
* Note: the ERC-165 identifier for this interface is 0x4bbee2df. | ||
* 0x4bbee2df === | ||
* bytes4(keccak256('transferAndCall(address,uint256)')) ^ | ||
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ | ||
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ | ||
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) | ||
*/ | ||
|
||
/* | ||
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce. | ||
* 0xfb9ec8ce === | ||
* bytes4(keccak256('approveAndCall(address,uint256)')) ^ | ||
* bytes4(keccak256('approveAndCall(address,uint256,bytes)')) | ||
*/ | ||
|
||
/** | ||
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver | ||
* @param to address The address which you want to transfer to | ||
* @param value uint256 The amount of tokens to be transferred | ||
* @return true unless throwing | ||
*/ | ||
function transferAndCall(address to, uint256 value) external returns (bool); | ||
|
||
/** | ||
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver | ||
* @param to address The address which you want to transfer to | ||
* @param value uint256 The amount of tokens to be transferred | ||
* @param data bytes Additional data with no specified format, sent in call to `to` | ||
* @return true unless throwing | ||
*/ | ||
function transferAndCall( | ||
address to, | ||
uint256 value, | ||
bytes memory data | ||
) external returns (bool); | ||
|
||
/** | ||
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver | ||
* @param from address The address which you want to send tokens from | ||
* @param to address The address which you want to transfer to | ||
* @param value uint256 The amount of tokens to be transferred | ||
* @return true unless throwing | ||
*/ | ||
function transferFromAndCall( | ||
address from, | ||
address to, | ||
uint256 value | ||
) external returns (bool); | ||
|
||
/** | ||
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver | ||
* @param from address The address which you want to send tokens from | ||
* @param to address The address which you want to transfer to | ||
* @param value uint256 The amount of tokens to be transferred | ||
* @param data bytes Additional data with no specified format, sent in call to `to` | ||
* @return true unless throwing | ||
*/ | ||
function transferFromAndCall( | ||
address from, | ||
address to, | ||
uint256 value, | ||
bytes memory data | ||
) external returns (bool); | ||
|
||
/** | ||
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender | ||
* and then call `onApprovalReceived` on spender. | ||
* @param spender address The address which will spend the funds | ||
* @param value uint256 The amount of tokens to be spent | ||
*/ | ||
function approveAndCall(address spender, uint256 value) external returns (bool); | ||
|
||
/** | ||
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender | ||
* and then call `onApprovalReceived` on spender. | ||
* @param spender address The address which will spend the funds | ||
* @param value uint256 The amount of tokens to be spent | ||
* @param data bytes Additional data with no specified format, sent in call to `spender` | ||
*/ | ||
function approveAndCall( | ||
address spender, | ||
uint256 value, | ||
bytes memory data | ||
) external returns (bool); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
interface IERC1363Receiver { | ||
/* | ||
* Note: the ERC-165 identifier for this interface is 0x88a7ca5c. | ||
* 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")) | ||
*/ | ||
|
||
/** | ||
* @notice Handle the receipt of ERC1363 tokens | ||
* @dev Any ERC1363 smart contract calls this function on the recipient | ||
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the | ||
* transfer. Return of other than the magic value MUST result in the | ||
* transaction being reverted. | ||
* Note: the token contract address is always the message sender. | ||
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function | ||
* @param from address The address which are token transferred from | ||
* @param value uint256 The amount of tokens transferred | ||
* @param data bytes Additional data with no specified format | ||
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` | ||
* unless throwing | ||
*/ | ||
function onTransferReceived( | ||
address operator, | ||
address from, | ||
uint256 value, | ||
bytes memory data | ||
) external returns (bytes4); | ||
} |
Oops, something went wrong.