@@ -44,6 +44,8 @@ import {
4444 MAGIC_VALUE_SIG_REPLAYABLE
4545} from "./types/Constants.sol " ;
4646
47+ import {InstallExecutorDataFormat, InstallFallbackDataFormat, InstallValidatorDataFormat} from "./types/Structs.sol " ;
48+
4749contract Kernel is IAccount , IAccountExecute , IERC7579Account , ValidationManager {
4850 error ExecutionReverted ();
4951 error InvalidExecutor ();
@@ -357,45 +359,30 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
357359 }
358360 ValidationConfig memory config =
359361 ValidationConfig ({nonce: vs.currentNonce, hook: IHook (address (bytes20 (initData[0 :20 ])))});
360- bytes calldata validatorData;
361- bytes calldata hookData;
362- bytes calldata selectorData;
362+ InstallValidatorDataFormat calldata data;
363363 assembly {
364- validatorData.offset := add (add (initData.offset, 52 ), calldataload (add (initData.offset, 20 )))
365- validatorData.length := calldataload (sub (validatorData.offset, 32 ))
366- hookData.offset := add (add (initData.offset, 52 ), calldataload (add (initData.offset, 52 )))
367- hookData.length := calldataload (sub (hookData.offset, 32 ))
368- selectorData.offset := add (add (initData.offset, 52 ), calldataload (add (initData.offset, 84 )))
369- selectorData.length := calldataload (sub (selectorData.offset, 32 ))
364+ data := add (initData.offset, 20 )
370365 }
371- _installValidation (vId, config, validatorData, hookData);
372- if (selectorData.length == 4 ) {
366+ _installValidation (vId, config, data. validatorData, data. hookData);
367+ if (data. selectorData.length == 4 ) {
373368 // NOTE: we don't allow configure on selector data on v3.1+, but using bytes instead of bytes4 for selector data to make sure we are future proof
374- _setSelector (vId, bytes4 (selectorData[0 :4 ]), true );
369+ _setSelector (vId, bytes4 (data. selectorData[0 :4 ]), true );
375370 }
376371 } else if (moduleType == MODULE_TYPE_EXECUTOR) {
377- bytes calldata executorData;
378- bytes calldata hookData;
372+ InstallExecutorDataFormat calldata data;
379373 assembly {
380- executorData.offset := add (add (initData.offset, 52 ), calldataload (add (initData.offset, 20 )))
381- executorData.length := calldataload (sub (executorData.offset, 32 ))
382- hookData.offset := add (add (initData.offset, 52 ), calldataload (add (initData.offset, 52 )))
383- hookData.length := calldataload (sub (hookData.offset, 32 ))
374+ data := add (initData.offset, 20 )
384375 }
385376 IHook hook = IHook (address (bytes20 (initData[0 :20 ])));
386- _installExecutor (IExecutor (module), executorData, hook);
387- _installHook (hook, hookData);
377+ _installExecutor (IExecutor (module), data. executorData, hook);
378+ _installHook (hook, data. hookData);
388379 } else if (moduleType == MODULE_TYPE_FALLBACK) {
389- bytes calldata selectorData;
390- bytes calldata hookData;
380+ InstallFallbackDataFormat calldata data;
391381 assembly {
392- selectorData.offset := add (add (initData.offset, 56 ), calldataload (add (initData.offset, 24 )))
393- selectorData.length := calldataload (sub (selectorData.offset, 32 ))
394- hookData.offset := add (add (initData.offset, 56 ), calldataload (add (initData.offset, 56 )))
395- hookData.length := calldataload (sub (hookData.offset, 32 ))
382+ data := add (initData.offset, 24 )
396383 }
397- _installSelector (bytes4 (initData[0 :4 ]), module, IHook (address (bytes20 (initData[4 :24 ]))), selectorData);
398- _installHook (IHook (address (bytes20 (initData[4 :24 ]))), hookData);
384+ _installSelector (bytes4 (initData[0 :4 ]), module, IHook (address (bytes20 (initData[4 :24 ]))), data. selectorData);
385+ _installHook (IHook (address (bytes20 (initData[4 :24 ]))), data. hookData);
399386 } else if (moduleType == MODULE_TYPE_HOOK) {
400387 // force call onInstall for hook
401388 // NOTE: for hook, kernel does not support independent hook install,
0 commit comments