-
Notifications
You must be signed in to change notification settings - Fork 842
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 _mint(to, quantity) function #235
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.
Wow, this makes my life a lot easier.
I was frustrated doing _mint(addr, quantity, '', false)
instead of a simple _mint(addr, quantity)
throughout my contract.
Apart from being more user-friendly, it's more optimized too (if an implemented contract doesn't use both _mint and _safeMint).
The downside, lower maintainability, is totally worth it. "pretends to be a maintainer"
/** | ||
* @dev Equivalent to _mint(to, quantity, '', false). | ||
*/ | ||
function _mint(address to, uint256 quantity) internal { |
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.
Should we just rename the existing mint function to _safeMint and remove the safe
parameter? This will be backwards incompatible, but will make the code cleaner since I don't see ppl calling _mint(to, qty,'', false)
going forward
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.
Agree to remove the safe
parameter and rename _safeMint
.
For backward compatibility, we could add back _mint(to, qty, data, safe)
and then call _mint
and _safeMint
based on the safe
parameter, but it cost maintainability.
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’m just worried about the customers calling the ERC721A helpdesk if we break backwards compatibility. Lemme think for a while.
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.
Well we've broken it a couple times already. I'm ok cutting a v4 of ERC721A for a change like that
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.
Outside rn, brb in a few hours probably
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.
Code is neater, about 50 gas saved. Let’s go.
Most people use
_mint(to, quantity, "", false)
when they do not need safe minting.Sadly, the compiler will still produce the bytecode needed for safe minting.
<Inserts optimizoor meme here>
This PR adds a
_mint(to, quantity)
function.It saves 100 gas per call, and 42495 gas during deployment (about 200 bytes), which is about 6% for a minimal contract.
The code is manually inlined directly. Simply calling
_mint(to, quantity, "", false)
inside actually leads to increased gas costs (50 gas function call overhead) with no reduction in bytecode size.⛽ Gas Reports
Before
After