-
Notifications
You must be signed in to change notification settings - Fork 34
Feat/eip-2981 royalties #112
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
Open
carlomigueldy
wants to merge
5
commits into
Developer-DAO:main
Choose a base branch
from
carlomigueldy:feat/erc2981-royalties
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c4d5ff
Add sol files for royalties implementation
carlomigueldy 5b7f17c
Implement contract wide royalties
carlomigueldy efd5948
Set royalties to 1000 -> 10%
carlomigueldy ca885e5
Update IERC2981Royalties.sol
carlomigueldy e55183f
Update PixelAvatars.sol
carlomigueldy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // SPDX-License-Identifier: GNU General Public License v3.0 | ||
| pragma solidity ^0.8.10; | ||
|
|
||
| import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
|
|
||
| import "./IERC2981Royalties.sol"; | ||
|
|
||
| /// @dev This is a contract used to add ERC2981 support to ERC721 and 1155 | ||
| abstract contract ERC2981Base is ERC165, IERC2981Royalties { | ||
| struct RoyaltyInfo { | ||
| address recipient; | ||
| uint24 amount; | ||
| } | ||
|
|
||
| /// @inheritdoc ERC165 | ||
| function supportsInterface(bytes4 interfaceId) | ||
| public | ||
| view | ||
| virtual | ||
| override | ||
| returns (bool) | ||
| { | ||
| return | ||
| interfaceId == type(IERC2981Royalties).interfaceId || | ||
| super.supportsInterface(interfaceId); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
contract/contracts/@eip2981/ERC2981ContractWideRoyalties.sol
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // SPDX-License-Identifier: GNU General Public License v3.0 | ||
| pragma solidity ^0.8.10; | ||
|
|
||
| import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
|
|
||
| import "./ERC2981Base.sol"; | ||
|
|
||
| /// @dev This is a contract used to add ERC2981 support to ERC721 and 1155 | ||
| /// @dev This implementation has the same royalties for each and every tokens | ||
| abstract contract ERC2981ContractWideRoyalties is ERC2981Base { | ||
| RoyaltyInfo private _royalties; | ||
|
|
||
| /// @dev Sets token royalties | ||
| /// @param recipient recipient of the royalties | ||
| /// @param value percentage (using 2 decimals - 10000 = 100, 0 = 0) | ||
| function _setRoyalties(address recipient, uint256 value) internal { | ||
| require(value <= 10000, "ERC2981Royalties: Too high"); | ||
| _royalties = RoyaltyInfo(recipient, uint24(value)); | ||
| } | ||
|
|
||
| /// @inheritdoc IERC2981Royalties | ||
| function royaltyInfo(uint256, uint256 value) | ||
| external | ||
| view | ||
| override | ||
| returns (address receiver, uint256 royaltyAmount) | ||
| { | ||
| RoyaltyInfo memory royalties = _royalties; | ||
| receiver = royalties.recipient; | ||
| royaltyAmount = (value * royalties.amount) / 10000; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // SPDX-License-Identifier: GNU General Public License v3.0 | ||
| pragma solidity ^0.8.10; | ||
|
|
||
| /// @title IERC2981Royalties | ||
| /// @dev Interface for the ERC2981 - Token Royalty standard | ||
| interface IERC2981Royalties { | ||
| /// @notice Called with the sale price to determine how much royalty is owed and to whom. | ||
| /// @param _tokenId - the NFT asset queried for royalty information | ||
| /// @param _value - the sale price of the NFT asset specified by _tokenId | ||
| /// @return _receiver - address of who should be sent the royalty payment | ||
| /// @return _royaltyAmount - the royalty payment amount for value sale price | ||
| function royaltyInfo(uint256 _tokenId, uint256 _value) | ||
| external | ||
| view | ||
| returns (address _receiver, uint256 _royaltyAmount); | ||
| } |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add
/// @author Developer DAOto all files you edited?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noahliechti
For the ERC2981 was a code copied from a repo.
But what are your thinks if adding and @author tag on a code that wasn't originally created here?