Let's say I have:
//SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v4.4.1/contracts/access/AccessControlUpgradeable.sol";
contract A is AccessControlUpgradeable {
bytes32 public constant OWNER = keccak256("OWNER");
function inner() external onlyRole(OWNER) returns (uint){
return 10;
}
}
And I call inner() from contract B:
//SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract B {
function outer(address deployedA) external {
A contractToCall = A(deployedA);
(bool success, bytes memory data) = address(contractToCall).call(abi.encodeWithSelector(A(address(contractToCall)).inner.selector));
require(success, "FAILED");
}
}
If I didn't set the "OWNER" role properly, calling the function in the context of contract A throws the reason of why it failed. However, if made with the context of B (i.e calling "outer()") the transaction fails without meaningful information. Is there a workaround? Is "data" bringing it?