Skip to content

Commit

Permalink
v1 deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsoncusack committed Apr 22, 2024
1 parent 7dc6000 commit d271f25
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 48 deletions.
16 changes: 8 additions & 8 deletions .gas-snapshot
Expand Up @@ -23,7 +23,7 @@ CoinbaseSmartWalletFactoryTest:test_implementation_returnsExpectedAddress() (gas
CoinbaseSmartWalletFactoryTest:test_initCodeHash() (gas: 7912)
CoinbaseSmartWalletFactoryTest:test_revertsIfNoOwners() (gas: 29232)
ERC1271Test:test_returnsExpectedDomainHashWhenProxy() (gas: 29243)
ERC1271Test:test_static() (gas: 3240637)
ERC1271Test:test_static() (gas: 3247131)
MultiOwnableInitializeTest:testRevertsIfLength32ButLargerThanAddress() (gas: 81111)
MultiOwnableInitializeTest:testRevertsIfLength32NotAddress() (gas: 81092)
MultiOwnableInitializeTest:testRevertsIfLengthNot32Or64() (gas: 103395)
Expand All @@ -45,8 +45,8 @@ TestCanSkipChainIdValidation:test_approvedSelectorsReturnTrue() (gas: 17781)
TestCanSkipChainIdValidation:test_otherSelectorsReturnFalse() (gas: 12579)
TestExecuteWithoutChainIdValidation:testExecute() (gas: 403873)
TestExecuteWithoutChainIdValidation:testExecuteBatch() (gas: 728942)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3608152, ~: 3468946)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 50179)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3603267, ~: 3475199)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 50211)
TestExecuteWithoutChainIdValidation:test_revertsWithReservedNonce() (gas: 81941)
TestExecuteWithoutChainIdValidation:test_reverts_whenCallerNotEntryPoint() (gas: 11031)
TestExecuteWithoutChainIdValidation:test_reverts_whenOneCallReverts() (gas: 467783)
Expand All @@ -55,18 +55,18 @@ TestExecuteWithoutChainIdValidation:test_reverts_whenSelectorNotApproved() (gas:
TestExecuteWithoutChainIdValidation:test_succeeds_whenSelectorAllowed() (gas: 423963)
TestImplementation:testImplementation() (gas: 12558)
TestInitialize:testInitialize() (gas: 21012)
TestInitialize:test_cannotInitImplementation() (gas: 2889926)
TestInitialize:test_cannotInitImplementation() (gas: 2896342)
TestIsValidSignature:testReturnsInvalidIfPasskeySigButWrongOwnerLength() (gas: 40165)
TestIsValidSignature:testRevertsIfEthereumSignatureButWrongOwnerLength() (gas: 24018)
TestIsValidSignature:testRevertsIfOwnerIsInvalidEthereumAddress() (gas: 21999)
TestIsValidSignature:testSmartWalletSigner() (gas: 3171533)
TestIsValidSignature:testSmartWalletSigner() (gas: 3177948)
TestIsValidSignature:testValidateSignatureWithEOASigner() (gas: 24900)
TestIsValidSignature:testValidateSignatureWithEOASignerFailsWithWrongSigner() (gas: 23855)
TestIsValidSignature:testValidateSignatureWithPasskeySigner() (gas: 423216)
TestIsValidSignature:testValidateSignatureWithPasskeySigner() (gas: 423221)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsBadOwnerIndex() (gas: 35642)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsWithWrongBadSignature() (gas: 430682)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsWithWrongBadSignature() (gas: 430687)
TestUpgradeToAndCall:testUpgradeToAndCall() (gas: 25499)
TestValidateUserOp:test_reverts_whenReplayableNonceKeyInvalidForSelector() (gas: 14211)
TestValidateUserOp:test_reverts_whenSelectorInvalidForReplayableNonceKey() (gas: 14476)
TestValidateUserOp:test_succeedsWithEOASigner() (gas: 448010)
TestValidateUserOp:test_succeedsWithPasskeySigner() (gas: 785193)
TestValidateUserOp:test_succeedsWithPasskeySigner() (gas: 785198)
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -7,7 +7,7 @@ out/
/broadcast/*/31337/
/broadcast/**/dry-run/

/broadcast
/broadcast/DeployERC4337Factory.s.sol

# Docs
docs/
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Expand Up @@ -7,9 +7,6 @@
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
[submodule "lib/FreshCryptoLib"]
path = lib/FreshCryptoLib
url = https://github.com/rdubois-crypto/FreshCryptoLib
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
Expand Down
17 changes: 14 additions & 3 deletions README.md
Expand Up @@ -82,10 +82,10 @@ Today, allowed are
- UUPSUpgradeable.upgradeToAndCall

## Deployments

| Network | CoinbaseSmartWalletFactory Address |
Factory and implementation are deployed via [Safe Singleton Factory](https://github.com/safe-global/safe-singleton-factory), which today will give the same address across 248 chains. See "Deploying" below for instructions on how to deploy to new chains.
| Version | Factory Address |
|-----------|-----------------------------------------|
| Base Sepolia | [0xeD4EAeBDBBA52DBB37259a2b75AbB87abF3a19E8](https://sepolia.basescan.org/address/0xeD4EAeBDBBA52DBB37259a2b75AbB87abF3a19E8) |
| 1 | [0x0BA5ED0c6AA8c49038F819E587E2633c4A9F428a](https://basescan.org/address/0x0BA5ED0c6AA8c49038F819E587E2633c4A9F428a) |


## Developing
Expand All @@ -94,5 +94,16 @@ After cloning the repo, run the tests using Forge, from [Foundry](https://github
forge test
```

## Deploying
To deploy on a new chain, in your `.env` set
```bash
FOUNDRY_PROFILE=default
```

Then run
```
forge script script/DeployFactory.s.sol --rpc-url https://...
```

## Influences
Much of the code in this repository started from Solady's [ERC4337](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC4337.sol) implementation. We were also influenced by [DaimoAccount](https://github.com/daimo-eth/daimo/blob/master/packages/contract/src/DaimoAccount.sol), which pioneered using passkey signers on ERC-4337 accounts, and [LightAccount](https://github.com/alchemyplatform/light-account).
113 changes: 113 additions & 0 deletions broadcast/DeployFactory.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions broadcast/DeployFactory.s.sol/8453/run-1713818220.json

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions broadcast/DeployFactory.s.sol/8453/run-latest.json

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions broadcast/DeployFactory.s.sol/84532/run-1713816554.json

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions broadcast/DeployFactory.s.sol/84532/run-latest.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions foundry.toml
Expand Up @@ -3,6 +3,10 @@ src = "src"
out = "out"
libs = ["lib"]

[profile.deploy]
optimizer = true
optimizer_runs = 999999

[fmt]
sort_imports = true
wrap_comments = true
Expand Down
1 change: 0 additions & 1 deletion lib/FreshCryptoLib
Submodule FreshCryptoLib deleted from d9bb3b
10 changes: 0 additions & 10 deletions remappings.txt

This file was deleted.

21 changes: 0 additions & 21 deletions script/DeployERC4337Factory.s.sol

This file was deleted.

33 changes: 33 additions & 0 deletions script/DeployFactory.s.sol
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {Script, console2} from "forge-std/Script.sol";
import {SafeSingletonDeployer} from "safe-singleton-deployer-sol/src/SafeSingletonDeployer.sol";

import {CoinbaseSmartWallet, CoinbaseSmartWalletFactory} from "../src/CoinbaseSmartWalletFactory.sol";

contract DeployFactoryScript is Script {
address constant EXPECTED_IMPLEMENTATION = 0x000100abaad02f1cfC8Bbe32bD5a564817339E72;
address constant EXPECTED_FACTORY = 0x0BA5ED0c6AA8c49038F819E587E2633c4A9F428a;

function run() public {
console2.log("Deploying on chain ID", block.chainid);
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address implementation = SafeSingletonDeployer.broadcastDeploy({
deployerPrivateKey: deployerPrivateKey,
creationCode: type(CoinbaseSmartWallet).creationCode,
args: "",
salt: 0x3438ae5ce1ff7750c1e09c4b28e2a04525da412f91561eb5b57729977f591fbb
});
console2.log("implementation", implementation);
assert(implementation == EXPECTED_IMPLEMENTATION);
address factory = SafeSingletonDeployer.broadcastDeploy({
deployerPrivateKey: deployerPrivateKey,
creationCode: type(CoinbaseSmartWalletFactory).creationCode,
args: abi.encode(implementation),
salt: 0x278d06dab87f67bb2d83470a70c8975a2c99872f290058fb43bcc47da5f0390c
});
console2.log("factory", factory);
assert(factory == EXPECTED_FACTORY);
}
}

0 comments on commit d271f25

Please sign in to comment.