-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ernesto García <[email protected]>
- Loading branch information
1 parent
d4ed5f9
commit 7526c8f
Showing
2 changed files
with
128 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,5 @@ | ||
--- | ||
'openzeppelin-solidity': minor | ||
--- | ||
|
||
`IERC6909`: Add the interface for ERC-6909. |
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,123 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {IERC165} from "../utils/introspection/IERC165.sol"; | ||
|
||
/** | ||
* @dev Required interface of an ERC-6909 compliant contract, as defined in the | ||
* https://eips.ethereum.org/EIPS/eip-6909[ERC]. | ||
*/ | ||
interface IERC6909 is IERC165 { | ||
/** | ||
* @dev Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`. | ||
* The new allowance is `amount`. | ||
*/ | ||
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount); | ||
|
||
/** | ||
* @dev Emitted when `owner` grants or revokes operator status for a `spender`. | ||
*/ | ||
event OperatorSet(address indexed owner, address indexed spender, bool approved); | ||
|
||
/** | ||
* @dev Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`. | ||
*/ | ||
event Transfer( | ||
address caller, | ||
address indexed sender, | ||
address indexed receiver, | ||
uint256 indexed id, | ||
uint256 amount | ||
); | ||
|
||
/** | ||
* @dev Returns the amount of tokens of type `id` owned by `owner`. | ||
*/ | ||
function balanceOf(address owner, uint256 id) external view returns (uint256); | ||
|
||
/** | ||
* @dev Returns the amount of tokens of type `id` that `spender` is allowed to spend on behalf of `owner`. | ||
* | ||
* NOTE: Does not include operator allowances. | ||
*/ | ||
function allowance(address owner, address spender, uint256 id) external view returns (uint256); | ||
|
||
/** | ||
* @dev Returns true if `spender` is set as an operator for `owner`. | ||
*/ | ||
function isOperator(address owner, address spender) external view returns (bool); | ||
|
||
/** | ||
* @dev Sets an approval to `spender` for `amount` tokens of type `id` from the caller's tokens. | ||
* | ||
* Must return true. | ||
*/ | ||
function approve(address spender, uint256 id, uint256 amount) external returns (bool); | ||
|
||
/** | ||
* @dev Grants or revokes unlimited transfer permission of any token id to `spender` for the caller's tokens. | ||
* | ||
* Must return true. | ||
*/ | ||
function setOperator(address spender, bool approved) external returns (bool); | ||
|
||
/** | ||
* @dev Transfers `amount` of token type `id` from the caller's account to `receiver`. | ||
* | ||
* Must return true. | ||
*/ | ||
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool); | ||
|
||
/** | ||
* @dev Transfers `amount` of token type `id` from `sender` to `receiver`. | ||
* | ||
* Must return true. | ||
*/ | ||
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool); | ||
} | ||
|
||
/** | ||
* @dev Optional extension of {IERC6909} that adds metadata functions. | ||
*/ | ||
interface IERC6909Metadata is IERC6909 { | ||
/** | ||
* @dev Returns the name of the token of type `id`. | ||
*/ | ||
function name(uint256 id) external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the ticker symbol of the token of type `id`. | ||
*/ | ||
function symbol(uint256 id) external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the number of decimals for the token of type `id`. | ||
*/ | ||
function decimals(uint256 id) external view returns (uint8); | ||
} | ||
|
||
/** | ||
* @dev Optional extension of {IERC6909} that adds content URI functions. | ||
*/ | ||
interface IERC6909ContentURI is IERC6909 { | ||
/** | ||
* @dev Returns URI for the contract. | ||
*/ | ||
function contractURI() external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the URI for the token of type `id`. | ||
*/ | ||
function tokenURI(uint256 id) external view returns (string memory); | ||
} | ||
|
||
/** | ||
* @dev Optional extension of {IERC6909} that adds a token supply function. | ||
*/ | ||
interface IERC6909TokenSupply is IERC6909 { | ||
/** | ||
* @dev Returns the total supply of the token of type `id`. | ||
*/ | ||
function totalSupply(uint256 id) external view returns (uint256); | ||
} |