-
Notifications
You must be signed in to change notification settings - Fork 354
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 ERC2981 component #1043
Conversation
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.
Thanks again for taking the time @ptisserand. Left some comments. The main suggestion is to be as consistent as possible with the implementation we have in Solidity.
src/token.cairo
Outdated
@@ -1,3 +1,4 @@ | |||
pub mod erc1155; | |||
pub mod erc20; | |||
pub mod erc2981; |
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.
Since this is not a different token but an extension to both ERC721 and ERC1155, it makes sense for it to be placed under a common module instead.
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.
I have moved the implementation to src/token/common/erc2981
src/token/erc2981.cairo
Outdated
pub use erc2981::ERC2981Component; | ||
pub use fees::FeesImpl; | ||
pub use fees::FeesRatio; | ||
pub use fees::FeesRatioDefault; | ||
pub use interface::IERC2981Dispatcher; | ||
pub use interface::IERC2981DispatcherTrait; | ||
pub use interface::IERC2981SetupDispatcher; | ||
pub use interface::IERC2981SetupDispatcherTrait; |
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.
These imports can be consolidated into three lines.
src/token/erc2981/erc2981.cairo
Outdated
@@ -0,0 +1,176 @@ | |||
// SPDX-License-Identifier: MIT |
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.
While the idea is good, we try to be as consistent as possible with modules that we have already implemented in Solidity, and we have an implementation here.
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.
Do you mean that I should removed my FeesRatio
structure and use _feeDenominator
in storage as in solidity contract ?
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.
The solidity implementation doesn't have _feeDenominator
in storage, but as part of the bytecode as a function. I mean to be as consistent as possible, only diverging when the benefit is obvious or there is a feature inconsistency.
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.
Thanks for your explanation, I have updated source code to be more consistent with solidity implementation.
src/token/erc2981/interface.cairo
Outdated
|
||
|
||
#[starknet::interface] | ||
pub trait IERC2981Setup<TState> { |
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.
This should be provided as internal functions, but since this interface is not part of the standard, we shouldn't provide an external implementation.
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.
I have removed this trait and added internal functions matching the ones in Solidity implementation
0cb7fc4
to
b9c8c9c
Compare
branch rebased on main |
Hi @ericnordelo , are you agree that ERC2981 API documentation should be in |
|
||
fn RECEIVER() -> ContractAddress { | ||
contract_address_const::<'RECEIVER'>() | ||
} |
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.
The constants module already declares similar constants, you can employ them instead
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.
Hey @ptisserand, the PR is looking good and we have left a few comments. We have two big migrations ongoing (as you can see here), and that's why this won't make it into the next release, since those should be merged into it first. With this said, we will prioritize it and get it merged right after that release, and it will be included in the next one as the main priority.
.default_royalty_info | ||
.write(RoyaltyInfo { receiver, royalty_fraction: fee_numerator }) | ||
} | ||
|
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.
This implementation lacks _deleteDefaultRoyalty
function, which is present in the Solidity implementation. Imo, it makes sense to add it for consistency
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.
Could you please confirm if the following behavior is expected after _deleteDefaultRoyalty
is called ?:
- Default Royalty is 0% and receiver address is address(0)
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.
Yes, it is the expected one
Thanks @ptisserand. Closing this in favor of #1091. |
Fixes #1041
This PR add
ERC2981
component.ERC2981 component implements the
ERC2981
standard interface:The following internal functions are implemented:
PR Checklist