diamond-2-hardhat
diamond-2-hardhat copied to clipboard
refactor(DiamondCutFacet.sol): use diamondCut from library
Motivation
Since this repo, just like the diamond-1-hardhat and diamond-3-hardhat are for reference implementations, was thinking reusing the diamondCut from the LibDiamond in the DiamondCutFacet.sol would be helpful for new readers to understand how the cut logic differs from the other implementations (instead of duplicating the same pre logic for addReplaceRemoveFacetSelectors).
I totally understand that diamond-2-hardhat should be the most efficient in terms of diamond cutting. Even so, using the library instead uses more gas (not that significant) 😅. Is this worth doing this to help demonstrate how the cutting logic works?
- DiamondCutFacet from implementation 1
- DiamondCutFacet from implementation 2 (current)
- DiamondCutFacet from implementation 3
Gas report for the current repo test
Current:
diamondCutmethod: avg gas for 22 calls 348444DiamondCutFacetdeployment method: avg gas for 22 calls 1952190
Proposed:
diamondCutmethod: avg gas for 22 calls 349019DiamondCutFacetdeployment method: avg gas for 22 calls 1974592
You are right, it really isn't much more gas. Will consider it.