generated from m0-foundation/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- solc 0.8.26 - latest common - latest forge-std - registrar as constructor arg - excess destination as constructor arg - constants made public - token name changed - `IsApprovedEarner` and `NotApprovedEarner` errors have account as parameter - basic Migrator contract introduced - version bump - use more from common - more test coverage - fixed scripts to allow for generic deploy and mainnet upgrade
- Loading branch information
1 parent
60b0d42
commit 3e9989e
Showing
12 changed files
with
454 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity 0.8.26; | ||
|
||
import { Script, console2 } from "../lib/forge-std/src/Script.sol"; | ||
|
||
import { DeployBase } from "./DeployBase.sol"; | ||
|
||
contract DeployProduction is Script, DeployBase { | ||
error DeployerMismatch(address expected, address actual); | ||
|
||
error DeployerNonceTooHigh(); | ||
|
||
error UnexpectedDeployerNonce(); | ||
|
||
error CurrentNonceMismatch(uint64 expected, uint64 actual); | ||
|
||
error ExpectedProxyMismatch(address expected, address actual); | ||
|
||
error ResultingProxyMismatch(address expected, address actual); | ||
|
||
function run() external { | ||
address deployer_ = vm.rememberKey(vm.envUint("PRIVATE_KEY")); | ||
address expectedDeployer_ = vm.envAddress("DEPLOYER"); | ||
|
||
uint64 deployerProxyNonce_ = uint64(vm.envUint("DEPLOYER_PROXY_NONCE")); | ||
|
||
address registrar_ = vm.envAddress("REGISTRAR"); | ||
address excessDestination_ = vm.envAddress("EXCESS_DESTINATION"); | ||
address mToken_ = vm.envAddress("M_TOKEN"); | ||
address migrationAdmin_ = vm.envAddress("MIGRATION_ADMIN"); | ||
address expectedProxy_ = vm.envAddress("EXPECTED_PROXY"); | ||
|
||
console2.log("Deployer:", deployer_); | ||
|
||
if (deployer_ != expectedDeployer_) revert DeployerMismatch(expectedDeployer_, deployer_); | ||
|
||
uint64 currentNonce_ = vm.getNonce(deployer_); | ||
|
||
uint64 startNonce_ = currentNonce_; | ||
address implementation_; | ||
address proxy_; | ||
|
||
while (true) { | ||
if (startNonce_ > deployerProxyNonce_) revert DeployerNonceTooHigh(); | ||
|
||
(implementation_, proxy_) = mockDeploy(deployer_, startNonce_); | ||
|
||
if (proxy_ == expectedProxy_) break; | ||
|
||
++startNonce_; | ||
} | ||
|
||
vm.startBroadcast(deployer_); | ||
|
||
// Burn nonces until to `currentNonce_ == startNonce_`. | ||
while (currentNonce_ < startNonce_) { | ||
payable(deployer_).transfer(0); | ||
++currentNonce_; | ||
} | ||
|
||
if (currentNonce_ != vm.getNonce(deployer_)) revert CurrentNonceMismatch(currentNonce_, vm.getNonce(deployer_)); | ||
|
||
if (currentNonce_ != startNonce_) revert UnexpectedDeployerNonce(); | ||
|
||
(implementation_, proxy_) = deployUpgrade(mToken_, registrar_, excessDestination_, migrationAdmin_); | ||
|
||
vm.stopBroadcast(); | ||
|
||
console2.log("Wrapped M Implementation address:", implementation_); | ||
console2.log("Migrator address:", proxy_); | ||
|
||
if (proxy_ != expectedProxy_) revert ResultingProxyMismatch(expectedProxy_, proxy_); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.