frangio
November 24, 2019, 3:27pm
1
Pull request https://github.com/OpenZeppelin/openzeppelin-contracts/pull/1943 needs some changes before being merged. The original author isn't replying, so if anyone would like to pick it up please do! Make sure to take the PR branch and commit on top to preserve authorship of the existing work.
OpenZeppelin:master
← NoopurShinde:master
opened 06:03AM - 11 Oct 19 UTC
* Solved issue #1727: Improve revert reason when assuming interface compliance c… ontracts.
* Fixes
* Added the below code in ERC721.sol
bytes memory payload = abi.encodeWithSignature(
"onERC721Received(address,address,uint256,bytes)",
msg.sender,
from,
tokenId,
_data
);
(bool success, bytes memory returndata) = to.call(payload);
if (!success) {
if(returndata.length > 0){
revert(string (returndata));
}
else
revert("ERC721: to address does not implement ERC721Received interface");
} else {
return true;
}
* Added 2 dummy contracts in **/contracts/mocks**; one which does not implement ERC721Received and one which implements it but reverts as the contract rejects the transaction.
* Updated the test cases in ERC721.behavior.js to test the code added in ERC721.sol
Also take a look at the original issue for context!
opened 02:23PM - 24 Apr 19 UTC
closed 07:33PM - 23 Jan 20 UTC
good first issue
contracts
As discussed in [this review comment](https://github.com/OpenZeppelin/openzeppel… in-solidity/pull/1704#discussion_r277462537), it'd be interesting to wrap calls to unknown contracts for which an interface is assumed in a low-level call that returns a custom revert reason on error, to better describe what went wrong.
1 Like