{"file_path":"src/EmergencyUpgradeBoard.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport {EIP712} from \"@openzeppelin/contracts/utils/cryptography/EIP712.sol\";\nimport {SignatureChecker} from \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\nimport {IProtocolUpgradeHandler} from \"./interfaces/IProtocolUpgradeHandler.sol\";\n\n/// @title Emergency Upgrade Board\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ncontract EmergencyUpgradeBoard is EIP712 {\n    using SignatureChecker for address;\n\n    /// @notice Address of the contract, which manages protocol upgrades.\n    IProtocolUpgradeHandler public immutable PROTOCOL_UPGRADE_HANDLER;\n\n    /// @notice The address of the Security Council.\n    address public immutable SECURITY_COUNCIL;\n\n    /// @notice The address of the guardians.\n    address public immutable GUARDIANS;\n\n    /// @notice The address of the ZK Foundation multisig.\n    address public immutable ZK_FOUNDATION_SAFE;\n\n    /// @dev EIP-712 TypeHash for the emergency protocol upgrade execution approved by the guardians.\n    bytes32 internal constant EXECUTE_EMERGENCY_UPGRADE_GUARDIANS_TYPEHASH =\n        keccak256(\"ExecuteEmergencyUpgradeGuardians(bytes32 id)\");\n\n    /// @dev EIP-712 TypeHash for the emergency protocol upgrade execution approved by the Security Council.\n    bytes32 internal constant EXECUTE_EMERGENCY_UPGRADE_SECURITY_COUNCIL_TYPEHASH =\n        keccak256(\"ExecuteEmergencyUpgradeSecurityCouncil(bytes32 id)\");\n\n    /// @dev EIP-712 TypeHash for the emergency protocol upgrade execution approved by the ZK Foundation.\n    bytes32 internal constant EXECUTE_EMERGENCY_UPGRADE_ZK_FOUNDATION_TYPEHASH =\n        keccak256(\"ExecuteEmergencyUpgradeZKFoundation(bytes32 id)\");\n\n    /// @dev Initializes the Emergency Upgrade Board contract with setup for EIP-712.\n    /// @param _protocolUpgradeHandler The address of the protocol upgrade handler contract, responsible for executing the upgrades.\n    /// @param _securityCouncil The address of the Security Council multisig.\n    /// @param _guardians The address of the Guardians multisig.\n    /// @param _zkFoundation The address of the ZK Foundation Safe multisig.\n    constructor(\n        IProtocolUpgradeHandler _protocolUpgradeHandler,\n        address _securityCouncil,\n        address _guardians,\n        address _zkFoundation\n    ) EIP712(\"EmergencyUpgradeBoard\", \"1\") {\n        PROTOCOL_UPGRADE_HANDLER = _protocolUpgradeHandler;\n        SECURITY_COUNCIL = _securityCouncil;\n        GUARDIANS = _guardians;\n        ZK_FOUNDATION_SAFE = _zkFoundation;\n    }\n\n    /// @notice Executes an emergency protocol upgrade approved by the Security Council, Guardians and ZK Foundation.\n    /// @param _calls Array of `Call` structures specifying the calls to be made in the upgrade.\n    /// @param _salt A bytes32 value used for creating unique upgrade proposal hashes.\n    /// @param _guardiansSignatures Encoded signers & signatures from the guardians multisig, required to authorize the emergency upgrade.\n    /// @param _securityCouncilSignatures Encoded signers & signatures from the Security Council multisig, required to authorize the emergency upgrade.\n    /// @param _zkFoundationSignatures Signatures from the ZK Foundation multisig, required to authorize the emergency upgrade.\n    function executeEmergencyUpgrade(\n        IProtocolUpgradeHandler.Call[] calldata _calls,\n        bytes32 _salt,\n        bytes calldata _guardiansSignatures,\n        bytes calldata _securityCouncilSignatures,\n        bytes calldata _zkFoundationSignatures\n    ) external {\n        IProtocolUpgradeHandler.UpgradeProposal memory upgradeProposal =\n            IProtocolUpgradeHandler.UpgradeProposal({calls: _calls, salt: _salt, executor: address(this)});\n        bytes32 id = keccak256(abi.encode(upgradeProposal));\n\n        bytes32 guardiansDigest =\n            _hashTypedDataV4(keccak256(abi.encode(EXECUTE_EMERGENCY_UPGRADE_GUARDIANS_TYPEHASH, id)));\n        require(\n            GUARDIANS.isValidERC1271SignatureNow(guardiansDigest, _guardiansSignatures), \"Invalid guardians signatures\"\n        );\n\n        bytes32 securityCouncilDigest =\n            _hashTypedDataV4(keccak256(abi.encode(EXECUTE_EMERGENCY_UPGRADE_SECURITY_COUNCIL_TYPEHASH, id)));\n        require(\n            SECURITY_COUNCIL.isValidERC1271SignatureNow(securityCouncilDigest, _securityCouncilSignatures),\n            \"Invalid Security Council signatures\"\n        );\n\n        bytes32 zkFoundationDigest =\n            _hashTypedDataV4(keccak256(abi.encode(EXECUTE_EMERGENCY_UPGRADE_ZK_FOUNDATION_TYPEHASH, id)));\n        require(\n            ZK_FOUNDATION_SAFE.isValidSignatureNow(zkFoundationDigest, _zkFoundationSignatures),\n            \"Invalid ZK Foundation signatures\"\n        );\n\n        PROTOCOL_UPGRADE_HANDLER.executeEmergencyUpgrade(upgradeProposal);\n    }\n}\n","deployed_bytecode":"0x608060405234801561000f575f80fd5b5060043610610060575f3560e01c806336086417146100645780633f6b9ddb146100a857806384b0196e146100cf578063b4c77c3b146100ea578063c03fd44b14610111578063c2646db414610126575b5f80fd5b61008b7f00000000000000000000000066e4431266dc7e04e7d8b7fe9d2181253df7f41081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008b7f000000000000000000000000600da620ab29f41abc6596a15981e14ce58c86b881565b6100d761014d565b60405161009f9796959493929190610ad9565b61008b7f000000000000000000000000e30dca3047b37dc7d88849de4a4dc07937ad5ab381565b61012461011f366004610bb5565b61018f565b005b61008b7f000000000000000000000000bc1653bd3829dfec575afc3816d4899cd103b51c81565b5f6060805f805f606061015e610588565b6101666105b9565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f60405180606001604052808b8b906101a89190610d14565b8152602001306001600160a01b031681526020018981525090505f816040516020016101d49190610e33565b6040516020818303038152906040528051906020012090505f6102477fca13e65539327d441ed2bdec279e457a1af26eb3e4dbe09fcd7a8633662af7e28360405160200161022c929190918252602082015260400190565b604051602081830303815290604052805190602001206105e6565b90506102b4818a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250506001600160a01b037f000000000000000000000000600da620ab29f41abc6596a15981e14ce58c86b8169392915050610618565b6103055760405162461bcd60e51b815260206004820152601c60248201527f496e76616c696420677561726469616e73207369676e6174757265730000000060448201526064015b60405180910390fd5b604080517fca6492c171331a4293d71e9e45f05ca3db6aaf73acc6e0cde07a1bdc2a119cdc60208201529081018390525f906103439060600161022c565b90506103b08189898080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250506001600160a01b037f00000000000000000000000066e4431266dc7e04e7d8b7fe9d2181253df7f410169392915050610618565b6104085760405162461bcd60e51b815260206004820152602360248201527f496e76616c696420536563757269747920436f756e63696c207369676e61747560448201526272657360e81b60648201526084016102fc565b604080517fbc65a4e7edaf75c145d74b7c4e65a168cf6bce5e78f11e27fcd63ed0c62afacf60208201529081018490525f906104469060600161022c565b90506104b38188888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250506001600160a01b037f000000000000000000000000bc1653bd3829dfec575afc3816d4899cd103b51c1693929150506106ef565b6104ff5760405162461bcd60e51b815260206004820181905260248201527f496e76616c6964205a4b20466f756e646174696f6e207369676e61747572657360448201526064016102fc565b604051632291ed1b60e11b81526001600160a01b037f000000000000000000000000e30dca3047b37dc7d88849de4a4dc07937ad5ab31690634523da369061054b908890600401610e33565b5f604051808303815f87803b158015610562575f80fd5b505af1158015610574573d5f803e3d5ffd5b505050505050505050505050505050505050565b60606105b47f456d657267656e637955706772616465426f61726400000000000000000000155f610744565b905090565b60606105b47f31000000000000000000000000000000000000000000000000000000000000016001610744565b5f6106126105f26107ee565b8360405161190160f01b8152600281019290925260228201526042902090565b92915050565b5f805f856001600160a01b03168585604051602401610638929190610ee5565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b1790525161066d9190610f05565b5f60405180830381855afa9150503d805f81146106a5576040519150601f19603f3d011682016040523d82523d5f602084013e6106aa565b606091505b50915091508180156106be57506020815110155b80156106e557508051630b135d3f60e11b906106e39083016020908101908401610f20565b145b9695505050505050565b5f805f6106fc8585610917565b5090925090505f81600381111561071557610715610f37565b1480156107335750856001600160a01b0316826001600160a01b0316145b806106e557506106e5868686610618565b606060ff831461075e5761075783610960565b9050610612565b81805461076a90610f4b565b80601f016020809104026020016040519081016040528092919081815260200182805461079690610f4b565b80156107e15780601f106107b8576101008083540402835291602001916107e1565b820191905f5260205f20905b8154815290600101906020018083116107c457829003601f168201915b5050505050905092915050565b5f306001600160a01b037f000000000000000000000000ece8e30bfc92c2a8e11e6cb2e17b70868572e3f61614801561084657507f000000000000000000000000000000000000000000000000000000000000000146145b1561087057507f694d658491e66f3a08bca176fe90b3d454d36ae4299d719b652a327888b7966590565b6105b4604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f09e7b74238054110bafcefc73054144d67fe22a2ed5c1eedf64ff5ea802611fd918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b5f805f835160410361094e576020840151604085015160608601515f1a6109408882858561099d565b955095509550505050610959565b505081515f91506002905b9250925092565b60605f61096c83610a65565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156109d657505f91506003905082610a5b565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015610a27573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116610a5257505f925060019150829050610a5b565b92505f91508190505b9450945094915050565b5f60ff8216601f81111561061257604051632cd44ac360e21b815260040160405180910390fd5b5f5b83811015610aa6578181015183820152602001610a8e565b50505f910152565b5f8151808452610ac5816020860160208601610a8c565b601f01601f19169290920160200192915050565b60ff60f81b881681525f602060e06020840152610af960e084018a610aae565b8381036040850152610b0b818a610aae565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825260208088019350909101905f5b81811015610b5e57835183529284019291840191600101610b42565b50909c9b505050505050505050505050565b5f8083601f840112610b80575f80fd5b50813567ffffffffffffffff811115610b97575f80fd5b602083019150836020828501011115610bae575f80fd5b9250929050565b5f805f805f805f805f60a08a8c031215610bcd575f80fd5b893567ffffffffffffffff80821115610be4575f80fd5b818c0191508c601f830112610bf7575f80fd5b813581811115610c05575f80fd5b8d60208260051b8501011115610c19575f80fd5b60209283019b509950908b0135975060408b01359080821115610c3a575f80fd5b610c468d838e01610b70565b909850965060608c0135915080821115610c5e575f80fd5b610c6a8d838e01610b70565b909650945060808c0135915080821115610c82575f80fd5b50610c8f8c828d01610b70565b915080935050809150509295985092959850929598565b634e487b7160e01b5f52604160045260245ffd5b6040516060810167ffffffffffffffff81118282101715610cdd57610cdd610ca6565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610d0c57610d0c610ca6565b604052919050565b5f67ffffffffffffffff80841115610d2e57610d2e610ca6565b8360051b6020610d3f818301610ce3565b868152918501918181019036841115610d56575f80fd5b865b84811015610e2757803586811115610d6e575f80fd5b88016060368290031215610d80575f80fd5b610d88610cba565b81356001600160a01b0381168114610d9e575f80fd5b8152818601358682015260408083013589811115610dba575f80fd5b9290920191601f3681850112610dce575f80fd5b83358a811115610de057610de0610ca6565b610df1818301601f19168a01610ce3565b91508082523689828701011115610e06575f80fd5b808986018a8401375f90820189015290820152845250918301918301610d58565b50979650505050505050565b5f60208083526080830184516060808487015282825180855260a08801915060a08160051b890101945085840193505f5b81811015610eb757888603609f19018352845180516001600160a01b031687528781015188880152604090810151908701859052610ea485880182610aae565b9650509386019391860191600101610e64565b50505050918501516001600160a01b0381166040860152915060408501516060850152809250505092915050565b828152604060208201525f610efd6040830184610aae565b949350505050565b5f8251610f16818460208701610a8c565b9190910192915050565b5f60208284031215610f30575f80fd5b5051919050565b634e487b7160e01b5f52602160045260245ffd5b600181811c90821680610f5f57607f821691505b602082108103610f7d57634e487b7160e01b5f52602260045260245ffd5b5091905056fea26469706673582212200c166ea6dd3ab3d912901bebe655c8ad3e6d871845812c00a96142ecd66cf65d64736f6c63430008180033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"cancun","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":200},"remappings":[":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",":ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",":erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",":forge-std/=lib/forge-std/src/",":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",":openzeppelin-contracts/=lib/openzeppelin-contracts/"]},"optimization_runs":200,"sourcify_repo_url":"https://repo.sourcify.dev/contracts/full_match/1/0xECE8e30bFc92c2A8e11e6cb2e17B70868572E3f6/","decoded_constructor_args":[["0xE30Dca3047B37dc7d88849dE4A4Dc07937ad5Ab3",{"internalType":"contract IProtocolUpgradeHandler","name":"_protocolUpgradeHandler","type":"address"}],["0x66E4431266DC7E04E7d8b7FE9d2181253df7F410",{"internalType":"address","name":"_securityCouncil","type":"address"}],["0x600dA620Ab29F41ABC6596a15981e14cE58c86b8",{"internalType":"address","name":"_guardians","type":"address"}],["0xbC1653bd3829dfEc575AfC3816D4899cd103B51c",{"internalType":"address","name":"_zkFoundation","type":"address"}]],"compiler_version":"0.8.24+commit.e11b9ed9","is_verified_via_verifier_alliance":false,"verified_at":"2026-01-20T23:21:03.066662Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x6101e060405234801562000011575f80fd5b5060405162001483380380620014838339810160408190526200003491620001f6565b604080518082018252601581527f456d657267656e637955706772616465426f6172640000000000000000000000602080830191909152825180840190935260018352603160f81b90830152906200008d825f6200015b565b610120526200009e8160016200015b565b61014052815160208084019190912060e052815190820120610100524660a0526200012b60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526001600160a01b03938416610160529183166101805282166101a052166101c05262000437565b5f6020835110156200017a57620001728362000193565b90506200018d565b81620001878482620002f9565b5060ff90505b92915050565b5f80829050601f81511115620001c9578260405163305a27a960e01b8152600401620001c09190620003c5565b60405180910390fd5b8051620001d68262000413565b179392505050565b6001600160a01b0381168114620001f3575f80fd5b50565b5f805f80608085870312156200020a575f80fd5b84516200021781620001de565b60208601519094506200022a81620001de565b60408601519093506200023d81620001de565b60608601519092506200025081620001de565b939692955090935050565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806200028457607f821691505b602082108103620002a357634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620002f457805f5260205f20601f840160051c81016020851015620002d05750805b601f840160051c820191505b81811015620002f1575f8155600101620002dc565b50505b505050565b81516001600160401b038111156200031557620003156200025b565b6200032d816200032684546200026f565b84620002a9565b602080601f83116001811462000363575f84156200034b5750858301515b5f19600386901b1c1916600185901b178555620003bd565b5f85815260208120601f198616915b82811015620003935788860151825594840194600190910190840162000372565b5085821015620003b157878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f602080835283518060208501525f5b81811015620003f357858101830151858201604001528201620003d5565b505f604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620002a3575f1960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c051610fb9620004ca5f395f818161012b015261048901525f818160ad015261028a01525f81816069015261038601525f818160ef015261051601525f6105c001525f61058f01525f6108c701525f61089f01525f6107fa01525f61082401525f61084e0152610fb95ff3fe608060405234801561000f575f80fd5b5060043610610060575f3560e01c806336086417146100645780633f6b9ddb146100a857806384b0196e146100cf578063b4c77c3b146100ea578063c03fd44b14610111578063c2646db414610126575b5f80fd5b61008b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61008b7f000000000000000000000000000000000000000000000000000000000000000081565b6100d761014d565b60405161009f9796959493929190610ad9565b61008b7f000000000000000000000000000000000000000000000000000000000000000081565b61012461011f366004610bb5565b61018f565b005b61008b7f000000000000000000000000000000000000000000000000000000000000000081565b5f6060805f805f606061015e610588565b6101666105b9565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f60405180606001604052808b8b906101a89190610d14565b8152602001306001600160a01b031681526020018981525090505f816040516020016101d49190610e33565b6040516020818303038152906040528051906020012090505f6102477fca13e65539327d441ed2bdec279e457a1af26eb3e4dbe09fcd7a8633662af7e28360405160200161022c929190918252602082015260400190565b604051602081830303815290604052805190602001206105e6565b90506102b4818a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169392915050610618565b6103055760405162461bcd60e51b815260206004820152601c60248201527f496e76616c696420677561726469616e73207369676e6174757265730000000060448201526064015b60405180910390fd5b604080517fca6492c171331a4293d71e9e45f05ca3db6aaf73acc6e0cde07a1bdc2a119cdc60208201529081018390525f906103439060600161022c565b90506103b08189898080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169392915050610618565b6104085760405162461bcd60e51b815260206004820152602360248201527f496e76616c696420536563757269747920436f756e63696c207369676e61747560448201526272657360e81b60648201526084016102fc565b604080517fbc65a4e7edaf75c145d74b7c4e65a168cf6bce5e78f11e27fcd63ed0c62afacf60208201529081018490525f906104469060600161022c565b90506104b38188888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001693929150506106ef565b6104ff5760405162461bcd60e51b815260206004820181905260248201527f496e76616c6964205a4b20466f756e646174696f6e207369676e61747572657360448201526064016102fc565b604051632291ed1b60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690634523da369061054b908890600401610e33565b5f604051808303815f87803b158015610562575f80fd5b505af1158015610574573d5f803e3d5ffd5b505050505050505050505050505050505050565b60606105b47f00000000000000000000000000000000000000000000000000000000000000005f610744565b905090565b60606105b47f00000000000000000000000000000000000000000000000000000000000000006001610744565b5f6106126105f26107ee565b8360405161190160f01b8152600281019290925260228201526042902090565b92915050565b5f805f856001600160a01b03168585604051602401610638929190610ee5565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b1790525161066d9190610f05565b5f60405180830381855afa9150503d805f81146106a5576040519150601f19603f3d011682016040523d82523d5f602084013e6106aa565b606091505b50915091508180156106be57506020815110155b80156106e557508051630b135d3f60e11b906106e39083016020908101908401610f20565b145b9695505050505050565b5f805f6106fc8585610917565b5090925090505f81600381111561071557610715610f37565b1480156107335750856001600160a01b0316826001600160a01b0316145b806106e557506106e5868686610618565b606060ff831461075e5761075783610960565b9050610612565b81805461076a90610f4b565b80601f016020809104026020016040519081016040528092919081815260200182805461079690610f4b565b80156107e15780601f106107b8576101008083540402835291602001916107e1565b820191905f5260205f20905b8154815290600101906020018083116107c457829003601f168201915b5050505050905092915050565b5f306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561084657507f000000000000000000000000000000000000000000000000000000000000000046145b1561087057507f000000000000000000000000000000000000000000000000000000000000000090565b6105b4604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b5f805f835160410361094e576020840151604085015160608601515f1a6109408882858561099d565b955095509550505050610959565b505081515f91506002905b9250925092565b60605f61096c83610a65565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156109d657505f91506003905082610a5b565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015610a27573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116610a5257505f925060019150829050610a5b565b92505f91508190505b9450945094915050565b5f60ff8216601f81111561061257604051632cd44ac360e21b815260040160405180910390fd5b5f5b83811015610aa6578181015183820152602001610a8e565b50505f910152565b5f8151808452610ac5816020860160208601610a8c565b601f01601f19169290920160200192915050565b60ff60f81b881681525f602060e06020840152610af960e084018a610aae565b8381036040850152610b0b818a610aae565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825260208088019350909101905f5b81811015610b5e57835183529284019291840191600101610b42565b50909c9b505050505050505050505050565b5f8083601f840112610b80575f80fd5b50813567ffffffffffffffff811115610b97575f80fd5b602083019150836020828501011115610bae575f80fd5b9250929050565b5f805f805f805f805f60a08a8c031215610bcd575f80fd5b893567ffffffffffffffff80821115610be4575f80fd5b818c0191508c601f830112610bf7575f80fd5b813581811115610c05575f80fd5b8d60208260051b8501011115610c19575f80fd5b60209283019b509950908b0135975060408b01359080821115610c3a575f80fd5b610c468d838e01610b70565b909850965060608c0135915080821115610c5e575f80fd5b610c6a8d838e01610b70565b909650945060808c0135915080821115610c82575f80fd5b50610c8f8c828d01610b70565b915080935050809150509295985092959850929598565b634e487b7160e01b5f52604160045260245ffd5b6040516060810167ffffffffffffffff81118282101715610cdd57610cdd610ca6565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610d0c57610d0c610ca6565b604052919050565b5f67ffffffffffffffff80841115610d2e57610d2e610ca6565b8360051b6020610d3f818301610ce3565b868152918501918181019036841115610d56575f80fd5b865b84811015610e2757803586811115610d6e575f80fd5b88016060368290031215610d80575f80fd5b610d88610cba565b81356001600160a01b0381168114610d9e575f80fd5b8152818601358682015260408083013589811115610dba575f80fd5b9290920191601f3681850112610dce575f80fd5b83358a811115610de057610de0610ca6565b610df1818301601f19168a01610ce3565b91508082523689828701011115610e06575f80fd5b808986018a8401375f90820189015290820152845250918301918301610d58565b50979650505050505050565b5f60208083526080830184516060808487015282825180855260a08801915060a08160051b890101945085840193505f5b81811015610eb757888603609f19018352845180516001600160a01b031687528781015188880152604090810151908701859052610ea485880182610aae565b9650509386019391860191600101610e64565b50505050918501516001600160a01b0381166040860152915060408501516060850152809250505092915050565b828152604060208201525f610efd6040830184610aae565b949350505050565b5f8251610f16818460208701610a8c565b9190910192915050565b5f60208284031215610f30575f80fd5b5051919050565b634e487b7160e01b5f52602160045260245ffd5b600181811c90821680610f5f57607f821691505b602082108103610f7d57634e487b7160e01b5f52602260045260245ffd5b5091905056fea26469706673582212200c166ea6dd3ab3d912901bebe655c8ad3e6d871845812c00a96142ecd66cf65d64736f6c63430008180033000000000000000000000000e30dca3047b37dc7d88849de4a4dc07937ad5ab300000000000000000000000066e4431266dc7e04e7d8b7fe9d2181253df7f410000000000000000000000000600da620ab29f41abc6596a15981e14ce58c86b8000000000000000000000000bc1653bd3829dfec575afc3816d4899cd103b51c","name":"EmergencyUpgradeBoard","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"cancun","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":true,"additional_sources":[{"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 ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"},{"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/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 ERC1967 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[EIP-2098 short signatures]\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n        unchecked {\n            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError, bytes32) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"},{"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"},{"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[EIP 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 EIP-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 EIP-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 EIP-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 (EIP-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/cryptography/SignatureChecker.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.20;\n\nimport {ECDSA} from \"./ECDSA.sol\";\nimport {IERC1271} from \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like\n * Argent and Safe Wallet (previously Gnosis Safe).\n */\nlibrary SignatureChecker {\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {\n        (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature);\n        return\n            (error == ECDSA.RecoverError.NoError && recovered == signer) ||\n            isValidERC1271SignatureNow(signer, hash, signature);\n    }\n\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n     * against the signer smart contract using ERC1271.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidERC1271SignatureNow(\n        address signer,\n        bytes32 hash,\n        bytes memory signature\n    ) internal view returns (bool) {\n        (bool success, bytes memory result) = signer.staticcall(\n            abi.encodeCall(IERC1271.isValidSignature, (hash, signature))\n        );\n        return (success &&\n            result.length >= 32 &&\n            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));\n    }\n}\n"},{"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\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Muldiv operation overflow.\n     */\n    error MathOverflowedMulDiv();\n\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 overflow flag.\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\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 overflow flag.\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\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 overflow flag.\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\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 division by zero flag.\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\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 division by zero flag.\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\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            return a / b;\n        }\n\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     * @dev 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^256 and mod 2^256 - 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^256 + 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^256. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                revert MathOverflowedMulDiv();\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^256 / 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^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\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^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, 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     * @notice 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        uint256 result = mulDiv(x, y, denominator);\n        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\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     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\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        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\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        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\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/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            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"},{"file_path":"src/interfaces/IProtocolUpgradeHandler.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ninterface IProtocolUpgradeHandler {\n    /// @dev This enumeration includes the following states:\n    /// @param None Default state, indicating the upgrade has not been set.\n    /// @param LegalVetoPeriod The upgrade passed L2 voting process but it is waiting for the legal veto period.\n    /// @param Waiting The upgrade passed Legal Veto period but it is waiting for the approval from guardians or Security Council.\n    /// @param ExecutionPending The upgrade proposal is waiting for the delay period before being ready for execution.\n    /// @param Ready The upgrade proposal is ready to be executed.\n    /// @param Expired The upgrade proposal was expired.\n    /// @param Done The upgrade has been successfully executed.\n    enum UpgradeState {\n        None,\n        LegalVetoPeriod,\n        Waiting,\n        ExecutionPending,\n        Ready,\n        Expired,\n        Done\n    }\n\n    /// @dev Represents the status of an upgrade process, including the creation timestamp and actions made by guardians and Security Council.\n    /// @param creationTimestamp The timestamp (in seconds) when the upgrade state was created.\n    /// @param securityCouncilApprovalTimestamp The timestamp (in seconds) when Security Council approved the upgrade.\n    /// @param guardiansApproval Indicates whether the upgrade has been approved by the guardians.\n    /// @param guardiansExtendedLegalVeto Indicates whether guardians extended the legal veto period.\n    /// @param executed Indicates whether the proposal is executed or not.\n    struct UpgradeStatus {\n        uint48 creationTimestamp;\n        uint48 securityCouncilApprovalTimestamp;\n        bool guardiansApproval;\n        bool guardiansExtendedLegalVeto;\n        bool executed;\n    }\n\n    /// @dev Represents a call to be made during an upgrade.\n    /// @param target The address to which the call will be made.\n    /// @param value The amount of Ether (in wei) to be sent along with the call.\n    /// @param data The calldata to be executed on the `target` address.\n    struct Call {\n        address target;\n        uint256 value;\n        bytes data;\n    }\n\n    /// @dev Defines the structure of an upgrade that is executed by Protocol Upgrade Handler.\n    /// @param executor The L1 address that is authorized to perform the upgrade execution (if address(0) then anyone).\n    /// @param calls An array of `Call` structs, each representing a call to be made during the upgrade execution.\n    /// @param salt A bytes32 value used for creating unique upgrade proposal hashes.\n    struct UpgradeProposal {\n        Call[] calls;\n        address executor;\n        bytes32 salt;\n    }\n\n    /// @dev This enumeration includes the following states:\n    /// @param None Default state, indicating the freeze has not been happening in this upgrade cycle.\n    /// @param Soft The protocol is/was frozen for the short time.\n    /// @param Hard The protocol is/was frozen for the long time.\n    /// @param AfterSoftFreeze The protocol was soft frozen, it can be hard frozen in this upgrade cycle.\n    /// @param AfterHardFreeze The protocol was hard frozen, but now it can't be frozen until the upgrade.\n    enum FreezeStatus {\n        None,\n        Soft,\n        Hard,\n        AfterSoftFreeze,\n        AfterHardFreeze\n    }\n\n    function startUpgrade(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _proof,\n        UpgradeProposal calldata _proposal\n    ) external;\n\n    function extendLegalVeto(bytes32 _id) external;\n\n    function approveUpgradeSecurityCouncil(bytes32 _id) external;\n\n    function approveUpgradeGuardians(bytes32 _id) external;\n\n    function execute(UpgradeProposal calldata _proposal) external payable;\n\n    function executeEmergencyUpgrade(UpgradeProposal calldata _proposal) external payable;\n\n    function softFreeze() external;\n\n    function hardFreeze() external;\n\n    function reinforceFreeze() external;\n\n    function unfreeze() external;\n\n    function reinforceFreezeOneChain(uint256 _chainId) external;\n\n    function reinforceUnfreeze() external;\n\n    function reinforceUnfreezeOneChain(uint256 _chainId) external;\n\n    function upgradeState(bytes32 _id) external view returns (UpgradeState);\n\n    function updateSecurityCouncil(address _newSecurityCouncil) external;\n\n    function updateGuardians(address _newGuardians) external;\n\n    function updateEmergencyUpgradeBoard(address _newEmergencyUpgradeBoard) external;\n\n    /// @notice Emitted when the security council address is changed.\n    event ChangeSecurityCouncil(address indexed _securityCouncilBefore, address indexed _securityCouncilAfter);\n\n    /// @notice Emitted when the guardians address is changed.\n    event ChangeGuardians(address indexed _guardiansBefore, address indexed _guardiansAfter);\n\n    /// @notice Emitted when the emergency upgrade board address is changed.\n    event ChangeEmergencyUpgradeBoard(\n        address indexed _emergencyUpgradeBoardBefore, address indexed _emergencyUpgradeBoardAfter\n    );\n\n    /// @notice Emitted when upgrade process on L1 is started.\n    event UpgradeStarted(bytes32 indexed _id, UpgradeProposal _proposal);\n\n    /// @notice Emitted when the legal veto period is extended.\n    event UpgradeLegalVetoExtended(bytes32 indexed _id);\n\n    /// @notice Emitted when Security Council approved the upgrade.\n    event UpgradeApprovedBySecurityCouncil(bytes32 indexed _id);\n\n    /// @notice Emitted when Guardians approved the upgrade.\n    event UpgradeApprovedByGuardians(bytes32 indexed _id);\n\n    /// @notice Emitted when the upgrade is executed.\n    event UpgradeExecuted(bytes32 indexed _id);\n\n    /// @notice Emitted when the emergency upgrade is executed.\n    event EmergencyUpgradeExecuted(bytes32 indexed _id);\n\n    /// @notice Emitted when the protocol became soft frozen.\n    event SoftFreeze(uint256 _protocolFrozenUntil);\n\n    /// @notice Emitted when the protocol became hard frozen.\n    event HardFreeze(uint256 _protocolFrozenUntil);\n\n    /// @notice Emitted when someone makes an attempt to freeze the protocol when it is frozen already.\n    event ReinforceFreeze();\n\n    /// @notice Emitted when the protocol became active after the soft/hard freeze.\n    event Unfreeze();\n\n    /// @notice Emitted when someone makes an attempt to freeze the specific chain when the protocol is frozen already.\n    event ReinforceFreezeOneChain(uint256 _chainId);\n\n    /// @notice Emitted when someone makes an attempt to unfreeze the protocol when it is unfrozen already.\n    event ReinforceUnfreeze();\n\n    /// @notice Emitted when someone makes an attempt to unfreeze the specific chain when the protocol is unfrozen already.\n    event ReinforceUnfreezeOneChain(uint256 _chainId);\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"contract IProtocolUpgradeHandler","name":"_protocolUpgradeHandler","type":"address"},{"internalType":"address","name":"_securityCouncil","type":"address"},{"internalType":"address","name":"_guardians","type":"address"},{"internalType":"address","name":"_zkFoundation","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"inputs":[],"name":"GUARDIANS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_UPGRADE_HANDLER","outputs":[{"internalType":"contract IProtocolUpgradeHandler","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SECURITY_COUNCIL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ZK_FOUNDATION_SAFE","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IProtocolUpgradeHandler.Call[]","name":"_calls","type":"tuple[]"},{"internalType":"bytes32","name":"_salt","type":"bytes32"},{"internalType":"bytes","name":"_guardiansSignatures","type":"bytes"},{"internalType":"bytes","name":"_securityCouncilSignatures","type":"bytes"},{"internalType":"bytes","name":"_zkFoundationSignatures","type":"bytes"}],"name":"executeEmergencyUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":"0x000000000000000000000000e30dca3047b37dc7d88849de4a4dc07937ad5ab300000000000000000000000066e4431266dc7e04e7d8b7fe9d2181253df7f410000000000000000000000000600da620ab29f41abc6596a15981e14ce58c86b8000000000000000000000000bc1653bd3829dfec575afc3816d4899cd103b51c"}