Skip to content

Commit

Permalink
feat: disable validators on removal
Browse files Browse the repository at this point in the history
This matches the behaviour of the hook
  • Loading branch information
cpb8010 committed Dec 5, 2024
1 parent 0f083e5 commit 2c6e0d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/managers/HookManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ abstract contract HookManager is IHookManager, Auth {
_executionHooksLinkedList().remove(hook);
}

(bool success, ) = hook.excessivelySafeCall(gasleft(), 0, abi.encodeWithSelector(IInitable.disable.selector));
(success); // silence unused local variable warning
hook.excessivelySafeCall(gasleft(), 0, abi.encodeWithSelector(IInitable.disable.selector));

emit RemoveHook(hook);
}
Expand Down
6 changes: 6 additions & 0 deletions src/managers/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
pragma solidity ^0.8.24;

import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import { ExcessivelySafeCall } from "@nomad-xyz/excessively-safe-call/src/ExcessivelySafeCall.sol";

import { Auth } from "../auth/Auth.sol";
import { Errors } from "../libraries/Errors.sol";
import { SsoStorage } from "../libraries/SsoStorage.sol";
import { IInitable } from "../interfaces/IInitable.sol";
import { AddressLinkedList } from "../libraries/LinkedList.sol";
import { IValidatorManager } from "../interfaces/IValidatorManager.sol";
import { IModuleValidator } from "../interfaces/IModuleValidator.sol";
Expand All @@ -21,6 +23,8 @@ abstract contract ValidatorManager is IValidatorManager, Auth {
using AddressLinkedList for mapping(address => address);
// Interface helper library
using ERC165Checker for address;
// Low level calls helper library
using ExcessivelySafeCall for address;

function addModuleValidator(address validator, bytes memory initialAccountValidationKey) external onlySelf {
_addModuleValidator(validator, initialAccountValidationKey);
Expand Down Expand Up @@ -55,6 +59,8 @@ abstract contract ValidatorManager is IValidatorManager, Auth {
function _removeModuleValidator(address validator) internal {
_moduleValidatorsLinkedList().remove(validator);

validator.excessivelySafeCall(gasleft(), 0, abi.encodeWithSelector(IInitable.disable.selector));

emit RemoveModuleValidator(validator);
}

Expand Down
9 changes: 5 additions & 4 deletions src/validators/WebAuthValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ contract WebAuthValidator is VerifierCaller, IModuleValidator {
return _addValidationKey(key);
}

// There's no mapping from account address to domains,
// so there's no way to just delete all the keys
// We can only disconnect the module from the account,
// re-linking it will allow any previous keys
function disable() external {
// There's no mapping from account address to domains,
// so there's no way to just delete all the keys
// We can only disconnect the module from the account,
// re-linking it will allow any previous keys
require(false, "Cannot disable module without removing it from account");
}

function _addValidationKey(bytes memory key) internal returns (bool) {
Expand Down

0 comments on commit 2c6e0d4

Please sign in to comment.