Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for ERC6909 #5343

Merged
merged 19 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/long-walls-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`IERC6909`: Add the interface for the ERC6909.
arr00 marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions contracts/interfaces/draft-IERC6909.sol
arr00 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (interfaces/draft-IERC6909.sol)
ernestognw marked this conversation as resolved.
Show resolved Hide resolved

pragma solidity ^0.8.20;

import {IERC6909} from "../token/ERC6909/draft-IERC6909.sol";
73 changes: 73 additions & 0 deletions contracts/token/ERC6909/draft-IERC6909.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (token/ERC6909/draft-IRC6909.sol)

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 by a call to `approve` 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 isOperator);

/**
* @dev Emitted when `amount` tokens of type `id` are moved from `from` to `to` initiated by `caller`.
*/
event Transfer(address caller, address indexed from, address indexed to, 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 view 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 isOperator) external returns (bool);

/**
* @dev Transfers `amount` of token type `id` from the caller's account to `to`.
*
* Must return true.
*/
function transfer(address to, uint256 id, uint256 amount) external returns (bool);

/**
* @dev Transfers `amount` of token type `id` from `from` to `to`.
*
* Must return true.
*/
function transferFrom(address from, address to, uint256 id, uint256 amount) external returns (bool);
}
Loading