-
Notifications
You must be signed in to change notification settings - Fork 82
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
feat: add eip-2981 extension (wip) #31
Draft
vasa-develop
wants to merge
1
commit into
sudoswap:main
Choose a base branch
from
vasa-develop:royalty-support
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.
+124
−17
Draft
Changes from all commits
Commits
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 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,8 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.0; | ||
|
||
import {LSSVMRouter} from "./LSSVMRouter.sol"; | ||
|
||
contract LSSVMRouterWithRoyalty is LSSVMRouter, EIP2981Extension { | ||
// TODO: Add EIP2981 complaint versions of all sudoswap swap functions. | ||
} |
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,49 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.0; | ||
|
||
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
|
||
/// | ||
/// @dev Interface for the NFT Royalty Standard | ||
/// | ||
interface IERC2981 is IERC165 { | ||
/// ERC165 bytes to add to interface array - set in parent contract | ||
/// implementing this standard | ||
/// | ||
/// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a | ||
/// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; | ||
/// _registerInterface(_INTERFACE_ID_ERC2981); | ||
|
||
/// @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 _salePrice - 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 _salePrice | ||
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) | ||
external | ||
view | ||
returns (address receiver, uint256 royaltyAmount); | ||
} | ||
|
||
contract EIP2981Extension { | ||
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; | ||
|
||
function _checkRoyalties(address _contract) internal view returns (bool) { | ||
bool success = IERC165(_contract).supportsInterface( | ||
_INTERFACE_ID_ERC2981 | ||
); | ||
return success; | ||
} | ||
|
||
function _getRoyaltyInfo( | ||
IERC2981 _token, | ||
uint256 _tokenId, | ||
uint256 _salePrice | ||
) internal view returns (address _royaltyReceiver, uint256 _royaltyAmount) { | ||
(_royaltyReceiver, _royaltyAmount) = IERC2981(_token).royaltyInfo( | ||
_tokenId, | ||
_salePrice | ||
); | ||
} | ||
} |
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.
missing 'r' on _ position: RobustPairNFTsFo_TokenAndTokenforNFTsTrade
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.
no point in changing it now, will make all contracts interacting with previous versions incompatible.