Given the following function:
function checkLock() external view returns (bool) {
require(
address(this) == IERC721(_nftRegistryAddress).ownerOf(_tokenId),
"[checkLock] Contract is not owner of tokenId"
);
return true;
}
The correct state is false
- the contract does not own the NFT.
If I call this function with Metamask's web3, i.e. 0.20.7, it correctly returns false
.
If I call this function with web3 1.2.6, it incorrectly returns true
!
I'm aware that relying on a require to return state is nonstandard, but would be interested in understanding the discrepancy.
I'm aware that relying on a require to return state is nonstandard
- it's not returning anything. The line below it returnstrue
. And BTW, you may as well get rid of that line (as well as thereturns (bool)
in the function declaration), because it's never going to return anything else. Either the function-call completes successfully, or it reverts (so you can simply rely on that in order to determine the status).If I call this function with Metamask's web3, i.e. 0.2.7, it correctly returns false
- this function does not return anything other than true!If I call this function with web3 1.2.6
- how do you call this function?.call()
for both versions.