From 77e98a1c1d65900e99d0b2e9a152dd629812c94b Mon Sep 17 00:00:00 2001 From: gabrielstoica Date: Mon, 4 Nov 2024 17:49:03 +0200 Subject: [PATCH] fix: replace 'EntryPoint' import with 'IEntryPoint' to avoid versions incompatibility --- .../DeployDeterministicStationRegistry.s.sol | 4 ++-- src/Space.sol | 20 ++++++++++++++----- src/StationRegistry.sol | 8 ++++++-- test/Base.t.sol | 18 ++++++++++------- .../station-registry/constructor.t.sol | 7 ++++++- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/script/DeployDeterministicStationRegistry.s.sol b/script/DeployDeterministicStationRegistry.s.sol index 25deec1..07f1b59 100644 --- a/script/DeployDeterministicStationRegistry.s.sol +++ b/script/DeployDeterministicStationRegistry.s.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.26; import { BaseScript } from "./Base.s.sol"; import { StationRegistry } from "./../src/StationRegistry.sol"; import { ModuleKeeper } from "./../src/ModuleKeeper.sol"; -import { EntryPoint } from "@thirdweb/contracts/prebuilts/account/utils/Entrypoint.sol"; +import { IEntryPoint } from "@thirdweb/contracts/prebuilts/account/interface/IEntrypoint.sol"; /// @notice Deploys at deterministic addresses across chains an instance of {StationRegistry} /// @dev Reverts if any contract has already been deployed @@ -14,7 +14,7 @@ contract DeployDeterministicStationRegistry is BaseScript { function run( string memory create2Salt, address initialAdmin, - EntryPoint entrypoint, + IEntryPoint entrypoint, ModuleKeeper moduleKeeper ) public virtual broadcast returns (StationRegistry stationRegistry) { bytes32 salt = bytes32(abi.encodePacked(create2Salt)); diff --git a/src/Space.sol b/src/Space.sol index ca5c1b1..a97833e 100644 --- a/src/Space.sol +++ b/src/Space.sol @@ -163,7 +163,9 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager { } /// @inheritdoc ISpace - function withdrawNative(uint256 amount) public onlyAdminOrEntrypoint { + function withdrawNative( + uint256 amount + ) public onlyAdminOrEntrypoint { // Checks: the native balance of the space minus the amount locked for operations is greater than the requested amount if (amount > address(this).balance) revert Errors.InsufficientNativeToWithdraw(); @@ -177,7 +179,9 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager { } /// @inheritdoc IModuleManager - function enableModule(address module) public override onlyAdminOrEntrypoint { + function enableModule( + address module + ) public override onlyAdminOrEntrypoint { // Retrieve the address of the {ModuleKeeper} ModuleKeeper moduleKeeper = StationRegistry(factory).moduleKeeper(); @@ -186,7 +190,9 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager { } /// @inheritdoc IModuleManager - function disableModule(address module) public override onlyAdminOrEntrypoint { + function disableModule( + address module + ) public override onlyAdminOrEntrypoint { // Effects: disable the module _disableModule(module); } @@ -224,14 +230,18 @@ contract Space is ISpace, AccountCore, ERC1271, ModuleManager { } /// @inheritdoc ISpace - function getMessageHash(bytes32 _hash) public view returns (bytes32) { + function getMessageHash( + bytes32 _hash + ) public view returns (bytes32) { bytes32 messageHash = keccak256(abi.encode(_hash)); bytes32 typedDataHash = keccak256(abi.encode(MSG_TYPEHASH, messageHash)); return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), typedDataHash)); } /// @inheritdoc IERC165 - function supportsInterface(bytes4 interfaceId) public pure returns (bool) { + function supportsInterface( + bytes4 interfaceId + ) public pure returns (bool) { return interfaceId == type(ISpace).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC165).interfaceId; } diff --git a/src/StationRegistry.sol b/src/StationRegistry.sol index d7315d4..5aefdf7 100644 --- a/src/StationRegistry.sol +++ b/src/StationRegistry.sol @@ -111,7 +111,9 @@ contract StationRegistry is IStationRegistry, BaseAccountFactory, PermissionsEnu } /// @inheritdoc IStationRegistry - function updateModuleKeeper(ModuleKeeper newModuleKeeper) external onlyRole(DEFAULT_ADMIN_ROLE) { + function updateModuleKeeper( + ModuleKeeper newModuleKeeper + ) external onlyRole(DEFAULT_ADMIN_ROLE) { // Effects: update the {ModuleKeeper} address moduleKeeper = newModuleKeeper; @@ -124,7 +126,9 @@ contract StationRegistry is IStationRegistry, BaseAccountFactory, PermissionsEnu //////////////////////////////////////////////////////////////////////////*/ /// @inheritdoc IStationRegistry - function totalAccountsOfSigner(address signer) public view returns (uint256) { + function totalAccountsOfSigner( + address signer + ) public view returns (uint256) { return accountsOfSigner[signer].length(); } diff --git a/test/Base.t.sol b/test/Base.t.sol index 8834934..bafd1df 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -11,11 +11,11 @@ import { MockBadReceiver } from "./mocks/MockBadReceiver.sol"; import { Space } from "./../src/Space.sol"; import { ModuleKeeper } from "./../src/ModuleKeeper.sol"; import { StationRegistry } from "./../src/StationRegistry.sol"; -import { EntryPoint } from "@thirdweb/contracts/prebuilts/account/utils/Entrypoint.sol"; import { MockERC721Collection } from "./mocks/MockERC721Collection.sol"; import { MockERC1155Collection } from "./mocks/MockERC1155Collection.sol"; import { MockBadSpace } from "./mocks/MockBadSpace.sol"; import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol"; +import { IEntryPoint } from "@thirdweb/contracts/prebuilts/account/interface/IEntrypoint.sol"; abstract contract Base_Test is Test, Events { /*////////////////////////////////////////////////////////////////////////// @@ -28,7 +28,7 @@ abstract contract Base_Test is Test, Events { TEST CONTRACTS //////////////////////////////////////////////////////////////////////////*/ - EntryPoint internal entrypoint; + address internal entrypoint; StationRegistry internal stationRegistry; Space internal space; ModuleKeeper internal moduleKeeper; @@ -58,11 +58,11 @@ abstract contract Base_Test is Test, Events { users = Users({ admin: createUser("admin"), eve: createUser("eve"), bob: createUser("bob") }); // Deploy test contracts - entrypoint = new EntryPoint(); + //entrypoint = new EntryPoint(); moduleKeeper = new ModuleKeeper({ _initialOwner: users.admin }); - stationRegistry = new StationRegistry(users.admin, entrypoint, moduleKeeper); - containerImplementation = address(new Space(entrypoint, address(stationRegistry))); + stationRegistry = new StationRegistry(users.admin, IEntryPoint(entrypoint), moduleKeeper); + containerImplementation = address(new Space(IEntryPoint(entrypoint), address(stationRegistry))); mockModule = new MockModule(); mockNonCompliantSpace = new MockNonCompliantSpace({ _owner: users.admin }); @@ -126,7 +126,9 @@ abstract contract Base_Test is Test, Events { vm.stopPrank(); } - function allowlistModule(address _module) internal { + function allowlistModule( + address _module + ) internal { moduleKeeper.addToAllowlist({ module: _module }); } @@ -135,7 +137,9 @@ abstract contract Base_Test is Test, Events { //////////////////////////////////////////////////////////////////////////*/ /// @dev Generates a user, labels its address, and funds it with test assets - function createUser(string memory name) internal returns (address payable) { + function createUser( + string memory name + ) internal returns (address payable) { address payable user = payable(makeAddr(name)); vm.deal({ account: user, newBalance: 100 ether }); deal({ token: address(usdt), to: user, give: 10_000_000e18 }); diff --git a/test/unit/concrete/station-registry/constructor.t.sol b/test/unit/concrete/station-registry/constructor.t.sol index b789115..e88086b 100644 --- a/test/unit/concrete/station-registry/constructor.t.sol +++ b/test/unit/concrete/station-registry/constructor.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.26; import { StationRegistry } from "./../../../../src/StationRegistry.sol"; import { Base_Test } from "../../../Base.t.sol"; import { Constants } from "../../../utils/Constants.sol"; +import { IEntryPoint } from "@thirdweb/contracts/prebuilts/account/interface/IEntrypoint.sol"; contract Constructor_StationRegistry_Test is Base_Test { function setUp() public virtual override { @@ -12,7 +13,11 @@ contract Constructor_StationRegistry_Test is Base_Test { function test_Constructor() external { // Run the test - new StationRegistry({ _initialAdmin: users.admin, _entrypoint: entrypoint, _moduleKeeper: moduleKeeper }); + new StationRegistry({ + _initialAdmin: users.admin, + _entrypoint: IEntryPoint(entrypoint), + _moduleKeeper: moduleKeeper + }); // Assert the actual and expected {ModuleKeeper} address address actualModuleKeeper = address(stationRegistry.moduleKeeper());