Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Add failing test for owner exclusion #4

Merged
merged 4 commits into from Nov 8, 2022

Conversation

cxkoda
Copy link
Contributor

@cxkoda cxkoda commented Nov 7, 2022

This adds a failing test to demonstrate that token owners can be blocked by the proposed operator filter implementation.

@cxkoda cxkoda mentioned this pull request Nov 7, 2022
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from == msg.sender) {
if (balanceOf(msg.sender, id) > 0) {
Copy link

Choose a reason for hiding this comment

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

Curious, won't standard methods perform this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I've just seen that you left a similar comment. Wondering about the same thing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@operatorfilterer operatorfilterer merged commit 11c5c87 into ProjectOpenSea:main Nov 8, 2022
Comment on lines +36 to +39
if (balanceOf(msg.sender) > 0) {
_;
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is a non-zero token balance relevant? Shouldn't this be checked by the modifier receiving function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is to skip the external call overhead to the registry and associated SLOADs there; overhead should be minimal in normal cases as the storage slot will then become warm for the balance check in the transfer method. Can add a comment about that or remove if you think the approach is problematic.

Edit: Actually, since the tx will fail anyway, this isn't necessary. Thanks!

Copy link

@0xGh 0xGh Nov 8, 2022

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No just trying to understand what this is for.
If the modifier was to be applied to a transferFrom, it would revert anyways if the caller is not the owner or approved, right?

This is to skip the external call overhead to the registry and associated SLOADs there

Why would this need to call the registry?

Copy link

Choose a reason for hiding this comment

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

Exactly. My question was for @operatorfilterer and if the answer would have been positive I would have followed up with: #4 (review)

@@ -26,13 +26,29 @@ contract OperatorFilterer {
}
}

modifier onlyAllowedOperator() virtual {
modifier onlyAllowedOperator(address from) virtual {
// Check registry code length to facilitate testing in environments without a deployed registry.
if (address(operatorFilterRegistry).code.length > 0) {
Copy link

Choose a reason for hiding this comment

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

this could be

if (from != msg.sender && address(operatorFilterRegistry).code.length > 0) {

emo-eth added a commit that referenced this pull request Jan 20, 2023
OpenZeppelin M-01: Incomplete test coverage
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants