unlock icon indicating copy to clipboard operation
unlock copied to clipboard

feat(smart-contracts): lower contract size for PublicLock v15

Open clemsos opened this issue 1 year ago • 1 comments

Description

This removes some code from PublicLock template so more features can be added without hitting the EVM contract size limit

Size: before : 23.956 / after: 22.636

Make some function private (avoid storing/copying full signature)

  • schemaVersion (-0.032)
  • set updateSchemaVersion internal (?)

Functions removed

  • addLockManager (duplicate of hasRole(LOCK_MANAGER_ROLE, address)) and renounceLockManager (duplicate of renounceRole(LOCK_MANAGER_ROLE)) (-0.220)
  • remove isApprovedForAll and setApprovalForAll(-0.477)
  • refactor hooks addresses getters into a single hooks getter (-0.061)

Other cleanup

  • remove previous migration code (-0.188)
  • refactor hooks addresses checks (-0.349)

NOT doing:

  • ~~group fees into a single getter and a single setter (gas refund, transfer fee, cancel fee)~~ (+0.063)
  • ~~refactor hooks addresses getters into a single hooks getter~~ (-0.061)

Potential candidates for deletion

  • function where feature can be recreated with workarounds : burn
  • 'nice to have' / sad to delete functions : lendKey / unlendKey, mergeKeys

Issues

Fixes # Refs #

Checklist:

  • [ ] 1 PR, 1 purpose: my Pull Request applies to a single purpose
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have updated the docs to reflect my changes if applicable
  • [ ] I have added tests (and stories for frontend components) that prove my fix is effective or that my feature works
  • [ ] I have performed a self-review of my own code
  • [ ] If my code involves visual changes, I am adding applicable screenshots to this thread

Release Note Draft Snippet

clemsos avatar Oct 16 '24 10:10 clemsos

contract size audit here https://observablehq.com/d/fcfc7fa77ef2dd13

clemsos avatar Oct 17 '24 12:10 clemsos