-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch switches our core Factory to be `CodeJarFactory` that deploys `CodeJar` deterministically via `scripts/deploy-code-jar.sh`. After that, you're expected to pass in `CODE_JAR` to the deployment script which now depends on using that same Code Jar for deployments. The key benefit here is that we can re-use that same CodeJar access multiple network deployments. In fact, if we get a consistent CodeJar address on all chains (e.g. via running the deployment script on all standard EVM chains), then we can use whatever key to deploy any new Quark Factory contracts and they will always end up at the same address on all chains. This should make multi-chain deployments a breeze! Plus, everything _should_ be verifiable, etc, on Etherscan now, too.
- Loading branch information
Showing
6 changed files
with
127 additions
and
31 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,41 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.23; | ||
|
||
import "forge-std/Script.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import {CodeJar} from "codejar/src/CodeJar.sol"; | ||
import {CodeJarFactory} from "codejar/src/CodeJarFactory.sol"; | ||
|
||
// Deploy with: | ||
// $ set -a && source .env && ./script/deploy.sh --broadcast | ||
|
||
// Required ENV vars: | ||
// RPC_URL | ||
// DEPLOYER_PK | ||
|
||
// Optional ENV vars: | ||
// ETHERSCAN_KEY | ||
|
||
contract DeployCodeJarFactory is Script { | ||
CodeJarFactory codeJarFactory; | ||
CodeJar codeJar; | ||
|
||
function run() public { | ||
address deployer = vm.addr(vm.envUint("DEPLOYER_PK")); | ||
|
||
vm.startBroadcast(deployer); | ||
|
||
console.log("============================================================="); | ||
|
||
console.log("Deploying Code Jar Factory"); | ||
codeJarFactory = new CodeJarFactory(); | ||
codeJar = codeJarFactory.codeJar(); | ||
console.log("Code Jar Factory Deployed:", address(codeJarFactory)); | ||
console.log("Code Jar Deployed:", address(codeJar)); | ||
|
||
console.log("============================================================="); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
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,28 @@ | ||
#!/bin/bash | ||
|
||
set -exo pipefail | ||
|
||
if [ -n "$RPC_URL" ]; then | ||
rpc_args="--rpc-url $RPC_URL" | ||
else | ||
rpc_args="" | ||
fi | ||
|
||
if [ -n "$DEPLOYER_PK" ]; then | ||
wallet_args="--private-key $DEPLOYER_PK" | ||
else | ||
wallet_args="--unlocked" | ||
fi | ||
|
||
if [ -n "$ETHERSCAN_KEY" ]; then | ||
etherscan_args="--verify --etherscan-api-key $ETHERSCAN_KEY" | ||
else | ||
etherscan_args="" | ||
fi | ||
|
||
forge script --via-ir \ | ||
$rpc_args \ | ||
$wallet_args \ | ||
$etherscan_args \ | ||
$@ \ | ||
script/DeployCodeJarFactory.s.sol:DeployCodeJarFactory |
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,17 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.23; | ||
|
||
import {CodeJar} from "codejar/src/CodeJar.sol"; | ||
|
||
/** | ||
* @title Code Jar Factory | ||
* @notice A factory for deploying Code Jar to a content-determinstic address | ||
* @author Compound Labs, Inc. | ||
*/ | ||
contract CodeJarFactory { | ||
CodeJar public immutable codeJar; | ||
|
||
constructor() { | ||
codeJar = new CodeJar{salt: 0}(); | ||
} | ||
} |
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