Commit 12024acb by Francisco Giordano

inline functionDelegateCall

parent 5230b7f1
...@@ -27,7 +27,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { ...@@ -27,7 +27,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock {
// Initial upgrade and setup call // Initial upgrade and setup call
__setImplementation(newImplementation); __setImplementation(newImplementation);
if (data.length > 0 || forceCall) { if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data); __functionDelegateCall(newImplementation, data);
} }
// Perform rollback test if not already in progress // Perform rollback test if not already in progress
...@@ -35,7 +35,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { ...@@ -35,7 +35,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock {
if (!rollbackTesting.value) { if (!rollbackTesting.value) {
// Trigger rollback using upgradeTo from the new implementation // Trigger rollback using upgradeTo from the new implementation
rollbackTesting.value = true; rollbackTesting.value = true;
Address.functionDelegateCall( __functionDelegateCall(
newImplementation, newImplementation,
abi.encodeWithSignature("upgradeTo(address)", oldImplementation) abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
); );
...@@ -55,4 +55,14 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { ...@@ -55,4 +55,14 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock {
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual override { function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual override {
_upgradeToAndCallSecureLegacyV1(newImplementation, data, false); _upgradeToAndCallSecureLegacyV1(newImplementation, data, false);
} }
// ERC1967Upgrade._functionDelegateCall is private so we reproduce it here.
// An extra underscore prevents a name clash error.
function __functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(Address.isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return Address.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment