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

[CodeArena] - [G-11] : Change mint to external #76

Closed
wants to merge 1 commit into from

Conversation

maximebrugel
Copy link
Contributor

@maximebrugel maximebrugel commented Dec 20, 2021

Issue => code-423n4/2021-11-nested-findings#29

Note from the issue :

Note :
createRecord has been removed.
setRoyaltiesWeight & setShareholders can't be external since they're called from the constructor.
The resolution will be focus on the mint function.

@maximebrugel maximebrugel added the To review Let people know this PR is ready for a review label Dec 20, 2021
originalAsset[tokenId] = originalTokenId != 0 ? originalTokenId : _replicatedTokenId;

return tokenId;
function mint(address _owner, uint256 _replicatedTokenId) external onlyFactory returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Do we really save gas by calling an external function that calls another function and passes parameters, instead of a public function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling a public function costs more gas, however we're not saving gas in this case. It's just "cleaner", so I was also wondering if we should close this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why it is cleaner but here I'd advocate for the most efficient solution

/// @param _owner The account address that signed the transaction
/// @param _replicatedTokenId The token id of the replicated asset, 0 if no replication
/// @return The minted token's id
function _mintFromReplicated(address _owner, uint256 _replicatedTokenId) internal returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the function is inaccurate as it can be called with _replicatedTokenId being 0, when it is not a copy.

Suggested change
function _mintFromReplicated(address _owner, uint256 _replicatedTokenId) internal returns (uint256) {
function _mint(address _owner, uint256 _replicatedTokenId) internal returns (uint256) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed a name different from _mint (already exists). Even if the parameter can be 0, the parameter is _replicatedTokenId .

Other possibilities :

  • _mintWithReplication
  • _mintAndHandleReplication

@adrien-supizet adrien-supizet removed the To review Let people know this PR is ready for a review label Dec 20, 2021
@maximebrugel maximebrugel added the Draft Do not merge label Dec 21, 2021
@maximebrugel
Copy link
Contributor Author

@adrien-supizet Change this PR as "draft", we should discuss about it (pro and cons).

@maximebrugel
Copy link
Contributor Author

After discussing, we prefer the most efficient solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Draft Do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants