I faced a wired behavior on EVM. It's supposed to state-changing external calls between contracts can not bring return value back. Here is the code:
The interface:
interface MyLogic{
function ModifyData(uint c, uint256[] memory d) external returns (uint256);
}
On the proxy contract:
First approach:
function makeCall(uint command, uint256[] memory _data) public returns (uint256){
logic = MyLogic(_logicAddress);
return logic.ModifyData( command, _data);
}
Second approach:
uint256 private _latestValue;
function makeCall(uint command, uint256[] memory _data) public returns (uint256){
logic = MyLogic(_logicAddress);
_latestValue = logic.ModifyData( command, _data);
return _latestValue ;
}
function getLatestValue() public view returns(uint256) {
return _latestValue;
}
Obviously, I don't get any return value in both approaches when I call the "MyCall" function.
But when I call the "getLatestValue" right after that, it has the correct return value of the "MyCall".
Apparently, the return value of "MyCall" somehow comes to and even being saved on the proxy contract's storage by the first call, but I have no idea why it doesn't show up at first.
Any clue?