Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Sep 24, 2024
1 parent 35499cf commit 2b08ee8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/SafeSingletonDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {VmSafe} from "forge-std/Vm.sol";
import {Vm} from "forge-std/Vm.sol";

/// @notice Library for deploying contracts using Safe's Singleton Factory
/// https://github.com/safe-global/safe-singleton-factory
Expand All @@ -14,7 +14,7 @@ library SafeSingletonDeployer {
bytes constant factoryCode =
hex"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3";

VmSafe private constant VM = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Vm private constant VM = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

function computeAddress(bytes memory creationCode, bytes32 salt) public pure returns (address) {
return computeAddress(creationCode, "", salt);
Expand Down Expand Up @@ -98,9 +98,9 @@ library SafeSingletonDeployer {
return keccak256(abi.encodePacked(creationCode, args));
}

function prepareAnvil() {
function prepareAnvil() public {
if (block.chainid == 31337) {
vm.etch(SafeSingletonDeployer.SAFE_SINGLETON_FACTORY, factoryCode);
VM.etch(SafeSingletonDeployer.SAFE_SINGLETON_FACTORY, factoryCode);
}
}
}
7 changes: 5 additions & 2 deletions test/SafeSingletonDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {MockReverting} from "./MockReverting.sol";

contract SafeSingletonDeployerTest is Test {
function test_deploy_createsAtExpectedAddress() public {
address expectedAddress =
SafeSingletonDeployer.computeAddress(type(Mock).creationCode, abi.encode(1), bytes32("0x1234"));
address expectedAddress = SafeSingletonDeployer.computeAddress(
type(Mock).creationCode,
abi.encode(1),
bytes32("0x1234")
);
assertEq(expectedAddress.code, "");
address returnAddress = SafeSingletonDeployer.deploy({
creationCode: type(Mock).creationCode,
Expand Down

0 comments on commit 2b08ee8

Please sign in to comment.