diff --git a/run.sh b/run.sh index 47d9932..9ed4253 100755 --- a/run.sh +++ b/run.sh @@ -6,8 +6,8 @@ for arg in "$@"; do --trezor) extra_argument+=trezor@ ;; - --disable-postcheck) - set -- "${@/#--disable-postcheck/}" + --no-postcheck) + set -- "${@/#--no-postcheck/}" extra_argument+=no-postcheck@ ;; --generate-artifacts) diff --git a/script/BaseMigration.s.sol b/script/BaseMigration.s.sol index adb2081..f10cf71 100644 --- a/script/BaseMigration.s.sol +++ b/script/BaseMigration.s.sol @@ -2,10 +2,7 @@ pragma solidity ^0.8.19; import { ProxyAdmin } from "../lib/openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol"; -import { - ITransparentUpgradeableProxy, - TransparentUpgradeableProxy -} from "../lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { ITransparentUpgradeableProxy, Proxy } from "../src/Proxy.sol"; import { LibString } from "../lib/solady/src/utils/LibString.sol"; import { console, @@ -22,10 +19,12 @@ import { IMigrationScript } from "./interfaces/IMigrationScript.sol"; import { LibProxy } from "./libraries/LibProxy.sol"; import { DefaultContract } from "./utils/DefaultContract.sol"; import { TContract } from "./types/Types.sol"; +import { LibErrorHandler } from "../lib/contract-libs/src/LibErrorHandler.sol"; abstract contract BaseMigration is ScriptExtended { using StdStyle for *; using LibString for bytes32; + using LibErrorHandler for bool; using LibProxy for address payable; IArtifactFactory public constant ARTIFACT_FACTORY = IArtifactFactory(LibSharedAddress.ARTIFACT_FACTORY); @@ -139,14 +138,13 @@ abstract contract BaseMigration is ScriptExtended { string memory contractName = CONFIG.getContractName(contractType); address logic = _deployLogic(contractType, argsLogicConstructor); - string memory proxyAbsolutePath = - "./out/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json"; + string memory proxyAbsolutePath = "Proxy.sol:Proxy"; uint256 proxyNonce = vm.getNonce(sender()); address proxyAdmin = _getProxyAdmin(); assertTrue(proxyAdmin != address(0x0), "BaseMigration: Null ProxyAdmin"); vm.broadcast(sender()); - deployed = payable(address(new TransparentUpgradeableProxy(logic, proxyAdmin, args))); + deployed = payable(address(new Proxy(logic, proxyAdmin, args))); // validate proxy admin address actualProxyAdmin = deployed.getProxyAdmin(); @@ -308,6 +306,28 @@ abstract contract BaseMigration is ScriptExtended { } } + function _cheatBroadcast(address from, address to, bytes memory callData) internal virtual { + string[] memory commandInputs = new string[](3); + commandInputs[0] = "cast"; + commandInputs[1] = "4byte-decode"; + commandInputs[2] = vm.toString(callData); + string memory decodedCallData = string(vm.ffi(commandInputs)); + + console.log("\n"); + console.log("--------------------------- Call Detail ---------------------------"); + console.log("To:".cyan(), vm.getLabel(to)); + console.log( + "Raw Calldata Data (Please double check using `cast pretty-calldata {raw_bytes}`):\n".cyan(), + string.concat(" - ", vm.toString(callData)) + ); + console.log("Cast Decoded Call Data:".cyan(), decodedCallData); + console.log("--------------------------------------------------------------------"); + + vm.prank(from); + (bool success, bytes memory returnOrRevertData) = to.call(callData); + success.handleRevert(bytes4(callData), returnOrRevertData); + } + function _cheatUpgrade(address owner, ProxyAdmin wProxyAdmin, ITransparentUpgradeableProxy iProxy, address logic) internal virtual diff --git a/src/Proxy.sol b/src/Proxy.sol new file mode 100644 index 0000000..2e3280a --- /dev/null +++ b/src/Proxy.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import { + ITransparentUpgradeableProxy, + TransparentUpgradeableProxy +} from "../lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +/** + * @title Proxy + * @dev A contract that acts as a proxy for transparent upgrades. + */ +contract Proxy 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) TransparentUpgradeableProxy(_logic, _admin, _data) { } +}