Skip to content

Commit

Permalink
Merge pull request #166 from rhinestonewtf/fix/via-ir
Browse files Browse the repository at this point in the history
fix: make --via-ir build work
  • Loading branch information
highskore authored Dec 9, 2024
2 parents 85be53f + d397e37 commit ab4ab5d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 25 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ jobs:
cp node_modules/@rhinestone/modulekit/remappings.txt remappings.txt
forge build
- name: Run via-ir test
run: |
mkdir test-via-ir
cd test-via-ir
pnpm init
pnpm install "../${{ env.package }}" --shamefully-hoist
mkdir -p src
echo 'import "modulekit/ModuleKit.sol";' > src/TestImport.sol
echo '[profile.default]
evm_version = "cancun"
src = "src"
out = "out"
libs = ["node_modules"]' > foundry.toml
cp node_modules/@rhinestone/modulekit/remappings.txt remappings.txt
forge build --via-ir
- name: Clean up
run: |
rm "${{ env.package }}"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"",
"test": "forge test",
"test:lite": "FOUNDRY_PROFILE=lite forge test",
"test:via-ir": "forge test --via-ir",
"test:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge test",
"test:accounts": "forge test && ACCOUNT_TYPE=SAFE forge test && ACCOUNT_TYPE=KERNEL forge test && ACCOUNT_TYPE=NEXUS forge test",
"changeset": "changeset",
Expand All @@ -32,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: MIT
pragma solidity >=0.8.23 <0.9.0;

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 ab4ab5d

Please sign in to comment.