While I was skimming through open zeppelin's ERC721BasicToken.sol
I came across a problem.
When setting the approval of a given operator
function setApprovalForAll(address _to, bool _approved) public {
require(_to != msg.sender);
operatorApprovals[msg.sender][_to] = _approved;
emit ApprovalForAll(msg.sender, _to, _approved);
}
I've noticed that the visibility of the function is public
. Doesn't it mean that anyone can modify an operator which was previously set before?
For example, I would create a contract that can control over a deployed ERC721Token contract.
contract TokenAccessor {
ERC721Token public nft;
constructor(address _tokenAddress) public {
nft= ERC721Token(_tokenAddress);
}
}
And from the migrations script, I would pass in the address of someone's deployed ERC721 token contract.
module.exports = function (deployer) {
deployer.deploy(TokenAccessor, "0x......")
.then(() => {
This way, I think anyone can access setApprovalForAll
to change the operator?
contract TokenAccessor {
ERC721Token public nft;
constructor(address _tokenAddress) public {
nft= ERC721Token(_tokenAddress);
}
function changeOperator() public {
nft.setApprovalForAll(msg.sender, true);
}
}