creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@account-abstraction/contracts/core/BaseAccount.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-empty-blocks */\n\nimport \"../interfaces/IAccount.sol\";\nimport \"../interfaces/IEntryPoint.sol\";\nimport \"./Helpers.sol\";\n\n/**\n * Basic account implementation.\n * this contract provides the basic logic for implementing the IAccount interface  - validateUserOp\n * specific account implementation should inherit it and provide the account-specific logic\n */\nabstract contract BaseAccount is IAccount {\n    using UserOperationLib for UserOperation;\n\n    //return value in case of signature failure, with no time-range.\n    // equivalent to _packValidationData(true,0,0);\n    uint256 constant internal SIG_VALIDATION_FAILED = 1;\n\n    /**\n     * Return the account nonce.\n     * This method returns the next sequential nonce.\n     * For a nonce of a specific key, use `entrypoint.getNonce(account, key)`\n     */\n    function getNonce() public view virtual returns (uint256) {\n        return entryPoint().getNonce(address(this), 0);\n    }\n\n    /**\n     * return the entryPoint used by this account.\n     * subclass should return the current entryPoint used by this account.\n     */\n    function entryPoint() public view virtual returns (IEntryPoint);\n\n    /**\n     * Validate user's signature and nonce.\n     * subclass doesn't need to override this method. Instead, it should override the specific internal validation methods.\n     */\n    function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)\n    external override virtual returns (uint256 validationData) {\n        _requireFromEntryPoint();\n        validationData = _validateSignature(userOp, userOpHash);\n        _validateNonce(userOp.nonce);\n        _payPrefund(missingAccountFunds);\n    }\n\n    /**\n     * ensure the request comes from the known entrypoint.\n     */\n    function _requireFromEntryPoint() internal virtual view {\n        require(msg.sender == address(entryPoint()), \"account: not from EntryPoint\");\n    }\n\n    /**\n     * validate the signature is valid for this message.\n     * @param userOp validate the userOp.signature field\n     * @param userOpHash convenient field: the hash of the request, to check the signature against\n     *          (also hashes the entrypoint and chain id)\n     * @return validationData signature and time-range of this operation\n     *      <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,\n     *         otherwise, an address of an \"authorizer\" contract.\n     *      <6-byte> validUntil - last timestamp this operation is valid. 0 for \"indefinite\"\n     *      <6-byte> validAfter - first timestamp this operation is valid\n     *      If the account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.\n     *      Note that the validation code cannot use block.timestamp (or block.number) directly.\n     */\n    function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)\n    internal virtual returns (uint256 validationData);\n\n    /**\n     * Validate the nonce of the UserOperation.\n     * This method may validate the nonce requirement of this account.\n     * e.g.\n     * To limit the nonce to use sequenced UserOps only (no \"out of order\" UserOps):\n     *      `require(nonce < type(uint64).max)`\n     * For a hypothetical account that *requires* the nonce to be out-of-order:\n     *      `require(nonce & type(uint64).max == 0)`\n     *\n     * The actual nonce uniqueness is managed by the EntryPoint, and thus no other\n     * action is needed by the account itself.\n     *\n     * @param nonce to validate\n     *\n     * solhint-disable-next-line no-empty-blocks\n     */\n    function _validateNonce(uint256 nonce) internal view virtual {\n    }\n\n    /**\n     * sends to the entrypoint (msg.sender) the missing funds for this transaction.\n     * subclass MAY override this method for better funds management\n     * (e.g. send to the entryPoint more than the minimum required, so that in future transactions\n     * it will not be required to send again)\n     * @param missingAccountFunds the minimum value this method should send the entrypoint.\n     *  this value MAY be zero, in case there is enough deposit, or the userOp has a paymaster.\n     */\n    function _payPrefund(uint256 missingAccountFunds) internal virtual {\n        if (missingAccountFunds != 0) {\n            (bool success,) = payable(msg.sender).call{value : missingAccountFunds, gas : type(uint256).max}(\"\");\n            (success);\n            //ignore failure (its EntryPoint's job to verify, not account.)\n        }\n    }\n}\n"
      },
      "@account-abstraction/contracts/core/Helpers.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable no-inline-assembly */\n\n/**\n * returned data from validateUserOp.\n * validateUserOp returns a uint256, with is created by `_packedValidationData` and parsed by `_parseValidationData`\n * @param aggregator - address(0) - the account validated the signature by itself.\n *              address(1) - the account failed to validate the signature.\n *              otherwise - this is an address of a signature aggregator that must be used to validate the signature.\n * @param validAfter - this UserOp is valid only after this timestamp.\n * @param validaUntil - this UserOp is valid only up to this timestamp.\n */\n    struct ValidationData {\n        address aggregator;\n        uint48 validAfter;\n        uint48 validUntil;\n    }\n\n//extract sigFailed, validAfter, validUntil.\n// also convert zero validUntil to type(uint48).max\n    function _parseValidationData(uint validationData) pure returns (ValidationData memory data) {\n        address aggregator = address(uint160(validationData));\n        uint48 validUntil = uint48(validationData >> 160);\n        if (validUntil == 0) {\n            validUntil = type(uint48).max;\n        }\n        uint48 validAfter = uint48(validationData >> (48 + 160));\n        return ValidationData(aggregator, validAfter, validUntil);\n    }\n\n// intersect account and paymaster ranges.\n    function _intersectTimeRange(uint256 validationData, uint256 paymasterValidationData) pure returns (ValidationData memory) {\n        ValidationData memory accountValidationData = _parseValidationData(validationData);\n        ValidationData memory pmValidationData = _parseValidationData(paymasterValidationData);\n        address aggregator = accountValidationData.aggregator;\n        if (aggregator == address(0)) {\n            aggregator = pmValidationData.aggregator;\n        }\n        uint48 validAfter = accountValidationData.validAfter;\n        uint48 validUntil = accountValidationData.validUntil;\n        uint48 pmValidAfter = pmValidationData.validAfter;\n        uint48 pmValidUntil = pmValidationData.validUntil;\n\n        if (validAfter < pmValidAfter) validAfter = pmValidAfter;\n        if (validUntil > pmValidUntil) validUntil = pmValidUntil;\n        return ValidationData(aggregator, validAfter, validUntil);\n    }\n\n/**\n * helper to pack the return value for validateUserOp\n * @param data - the ValidationData to pack\n */\n    function _packValidationData(ValidationData memory data) pure returns (uint256) {\n        return uint160(data.aggregator) | (uint256(data.validUntil) << 160) | (uint256(data.validAfter) << (160 + 48));\n    }\n\n/**\n * helper to pack the return value for validateUserOp, when not using an aggregator\n * @param sigFailed - true for signature failure, false for success\n * @param validUntil last timestamp this UserOperation is valid (or zero for infinite)\n * @param validAfter first timestamp this UserOperation is valid\n */\n    function _packValidationData(bool sigFailed, uint48 validUntil, uint48 validAfter) pure returns (uint256) {\n        return (sigFailed ? 1 : 0) | (uint256(validUntil) << 160) | (uint256(validAfter) << (160 + 48));\n    }\n\n/**\n * keccak function over calldata.\n * @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.\n */\n    function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {\n        assembly {\n            let mem := mload(0x40)\n            let len := data.length\n            calldatacopy(mem, data.offset, len)\n            ret := keccak256(mem, len)\n        }\n    }\n\n"
      },
      "@account-abstraction/contracts/interfaces/IAccount.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.sol\";\n\ninterface IAccount {\n\n    /**\n     * Validate user's signature and nonce\n     * the entryPoint will make the call to the recipient only if this validation call returns successfully.\n     * signature failure should be reported by returning SIG_VALIDATION_FAILED (1).\n     * This allows making a \"simulation call\" without a valid signature\n     * Other failures (e.g. nonce mismatch, or invalid signature format) should still revert to signal failure.\n     *\n     * @dev Must validate caller is the entryPoint.\n     *      Must validate the signature and nonce\n     * @param userOp the operation that is about to be executed.\n     * @param userOpHash hash of the user's request data. can be used as the basis for signature.\n     * @param missingAccountFunds missing funds on the account's deposit in the entrypoint.\n     *      This is the minimum amount to transfer to the sender(entryPoint) to be able to make the call.\n     *      The excess is left as a deposit in the entrypoint, for future calls.\n     *      can be withdrawn anytime using \"entryPoint.withdrawTo()\"\n     *      In case there is a paymaster in the request (or the current deposit is high enough), this value will be zero.\n     * @return validationData packaged ValidationData structure. use `_packValidationData` and `_unpackValidationData` to encode and decode\n     *      <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,\n     *         otherwise, an address of an \"authorizer\" contract.\n     *      <6-byte> validUntil - last timestamp this operation is valid. 0 for \"indefinite\"\n     *      <6-byte> validAfter - first timestamp this operation is valid\n     *      If an account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.\n     *      Note that the validation code cannot use block.timestamp (or block.number) directly.\n     */\n    function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)\n    external returns (uint256 validationData);\n}\n"
      },
      "@account-abstraction/contracts/interfaces/IAggregator.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.sol\";\n\n/**\n * Aggregated Signatures validator.\n */\ninterface IAggregator {\n\n    /**\n     * validate aggregated signature.\n     * revert if the aggregated signature does not match the given list of operations.\n     */\n    function validateSignatures(UserOperation[] calldata userOps, bytes calldata signature) external view;\n\n    /**\n     * validate signature of a single userOp\n     * This method is should be called by bundler after EntryPoint.simulateValidation() returns (reverts) with ValidationResultWithAggregation\n     * First it validates the signature over the userOp. Then it returns data to be used when creating the handleOps.\n     * @param userOp the userOperation received from the user.\n     * @return sigForUserOp the value to put into the signature field of the userOp when calling handleOps.\n     *    (usually empty, unless account and aggregator support some kind of \"multisig\"\n     */\n    function validateUserOpSignature(UserOperation calldata userOp)\n    external view returns (bytes memory sigForUserOp);\n\n    /**\n     * aggregate multiple signatures into a single value.\n     * This method is called off-chain to calculate the signature to pass with handleOps()\n     * bundler MAY use optimized custom code perform this aggregation\n     * @param userOps array of UserOperations to collect the signatures from.\n     * @return aggregatedSignature the aggregated signature\n     */\n    function aggregateSignatures(UserOperation[] calldata userOps) external view returns (bytes memory aggregatedSignature);\n}\n"
      },
      "@account-abstraction/contracts/interfaces/IEntryPoint.sol": {
        "content": "/**\n ** Account-Abstraction (EIP-4337) singleton EntryPoint implementation.\n ** Only one instance required on each chain.\n **/\n// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-inline-assembly */\n/* solhint-disable reason-string */\n\nimport \"./UserOperation.sol\";\nimport \"./IStakeManager.sol\";\nimport \"./IAggregator.sol\";\nimport \"./INonceManager.sol\";\n\ninterface IEntryPoint is IStakeManager, INonceManager {\n\n    /***\n     * An event emitted after each successful request\n     * @param userOpHash - unique identifier for the request (hash its entire content, except signature).\n     * @param sender - the account that generates this request.\n     * @param paymaster - if non-null, the paymaster that pays for this request.\n     * @param nonce - the nonce value from the request.\n     * @param success - true if the sender transaction succeeded, false if reverted.\n     * @param actualGasCost - actual amount paid (by account or paymaster) for this UserOperation.\n     * @param actualGasUsed - total gas used by this UserOperation (including preVerification, creation, validation and execution).\n     */\n    event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed);\n\n    /**\n     * account \"sender\" was deployed.\n     * @param userOpHash the userOp that deployed this account. UserOperationEvent will follow.\n     * @param sender the account that is deployed\n     * @param factory the factory used to deploy this account (in the initCode)\n     * @param paymaster the paymaster used by this UserOp\n     */\n    event AccountDeployed(bytes32 indexed userOpHash, address indexed sender, address factory, address paymaster);\n\n    /**\n     * An event emitted if the UserOperation \"callData\" reverted with non-zero length\n     * @param userOpHash the request unique identifier.\n     * @param sender the sender of this request\n     * @param nonce the nonce used in the request\n     * @param revertReason - the return bytes from the (reverted) call to \"callData\".\n     */\n    event UserOperationRevertReason(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason);\n\n    /**\n     * an event emitted by handleOps(), before starting the execution loop.\n     * any event emitted before this event, is part of the validation.\n     */\n    event BeforeExecution();\n\n    /**\n     * signature aggregator used by the following UserOperationEvents within this bundle.\n     */\n    event SignatureAggregatorChanged(address indexed aggregator);\n\n    /**\n     * a custom revert error of handleOps, to identify the offending op.\n     *  NOTE: if simulateValidation passes successfully, there should be no reason for handleOps to fail on it.\n     *  @param opIndex - index into the array of ops to the failed one (in simulateValidation, this is always zero)\n     *  @param reason - revert reason\n     *      The string starts with a unique code \"AAmn\", where \"m\" is \"1\" for factory, \"2\" for account and \"3\" for paymaster issues,\n     *      so a failure can be attributed to the correct entity.\n     *   Should be caught in off-chain handleOps simulation and not happen on-chain.\n     *   Useful for mitigating DoS attempts against batchers or for troubleshooting of factory/account/paymaster reverts.\n     */\n    error FailedOp(uint256 opIndex, string reason);\n\n    /**\n     * error case when a signature aggregator fails to verify the aggregated signature it had created.\n     */\n    error SignatureValidationFailed(address aggregator);\n\n    /**\n     * Successful result from simulateValidation.\n     * @param returnInfo gas and time-range returned values\n     * @param senderInfo stake information about the sender\n     * @param factoryInfo stake information about the factory (if any)\n     * @param paymasterInfo stake information about the paymaster (if any)\n     */\n    error ValidationResult(ReturnInfo returnInfo,\n        StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo);\n\n    /**\n     * Successful result from simulateValidation, if the account returns a signature aggregator\n     * @param returnInfo gas and time-range returned values\n     * @param senderInfo stake information about the sender\n     * @param factoryInfo stake information about the factory (if any)\n     * @param paymasterInfo stake information about the paymaster (if any)\n     * @param aggregatorInfo signature aggregation info (if the account requires signature aggregator)\n     *      bundler MUST use it to verify the signature, or reject the UserOperation\n     */\n    error ValidationResultWithAggregation(ReturnInfo returnInfo,\n        StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo,\n        AggregatorStakeInfo aggregatorInfo);\n\n    /**\n     * return value of getSenderAddress\n     */\n    error SenderAddressResult(address sender);\n\n    /**\n     * return value of simulateHandleOp\n     */\n    error ExecutionResult(uint256 preOpGas, uint256 paid, uint48 validAfter, uint48 validUntil, bool targetSuccess, bytes targetResult);\n\n    //UserOps handled, per aggregator\n    struct UserOpsPerAggregator {\n        UserOperation[] userOps;\n\n        // aggregator address\n        IAggregator aggregator;\n        // aggregated signature\n        bytes signature;\n    }\n\n    /**\n     * Execute a batch of UserOperation.\n     * no signature aggregator is used.\n     * if any account requires an aggregator (that is, it returned an aggregator when\n     * performing simulateValidation), then handleAggregatedOps() must be used instead.\n     * @param ops the operations to execute\n     * @param beneficiary the address to receive the fees\n     */\n    function handleOps(UserOperation[] calldata ops, address payable beneficiary) external;\n\n    /**\n     * Execute a batch of UserOperation with Aggregators\n     * @param opsPerAggregator the operations to execute, grouped by aggregator (or address(0) for no-aggregator accounts)\n     * @param beneficiary the address to receive the fees\n     */\n    function handleAggregatedOps(\n        UserOpsPerAggregator[] calldata opsPerAggregator,\n        address payable beneficiary\n    ) external;\n\n    /**\n     * generate a request Id - unique identifier for this request.\n     * the request ID is a hash over the content of the userOp (except the signature), the entrypoint and the chainid.\n     */\n    function getUserOpHash(UserOperation calldata userOp) external view returns (bytes32);\n\n    /**\n     * Simulate a call to account.validateUserOp and paymaster.validatePaymasterUserOp.\n     * @dev this method always revert. Successful result is ValidationResult error. other errors are failures.\n     * @dev The node must also verify it doesn't use banned opcodes, and that it doesn't reference storage outside the account's data.\n     * @param userOp the user operation to validate.\n     */\n    function simulateValidation(UserOperation calldata userOp) external;\n\n    /**\n     * gas and return values during simulation\n     * @param preOpGas the gas used for validation (including preValidationGas)\n     * @param prefund the required prefund for this operation\n     * @param sigFailed validateUserOp's (or paymaster's) signature check failed\n     * @param validAfter - first timestamp this UserOp is valid (merging account and paymaster time-range)\n     * @param validUntil - last timestamp this UserOp is valid (merging account and paymaster time-range)\n     * @param paymasterContext returned by validatePaymasterUserOp (to be passed into postOp)\n     */\n    struct ReturnInfo {\n        uint256 preOpGas;\n        uint256 prefund;\n        bool sigFailed;\n        uint48 validAfter;\n        uint48 validUntil;\n        bytes paymasterContext;\n    }\n\n    /**\n     * returned aggregated signature info.\n     * the aggregator returned by the account, and its current stake.\n     */\n    struct AggregatorStakeInfo {\n        address aggregator;\n        StakeInfo stakeInfo;\n    }\n\n    /**\n     * Get counterfactual sender address.\n     *  Calculate the sender contract address that will be generated by the initCode and salt in the UserOperation.\n     * this method always revert, and returns the address in SenderAddressResult error\n     * @param initCode the constructor code to be passed into the UserOperation.\n     */\n    function getSenderAddress(bytes memory initCode) external;\n\n\n    /**\n     * simulate full execution of a UserOperation (including both validation and target execution)\n     * this method will always revert with \"ExecutionResult\".\n     * it performs full validation of the UserOperation, but ignores signature error.\n     * an optional target address is called after the userop succeeds, and its value is returned\n     * (before the entire call is reverted)\n     * Note that in order to collect the the success/failure of the target call, it must be executed\n     * with trace enabled to track the emitted events.\n     * @param op the UserOperation to simulate\n     * @param target if nonzero, a target address to call after userop simulation. If called, the targetSuccess and targetResult\n     *        are set to the return from that call.\n     * @param targetCallData callData to pass to target address\n     */\n    function simulateHandleOp(UserOperation calldata op, address target, bytes calldata targetCallData) external;\n}\n\n"
      },
      "@account-abstraction/contracts/interfaces/INonceManager.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\ninterface INonceManager {\n\n    /**\n     * Return the next nonce for this sender.\n     * Within a given key, the nonce values are sequenced (starting with zero, and incremented by one on each userop)\n     * But UserOp with different keys can come with arbitrary order.\n     *\n     * @param sender the account address\n     * @param key the high 192 bit of the nonce\n     * @return nonce a full nonce to pass for next UserOp with this sender.\n     */\n    function getNonce(address sender, uint192 key)\n    external view returns (uint256 nonce);\n\n    /**\n     * Manually increment the nonce of the sender.\n     * This method is exposed just for completeness..\n     * Account does NOT need to call it, neither during validation, nor elsewhere,\n     * as the EntryPoint will update the nonce regardless.\n     * Possible use-case is call it with various keys to \"initialize\" their nonces to one, so that future\n     * UserOperations will not pay extra for the first transaction with a given key.\n     */\n    function incrementNonce(uint192 key) external;\n}\n"
      },
      "@account-abstraction/contracts/interfaces/IStakeManager.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.12;\n\n/**\n * manage deposits and stakes.\n * deposit is just a balance used to pay for UserOperations (either by a paymaster or an account)\n * stake is value locked for at least \"unstakeDelay\" by the staked entity.\n */\ninterface IStakeManager {\n\n    event Deposited(\n        address indexed account,\n        uint256 totalDeposit\n    );\n\n    event Withdrawn(\n        address indexed account,\n        address withdrawAddress,\n        uint256 amount\n    );\n\n    /// Emitted when stake or unstake delay are modified\n    event StakeLocked(\n        address indexed account,\n        uint256 totalStaked,\n        uint256 unstakeDelaySec\n    );\n\n    /// Emitted once a stake is scheduled for withdrawal\n    event StakeUnlocked(\n        address indexed account,\n        uint256 withdrawTime\n    );\n\n    event StakeWithdrawn(\n        address indexed account,\n        address withdrawAddress,\n        uint256 amount\n    );\n\n    /**\n     * @param deposit the entity's deposit\n     * @param staked true if this entity is staked.\n     * @param stake actual amount of ether staked for this entity.\n     * @param unstakeDelaySec minimum delay to withdraw the stake.\n     * @param withdrawTime - first block timestamp where 'withdrawStake' will be callable, or zero if already locked\n     * @dev sizes were chosen so that (deposit,staked, stake) fit into one cell (used during handleOps)\n     *    and the rest fit into a 2nd cell.\n     *    112 bit allows for 10^15 eth\n     *    48 bit for full timestamp\n     *    32 bit allows 150 years for unstake delay\n     */\n    struct DepositInfo {\n        uint112 deposit;\n        bool staked;\n        uint112 stake;\n        uint32 unstakeDelaySec;\n        uint48 withdrawTime;\n    }\n\n    //API struct used by getStakeInfo and simulateValidation\n    struct StakeInfo {\n        uint256 stake;\n        uint256 unstakeDelaySec;\n    }\n\n    /// @return info - full deposit information of given account\n    function getDepositInfo(address account) external view returns (DepositInfo memory info);\n\n    /// @return the deposit (for gas payment) of the account\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * add to the deposit of the given account\n     */\n    function depositTo(address account) external payable;\n\n    /**\n     * add to the account's stake - amount and delay\n     * any pending unstake is first cancelled.\n     * @param _unstakeDelaySec the new lock duration before the deposit can be withdrawn.\n     */\n    function addStake(uint32 _unstakeDelaySec) external payable;\n\n    /**\n     * attempt to unlock the stake.\n     * the value can be withdrawn (using withdrawStake) after the unstake delay.\n     */\n    function unlockStake() external;\n\n    /**\n     * withdraw from the (unlocked) stake.\n     * must first call unlockStake and wait for the unstakeDelay to pass\n     * @param withdrawAddress the address to send withdrawn value.\n     */\n    function withdrawStake(address payable withdrawAddress) external;\n\n    /**\n     * withdraw from the deposit.\n     * @param withdrawAddress the address to send withdrawn value.\n     * @param withdrawAmount the amount to withdraw.\n     */\n    function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount) external;\n}\n"
      },
      "@account-abstraction/contracts/interfaces/UserOperation.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable no-inline-assembly */\n\nimport {calldataKeccak} from \"../core/Helpers.sol\";\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 callGasLimit the gas limit passed to the callData method call.\n     * @param verificationGasLimit gas used for validateUserOp and validatePaymasterUserOp.\n     * @param preVerificationGas gas not calculated by the handleOps method, but added to the gas paid. Covers batch overhead.\n     * @param maxFeePerGas same as EIP-1559 gas parameter.\n     * @param maxPriorityFeePerGas same as EIP-1559 gas parameter.\n     * @param paymasterAndData if set, this field holds the paymaster address and paymaster-specific data. 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     */\n    struct UserOperation {\n\n        address sender;\n        uint256 nonce;\n        bytes initCode;\n        bytes callData;\n        uint256 callGasLimit;\n        uint256 verificationGasLimit;\n        uint256 preVerificationGas;\n        uint256 maxFeePerGas;\n        uint256 maxPriorityFeePerGas;\n        bytes paymasterAndData;\n        bytes signature;\n    }\n\n/**\n * Utility functions helpful when working with UserOperation structs.\n */\nlibrary UserOperationLib {\n\n    function getSender(UserOperation calldata userOp) internal pure returns (address) {\n        address data;\n        //read sender from userOp, which is first userOp member (saves 800 gas...)\n        assembly {data := calldataload(userOp)}\n        return address(uint160(data));\n    }\n\n    //relayer/block builder might submit the TX with higher priorityFee, but the user should not\n    // pay above what he signed for.\n    function gasPrice(UserOperation calldata userOp) internal view returns (uint256) {\n    unchecked {\n        uint256 maxFeePerGas = userOp.maxFeePerGas;\n        uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n        if (maxFeePerGas == maxPriorityFeePerGas) {\n            //legacy mode (for networks that don't support basefee opcode)\n            return maxFeePerGas;\n        }\n        return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);\n    }\n    }\n\n    function pack(UserOperation calldata userOp) internal pure returns (bytes memory ret) {\n        address sender = getSender(userOp);\n        uint256 nonce = userOp.nonce;\n        bytes32 hashInitCode = calldataKeccak(userOp.initCode);\n        bytes32 hashCallData = calldataKeccak(userOp.callData);\n        uint256 callGasLimit = userOp.callGasLimit;\n        uint256 verificationGasLimit = userOp.verificationGasLimit;\n        uint256 preVerificationGas = userOp.preVerificationGas;\n        uint256 maxFeePerGas = userOp.maxFeePerGas;\n        uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n        bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);\n\n        return abi.encode(\n            sender, nonce,\n            hashInitCode, hashCallData,\n            callGasLimit, verificationGasLimit, preVerificationGas,\n            maxFeePerGas, maxPriorityFeePerGas,\n            hashPaymasterAndData\n        );\n    }\n\n    function hash(UserOperation calldata userOp) internal pure returns (bytes32) {\n        return keccak256(pack(userOp));\n    }\n\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n}\n"
      },
      "@openzeppelin/contracts/interfaces/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"
      },
      "@openzeppelin/contracts/metatx/ERC2771Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n *\n * WARNING: Avoid using this pattern in contracts that rely in a specific calldata length as they'll\n * be affected by any forwarder whose `msg.data` is suffixed with the `from` address according to the ERC2771\n * specification adding the address size in bytes (20) to the calldata size. An example of an unexpected\n * behavior could be an unintended fallback (or another function) invocation while trying to invoke the `receive`\n * function only accessible if `msg.data.length == 0`.\n *\n * WARNING: The usage of `delegatecall` in this contract is dangerous and may result in context corruption.\n * Any forwarded request to this contract triggering a `delegatecall` to itself will result in an invalid {_msgSender}\n * recovery.\n */\nabstract contract ERC2771Context is Context {\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address private immutable _trustedForwarder;\n\n    /**\n     * @dev Initializes the contract with a trusted forwarder, which will be able to\n     * invoke functions on this contract on behalf of other accounts.\n     *\n     * NOTE: The trusted forwarder can be replaced by overriding {trustedForwarder}.\n     */\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor(address trustedForwarder_) {\n        _trustedForwarder = trustedForwarder_;\n    }\n\n    /**\n     * @dev Returns the address of the trusted forwarder.\n     */\n    function trustedForwarder() public view virtual returns (address) {\n        return _trustedForwarder;\n    }\n\n    /**\n     * @dev Indicates whether any particular address is the trusted forwarder.\n     */\n    function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n        return forwarder == trustedForwarder();\n    }\n\n    /**\n     * @dev Override for `msg.sender`. Defaults to the original `msg.sender` whenever\n     * a call is not performed by the trusted forwarder or the calldata length is less than\n     * 20 bytes (an address length).\n     */\n    function _msgSender() internal view virtual override returns (address) {\n        uint256 calldataLength = msg.data.length;\n        uint256 contextSuffixLength = _contextSuffixLength();\n        if (isTrustedForwarder(msg.sender) && calldataLength >= contextSuffixLength) {\n            return address(bytes20(msg.data[calldataLength - contextSuffixLength:]));\n        } else {\n            return super._msgSender();\n        }\n    }\n\n    /**\n     * @dev Override for `msg.data`. Defaults to the original `msg.data` whenever\n     * a call is not performed by the trusted forwarder or the calldata length is less than\n     * 20 bytes (an address length).\n     */\n    function _msgData() internal view virtual override returns (bytes calldata) {\n        uint256 calldataLength = msg.data.length;\n        uint256 contextSuffixLength = _contextSuffixLength();\n        if (isTrustedForwarder(msg.sender) && calldataLength >= contextSuffixLength) {\n            return msg.data[:calldataLength - contextSuffixLength];\n        } else {\n            return super._msgData();\n        }\n    }\n\n    /**\n     * @dev ERC-2771 specifies the context as being a single address (20 bytes).\n     */\n    function _contextSuffixLength() internal view virtual override returns (uint256) {\n        return 20;\n    }\n}"
      },
      "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface that must be implemented by smart contracts in order to receive\n * ERC-1155 token transfers.\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165, ERC165} from \"../../../utils/introspection/ERC165.sol\";\nimport {IERC1155Receiver} from \"../IERC1155Receiver.sol\";\n\n/**\n * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.\n *\n * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be\n * stuck.\n */\nabstract contract ERC1155Holder is ERC165, IERC1155Receiver {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be\n     * reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721Receiver} from \"../IERC721Receiver.sol\";\n\n/**\n * @dev Implementation of the {IERC721Receiver} interface.\n *\n * Accepts all token transfers.\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or\n * {IERC721-setApprovalForAll}.\n */\nabstract contract ERC721Holder is IERC721Receiver {\n    /**\n     * @dev See {IERC721Receiver-onERC721Received}.\n     *\n     * Always returns `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Create2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Create2.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2 {\n    /**\n     * @dev Not enough balance for performing a CREATE2 deploy.\n     */\n    error Create2InsufficientBalance(uint256 balance, uint256 needed);\n\n    /**\n     * @dev There's no code to deploy.\n     */\n    error Create2EmptyBytecode();\n\n    /**\n     * @dev The deployment failed.\n     */\n    error Create2FailedDeployment();\n\n    /**\n     * @dev Deploys a contract using `CREATE2`. The address where the contract\n     * will be deployed can be known in advance via {computeAddress}.\n     *\n     * The bytecode for a contract can be obtained from Solidity with\n     * `type(contractName).creationCode`.\n     *\n     * Requirements:\n     *\n     * - `bytecode` must not be empty.\n     * - `salt` must have not been used for `bytecode` already.\n     * - the factory must have a balance of at least `amount`.\n     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n     */\n    function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {\n        if (address(this).balance < amount) {\n            revert Create2InsufficientBalance(address(this).balance, amount);\n        }\n        if (bytecode.length == 0) {\n            revert Create2EmptyBytecode();\n        }\n        /// @solidity memory-safe-assembly\n        assembly {\n            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n        }\n        if (addr == address(0)) {\n            revert Create2FailedDeployment();\n        }\n    }\n\n    /**\n     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n     * `bytecodeHash` or `salt` will result in a new destination address.\n     */\n    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n        return computeAddress(salt, bytecodeHash, address(this));\n    }\n\n    /**\n     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n     */\n    function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40) // Get free memory pointer\n\n            // |                   | ↓ ptr ...  ↓ ptr + 0x0B (start) ...  ↓ ptr + 0x20 ...  ↓ ptr + 0x40 ...   |\n            // |-------------------|---------------------------------------------------------------------------|\n            // | bytecodeHash      |                                                        CCCCCCCCCCCCC...CC |\n            // | salt              |                                      BBBBBBBBBBBBB...BB                   |\n            // | deployer          | 000000...0000AAAAAAAAAAAAAAAAAAA...AA                                     |\n            // | 0xFF              |            FF                                                             |\n            // |-------------------|---------------------------------------------------------------------------|\n            // | memory            | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n            // | keccak(start, 85) |            ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n            mstore(add(ptr, 0x40), bytecodeHash)\n            mstore(add(ptr, 0x20), salt)\n            mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n            let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n            mstore8(start, 0xff)\n            addr := keccak256(start, 85)\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS\n    }\n\n    /**\n     * @dev The signature derives the `address(0)`.\n     */\n    error ECDSAInvalidSignature();\n\n    /**\n     * @dev The signature has an invalid length.\n     */\n    error ECDSAInvalidSignatureLength(uint256 length);\n\n    /**\n     * @dev The signature has an S value that is in the upper half order.\n     */\n    error ECDSAInvalidSignatureS(bytes32 s);\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n     * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n     * and a bytes32 providing additional information about the error.\n     *\n     * If no error is returned, then the address can be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n        unchecked {\n            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError, bytes32) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.20;\n\nimport {ECDSA} from \"./ECDSA.sol\";\nimport {IERC1271} from \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like\n * Argent and Safe Wallet (previously Gnosis Safe).\n */\nlibrary SignatureChecker {\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {\n        (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature);\n        return\n            (error == ECDSA.RecoverError.NoError && recovered == signer) ||\n            isValidERC1271SignatureNow(signer, hash, signature);\n    }\n\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n     * against the signer smart contract using ERC1271.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidERC1271SignatureNow(\n        address signer,\n        bytes32 hash,\n        bytes memory signature\n    ) internal view returns (bool) {\n        (bool success, bytes memory result) = signer.staticcall(\n            abi.encodeCall(IERC1271.isValidSignature, (hash, signature))\n        );\n        return (success &&\n            result.length >= 32 &&\n            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "contracts/abstract/ERC4337Account.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\nimport {BaseAccount as BaseERC4337Account} from \"@account-abstraction/contracts/core/BaseAccount.sol\";\n\nimport \"../utils/Errors.sol\";\n\n/**\n * @title ERC-4337 Support\n * @dev Implements ERC-4337 account support\n */\nabstract contract ERC4337Account is BaseERC4337Account {\n    using ECDSA for bytes32;\n\n    IEntryPoint immutable _entryPoint;\n\n    constructor(address entryPoint_) {\n        if (entryPoint_ == address(0)) revert InvalidEntryPoint();\n        _entryPoint = IEntryPoint(entryPoint_);\n    }\n\n    /**\n     * @dev See {BaseERC4337Account-entryPoint}\n     */\n    function entryPoint() public view override returns (IEntryPoint) {\n        return _entryPoint;\n    }\n\n    /**\n     * @dev See {BaseERC4337Account-_validateSignature}\n     */\n    function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)\n        internal\n        view\n        virtual\n        override\n        returns (uint256)\n    {\n        if (_isValidSignature(_getUserOpSignatureHash(userOp, userOpHash), userOp.signature)) {\n            return 0;\n        }\n\n        return 1;\n    }\n\n    /**\n     * @dev Returns the user operation hash that should be signed by the account owner\n     */\n    function _getUserOpSignatureHash(UserOperation calldata userOp, bytes32 userOpHash)\n        internal\n        view\n        virtual\n        returns (bytes32)\n    {\n        bytes32 prefixedHash = keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", userOpHash));\n        return prefixedHash;\n    }\n\n    function _isValidSignature(bytes32 hash, bytes calldata signature)\n        internal\n        view\n        virtual\n        returns (bool);\n}\n"
      },
      "contracts/abstract/ERC6551Account.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\nimport \"erc6551/interfaces/IERC6551Account.sol\";\n\nimport \"./Signatory.sol\";\n\n/**\n * @title ERC-6551 Account Support\n * @dev Implements the ERC-6551 Account interface\n */\nabstract contract ERC6551Account is IERC6551Account, ERC165, Signatory {\n    uint256 _state;\n\n    receive() external payable virtual {}\n\n    /**\n     * @dev See: {IERC6551Account-isValidSigner}\n     */\n    function isValidSigner(address signer, bytes calldata data)\n        external\n        view\n        returns (bytes4 magicValue)\n    {\n        if (_isValidSigner(signer, data)) {\n            return IERC6551Account.isValidSigner.selector;\n        }\n\n        return bytes4(0);\n    }\n\n    /**\n     * @dev See: {IERC6551Account-token}\n     */\n    function token()\n        public\n        view\n        returns (uint256 chainId, address tokenContract, uint256 tokenId)\n    {\n        return ERC6551AccountLib.token();\n    }\n\n    /**\n     * @dev See: {IERC6551Account-state}\n     */\n    function state() public view returns (uint256) {\n        return _state;\n    }\n\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return\n            interfaceId == type(IERC6551Account).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns true if a given signer is authorized to use this account\n     */\n    function _isValidSigner(address signer, bytes memory) internal view virtual returns (bool);\n}\n"
      },
      "contracts/abstract/execution/BaseExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\nimport \"./SandboxExecutor.sol\";\n\n/**\n * @title Base Executor\n * @dev Base configuration for all executors\n */\nabstract contract BaseExecutor is Context, SandboxExecutor {\n    function _beforeExecute() internal virtual {}\n\n    function _isValidExecutor(address executor) internal view virtual returns (bool);\n}\n"
      },
      "contracts/abstract/execution/BatchExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"../../utils/Errors.sol\";\n\nimport \"./BaseExecutor.sol\";\n\n/**\n * @title Batch Executor\n * @dev Allows multiple operations to be executed from this account in a single transaction\n */\nabstract contract BatchExecutor is BaseExecutor {\n    struct Operation {\n        address to;\n        uint256 value;\n        bytes data;\n        uint8 operation;\n    }\n\n    /**\n     * @notice Executes a batch of operations if the caller is authorized\n     * @param operations Operations to execute\n     */\n    function executeBatch(Operation[] calldata operations)\n        external\n        payable\n        returns (bytes[] memory)\n    {\n        if (!_isValidExecutor(_msgSender())) revert NotAuthorized();\n\n        _beforeExecute();\n\n        uint256 length = operations.length;\n        bytes[] memory results = new bytes[](length);\n\n        for (uint256 i = 0; i < length; i++) {\n            results[i] = LibExecutor._execute(\n                operations[i].to, operations[i].value, operations[i].data, operations[i].operation\n            );\n        }\n\n        return results;\n    }\n}\n"
      },
      "contracts/abstract/execution/ERC6551Executor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/metatx/ERC2771Context.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nimport \"erc6551/interfaces/IERC6551Executable.sol\";\nimport \"erc6551/interfaces/IERC6551Account.sol\";\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\n\nimport \"../../utils/Errors.sol\";\nimport \"../../lib/LibExecutor.sol\";\nimport \"../../lib/LibSandbox.sol\";\nimport \"./SandboxExecutor.sol\";\nimport \"./BaseExecutor.sol\";\n\n/**\n * @title ERC-6551 Executor\n * @dev Basic executor which implements the IERC6551Executable execution interface\n */\nabstract contract ERC6551Executor is IERC6551Executable, ERC165, BaseExecutor {\n    /**\n     * Executes a low-level operation from this account if the caller is a valid executor\n     *\n     * @param to Account to operate on\n     * @param value Value to send with operation\n     * @param data Encoded calldata of operation\n     * @param operation Operation type (0=CALL, 1=DELEGATECALL, 2=CREATE, 3=CREATE2)\n     */\n    function execute(address to, uint256 value, bytes calldata data, uint8 operation)\n        external\n        payable\n        virtual\n        returns (bytes memory)\n    {\n        if (!_isValidExecutor(_msgSender())) revert NotAuthorized();\n\n        _beforeExecute();\n\n        return LibExecutor._execute(to, value, data, operation);\n    }\n\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC6551Executable).interfaceId\n            || super.supportsInterface(interfaceId);\n    }\n}\n"
      },
      "contracts/abstract/execution/NestedAccountExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/metatx/ERC2771Context.sol\";\n\nimport \"erc6551/interfaces/IERC6551Executable.sol\";\nimport \"erc6551/interfaces/IERC6551Account.sol\";\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\n\nimport \"../../utils/Errors.sol\";\nimport \"../../lib/LibExecutor.sol\";\nimport \"../../lib/LibSandbox.sol\";\nimport \"./SandboxExecutor.sol\";\nimport \"./BaseExecutor.sol\";\n\nimport \"../Lockable.sol\";\n\n/**\n * @title Nested Account Executor\n * @dev Allows the root owner of a nested token bound account to execute transactions directly\n * against the nested account, even if intermediate accounts have not been created.\n */\nabstract contract NestedAccountExecutor is BaseExecutor {\n    address immutable __self = address(this);\n    address public immutable erc6551Registry;\n\n    struct ERC6551AccountInfo {\n        bytes32 salt;\n        address tokenContract;\n        uint256 tokenId;\n    }\n\n    constructor(address _erc6551Registry) {\n        if (_erc6551Registry == address(0)) revert InvalidERC6551Registry();\n        erc6551Registry = _erc6551Registry;\n    }\n\n    /**\n     * Executes a low-level operation from this account if the caller is a valid signer on the\n     * parent TBA specified in the proof\n     *\n     * @param to Account to operate on\n     * @param value Value to send with operation\n     * @param data Encoded calldata of operation\n     * @param operation Operation type (0=CALL, 1=DELEGATECALL, 2=CREATE, 3=CREATE2)\n     * @param proof An array of ERC-6551 account information specifying the ownership path from this\n     * account to its parent\n     */\n    function executeNested(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        uint8 operation,\n        ERC6551AccountInfo[] calldata proof\n    ) external payable returns (bytes memory) {\n        uint256 length = proof.length;\n        address current = _msgSender();\n\n        ERC6551AccountInfo calldata accountInfo;\n        for (uint256 i = 0; i < length; i++) {\n            accountInfo = proof[i];\n            address tokenContract = accountInfo.tokenContract;\n            uint256 tokenId = accountInfo.tokenId;\n\n            address next = ERC6551AccountLib.computeAddress(\n                erc6551Registry, __self, accountInfo.salt, block.chainid, tokenContract, tokenId\n            );\n\n            if (tokenContract.code.length == 0) revert InvalidAccountProof();\n\n            if (next.code.length > 0) {\n                if (Lockable(next).isLocked()) revert AccountLocked();\n            }\n\n            try IERC721(tokenContract).ownerOf(tokenId) returns (address _owner) {\n                if (_owner != current) revert InvalidAccountProof();\n                current = next;\n            } catch {\n                revert InvalidAccountProof();\n            }\n        }\n\n        if (!_isValidExecutor(current)) revert NotAuthorized();\n\n        _beforeExecute();\n\n        return LibExecutor._execute(to, value, data, operation);\n    }\n}\n"
      },
      "contracts/abstract/execution/SandboxExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Create2.sol\";\n\nimport \"../../interfaces/ISandboxExecutor.sol\";\nimport \"../../utils/Errors.sol\";\nimport \"../../lib/LibSandbox.sol\";\nimport \"../../lib/LibExecutor.sol\";\n\n/**\n * @title Sandbox Executor\n * @dev Allows the sandbox contract for an account to execute low-level operations\n */\nabstract contract SandboxExecutor is ISandboxExecutor {\n    /**\n     * @dev Ensures that a given caller is the sandbox for this account\n     */\n    function _requireFromSandbox() internal view {\n        if (msg.sender != LibSandbox.sandbox(address(this))) revert NotAuthorized();\n    }\n\n    /**\n     * @dev Allows the sandbox contract to execute low-level calls from this account\n     */\n    function extcall(address to, uint256 value, bytes calldata data)\n        external\n        returns (bytes memory result)\n    {\n        _requireFromSandbox();\n        return LibExecutor._call(to, value, data);\n    }\n\n    /**\n     * @dev Allows the sandbox contract to create contracts on behalf of this account\n     */\n    function extcreate(uint256 value, bytes calldata bytecode) external returns (address) {\n        _requireFromSandbox();\n\n        return LibExecutor._create(value, bytecode);\n    }\n\n    /**\n     * @dev Allows the sandbox contract to create deterministic contracts on behalf of this account\n     */\n    function extcreate2(uint256 value, bytes32 salt, bytes calldata bytecode)\n        external\n        returns (address)\n    {\n        _requireFromSandbox();\n        return LibExecutor._create2(value, salt, bytecode);\n    }\n\n    /**\n     * @dev Allows arbitrary storage reads on this account from external contracts\n     */\n    function extsload(bytes32 slot) external view returns (bytes32 value) {\n        assembly {\n            value := sload(slot)\n        }\n    }\n}\n"
      },
      "contracts/abstract/execution/TokenboundExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/metatx/ERC2771Context.sol\";\n\nimport \"erc6551/interfaces/IERC6551Executable.sol\";\nimport \"erc6551/interfaces/IERC6551Account.sol\";\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\n\nimport \"../../utils/Errors.sol\";\nimport \"../../lib/LibExecutor.sol\";\nimport \"../../lib/LibSandbox.sol\";\nimport \"./ERC6551Executor.sol\";\nimport \"./BatchExecutor.sol\";\nimport \"./NestedAccountExecutor.sol\";\n\n/**\n * @title Tokenbound Executor\n * @dev Enables basic ERC-6551 execution as well as batch, nested, and mult-account execution\n */\nabstract contract TokenboundExecutor is\n    ERC6551Executor,\n    BatchExecutor,\n    NestedAccountExecutor,\n    ERC2771Context\n{\n    constructor(\n        address multicallForwarder,\n        address _erc6551Registry\n    )\n        ERC2771Context(multicallForwarder)\n        NestedAccountExecutor(_erc6551Registry)\n    {\n        if (multicallForwarder == address(0))\n            revert InvalidMulticallForwarder();\n    }\n\n    function _msgSender()\n        internal\n        view\n        virtual\n        override(Context, ERC2771Context)\n        returns (address sender)\n    {\n        return super._msgSender();\n    }\n\n    function _msgData()\n        internal\n        view\n        virtual\n        override(Context, ERC2771Context)\n        returns (bytes calldata)\n    {\n        return super._msgData();\n    }\n\n    /**\n     * @dev ERC-2771 specifies the context as being a single address (20 bytes).\n     */\n    function _contextSuffixLength()\n        internal\n        view\n        virtual\n        override(Context, ERC2771Context)\n        returns (uint256)\n    {\n        return 20;\n    }\n}\n"
      },
      "contracts/abstract/Lockable.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\n\nimport \"../utils/Errors.sol\";\n\n/**\n * @title Account Lock\n * @dev Allows the root owner of a token bound account to lock access to an account until a\n * certain timestamp\n */\nabstract contract Lockable {\n    /**\n     * @notice The timestamp at which this account will be unlocked\n     */\n    uint256 public lockedUntil;\n\n    event LockUpdated(uint256 lockedUntil);\n\n    /**\n     * @dev Locks the account until a certain timestamp\n     *\n     * @param _lockedUntil The time at which this account will no longer be locke\n     */\n    function lock(uint256 _lockedUntil) external virtual {\n        (uint256 chainId, address tokenContract, uint256 tokenId) = ERC6551AccountLib.token();\n        address _owner = _rootTokenOwner(chainId, tokenContract, tokenId);\n\n        if (_owner == address(0)) revert NotAuthorized();\n        if (msg.sender != _owner) revert NotAuthorized();\n\n        if (_lockedUntil > block.timestamp + 365 days) {\n            revert ExceedsMaxLockTime();\n        }\n\n        _beforeLock();\n\n        lockedUntil = _lockedUntil;\n\n        emit LockUpdated(_lockedUntil);\n    }\n\n    /**\n     * @dev Returns the current lock status of the account as a boolean\n     */\n    function isLocked() public view virtual returns (bool) {\n        return lockedUntil > block.timestamp;\n    }\n\n    function _rootTokenOwner(uint256 chainId, address tokenContract, uint256 tokenId)\n        internal\n        view\n        virtual\n        returns (address);\n\n    function _beforeLock() internal virtual {}\n}\n"
      },
      "contracts/abstract/Overridable.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\n\nimport \"../utils/Errors.sol\";\nimport \"../lib/LibSandbox.sol\";\n\n/**\n * @title Account Overrides\n * @dev Allows the root owner of a token bound account to override the implementation of a given\n * function selector on the account. Overrides are keyed by the root owner address, so will be\n * disabled upon transfer of the token which owns this account tree.\n */\nabstract contract Overridable {\n    /**\n     * @dev mapping from owner => selector => implementation\n     */\n    mapping(address => mapping(bytes4 => address)) public overrides;\n\n    event OverrideUpdated(address owner, bytes4 selector, address implementation);\n\n    /**\n     * @dev Sets the implementation address for a given array of function selectors. Can only be\n     * called by the root owner of the account\n     *\n     * @param selectors Array of selectors to override\n     * @param implementations Array of implementation address corresponding to selectors\n     */\n    function setOverrides(bytes4[] calldata selectors, address[] calldata implementations)\n        external\n        virtual\n    {\n        (uint256 chainId, address tokenContract, uint256 tokenId) = ERC6551AccountLib.token();\n        address _owner = _rootTokenOwner(chainId, tokenContract, tokenId);\n\n        if (_owner == address(0)) revert NotAuthorized();\n        if (msg.sender != _owner) revert NotAuthorized();\n\n        _beforeSetOverrides();\n\n        address sandbox = LibSandbox.sandbox(address(this));\n        if (sandbox.code.length == 0) LibSandbox.deploy(address(this));\n\n        uint256 length = selectors.length;\n\n        if (implementations.length != length) revert InvalidInput();\n\n        for (uint256 i = 0; i < length; i++) {\n            overrides[_owner][selectors[i]] = implementations[i];\n            emit OverrideUpdated(_owner, selectors[i], implementations[i]);\n        }\n    }\n\n    /**\n     * @dev Calls into the implementation address using sandbox if override is set for the current\n     * function selector. If an implementation is defined, this funciton will either revert or\n     * return with the return value of the implementation\n     */\n    function _handleOverride() internal virtual {\n        (uint256 chainId, address tokenContract, uint256 tokenId) = ERC6551AccountLib.token();\n        address _owner = _rootTokenOwner(chainId, tokenContract, tokenId);\n\n        address implementation = overrides[_owner][msg.sig];\n\n        if (implementation != address(0)) {\n            address sandbox = LibSandbox.sandbox(address(this));\n            (bool success, bytes memory result) =\n                sandbox.call(abi.encodePacked(implementation, msg.data, msg.sender));\n            assembly {\n                if iszero(success) { revert(add(result, 32), mload(result)) }\n                return(add(result, 32), mload(result))\n            }\n        }\n    }\n\n    /**\n     * @dev Static calls into the implementation addressif override is set for the current function\n     * selector. If an implementation is defined, this funciton will either revert or return with\n     * the return value of the implementation\n     */\n    function _handleOverrideStatic() internal view virtual {\n        (uint256 chainId, address tokenContract, uint256 tokenId) = ERC6551AccountLib.token();\n        address _owner = _rootTokenOwner(chainId, tokenContract, tokenId);\n\n        address implementation = overrides[_owner][msg.sig];\n\n        if (implementation != address(0)) {\n            (bool success, bytes memory result) = implementation.staticcall(msg.data);\n            assembly {\n                if iszero(success) { revert(add(result, 32), mload(result)) }\n                return(add(result, 32), mload(result))\n            }\n        }\n    }\n\n    function _beforeSetOverrides() internal virtual {}\n\n    function _rootTokenOwner(uint256 chainId, address tokenContract, uint256 tokenId)\n        internal\n        view\n        virtual\n        returns (address);\n}\n"
      },
      "contracts/abstract/Permissioned.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\nimport \"../utils/Errors.sol\";\n\n/**\n * @title Account Permissions\n * @dev Allows the root owner of a token bound account to allow another account to execute\n * operations from this account. Permissions are keyed by the root owner address, so will be\n * disabled upon transfer of the token which owns this account tree.\n */\nabstract contract Permissioned {\n    /**\n     * @dev mapping from owner => caller => has permissions\n     */\n    mapping(address => mapping(address => bool)) public permissions;\n\n    event PermissionUpdated(address owner, address caller, bool hasPermission);\n\n    /**\n     * @dev Grants or revokes execution permissions for a given array of callers on this account.\n     * Can only be called by the root owner of the account\n     *\n     * @param callers Array of callers to grant permissions to\n     * @param _permissions Array of booleans, true if execution permissions should be granted,\n     * false if permissions should be revoked\n     */\n    function setPermissions(address[] calldata callers, bool[] calldata _permissions)\n        external\n        virtual\n    {\n        (uint256 chainId, address tokenContract, uint256 tokenId) = ERC6551AccountLib.token();\n        address _owner = _rootTokenOwner(chainId, tokenContract, tokenId);\n\n        if (_owner == address(0)) revert NotAuthorized();\n        if (msg.sender != _owner) revert NotAuthorized();\n\n        _beforeSetPermissions();\n\n        uint256 length = callers.length;\n\n        if (_permissions.length != length) revert InvalidInput();\n\n        for (uint256 i = 0; i < length; i++) {\n            permissions[_owner][callers[i]] = _permissions[i];\n            emit PermissionUpdated(_owner, callers[i], _permissions[i]);\n        }\n    }\n\n    /**\n     * @dev Returns true if caller has permissions to act on behalf of owner\n     *\n     * @param caller Address to query permissions for\n     * @param owner Root owner address for which to query permissions\n     */\n    function hasPermission(address caller, address owner) internal view returns (bool) {\n        return permissions[owner][caller];\n    }\n\n    function _beforeSetPermissions() internal virtual {}\n\n    function _rootTokenOwner(uint256 chainId, address tokenContract, uint256 tokenId)\n        internal\n        view\n        virtual\n        returns (address);\n}\n"
      },
      "contracts/abstract/Signatory.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\n\n/**\n * @title Signatory\n * @dev Implements ERC-1271 signature verification\n */\nabstract contract Signatory is IERC1271 {\n    /**\n     * @dev See {IERC1721-isValidSignature}\n     */\n    function isValidSignature(bytes32 hash, bytes calldata signature)\n        external\n        view\n        returns (bytes4 magicValue)\n    {\n        if (_isValidSignature(hash, signature)) {\n            return IERC1271.isValidSignature.selector;\n        }\n\n        return bytes4(0);\n    }\n\n    function _isValidSignature(bytes32 hash, bytes calldata signature)\n        internal\n        view\n        virtual\n        returns (bool);\n}\n"
      },
      "contracts/AccountV3.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol\";\nimport \"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol\";\n\nimport \"erc6551/lib/ERC6551AccountLib.sol\";\n\nimport \"./abstract/Lockable.sol\";\nimport \"./abstract/Overridable.sol\";\nimport \"./abstract/Permissioned.sol\";\nimport \"./abstract/ERC6551Account.sol\";\nimport \"./abstract/ERC4337Account.sol\";\nimport \"./abstract/execution/TokenboundExecutor.sol\";\n\nimport \"./lib/OPAddressAliasHelper.sol\";\n\nimport \"./interfaces/IAccountGuardian.sol\";\n\n/**\n * @title Tokenbound ERC-6551 Account Implementation\n */\ncontract AccountV3 is\n    ERC721Holder,\n    ERC1155Holder,\n    Lockable,\n    Overridable,\n    Permissioned,\n    ERC6551Account,\n    ERC4337Account,\n    TokenboundExecutor\n{\n    IAccountGuardian immutable guardian;\n\n    /**\n     * @param entryPoint_ The ERC-4337 EntryPoint address\n     * @param multicallForwarder The MulticallForwarder address\n     * @param erc6551Registry The ERC-6551 Registry address\n     * @param _guardian The AccountGuardian address\n     */\n    constructor(\n        address entryPoint_,\n        address multicallForwarder,\n        address erc6551Registry,\n        address _guardian\n    )\n        ERC4337Account(entryPoint_)\n        TokenboundExecutor(multicallForwarder, erc6551Registry)\n    {\n        guardian = IAccountGuardian(_guardian);\n    }\n\n    /**\n     * @notice Called whenever this account received Ether\n     *\n     * @dev Can be overriden via Overridable\n     */\n    receive() external payable override {\n        _handleOverride();\n    }\n\n    /**\n     * @notice Called whenever the calldata function selector does not match a defined function\n     *\n     * @dev Can be overriden via Overridable\n     */\n    fallback() external payable {\n        _handleOverride();\n    }\n\n    /**\n     * @notice Returns the owner of the token this account is bound to (if available)\n     *\n     * @dev Returns zero address if token is on a foreign chain or token contract does not exist\n     *\n     * @return address The address which owns the token this account is bound to\n     */\n    function owner() public view returns (address) {\n        (\n            uint256 chainId,\n            address tokenContract,\n            uint256 tokenId\n        ) = ERC6551AccountLib.token();\n        return _tokenOwner(chainId, tokenContract, tokenId);\n    }\n\n    /**\n     * @notice Returns whether a given ERC165 interface ID is supported\n     *\n     * @dev Can be overriden via Overridable except for base interfaces.\n     *\n     * @param interfaceId The interface ID to query for\n     * @return bool True if the interface is supported, false otherwise\n     */\n    function supportsInterface(\n        bytes4 interfaceId\n    )\n        public\n        view\n        virtual\n        override(ERC6551Account, ERC6551Executor, ERC1155Holder)\n        returns (bool)\n    {\n        bool interfaceSupported = super.supportsInterface(interfaceId);\n\n        if (interfaceSupported) return true;\n\n        _handleOverrideStatic();\n\n        return false;\n    }\n\n    /**\n     * @dev called whenever an ERC-721 token is received. Can be overriden via Overridable. Reverts\n     * if token being received is the token the account is bound to.\n     */\n    function onERC721Received(\n        address,\n        address,\n        uint256 tokenId,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        (\n            uint256 chainId,\n            address tokenContract,\n            uint256 _tokenId\n        ) = ERC6551AccountLib.token();\n\n        if (\n            msg.sender == tokenContract &&\n            tokenId == _tokenId &&\n            chainId == block.chainid\n        ) {\n            revert OwnershipCycle();\n        }\n\n        _handleOverride();\n\n        return this.onERC721Received.selector;\n    }\n\n    /**\n     * @dev called whenever an ERC-1155 token is received. Can be overriden via Overridable.\n     */\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        _handleOverride();\n        return this.onERC1155Received.selector;\n    }\n\n    /**\n     * @dev called whenever a batch of ERC-1155 tokens are received. Can be overriden via Overridable.\n     */\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        _handleOverride();\n        return this.onERC1155BatchReceived.selector;\n    }\n\n    /**\n     * @notice Returns whether a given account is authorized to sign on behalf of this account\n     *\n     * @param signer The address to query authorization for\n     * @return True if the signer is valid, false otherwise\n     */\n    function _isValidSigner(\n        address signer,\n        bytes memory\n    ) internal view virtual override returns (bool) {\n        (\n            uint256 chainId,\n            address tokenContract,\n            uint256 tokenId\n        ) = ERC6551AccountLib.token();\n\n        // Single level accuont owner is valid signer\n        address _owner = _tokenOwner(chainId, tokenContract, tokenId);\n        if (signer == _owner) return true;\n\n        // Root owner of accuont tree is valid signer\n        address _rootOwner = _rootTokenOwner(\n            _owner,\n            chainId,\n            tokenContract,\n            tokenId\n        );\n        if (signer == _rootOwner) return true;\n\n        // Accounts granted permission by root owner are valid signers\n        return hasPermission(signer, _rootOwner);\n    }\n\n    /**\n     * Determines if a given hash and signature are valid for this account\n     * @param hash Hash of signed data\n     * @param signature ECDSA signature or encoded contract signature (v=0)\n     */\n    function _isValidSignature(\n        bytes32 hash,\n        bytes calldata signature\n    ) internal view override(ERC4337Account, Signatory) returns (bool) {\n        uint8 v = uint8(signature[64]);\n        address signer;\n        signer = address(0);\n        // Smart contract signature\n        if (v == 0) {\n            // Signer address encoded in r\n            signer = address(uint160(uint256(bytes32(signature[:32]))));\n\n            // Allow recursive signature verification\n            if (!_isValidSigner(signer, \"\") && signer != address(this)) {\n                return false;\n            }\n\n            // Signature offset encoded in s\n            bytes calldata _signature = signature[uint256(\n                bytes32(signature[32:64])\n            ):];\n\n            return\n                SignatureChecker.isValidERC1271SignatureNow(\n                    signer,\n                    hash,\n                    _signature\n                );\n        }\n\n        ECDSA.RecoverError _error;\n        signer = ECDSA.recover(hash, signature);\n\n        if (_error != ECDSA.RecoverError.NoError) return false;\n\n        return _isValidSigner(signer, \"\");\n    }\n\n    /**\n     * @notice Returns whether a given account is authorized to execute transactions on behalf of\n     * this account\n     *\n     * @param executor The address to query authorization for\n     * @return True if the executor is authorized, false otherwise\n     */\n    function _isValidExecutor(\n        address executor\n    ) internal view virtual override returns (bool) {\n        // Allow execution from ERC-4337 EntryPoint\n        if (executor == address(entryPoint())) return true;\n\n        (\n            uint256 chainId,\n            address tokenContract,\n            uint256 tokenId\n        ) = ERC6551AccountLib.token();\n\n        // Allow cross chain execution\n        if (chainId != block.chainid) {\n            // Allow execution from L1 account on OPStack chains\n            if (\n                OPAddressAliasHelper.undoL1ToL2Alias(_msgSender()) ==\n                address(this)\n            ) {\n                return true;\n            }\n\n            // Allow execution from trusted cross chain bridges\n            if (guardian.isTrustedExecutor(executor)) return true;\n        }\n\n        // Allow execution from owner\n        address _owner = _tokenOwner(chainId, tokenContract, tokenId);\n        if (executor == _owner) return true;\n\n        // Allow execution from root owner of account tree\n        address _rootOwner = _rootTokenOwner(\n            _owner,\n            chainId,\n            tokenContract,\n            tokenId\n        );\n        if (executor == _rootOwner) return true;\n\n        // Allow execution from permissioned account\n        if (hasPermission(executor, _rootOwner)) return true;\n\n        return false;\n    }\n\n    /**\n     * @dev Updates account state based on previous state and msg.data\n     */\n    function _updateState() internal virtual {\n        _state = uint256(keccak256(abi.encode(_state, _msgData())));\n    }\n\n    /**\n     * @dev Called before executing an operation. Reverts if account is locked. Ensures state is\n     * updated prior to execution.\n     */\n    function _beforeExecute() internal override {\n        if (isLocked()) revert AccountLocked();\n        _updateState();\n    }\n\n    /**\n     * @dev Called before locking the account. Reverts if account is locked. Updates account state.\n     */\n    function _beforeLock() internal override {\n        if (isLocked()) revert AccountLocked();\n        _updateState();\n    }\n\n    /**\n     * @dev Called before setting overrides on the account. Reverts if account is locked. Updates\n     * account state.\n     */\n    function _beforeSetOverrides() internal override {\n        if (isLocked()) revert AccountLocked();\n        _updateState();\n    }\n\n    /**\n     * @dev Called before setting permissions on the account. Reverts if account is locked. Updates\n     * account state.\n     */\n    function _beforeSetPermissions() internal override {\n        if (isLocked()) revert AccountLocked();\n        _updateState();\n    }\n\n    /**\n     * @dev Returns the root owner of an account. If account is not owned by a TBA, returns the\n     * owner of the NFT bound to this account. If account is owned by a TBA, iterates up token\n     * ownership tree and returns root owner.\n     *\n     * *Security Warning*: the return value of this function can only be trusted if it is also the\n     * address of the sender (as the code of the NFT contract cannot be trusted). This function\n     * should therefore only be used for authorization and never authentication.\n     */\n    function _rootTokenOwner(\n        uint256 chainId,\n        address tokenContract,\n        uint256 tokenId\n    )\n        internal\n        view\n        virtual\n        override(Overridable, Permissioned, Lockable)\n        returns (address)\n    {\n        address _owner = _tokenOwner(chainId, tokenContract, tokenId);\n\n        return _rootTokenOwner(_owner, chainId, tokenContract, tokenId);\n    }\n\n    /**\n     * @dev Returns the root owner of an account given a known account owner address (saves an\n     * additional external call).\n     */\n    function _rootTokenOwner(\n        address owner_,\n        uint256 chainId,\n        address tokenContract,\n        uint256 tokenId\n    ) internal view virtual returns (address) {\n        address _owner = owner_;\n\n        while (\n            ERC6551AccountLib.isERC6551Account(_owner, __self, erc6551Registry)\n        ) {\n            (chainId, tokenContract, tokenId) = IERC6551Account(payable(_owner))\n                .token();\n            _owner = _tokenOwner(chainId, tokenContract, tokenId);\n        }\n\n        return _owner;\n    }\n\n    /**\n     * @dev Returns the owner of the token which this account is bound to. Returns the zero address\n     * if token does not exist on the current chain or if the token contract does not exist\n     */\n    function _tokenOwner(\n        uint256 chainId,\n        address tokenContract,\n        uint256 tokenId\n    ) internal view virtual returns (address) {\n        if (chainId != block.chainid) return address(0);\n        if (tokenContract.code.length == 0) return address(0);\n\n        try IERC721(tokenContract).ownerOf(tokenId) returns (address _owner) {\n            return _owner;\n        } catch {\n            return address(0);\n        }\n    }\n}\n"
      },
      "contracts/interfaces/IAccountGuardian.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IAccountGuardian {\n    function setTrustedImplementation(address implementation, bool trusted) external;\n\n    function setTrustedExecutor(address executor, bool trusted) external;\n\n    function defaultImplementation() external view returns (address);\n\n    function isTrustedImplementation(address implementation) external view returns (bool);\n\n    function isTrustedExecutor(address implementation) external view returns (bool);\n}\n"
      },
      "contracts/interfaces/IL1GatewayRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\ninterface IL1GatewayRouter {\n    function depositETH(\n        address _to,\n        uint256 _amount,\n        uint256 _gasLimit\n    ) external payable;\n\n    function ethGateway() external view returns (address);\n}\n"
      },
      "contracts/interfaces/IL2GasOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IL2GasOracle {\n    function l2BaseFee() external view returns (uint256);\n}\n"
      },
      "contracts/interfaces/ISandboxExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface ISandboxExecutor {\n    function extcall(address to, uint256 value, bytes calldata data)\n        external\n        returns (bytes memory result);\n\n    function extcreate(uint256 value, bytes calldata data) external returns (address);\n\n    function extcreate2(uint256 value, bytes32 salt, bytes calldata bytecode)\n        external\n        returns (address);\n\n    function extsload(bytes32 slot) external view returns (bytes32 value);\n}\n"
      },
      "contracts/lib/LibExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"../utils/Errors.sol\";\nimport \"./LibSandbox.sol\";\n\nlibrary LibExecutor {\n    uint8 constant OP_CALL = 0;\n    uint8 constant OP_DELEGATECALL = 1;\n    uint8 constant OP_CREATE = 2;\n    uint8 constant OP_CREATE2 = 3;\n\n    function _execute(address to, uint256 value, bytes calldata data, uint8 operation)\n        internal\n        returns (bytes memory)\n    {\n        if (operation == OP_CALL) return _call(to, value, data);\n        if (operation == OP_DELEGATECALL) {\n            address sandbox = LibSandbox.sandbox(address(this));\n            if (sandbox.code.length == 0) LibSandbox.deploy(address(this));\n            return _call(sandbox, value, abi.encodePacked(to, data));\n        }\n        if (operation == OP_CREATE) return abi.encodePacked(_create(value, data));\n        if (operation == OP_CREATE2) {\n            bytes32 salt = bytes32(data[:32]);\n            bytes calldata bytecode = data[32:];\n            return abi.encodePacked(_create2(value, salt, bytecode));\n        }\n\n        revert InvalidOperation();\n    }\n\n    function _call(address to, uint256 value, bytes memory data)\n        internal\n        returns (bytes memory result)\n    {\n        bool success;\n        (success, result) = to.call{value: value}(data);\n\n        if (!success) {\n            assembly {\n                revert(add(result, 32), mload(result))\n            }\n        }\n    }\n\n    function _create(uint256 value, bytes memory data) internal returns (address created) {\n        bytes memory bytecode = data;\n\n        assembly {\n            created := create(value, add(bytecode, 0x20), mload(bytecode))\n        }\n\n        if (created == address(0)) revert ContractCreationFailed();\n    }\n\n    function _create2(uint256 value, bytes32 salt, bytes calldata data)\n        internal\n        returns (address created)\n    {\n        bytes memory bytecode = data;\n\n        assembly {\n            created := create2(value, add(bytecode, 0x20), mload(bytecode), salt)\n        }\n\n        if (created == address(0)) revert ContractCreationFailed();\n    }\n}\n"
      },
      "contracts/lib/LibSandbox.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Create2.sol\";\n\nlibrary LibSandbox {\n    bytes public constant header = hex\"604380600d600039806000f3fe73\";\n    bytes public constant footer =\n        hex\"3314601d573d3dfd5b363d3d373d3d6014360360143d5160601c5af43d6000803e80603e573d6000fd5b3d6000f3\";\n\n    function bytecode(address owner) internal pure returns (bytes memory) {\n        return abi.encodePacked(header, owner, footer);\n    }\n\n    function sandbox(address owner) internal view returns (address) {\n        return\n            Create2.computeAddress(keccak256(\"org.tokenbound.sandbox\"), keccak256(bytecode(owner)));\n    }\n\n    function deploy(address owner) internal {\n        Create2.deploy(0, keccak256(\"org.tokenbound.sandbox\"), bytecode(owner));\n    }\n}\n"
      },
      "contracts/lib/OPAddressAliasHelper.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\n// Source: https://github.com/ethereum-optimism/optimism/blob/96562692558e5c3851899488bcebe51fbe3b7f09/packages/contracts-bedrock/src/vendor/AddressAliasHelper.sol\nlibrary OPAddressAliasHelper {\n    uint160 constant offset = uint160(0x1111000000000000000000000000000000001111);\n\n    /// @notice Utility function that converts the address in the L1 that submitted a tx to\n    /// the inbox to the msg.sender viewed in the L2\n    /// @param l1Address the address in the L1 that triggered the tx to L2\n    /// @return l2Address L2 address as viewed in msg.sender\n    function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {\n        unchecked {\n            l2Address = address(uint160(l1Address) + offset);\n        }\n    }\n\n    /// @notice Utility function that converts the msg.sender viewed in the L2 to the\n    /// address in the L1 that submitted a tx to the inbox\n    /// @param l2Address L2 address as viewed in msg.sender\n    /// @return l1Address the address in the L1 that triggered the tx to L2\n    function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {\n        unchecked {\n            l1Address = address(uint160(l2Address) - offset);\n        }\n    }\n}\n"
      },
      "contracts/ScrollerAccount.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport \"./AccountV3.sol\"; // tokenbound base account contract\nimport \"./interfaces/IL1GatewayRouter.sol\";\nimport \"./interfaces/IL2GasOracle.sol\";\n\n/**\n * @title Tokenbound ERC-6551 Account Implementation\n * @dev Implementation of an account contract with ERC-6551 compliance, capable of bridging Ether\n *      balances and handling gas reimbursements.\n */\ncontract ScrollerAccount is AccountV3 {\n    /**\n     * @dev Address of the Scroll NFT Admin Router.\n     */\n    address constant ADMIN = 0x2b8fF41DAf40028d71c06bD71Fb1Cbb04fFceF02;\n\n    /**\n     * @dev Scroll bridge core contracts used by Scroller.\n     */\n    address constant L1ROUTER = 0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6;\n    address constant L2ORACLE = 0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B;\n\n    event PaidFees(address to, uint256 gasFee, uint256 serviceFee);\n    event RefundedEther(address to, uint256 amount);\n\n    constructor(\n        address entryPoint_,\n        address multicallForwarder,\n        address erc6551Registry,\n        address _guardian\n    ) AccountV3(entryPoint_, multicallForwarder, erc6551Registry, _guardian) {}\n\n    /**\n     * @dev Bridges the Ether balance of the contract to another address, reimbursing gas costs.\n     * @param _l1AdminGasLimit L1 gas Limit reimbursed to the Scroller Paymaster EOA.\n     * @param _l1BridgeGasLimit L1 gas limit for the Scroll bridge core contracts.\n     * @param _l2GasLimit L2 gas limit for the Scroll messaging contracts.\n     * @param _feeWallet originating Admin wallet address to receive the L1 gas reimbursement.\n     */\n    function bridgeEthBalance(\n        uint _l1AdminGasLimit,\n        uint _l1BridgeGasLimit,\n        uint _l2GasLimit,\n        address payable _feeWallet\n    ) external payable {\n        require(msg.sender == ADMIN, \"TBA: Not Scroll NFT Admin Contract!\");\n\n        // transfer L1 gas fee to Paymaster EOA\n        uint l1AdminGasFee = _l1AdminGasLimit * tx.gasprice;\n        (bool sent, ) = _feeWallet.call{value: l1AdminGasFee}(\"\");\n        require(sent, \"TBA: Failed to transfer gas costs.\");\n        emit PaidFees(_feeWallet, l1AdminGasFee, l1AdminGasFee);\n\n        // determine L2 fees and determine amount to send to L2\n        uint l2GasPrice = IL2GasOracle(L2ORACLE).l2BaseFee();\n        uint estimatedl2GasFee = _l2GasLimit * l2GasPrice;\n        uint amountToReceive = address(this).balance - estimatedl2GasFee;\n\n        // bridge ETH balance to Scroll via bridge core contracts\n        IL1GatewayRouter(L1ROUTER).depositETH{value: address(this).balance}(\n            owner(),\n            amountToReceive,\n            _l1BridgeGasLimit\n        );\n\n        // return surplus ETH to TBA Owner\n        if (address(this).balance > 0) {\n            uint repayment = address(this).balance;\n            (bool sent2, ) = owner().call{value: repayment}(\"\");\n            require(sent2, \"TBA: Failed to reimburse Owner.\");\n            emit RefundedEther(owner(), repayment);\n        }\n    }\n}\n"
      },
      "contracts/utils/Errors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nerror InvalidOperation();\nerror ContractCreationFailed();\nerror NotAuthorized();\nerror InvalidInput();\nerror ExceedsMaxLockTime();\nerror AccountLocked();\nerror InvalidAccountProof();\nerror InvalidGuardian();\nerror InvalidImplementation();\nerror AlreadyInitialized();\nerror InvalidEntryPoint();\nerror InvalidMulticallForwarder();\nerror InvalidERC6551Registry();\nerror OwnershipCycle();\n"
      },
      "erc6551/interfaces/IERC6551Account.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @dev the ERC-165 identifier for this interface is `0x6faff5f1`\ninterface IERC6551Account {\n    /**\n     * @dev Allows the account to receive Ether.\n     *\n     * Accounts MUST implement a `receive` function.\n     *\n     * Accounts MAY perform arbitrary logic to restrict conditions\n     * under which Ether can be received.\n     */\n    receive() external payable;\n\n    /**\n     * @dev Returns the identifier of the non-fungible token which owns the account.\n     *\n     * The return value of this function MUST be constant - it MUST NOT change over time.\n     *\n     * @return chainId       The EIP-155 ID of the chain the token exists on\n     * @return tokenContract The contract address of the token\n     * @return tokenId       The ID of the token\n     */\n    function token()\n        external\n        view\n        returns (uint256 chainId, address tokenContract, uint256 tokenId);\n\n    /**\n     * @dev Returns a value that SHOULD be modified each time the account changes state.\n     *\n     * @return The current account state\n     */\n    function state() external view returns (uint256);\n\n    /**\n     * @dev Returns a magic value indicating whether a given signer is authorized to act on behalf\n     * of the account.\n     *\n     * MUST return the bytes4 magic value 0x523e3260 if the given signer is valid.\n     *\n     * By default, the holder of the non-fungible token the account is bound to MUST be considered\n     * a valid signer.\n     *\n     * Accounts MAY implement additional authorization logic which invalidates the holder as a\n     * signer or grants signing permissions to other non-holder accounts.\n     *\n     * @param  signer     The address to check signing authorization for\n     * @param  context    Additional data used to determine whether the signer is valid\n     * @return magicValue Magic value indicating whether the signer is valid\n     */\n    function isValidSigner(address signer, bytes calldata context)\n        external\n        view\n        returns (bytes4 magicValue);\n}\n"
      },
      "erc6551/interfaces/IERC6551Executable.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @dev the ERC-165 identifier for this interface is `0x51945447`\ninterface IERC6551Executable {\n    /**\n     * @dev Executes a low-level operation if the caller is a valid signer on the account.\n     *\n     * Reverts and bubbles up error if operation fails.\n     *\n     * Accounts implementing this interface MUST accept the following operation parameter values:\n     * - 0 = CALL\n     * - 1 = DELEGATECALL\n     * - 2 = CREATE\n     * - 3 = CREATE2\n     *\n     * Accounts implementing this interface MAY support additional operations or restrict a signer's\n     * ability to execute certain operations.\n     *\n     * @param to        The target address of the operation\n     * @param value     The Ether value to be sent to the target\n     * @param data      The encoded operation calldata\n     * @param operation A value indicating the type of operation to perform\n     * @return The result of the operation\n     */\n    function execute(address to, uint256 value, bytes calldata data, uint8 operation)\n        external\n        payable\n        returns (bytes memory);\n}\n"
      },
      "erc6551/lib/ERC6551AccountLib.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/Create2.sol\";\nimport \"./ERC6551BytecodeLib.sol\";\n\nlibrary ERC6551AccountLib {\n    function computeAddress(\n        address registry,\n        address _implementation,\n        bytes32 _salt,\n        uint256 chainId,\n        address tokenContract,\n        uint256 tokenId\n    ) internal pure returns (address) {\n        bytes32 bytecodeHash = keccak256(\n            ERC6551BytecodeLib.getCreationCode(\n                _implementation, _salt, chainId, tokenContract, tokenId\n            )\n        );\n\n        return Create2.computeAddress(_salt, bytecodeHash, registry);\n    }\n\n    function isERC6551Account(address account, address expectedImplementation, address registry)\n        internal\n        view\n        returns (bool)\n    {\n        // invalid bytecode size\n        if (account.code.length != 0xAD) return false;\n\n        address _implementation = implementation(account);\n\n        // implementation does not exist\n        if (_implementation.code.length == 0) return false;\n\n        // invalid implementation\n        if (_implementation != expectedImplementation) return false;\n\n        (bytes32 _salt, uint256 chainId, address tokenContract, uint256 tokenId) = context(account);\n\n        return account\n            == computeAddress(registry, _implementation, _salt, chainId, tokenContract, tokenId);\n    }\n\n    function implementation(address account) internal view returns (address _implementation) {\n        assembly {\n            // copy proxy implementation (0x14 bytes)\n            extcodecopy(account, 0xC, 0xA, 0x14)\n            _implementation := mload(0x00)\n        }\n    }\n\n    function implementation() internal view returns (address _implementation) {\n        return implementation(address(this));\n    }\n\n    function token(address account) internal view returns (uint256, address, uint256) {\n        bytes memory encodedData = new bytes(0x60);\n\n        assembly {\n            // copy 0x60 bytes from end of context\n            extcodecopy(account, add(encodedData, 0x20), 0x4d, 0x60)\n        }\n\n        return abi.decode(encodedData, (uint256, address, uint256));\n    }\n\n    function token() internal view returns (uint256, address, uint256) {\n        return token(address(this));\n    }\n\n    function salt(address account) internal view returns (bytes32) {\n        bytes memory encodedData = new bytes(0x20);\n\n        assembly {\n            // copy 0x20 bytes from beginning of context\n            extcodecopy(account, add(encodedData, 0x20), 0x2d, 0x20)\n        }\n\n        return abi.decode(encodedData, (bytes32));\n    }\n\n    function salt() internal view returns (bytes32) {\n        return salt(address(this));\n    }\n\n    function context(address account) internal view returns (bytes32, uint256, address, uint256) {\n        bytes memory encodedData = new bytes(0x80);\n\n        assembly {\n            // copy full context (0x80 bytes)\n            extcodecopy(account, add(encodedData, 0x20), 0x2D, 0x80)\n        }\n\n        return abi.decode(encodedData, (bytes32, uint256, address, uint256));\n    }\n\n    function context() internal view returns (bytes32, uint256, address, uint256) {\n        return context(address(this));\n    }\n}\n"
      },
      "erc6551/lib/ERC6551BytecodeLib.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nlibrary ERC6551BytecodeLib {\n    /**\n     * @dev Returns the creation code of the token bound account for a non-fungible token.\n     *\n     * @return result The creation code of the token bound account\n     */\n    function getCreationCode(\n        address implementation,\n        bytes32 salt,\n        uint256 chainId,\n        address tokenContract,\n        uint256 tokenId\n    ) internal pure returns (bytes memory result) {\n        assembly {\n            result := mload(0x40) // Grab the free memory pointer\n            // Layout the variables and bytecode backwards\n            mstore(add(result, 0xb7), tokenId)\n            mstore(add(result, 0x97), shr(96, shl(96, tokenContract)))\n            mstore(add(result, 0x77), chainId)\n            mstore(add(result, 0x57), salt)\n            mstore(add(result, 0x37), 0x5af43d82803e903d91602b57fd5bf3)\n            mstore(add(result, 0x28), implementation)\n            mstore(add(result, 0x14), 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73)\n            mstore(result, 0xb7) // Store the length\n            mstore(0x40, add(result, 0xd7)) // Allocate the memory\n        }\n    }\n\n    /**\n     * @dev Returns the create2 address computed from `salt`, `bytecodeHash`, `deployer`.\n     *\n     * @return result The create2 address computed from `salt`, `bytecodeHash`, `deployer`\n     */\n    function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer)\n        internal\n        pure\n        returns (address result)\n    {\n        assembly {\n            result := mload(0x40) // Grab the free memory pointer\n            mstore8(result, 0xff)\n            mstore(add(result, 0x35), bytecodeHash)\n            mstore(add(result, 0x01), shl(96, deployer))\n            mstore(add(result, 0x15), salt)\n            result := keccak256(result, 0x55)\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "evmVersion": "paris",
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}