Hi there, I did a small experiement with the Address library and got something I have not fully understood yet. The following two contracts are quite straightforward. The f() function in the MappingUser contract is not working, and f2() works fine.
It seems that since m is a dynamically generated contract, a functionCall() is not working for it. Is this true?
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
contract MappingExample {
mapping(address => uint) public balances;
function update(uint newBalance) public {
balances[msg.sender] = newBalance;
}
}
contract MappingUser {
using Address for address;
function f() public returns (bytes memory) {
MappingExample m = new MappingExample();
// m.update(100);
(bytes memory data) = address(m).functionCall(abi.encodeWithSignature("update(uint256)", 100));
return data;
}
function f2(address adr) public returns(bytes memory) {
return adr.functionCall(abi.encodeWithSignature("update(uint256)", 100));
}
}