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

Fix casting to bytes1 in ERC721ReceiverMock for solc v0.8.4 #366

Merged
merged 4 commits into from
Jul 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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