{"file_path":"src/DelegationManager.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport { MessageHashUtils } from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport { ECDSA } from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport { Ownable2Step, Ownable } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport { IERC1271 } from \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\nimport { Pausable } from \"@openzeppelin/contracts/utils/Pausable.sol\";\nimport { EIP712 } from \"@openzeppelin/contracts/utils/cryptography/EIP712.sol\";\n\nimport { ICaveatEnforcer } from \"./interfaces/ICaveatEnforcer.sol\";\nimport { IDelegationManager } from \"./interfaces/IDelegationManager.sol\";\nimport { IDeleGatorCore } from \"./interfaces/IDeleGatorCore.sol\";\nimport { Delegation, Caveat, ModeCode } from \"./utils/Types.sol\";\nimport { EncoderLib } from \"./libraries/EncoderLib.sol\";\nimport { ERC1271Lib } from \"./libraries/ERC1271Lib.sol\";\n\n/**\n * @title DelegationManager\n * @notice This contract is used to manage delegations.\n * Delegations can be validated and executed through this contract.\n */\ncontract DelegationManager is IDelegationManager, Ownable2Step, Pausable, EIP712 {\n    using MessageHashUtils for bytes32;\n\n    ////////////////////////////// State //////////////////////////////\n\n    /// @dev The name of the contract\n    string public constant NAME = \"DelegationManager\";\n\n    /// @dev The full version of the contract\n    string public constant VERSION = \"1.3.0\";\n\n    /// @dev The version used in the domainSeparator for EIP712\n    string public constant DOMAIN_VERSION = \"1\";\n\n    /// @dev Special authority value. Indicates that the delegator is the authority\n    bytes32 public constant ROOT_AUTHORITY = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\n\n    /// @dev Special delegate value. Allows any delegate to redeem the delegation\n    address public constant ANY_DELEGATE = address(0xa11);\n\n    /// @dev A mapping of delegation hashes that have been disabled by the delegator\n    mapping(bytes32 delegationHash => bool isDisabled) public disabledDelegations;\n\n    ////////////////////////////// Modifier //////////////////////////////\n\n    /**\n     * @notice Require the caller to be the delegator\n     * This is to prevent others from accessing protected methods.\n     * @dev Check that the caller is delegator.\n     */\n    modifier onlyDeleGator(address delegator) {\n        if (delegator != msg.sender) revert InvalidDelegator();\n        _;\n    }\n\n    ////////////////////////////// Constructor //////////////////////////////\n\n    /**\n     * @notice Initializes Ownable and the DelegationManager's state\n     * @param _owner The initial owner of the contract\n     */\n    constructor(address _owner) Ownable(_owner) EIP712(NAME, DOMAIN_VERSION) {\n        bytes32 DOMAIN_HASH = _domainSeparatorV4();\n        emit SetDomain(DOMAIN_HASH, NAME, DOMAIN_VERSION, block.chainid, address(this));\n    }\n\n    ////////////////////////////// External Methods //////////////////////////////\n\n    /**\n     * @notice Allows the owner of the DelegationManager to pause delegation redemption functionality\n     */\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /**\n     * @notice Allows the owner of the DelegationManager to unpause the delegation redemption functionality\n     */\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    /**\n     * @notice This method is used to disable a delegation. Disabled delegations will fail upon redemption.\n     * @dev This method MUST be called by the delegator\n     * @param _delegation The delegation to be disabled\n     */\n    function disableDelegation(Delegation calldata _delegation) external onlyDeleGator(_delegation.delegator) {\n        bytes32 delegationHash_ = getDelegationHash(_delegation);\n        if (disabledDelegations[delegationHash_]) revert AlreadyDisabled();\n        disabledDelegations[delegationHash_] = true;\n        emit DisabledDelegation(delegationHash_, _delegation.delegator, _delegation.delegate, _delegation);\n    }\n\n    /**\n     * @notice This method is used to enable a delegation\n     * @dev This method MUST be called by the delegator\n     * @dev This method is only needed when a delegation has previously been disabled\n     * @param _delegation The delegation to be disabled\n     */\n    function enableDelegation(Delegation calldata _delegation) external onlyDeleGator(_delegation.delegator) {\n        bytes32 delegationHash_ = getDelegationHash(_delegation);\n        if (!disabledDelegations[delegationHash_]) revert AlreadyEnabled();\n        disabledDelegations[delegationHash_] = false;\n        emit EnabledDelegation(delegationHash_, _delegation.delegator, _delegation.delegate, _delegation);\n    }\n\n    /**\n     * @notice Validates permission contexts and executes batch actions if the caller is authorized.\n     * @dev For each execution in the batch:\n     *      - Calls `beforeAllHook` before any actions begin.\n     *      - For each delegation, calls `beforeHook` before its execution.\n     *      - Executes the call data.\n     *      - For each delegation, calls `afterHook` after execution.\n     *      - Calls `afterAllHook` after all actions are completed.\n     *      If any hook fails, the entire transaction reverts.\n     *\n     * @dev The lengths of `_permissionContexts`, `_modes`, and `_executionCallDatas` must be equal.\n     * @param _permissionContexts An array where each element is an array of `Delegation` structs used for\n     * authority validation ordered from leaf to root. An empty entry denotes self-authorization.\n     * @param _modes An array specifying modes to execute the corresponding `_executionCallDatas`.\n     * @param _executionCallDatas An array of encoded actions to be executed.\n     */\n    function redeemDelegations(\n        bytes[] calldata _permissionContexts,\n        ModeCode[] calldata _modes,\n        bytes[] calldata _executionCallDatas\n    )\n        external\n        whenNotPaused\n    {\n        uint256 batchSize_ = _permissionContexts.length;\n        if (batchSize_ != _executionCallDatas.length || batchSize_ != _modes.length) revert BatchDataLengthMismatch();\n\n        Delegation[][] memory batchDelegations_ = new Delegation[][](batchSize_);\n        bytes32[][] memory batchDelegationHashes_ = new bytes32[][](batchSize_);\n\n        // Validate and process delegations for each execution\n        for (uint256 batchIndex_; batchIndex_ < batchSize_; ++batchIndex_) {\n            Delegation[] memory delegations_ = abi.decode(_permissionContexts[batchIndex_], (Delegation[]));\n\n            if (delegations_.length == 0) {\n                // Special case: If the permissionContext is empty, treat it as a self authorized execution\n                batchDelegations_[batchIndex_] = new Delegation[](0);\n                batchDelegationHashes_[batchIndex_] = new bytes32[](0);\n            } else {\n                batchDelegations_[batchIndex_] = delegations_;\n\n                // Load delegation hashes and validate signatures (leaf to root)\n                bytes32[] memory delegationHashes_ = new bytes32[](delegations_.length);\n                batchDelegationHashes_[batchIndex_] = delegationHashes_;\n\n                // Validate caller\n                if (delegations_[0].delegate != msg.sender && delegations_[0].delegate != ANY_DELEGATE) {\n                    revert InvalidDelegate();\n                }\n\n                for (uint256 delegationsIndex_; delegationsIndex_ < delegations_.length; ++delegationsIndex_) {\n                    Delegation memory delegation_ = delegations_[delegationsIndex_];\n                    delegationHashes_[delegationsIndex_] = EncoderLib._getDelegationHash(delegation_);\n\n                    if (delegation_.delegator.code.length == 0) {\n                        // Validate delegation if it's an EOA\n                        address result_ = ECDSA.recover(\n                            MessageHashUtils.toTypedDataHash(getDomainHash(), delegationHashes_[delegationsIndex_]),\n                            delegation_.signature\n                        );\n                        if (result_ != delegation_.delegator) revert InvalidEOASignature();\n                    } else {\n                        // Validate delegation if it's a contract\n                        bytes32 typedDataHash_ =\n                            MessageHashUtils.toTypedDataHash(getDomainHash(), delegationHashes_[delegationsIndex_]);\n\n                        bytes32 result_ = IERC1271(delegation_.delegator).isValidSignature(typedDataHash_, delegation_.signature);\n                        if (result_ != ERC1271Lib.EIP1271_MAGIC_VALUE) {\n                            revert InvalidERC1271Signature();\n                        }\n                    }\n                }\n\n                // Validate authority and delegate (leaf to root)\n                for (uint256 delegationsIndex_; delegationsIndex_ < delegations_.length; ++delegationsIndex_) {\n                    // Validate if delegation is disabled\n                    if (disabledDelegations[delegationHashes_[delegationsIndex_]]) {\n                        revert CannotUseADisabledDelegation();\n                    }\n\n                    // Validate authority\n                    if (delegationsIndex_ != delegations_.length - 1) {\n                        if (delegations_[delegationsIndex_].authority != delegationHashes_[delegationsIndex_ + 1]) {\n                            revert InvalidAuthority();\n                        }\n                        // Validate delegate\n                        address nextDelegate_ = delegations_[delegationsIndex_ + 1].delegate;\n                        if (nextDelegate_ != ANY_DELEGATE && delegations_[delegationsIndex_].delegator != nextDelegate_) {\n                            revert InvalidDelegate();\n                        }\n                    } else if (delegations_[delegationsIndex_].authority != ROOT_AUTHORITY) {\n                        revert InvalidAuthority();\n                    }\n                }\n            }\n        }\n\n        // beforeAllHook (leaf to root)\n        for (uint256 batchIndex_; batchIndex_ < batchSize_; ++batchIndex_) {\n            if (batchDelegations_[batchIndex_].length > 0) {\n                // Execute beforeAllHooks\n                for (uint256 delegationsIndex_; delegationsIndex_ < batchDelegations_[batchIndex_].length; ++delegationsIndex_) {\n                    Caveat[] memory caveats_ = batchDelegations_[batchIndex_][delegationsIndex_].caveats;\n                    for (uint256 caveatsIndex_; caveatsIndex_ < caveats_.length; ++caveatsIndex_) {\n                        ICaveatEnforcer enforcer_ = ICaveatEnforcer(caveats_[caveatsIndex_].enforcer);\n                        enforcer_.beforeAllHook(\n                            caveats_[caveatsIndex_].terms,\n                            caveats_[caveatsIndex_].args,\n                            _modes[batchIndex_],\n                            _executionCallDatas[batchIndex_],\n                            batchDelegationHashes_[batchIndex_][delegationsIndex_],\n                            batchDelegations_[batchIndex_][delegationsIndex_].delegator,\n                            msg.sender\n                        );\n                    }\n                }\n            }\n        }\n\n        for (uint256 batchIndex_; batchIndex_ < batchSize_; ++batchIndex_) {\n            if (batchDelegations_[batchIndex_].length == 0) {\n                // Special case: If there are no delegations, defer the call to the caller.\n                IDeleGatorCore(msg.sender).executeFromExecutor(_modes[batchIndex_], _executionCallDatas[batchIndex_]);\n            } else {\n                // Execute beforeHooks\n                for (uint256 delegationsIndex_; delegationsIndex_ < batchDelegations_[batchIndex_].length; ++delegationsIndex_) {\n                    Caveat[] memory caveats_ = batchDelegations_[batchIndex_][delegationsIndex_].caveats;\n                    for (uint256 caveatsIndex_; caveatsIndex_ < caveats_.length; ++caveatsIndex_) {\n                        ICaveatEnforcer enforcer_ = ICaveatEnforcer(caveats_[caveatsIndex_].enforcer);\n                        enforcer_.beforeHook(\n                            caveats_[caveatsIndex_].terms,\n                            caveats_[caveatsIndex_].args,\n                            _modes[batchIndex_],\n                            _executionCallDatas[batchIndex_],\n                            batchDelegationHashes_[batchIndex_][delegationsIndex_],\n                            batchDelegations_[batchIndex_][delegationsIndex_].delegator,\n                            msg.sender\n                        );\n                    }\n                }\n\n                // Perform execution\n                IDeleGatorCore(batchDelegations_[batchIndex_][batchDelegations_[batchIndex_].length - 1].delegator)\n                    .executeFromExecutor(_modes[batchIndex_], _executionCallDatas[batchIndex_]);\n\n                // Execute afterHooks\n                for (uint256 delegationsIndex_ = batchDelegations_[batchIndex_].length; delegationsIndex_ > 0; --delegationsIndex_)\n                {\n                    Caveat[] memory caveats_ = batchDelegations_[batchIndex_][delegationsIndex_ - 1].caveats;\n                    for (uint256 caveatsIndex_ = caveats_.length; caveatsIndex_ > 0; --caveatsIndex_) {\n                        ICaveatEnforcer enforcer_ = ICaveatEnforcer(caveats_[caveatsIndex_ - 1].enforcer);\n                        enforcer_.afterHook(\n                            caveats_[caveatsIndex_ - 1].terms,\n                            caveats_[caveatsIndex_ - 1].args,\n                            _modes[batchIndex_],\n                            _executionCallDatas[batchIndex_],\n                            batchDelegationHashes_[batchIndex_][delegationsIndex_ - 1],\n                            batchDelegations_[batchIndex_][delegationsIndex_ - 1].delegator,\n                            msg.sender\n                        );\n                    }\n                }\n            }\n        }\n\n        // afterAllHook (root to leaf)\n        for (uint256 batchIndex_; batchIndex_ < batchSize_; ++batchIndex_) {\n            if (batchDelegations_[batchIndex_].length > 0) {\n                // Execute afterAllHooks\n                for (uint256 delegationsIndex_ = batchDelegations_[batchIndex_].length; delegationsIndex_ > 0; --delegationsIndex_)\n                {\n                    Caveat[] memory caveats_ = batchDelegations_[batchIndex_][delegationsIndex_ - 1].caveats;\n                    for (uint256 caveatsIndex_ = caveats_.length; caveatsIndex_ > 0; --caveatsIndex_) {\n                        ICaveatEnforcer enforcer_ = ICaveatEnforcer(caveats_[caveatsIndex_ - 1].enforcer);\n                        enforcer_.afterAllHook(\n                            caveats_[caveatsIndex_ - 1].terms,\n                            caveats_[caveatsIndex_ - 1].args,\n                            _modes[batchIndex_],\n                            _executionCallDatas[batchIndex_],\n                            batchDelegationHashes_[batchIndex_][delegationsIndex_ - 1],\n                            batchDelegations_[batchIndex_][delegationsIndex_ - 1].delegator,\n                            msg.sender\n                        );\n                    }\n                }\n            }\n        }\n\n        for (uint256 batchIndex_; batchIndex_ < batchSize_; ++batchIndex_) {\n            if (batchDelegations_[batchIndex_].length > 0) {\n                for (uint256 delegationsIndex_; delegationsIndex_ < batchDelegations_[batchIndex_].length; ++delegationsIndex_) {\n                    emit RedeemedDelegation(\n                        batchDelegations_[batchIndex_][batchDelegations_[batchIndex_].length - 1].delegator,\n                        msg.sender,\n                        batchDelegations_[batchIndex_][delegationsIndex_]\n                    );\n                }\n            }\n        }\n    }\n\n    /**\n     * @notice This method returns the domain hash used for signing typed data\n     * @return bytes32 The domain hash\n     */\n    function getDomainHash() public view returns (bytes32) {\n        return _domainSeparatorV4();\n    }\n\n    /**\n     * @notice Creates a hash of a Delegation\n     * @dev Used in EIP712 signatures and as a key for enabling and disabling delegations\n     * @param _input A Delegation struct\n     */\n    function getDelegationHash(Delegation calldata _input) public pure returns (bytes32) {\n        return EncoderLib._getDelegationHash(_input);\n    }\n}\n","deployed_bytecode":"0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806383ebb771116100ad578063acb8cc4911610071578063acb8cc491461027f578063cef6d2091461029f578063e30c3978146102b2578063f2fde38b146102c3578063ffa1ad74146102d657600080fd5b806383ebb771146102065780638456cb591461020e57806384b0196e146102165780638da5cb5b14610231578063a3f4df7e1461024257600080fd5b806358909ebc116100f457806358909ebc146101b05780635c975abb146101d157806366134607146101e3578063715018a6146101f657806379ba5097146101fe57600080fd5b80631b13cac2146101315780632d40d0521461014d5780633ed01015146101805780633f4ba83a14610195578063499340471461019d575b600080fd5b61013a60001981565b6040519081526020015b60405180910390f35b61017061015b3660046120e6565b60046020526000908152604090205460ff1681565b6040519015158152602001610144565b61019361018e3660046120ff565b6102fa565b005b6101936103f4565b6101936101ab3660046120ff565b610406565b6101b9610a1181565b6040516001600160a01b039091168152602001610144565b600154600160a01b900460ff16610170565b61013a6101f13660046120ff565b6104f6565b61019361050f565b610193610521565b61013a61056a565b610193610579565b61021e610589565b6040516101449796959493929190612190565b6000546001600160a01b03166101b9565b610272604051806040016040528060118152602001702232b632b3b0ba34b7b726b0b730b3b2b960791b81525081565b6040516101449190612229565b610272604051806040016040528060018152602001603160f81b81525081565b6101936102ad366004612287565b6105cf565b6001546001600160a01b03166101b9565b6101936102d136600461233c565b611891565b610272604051806040016040528060058152602001640312e332e360dc1b81525081565b61030a604082016020830161233c565b6001600160a01b03811633146103335760405163b9f0f17160e01b815260040160405180910390fd5b600061033e836104f6565b60008181526004602052604090205490915060ff1661037057604051637952fbad60e11b815260040160405180910390fd5b6000818152600460209081526040909120805460ff191690556103959084018461233c565b6001600160a01b03166103ae604085016020860161233c565b6001600160a01b0316827f3feadce88fc1b49db633a56fd5307ed6ee18734df83bcc4011daa720c9cd95f1866040516103e79190612484565b60405180910390a4505050565b6103fc611902565b61040461192f565b565b610416604082016020830161233c565b6001600160a01b038116331461043f5760405163b9f0f17160e01b815260040160405180910390fd5b600061044a836104f6565b60008181526004602052604090205490915060ff161561047c57604051625ecddb60e01b815260040160405180910390fd5b6000818152600460209081526040909120805460ff191660011790556104a49084018461233c565b6001600160a01b03166104bd604085016020860161233c565b6001600160a01b0316827fea589ba9473ee1fe77d352c7ed919747715a5d22931b972de9b02a907c66d5dd866040516103e79190612484565b600061050961050483612823565b611984565b92915050565b610517611902565b6104046000611a1f565b60015433906001600160a01b0316811461055e5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61056781611a1f565b50565b6000610574611a38565b905090565b610581611902565b610404611b63565b60006060806000806000606061059d611ba6565b6105a5611bd3565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b6105d7611c00565b8481811415806105e75750808414155b1561060557604051631bcaf69f60e01b815260040160405180910390fd5b6000816001600160401b0381111561061f5761061f612555565b60405190808252806020026020018201604052801561065257816020015b606081526020019060019003908161063d5790505b5090506000826001600160401b0381111561066f5761066f612555565b6040519080825280602002602001820160405280156106a257816020015b606081526020019060019003908161068d5790505b50905060005b83811015610c815760008a8a838181106106c4576106c461282f565b90506020028101906106d69190612845565b8101906106e3919061288b565b905080516000036107d1576040805160008082526020820190925290610765565b6107526040518060c0016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600080191681526020016060815260200160008152602001606081525090565b8152602001906001900390816107045790505b508483815181106107785761077861282f565b602090810291909101015260006040519080825280602002602001820160405280156107ae578160200160208202803683370190505b508383815181106107c1576107c161282f565b6020026020010181905250610c78565b808483815181106107e4576107e461282f565b6020026020010181905250600081516001600160401b0381111561080a5761080a612555565b604051908082528060200260200182016040528015610833578160200160208202803683370190505b509050808484815181106108495761084961282f565b6020026020010181905250336001600160a01b0316826000815181106108715761087161282f565b6020026020010151600001516001600160a01b0316141580156108c65750610a116001600160a01b0316826000815181106108ae576108ae61282f565b6020026020010151600001516001600160a01b031614155b156108e457604051632d618d8160e21b815260040160405180910390fd5b60005b8251811015610ab55760008382815181106109045761090461282f565b6020026020010151905061091781611984565b8383815181106109295761092961282f565b60200260200101818152505080602001516001600160a01b03163b6000036109dc57600061099e61099461095b61056a565b86868151811061096d5761096d61282f565b602002602001015160405161190160f01b8152600281019290925260228201526042902090565b8360a00151611c2b565b905081602001516001600160a01b0316816001600160a01b0316146109d657604051630f6d9e4760e21b815260040160405180910390fd5b50610aac565b60006109fb6109e961056a565b85858151811061096d5761096d61282f565b9050600082602001516001600160a01b0316631626ba7e838560a001516040518363ffffffff1660e01b8152600401610a3592919061293b565b602060405180830381865afa158015610a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a76919061295c565b6001600160e01b0319169050630b135d3f60e11b8114610aa95760405163155ff42760e01b815260040160405180910390fd5b50505b506001016108e7565b5060005b8251811015610c755760046000838381518110610ad857610ad861282f565b60209081029190910181015182528101919091526040016000205460ff1615610b14576040516302dd502960e11b815260040160405180910390fd5b60018351610b22919061299c565b8114610c2b5781610b348260016129af565b81518110610b4457610b4461282f565b6020026020010151838281518110610b5e57610b5e61282f565b60200260200101516040015114610b8857604051636f6a1b8760e11b815260040160405180910390fd5b600083610b968360016129af565b81518110610ba657610ba661282f565b6020026020010151600001519050610a116001600160a01b0316816001600160a01b031614158015610c075750806001600160a01b0316848381518110610bef57610bef61282f565b6020026020010151602001516001600160a01b031614155b15610c2557604051632d618d8160e21b815260040160405180910390fd5b50610c6d565b60001960001b838281518110610c4357610c4361282f565b60200260200101516040015114610c6d57604051636f6a1b8760e11b815260040160405180910390fd5b600101610ab9565b50505b506001016106a8565b5060005b83811015610ea6576000838281518110610ca157610ca161282f565b6020026020010151511115610e9e5760005b838281518110610cc557610cc561282f565b602002602001015151811015610e9c576000848381518110610ce957610ce961282f565b60200260200101518281518110610d0257610d0261282f565b602002602001015160600151905060005b8151811015610e92576000828281518110610d3057610d3061282f565b6020026020010151600001519050806001600160a01b031663414c3e33848481518110610d5f57610d5f61282f565b602002602001015160200151858581518110610d7d57610d7d61282f565b6020026020010151604001518f8f8a818110610d9b57610d9b61282f565b905060200201358e8e8b818110610db457610db461282f565b9050602002810190610dc69190612845565b8c8c81518110610dd857610dd861282f565b60200260200101518b81518110610df157610df161282f565b60200260200101518e8d81518110610e0b57610e0b61282f565b60200260200101518c81518110610e2457610e2461282f565b602002602001015160200151336040518963ffffffff1660e01b8152600401610e549897969594939291906129c2565b600060405180830381600087803b158015610e6e57600080fd5b505af1158015610e82573d6000803e3d6000fd5b5050505050806001019050610d13565b5050600101610cb3565b505b600101610c85565b5060005b838110156114ca57828181518110610ec457610ec461282f565b602002602001015151600003610f82573363d691c964898984818110610eec57610eec61282f565b90506020020135888885818110610f0557610f0561282f565b9050602002810190610f179190612845565b6040518463ffffffff1660e01b8152600401610f3593929190612a2d565b6000604051808303816000875af1158015610f54573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f7c9190810190612a50565b506114c2565b60005b838281518110610f9757610f9761282f565b60200260200101515181101561116e576000848381518110610fbb57610fbb61282f565b60200260200101518281518110610fd457610fd461282f565b602002602001015160600151905060005b81518110156111645760008282815181106110025761100261282f565b6020026020010151600001519050806001600160a01b031663a145832a8484815181106110315761103161282f565b60200260200101516020015185858151811061104f5761104f61282f565b6020026020010151604001518f8f8a81811061106d5761106d61282f565b905060200201358e8e8b8181106110865761108661282f565b90506020028101906110989190612845565b8c8c815181106110aa576110aa61282f565b60200260200101518b815181106110c3576110c361282f565b60200260200101518e8d815181106110dd576110dd61282f565b60200260200101518c815181106110f6576110f661282f565b602002602001015160200151336040518963ffffffff1660e01b81526004016111269897969594939291906129c2565b600060405180830381600087803b15801561114057600080fd5b505af1158015611154573d6000803e3d6000fd5b5050505050806001019050610fe5565b5050600101610f85565b508281815181106111815761118161282f565b6020026020010151600184838151811061119d5761119d61282f565b6020026020010151516111b0919061299c565b815181106111c0576111c061282f565b6020026020010151602001516001600160a01b031663d691c9648989848181106111ec576111ec61282f565b905060200201358888858181106112055761120561282f565b90506020028101906112179190612845565b6040518463ffffffff1660e01b815260040161123593929190612a2d565b6000604051808303816000875af1158015611254573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261127c9190810190612a50565b5060008382815181106112915761129161282f565b60200260200101515190505b80156114c05760008483815181106112b7576112b761282f565b60200260200101516001836112cc919061299c565b815181106112dc576112dc61282f565b60200260200101516060015190506000815190505b80156114ad5760008261130560018461299c565b815181106113155761131561282f565b6020026020010151600001519050806001600160a01b031663d3eddcc584600185611340919061299c565b815181106113505761135061282f565b6020026020010151602001518560018661136a919061299c565b8151811061137a5761137a61282f565b6020026020010151604001518f8f8a8181106113985761139861282f565b905060200201358e8e8b8181106113b1576113b161282f565b90506020028101906113c39190612845565b8c8c815181106113d5576113d561282f565b602002602001015160018c6113ea919061299c565b815181106113fa576113fa61282f565b60200260200101518e8d815181106114145761141461282f565b602002602001015160018d611429919061299c565b815181106114395761143961282f565b602002602001015160200151336040518963ffffffff1660e01b81526004016114699897969594939291906129c2565b600060405180830381600087803b15801561148357600080fd5b505af1158015611497573d6000803e3d6000fd5b5050505050806114a690612b2f565b90506112f1565b5050806114b990612b2f565b905061129d565b505b600101610eaa565b5060005b838110156117465760008382815181106114ea576114ea61282f565b602002602001015151111561173e57600083828151811061150d5761150d61282f565b60200260200101515190505b801561173c5760008483815181106115335761153361282f565b6020026020010151600183611548919061299c565b815181106115585761155861282f565b60200260200101516060015190506000815190505b80156117295760008261158160018461299c565b815181106115915761159161282f565b6020026020010151600001519050806001600160a01b031663ed463367846001856115bc919061299c565b815181106115cc576115cc61282f565b602002602001015160200151856001866115e6919061299c565b815181106115f6576115f661282f565b6020026020010151604001518f8f8a8181106116145761161461282f565b905060200201358e8e8b81811061162d5761162d61282f565b905060200281019061163f9190612845565b8c8c815181106116515761165161282f565b602002602001015160018c611666919061299c565b815181106116765761167661282f565b60200260200101518e8d815181106116905761169061282f565b602002602001015160018d6116a5919061299c565b815181106116b5576116b561282f565b602002602001015160200151336040518963ffffffff1660e01b81526004016116e59897969594939291906129c2565b600060405180830381600087803b1580156116ff57600080fd5b505af1158015611713573d6000803e3d6000fd5b50505050508061172290612b2f565b905061156d565b50508061173590612b2f565b9050611519565b505b6001016114ce565b5060005b838110156118855760008382815181106117665761176661282f565b602002602001015151111561187d5760005b83828151811061178a5761178a61282f565b60200260200101515181101561187b57336001600160a01b03168483815181106117b6576117b661282f565b602002602001015160018685815181106117d2576117d261282f565b6020026020010151516117e5919061299c565b815181106117f5576117f561282f565b6020026020010151602001516001600160a01b03167f40dadaa36c6c2e3d7317e24757451ffb2d603d875f0ad5e92c5dd156573b187386858151811061183d5761183d61282f565b602002602001015184815181106118565761185661282f565b602002602001015160405161186b9190612b46565b60405180910390a3600101611778565b505b60010161174a565b50505050505050505050565b611899611902565b600180546001600160a01b0383166001600160a01b031990911681179091556118ca6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146104045760405163118cdaa760e01b8152336004820152602401610555565b611937611c55565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000807f88c1d2ecf185adf710588203a5f263f0ff61be0d33da39792cde19ba9aa4331e8360000151846020015185604001516119c48760600151611c7f565b6080808901516040805160208101989098526001600160a01b03968716908801529490931660608601529184015260a083015260c082015260e0015b60408051601f1981840301815291905280516020909101209392505050565b600180546001600160a01b031916905561056781611d4a565b6000306001600160a01b037f000000000000000000000000db9b1e94b5b69df7e401ddbede43491141047db316148015611a9157507f000000000000000000000000000000000000000000000000000000000000000146145b15611abb57507fe787aa44f0f1f6dc6e8298b61d43d7ce553210e2276f628ff277081e74c9c14490565b610574604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f604240e1ed005b9ba256cb7011059bf4ae645812b834bbcb5b22c93e2d1185cc918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b611b6b611c00565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586119673390565b60606105747f44656c65676174696f6e4d616e616765720000000000000000000000000000116002611d9a565b60606105747f31000000000000000000000000000000000000000000000000000000000000016003611d9a565b600154600160a01b900460ff16156104045760405163d93c066560e01b815260040160405180910390fd5b600080600080611c3b8686611e45565b925092509250611c4b8282611e92565b5090949350505050565b600154600160a01b900460ff1661040457604051638dfc202b60e01b815260040160405180910390fd5b60008082516001600160401b03811115611c9b57611c9b612555565b604051908082528060200260200182016040528015611cc4578160200160208202803683370190505b50905060005b8351811015611d1a57611cf5848281518110611ce857611ce861282f565b6020026020010151611f4f565b828281518110611d0757611d0761282f565b6020908102919091010152600101611cca565b5080604051602001611d2c9190612c33565b60405160208183030381529060405280519060200120915050919050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060ff8314611db457611dad83611fb0565b9050610509565b818054611dc090612c69565b80601f0160208091040260200160405190810160405280929190818152602001828054611dec90612c69565b8015611e395780601f10611e0e57610100808354040283529160200191611e39565b820191906000526020600020905b815481529060010190602001808311611e1c57829003601f168201915b50505050509050610509565b60008060008351604103611e7f5760208401516040850151606086015160001a611e7188828585611fef565b955095509550505050611e8b565b50508151600091506002905b9250925092565b6000826003811115611ea657611ea6612ca3565b03611eaf575050565b6001826003811115611ec357611ec3612ca3565b03611ee15760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115611ef557611ef5612ca3565b03611f165760405163fce698f760e01b815260048101829052602401610555565b6003826003811115611f2a57611f2a612ca3565b03611f4b576040516335e2f38360e21b815260048101829052602401610555565b5050565b6000807f80ad7e1b04ee6d994a125f4714ca0720908bd80ed16063ec8aee4b88e9253e2d8360000151846020015180519060200120604051602001611a00939291909283526001600160a01b03919091166020830152604082015260600190565b60606000611fbd836120be565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561202a57506000915060039050826120b4565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561207e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166120aa575060009250600191508290506120b4565b9250600091508190505b9450945094915050565b600060ff8216601f81111561050957604051632cd44ac360e21b815260040160405180910390fd5b6000602082840312156120f857600080fd5b5035919050565b60006020828403121561211157600080fd5b81356001600160401b0381111561212757600080fd5b820160c0818503121561213957600080fd5b9392505050565b60005b8381101561215b578181015183820152602001612143565b50506000910152565b6000815180845261217c816020860160208601612140565b601f01601f19169290920160200192915050565b60ff60f81b881681526000602060e060208401526121b160e084018a612164565b83810360408501526121c3818a612164565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015612217578351835292840192918401916001016121fb565b50909c9b505050505050505050505050565b6020815260006121396020830184612164565b60008083601f84011261224e57600080fd5b5081356001600160401b0381111561226557600080fd5b6020830191508360208260051b850101111561228057600080fd5b9250929050565b600080600080600080606087890312156122a057600080fd5b86356001600160401b03808211156122b757600080fd5b6122c38a838b0161223c565b909850965060208901359150808211156122dc57600080fd5b6122e88a838b0161223c565b9096509450604089013591508082111561230157600080fd5b5061230e89828a0161223c565b979a9699509497509295939492505050565b80356001600160a01b038116811461233757600080fd5b919050565b60006020828403121561234e57600080fd5b61213982612320565b6000808335601e1984360301811261236e57600080fd5b83016020810192503590506001600160401b0381111561238d57600080fd5b80360382131561228057600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008383855260208086019550808560051b830101846000805b8881101561247657858403601f19018a52823536899003605e19018112612404578283fd5b880160606001600160a01b0361241983612320565b16865261242887830183612357565b828989015261243a838901828461239c565b92505050604061244c81840184612357565b93508783038289015261246083858361239c565b9d89019d975050509386019350506001016123df565b509198975050505050505050565b6020815260006001600160a01b038061249c85612320565b166020840152806124af60208601612320565b16604084015250604083013560608301526060830135601e198436030181126124d757600080fd5b83016020810190356001600160401b038111156124f357600080fd5b8060051b360382131561250557600080fd5b60c0608085015261251a60e0850182846123c5565b915050608084013560a084015261253460a0850185612357565b848303601f190160c086015261254b83828461239c565b9695505050505050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171561258d5761258d612555565b60405290565b60405160c081016001600160401b038111828210171561258d5761258d612555565b604051601f8201601f191681016001600160401b03811182821017156125dd576125dd612555565b604052919050565b60006001600160401b038211156125fe576125fe612555565b5060051b60200190565b60006001600160401b0382111561262157612621612555565b50601f01601f191660200190565b600082601f83011261264057600080fd5b813561265361264e82612608565b6125b5565b81815284602083860101111561266857600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f83011261269657600080fd5b813560206126a661264e836125e5565b82815260059290921b840181019181810190868411156126c557600080fd5b8286015b848110156127745780356001600160401b03808211156126e95760008081fd5b908801906060828b03601f19018113156127035760008081fd5b61270b61256b565b612716888501612320565b81526040808501358481111561272c5760008081fd5b61273a8e8b8389010161262f565b838b0152509184013591838311156127525760008081fd5b6127608d8a8588010161262f565b9082015286525050509183019183016126c9565b509695505050505050565b600060c0828403121561279157600080fd5b612799612593565b90506127a482612320565b81526127b260208301612320565b60208201526040820135604082015260608201356001600160401b03808211156127db57600080fd5b6127e785838601612685565b60608401526080840135608084015260a084013591508082111561280a57600080fd5b506128178482850161262f565b60a08301525092915050565b6000610509368361277f565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261285c57600080fd5b8301803591506001600160401b0382111561287657600080fd5b60200191503681900382131561228057600080fd5b6000602080838503121561289e57600080fd5b82356001600160401b03808211156128b557600080fd5b818501915085601f8301126128c957600080fd5b81356128d761264e826125e5565b81815260059190911b830184019084810190888311156128f657600080fd5b8585015b8381101561292e578035858111156129125760008081fd5b6129208b89838a010161277f565b8452509186019186016128fa565b5098975050505050505050565b8281526040602082015260006129546040830184612164565b949350505050565b60006020828403121561296e57600080fd5b81516001600160e01b03198116811461213957600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561050957610509612986565b8082018082111561050957610509612986565b60e0815260006129d560e083018b612164565b82810360208401526129e7818b612164565b90508860408401528281036060840152612a0281888a61239c565b608084019690965250506001600160a01b0392831660a0820152911660c09091015295945050505050565b838152604060208201526000612a4760408301848661239c565b95945050505050565b60006020808385031215612a6357600080fd5b82516001600160401b0380821115612a7a57600080fd5b818501915085601f830112612a8e57600080fd5b8151612a9c61264e826125e5565b81815260059190911b83018401908481019088831115612abb57600080fd5b8585015b8381101561292e57805185811115612ad75760008081fd5b8601603f81018b13612ae95760008081fd5b878101516040612afb61264e83612608565b8281528d82848601011115612b105760008081fd5b612b1f838c8301848701612140565b8652505050918601918601612abf565b600081612b3e57612b3e612986565b506000190190565b602080825282516001600160a01b0390811683830152838201518116604080850191909152808501516060808601919091528086015160c06080870152805160e0870181905260009594610100600583901b8901810195919493870193919290890190885b81811015612c055760ff198b8903018352855187815116895289810151858b8b0152612bd9868b0182612164565b918701518a83038b890152919050612bf18183612164565b995050509488019491880191600101612bab565b50505050505050608085015160a085015260a08501519150601f198482030160c0850152612a478183612164565b815160009082906020808601845b83811015612c5d57815185529382019390820190600101612c41565b50929695505050505050565b600181811c90821680612c7d57607f821691505b602082108103612c9d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220c2284ea0163aafd9aee402e7645e9db93d0c27667921732dd0458883520a475264736f6c63430008170033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"london","libraries":{},"metadata":{"appendCBOR":true,"bytecodeHash":"ipfs","useLiteralContent":false},"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"*":["abi","evm.bytecode.object","evm.bytecode.sourceMap","evm.bytecode.linkReferences","evm.deployedBytecode.object","evm.deployedBytecode.sourceMap","evm.deployedBytecode.linkReferences","evm.deployedBytecode.immutableReferences","evm.methodIdentifiers","metadata"]}},"remappings":["@account-abstraction/=lib/account-abstraction/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-upgradable-contracts/contracts/","ds-test/=lib/forge-std/lib/ds-test/src/","forge-std/=lib/forge-std/src/","@solidity-stringutils/=lib/solidity-stringutils/src/","@bytes-utils/=lib/solidity-bytes-utils/contracts/","@FCL/=lib/FCL/solidity/src/","@erc7579/=lib/erc7579-implementation/src/","@SCL/=lib/SCL/src/","@solidity/=lib/SCL/src/","FCL/=lib/FCL/solidity/src/","FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/","SCL/=lib/SCL/","account-abstraction/=lib/account-abstraction/contracts/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","erc7579-implementation/=lib/erc7579-implementation/src/","openzeppelin-contracts/=lib/openzeppelin-contracts/","sentinellist/=lib/erc7579-implementation/node_modules/@rhinestone/sentinellist/src/","solady/=lib/erc7579-implementation/node_modules/solady/src/","solidity-bytes-utils/=lib/solidity-bytes-utils/contracts/","solidity-stringutils/=lib/solidity-stringutils/"],"viaIR":false},"optimization_runs":200,"sourcify_repo_url":null,"decoded_constructor_args":[["0xB0403B32f54d0Bd752113f4009e8B534C6669f44",{"internalType":"address","name":"_owner","type":"address"}]],"compiler_version":"v0.8.23+commit.f704f362","is_verified_via_verifier_alliance":false,"verified_at":"2025-05-22T22:11:04.530990Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x6101606040523480156200001257600080fd5b506040516200334f3803806200334f833981016040819052620000359162000384565b60408051808201825260118152702232b632b3b0ba34b7b726b0b730b3b2b960791b602080830191909152825180840190935260018352603160f81b9083015290826001600160a01b038116620000a757604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000b28162000204565b506001805460ff60a01b19169055620000cd82600262000222565b61012052620000de81600362000222565b61014052815160208084019190912060e052815190820120610100524660a0526200015b60e05161010051604080516000805160206200332f83398151915260208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526000620001706200025b565b9050306001600160a01b0316817f04a46d9007577c7ff1e513b900545162ec25d25991ae3dc60cf26ec01a84806d604051806040016040528060118152602001702232b632b3b0ba34b7b726b0b730b3b2b960791b815250604051806040016040528060018152602001603160f81b81525046604051620001f493929190620003fe565b60405180910390a35050620005e5565b600180546001600160a01b03191690556200021f81620002f1565b50565b600060208351101562000242576200023a8362000341565b905062000255565b816200024f8482620004df565b5060ff90505b92915050565b600060c0516001600160a01b0316306001600160a01b031614801562000282575060a05146145b156200028f575060805190565b620002ec60e05161010051604080516000805160206200332f83398151915260208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b905090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080829050601f815111156200036f578260405163305a27a960e01b81526004016200009e9190620005ab565b80516200037c82620005c0565b179392505050565b6000602082840312156200039757600080fd5b81516001600160a01b0381168114620003af57600080fd5b9392505050565b6000815180845260005b81811015620003de57602081850181015186830182015201620003c0565b506000602082860101526020601f19601f83011685010191505092915050565b606081526000620004136060830186620003b6565b8281036020840152620004278186620003b6565b915050826040830152949350505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200046357607f821691505b6020821081036200048457634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620004da576000816000526020600020601f850160051c81016020861015620004b55750805b601f850160051c820191505b81811015620004d657828155600101620004c1565b5050505b505050565b81516001600160401b03811115620004fb57620004fb62000438565b62000513816200050c84546200044e565b846200048a565b602080601f8311600181146200054b5760008415620005325750858301515b600019600386901b1c1916600185901b178555620004d6565b600085815260208120601f198616915b828110156200057c578886015182559484019460019091019084016200055b565b50858210156200059b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b602081526000620003af6020830184620003b6565b80516020808301519190811015620004845760001960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051612cef620006406000396000611bda01526000611bad01526000611b1201526000611aea01526000611a4501526000611a6f01526000611a990152612cef6000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c806383ebb771116100ad578063acb8cc4911610071578063acb8cc491461027f578063cef6d2091461029f578063e30c3978146102b2578063f2fde38b146102c3578063ffa1ad74146102d657600080fd5b806383ebb771146102065780638456cb591461020e57806384b0196e146102165780638da5cb5b14610231578063a3f4df7e1461024257600080fd5b806358909ebc116100f457806358909ebc146101b05780635c975abb146101d157806366134607146101e3578063715018a6146101f657806379ba5097146101fe57600080fd5b80631b13cac2146101315780632d40d0521461014d5780633ed01015146101805780633f4ba83a14610195578063499340471461019d575b600080fd5b61013a60001981565b6040519081526020015b60405180910390f35b61017061015b3660046120e6565b60046020526000908152604090205460ff1681565b6040519015158152602001610144565b61019361018e3660046120ff565b6102fa565b005b6101936103f4565b6101936101ab3660046120ff565b610406565b6101b9610a1181565b6040516001600160a01b039091168152602001610144565b600154600160a01b900460ff16610170565b61013a6101f13660046120ff565b6104f6565b61019361050f565b610193610521565b61013a61056a565b610193610579565b61021e610589565b6040516101449796959493929190612190565b6000546001600160a01b03166101b9565b610272604051806040016040528060118152602001702232b632b3b0ba34b7b726b0b730b3b2b960791b81525081565b6040516101449190612229565b610272604051806040016040528060018152602001603160f81b81525081565b6101936102ad366004612287565b6105cf565b6001546001600160a01b03166101b9565b6101936102d136600461233c565b611891565b610272604051806040016040528060058152602001640312e332e360dc1b81525081565b61030a604082016020830161233c565b6001600160a01b03811633146103335760405163b9f0f17160e01b815260040160405180910390fd5b600061033e836104f6565b60008181526004602052604090205490915060ff1661037057604051637952fbad60e11b815260040160405180910390fd5b6000818152600460209081526040909120805460ff191690556103959084018461233c565b6001600160a01b03166103ae604085016020860161233c565b6001600160a01b0316827f3feadce88fc1b49db633a56fd5307ed6ee18734df83bcc4011daa720c9cd95f1866040516103e79190612484565b60405180910390a4505050565b6103fc611902565b61040461192f565b565b610416604082016020830161233c565b6001600160a01b038116331461043f5760405163b9f0f17160e01b815260040160405180910390fd5b600061044a836104f6565b60008181526004602052604090205490915060ff161561047c57604051625ecddb60e01b815260040160405180910390fd5b6000818152600460209081526040909120805460ff191660011790556104a49084018461233c565b6001600160a01b03166104bd604085016020860161233c565b6001600160a01b0316827fea589ba9473ee1fe77d352c7ed919747715a5d22931b972de9b02a907c66d5dd866040516103e79190612484565b600061050961050483612823565b611984565b92915050565b610517611902565b6104046000611a1f565b60015433906001600160a01b0316811461055e5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61056781611a1f565b50565b6000610574611a38565b905090565b610581611902565b610404611b63565b60006060806000806000606061059d611ba6565b6105a5611bd3565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b6105d7611c00565b8481811415806105e75750808414155b1561060557604051631bcaf69f60e01b815260040160405180910390fd5b6000816001600160401b0381111561061f5761061f612555565b60405190808252806020026020018201604052801561065257816020015b606081526020019060019003908161063d5790505b5090506000826001600160401b0381111561066f5761066f612555565b6040519080825280602002602001820160405280156106a257816020015b606081526020019060019003908161068d5790505b50905060005b83811015610c815760008a8a838181106106c4576106c461282f565b90506020028101906106d69190612845565b8101906106e3919061288b565b905080516000036107d1576040805160008082526020820190925290610765565b6107526040518060c0016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600080191681526020016060815260200160008152602001606081525090565b8152602001906001900390816107045790505b508483815181106107785761077861282f565b602090810291909101015260006040519080825280602002602001820160405280156107ae578160200160208202803683370190505b508383815181106107c1576107c161282f565b6020026020010181905250610c78565b808483815181106107e4576107e461282f565b6020026020010181905250600081516001600160401b0381111561080a5761080a612555565b604051908082528060200260200182016040528015610833578160200160208202803683370190505b509050808484815181106108495761084961282f565b6020026020010181905250336001600160a01b0316826000815181106108715761087161282f565b6020026020010151600001516001600160a01b0316141580156108c65750610a116001600160a01b0316826000815181106108ae576108ae61282f565b6020026020010151600001516001600160a01b031614155b156108e457604051632d618d8160e21b815260040160405180910390fd5b60005b8251811015610ab55760008382815181106109045761090461282f565b6020026020010151905061091781611984565b8383815181106109295761092961282f565b60200260200101818152505080602001516001600160a01b03163b6000036109dc57600061099e61099461095b61056a565b86868151811061096d5761096d61282f565b602002602001015160405161190160f01b8152600281019290925260228201526042902090565b8360a00151611c2b565b905081602001516001600160a01b0316816001600160a01b0316146109d657604051630f6d9e4760e21b815260040160405180910390fd5b50610aac565b60006109fb6109e961056a565b85858151811061096d5761096d61282f565b9050600082602001516001600160a01b0316631626ba7e838560a001516040518363ffffffff1660e01b8152600401610a3592919061293b565b602060405180830381865afa158015610a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a76919061295c565b6001600160e01b0319169050630b135d3f60e11b8114610aa95760405163155ff42760e01b815260040160405180910390fd5b50505b506001016108e7565b5060005b8251811015610c755760046000838381518110610ad857610ad861282f565b60209081029190910181015182528101919091526040016000205460ff1615610b14576040516302dd502960e11b815260040160405180910390fd5b60018351610b22919061299c565b8114610c2b5781610b348260016129af565b81518110610b4457610b4461282f565b6020026020010151838281518110610b5e57610b5e61282f565b60200260200101516040015114610b8857604051636f6a1b8760e11b815260040160405180910390fd5b600083610b968360016129af565b81518110610ba657610ba661282f565b6020026020010151600001519050610a116001600160a01b0316816001600160a01b031614158015610c075750806001600160a01b0316848381518110610bef57610bef61282f565b6020026020010151602001516001600160a01b031614155b15610c2557604051632d618d8160e21b815260040160405180910390fd5b50610c6d565b60001960001b838281518110610c4357610c4361282f565b60200260200101516040015114610c6d57604051636f6a1b8760e11b815260040160405180910390fd5b600101610ab9565b50505b506001016106a8565b5060005b83811015610ea6576000838281518110610ca157610ca161282f565b6020026020010151511115610e9e5760005b838281518110610cc557610cc561282f565b602002602001015151811015610e9c576000848381518110610ce957610ce961282f565b60200260200101518281518110610d0257610d0261282f565b602002602001015160600151905060005b8151811015610e92576000828281518110610d3057610d3061282f565b6020026020010151600001519050806001600160a01b031663414c3e33848481518110610d5f57610d5f61282f565b602002602001015160200151858581518110610d7d57610d7d61282f565b6020026020010151604001518f8f8a818110610d9b57610d9b61282f565b905060200201358e8e8b818110610db457610db461282f565b9050602002810190610dc69190612845565b8c8c81518110610dd857610dd861282f565b60200260200101518b81518110610df157610df161282f565b60200260200101518e8d81518110610e0b57610e0b61282f565b60200260200101518c81518110610e2457610e2461282f565b602002602001015160200151336040518963ffffffff1660e01b8152600401610e549897969594939291906129c2565b600060405180830381600087803b158015610e6e57600080fd5b505af1158015610e82573d6000803e3d6000fd5b5050505050806001019050610d13565b5050600101610cb3565b505b600101610c85565b5060005b838110156114ca57828181518110610ec457610ec461282f565b602002602001015151600003610f82573363d691c964898984818110610eec57610eec61282f565b90506020020135888885818110610f0557610f0561282f565b9050602002810190610f179190612845565b6040518463ffffffff1660e01b8152600401610f3593929190612a2d565b6000604051808303816000875af1158015610f54573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f7c9190810190612a50565b506114c2565b60005b838281518110610f9757610f9761282f565b60200260200101515181101561116e576000848381518110610fbb57610fbb61282f565b60200260200101518281518110610fd457610fd461282f565b602002602001015160600151905060005b81518110156111645760008282815181106110025761100261282f565b6020026020010151600001519050806001600160a01b031663a145832a8484815181106110315761103161282f565b60200260200101516020015185858151811061104f5761104f61282f565b6020026020010151604001518f8f8a81811061106d5761106d61282f565b905060200201358e8e8b8181106110865761108661282f565b90506020028101906110989190612845565b8c8c815181106110aa576110aa61282f565b60200260200101518b815181106110c3576110c361282f565b60200260200101518e8d815181106110dd576110dd61282f565b60200260200101518c815181106110f6576110f661282f565b602002602001015160200151336040518963ffffffff1660e01b81526004016111269897969594939291906129c2565b600060405180830381600087803b15801561114057600080fd5b505af1158015611154573d6000803e3d6000fd5b5050505050806001019050610fe5565b5050600101610f85565b508281815181106111815761118161282f565b6020026020010151600184838151811061119d5761119d61282f565b6020026020010151516111b0919061299c565b815181106111c0576111c061282f565b6020026020010151602001516001600160a01b031663d691c9648989848181106111ec576111ec61282f565b905060200201358888858181106112055761120561282f565b90506020028101906112179190612845565b6040518463ffffffff1660e01b815260040161123593929190612a2d565b6000604051808303816000875af1158015611254573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261127c9190810190612a50565b5060008382815181106112915761129161282f565b60200260200101515190505b80156114c05760008483815181106112b7576112b761282f565b60200260200101516001836112cc919061299c565b815181106112dc576112dc61282f565b60200260200101516060015190506000815190505b80156114ad5760008261130560018461299c565b815181106113155761131561282f565b6020026020010151600001519050806001600160a01b031663d3eddcc584600185611340919061299c565b815181106113505761135061282f565b6020026020010151602001518560018661136a919061299c565b8151811061137a5761137a61282f565b6020026020010151604001518f8f8a8181106113985761139861282f565b905060200201358e8e8b8181106113b1576113b161282f565b90506020028101906113c39190612845565b8c8c815181106113d5576113d561282f565b602002602001015160018c6113ea919061299c565b815181106113fa576113fa61282f565b60200260200101518e8d815181106114145761141461282f565b602002602001015160018d611429919061299c565b815181106114395761143961282f565b602002602001015160200151336040518963ffffffff1660e01b81526004016114699897969594939291906129c2565b600060405180830381600087803b15801561148357600080fd5b505af1158015611497573d6000803e3d6000fd5b5050505050806114a690612b2f565b90506112f1565b5050806114b990612b2f565b905061129d565b505b600101610eaa565b5060005b838110156117465760008382815181106114ea576114ea61282f565b602002602001015151111561173e57600083828151811061150d5761150d61282f565b60200260200101515190505b801561173c5760008483815181106115335761153361282f565b6020026020010151600183611548919061299c565b815181106115585761155861282f565b60200260200101516060015190506000815190505b80156117295760008261158160018461299c565b815181106115915761159161282f565b6020026020010151600001519050806001600160a01b031663ed463367846001856115bc919061299c565b815181106115cc576115cc61282f565b602002602001015160200151856001866115e6919061299c565b815181106115f6576115f661282f565b6020026020010151604001518f8f8a8181106116145761161461282f565b905060200201358e8e8b81811061162d5761162d61282f565b905060200281019061163f9190612845565b8c8c815181106116515761165161282f565b602002602001015160018c611666919061299c565b815181106116765761167661282f565b60200260200101518e8d815181106116905761169061282f565b602002602001015160018d6116a5919061299c565b815181106116b5576116b561282f565b602002602001015160200151336040518963ffffffff1660e01b81526004016116e59897969594939291906129c2565b600060405180830381600087803b1580156116ff57600080fd5b505af1158015611713573d6000803e3d6000fd5b50505050508061172290612b2f565b905061156d565b50508061173590612b2f565b9050611519565b505b6001016114ce565b5060005b838110156118855760008382815181106117665761176661282f565b602002602001015151111561187d5760005b83828151811061178a5761178a61282f565b60200260200101515181101561187b57336001600160a01b03168483815181106117b6576117b661282f565b602002602001015160018685815181106117d2576117d261282f565b6020026020010151516117e5919061299c565b815181106117f5576117f561282f565b6020026020010151602001516001600160a01b03167f40dadaa36c6c2e3d7317e24757451ffb2d603d875f0ad5e92c5dd156573b187386858151811061183d5761183d61282f565b602002602001015184815181106118565761185661282f565b602002602001015160405161186b9190612b46565b60405180910390a3600101611778565b505b60010161174a565b50505050505050505050565b611899611902565b600180546001600160a01b0383166001600160a01b031990911681179091556118ca6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146104045760405163118cdaa760e01b8152336004820152602401610555565b611937611c55565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000807f88c1d2ecf185adf710588203a5f263f0ff61be0d33da39792cde19ba9aa4331e8360000151846020015185604001516119c48760600151611c7f565b6080808901516040805160208101989098526001600160a01b03968716908801529490931660608601529184015260a083015260c082015260e0015b60408051601f1981840301815291905280516020909101209392505050565b600180546001600160a01b031916905561056781611d4a565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015611a9157507f000000000000000000000000000000000000000000000000000000000000000046145b15611abb57507f000000000000000000000000000000000000000000000000000000000000000090565b610574604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b611b6b611c00565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586119673390565b60606105747f00000000000000000000000000000000000000000000000000000000000000006002611d9a565b60606105747f00000000000000000000000000000000000000000000000000000000000000006003611d9a565b600154600160a01b900460ff16156104045760405163d93c066560e01b815260040160405180910390fd5b600080600080611c3b8686611e45565b925092509250611c4b8282611e92565b5090949350505050565b600154600160a01b900460ff1661040457604051638dfc202b60e01b815260040160405180910390fd5b60008082516001600160401b03811115611c9b57611c9b612555565b604051908082528060200260200182016040528015611cc4578160200160208202803683370190505b50905060005b8351811015611d1a57611cf5848281518110611ce857611ce861282f565b6020026020010151611f4f565b828281518110611d0757611d0761282f565b6020908102919091010152600101611cca565b5080604051602001611d2c9190612c33565b60405160208183030381529060405280519060200120915050919050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060ff8314611db457611dad83611fb0565b9050610509565b818054611dc090612c69565b80601f0160208091040260200160405190810160405280929190818152602001828054611dec90612c69565b8015611e395780601f10611e0e57610100808354040283529160200191611e39565b820191906000526020600020905b815481529060010190602001808311611e1c57829003601f168201915b50505050509050610509565b60008060008351604103611e7f5760208401516040850151606086015160001a611e7188828585611fef565b955095509550505050611e8b565b50508151600091506002905b9250925092565b6000826003811115611ea657611ea6612ca3565b03611eaf575050565b6001826003811115611ec357611ec3612ca3565b03611ee15760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115611ef557611ef5612ca3565b03611f165760405163fce698f760e01b815260048101829052602401610555565b6003826003811115611f2a57611f2a612ca3565b03611f4b576040516335e2f38360e21b815260048101829052602401610555565b5050565b6000807f80ad7e1b04ee6d994a125f4714ca0720908bd80ed16063ec8aee4b88e9253e2d8360000151846020015180519060200120604051602001611a00939291909283526001600160a01b03919091166020830152604082015260600190565b60606000611fbd836120be565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561202a57506000915060039050826120b4565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561207e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166120aa575060009250600191508290506120b4565b9250600091508190505b9450945094915050565b600060ff8216601f81111561050957604051632cd44ac360e21b815260040160405180910390fd5b6000602082840312156120f857600080fd5b5035919050565b60006020828403121561211157600080fd5b81356001600160401b0381111561212757600080fd5b820160c0818503121561213957600080fd5b9392505050565b60005b8381101561215b578181015183820152602001612143565b50506000910152565b6000815180845261217c816020860160208601612140565b601f01601f19169290920160200192915050565b60ff60f81b881681526000602060e060208401526121b160e084018a612164565b83810360408501526121c3818a612164565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015612217578351835292840192918401916001016121fb565b50909c9b505050505050505050505050565b6020815260006121396020830184612164565b60008083601f84011261224e57600080fd5b5081356001600160401b0381111561226557600080fd5b6020830191508360208260051b850101111561228057600080fd5b9250929050565b600080600080600080606087890312156122a057600080fd5b86356001600160401b03808211156122b757600080fd5b6122c38a838b0161223c565b909850965060208901359150808211156122dc57600080fd5b6122e88a838b0161223c565b9096509450604089013591508082111561230157600080fd5b5061230e89828a0161223c565b979a9699509497509295939492505050565b80356001600160a01b038116811461233757600080fd5b919050565b60006020828403121561234e57600080fd5b61213982612320565b6000808335601e1984360301811261236e57600080fd5b83016020810192503590506001600160401b0381111561238d57600080fd5b80360382131561228057600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008383855260208086019550808560051b830101846000805b8881101561247657858403601f19018a52823536899003605e19018112612404578283fd5b880160606001600160a01b0361241983612320565b16865261242887830183612357565b828989015261243a838901828461239c565b92505050604061244c81840184612357565b93508783038289015261246083858361239c565b9d89019d975050509386019350506001016123df565b509198975050505050505050565b6020815260006001600160a01b038061249c85612320565b166020840152806124af60208601612320565b16604084015250604083013560608301526060830135601e198436030181126124d757600080fd5b83016020810190356001600160401b038111156124f357600080fd5b8060051b360382131561250557600080fd5b60c0608085015261251a60e0850182846123c5565b915050608084013560a084015261253460a0850185612357565b848303601f190160c086015261254b83828461239c565b9695505050505050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171561258d5761258d612555565b60405290565b60405160c081016001600160401b038111828210171561258d5761258d612555565b604051601f8201601f191681016001600160401b03811182821017156125dd576125dd612555565b604052919050565b60006001600160401b038211156125fe576125fe612555565b5060051b60200190565b60006001600160401b0382111561262157612621612555565b50601f01601f191660200190565b600082601f83011261264057600080fd5b813561265361264e82612608565b6125b5565b81815284602083860101111561266857600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f83011261269657600080fd5b813560206126a661264e836125e5565b82815260059290921b840181019181810190868411156126c557600080fd5b8286015b848110156127745780356001600160401b03808211156126e95760008081fd5b908801906060828b03601f19018113156127035760008081fd5b61270b61256b565b612716888501612320565b81526040808501358481111561272c5760008081fd5b61273a8e8b8389010161262f565b838b0152509184013591838311156127525760008081fd5b6127608d8a8588010161262f565b9082015286525050509183019183016126c9565b509695505050505050565b600060c0828403121561279157600080fd5b612799612593565b90506127a482612320565b81526127b260208301612320565b60208201526040820135604082015260608201356001600160401b03808211156127db57600080fd5b6127e785838601612685565b60608401526080840135608084015260a084013591508082111561280a57600080fd5b506128178482850161262f565b60a08301525092915050565b6000610509368361277f565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261285c57600080fd5b8301803591506001600160401b0382111561287657600080fd5b60200191503681900382131561228057600080fd5b6000602080838503121561289e57600080fd5b82356001600160401b03808211156128b557600080fd5b818501915085601f8301126128c957600080fd5b81356128d761264e826125e5565b81815260059190911b830184019084810190888311156128f657600080fd5b8585015b8381101561292e578035858111156129125760008081fd5b6129208b89838a010161277f565b8452509186019186016128fa565b5098975050505050505050565b8281526040602082015260006129546040830184612164565b949350505050565b60006020828403121561296e57600080fd5b81516001600160e01b03198116811461213957600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561050957610509612986565b8082018082111561050957610509612986565b60e0815260006129d560e083018b612164565b82810360208401526129e7818b612164565b90508860408401528281036060840152612a0281888a61239c565b608084019690965250506001600160a01b0392831660a0820152911660c09091015295945050505050565b838152604060208201526000612a4760408301848661239c565b95945050505050565b60006020808385031215612a6357600080fd5b82516001600160401b0380821115612a7a57600080fd5b818501915085601f830112612a8e57600080fd5b8151612a9c61264e826125e5565b81815260059190911b83018401908481019088831115612abb57600080fd5b8585015b8381101561292e57805185811115612ad75760008081fd5b8601603f81018b13612ae95760008081fd5b878101516040612afb61264e83612608565b8281528d82848601011115612b105760008081fd5b612b1f838c8301848701612140565b8652505050918601918601612abf565b600081612b3e57612b3e612986565b506000190190565b602080825282516001600160a01b0390811683830152838201518116604080850191909152808501516060808601919091528086015160c06080870152805160e0870181905260009594610100600583901b8901810195919493870193919290890190885b81811015612c055760ff198b8903018352855187815116895289810151858b8b0152612bd9868b0182612164565b918701518a83038b890152919050612bf18183612164565b995050509488019491880191600101612bab565b50505050505050608085015160a085015260a08501519150601f198482030160c0850152612a478183612164565b815160009082906020808601845b83811015612c5d57815185529382019390820190600101612c41565b50929695505050505050565b600181811c90821680612c7d57607f821691505b602082108103612c9d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220c2284ea0163aafd9aee402e7645e9db93d0c27667921732dd0458883520a475264736f6c634300081700338b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f000000000000000000000000b0403b32f54d0bd752113f4009e8b534c6669f44","name":"DelegationManager","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"london","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":false,"additional_sources":[{"file_path":"lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing a bytes32 `messageHash` with\n     * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n     * keccak256, although any bytes32 value can be safely used because the final digest will\n     * be re-hashed.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n        }\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing an arbitrary `message` with\n     * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n        return\n            keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x00` (data with intended validator).\n     *\n     * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n     * `validator` address. Then hashing the result.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).\n     *\n     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n     * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(ptr, hex\"19_01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            digest := keccak256(ptr, 0x42)\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/math/Math.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an success flag (no overflow).\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n\n        // The following calculation ensures accurate ceiling division without overflow.\n        // Since a is non-zero, (a - 1) / b will not overflow.\n        // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n        // but the largest value we can obtain is type(uint256).max - 1, which happens\n        // when a = type(uint256).max and b = 1.\n        unchecked {\n            return a == 0 ? 0 : (a - 1) / b + 1;\n        }\n    }\n\n    /**\n     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     *\n     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2²⁵⁶ + prod0.\n            uint256 prod0 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                Panic.panic(denominator == 0 ? Panic.DIVISION_BY_ZERO : Panic.UNDER_OVERFLOW);\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such\n            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶\n            inverse *= 2 - denominator * inverse; // inverse mod 2³²\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is\n            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n    }\n\n    /**\n     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n     *\n     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, expect 0.\n     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n     *\n     * If the input value is not inversible, 0 is returned.\n     *\n     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Ferma's little theorem and get the\n     * inverse using `Math.modExp(a, n - 2, n)`.\n     */\n    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n        unchecked {\n            if (n == 0) return 0;\n\n            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n            // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n            // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n            // ax + ny = 1\n            // ax = 1 + (-y)n\n            // ax ≡ 1 (mod n) # x is the inverse of a modulo n\n\n            // If the remainder is 0 the gcd is n right away.\n            uint256 remainder = a % n;\n            uint256 gcd = n;\n\n            // Therefore the initial coefficients are:\n            // ax + ny = gcd(a, n) = n\n            // 0a + 1n = n\n            int256 x = 0;\n            int256 y = 1;\n\n            while (remainder != 0) {\n                uint256 quotient = gcd / remainder;\n\n                (gcd, remainder) = (\n                    // The old remainder is the next gcd to try.\n                    remainder,\n                    // Compute the next remainder.\n                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n                    // where gcd is at most n (capped to type(uint256).max)\n                    gcd - remainder * quotient\n                );\n\n                (x, y) = (\n                    // Increment the coefficient of a.\n                    y,\n                    // Decrement the coefficient of n.\n                    // Can overflow, but the result is casted to uint256 so that the\n                    // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n                    x - y * int256(quotient)\n                );\n            }\n\n            if (gcd != 1) return 0; // No inverse exists.\n            return x < 0 ? (n - uint256(-x)) : uint256(x); // Wrap the result if it's negative.\n        }\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n     *\n     * Requirements:\n     * - modulus can't be zero\n     * - underlying staticcall to precompile must succeed\n     *\n     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n     * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n     * interpreted as 0.\n     */\n    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n        (bool success, uint256 result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n     * It includes a success flag indicating if the operation succeeded. Operation will be marked has failed if trying\n     * to operate modulo 0 or if the underlying precompile reverted.\n     *\n     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n     * of a revert, but the result may be incorrectly interpreted as 0.\n     */\n    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n        if (m == 0) return (false, 0);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            // | Offset    | Content    | Content (Hex)                                                      |\n            // |-----------|------------|--------------------------------------------------------------------|\n            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n            // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n            mstore(ptr, 0x20)\n            mstore(add(ptr, 0x20), 0x20)\n            mstore(add(ptr, 0x40), 0x20)\n            mstore(add(ptr, 0x60), b)\n            mstore(add(ptr, 0x80), e)\n            mstore(add(ptr, 0xa0), m)\n\n            // Given the result < m, it's guaranteed to fit in 32 bytes,\n            // so we can use the memory scratch space located at offset 0.\n            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n            result := mload(0x00)\n        }\n    }\n\n    /**\n     * @dev Variant of {modExp} that supports inputs of arbitrary length.\n     */\n    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n        (bool success, bytes memory result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n     */\n    function tryModExp(\n        bytes memory b,\n        bytes memory e,\n        bytes memory m\n    ) internal view returns (bool success, bytes memory result) {\n        if (_zeroBytes(m)) return (false, new bytes(0));\n\n        uint256 mLen = m.length;\n\n        // Encode call args in result and move the free memory pointer\n        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            let dataPtr := add(result, 0x20)\n            // Write result on top of args to avoid allocating extra memory.\n            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n            // Overwrite the length.\n            // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n            mstore(result, mLen)\n            // Set the memory pointer after the returned data.\n            mstore(0x40, add(dataPtr, mLen))\n        }\n    }\n\n    /**\n     * @dev Returns whether the provided byte array is zero.\n     */\n    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n        for (uint256 i = 0; i < byteArray.length; ++i) {\n            if (byteArray[i] != 0) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n     * using integer operations.\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        unchecked {\n            // Take care of easy edge cases when a == 0 or a == 1\n            if (a <= 1) {\n                return a;\n            }\n\n            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a\n            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n            // the current value as `ε_n = | x_n - sqrt(a) |`.\n            //\n            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is\n            // bigger than any uint256.\n            //\n            // By noticing that\n            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`\n            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n            // to the msb function.\n            uint256 aa = a;\n            uint256 xn = 1;\n\n            if (aa >= (1 << 128)) {\n                aa >>= 128;\n                xn <<= 64;\n            }\n            if (aa >= (1 << 64)) {\n                aa >>= 64;\n                xn <<= 32;\n            }\n            if (aa >= (1 << 32)) {\n                aa >>= 32;\n                xn <<= 16;\n            }\n            if (aa >= (1 << 16)) {\n                aa >>= 16;\n                xn <<= 8;\n            }\n            if (aa >= (1 << 8)) {\n                aa >>= 8;\n                xn <<= 4;\n            }\n            if (aa >= (1 << 4)) {\n                aa >>= 4;\n                xn <<= 2;\n            }\n            if (aa >= (1 << 2)) {\n                xn <<= 1;\n            }\n\n            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).\n            //\n            // We can refine our estimation by noticing that the the middle of that interval minimizes the error.\n            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).\n            // This is going to be our x_0 (and ε_0)\n            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)\n\n            // From here, Newton's method give us:\n            // x_{n+1} = (x_n + a / x_n) / 2\n            //\n            // One should note that:\n            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a\n            //              = ((x_n² + a) / (2 * x_n))² - a\n            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a\n            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)\n            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)\n            //              = (x_n² - a)² / (2 * x_n)²\n            //              = ((x_n² - a) / (2 * x_n))²\n            //              ≥ 0\n            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n\n            //\n            // This gives us the proof of quadratic convergence of the sequence:\n            // ε_{n+1} = | x_{n+1} - sqrt(a) |\n            //         = | (x_n + a / x_n) / 2 - sqrt(a) |\n            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n            //         = | (x_n - sqrt(a))² / (2 * x_n) |\n            //         = | ε_n² / (2 * x_n) |\n            //         = ε_n² / | (2 * x_n) |\n            //\n            // For the first iteration, we have a special case where x_0 is known:\n            // ε_1 = ε_0² / | (2 * x_0) |\n            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))\n            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))\n            //     ≤ 2**(e-3) / 3\n            //     ≤ 2**(e-3-log2(3))\n            //     ≤ 2**(e-4.5)\n            //\n            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:\n            // ε_{n+1} = ε_n² / | (2 * x_n) |\n            //         ≤ (2**(e-k))² / (2 * 2**(e-1))\n            //         ≤ 2**(2*e-2*k) / 2**e\n            //         ≤ 2**(e-2*k)\n            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above\n            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5\n            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9\n            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18\n            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36\n            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72\n\n            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision\n            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n            // sqrt(a) or sqrt(a) + 1.\n            return xn - SafeCast.toUint(xn > a / xn);\n        }\n    }\n\n    /**\n     * @dev Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        uint256 exp;\n        unchecked {\n            exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n            value >>= exp;\n            result += exp;\n\n            result += SafeCast.toUint(value > 1);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        uint256 isGt;\n        unchecked {\n            isGt = SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= isGt * 128;\n            result += isGt * 16;\n\n            isGt = SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= isGt * 64;\n            result += isGt * 8;\n\n            isGt = SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= isGt * 32;\n            result += isGt * 4;\n\n            isGt = SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= isGt * 16;\n            result += isGt * 2;\n\n            result += SafeCast.toUint(value > (1 << 8) - 1);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n    /**\n     * @dev Value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n    /**\n     * @dev An int value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedIntToUint(int256 value);\n\n    /**\n     * @dev Value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n    /**\n     * @dev An uint value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedUintToInt(uint256 value);\n\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        if (value > type(uint248).max) {\n            revert SafeCastOverflowedUintDowncast(248, value);\n        }\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        if (value > type(uint240).max) {\n            revert SafeCastOverflowedUintDowncast(240, value);\n        }\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        if (value > type(uint232).max) {\n            revert SafeCastOverflowedUintDowncast(232, value);\n        }\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        if (value > type(uint224).max) {\n            revert SafeCastOverflowedUintDowncast(224, value);\n        }\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        if (value > type(uint216).max) {\n            revert SafeCastOverflowedUintDowncast(216, value);\n        }\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        if (value > type(uint208).max) {\n            revert SafeCastOverflowedUintDowncast(208, value);\n        }\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        if (value > type(uint200).max) {\n            revert SafeCastOverflowedUintDowncast(200, value);\n        }\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        if (value > type(uint192).max) {\n            revert SafeCastOverflowedUintDowncast(192, value);\n        }\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        if (value > type(uint184).max) {\n            revert SafeCastOverflowedUintDowncast(184, value);\n        }\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        if (value > type(uint176).max) {\n            revert SafeCastOverflowedUintDowncast(176, value);\n        }\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        if (value > type(uint168).max) {\n            revert SafeCastOverflowedUintDowncast(168, value);\n        }\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) {\n            revert SafeCastOverflowedUintDowncast(160, value);\n        }\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        if (value > type(uint152).max) {\n            revert SafeCastOverflowedUintDowncast(152, value);\n        }\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        if (value > type(uint144).max) {\n            revert SafeCastOverflowedUintDowncast(144, value);\n        }\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        if (value > type(uint136).max) {\n            revert SafeCastOverflowedUintDowncast(136, value);\n        }\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        if (value > type(uint128).max) {\n            revert SafeCastOverflowedUintDowncast(128, value);\n        }\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        if (value > type(uint120).max) {\n            revert SafeCastOverflowedUintDowncast(120, value);\n        }\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        if (value > type(uint112).max) {\n            revert SafeCastOverflowedUintDowncast(112, value);\n        }\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        if (value > type(uint104).max) {\n            revert SafeCastOverflowedUintDowncast(104, value);\n        }\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        if (value > type(uint96).max) {\n            revert SafeCastOverflowedUintDowncast(96, value);\n        }\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        if (value > type(uint88).max) {\n            revert SafeCastOverflowedUintDowncast(88, value);\n        }\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        if (value > type(uint80).max) {\n            revert SafeCastOverflowedUintDowncast(80, value);\n        }\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        if (value > type(uint72).max) {\n            revert SafeCastOverflowedUintDowncast(72, value);\n        }\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        if (value > type(uint64).max) {\n            revert SafeCastOverflowedUintDowncast(64, value);\n        }\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        if (value > type(uint56).max) {\n            revert SafeCastOverflowedUintDowncast(56, value);\n        }\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        if (value > type(uint48).max) {\n            revert SafeCastOverflowedUintDowncast(48, value);\n        }\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        if (value > type(uint40).max) {\n            revert SafeCastOverflowedUintDowncast(40, value);\n        }\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        if (value > type(uint32).max) {\n            revert SafeCastOverflowedUintDowncast(32, value);\n        }\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        if (value > type(uint24).max) {\n            revert SafeCastOverflowedUintDowncast(24, value);\n        }\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        if (value > type(uint16).max) {\n            revert SafeCastOverflowedUintDowncast(16, value);\n        }\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        if (value > type(uint8).max) {\n            revert SafeCastOverflowedUintDowncast(8, value);\n        }\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        if (value < 0) {\n            revert SafeCastOverflowedIntToUint(value);\n        }\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(248, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(240, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(232, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(224, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(216, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(208, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(200, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(192, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(184, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(176, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(168, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(160, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(152, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(144, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(136, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(128, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(120, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(112, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(104, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(96, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(88, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(80, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(72, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(64, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(56, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(48, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(40, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(32, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(24, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(16, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(8, value);\n        }\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        if (value > uint256(type(int256).max)) {\n            revert SafeCastOverflowedUintToInt(value);\n        }\n        return int256(value);\n    }\n\n    /**\n     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n     */\n    function toUint(bool b) internal pure returns (uint256 u) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            u := iszero(iszero(b))\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // Formula from the \"Bit Twiddling Hacks\" by Sean Eron Anderson.\n            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,\n            // taking advantage of the most significant (or \"sign\" bit) in two's complement representation.\n            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,\n            // the mask will either be `bytes(0)` (if n is positive) or `~bytes32(0)` (if n is negative).\n            int256 mask = n >> 255;\n\n            // A `bytes(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.\n            return uint256((n + mask) ^ mask);\n        }\n    }\n}\n"},{"file_path":"src/interfaces/ICaveatEnforcer.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport { ModeCode } from \"../utils/Types.sol\";\n\n/**\n * @title CaveatEnforcer\n * @notice This is an abstract contract that exposes pre and post Execution hooks during delegation redemption.\n * @dev Hooks can be used to enforce conditions before and after an Execution is performed.\n * @dev Reverting during the hooks will revert the entire delegation redemption.\n * @dev Child contracts can implement the beforeAllHook, beforeHook, afterAllHook, afterHook methods.\n * @dev NOTE: There is no guarantee that the Execution is performed. If you are relying on the execution then\n * be sure to use the `afterHook` or `afterAllHook` methods to validate any required conditions.\n */\ninterface ICaveatEnforcer {\n    /**\n     * @notice Enforces conditions before any actions in a batch redemption process begin.\n     * @dev This function MUST revert if the conditions are not met.\n     * @param _terms The terms to enforce set by the delegator.\n     * @param _args An optional input parameter set by the redeemer at time of invocation.\n     * @param _mode The mode of execution for the executionCalldata.\n     * @param _executionCalldata The data representing the execution.\n     * @param _delegationHash The hash of the delegation.\n     * @param _delegator The address of the delegator.\n     * @param _redeemer The address that is redeeming the delegation.\n     */\n    function beforeAllHook(\n        bytes calldata _terms,\n        bytes calldata _args,\n        ModeCode _mode,\n        bytes calldata _executionCalldata,\n        bytes32 _delegationHash,\n        address _delegator,\n        address _redeemer\n    )\n        external;\n\n    /**\n     * @notice Enforces conditions before the execution tied to a specific delegation in the redemption process.\n     * @dev This function MUST revert if the conditions are not met.\n     * @param _terms The terms to enforce set by the delegator.\n     * @param _args An optional input parameter set by the redeemer at time of invocation.\n     * @param _mode The mode of execution for the executionCalldata.\n     * @param _executionCalldata The data representing the execution.\n     * @param _delegationHash The hash of the delegation.\n     * @param _delegator The address of the delegator.\n     * @param _redeemer The address that is redeeming the delegation.\n     */\n    function beforeHook(\n        bytes calldata _terms,\n        bytes calldata _args,\n        ModeCode _mode,\n        bytes calldata _executionCalldata,\n        bytes32 _delegationHash,\n        address _delegator,\n        address _redeemer\n    )\n        external;\n\n    /**\n     * @notice Enforces conditions after the execution tied to a specific delegation in the redemption process.\n     * @dev This function MUST revert if the conditions are not met.\n     * @param _terms The terms to enforce set by the delegator.\n     * @param _args An optional input parameter set by the redeemer at time of invocation.\n     * @param _mode The mode of execution for the executionCalldata.\n     * @param _executionCalldata The data representing the execution.\n     * @param _delegationHash The hash of the delegation.\n     * @param _delegator The address of the delegator.\n     * @param _redeemer The address that is redeeming the delegation.\n     */\n    function afterHook(\n        bytes calldata _terms,\n        bytes calldata _args,\n        ModeCode _mode,\n        bytes calldata _executionCalldata,\n        bytes32 _delegationHash,\n        address _delegator,\n        address _redeemer\n    )\n        external;\n\n    /**\n     * @notice Enforces conditions after all actions in a batch redemption process have been executed.\n     * @dev This function MUST revert if the conditions are not met.\n     * @param _terms The terms to enforce set by the delegator.\n     * @param _args An optional input parameter set by the redeemer at time of invocation.\n     * @param _mode The mode of execution for the executionCalldata.\n     * @param _executionCalldata The data representing the execution.\n     * @param _delegationHash The hash of the delegation.\n     * @param _delegator The address of the delegator.\n     * @param _redeemer The address that is redeeming the delegation.\n     */\n    function afterAllHook(\n        bytes calldata _terms,\n        bytes calldata _args,\n        ModeCode _mode,\n        bytes calldata _executionCalldata,\n        bytes32 _delegationHash,\n        address _delegator,\n        address _redeemer\n    )\n        external;\n}\n"},{"file_path":"src/interfaces/IDeleGatorCore.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport { IERC1271 } from \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\n\nimport { ModeCode } from \"../utils/Types.sol\";\n\n/**\n * @title IDeleGatorCore\n * @notice Interface for a DeleGator that exposes the minimal functionality required.\n */\ninterface IDeleGatorCore is IERC1271 {\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     *         This function is intended to be called by Executor Modules\n     * @dev Ensure adequate authorization control: i.e. onlyExecutorModule\n     * @dev If a mode is requested that is not supported by the Account, it MUST revert\n     * @dev Related: @erc7579/MSAAdvanced.sol\n     * @param _mode The encoded execution mode of the transaction. See @erc7579/ModeLib.sol for details.\n     * @param _executionCalldata The encoded execution call data\n     */\n    function executeFromExecutor(\n        ModeCode _mode,\n        bytes calldata _executionCalldata\n    )\n        external\n        payable\n        returns (bytes[] memory returnData);\n}\n"},{"file_path":"src/interfaces/IDelegationManager.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport { Delegation, Execution, ModeCode } from \"../utils/Types.sol\";\n\n/**\n * @title IDelegationManager\n * @notice Interface that exposes methods of a custom DelegationManager implementation.\n */\ninterface IDelegationManager {\n    ////////////////////////////// Events //////////////////////////////\n\n    /// @dev Emitted when a delegation is redeemed\n    event RedeemedDelegation(address indexed rootDelegator, address indexed redeemer, Delegation delegation);\n\n    /// @dev Emitted when a delegation is enabled after being disabled\n    event EnabledDelegation(\n        bytes32 indexed delegationHash, address indexed delegator, address indexed delegate, Delegation delegation\n    );\n\n    /// @dev Emitted when a delegation is disabled\n    event DisabledDelegation(\n        bytes32 indexed delegationHash, address indexed delegator, address indexed delegate, Delegation delegation\n    );\n\n    /// @dev Emitted when the domain hash is set\n    event SetDomain(\n        bytes32 indexed domainHash, string name, string domainVersion, uint256 chainId, address indexed contractAddress\n    );\n\n    ////////////////////////////// Errors //////////////////////////////\n\n    /// @dev Error thrown when a user attempts to use a disabled delegation\n    error CannotUseADisabledDelegation();\n\n    /// @dev Error thrown when the authority in a chain of delegations doesn't match the expected authority\n    error InvalidAuthority();\n\n    /// @dev Error thrown when the redeemer doesn't match the approved delegate\n    error InvalidDelegate();\n\n    /// @dev Error thrown when the delegator of a delegation doesn't match the caller\n    error InvalidDelegator();\n\n    /// @dev Error thrown when the EOA signature provided is invalid\n    error InvalidEOASignature();\n\n    /// @dev Error thrown when the ERC1271 signature provided is invalid\n    error InvalidERC1271Signature();\n\n    /// @dev Error thrown when the signature is empty\n    error EmptySignature();\n\n    /// @dev Error thrown when the delegation provided is already disabled\n    error AlreadyDisabled();\n\n    /// @dev Error thrown when the delegation provided is already enabled\n    error AlreadyEnabled();\n\n    /// @dev Error thrown when the batch size doesn't match the execution array size\n    error BatchDataLengthMismatch();\n\n    ////////////////////////////// MM Implementation Methods //////////////////////////////\n\n    function pause() external;\n\n    function unpause() external;\n\n    function enableDelegation(Delegation calldata _delegation) external;\n\n    function disableDelegation(Delegation calldata _delegation) external;\n\n    function disabledDelegations(bytes32 _delegationHash) external view returns (bool);\n\n    function getDelegationHash(Delegation calldata _delegation) external pure returns (bytes32);\n\n    function redeemDelegations(\n        bytes[] calldata _permissionContexts,\n        ModeCode[] calldata _modes,\n        bytes[] calldata _executionCallDatas\n    )\n        external;\n\n    function getDomainHash() external view returns (bytes32);\n}\n"},{"file_path":"src/libraries/ERC1271Lib.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\n/**\n * @title ERC1271 Library\n */\nlibrary ERC1271Lib {\n    /// @dev Magic value to be returned upon successful validation.\n    bytes4 internal constant EIP1271_MAGIC_VALUE = 0x1626ba7e;\n\n    /// @dev Magic value to be returned upon failed validation.\n    bytes4 internal constant SIG_VALIDATION_FAILED = 0xffffffff;\n}\n"},{"file_path":"src/libraries/EncoderLib.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport { Delegation, Caveat } from \"../utils/Types.sol\";\nimport { DELEGATION_TYPEHASH, CAVEAT_TYPEHASH } from \"../utils/Constants.sol\";\n\n/**\n * @dev Provides implementations for common utility methods for Delegation.\n * @title Delegation Utility Library\n */\nlibrary EncoderLib {\n    /**\n     * @notice Encodes and hashes a Delegation struct.\n     * @dev The hash is used to verify the integrity of the Delegation.\n     * @param _input The Delegation parameters to be hashed.\n     * @return The keccak256 hash of the encoded Delegation packet.\n     */\n    function _getDelegationHash(Delegation memory _input) internal pure returns (bytes32) {\n        bytes memory encoded_ = abi.encode(\n            DELEGATION_TYPEHASH,\n            _input.delegate,\n            _input.delegator,\n            _input.authority,\n            _getCaveatArrayPacketHash(_input.caveats),\n            _input.salt\n        );\n        return keccak256(encoded_);\n    }\n\n    /**\n     * @notice Calculates the hash of an array of Caveats.\n     * @dev The hash is used to verify the integrity of the Caveats.\n     * @param _input The array of Caveats.\n     * @return The keccak256 hash of the encoded Caveat array packet.\n     */\n    function _getCaveatArrayPacketHash(Caveat[] memory _input) internal pure returns (bytes32) {\n        bytes32[] memory caveatPacketHashes_ = new bytes32[](_input.length);\n        for (uint256 i = 0; i < _input.length; ++i) {\n            caveatPacketHashes_[i] = _getCaveatPacketHash(_input[i]);\n        }\n        return keccak256(abi.encodePacked(caveatPacketHashes_));\n    }\n\n    /**\n     * @notice Calculates the hash of a single Caveat.\n     * @dev The hash is used to verify the integrity of the Caveat.\n     * @param _input The Caveat data.\n     * @return The keccak256 hash of the encoded Caveat packet.\n     */\n    function _getCaveatPacketHash(Caveat memory _input) internal pure returns (bytes32) {\n        bytes memory encoded_ = abi.encode(CAVEAT_TYPEHASH, _input.enforcer, keccak256(_input.terms));\n        return keccak256(encoded_);\n    }\n}\n"},{"file_path":"src/utils/Constants.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport {\n    CALLTYPE_SINGLE, CALLTYPE_BATCH, EXECTYPE_DEFAULT, EXECTYPE_TRY, MODE_DEFAULT, MODE_OFFSET\n} from \"@erc7579/lib/ModeLib.sol\";\n\nbytes32 constant EIP712_DOMAIN_TYPEHASH =\n    keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n// NOTE: signature is omitted from the Delegation typehash\nbytes32 constant DELEGATION_TYPEHASH = keccak256(\n    \"Delegation(address delegate,address delegator,bytes32 authority,Caveat[] caveats,uint256 salt)Caveat(address enforcer,bytes terms)\"\n);\n\nbytes32 constant CAVEAT_TYPEHASH = keccak256(\"Caveat(address enforcer,bytes terms)\");\n"},{"file_path":"src/utils/Types.sol","source_code":"// SPDX-License-Identifier: MIT AND Apache-2.0\npragma solidity 0.8.23;\n\nimport { PackedUserOperation } from \"@account-abstraction/interfaces/PackedUserOperation.sol\";\nimport { Execution } from \"@erc7579/interfaces/IERC7579Account.sol\";\nimport { ModeCode, CallType, ExecType, ModeSelector, ModePayload } from \"@erc7579/lib/ModeLib.sol\";\n\n/**\n * @title EIP712Domain\n * @notice Struct representing the EIP712 domain for signature validation.\n */\nstruct EIP712Domain {\n    string name;\n    string version;\n    uint256 chainId;\n    address verifyingContract;\n}\n\n/**\n * @title Delegation\n * @notice Struct representing a delegation to give a delegate authority to act on behalf of a delegator.\n * @dev `signature` is ignored during delegation hashing so it can be manipulated post signing.\n */\nstruct Delegation {\n    address delegate;\n    address delegator;\n    bytes32 authority;\n    Caveat[] caveats;\n    uint256 salt;\n    bytes signature;\n}\n\n/**\n * @title Caveat\n * @notice Struct representing a caveat to enforce on a delegation.\n * @dev `args` is ignored during caveat hashing so it can be manipulated post signing.\n */\nstruct Caveat {\n    address enforcer;\n    bytes terms;\n    bytes args;\n}\n\n/**\n * @title P256 Public Key\n * @notice Struct containing the X and Y coordinates of a P256 public key.\n */\nstruct P256PublicKey {\n    uint256 x;\n    uint256 y;\n}\n\nstruct DecodedWebAuthnSignature {\n    uint256 r;\n    uint256 s;\n    bytes authenticatorData;\n    bool requireUserVerification;\n    string clientDataJSONPrefix;\n    string clientDataJSONSuffix;\n    uint256 responseTypeLocation;\n}\n"},{"file_path":"lib/account-abstraction/contracts/interfaces/PackedUserOperation.sol","source_code":"// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/**\n * User Operation struct\n * @param sender                - The sender account of this request.\n * @param nonce                 - Unique value the sender uses to verify it is not a replay.\n * @param initCode              - If set, the account contract will be created by this constructor/\n * @param callData              - The method call to execute on this account.\n * @param accountGasLimits      - Packed gas limits for validateUserOp and gas limit passed to the callData method call.\n * @param preVerificationGas    - Gas not calculated by the handleOps method, but added to the gas paid.\n *                                Covers batch overhead.\n * @param gasFees               - packed gas fields maxPriorityFeePerGas and maxFeePerGas - Same as EIP-1559 gas parameters.\n * @param paymasterAndData      - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data\n *                                The paymaster will pay for the transaction instead of the sender.\n * @param signature             - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.\n */\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes initCode;\n    bytes callData;\n    bytes32 accountGasLimits;\n    uint256 preVerificationGas;\n    bytes32 gasFees;\n    bytes paymasterAndData;\n    bytes signature;\n}\n"},{"file_path":"lib/erc7579-implementation/src/interfaces/IERC7579Account.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.21;\n\nimport { CallType, ExecType, ModeCode } from \"../lib/ModeLib.sol\";\n\nstruct Execution {\n    address target;\n    uint256 value;\n    bytes callData;\n}\n\ninterface IERC7579Account {\n    event ModuleInstalled(uint256 moduleTypeId, address module);\n    event ModuleUninstalled(uint256 moduleTypeId, address module);\n\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     *         This function is intended to be called by ERC-4337 EntryPoint.sol\n     * @dev Ensure adequate authorization control: i.e. onlyEntryPointOrSelf\n     *\n     * @dev MSA MUST implement this function signature.\n     * If a mode is requested that is not supported by the Account, it MUST revert\n     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details\n     * @param executionCalldata The encoded execution call data\n     */\n    function execute(ModeCode mode, bytes calldata executionCalldata) external payable;\n\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     *         This function is intended to be called by Executor Modules\n     * @dev Ensure adequate authorization control: i.e. onlyExecutorModule\n     *\n     * @dev MSA MUST implement this function signature.\n     * If a mode is requested that is not supported by the Account, it MUST revert\n     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details\n     * @param executionCalldata The encoded execution call data\n     */\n    function executeFromExecutor(\n        ModeCode mode,\n        bytes calldata executionCalldata\n    )\n        external\n        payable\n        returns (bytes[] memory returnData);\n\n    /**\n     * @dev ERC-1271 isValidSignature\n     *         This function is intended to be used to validate a smart account signature\n     * and may forward the call to a validator module\n     *\n     * @param hash The hash of the data that is signed\n     * @param data The data that is signed\n     */\n    function isValidSignature(bytes32 hash, bytes calldata data) external view returns (bytes4);\n\n    /**\n     * @dev installs a Module of a certain type on the smart account\n     * @dev Implement Authorization control of your chosing\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     * @param module the module address\n     * @param initData arbitrary data that may be required on the module during `onInstall`\n     * initialization.\n     */\n    function installModule(\n        uint256 moduleTypeId,\n        address module,\n        bytes calldata initData\n    )\n        external\n        payable;\n\n    /**\n     * @dev uninstalls a Module of a certain type on the smart account\n     * @dev Implement Authorization control of your chosing\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     * @param module the module address\n     * @param deInitData arbitrary data that may be required on the module during `onUninstall`\n     * de-initialization.\n     */\n    function uninstallModule(\n        uint256 moduleTypeId,\n        address module,\n        bytes calldata deInitData\n    )\n        external\n        payable;\n\n    /**\n     * Function to check if the account supports a certain CallType or ExecType (see ModeLib.sol)\n     * @param encodedMode the encoded mode\n     */\n    function supportsExecutionMode(ModeCode encodedMode) external view returns (bool);\n\n    /**\n     * Function to check if the account supports installation of a certain module type Id\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     */\n    function supportsModule(uint256 moduleTypeId) external view returns (bool);\n\n    /**\n     * Function to check if the account has a certain module installed\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     *      Note: keep in mind that some contracts can be multiple module types at the same time. It\n     *            thus may be necessary to query multiple module types\n     * @param module the module address\n     * @param additionalContext additional context data that the smart account may interpret to\n     *                          identifiy conditions under which the module is installed.\n     *                          usually this is not necessary, but for some special hooks that\n     *                          are stored in mappings, this param might be needed\n     */\n    function isModuleInstalled(\n        uint256 moduleTypeId,\n        address module,\n        bytes calldata additionalContext\n    )\n        external\n        view\n        returns (bool);\n\n    /**\n     * @dev Returns the account id of the smart account\n     * @return accountImplementationId the account id of the smart account\n     * the accountId should be structured like so:\n     *        \"vendorname.accountname.semver\"\n     */\n    function accountId() external view returns (string memory accountImplementationId);\n}\n"},{"file_path":"lib/erc7579-implementation/src/lib/ModeLib.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.23;\n\n/**\n * @title ModeLib\n * To allow smart accounts to be very simple, but allow for more complex execution, A custom mode\n * encoding is used.\n *    Function Signature of execute function:\n *           function execute(ModeCode mode, bytes calldata executionCalldata) external payable;\n * This allows for a single bytes32 to be used to encode the execution mode, calltype, execType and\n * context.\n * NOTE: Simple Account implementations only have to scope for the most significant byte. Account  that\n * implement\n * more complex execution modes may use the entire bytes32.\n *\n * |--------------------------------------------------------------------|\n * | CALLTYPE  | EXECTYPE  |   UNUSED   | ModeSelector  |  ModePayload  |\n * |--------------------------------------------------------------------|\n * | 1 byte    | 1 byte    |   4 bytes  | 4 bytes       |   22 bytes    |\n * |--------------------------------------------------------------------|\n *\n * CALLTYPE: 1 byte\n * CallType is used to determine how the executeCalldata paramter of the execute function has to be\n * decoded.\n * It can be either single, batch or delegatecall. In the future different calls could be added.\n * CALLTYPE can be used by a validation module to determine how to decode <userOp.callData[36:]>.\n *\n * EXECTYPE: 1 byte\n * ExecType is used to determine how the account should handle the execution.\n * It can indicate if the execution should revert on failure or continue execution.\n * In the future more execution modes may be added.\n * Default Behavior (EXECTYPE = 0x00) is to revert on a single failed execution. If one execution in\n * a batch fails, the entire batch is reverted\n *\n * UNUSED: 4 bytes\n * Unused bytes are reserved for future use.\n *\n * ModeSelector: bytes4\n * The \"optional\" mode selector can be used by account vendors, to implement custom behavior in\n * their accounts.\n * the way a ModeSelector is to be calculated is bytes4(keccak256(\"vendorname.featurename\"))\n * this is to prevent collisions between different vendors, while allowing innovation and the\n * development of new features without coordination between ERC-7579 implementing accounts\n *\n * ModePayload: 22 bytes\n * Mode payload is used to pass additional data to the smart account execution, this may be\n * interpreted depending on the ModeSelector\n *\n * ExecutionCallData: n bytes\n * single, delegatecall or batch exec abi.encoded as bytes\n */\nimport { Execution } from \"../interfaces/IERC7579Account.sol\";\n\n// Custom type for improved developer experience\ntype ModeCode is bytes32;\n\ntype CallType is bytes1;\n\ntype ExecType is bytes1;\n\ntype ModeSelector is bytes4;\n\ntype ModePayload is bytes22;\n\n// Default CallType\nCallType constant CALLTYPE_SINGLE = CallType.wrap(0x00);\n// Batched CallType\nCallType constant CALLTYPE_BATCH = CallType.wrap(0x01);\n// @dev Implementing delegatecall is OPTIONAL!\n// implement delegatecall with extreme care.\nCallType constant CALLTYPE_STATIC = CallType.wrap(0xFE);\nCallType constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);\n\n// @dev default behavior is to revert on failure\n// To allow very simple accounts to use mode encoding, the default behavior is to revert on failure\n// Since this is value 0x00, no additional encoding is required for simple accounts\nExecType constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);\n// @dev account may elect to change execution behavior. For example \"try exec\" / \"allow fail\"\nExecType constant EXECTYPE_TRY = ExecType.wrap(0x01);\n\nModeSelector constant MODE_DEFAULT = ModeSelector.wrap(bytes4(0x00000000));\n// Example declaration of a custom mode selector\nModeSelector constant MODE_OFFSET = ModeSelector.wrap(bytes4(keccak256(\"default.mode.offset\")));\n\n/**\n * @dev ModeLib is a helper library to encode/decode ModeCodes\n */\nlibrary ModeLib {\n    function decode(ModeCode mode)\n        internal\n        pure\n        returns (\n            CallType _calltype,\n            ExecType _execType,\n            ModeSelector _modeSelector,\n            ModePayload _modePayload\n        )\n    {\n        assembly {\n            _calltype := mode\n            _execType := shl(8, mode)\n            _modeSelector := shl(48, mode)\n            _modePayload := shl(80, mode)\n        }\n    }\n\n    function encode(\n        CallType callType,\n        ExecType execType,\n        ModeSelector mode,\n        ModePayload payload\n    )\n        internal\n        pure\n        returns (ModeCode)\n    {\n        return ModeCode.wrap(\n            bytes32(\n                abi.encodePacked(callType, execType, bytes4(0), ModeSelector.unwrap(mode), payload)\n            )\n        );\n    }\n\n    function encodeSimpleBatch() internal pure returns (ModeCode mode) {\n        mode = encode(CALLTYPE_BATCH, EXECTYPE_DEFAULT, MODE_DEFAULT, ModePayload.wrap(0x00));\n    }\n\n    function encodeSimpleSingle() internal pure returns (ModeCode mode) {\n        mode = encode(CALLTYPE_SINGLE, EXECTYPE_DEFAULT, MODE_DEFAULT, ModePayload.wrap(0x00));\n    }\n\n    function getCallType(ModeCode mode) internal pure returns (CallType calltype) {\n        assembly {\n            calltype := mode\n        }\n    }\n}\n\nusing { eqModeSelector as == } for ModeSelector global;\nusing { eqCallType as == } for CallType global;\nusing { eqExecType as == } for ExecType global;\n\nfunction eqCallType(CallType a, CallType b) pure returns (bool) {\n    return CallType.unwrap(a) == CallType.unwrap(b);\n}\n\nfunction eqExecType(ExecType a, ExecType b) pure returns (bool) {\n    return ExecType.unwrap(a) == ExecType.unwrap(b);\n}\n\nfunction eqModeSelector(ModeSelector a, ModeSelector b) pure returns (bool) {\n    return ModeSelector.unwrap(a) == ModeSelector.unwrap(b);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/access/Ownable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * This extension of the {Ownable} contract includes a two-step mechanism to transfer\n * ownership, where the new owner must call {acceptOwnership} in order to replace the\n * old one. This can help prevent common mistakes, such as transfers of ownership to\n * incorrect accounts, or to contracts that are unable to interact with the\n * permission system.\n *\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n    address private _pendingOwner;\n\n    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Returns the address of the pending owner.\n     */\n    function pendingOwner() public view virtual returns (address) {\n        return _pendingOwner;\n    }\n\n    /**\n     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual override onlyOwner {\n        _pendingOwner = newOwner;\n        emit OwnershipTransferStarted(owner(), newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual override {\n        delete _pendingOwner;\n        super._transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev The new owner accepts the ownership transfer.\n     */\n    function acceptOwnership() public virtual {\n        address sender = _msgSender();\n        if (pendingOwner() != sender) {\n            revert OwnableUnauthorizedAccount(sender);\n        }\n        _transferOwnership(sender);\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC1271.sol","source_code":"// 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 ERC-1271 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"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC5267.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n    /**\n     * @dev MAY be emitted to signal that the domain could have changed.\n     */\n    event EIP712DomainChanged();\n\n    /**\n     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n     * signature.\n     */\n    function eip712Domain()\n        external\n        view\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        );\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Context.sol","source_code":"// 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"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Panic.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n *      using Panic for uint256;\n *\n *      // Use any of the declared internal constants\n *      function foo() { Panic.GENERIC.panic(); }\n *\n *      // Alternatively\n *      function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n    /// @dev generic / unspecified error\n    uint256 internal constant GENERIC = 0x00;\n    /// @dev used by the assert() builtin\n    uint256 internal constant ASSERT = 0x01;\n    /// @dev arithmetic underflow or overflow\n    uint256 internal constant UNDER_OVERFLOW = 0x11;\n    /// @dev division or modulo by zero\n    uint256 internal constant DIVISION_BY_ZERO = 0x12;\n    /// @dev enum conversion error\n    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n    /// @dev invalid encoding in storage\n    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n    /// @dev empty array pop\n    uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n    /// @dev array out of bounds access\n    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n    /// @dev resource error (too large allocation or too large array)\n    uint256 internal constant RESOURCE_ERROR = 0x41;\n    /// @dev calling invalid internal function\n    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n    /// @dev Reverts with a panic code. Recommended to use with\n    /// the internal constants with predefined codes.\n    function panic(uint256 code) internal pure {\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, 0x4e487b71)\n            mstore(0x20, code)\n            revert(0x1c, 0x24)\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Pausable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n    bool private _paused;\n\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    /**\n     * @dev The operation failed because the contract is paused.\n     */\n    error EnforcedPause();\n\n    /**\n     * @dev The operation failed because the contract is not paused.\n     */\n    error ExpectedPause();\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    constructor() {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        if (paused()) {\n            revert EnforcedPause();\n        }\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        if (!paused()) {\n            revert ExpectedPause();\n        }\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/ShortStrings.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |\n// | length  | 0x                                                              BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n *     using ShortStrings for *;\n *\n *     ShortString private immutable _name;\n *     string private _nameFallback;\n *\n *     constructor(string memory contractName) {\n *         _name = contractName.toShortStringWithFallback(_nameFallback);\n *     }\n *\n *     function name() external view returns (string memory) {\n *         return _name.toStringWithFallback(_nameFallback);\n *     }\n * }\n * ```\n */\nlibrary ShortStrings {\n    // Used as an identifier for strings longer than 31 bytes.\n    bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n    error StringTooLong(string str);\n    error InvalidShortString();\n\n    /**\n     * @dev Encode a string of at most 31 chars into a `ShortString`.\n     *\n     * This will trigger a `StringTooLong` error is the input string is too long.\n     */\n    function toShortString(string memory str) internal pure returns (ShortString) {\n        bytes memory bstr = bytes(str);\n        if (bstr.length > 31) {\n            revert StringTooLong(str);\n        }\n        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n    }\n\n    /**\n     * @dev Decode a `ShortString` back to a \"normal\" string.\n     */\n    function toString(ShortString sstr) internal pure returns (string memory) {\n        uint256 len = byteLength(sstr);\n        // using `new string(len)` would work locally but is not memory safe.\n        string memory str = new string(32);\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(str, len)\n            mstore(add(str, 0x20), sstr)\n        }\n        return str;\n    }\n\n    /**\n     * @dev Return the length of a `ShortString`.\n     */\n    function byteLength(ShortString sstr) internal pure returns (uint256) {\n        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n        if (result > 31) {\n            revert InvalidShortString();\n        }\n        return result;\n    }\n\n    /**\n     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n     */\n    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n        if (bytes(value).length < 32) {\n            return toShortString(value);\n        } else {\n            StorageSlot.getStringSlot(store).value = value;\n            return ShortString.wrap(FALLBACK_SENTINEL);\n        }\n    }\n\n    /**\n     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n     */\n    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n            return toString(value);\n        } else {\n            return store;\n        }\n    }\n\n    /**\n     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n     * {setWithFallback}.\n     *\n     * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n     */\n    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n            return byteLength(value);\n        } else {\n            return bytes(store).length;\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC-1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(newImplementation.code.length > 0);\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Strings.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        uint256 localValue = value;\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = HEX_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol","source_code":"// 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[ERC-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"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/cryptography/EIP712.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n    using ShortStrings for *;\n\n    bytes32 private constant TYPE_HASH =\n        keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n    // invalidate the cached domain separator if the chain id changes.\n    bytes32 private immutable _cachedDomainSeparator;\n    uint256 private immutable _cachedChainId;\n    address private immutable _cachedThis;\n\n    bytes32 private immutable _hashedName;\n    bytes32 private immutable _hashedVersion;\n\n    ShortString private immutable _name;\n    ShortString private immutable _version;\n    string private _nameFallback;\n    string private _versionFallback;\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    constructor(string memory name, string memory version) {\n        _name = name.toShortStringWithFallback(_nameFallback);\n        _version = version.toShortStringWithFallback(_versionFallback);\n        _hashedName = keccak256(bytes(name));\n        _hashedVersion = keccak256(bytes(version));\n\n        _cachedChainId = block.chainid;\n        _cachedDomainSeparator = _buildDomainSeparator();\n        _cachedThis = address(this);\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n            return _cachedDomainSeparator;\n        } else {\n            return _buildDomainSeparator();\n        }\n    }\n\n    function _buildDomainSeparator() private view returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev See {IERC-5267}.\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        return (\n            hex\"0f\", // 01111\n            _EIP712Name(),\n            _EIP712Version(),\n            block.chainid,\n            address(this),\n            bytes32(0),\n            new uint256[](0)\n        );\n    }\n\n    /**\n     * @dev The name parameter for the EIP712 domain.\n     *\n     * NOTE: By default this function reads _name which is an immutable value.\n     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function _EIP712Name() internal view returns (string memory) {\n        return _name.toStringWithFallback(_nameFallback);\n    }\n\n    /**\n     * @dev The version parameter for the EIP712 domain.\n     *\n     * NOTE: By default this function reads _version which is an immutable value.\n     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function _EIP712Version() internal view returns (string memory) {\n        return _version.toStringWithFallback(_versionFallback);\n    }\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyDisabled","type":"error"},{"inputs":[],"name":"AlreadyEnabled","type":"error"},{"inputs":[],"name":"BatchDataLengthMismatch","type":"error"},{"inputs":[],"name":"CannotUseADisabledDelegation","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"EmptySignature","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidAuthority","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidDelegator","type":"error"},{"inputs":[],"name":"InvalidEOASignature","type":"error"},{"inputs":[],"name":"InvalidERC1271Signature","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"delegationHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"address","name":"delegator","type":"address"},{"internalType":"bytes32","name":"authority","type":"bytes32"},{"components":[{"internalType":"address","name":"enforcer","type":"address"},{"internalType":"bytes","name":"terms","type":"bytes"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct Caveat[]","name":"caveats","type":"tuple[]"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"indexed":false,"internalType":"struct Delegation","name":"delegation","type":"tuple"}],"name":"DisabledDelegation","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"delegationHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"address","name":"delegator","type":"address"},{"internalType":"bytes32","name":"authority","type":"bytes32"},{"components":[{"internalType":"address","name":"enforcer","type":"address"},{"internalType":"bytes","name":"terms","type":"bytes"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct Caveat[]","name":"caveats","type":"tuple[]"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"indexed":false,"internalType":"struct Delegation","name":"delegation","type":"tuple"}],"name":"EnabledDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rootDelegator","type":"address"},{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"address","name":"delegator","type":"address"},{"internalType":"bytes32","name":"authority","type":"bytes32"},{"components":[{"internalType":"address","name":"enforcer","type":"address"},{"internalType":"bytes","name":"terms","type":"bytes"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct Caveat[]","name":"caveats","type":"tuple[]"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"indexed":false,"internalType":"struct Delegation","name":"delegation","type":"tuple"}],"name":"RedeemedDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"domainHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"domainVersion","type":"string"},{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"contractAddress","type":"address"}],"name":"SetDomain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ANY_DELEGATE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROOT_AUTHORITY","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"address","name":"delegator","type":"address"},{"internalType":"bytes32","name":"authority","type":"bytes32"},{"components":[{"internalType":"address","name":"enforcer","type":"address"},{"internalType":"bytes","name":"terms","type":"bytes"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct Caveat[]","name":"caveats","type":"tuple[]"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Delegation","name":"_delegation","type":"tuple"}],"name":"disableDelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"delegationHash","type":"bytes32"}],"name":"disabledDelegations","outputs":[{"internalType":"bool","name":"isDisabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"address","name":"delegator","type":"address"},{"internalType":"bytes32","name":"authority","type":"bytes32"},{"components":[{"internalType":"address","name":"enforcer","type":"address"},{"internalType":"bytes","name":"terms","type":"bytes"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct Caveat[]","name":"caveats","type":"tuple[]"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Delegation","name":"_delegation","type":"tuple"}],"name":"enableDelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"delegate","type":"address"},{"internalType":"address","name":"delegator","type":"address"},{"internalType":"bytes32","name":"authority","type":"bytes32"},{"components":[{"internalType":"address","name":"enforcer","type":"address"},{"internalType":"bytes","name":"terms","type":"bytes"},{"internalType":"bytes","name":"args","type":"bytes"}],"internalType":"struct Caveat[]","name":"caveats","type":"tuple[]"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Delegation","name":"_input","type":"tuple"}],"name":"getDelegationHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getDomainHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_permissionContexts","type":"bytes[]"},{"internalType":"ModeCode[]","name":"_modes","type":"bytes32[]"},{"internalType":"bytes[]","name":"_executionCallDatas","type":"bytes[]"}],"name":"redeemDelegations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":"000000000000000000000000b0403b32f54d0bd752113f4009e8b534c6669f44"}