I have two contracts called A and B. I defined an array variable in contract A. I want to check if an index exists or not from contract B.
A.sol
contract A {
SomeStruct[] private myArray;
/// @notice Check if an index exists
function isIndexExists(uint256 index) public view returns (bool) {
if (myArray[index].isExist) {
return true;
} else {
return false;
}
}
}
B.sol
contract B is A {
function todo(uint256 index) public view returns (bool) {
if (isIndexExists(index)) {
// ... logic
} else {
revert("Index in not exist")l
}
}
}
The isIndexExists function works well When called directly from contract A, But in B an error occurs.
I make this call from the JS test environment in Truffle.
Error:
Error: Returned error: VM Exception while processing transaction: revert