-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c64eef1
commit d76f4f6
Showing
4 changed files
with
311 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
interface IERC1820Registry { | ||
/** | ||
* @dev Sets `newManager` as the manager for `account`. A manager of an | ||
* account is able to set interface implementers for it. | ||
* | ||
* By default, each account is its own manager. Passing a value of `0x0` in | ||
* `newManager` will reset the manager to this initial state. | ||
* | ||
* Emits a `ManagerChanged` event. | ||
* | ||
* Requirements: | ||
* | ||
* - the caller must be the current manager for `account`. | ||
*/ | ||
function setManager(address account, address newManager) external; | ||
|
||
/** | ||
* @dev Returns the manager for `account`. | ||
* | ||
* See `setManager`. | ||
*/ | ||
function getManager(address account) external view returns (address); | ||
|
||
/** | ||
* @dev Sets the `implementer` contract as `account`'s implementer for | ||
* `interfaceHash`. | ||
* | ||
* `account` being the zero address is an alias for the caller's address. | ||
* The zero address can also be used in `implementer` to remove an old one. | ||
* | ||
* See `interfaceHash` to learn how these are created. | ||
* | ||
* Emits an `InterfaceImplementerSet` event. | ||
* | ||
* Requirements: | ||
* | ||
* - the caller must be the current manager for `account`. | ||
* - `interfaceHash` must not be an `IERC165` interface id (i.e. it must not | ||
* end in 28 zeroes). | ||
* - `implementer` must implement `IERC1820Implementer` and return true when | ||
* queried for support, unless `implementer` is the caller. See | ||
* `IERC1820Implementer.canImplementInterfaceForAddress`. | ||
*/ | ||
function setInterfaceImplementer(address account, bytes32 interfaceHash, address implementer) external; | ||
|
||
/** | ||
* @dev Returns the implementer of `interfaceHash` for `account`. If no such | ||
* implementer is registered, returns the zero address. | ||
* | ||
* If `interfaceHash` is an `IERC165` interface id (i.e. it ends with 28 | ||
* zeroes), `account` will be queried for support of it. | ||
* | ||
* `account` being the zero address is an alias for the caller's address. | ||
*/ | ||
function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address); | ||
|
||
/** | ||
* @dev Returns the interface hash for an `interfaceName`, as defined in the | ||
* corresponding | ||
* [section of the EIP](https://eips.ethereum.org/EIPS/eip-1820#interface-name). | ||
*/ | ||
function interfaceHash(string calldata interfaceName) external pure returns (bytes32); | ||
|
||
/** | ||
* @notice Updates the cache with whether the contract implements an ERC165 interface or not. | ||
* @param account Address of the contract for which to update the cache. | ||
* @param interfaceId ERC165 interface for which to update the cache. | ||
*/ | ||
function updateERC165Cache(address account, bytes4 interfaceId) external; | ||
|
||
/** | ||
* @notice Checks whether a contract implements an ERC165 interface or not. | ||
* If the result is not cached a direct lookup on the contract address is performed. | ||
* If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling | ||
* 'updateERC165Cache' with the contract address. | ||
* @param account Address of the contract to check. | ||
* @param interfaceId ERC165 interface to check. | ||
* @return True if `account.address()` implements `interfaceId`, false otherwise. | ||
*/ | ||
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); | ||
|
||
/** | ||
* @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. | ||
* @param account Address of the contract to check. | ||
* @param interfaceId ERC165 interface to check. | ||
* @return True if `account.address()` implements `interfaceId`, false otherwise. | ||
*/ | ||
function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); | ||
|
||
event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); | ||
|
||
event ManagerChanged(address indexed account, address indexed newManager); | ||
} |
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,172 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
interface IERC777 { | ||
/** | ||
* @dev Returns the name of the token. | ||
*/ | ||
function name() external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the symbol of the token, usually a shorter version of the | ||
* name. | ||
*/ | ||
function symbol() external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the smallest part of the token that is not divisible. This | ||
* means all token operations (creation, movement and destruction) must have | ||
* amounts that are a multiple of this number. | ||
* | ||
* For most token contracts, this value will equal 1. | ||
*/ | ||
function granularity() external view returns (uint256); | ||
|
||
/** | ||
* @dev Returns the amount of tokens in existence. | ||
*/ | ||
function totalSupply() external view returns (uint256); | ||
|
||
/** | ||
* @dev Returns the amount of tokens owned by an account (`owner`). | ||
*/ | ||
function balanceOf(address owner) external view returns (uint256); | ||
|
||
/** | ||
* @dev Moves `amount` tokens from the caller's account to `recipient`. | ||
* | ||
* If send or receive hooks are registered for the caller and `recipient`, | ||
* the corresponding functions will be called with `data` and empty | ||
* `operatorData`. See `IERC777Sender` and `IERC777Recipient`. | ||
* | ||
* Emits a `Sent` event. | ||
* | ||
* Requirements | ||
* | ||
* - the caller must have at least `amount` tokens. | ||
* - `recipient` cannot be the zero address. | ||
* - if `recipient` is a contract, it must implement the `tokensReceived` | ||
* interface. | ||
*/ | ||
function send(address recipient, uint256 amount, bytes calldata data) external; | ||
|
||
/** | ||
* @dev Destroys `amount` tokens from the caller's account, reducing the | ||
* total supply. | ||
* | ||
* If a send hook is registered for the caller, the corresponding function | ||
* will be called with `data` and empty `operatorData`. See `IERC777Sender`. | ||
* | ||
* Emits a `Burned` event. | ||
* | ||
* Requirements | ||
* | ||
* - the caller must have at least `amount` tokens. | ||
*/ | ||
function burn(uint256 amount, bytes calldata data) external; | ||
|
||
/** | ||
* @dev Returns true if an account is an operator of `tokenHolder`. | ||
* Operators can send and burn tokens on behalf of their owners. All | ||
* accounts are their own operator. | ||
* | ||
* See `operatorSend` and `operatorBurn`. | ||
*/ | ||
function isOperatorFor(address operator, address tokenHolder) external view returns (bool); | ||
|
||
/** | ||
* @dev Make an account an operator of the caller. | ||
* | ||
* See `isOperatorFor`. | ||
* | ||
* Emits an `AuthorizedOperator` event. | ||
* | ||
* Requirements | ||
* | ||
* - `operator` cannot be calling address. | ||
*/ | ||
function authorizeOperator(address operator) external; | ||
|
||
/** | ||
* @dev Make an account an operator of the caller. | ||
* | ||
* See `isOperatorFor` and `_defaultOperators`. | ||
* | ||
* Emits a `RevokedOperator` event. | ||
* | ||
* Requirements | ||
* | ||
* - `operator` cannot be calling address. | ||
*/ | ||
function revokeOperator(address operator) external; | ||
|
||
/** | ||
* @dev Returns the list of default operators. These accounts are operators | ||
* for all token holders, even if `authorizeOperator` was never called on | ||
* them. | ||
* | ||
* This list is immutable, but individual holders may revoke these via | ||
* `revokeOperator`, in which case `isOperatorFor` will return false. | ||
*/ | ||
function _defaultOperators() external view returns (address[] memory); | ||
|
||
/** | ||
* @dev Moves `amount` tokens from `sender` to `recipient`. The caller must | ||
* be an operator of `sender`. | ||
* | ||
* If send or receive hooks are registered for `sender` and `recipient`, | ||
* the corresponding functions will be called with `data` and | ||
* `operatorData`. See `IERC777Sender` and `IERC777Recipient`. | ||
* | ||
* Emits a `Sent` event. | ||
* | ||
* Requirements | ||
* | ||
* - `sender` cannot be the zero address. | ||
* - `sender` must have at least `amount` tokens. | ||
* - the caller must be an operator for `sender`. | ||
* - `recipient` cannot be the zero address. | ||
* - if `recipient` is a contract, it must implement the `tokensReceived` | ||
* interface. | ||
*/ | ||
function operatorSend( | ||
address sender, | ||
address recipient, | ||
uint256 amount, | ||
bytes calldata data, | ||
bytes calldata operatorData | ||
) external; | ||
|
||
/** | ||
* @dev Destoys `amount` tokens from `account`, reducing the total supply. | ||
* The caller must be an operator of `account`. | ||
* | ||
* If a send hook is registered for `account`, the corresponding function | ||
* will be called with `data` and `operatorData`. See `IERC777Sender`. | ||
* | ||
* Emits a `Burned` event. | ||
* | ||
* Requirements | ||
* | ||
* - `account` cannot be the zero address. | ||
* - `account` must have at least `amount` tokens. | ||
* - the caller must be an operator for `account`. | ||
*/ | ||
function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external; | ||
|
||
event Sent( | ||
address indexed operator, | ||
address indexed from, | ||
address indexed to, | ||
uint256 amount, | ||
bytes data, | ||
bytes operatorData | ||
); | ||
|
||
event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData); | ||
|
||
event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData); | ||
|
||
event AuthorizedOperator(address indexed operator, address indexed tokenHolder); | ||
|
||
event RevokedOperator(address indexed operator, address indexed tokenHolder); | ||
} |
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,22 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
interface IERC777Recipient { | ||
/** | ||
* @dev Called by an `IERC777` token contract whenever tokens are being | ||
* moved or created into a registered account (`to`). The type of operation | ||
* is conveyed by `from` being the zero address or not. | ||
* | ||
* This call occurs _after_ the token contract's state is updated, so | ||
* `IERC777.balanceOf`, etc., can be used to query the post-operation state. | ||
* | ||
* This function may revert to prevent the operation from being executed. | ||
*/ | ||
function tokensReceived( | ||
address operator, | ||
address from, | ||
address to, | ||
uint256 amount, | ||
bytes calldata userData, | ||
bytes calldata operatorData | ||
) 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,22 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
interface IERC777Sender { | ||
/** | ||
* @dev Called by an `IERC777` token contract whenever a registered holder's | ||
* (`from`) tokens are about to be moved or destroyed. The type of operation | ||
* is conveyed by `to` being the zero address or not. | ||
* | ||
* This call occurs _before_ the token contract's state is updated, so | ||
* `IERC777.balanceOf`, etc., can be used to query the pre-operation state. | ||
* | ||
* This function may revert to prevent the operation from being executed. | ||
*/ | ||
function tokensToSend( | ||
address operator, | ||
address from, | ||
address to, | ||
uint256 amount, | ||
bytes calldata userData, | ||
bytes calldata operatorData | ||
) external; | ||
} |