Skip to content

Commit

Permalink
changeRootValidator (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
leekt authored May 8, 2024
1 parent 10c0997 commit 51e935d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Kernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,28 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
_installValidation(_rootValidator, config, validatorData, hookData);
}

function changeRootValidator(
ValidationId _rootValidator,
IHook hook,
bytes calldata validatorData,
bytes calldata hookData
) external payable onlyEntryPointOrSelfOrRoot {
ValidationStorage storage vs = _validationStorage();
if (ValidationId.unwrap(_rootValidator) == bytes21(0)) {
revert InvalidValidator();
}
ValidationType vType = ValidatorLib.getType(_rootValidator);
if (vType != VALIDATION_TYPE_VALIDATOR && vType != VALIDATION_TYPE_PERMISSION) {
revert InvalidValidationType();
}
_setRootValidator(_rootValidator);
if (_validationStorage().validationConfig[_rootValidator].hook == IHook(address(0))) {
// when new rootValidator is not installed yet
ValidationConfig memory config = ValidationConfig({nonce: uint32(vs.currentNonce), hook: hook});
_installValidation(_rootValidator, config, validatorData, hookData);
}
}

function upgradeTo(address _newImplementation) external payable onlyEntryPointOrSelfOrRoot {
assembly {
sstore(ERC1967_IMPLEMENTATION_SLOT, _newImplementation)
Expand Down

0 comments on commit 51e935d

Please sign in to comment.