Can I pass parameter to run() function?
When I want to upgrade a contract, I think we need to pass proxy address.
How can I do that? I'm not sure below code block is working or not
Code to reproduce
contract DeployScript is Script {
function setUp() public {}
function run() public returns (address proxy, address implementation) {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
proxy = Upgrades.deployUUPSProxy("MyContract.sol", abi.encodeCall(MyContract.initialize, ()));
implementation = Upgrades.getImplementationAddress(proxy);
vm.stopBroadcast();
}
}
contract UpgradeScript is Script {
function setUp() public {}
function run(address proxy) returns (address proxy, address newImplementation) {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
Upgrades.upgradeProxy(proxy, "MyContractV2", MyContractV2.initialize);
newImplementation = Upgrades.getImplementationAddress(proxy);
vm.stopBroadcast();
}
}