Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
allow call external contract
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will committed Feb 22, 2024
1 parent 011ddca commit bf947d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
4 changes: 0 additions & 4 deletions contracts/AccessController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ contract AccessController is IAccessController, Governable {
/// @param func The function selector of `to` that can be called by the `signer` on behalf of the `ipAccount`
// solhint-disable code-complexity
function checkPermission(address ipAccount, address signer, address to, bytes4 func) external view whenNotPaused {
// ipAccount can only call registered modules or set Permissions
if (to != address(this) && !IModuleRegistry(MODULE_REGISTRY).isRegistered(to)) {
revert Errors.AccessController__RecipientIsNotRegisteredModule(to);
}
// Must be a valid IPAccount
if (!IIPAccountRegistry(IP_ACCOUNT_REGISTRY).isIpAccount(ipAccount)) {
revert Errors.AccessController__IPAccountIsNotValid(ipAccount);
Expand Down
11 changes: 2 additions & 9 deletions test/foundry/AccessController.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,6 @@ contract AccessControllerTest is BaseTest {
AccessPermission.ALLOW
)
);
vm.expectRevert(
abi.encodeWithSelector(Errors.AccessController__RecipientIsNotRegisteredModule.selector, address(0xbeef))
);
accessController.checkPermission(
address(ipAccount),
signer,
address(0xbeef), // instead of address(mockModule)
mockModule.executeSuccessfully.selector
);

vm.expectRevert(abi.encodeWithSelector(Errors.AccessController__IPAccountIsNotValid.selector, address(0xbeef)));
accessController.checkPermission(
Expand All @@ -195,6 +186,8 @@ contract AccessControllerTest is BaseTest {
);
}



function test_AccessController_functionPermissionWildcardAllow() public {
moduleRegistry.registerModule("MockModule", address(mockModule));
address signer = vm.addr(2);
Expand Down
12 changes: 4 additions & 8 deletions test/foundry/access/AccessControlled.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,17 @@ contract AccessControlledTest is BaseTest {
mockModule.ipAccountOrPermissionFunction(address(ipAccount), "test", true);
}

function test_AccessControlled_revert_callIpAccountOrPermissionFunction_nonRegisteredModule() public {
function test_AccessControlled_callIpAccountOrPermissionFunction_nonRegisteredModule() public {
MockAccessControlledModule nonRegisteredModule = new MockAccessControlledModule(
address(accessController),
address(ipAccountRegistry),
address(moduleRegistry),
"NonRegisteredMockAccessControlledModule"
);
vm.expectRevert(
abi.encodeWithSelector(
Errors.AccessController__RecipientIsNotRegisteredModule.selector,
address(nonRegisteredModule)
)
);

vm.prank(owner);
nonRegisteredModule.ipAccountOrPermissionFunction(address(ipAccount), "test", true);
string memory result = nonRegisteredModule.ipAccountOrPermissionFunction(address(ipAccount), "test", true);
assertEq("test", result);
}

function test_AccessControlled_revert_callIpAccountOrPermissionFunction_passInNonIpAccount() public {
Expand Down

0 comments on commit bf947d1

Please sign in to comment.