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

Allow deposit by someone who is not a token owner #101

Open
bogdan opened this issue Dec 6, 2021 · 4 comments · May be fixed by #102
Open

Allow deposit by someone who is not a token owner #101

bogdan opened this issue Dec 6, 2021 · 4 comments · May be fixed by #102

Comments

@bogdan
Copy link

bogdan commented Dec 6, 2021

Motivation

In our app we want to provide people a better user experience when they deposit their tokens to polygon.
That is why we want RootChainManager#depositFor to be callable by an address that is not a token owner (like approved or approved for all).

Problem

That is not currently possible with MintableERC721Predicate (I didn't check others, but it is probably the same issue there).

Here is why:
RootChainManager always uses _msgSender as a depositor:


depositor is always passed as a first argument to ERC721#safeTransferFrom which should always be a token owner:
IMintableERC721(rootToken).safeTransferFrom(depositor, address(this), tokenId);

Solution

Use ERC721#ownerOf instead of depositor when calling ERC721#safeTransferFrom.

If that is not acceptable, can you explain a motivation of this limitation?

@itzmeanjan
Copy link
Contributor

Hello @bogdan , given that https://github.com/OpenZeppelin/openzeppelin-contracts/blob/4961a51cc736c7d4aa9bd2e11e4cbbaff73efee9/contracts/token/ERC721/ERC721.sol#L181 kind check is implemented in root contract and depositor is non-owner address but allowed to transfer on owner's behalf, does it not solve your problem ?

@bogdan
Copy link
Author

bogdan commented Dec 6, 2021

@itzmeanjan nope, here the problem is in the from argument of safeTransferFrom that in the end should be exactly equal to token owner: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/4961a51cc736c7d4aa9bd2e11e4cbbaff73efee9/contracts/token/ERC721/ERC721.sol#L332 all the time.

@itzmeanjan
Copy link
Contributor

Yes, I get it now. For ERC721 we can probably implement it.

@itzmeanjan
Copy link
Contributor

Would you be able to send one PR @bogdan ?

@bogdan bogdan linked a pull request Dec 7, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants
@bogdan @itzmeanjan and others