creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/CallPolicy.sol": {
        "content": "pragma solidity ^0.8.0;\n\nimport \"kernel/sdk/moduleBase/PolicyBase.sol\";\nimport \"kernel/utils/ExecLib.sol\";\nimport {IERC7579Account} from \"kernel/interfaces/IERC7579Account.sol\";\n\nstruct Permission {\n    CallType callType; // calltype can be CALLTYPE_SINGLE/CALLTYPE_DELEGATECALL\n    address target;\n    bytes4 selector;\n    uint256 valueLimit;\n    ParamRule[] rules;\n}\n\nstruct ParamRule {\n    ParamCondition condition;\n    uint64 offset;\n    bytes32 param;\n}\n\nenum ParamCondition {\n    EQUAL,\n    GREATER_THAN,\n    LESS_THAN,\n    GREATER_THAN_OR_EQUAL,\n    LESS_THAN_OR_EQUAL,\n    NOT_EQUAL\n}\n\nenum Status {\n    NA,\n    Live,\n    Deprecated\n}\n\ncontract CallPolicy is PolicyBase {\n    error InvalidCallType();\n    error CallViolatesParamRule();\n    error CallViolatesValueRule();\n    mapping(address => uint256) public usedIds;\n    mapping(bytes32 id => mapping(address => Status)) public status;\n    mapping(bytes32 id => mapping(bytes32 permissionHash => mapping(address => bytes))) public encodedPermissions;\n\n    function isInitialized(address wallet) external view override returns (bool) {\n        return usedIds[wallet] > 0;\n    }\n\n    function checkUserOpPolicy(bytes32 id, PackedUserOperation calldata userOp)\n        external\n        payable\n        override\n        returns (uint256)\n    {\n        require(bytes4(userOp.callData[0:4]) == IERC7579Account.execute.selector);\n        ExecMode mode = ExecMode.wrap(bytes32(userOp.callData[4:36]));\n        (CallType callType, ExecType execType,,) = ExecLib.decode(mode);\n        bytes calldata executionCallData = userOp.callData; // Cache calldata here\n        assembly {\n            executionCallData.offset := add(add(executionCallData.offset, 0x24), calldataload(add(executionCallData.offset, 0x24)))\n            executionCallData.length := calldataload(sub(executionCallData.offset, 0x20))\n        }\n        if(callType == CALLTYPE_SINGLE) {\n            (address target, uint256 value, bytes calldata callData) = ExecLib.decodeSingle(executionCallData);\n            bool permissionPass = _checkPermission(msg.sender, id, CALLTYPE_SINGLE, target, callData, value);\n            if(!permissionPass) {\n                revert CallViolatesParamRule();\n            }\n        } else if(callType == CALLTYPE_BATCH) {\n            Execution[] calldata exec = ExecLib.decodeBatch(executionCallData);\n            for(uint256 i = 0; i < exec.length; i++) {\n                bool permissionPass = _checkPermission(msg.sender, id, CALLTYPE_SINGLE, exec[i].target, exec[i].callData, exec[i].value);\n                if(!permissionPass) {\n                    revert CallViolatesParamRule();\n                }\n            }\n        } else if(callType == CALLTYPE_DELEGATECALL) {\n            (address target, uint256 value, bytes calldata callData) = ExecLib.decodeSingle(executionCallData);\n            bool permissionPass = _checkPermission(msg.sender, id, CALLTYPE_DELEGATECALL, target, callData, value);\n            if(!permissionPass) {\n                revert CallViolatesParamRule();\n            }\n        } else {\n            revert InvalidCallType();\n        }\n    }\n\n    function _checkPermission(address wallet, bytes32 id, CallType callType, address target, bytes calldata data, uint256 value) internal returns(bool){\n        bytes32 permissionHash = keccak256(abi.encodePacked(callType, target, bytes4(data[0:4])));\n        (uint256 allowedValue, ParamRule[] memory rules) = abi.decode(encodedPermissions[id][permissionHash][wallet], (uint256, ParamRule[]));\n        if(value > allowedValue) {\n            revert CallViolatesValueRule();\n        }\n        for (uint256 i = 0; i < rules.length; i++) {\n            ParamRule memory rule = rules[i];\n            bytes32 param = bytes32(data[4 + rule.offset:4 + rule.offset + 32]);\n            if (rule.condition == ParamCondition.EQUAL && param != rule.param) {\n                return false;\n            } else if (rule.condition == ParamCondition.GREATER_THAN && param <= rule.param) {\n                return false;\n            } else if (rule.condition == ParamCondition.LESS_THAN && param >= rule.param) {\n                return false;\n            } else if (rule.condition == ParamCondition.GREATER_THAN_OR_EQUAL && param < rule.param) {\n                return false;\n            } else if (rule.condition == ParamCondition.LESS_THAN_OR_EQUAL && param > rule.param) {\n                return false;\n            } else if (rule.condition == ParamCondition.NOT_EQUAL && param == rule.param) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    function checkSignaturePolicy(bytes32 id, address sender, bytes32 hash, bytes calldata sig)\n        external\n        view\n        override\n        returns (uint256)\n    {\n        require(status[id][msg.sender] == Status.Live);\n        return 0;\n    }\n\n    function _parsePermission(bytes calldata _sig) internal pure returns(Permission[] calldata permissions) {\n        assembly {\n            permissions.offset := add(add(_sig.offset,32), calldataload(_sig.offset))\n            permissions.length := calldataload(sub(permissions.offset, 32))\n        }\n    }\n\n\n    function _policyOninstall(bytes32 id, bytes calldata _data) internal override {\n        require(status[id][msg.sender] == Status.NA);\n        Permission[] calldata permissions = _parsePermission(_data);\n        for(uint256 i = 0; i<permissions.length; i++) {\n            bytes32 permissionHash = keccak256(abi.encodePacked(permissions[i].callType, permissions[i].target, permissions[i].selector));\n            require(encodedPermissions[id][permissionHash][msg.sender].length == 0, \"duplicate permissionHash\");\n            encodedPermissions[id][permissionHash][msg.sender] = abi.encode(permissions[i].valueLimit, permissions[i].rules);\n        }\n        status[id][msg.sender] = Status.Live;\n        usedIds[msg.sender]++;\n    }\n\n    function _policyOnUninstall(bytes32 id, bytes calldata _data) internal override {\n        require(status[id][msg.sender] == Status.Live);\n        //delete encodedPermissions[id][msg.sender];\n        status[id][msg.sender] = Status.Deprecated;\n        usedIds[msg.sender]--;\n    }\n}\n"
      },
      "lib/kernel_v3/src/sdk/moduleBase/PolicyBase.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IPolicy} from \"../../interfaces/IERC7579Modules.sol\";\nimport {PackedUserOperation} from \"../../interfaces/PackedUserOperation.sol\";\n\nabstract contract PolicyBase is IPolicy {\n    function onInstall(bytes calldata data) external payable {\n        bytes32 id = bytes32(data[0:32]);\n        bytes calldata _data = data[32:];\n        _policyOninstall(id, _data);\n    }\n\n    function onUninstall(bytes calldata data) external payable {\n        bytes32 id = bytes32(data[0:32]);\n        bytes calldata _data = data[32:];\n        _policyOnUninstall(id, _data);\n    }\n\n    function isModuleType(uint256 id) external pure returns (bool) {\n        return id == 5;\n    }\n\n    function isInitialized(address) external view virtual returns (bool); // TODO : not sure if this is the right way to do it\n    function checkUserOpPolicy(bytes32 id, PackedUserOperation calldata userOp)\n        external\n        payable\n        virtual\n        returns (uint256);\n    function checkSignaturePolicy(bytes32 id, address sender, bytes32 hash, bytes calldata sig)\n        external\n        view\n        virtual\n        returns (uint256);\n\n    function _policyOninstall(bytes32 id, bytes calldata _data) internal virtual;\n    function _policyOnUninstall(bytes32 id, bytes calldata _data) internal virtual;\n}\n"
      },
      "lib/kernel_v3/src/utils/ExecLib.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.23;\n\nimport {ExecMode, CallType, ExecType, ExecModeSelector, ExecModePayload} from \"../types/Types.sol\";\nimport {\n    CALLTYPE_SINGLE,\n    CALLTYPE_BATCH,\n    EXECTYPE_DEFAULT,\n    EXEC_MODE_DEFAULT,\n    EXECTYPE_TRY,\n    CALLTYPE_DELEGATECALL\n} from \"../types/Constants.sol\";\nimport {Execution} from \"../types/Structs.sol\";\n\n/**\n * @dev ExecLib is a helper library for execution\n */\nlibrary ExecLib {\n    error ExecutionFailed();\n\n    event TryExecuteUnsuccessful(uint256 batchExecutionindex, bytes result);\n\n    function _execute(ExecMode execMode, bytes calldata executionCalldata)\n        internal\n        returns (bytes[] memory returnData)\n    {\n        (CallType callType, ExecType execType,,) = decode(execMode);\n\n        // check if calltype is batch or single\n        if (callType == CALLTYPE_BATCH) {\n            // destructure executionCallData according to batched exec\n            Execution[] calldata executions = decodeBatch(executionCalldata);\n            // check if execType is revert or try\n            if (execType == EXECTYPE_DEFAULT) returnData = _execute(executions);\n            else if (execType == EXECTYPE_TRY) returnData = _tryExecute(executions);\n            else revert(\"Unsupported\");\n        } else if (callType == CALLTYPE_SINGLE) {\n            // destructure executionCallData according to single exec\n            (address target, uint256 value, bytes calldata callData) = decodeSingle(executionCalldata);\n            returnData = new bytes[](1);\n            bool success;\n            // check if execType is revert or try\n            if (execType == EXECTYPE_DEFAULT) {\n                returnData[0] = _execute(target, value, callData);\n            } else if (execType == EXECTYPE_TRY) {\n                (success, returnData[0]) = _tryExecute(target, value, callData);\n                if (!success) emit TryExecuteUnsuccessful(0, returnData[0]);\n            } else {\n                revert(\"Unsupported\");\n            }\n        } else if (callType == CALLTYPE_DELEGATECALL) {\n            address delegate = address(bytes20(executionCalldata[0:20]));\n            bytes calldata callData = executionCalldata[20:];\n            _executeDelegatecall(delegate, callData);\n        } else {\n            revert(\"Unsupported\");\n        }\n    }\n\n    function _execute(Execution[] calldata executions) internal returns (bytes[] memory result) {\n        uint256 length = executions.length;\n        result = new bytes[](length);\n\n        for (uint256 i; i < length; i++) {\n            Execution calldata _exec = executions[i];\n            result[i] = _execute(_exec.target, _exec.value, _exec.callData);\n        }\n    }\n\n    function _tryExecute(Execution[] calldata executions) internal returns (bytes[] memory result) {\n        uint256 length = executions.length;\n        result = new bytes[](length);\n\n        for (uint256 i; i < length; i++) {\n            Execution calldata _exec = executions[i];\n            bool success;\n            (success, result[i]) = _tryExecute(_exec.target, _exec.value, _exec.callData);\n            if (!success) emit TryExecuteUnsuccessful(i, result[i]);\n        }\n    }\n\n    function _execute(address target, uint256 value, bytes calldata callData) internal returns (bytes memory result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := mload(0x40)\n            calldatacopy(result, callData.offset, callData.length)\n            if iszero(call(gas(), target, value, result, callData.length, codesize(), 0x00)) {\n                // Bubble up the revert if the call reverts.\n                returndatacopy(result, 0x00, returndatasize())\n                revert(result, returndatasize())\n            }\n            mstore(result, returndatasize()) // Store the length.\n            let o := add(result, 0x20)\n            returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.\n            mstore(0x40, add(o, returndatasize())) // Allocate the memory.\n        }\n    }\n\n    function _tryExecute(address target, uint256 value, bytes calldata callData)\n        internal\n        returns (bool success, bytes memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := mload(0x40)\n            calldatacopy(result, callData.offset, callData.length)\n            success := call(gas(), target, value, result, callData.length, codesize(), 0x00)\n            mstore(result, returndatasize()) // Store the length.\n            let o := add(result, 0x20)\n            returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.\n            mstore(0x40, add(o, returndatasize())) // Allocate the memory.\n        }\n    }\n\n    /// @dev Execute a delegatecall with `delegate` on this account.\n    function _executeDelegatecall(address delegate, bytes calldata callData)\n        internal\n        returns (bool success, bytes memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := mload(0x40)\n            calldatacopy(result, callData.offset, callData.length)\n            // Forwards the `data` to `delegate` via delegatecall.\n            success := delegatecall(gas(), delegate, result, callData.length, codesize(), 0x00)\n            mstore(result, returndatasize()) // Store the length.\n            let o := add(result, 0x20)\n            returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.\n            mstore(0x40, add(o, returndatasize())) // Allocate the memory.\n        }\n    }\n\n    function decode(ExecMode mode)\n        internal\n        pure\n        returns (CallType _calltype, ExecType _execType, ExecModeSelector _modeSelector, ExecModePayload _modePayload)\n    {\n        assembly {\n            _calltype := mode\n            _execType := shl(8, mode)\n            _modeSelector := shl(48, mode)\n            _modePayload := shl(80, mode)\n        }\n    }\n\n    function encode(CallType callType, ExecType execType, ExecModeSelector mode, ExecModePayload payload)\n        internal\n        pure\n        returns (ExecMode)\n    {\n        return ExecMode.wrap(\n            bytes32(abi.encodePacked(callType, execType, bytes4(0), ExecModeSelector.unwrap(mode), payload))\n        );\n    }\n\n    function encodeSimpleBatch() internal pure returns (ExecMode mode) {\n        mode = encode(CALLTYPE_BATCH, EXECTYPE_DEFAULT, EXEC_MODE_DEFAULT, ExecModePayload.wrap(0x00));\n    }\n\n    function encodeSimpleSingle() internal pure returns (ExecMode mode) {\n        mode = encode(CALLTYPE_SINGLE, EXECTYPE_DEFAULT, EXEC_MODE_DEFAULT, ExecModePayload.wrap(0x00));\n    }\n\n    function getCallType(ExecMode mode) internal pure returns (CallType calltype) {\n        assembly {\n            calltype := mode\n        }\n    }\n\n    function decodeBatch(bytes calldata callData) internal pure returns (Execution[] calldata executionBatch) {\n        /*\n         * Batch Call Calldata Layout\n         * Offset (in bytes)    | Length (in bytes) | Contents\n         * 0x0                  | 0x4               | bytes4 function selector\n        *  0x4                  | -                 |\n        abi.encode(IERC7579Execution.Execution[])\n         */\n        // solhint-disable-next-line no-inline-assembly\n        assembly (\"memory-safe\") {\n            let dataPointer := add(callData.offset, calldataload(callData.offset))\n\n            // Extract the ERC7579 Executions\n            executionBatch.offset := add(dataPointer, 32)\n            executionBatch.length := calldataload(dataPointer)\n        }\n    }\n\n    function encodeBatch(Execution[] memory executions) internal pure returns (bytes memory callData) {\n        callData = abi.encode(executions);\n    }\n\n    function decodeSingle(bytes calldata executionCalldata)\n        internal\n        pure\n        returns (address target, uint256 value, bytes calldata callData)\n    {\n        target = address(bytes20(executionCalldata[0:20]));\n        value = uint256(bytes32(executionCalldata[20:52]));\n        callData = executionCalldata[52:];\n    }\n\n    function encodeSingle(address target, uint256 value, bytes memory callData)\n        internal\n        pure\n        returns (bytes memory userOpCalldata)\n    {\n        userOpCalldata = abi.encodePacked(target, value, callData);\n    }\n}\n"
      },
      "lib/kernel_v3/src/interfaces/IERC7579Account.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.21;\n\nimport {CallType, ExecType, ExecMode} from \"../utils/ExecLib.sol\";\nimport {PackedUserOperation} from \"./PackedUserOperation.sol\";\n\nstruct Execution {\n    address target;\n    uint256 value;\n    bytes callData;\n}\n\ninterface IERC7579Account {\n    event ModuleInstalled(uint256 moduleTypeId, address module);\n    event ModuleUninstalled(uint256 moduleTypeId, address module);\n\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     *         This function is intended to be called by ERC-4337 EntryPoint.sol\n     * @dev Ensure adequate authorization control: i.e. onlyEntryPointOrSelf\n     *\n     * @dev MSA MUST implement this function signature.\n     * If a mode is requested that is not supported by the Account, it MUST revert\n     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details\n     * @param executionCalldata The encoded execution call data\n     */\n    function execute(ExecMode mode, bytes calldata executionCalldata) external payable;\n\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     *         This function is intended to be called by Executor Modules\n     * @dev Ensure adequate authorization control: i.e. onlyExecutorModule\n     *\n     * @dev MSA MUST implement this function signature.\n     * If a mode is requested that is not supported by the Account, it MUST revert\n     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details\n     * @param executionCalldata The encoded execution call data\n     */\n    function executeFromExecutor(ExecMode mode, bytes calldata executionCalldata)\n        external\n        payable\n        returns (bytes[] memory returnData);\n\n    /**\n     * @dev ERC-1271 isValidSignature\n     *         This function is intended to be used to validate a smart account signature\n     * and may forward the call to a validator module\n     *\n     * @param hash The hash of the data that is signed\n     * @param data The data that is signed\n     */\n    function isValidSignature(bytes32 hash, bytes calldata data) external view returns (bytes4);\n\n    /**\n     * @dev installs a Module of a certain type on the smart account\n     * @dev Implement Authorization control of your chosing\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     * @param module the module address\n     * @param initData arbitrary data that may be required on the module during `onInstall`\n     * initialization.\n     */\n    function installModule(uint256 moduleTypeId, address module, bytes calldata initData) external payable;\n\n    /**\n     * @dev uninstalls a Module of a certain type on the smart account\n     * @dev Implement Authorization control of your chosing\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     * @param module the module address\n     * @param deInitData arbitrary data that may be required on the module during `onUninstall`\n     * de-initialization.\n     */\n    function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData) external payable;\n\n    /**\n     * Function to check if the account supports a certain CallType or ExecType (see ModeLib.sol)\n     * @param encodedMode the encoded mode\n     */\n    function supportsExecutionMode(ExecMode encodedMode) external view returns (bool);\n\n    /**\n     * Function to check if the account supports installation of a certain module type Id\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     */\n    function supportsModule(uint256 moduleTypeId) external view returns (bool);\n\n    /**\n     * Function to check if the account has a certain module installed\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     *      Note: keep in mind that some contracts can be multiple module types at the same time. It\n     *            thus may be necessary to query multiple module types\n     * @param module the module address\n     * @param additionalContext additional context data that the smart account may interpret to\n     *                          identifiy conditions under which the module is installed.\n     *                          usually this is not necessary, but for some special hooks that\n     *                          are stored in mappings, this param might be needed\n     */\n    function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext)\n        external\n        view\n        returns (bool);\n\n    /**\n     * @dev Returns the account id of the smart account\n     * @return accountImplementationId the account id of the smart account\n     * the accountId should be structured like so:\n     *        \"vendorname.accountname.semver\"\n     */\n    function accountId() external view returns (string memory accountImplementationId);\n}\n"
      },
      "lib/kernel_v3/src/interfaces/IERC7579Modules.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.21;\n\nimport {PackedUserOperation} from \"./PackedUserOperation.sol\";\n\nuint256 constant VALIDATION_SUCCESS = 0;\nuint256 constant VALIDATION_FAILED = 1;\n\nuint256 constant MODULE_TYPE_VALIDATOR = 1;\nuint256 constant MODULE_TYPE_EXECUTOR = 2;\nuint256 constant MODULE_TYPE_FALLBACK = 3;\nuint256 constant MODULE_TYPE_HOOK = 4;\nuint256 constant MODULE_TYPE_POLICY = 5;\nuint256 constant MODULE_TYPE_SIGNER = 6;\nuint256 constant MODULE_TYPE_ACTION = 7;\n\ninterface IModule {\n    error AlreadyInitialized(address smartAccount);\n    error NotInitialized(address smartAccount);\n\n    /**\n     * @dev This function is called by the smart account during installation of the module\n     * @param data arbitrary data that may be required on the module during `onInstall`\n     * initialization\n     *\n     * MUST revert on error (i.e. if module is already enabled)\n     */\n    function onInstall(bytes calldata data) external payable;\n\n    /**\n     * @dev This function is called by the smart account during uninstallation of the module\n     * @param data arbitrary data that may be required on the module during `onUninstall`\n     * de-initialization\n     *\n     * MUST revert on error\n     */\n    function onUninstall(bytes calldata data) external payable;\n\n    /**\n     * @dev Returns boolean value if module is a certain type\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     *\n     * MUST return true if the module is of the given type and false otherwise\n     */\n    function isModuleType(uint256 moduleTypeId) external view returns (bool);\n\n    /**\n     * @dev Returns if the module was already initialized for a provided smartaccount\n     */\n    function isInitialized(address smartAccount) external view returns (bool);\n}\n\ninterface IValidator is IModule {\n    error InvalidTargetAddress(address target);\n\n    /**\n     * @dev Validates a transaction on behalf of the account.\n     *         This function is intended to be called by the MSA during the ERC-4337 validaton phase\n     *         Note: solely relying on bytes32 hash and signature is not suffcient for some\n     * validation implementations (i.e. SessionKeys often need access to userOp.calldata)\n     * @param userOp The user operation to be validated. The userOp MUST NOT contain any metadata.\n     * The MSA MUST clean up the userOp before sending it to the validator.\n     * @param userOpHash The hash of the user operation to be validated\n     * @return return value according to ERC-4337\n     */\n    function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)\n        external\n        payable\n        returns (uint256);\n\n    /**\n     * Validator can be used for ERC-1271 validation\n     */\n    function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata data)\n        external\n        view\n        returns (bytes4);\n}\n\ninterface IExecutor is IModule {}\n\ninterface IHook is IModule {\n    function preCheck(address msgSender, bytes calldata msgData) external payable returns (bytes memory hookData);\n    function postCheck(bytes calldata hookData) external payable returns (bool success);\n}\n\ninterface IFallback is IModule {}\n\ninterface IPolicy is IModule {\n    function checkUserOpPolicy(bytes32 id, PackedUserOperation calldata userOp) external payable returns (uint256);\n    function checkSignaturePolicy(bytes32 id, address sender, bytes32 hash, bytes calldata sig)\n        external\n        view\n        returns (uint256);\n}\n\ninterface ISigner is IModule {\n    function checkUserOpSignature(bytes32 id, PackedUserOperation calldata userOp, bytes32 userOpHash)\n        external\n        payable\n        returns (uint256);\n    function checkSignature(bytes32 id, address sender, bytes32 hash, bytes calldata sig)\n        external\n        view\n        returns (bytes4);\n}\n\ninterface IAction is IModule {}\n"
      },
      "lib/kernel_v3/src/interfaces/PackedUserOperation.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/**\n * User Operation struct\n * @param sender                - The sender account of this request.\n * @param nonce                 - Unique value the sender uses to verify it is not a replay.\n * @param initCode              - If set, the account contract will be created by this constructor/\n * @param callData              - The method call to execute on this account.\n * @param accountGasLimits      - Packed gas limits for validateUserOp and gas limit passed to the callData method call.\n * @param preVerificationGas    - Gas not calculated by the handleOps method, but added to the gas paid.\n *                                Covers batch overhead.\n * @param gasFees                - packed gas fields maxFeePerGas and maxPriorityFeePerGas - Same as EIP-1559 gas parameter.\n * @param paymasterAndData      - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data\n *                                The paymaster will pay for the transaction instead of the sender.\n * @param signature             - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.\n */\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes initCode;\n    bytes callData;\n    bytes32 accountGasLimits;\n    uint256 preVerificationGas;\n    bytes32 gasFees; //maxPriorityFee and maxFeePerGas;\n    bytes paymasterAndData;\n    bytes signature;\n}\n"
      },
      "lib/kernel_v3/src/types/Types.sol": {
        "content": "pragma solidity ^0.8.23;\n\n// Custom type for improved developer experience\ntype ExecMode is bytes32;\n\ntype CallType is bytes1;\n\ntype ExecType is bytes1;\n\ntype ExecModeSelector is bytes4;\n\ntype ExecModePayload is bytes22;\n\nusing {eqModeSelector as ==} for ExecModeSelector global;\nusing {eqCallType as ==} for CallType global;\nusing {eqExecType as ==} for ExecType global;\n\nfunction eqCallType(CallType a, CallType b) pure returns (bool) {\n    return CallType.unwrap(a) == CallType.unwrap(b);\n}\n\nfunction eqExecType(ExecType a, ExecType b) pure returns (bool) {\n    return ExecType.unwrap(a) == ExecType.unwrap(b);\n}\n\nfunction eqModeSelector(ExecModeSelector a, ExecModeSelector b) pure returns (bool) {\n    return ExecModeSelector.unwrap(a) == ExecModeSelector.unwrap(b);\n}\n\ntype ValidationMode is bytes1;\n\ntype ValidationId is bytes21;\n\ntype ValidationType is bytes1;\n\ntype PermissionId is bytes4;\n\ntype PolicyData is bytes22; // 2bytes for flag on skip, 20 bytes for validator address\n\ntype PassFlag is bytes2;\n\nusing {vModeEqual as ==} for ValidationMode global;\nusing {vTypeEqual as ==} for ValidationType global;\nusing {vIdentifierEqual as ==} for ValidationId global;\nusing {vModeNotEqual as !=} for ValidationMode global;\nusing {vTypeNotEqual as !=} for ValidationType global;\nusing {vIdentifierNotEqual as !=} for ValidationId global;\n\n// nonce = uint192(key) + nonce\n// key = mode + (vtype + validationDataWithoutType) + 2bytes parallelNonceKey\n// key = 0x00 + 0x00 + 0x000 .. 00 + 0x0000\n// key = 0x00 + 0x01 + 0x1234...ff + 0x0000\n// key = 0x00 + 0x02 + ( ) + 0x000\n\nfunction vModeEqual(ValidationMode a, ValidationMode b) pure returns (bool) {\n    return ValidationMode.unwrap(a) == ValidationMode.unwrap(b);\n}\n\nfunction vModeNotEqual(ValidationMode a, ValidationMode b) pure returns (bool) {\n    return ValidationMode.unwrap(a) != ValidationMode.unwrap(b);\n}\n\nfunction vTypeEqual(ValidationType a, ValidationType b) pure returns (bool) {\n    return ValidationType.unwrap(a) == ValidationType.unwrap(b);\n}\n\nfunction vTypeNotEqual(ValidationType a, ValidationType b) pure returns (bool) {\n    return ValidationType.unwrap(a) != ValidationType.unwrap(b);\n}\n\nfunction vIdentifierEqual(ValidationId a, ValidationId b) pure returns (bool) {\n    return ValidationId.unwrap(a) == ValidationId.unwrap(b);\n}\n\nfunction vIdentifierNotEqual(ValidationId a, ValidationId b) pure returns (bool) {\n    return ValidationId.unwrap(a) != ValidationId.unwrap(b);\n}\n\ntype ValidationData is uint256;\n\ntype ValidAfter is uint48;\n\ntype ValidUntil is uint48;\n\nfunction getValidationResult(ValidationData validationData) pure returns (address result) {\n    assembly {\n        result := validationData\n    }\n}\n\nfunction packValidationData(ValidAfter validAfter, ValidUntil validUntil) pure returns (uint256) {\n    return uint256(ValidAfter.unwrap(validAfter)) << 208 | uint256(ValidUntil.unwrap(validUntil)) << 160;\n}\n\nfunction parseValidationData(uint256 validationData)\n    pure\n    returns (ValidAfter validAfter, ValidUntil validUntil, address result)\n{\n    assembly {\n        result := validationData\n        validUntil := and(shr(160, validationData), 0xffffffffffff)\n        switch iszero(validUntil)\n        case 1 { validUntil := 0xffffffffffff }\n        validAfter := shr(208, validationData)\n    }\n}\n"
      },
      "lib/kernel_v3/src/types/Constants.sol": {
        "content": "pragma solidity ^0.8.0;\n\nimport {CallType, ExecType, ExecModeSelector} from \"./Types.sol\";\nimport {PassFlag, ValidationMode, ValidationType} from \"./Types.sol\";\nimport {ValidationData} from \"./Types.sol\";\n// Default CallType\n\nCallType constant CALLTYPE_SINGLE = CallType.wrap(0x00);\n// Batched CallType\nCallType constant CALLTYPE_BATCH = CallType.wrap(0x01);\n// @dev Implementing delegatecall is OPTIONAL!\n// implement delegatecall with extreme care.\nCallType constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);\n\n// @dev default behavior is to revert on failure\n// To allow very simple accounts to use mode encoding, the default behavior is to revert on failure\n// Since this is value 0x00, no additional encoding is required for simple accounts\nExecType constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);\n// @dev account may elect to change execution behavior. For example \"try exec\" / \"allow fail\"\nExecType constant EXECTYPE_TRY = ExecType.wrap(0x01);\n\nExecModeSelector constant EXEC_MODE_DEFAULT = ExecModeSelector.wrap(bytes4(0x00000000));\n\nPassFlag constant SKIP_USEROP = PassFlag.wrap(0x0001);\nPassFlag constant SKIP_SIGNATURE = PassFlag.wrap(0x0002);\n\n// FLAG\nValidationMode constant VALIDATION_MODE_DEFAULT = ValidationMode.wrap(0x00);\nValidationMode constant VALIDATION_MODE_ENABLE = ValidationMode.wrap(0x01);\nValidationMode constant VALIDATION_MODE_INSTALL = ValidationMode.wrap(0x02);\n\n// TYPES, ENUM\nValidationType constant VALIDATION_TYPE_SUDO = ValidationType.wrap(0x00);\nValidationType constant VALIDATION_TYPE_VALIDATOR = ValidationType.wrap(0x01);\nValidationType constant VALIDATION_TYPE_PERMISSION = ValidationType.wrap(0x02);\n\n// ERC4337 constants\nuint256 constant SIG_VALIDATION_FAILED_UINT = 1;\nValidationData constant SIG_VALIDATION_FAILED = ValidationData.wrap(SIG_VALIDATION_FAILED_UINT);\n\n// ERC-1271 constants\nbytes4 constant ERC1271_MAGICVALUE = 0x1626ba7e;\nbytes4 constant ERC1271_INVALID = 0xffffffff;\n"
      },
      "lib/kernel_v3/src/types/Structs.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.23;\n\nstruct Execution {\n    address target;\n    uint256 value;\n    bytes callData;\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "ds-test/=lib/kernel_v3/lib/forge-std/lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/",
        "kernel/=lib/kernel_v3/src/",
        "solady/=lib/kernel_v3/lib/solady/src/",
        "kernel_v3/=lib/kernel_v3/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "libraries": {}
    }
  }}