diff --git a/script/BaseMigration.s.sol b/script/BaseMigration.s.sol index 0cefd60..5866a68 100644 --- a/script/BaseMigration.s.sol +++ b/script/BaseMigration.s.sol @@ -7,6 +7,7 @@ import { Vm } from "../dependencies/forge-std-1.9.3/src/Vm.sol"; import { console } from "../dependencies/forge-std-1.9.3/src/console.sol"; import { LibString } from "../dependencies/solady-0.0.228/src/utils/LibString.sol"; import { RoninTransparentProxy } from "../src/RoninTransparentProxy.sol"; +import { TransparentProxyOZv4_9_5 } from "../src/TransparentProxyOZv4_9_5.sol"; import { OnchainExecutor } from "./OnchainExecutor.s.sol"; import { IScriptExtended, ScriptExtended } from "./extensions/ScriptExtended.s.sol"; // cheat to load artifact to parent @@ -328,6 +329,7 @@ abstract contract BaseMigration is ScriptExtended { */ function _precompileProxyContracts() internal pure virtual { bytes memory dummy; - dummy = type(RoninTransparentProxy).creationCode; + dummy = type(RoninTransparentProxy).creationCode; + dummy = type(TransparentProxyOZv4_9_5).creationCode; } } diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 3944965..1a528d6 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -205,7 +205,7 @@ library LibDeploy { DeployInfo memory proxyInfo; proxyInfo.callValue = callValue; proxyInfo.by = implInfo.by; - proxyInfo.contractName = "RoninTransparentProxy"; + proxyInfo.contractName = "TransparentProxyOZv4_9_5"; proxyInfo.absolutePath = string.concat(proxyInfo.contractName, ".sol:", proxyInfo.contractName); proxyInfo.artifactName = string.concat(vm.replace(implInfo.artifactName, "Logic", ""), "Proxy"); proxyInfo.constructorArgs = abi.encode(impl, proxyAdmin, callData); diff --git a/script/libraries/LibInitializeGuard.sol b/script/libraries/LibInitializeGuard.sol index a4f6962..aa70acc 100644 --- a/script/libraries/LibInitializeGuard.sol +++ b/script/libraries/LibInitializeGuard.sol @@ -340,9 +340,12 @@ library LibInitializeGuard { string memory path ) internal pure returns (string memory contractName) { uint256 length = bytes(path).length; - // Remove ".sol" + contractName = path; if (path.endsWith(".sol")) contractName = path.slice(0, length - 4); - return string(contractName); + string[] memory parts = contractName.split(":"); + if (parts.length != 0) contractName = parts[parts.length - 1]; + parts = contractName.split("/"); + if (parts.length != 0) contractName = parts[parts.length - 1]; } /** diff --git a/src/TransparentProxyOZv4_9_5.sol b/src/TransparentProxyOZv4_9_5.sol new file mode 100644 index 0000000..7ed36d9 --- /dev/null +++ b/src/TransparentProxyOZv4_9_5.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { + ITransparentUpgradeableProxy, + TransparentUpgradeableProxy +} from "../dependencies/openzeppelin-v4-4.9.5/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +/** + * @title TransparentProxyOZv4_9_5 + * @dev A contract that acts as a proxy for transparent upgrades. + */ +contract TransparentProxyOZv4_9_5 is TransparentUpgradeableProxy { + /** + * @dev Initializes the Proxy contract. + * @param logic The address of the logic contract. + * @param admin The address of the admin contract. + * @param data The initialization data. + */ + constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) { } +} diff --git a/test/LibInitializeGuard.t.sol b/test/LibInitializeGuard.t.sol index c8b5209..e9ba1b8 100644 --- a/test/LibInitializeGuard.t.sol +++ b/test/LibInitializeGuard.t.sol @@ -22,6 +22,7 @@ import { SampleProxyForTestingPurpose7 } from "src/mocks/ForTesting/SampleProxyF import { SampleProxy } from "src/mocks/SampleProxy.sol"; interface ITransparentUpgradeableProxy { + function upgradeTo(address) external; function upgradeToAndCall(address, bytes memory) external payable; } @@ -65,7 +66,7 @@ contract LibInitializeGuardTest is Test { address newLogic = address(new SampleProxyForTestingPurpose2()); vm.prank(admin); - ITransparentUpgradeableProxy(address(_sample)).upgradeToAndCall(newLogic, ""); + ITransparentUpgradeableProxy(address(_sample)).upgradeTo(newLogic); MockConfig(address(vme)).updateSampleProxyLogicForTesting("SampleProxyForTestingPurpose2"); Vm.Log[] memory logs = vm.getRecordedLogs();