Skip to content

Commit

Permalink
feat: v1 broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
deluca-mike committed Jan 3, 2025
1 parent 5c1e17d commit db0742a
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 23 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
broadcast/**/*run*

# Coverage files
coverage/
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
url = git@github.com:foundry-rs/forge-std.git
branch = v1
[submodule "lib/common"]
path = lib/common
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ update:; forge update

# Deployment helpers
deploy:
FOUNDRY_PROFILE=production forge script script/Deploy.s.sol --skip src --skip test --rpc-url mainnet --slow --broadcast -vvv --verify

deploy-sepolia:
FOUNDRY_PROFILE=production forge script script/Deploy.s.sol --skip src --skip test --rpc-url sepolia --slow --broadcast -vvv
FOUNDRY_PROFILE=production forge script script/DeployProduction.s.sol --skip src --skip test --rpc-url mainnet --slow --broadcast -vvv --verify

deploy-local:
FOUNDRY_PROFILE=production forge script script/Deploy.s.sol --skip src --skip test --rpc-url localhost --slow --broadcast -v
FOUNDRY_PROFILE=production forge script script/DeployProduction.s.sol --skip src --skip test --rpc-url localhost --slow --broadcast -vvv

# Run slither
slither :
Expand Down
225 changes: 225 additions & 0 deletions broadcast/deployments/mainnet-v1.json

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
{
"name": "@mzero-labs/foundry-template",
"name": "@mzero-labs/wrapped-m-token",
"version": "1.0.0",
"description": "Template to kickstart a Foundry project",
"main": "index.js",
"description": "Wrapped M Token",
"author": "M^0 Labs <[email protected]>",
"repository": {
"type": "git",
"url": "git+https://github.com/MZero-Labs/foundry-template.git"
"url": "git+https://github.com/m0-foundation/wrapped-m-token.git"
},
"bugs": {
"url": "https://github.com/MZero-Labs/foundry-template/issues"
"url": "https://github.com/m0-foundation/wrapped-m-token/issues"
},
"homepage": "https://github.com/MZero-Labs/foundry-template#readme",
"homepage": "https://github.com/m0-foundation/wrapped-m-token#readme",
"scripts": {
"build": "make -B build",
"clean": "make -B clean",
"compile": "forge compile",
"coverage": "make -B coverage",
"deploy": "make -B deploy",
"deploy-local": "make -B deploy-local",
"deploy-sepolia": "make -B deploy-sepolia",
"doc": "forge doc --serve --port 4000",
"lint-staged": "lint-staged",
"prepack": "npm run clean && npm run build",
Expand Down
11 changes: 6 additions & 5 deletions script/DeployProduction.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract DeployProduction is Script, DeployBase {
address internal constant _EXPECTED_DEPLOYER = 0xF2f1ACbe0BA726fEE8d75f3E32900526874740BB;

// NOTE: Ensure this is the correct nonce to use to deploy the Proxy on testnet/mainnet.
uint256 internal constant _DEPLOYER_PROXY_NONCE = 40;
uint64 internal constant _DEPLOYER_PROXY_NONCE = 40;

// NOTE: Ensure this is the correct expected testnet/mainnet address for the Proxy.
address internal constant _EXPECTED_PROXY = 0x437cc33344a0B27A429f795ff6B469C72698B291;
Expand All @@ -42,24 +42,25 @@ contract DeployProduction is Script, DeployBase {
if (deployer_ != _EXPECTED_DEPLOYER) revert DeployerMismatch(_EXPECTED_DEPLOYER, deployer_);

uint64 currentNonce_ = vm.getNonce(deployer_);
uint64 startNonce_ = _DEPLOYER_PROXY_NONCE - 1;

if (currentNonce_ >= _DEPLOYER_PROXY_NONCE - 1) revert DeployerNonceTooHigh();
if (currentNonce_ >= startNonce_) revert DeployerNonceTooHigh();

address expectedProxy_ = getExpectedWrappedMTokenProxy(deployer_, _DEPLOYER_PROXY_NONCE);
address expectedProxy_ = getExpectedWrappedMTokenProxy(deployer_, startNonce_);

if (expectedProxy_ != _EXPECTED_PROXY) revert ExpectedProxyMismatch(_EXPECTED_PROXY, expectedProxy_);

vm.startBroadcast(deployer_);

// Burn nonces until to 1 before `_DEPLOYER_PROXY_NONCE` since implementation is deployed before proxy.
while (currentNonce_ < _DEPLOYER_PROXY_NONCE - 1) {
while (currentNonce_ < startNonce_) {
payable(deployer_).transfer(0);
++currentNonce_;
}

if (currentNonce_ != vm.getNonce(deployer_)) revert CurrentNonceMismatch(currentNonce_, vm.getNonce(deployer_));

if (currentNonce_ != _DEPLOYER_PROXY_NONCE - 1) revert UnexpectedDeployerNonce();
if (currentNonce_ != startNonce_) revert UnexpectedDeployerNonce();

(address implementation_, address proxy_) = deploy(_M_TOKEN, _MIGRATION_ADMIN);

Expand Down

0 comments on commit db0742a

Please sign in to comment.