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 ce4261b
Showing
15 changed files
with
482 additions
and
200 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Deploy script environment variables | ||
PRIVATE_KEY= # Private key of the deployer | ||
DEPLOYER= # Address the deployer | ||
DEPLOYER_PROXY_NONCE= # Nonce of the deployer when creating the Wrapped M proxy | ||
EXPECTED_PROXY= # Address of the expected Wrapped M proxy | ||
M_TOKEN= # Address of the M token | ||
REGISTRAR= # Address of the Registrar | ||
EXCESS_DESTINATION= # Address of the Excess Destination | ||
MIGRATION_ADMIN= # Address of the Migration Admin | ||
|
||
# RPC URL to deploy to | ||
MAINNET_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
ETHERSCAN_API_KEY= |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Localhost RPC URL | ||
export LOCALHOST_RPC_URL=http://127.0.0.1:8545 | ||
LOCALHOST_RPC_URL=http://127.0.0.1:8545 | ||
|
||
# Mainnet RPC URLs | ||
export MAINNET_RPC_URL= | ||
MAINNET_RPC_URL= | ||
|
||
# Testnet RPC URLs | ||
export SEPOLIA_RPC_URL= | ||
SEPOLIA_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
export ETHERSCAN_API_KEY= | ||
ETHERSCAN_API_KEY= |
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,8 @@ | ||
# Mainnet upgrade script environment variables | ||
PRIVATE_KEY= # Private key of the deployer | ||
|
||
# Mainnet RPC URL to perform upgrade | ||
MAINNET_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
ETHERSCAN_API_KEY= |
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,76 @@ | ||
// 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 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_) = deploy( | ||
vm.envAddress("M_TOKEN"), | ||
vm.envAddress("REGISTRAR"), | ||
vm.envAddress("EXCESS_DESTINATION"), | ||
vm.envAddress("MIGRATION_ADMIN") | ||
); | ||
|
||
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.