Skip to content

Commit

Permalink
Fix casting to bytes1 in ERC721ReceiverMock for solc v0.8.4 (#366)
Browse files Browse the repository at this point in the history
* Fix casting to bytes1 in v0.8.4

* Set back solc to v0.8.11

* Fix comments

* Change to normal Solidity cast
  • Loading branch information
Vectorized authored Jul 13, 2022
1 parent 8f46446 commit d2c2f48
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions contracts/mocks/ERC721ReceiverMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@ contract ERC721ReceiverMock is ERC721A__IERC721Receiver {
uint256 tokenId,
bytes memory data
) public override returns (bytes4) {
// for testing reverts with a message from the receiver contract
if (bytes1(data) == 0x01) {
uint256 dataValue = data.length == 0 ? 0 : uint256(uint8(data[0]));

// For testing reverts with a message from the receiver contract.
if (dataValue == 0x01) {
revert('reverted in the receiver contract!');
}

// for testing with the returned wrong value from the receiver contract
if (bytes1(data) == 0x02) {
// For testing with the returned wrong value from the receiver contract.
if (dataValue == 0x02) {
return 0x0;
}

// for testing the reentrancy protection
if (bytes1(data) == 0x03) {
// For testing the reentrancy protection.
if (dataValue == 0x03) {
IERC721AMock(_erc721aMock).safeMint(address(this), 1);
}

Expand Down

0 comments on commit d2c2f48

Please sign in to comment.