Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changeRootValidator #114

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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