Skip to content
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

Feature Request: Add block list using mapping for efficiency #417

Open
maximonee opened this issue Aug 26, 2022 · 1 comment
Open

Feature Request: Add block list using mapping for efficiency #417

maximonee opened this issue Aug 26, 2022 · 1 comment

Comments

@maximonee
Copy link

Hi team,

I recently stumbled across a great feature request to add a block list to combat marketplaces not respecting royalties. I think the proposal was good, but it was unfortunately not very performant because the creator could have used a mapping instead as it is more efficient. I’ve rewritten the proposal using a more efficient mapping instead.

mapping (uint128 => address[]) public blockedAddrs;
uint256 numberOfBlockedAddressesBecauseOfCreatorRoyaltiesDisrespectingCreators = 0;

function populateBlockedAddrs(Address addr) public onlyOwner{
    blockedAddrs[numberOfBlockedAddressesBecauseOfCreatorRoyaltiesDisrespectingCreators] = addr;
    numberOfBlockedAddressesBecauseOfCreatorRoyaltiesDisrespectingCreators++;
}

function _beforeTokenTransfer(
    address from,
    address to,
    uint256 tokenId
) internal virtual override(ERC721, ERC721Enumerable) {

    uint256 i = 0;
    while(i < numberOfBlockedAddressesBecauseOfCreatorRoyaltiesDisrespectingCreators) {
        for (uint256 j = 0; j < blockedAddrs[i].length; j++) {
        
            require(msg.sender != blockedAddrs[i][j], "Thanks for the consideration");
            j = j + 1;
        }
        unchecked {
            i++;
        }
    }
    super._beforeTokenTransfer(from, to, tokenId);
}
@Vectorized
Copy link
Collaborator

Thank you for the request.

After much discussion, we have decided it is unsuitable for inclusion, citing reasons highlighted in #416.

However, due to the supposedly greatly improved efficiency of this implementation, we may leave this request open for a while as a reference for any devs aspiring to build a similar feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants