Skip to content

Commit

Permalink
refactor: remove safe dep, add precompiles
Browse files Browse the repository at this point in the history
  • Loading branch information
highskore committed Dec 9, 2024
1 parent 3ff7014 commit fe2f834
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@prb/math": "^4.1.0",
"@rhinestone/erc4337-validation": "^0.0.4",
"@rhinestone/sentinellist": "github:rhinestonewtf/sentinellist",
"@safe-global/safe-contracts": "^1.4.1",
"ds-test": "github:dapphub/ds-test",
"excessively-safe-call": "github:nomad-xyz/ExcessivelySafeCall",
"forge-std": "github:foundry-rs/forge-std",
Expand Down
12 changes: 0 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ account-abstraction/=node_modules/@ERC4337/account-abstraction/contracts/
account-abstraction-v0.6/=node_modules/@ERC4337/account-abstraction-v0.6/contracts/
modulekit/=node_modules/@rhinestone/modulekit/src/
@openzeppelin/=node_modules/@openzeppelin/
@safe-global/=node_modules/@safe-global/
ds-test/=node_modules/ds-test/src/
forge-std/=node_modules/forge-std/src/
solady/=node_modules/solady/src/
Expand Down
17 changes: 6 additions & 11 deletions src/accounts/safe/SafeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import {
ISafe7579Launchpad, ModuleInit
} from "../../accounts/safe/interfaces/ISafe7579Launchpad.sol";
import { IAccountFactory } from "../../accounts/factory/interface/IAccountFactory.sol";

// External dependencies
import { Safe } from "@safe-global/safe-contracts/contracts/Safe.sol";
import { SafeProxy } from "@safe-global/safe-contracts/contracts/proxies/SafeProxy.sol";
import { SafeProxyFactory } from
"@safe-global/safe-contracts/contracts/proxies/SafeProxyFactory.sol";
import { ISafeProxyFactory } from "./interfaces/ISafeProxyFactory.sol";

// Utils
import { ENTRYPOINT_ADDR } from "../../deployment/predeploy/EntryPoint.sol";
Expand All @@ -27,14 +22,14 @@ contract SafeFactory is IAccountFactory, Safe7579Precompiles {
// singletons
ISafe7579 internal safe7579;
ISafe7579Launchpad internal launchpad;
Safe internal safeSingleton;
SafeProxyFactory internal safeProxyFactory;
address internal safeSingleton;
ISafeProxyFactory internal safeProxyFactory;

function init() public override {
safe7579 = deploySafe7579();
launchpad = deploySafe7579Launchpad(ENTRYPOINT_ADDR, REGISTRY_ADDR);
safeSingleton = new Safe();
safeProxyFactory = new SafeProxyFactory();
safeSingleton = deploySafeSingleton();
safeProxyFactory = deploySafeProxyFactory();
}

function createAccount(
Expand Down Expand Up @@ -78,7 +73,7 @@ contract SafeFactory is IAccountFactory, Safe7579Precompiles {
return launchpad.predictSafeAddress({
singleton: address(launchpad),
safeProxyFactory: address(safeProxyFactory),
creationCode: type(SafeProxy).creationCode,
creationCode: SAFE_PROXY_BYTECODE,
salt: salt,
factoryInitializer: factoryInitializer
});
Expand Down
33 changes: 33 additions & 0 deletions src/accounts/safe/interfaces/ISafeProxyFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

Check failure on line 2 in src/accounts/safe/interfaces/ISafeProxyFactory.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Compiler version >=0.7.0 <0.9.0 does not satisfy the >=0.8.0 semver requirement

interface ISafeProxyFactory {
function proxyCreationCode() external pure returns (bytes memory);

function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
)
external
returns (address proxy);

function createChainSpecificProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
)
external
returns (address proxy);

function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
address callback
)
external
returns (address proxy);

function getChainId() external view returns (uint256);
}
17 changes: 17 additions & 0 deletions src/deployment/precompiles/Safe7579Precompiles.sol

Large diffs are not rendered by default.

0 comments on commit fe2f834

Please sign in to comment.