Skip to content

Commit

Permalink
Merge pull request #25 from tokenbound/jw/account-v3
Browse files Browse the repository at this point in the history
Tokenbound v3
  • Loading branch information
jaydenwindle authored Oct 19, 2023
2 parents 43f2dc7 + a37903c commit 4e34891
Show file tree
Hide file tree
Showing 51 changed files with 2,483 additions and 1,211 deletions.
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
[submodule "lib/erc6551"]
path = lib/erc6551
url = https://github.com/erc6551/reference
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/multicall-authenticated"]
path = lib/multicall-authenticated
url = https://github.com/jaydenwindle/multicall-authenticated
7 changes: 7 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ src = 'src'
out = 'out'
libs = ['lib']

solc_version = "0.8.17"
optimizer = true
optimizer_runs = 200

[fmt]
line_length = 100

[rpc_endpoints]
goerli = "${GOERLI_RPC_URL}"
sepolia = "${SEPOLIA_RPC_URL}"
Expand Down
1 change: 1 addition & 0 deletions lib/multicall-authenticated
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ ds-test/=lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=lib/forge-std/src/
@openzeppelin/=lib/openzeppelin-contracts/
multicall-authenticated/=lib/multicall-authenticated/src/
27 changes: 0 additions & 27 deletions script/DeployAccount.s.sol

This file was deleted.

128 changes: 128 additions & 0 deletions script/DeployAccountV3.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "forge-std/Script.sol";

import "@openzeppelin/contracts/utils/Create2.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "../src/AccountGuardian.sol";
import "../src/AccountV3Upgradable.sol";
import "../src/AccountProxy.sol";

contract DeployAccountV3 is Script {
function run() external {
bytes32 salt = 0x6551655165516551655165516551655165516551655165516551655165516551;
address factory = 0x4e59b44847b379578588920cA78FbF26c0B4956C;

address tokenboundSafe = 0x781b6A527482828bB04F33563797d4b696ddF328;
address erc4337EntryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address multicallForwarder = 0xcA1167915584462449EE5b4Ea51c37fE81eCDCCD;
address erc6551Registry = 0x8deDFee9BEEe2D64817Dd8dB8cff138C468Bd3Ef;

address guardian = Create2.computeAddress(
salt,
keccak256(
abi.encodePacked(type(AccountGuardian).creationCode, abi.encode(tokenboundSafe))
),
factory
);
address implementation = Create2.computeAddress(
salt,
keccak256(
abi.encodePacked(
type(AccountV3Upgradable).creationCode,
abi.encode(erc4337EntryPoint, multicallForwarder, erc6551Registry, guardian)
)
),
factory
);
address proxy = Create2.computeAddress(
salt,
keccak256(
abi.encodePacked(
type(AccountProxy).creationCode, abi.encode(guardian, implementation)
)
),
factory
);

// Deploy AccountGuardian
if (guardian.code.length == 0) {
vm.startBroadcast();
new AccountGuardian{salt: salt}(tokenboundSafe);
vm.stopBroadcast();

console.log("AccountGuardian:", guardian, "(deployed)");
} else {
console.log("AccountGuardian:", guardian, "(exists)");
}

// Deploy Account implementation
if (implementation.code.length == 0) {
vm.startBroadcast();
new AccountV3Upgradable{salt: salt}(
erc4337EntryPoint,
multicallForwarder,
erc6551Registry,
guardian
);
vm.stopBroadcast();

console.log("AccountV3Upgradable:", implementation, "(deployed)");
} else {
console.log("AccountV3Upgradable:", implementation, "(exists)");
}

// Deploy AccountProxy
if (proxy.code.length == 0) {
vm.startBroadcast();
new AccountProxy{salt: salt}(guardian, implementation);
vm.stopBroadcast();

console.log("AccountProxy:", proxy, "(deployed)");
} else {
console.log("AccountProxy:", proxy, "(exists)");
}

console.log("\nVerification Commands:\n");
console.log(
"AccountGuardian: forge verify-contract --num-of-optimizations 200 --chain-id",
block.chainid,
guardian,
string.concat(
"src/AccountGuardian.sol:AccountGuardian --constructor-args $(cast abi-encode \"constructor(address)\" ",
Strings.toHexString(tokenboundSafe),
")\n"
)
);
console.log(
"AccountV3Upgradable: forge verify-contract --num-of-optimizations 200 --chain-id",
block.chainid,
implementation,
string.concat(
"src/AccountV3Upgradable.sol:AccountV3Upgradable --constructor-args $(cast abi-encode \"constructor(address,address,address,address)\" ",
Strings.toHexString(erc4337EntryPoint),
" ",
Strings.toHexString(multicallForwarder),
" ",
Strings.toHexString(erc6551Registry),
" ",
Strings.toHexString(guardian),
")\n"
)
);
console.log(
"AccountProxy: forge verify-contract --num-of-optimizations 200 --chain-id",
block.chainid,
proxy,
string.concat(
"src/AccountProxy.sol:AccountProxy --constructor-args $(cast abi-encode \"constructor(address,address)\" ",
Strings.toHexString(guardian),
" ",
Strings.toHexString(implementation),
")\n"
)
);
}
}
17 changes: 0 additions & 17 deletions script/DeployGuardian.s.sol

This file was deleted.

Loading

0 comments on commit 4e34891

Please sign in to comment.