Skip to content

Commit 87672a7

Browse files
committed
Successfully perform upgrade on local anvil
1 parent 0173c49 commit 87672a7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lazer/contracts/evm/script/PythLazerDeploy.s.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {PythLazer} from "../src/PythLazer.sol";
66
import {ICreateX} from "createx/ICreateX.sol";
77
import {CreateX} from "createx/CreateX.sol";
88
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
9+
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
910

1011
// This script deploys the PythLazer proxy and implementation contract using
1112
// CreateX's contract factory to a deterministic address. Having deterministic
@@ -168,8 +169,24 @@ contract PythLazerDeployScript is Script {
168169
return addr;
169170
}
170171

172+
function getProxyAddress(bytes11 seed) public view returns (address addr) {
173+
(, bytes32 guardedSalt) = generateSalt(seed);
174+
address proxyAddr = createX.computeCreate3Address({salt: guardedSalt});
175+
return proxyAddr;
176+
}
177+
171178
function run() public {
172179
address impl = deployImplementation("lazer:impl");
173180
deployProxy("lazer:proxy", impl);
174181
}
182+
183+
function migrate() public {
184+
address proxyAddress = getProxyAddress("lazer:proxy");
185+
address newImpl = deployImplementation("lazer:impl");
186+
bytes memory migrateCall = abi.encodeWithSignature("migrate()");
187+
vm.startBroadcast();
188+
UUPSUpgradeable proxy = UUPSUpgradeable(proxyAddress);
189+
proxy.upgradeToAndCall(newImpl, migrateCall);
190+
vm.stopBroadcast();
191+
}
175192
}

lazer/contracts/evm/src/PythLazer.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
1616
function initialize(address _topAuthority) public initializer {
1717
__Ownable_init(_topAuthority);
1818
__UUPSUpgradeable_init();
19+
}
1920

21+
function migrate() public onlyOwner {
2022
verification_fee = 1 wei;
2123
}
2224

0 commit comments

Comments
 (0)