ProjectOpenSea / operator-filter-registry

MIT License
312 stars 89 forks source link

Reorganize OperatorFilter modifiers to be easier to override #49

Closed dievardump closed 1 year ago

dievardump commented 1 year ago

As explained in #47, checking the codesize of an external address is way more expensive than doing the simple from != msg.sender check and it feels more natural (and gas effective) to first check that before going into the filtering shenanigans: there is no reason to deploy contracts using the OperatorFilter on networks where it's not, so the check "from != msg.sender" should normally always be performed, so better do it before checking any external stuff.

When the check is then put first, it appears that the code used to check if an operator is allowed can be put in its own internal function, making the code more DRY but also easier to override when we want to add things like switches

It adds a small gas overhead of 150gas, but we can sure all agree that this OperatorFilterRegistry is already introducing so much gas overhead that 150 gas in order to have a cleaner and more usable code is nothing.

operatorfilterer commented 1 year ago

Another great QOL improvement, thank you!