Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve local deployment #89

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
deploy :; source .env && export FOUNDRY_PROFILE=deploy && forge script script/DeployFactory.s.sol --rpc-url $${RPC_URL} --account $${ACCOUNT} --broadcast --verify
deploy :; \
source .env && \
export FOUNDRY_PROFILE=deploy && \
forge script script/DeployFactory.s.sol \
--rpc-url $${RPC_URL} \
--account $${ACCOUNT} \
--broadcast \
$(if $(ETHERSCAN_API_KEY),--verify)
18 changes: 16 additions & 2 deletions script/DeployFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@ import {SafeSingletonDeployer} from "safe-singleton-deployer-sol/src/SafeSinglet
import {CoinbaseSmartWallet, CoinbaseSmartWalletFactory} from "../src/CoinbaseSmartWalletFactory.sol";

contract DeployFactoryScript is Script {
address constant EXPECTED_IMPLEMENTATION = 0x000100abaad02f1cfC8Bbe32bD5a564817339E72;
address constant EXPECTED_FACTORY = 0x0BA5ED0c6AA8c49038F819E587E2633c4A9F428a;
// cast code 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7 --rpc-url https://mainnet.base.org
bytes constant SAFE_SINGLETON_FACTORY_CODE =
hex"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3";
Copy link
Author

@frolic frolic Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally SafeSingletonDeployer would export this or a method containing the vm.etch logic, but hardcoding it here for now

happy to open a PR over there too if this sounds reasonable!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good idea to export

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or alternatively, maybe we should just have a new function like, "deployAnvil"? which uses etch and doesn't have to expose

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me, should I open a PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went ahead and opened one: wilsoncusack/safe-singleton-deployer-sol#2


address constant EXPECTED_IMPLEMENTATION =
0x000100abaad02f1cfC8Bbe32bD5a564817339E72;
address constant EXPECTED_FACTORY =
0x0BA5ED0c6AA8c49038F819E587E2633c4A9F428a;

function run() public {
// Set the deployer code if it's not already on the chain.
if (SafeSingletonDeployer.SAFE_SINGLETON_FACTORY.code.length == 0) {
Comment on lines +20 to +21
Copy link
Author

@frolic frolic Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check could alternatively be

Suggested change
// Set the deployer code if it's not already on the chain.
if (SafeSingletonDeployer.SAFE_SINGLETON_FACTORY.code.length == 0) {
// Set the deployer code when running this on Anvil
if (block.chainid == 31337) {

vm.etch(
SafeSingletonDeployer.SAFE_SINGLETON_FACTORY,
SAFE_SINGLETON_FACTORY_CODE
);
}

console2.log("Deploying on chain ID", block.chainid);
address implementation = SafeSingletonDeployer.broadcastDeploy({
creationCode: type(CoinbaseSmartWallet).creationCode,
Expand Down