ETH Price: $2,026.45 (-1.32%)

Transaction Decoder

Block:
18596348 at Nov-18-2023 04:25:59 AM +UTC
Transaction Fee:
0.002039214910131 ETH $4.13
Gas Used:
105,150 Gas / 19.39338954 Gwei

Emitted Events:

196 Proxy.0x7a06c571aa77f34d9706c51e5d8122b5595aebeaa34233bfe866f22befb973b1( 0x7a06c571aa77f34d9706c51e5d8122b5595aebeaa34233bfe866f22befb973b1, 0x05cd48fccbfd8aa2773fe22c217e808319ffcc1c5a6a463f7d8fa2da48218196, 0x000000000000000000000000f6080d9fbeebcd44d89affbfd42f098cbff92816, 0000000000000000000000000000000000000000000000000000000000000020, 0000000000000000000000000000000000000000000000000000000000000004, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000009550a068df0d707dbfdb0aae636d3ab45bfdd2d2, 0000000000000000000000000000000000000000000000000000000004c4b400, 0000000000000000000000000000000000000000000000000000000000000000 )
197 FiatTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000f6080d9fbeebcd44d89affbfd42f098cbff92816, 0x0000000000000000000000009550a068df0d707dbfdb0aae636d3ab45bfdd2d2, 0000000000000000000000000000000000000000000000000000000004c4b400 )
198 Proxy.0xb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e91( 0xb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e91, 0x0000000000000000000000009550a068df0d707dbfdb0aae636d3ab45bfdd2d2, 0000000000000000000000000000000000000000000000000000000004c4b400 )

Account State Difference:

  Address   Before After State Difference Code
1.809313620145593563 Eth1.809324135145593563 Eth0.000010515
0x9550a068...45bfDD2D2
0.007014966651600427 Eth
Nonce: 5
0.004975751741469427 Eth
Nonce: 6
0.002039214910131
0xA0b86991...E3606eB48
0xc662c410...BeBD9C8c4
(Starknet: Core Contract)

Execution Trace

Proxy.00f714ce( )
  • StarknetERC20Bridge.withdraw( amount=80000000, recipient=0x9550a068dF0d707DbFdB0AAe636d3Ab45bfDD2D2 )
    • Proxy.2c9dd5c0( )
      • Starknet.consumeMessageFromL2( fromAddress=2624271632322125921217374734393920890821192138210577916078337694621182820758, payload=[0, 852437658120237404891094513026375357080501342930, 80000000, 0] ) => ( B6360F33F41C4B235811344A2F1AA412902D27910ACAD15B311D45BE210DAE4E )
      • FiatTokenProxy.70a08231( )
        • FiatTokenV2_1.balanceOf( account=0xF6080D9fbEEbcd44D89aFfBFd42F098cbFf92816 ) => ( 19458162379829 )
        • FiatTokenProxy.a9059cbb( )
          • FiatTokenV2_1.transfer( to=0x9550a068dF0d707DbFdB0AAe636d3Ab45bfDD2D2, value=80000000 ) => ( True )
          • FiatTokenProxy.70a08231( )
            • FiatTokenV2_1.balanceOf( account=0xF6080D9fbEEbcd44D89aFfBFd42F098cbFf92816 ) => ( 19458082379829 )
              File 1 of 6: Proxy
              {"Addresses.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\nimport \"Identity.sol\";\n\n/*\n  Common Utility librarries.\n  I. Addresses (extending address).\n*/\nlibrary Addresses {\n    /*\n      Note: isContract function has some known limitation.\n      See https://github.com/OpenZeppelin/\n      openzeppelin-contracts/blob/master/contracts/utils/Address.sol.\n    */\n    function isContract(address account) internal view returns (bool) {\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size \u003e 0;\n    }\n\n    function performEthTransfer(address recipient, uint256 amount) internal {\n        (bool success, ) = recipient.call{value: amount}(\"\"); // NOLINT: low-level-calls.\n        require(success, \"ETH_TRANSFER_FAILED\");\n    }\n\n    /*\n      Safe wrapper around ERC20/ERC721 calls.\n      This is required because many deployed ERC20 contracts don\u0027t return a value.\n      See https://github.com/ethereum/solidity/issues/4116.\n    */\n    function safeTokenContractCall(address tokenAddress, bytes memory callData) internal {\n        require(isContract(tokenAddress), \"BAD_TOKEN_ADDRESS\");\n        // NOLINTNEXTLINE: low-level-calls.\n        (bool success, bytes memory returndata) = tokenAddress.call(callData);\n        require(success, string(returndata));\n\n        if (returndata.length \u003e 0) {\n            require(abi.decode(returndata, (bool)), \"TOKEN_OPERATION_FAILED\");\n        }\n    }\n\n    /*\n      Validates that the passed contract address is of a real contract,\n      and that its id hash (as infered fromn identify()) matched the expected one.\n    */\n    function validateContractId(address contractAddress, bytes32 expectedIdHash) internal view {\n        require(isContract(contractAddress), \"ADDRESS_NOT_CONTRACT\");\n        string memory actualContractId = Identity(contractAddress).identify();\n        require(\n            keccak256(abi.encodePacked(actualContractId)) == expectedIdHash,\n            \"UNEXPECTED_CONTRACT_IDENTIFIER\"\n        );\n    }\n}\n"},"Governance.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"MGovernance.sol\";\n\n/*\n  Implements Generic Governance, applicable for both proxy and main contract, and possibly others.\n  Notes:\n   The use of the same function names by both the Proxy and a delegated implementation\n   is not possible since calling the implementation functions is done via the default function\n   of the Proxy. For this reason, for example, the implementation of MainContract (MainGovernance)\n   exposes mainIsGovernor, which calls the internal _isGovernor method.\n*/\nstruct GovernanceInfoStruct {\n    mapping(address =\u003e bool) effectiveGovernors;\n    address candidateGovernor;\n    bool initialized;\n}\n\nabstract contract Governance is MGovernance {\n    event LogNominatedGovernor(address nominatedGovernor);\n    event LogNewGovernorAccepted(address acceptedGovernor);\n    event LogRemovedGovernor(address removedGovernor);\n    event LogNominationCancelled();\n\n    function getGovernanceInfo() internal view virtual returns (GovernanceInfoStruct storage);\n\n    /*\n      Current code intentionally prevents governance re-initialization.\n      This may be a problem in an upgrade situation, in a case that the upgrade-to implementation\n      performs an initialization (for real) and within that calls initGovernance().\n\n      Possible workarounds:\n      1. Clearing the governance info altogether by changing the MAIN_GOVERNANCE_INFO_TAG.\n         This will remove existing main governance information.\n      2. Modify the require part in this function, so that it will exit quietly\n         when trying to re-initialize (uncomment the lines below).\n    */\n    function initGovernance() internal {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(!gub.initialized, \"ALREADY_INITIALIZED\");\n        gub.initialized = true; // to ensure addGovernor() won\u0027t fail.\n        // Add the initial governer.\n        addGovernor(msg.sender);\n\n        // Emit governance information.\n        emit LogNominatedGovernor(msg.sender);\n        emit LogNewGovernorAccepted(msg.sender);\n    }\n\n    function _isGovernor(address user) internal view override returns (bool) {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        return gub.effectiveGovernors[user];\n    }\n\n    /*\n      Cancels the nomination of a governor candidate.\n    */\n    function _cancelNomination() internal onlyGovernance {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        if (gub.candidateGovernor != address(0x0)) {\n            gub.candidateGovernor = address(0x0);\n            emit LogNominationCancelled();\n        }\n    }\n\n    function _nominateNewGovernor(address newGovernor) internal onlyGovernance {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(newGovernor != address(0x0), \"BAD_ADDRESS\");\n        require(!_isGovernor(newGovernor), \"ALREADY_GOVERNOR\");\n        require(gub.candidateGovernor == address(0x0), \"OTHER_CANDIDATE_PENDING\");\n        gub.candidateGovernor = newGovernor;\n        emit LogNominatedGovernor(newGovernor);\n    }\n\n    /*\n      The addGovernor is called in two cases:\n      1. by _acceptGovernance when a new governor accepts its role.\n      2. by initGovernance to add the initial governor.\n      The difference is that the init path skips the nominate step\n      that would fail because of the onlyGovernance modifier.\n    */\n    function addGovernor(address newGovernor) private {\n        require(!_isGovernor(newGovernor), \"ALREADY_GOVERNOR\");\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        gub.effectiveGovernors[newGovernor] = true;\n    }\n\n    function _acceptGovernance() internal {\n        // The new governor was proposed as a candidate by the current governor.\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(msg.sender == gub.candidateGovernor, \"ONLY_CANDIDATE_GOVERNOR\");\n\n        // Update state.\n        addGovernor(gub.candidateGovernor);\n        gub.candidateGovernor = address(0x0);\n\n        // Send a notification about the change of governor.\n        emit LogNewGovernorAccepted(msg.sender);\n    }\n\n    /*\n      Remove a governor from office.\n    */\n    function _removeGovernor(address governorForRemoval) internal onlyGovernance {\n        require(msg.sender != governorForRemoval, \"GOVERNOR_SELF_REMOVE\");\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(_isGovernor(governorForRemoval), \"NOT_GOVERNOR\");\n        gub.effectiveGovernors[governorForRemoval] = false;\n        emit LogRemovedGovernor(governorForRemoval);\n    }\n}\n"},"GovernanceStorage.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\nimport {GovernanceInfoStruct} from \"./Governance.sol\";\n\n/*\n  Holds the governance slots for ALL entities, including proxy and the main contract.\n*/\ncontract GovernanceStorage {\n    // A map from a Governor tag to its own GovernanceInfoStruct.\n    mapping(string =\u003e GovernanceInfoStruct) internal governanceInfo; //NOLINT uninitialized-state.\n}\n"},"Identity.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\ninterface Identity {\n    /*\n      Allows a caller to ensure that the provided address is of the expected type and version.\n    */\n    function identify() external pure returns (string memory);\n}\n"},"MGovernance.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nabstract contract MGovernance {\n    function _isGovernor(address user) internal view virtual returns (bool);\n\n    /*\n      Allows calling the function only by a Governor.\n    */\n    modifier onlyGovernance() {\n        require(_isGovernor(msg.sender), \"ONLY_GOVERNANCE\");\n        _;\n    }\n}\n"},"Proxy.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"ProxyGovernance.sol\";\nimport \"ProxyStorage.sol\";\nimport \"StorageSlots.sol\";\nimport \"Addresses.sol\";\n\n/**\n  The Proxy contract implements delegation of calls to other contracts (`implementations`), with\n  proper forwarding of return values and revert reasons. This pattern allows retaining the contract\n  storage while replacing implementation code.\n\n  The following operations are supported by the proxy contract:\n\n  - :sol:func:`addImplementation`: Defines a new implementation, the data with which it should be initialized and whether this will be the last version of implementation.\n  - :sol:func:`upgradeTo`: Once an implementation is added, the governor may upgrade to that implementation only after a safety time period has passed (time lock), the current implementation is not the last version and the implementation is not frozen (see :sol:mod:`FullWithdrawals`).\n  - :sol:func:`removeImplementation`: Any announced implementation may be removed. Removing an implementation is especially important once it has been used for an upgrade in order to avoid an additional unwanted revert to an older version.\n\n  The only entity allowed to perform the above operations is the proxy governor\n  (see :sol:mod:`ProxyGovernance`).\n\n  Every implementation is required to have an `initialize` function that replaces the constructor\n  of a normal contract. Furthermore, the only parameter of this function is an array of bytes\n  (`data`) which may be decoded arbitrarily by the `initialize` function. It is up to the\n  implementation to ensure that this function cannot be run more than once if so desired.\n\n  When an implementation is added (:sol:func:`addImplementation`) the initialization `data` is also\n  announced, allowing users of the contract to analyze the full effect of an upgrade to the new\n  implementation. During an :sol:func:`upgradeTo`, the `data` is provided again and only if it is\n  identical to the announced `data` is the upgrade performed by pointing the proxy to the new\n  implementation and calling its `initialize` function with this `data`.\n\n  It is the responsibility of the implementation not to overwrite any storage belonging to the\n  proxy (`ProxyStorage`). In addition, upon upgrade, the new implementation is assumed to be\n  backward compatible with previous implementations with respect to the storage used until that\n  point.\n*/\ncontract Proxy is ProxyStorage, ProxyGovernance, StorageSlots {\n    // Emitted when the active implementation is replaced.\n    event ImplementationUpgraded(address indexed implementation, bytes initializer);\n\n    // Emitted when an implementation is submitted as an upgrade candidate and a time lock\n    // is activated.\n    event ImplementationAdded(address indexed implementation, bytes initializer, bool finalize);\n\n    // Emitted when an implementation is removed from the list of upgrade candidates.\n    event ImplementationRemoved(address indexed implementation, bytes initializer, bool finalize);\n\n    // Emitted when the implementation is finalized.\n    event FinalizedImplementation(address indexed implementation);\n\n    using Addresses for address;\n\n    string public constant PROXY_VERSION = \"3.0.1\";\n\n    constructor(uint256 upgradeActivationDelay) public {\n        initGovernance();\n        setUpgradeActivationDelay(upgradeActivationDelay);\n    }\n\n    function setUpgradeActivationDelay(uint256 delayInSeconds) private {\n        bytes32 slot = UPGRADE_DELAY_SLOT;\n        assembly {\n            sstore(slot, delayInSeconds)\n        }\n    }\n\n    function getUpgradeActivationDelay() public view returns (uint256 delay) {\n        bytes32 slot = UPGRADE_DELAY_SLOT;\n        assembly {\n            delay := sload(slot)\n        }\n        return delay;\n    }\n\n    /*\n      Returns the address of the current implementation.\n    */\n    // NOLINTNEXTLINE external-function.\n    function implementation() public view returns (address _implementation) {\n        bytes32 slot = IMPLEMENTATION_SLOT;\n        assembly {\n            _implementation := sload(slot)\n        }\n    }\n\n    /*\n      Returns true if the implementation is frozen.\n      If the implementation was not assigned yet, returns false.\n    */\n    function implementationIsFrozen() private returns (bool) {\n        address _implementation = implementation();\n\n        // We can\u0027t call low level implementation before it\u0027s assigned. (i.e. ZERO).\n        if (_implementation == address(0x0)) {\n            return false;\n        }\n\n        // NOLINTNEXTLINE: low-level-calls.\n        (bool success, bytes memory returndata) = _implementation.delegatecall(\n            abi.encodeWithSignature(\"isFrozen()\")\n        );\n        require(success, string(returndata));\n        return abi.decode(returndata, (bool));\n    }\n\n    /*\n      This method blocks delegation to initialize().\n      Only upgradeTo should be able to delegate call to initialize().\n    */\n    function initialize(\n        bytes calldata /*data*/\n    ) external pure {\n        revert(\"CANNOT_CALL_INITIALIZE\");\n    }\n\n    modifier notFinalized() {\n        require(isNotFinalized(), \"IMPLEMENTATION_FINALIZED\");\n        _;\n    }\n\n    /*\n      Forbids calling the function if the implementation is frozen.\n      This modifier relies on the lower level (logical contract) implementation of isFrozen().\n    */\n    modifier notFrozen() {\n        require(!implementationIsFrozen(), \"STATE_IS_FROZEN\");\n        _;\n    }\n\n    /*\n      This entry point serves only transactions with empty calldata. (i.e. pure value transfer tx).\n      We don\u0027t expect to receive such, thus block them.\n    */\n    receive() external payable {\n        revert(\"CONTRACT_NOT_EXPECTED_TO_RECEIVE\");\n    }\n\n    /*\n      Contract\u0027s default function. Delegates execution to the implementation contract.\n      It returns back to the external caller whatever the implementation delegated code returns.\n    */\n    fallback() external payable {\n        address _implementation = implementation();\n        require(_implementation != address(0x0), \"MISSING_IMPLEMENTATION\");\n\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 for now, as we don\u0027t know the out size yet.\n            let result := delegatecall(gas(), _implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /*\n      Sets the implementation address of the proxy.\n    */\n    function setImplementation(address newImplementation) private {\n        bytes32 slot = IMPLEMENTATION_SLOT;\n        assembly {\n            sstore(slot, newImplementation)\n        }\n    }\n\n    /*\n      Returns true if the contract is not in the finalized state.\n    */\n    function isNotFinalized() public view returns (bool notFinal) {\n        bytes32 slot = FINALIZED_STATE_SLOT;\n        uint256 slotValue;\n        assembly {\n            slotValue := sload(slot)\n        }\n        notFinal = (slotValue == 0);\n    }\n\n    /*\n      Marks the current implementation as finalized.\n    */\n    function setFinalizedFlag() private {\n        bytes32 slot = FINALIZED_STATE_SLOT;\n        assembly {\n            sstore(slot, 0x1)\n        }\n    }\n\n    /*\n      Introduce an implementation and its initialization vector,\n      and start the time-lock before it can be upgraded to.\n      addImplementation is not blocked when frozen or finalized.\n      (upgradeTo API is blocked when finalized or frozen).\n    */\n    function addImplementation(\n        address newImplementation,\n        bytes calldata data,\n        bool finalize\n    ) external onlyGovernance {\n        require(newImplementation.isContract(), \"ADDRESS_NOT_CONTRACT\");\n\n        bytes32 implVectorHash = keccak256(abi.encode(newImplementation, data, finalize));\n\n        uint256 activationTime = block.timestamp + getUpgradeActivationDelay();\n\n        enabledTime[implVectorHash] = activationTime;\n        emit ImplementationAdded(newImplementation, data, finalize);\n    }\n\n    /*\n      Removes a candidate implementation.\n      Note that it is possible to remove the current implementation. Doing so doesn\u0027t affect the\n      current implementation, but rather revokes it as a future candidate.\n    */\n    function removeImplementation(\n        address removedImplementation,\n        bytes calldata data,\n        bool finalize\n    ) external onlyGovernance {\n        bytes32 implVectorHash = keccak256(abi.encode(removedImplementation, data, finalize));\n\n        // If we have initializer, we set the hash of it.\n        uint256 activationTime = enabledTime[implVectorHash];\n        require(activationTime \u003e 0, \"UNKNOWN_UPGRADE_INFORMATION\");\n        delete enabledTime[implVectorHash];\n        emit ImplementationRemoved(removedImplementation, data, finalize);\n    }\n\n    /*\n      Upgrades the proxy to a new implementation, with its initialization.\n      to upgrade successfully, implementation must have been added time-lock agreeably\n      before, and the init vector must be identical ot the one submitted before.\n\n      Upon assignment of new implementation address,\n      its initialize will be called with the initializing vector (even if empty).\n      Therefore, the implementation MUST must have such a method.\n\n      Note - Initialization data is committed to in advance, therefore it must remain valid\n      until the actual contract upgrade takes place.\n\n      Care should be taken regarding initialization data and flow when planning the contract upgrade.\n\n      When planning contract upgrade, special care is also needed with regard to governance\n      (See comments in Governance.sol).\n    */\n    // NOLINTNEXTLINE: reentrancy-events timestamp.\n    function upgradeTo(\n        address newImplementation,\n        bytes calldata data,\n        bool finalize\n    ) external payable onlyGovernance notFinalized notFrozen {\n        bytes32 implVectorHash = keccak256(abi.encode(newImplementation, data, finalize));\n        uint256 activationTime = enabledTime[implVectorHash];\n        require(activationTime \u003e 0, \"UNKNOWN_UPGRADE_INFORMATION\");\n        require(newImplementation.isContract(), \"ADDRESS_NOT_CONTRACT\");\n\n        // On the first time an implementation is set - time-lock should not be enforced.\n        require(\n            activationTime \u003c= block.timestamp || implementation() == address(0x0),\n            \"UPGRADE_NOT_ENABLED_YET\"\n        );\n\n        setImplementation(newImplementation);\n\n        // NOLINTNEXTLINE: low-level-calls controlled-delegatecall.\n        (bool success, bytes memory returndata) = newImplementation.delegatecall(\n            abi.encodeWithSelector(this.initialize.selector, data)\n        );\n        require(success, string(returndata));\n\n        // Verify that the new implementation is not frozen post initialization.\n        // NOLINTNEXTLINE: low-level-calls controlled-delegatecall.\n        (success, returndata) = newImplementation.delegatecall(\n            abi.encodeWithSignature(\"isFrozen()\")\n        );\n        require(success, \"CALL_TO_ISFROZEN_REVERTED\");\n        require(!abi.decode(returndata, (bool)), \"NEW_IMPLEMENTATION_FROZEN\");\n\n        if (finalize) {\n            setFinalizedFlag();\n            emit FinalizedImplementation(newImplementation);\n        }\n\n        emit ImplementationUpgraded(newImplementation, data);\n    }\n}\n"},"ProxyGovernance.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"Governance.sol\";\nimport \"GovernanceStorage.sol\";\n\n/**\n  The Proxy contract is governed by one or more Governors of which the initial one is the\n  deployer of the contract.\n\n  A governor has the sole authority to perform the following operations:\n\n  1. Nominate additional governors (:sol:func:`proxyNominateNewGovernor`)\n  2. Remove other governors (:sol:func:`proxyRemoveGovernor`)\n  3. Add new `implementations` (proxied contracts)\n  4. Remove (new or old) `implementations`\n  5. Update `implementations` after a timelock allows it\n\n  Adding governors is performed in a two step procedure:\n\n  1. First, an existing governor nominates a new governor (:sol:func:`proxyNominateNewGovernor`)\n  2. Then, the new governor must accept governance to become a governor (:sol:func:`proxyAcceptGovernance`)\n\n  This two step procedure ensures that a governor public key cannot be nominated unless there is an\n  entity that has the corresponding private key. This is intended to prevent errors in the addition\n  process.\n\n  The governor private key should typically be held in a secure cold wallet or managed via a\n  multi-sig contract.\n*/\n/*\n  Implements Governance for the proxy contract.\n  It is a thin wrapper to the Governance contract,\n  which is needed so that it can have non-colliding function names,\n  and a specific tag (key) to allow unique state storage.\n*/\ncontract ProxyGovernance is GovernanceStorage, Governance {\n    // The tag is the string key that is used in the Governance storage mapping.\n    string public constant PROXY_GOVERNANCE_TAG = \"StarkEx.Proxy.2019.GovernorsInformation\";\n\n    /*\n      Returns the GovernanceInfoStruct associated with the governance tag.\n    */\n    function getGovernanceInfo() internal view override returns (GovernanceInfoStruct storage) {\n        return governanceInfo[PROXY_GOVERNANCE_TAG];\n    }\n\n    function proxyIsGovernor(address user) external view returns (bool) {\n        return _isGovernor(user);\n    }\n\n    function proxyNominateNewGovernor(address newGovernor) external {\n        _nominateNewGovernor(newGovernor);\n    }\n\n    function proxyRemoveGovernor(address governorForRemoval) external {\n        _removeGovernor(governorForRemoval);\n    }\n\n    function proxyAcceptGovernance() external {\n        _acceptGovernance();\n    }\n\n    function proxyCancelNomination() external {\n        _cancelNomination();\n    }\n}\n"},"ProxyStorage.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"GovernanceStorage.sol\";\n\n/*\n  Holds the Proxy-specific state variables.\n  This contract is inherited by the GovernanceStorage (and indirectly by MainStorage)\n  to prevent collision hazard.\n*/\ncontract ProxyStorage is GovernanceStorage {\n    // NOLINTNEXTLINE: naming-convention uninitialized-state.\n    mapping(address =\u003e bytes32) internal initializationHash_DEPRECATED;\n\n    // The time after which we can switch to the implementation.\n    // Hash(implementation, data, finalize) =\u003e time.\n    mapping(bytes32 =\u003e uint256) internal enabledTime;\n\n    // A central storage of the flags whether implementation has been initialized.\n    // Note - it can be used flexibly enough to accommodate multiple levels of initialization\n    // (i.e. using different key salting schemes for different initialization levels).\n    mapping(bytes32 =\u003e bool) internal initialized;\n}\n"},"StorageSlots.sol":{"content":"/*\n  Copyright 2019-2022 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\n/**\n  StorageSlots holds the arbitrary storage slots used throughout the Proxy pattern.\n  Storage address slots are a mechanism to define an arbitrary location, that will not be\n  overlapped by the logical contracts.\n*/\ncontract StorageSlots {\n    // Storage slot with the address of the current implementation.\n    // The address of the slot is keccak256(\"StarkWare2019.implemntation-slot\").\n    // We need to keep this variable stored outside of the commonly used space,\n    // so that it\u0027s not overrun by the logical implementation (the proxied contract).\n    bytes32 internal constant IMPLEMENTATION_SLOT =\n        0x177667240aeeea7e35eabe3a35e18306f336219e1386f7710a6bf8783f761b24;\n\n    // Storage slot with the address of the call-proxy current implementation.\n    // The address of the slot is keccak256(\"\u0027StarkWare2020.CallProxy.Implemntation.Slot\u0027\").\n    // We need to keep this variable stored outside of the commonly used space.\n    // so that it\u0027s not overrun by the logical implementation (the proxied contract).\n    bytes32 internal constant CALL_PROXY_IMPL_SLOT =\n        0x7184681641399eb4ad2fdb92114857ee6ff239f94ad635a1779978947b8843be;\n\n    // This storage slot stores the finalization flag.\n    // Once the value stored in this slot is set to non-zero\n    // the proxy blocks implementation upgrades.\n    // The current implementation is then referred to as Finalized.\n    // Web3.solidityKeccak([\u0027string\u0027], [\"StarkWare2019.finalization-flag-slot\"]).\n    bytes32 internal constant FINALIZED_STATE_SLOT =\n        0x7d433c6f837e8f93009937c466c82efbb5ba621fae36886d0cac433c5d0aa7d2;\n\n    // Storage slot to hold the upgrade delay (time-lock).\n    // The intention of this slot is to allow modification using an EIC.\n    // Web3.solidityKeccak([\u0027string\u0027], [\u0027StarkWare.Upgradibility.Delay.Slot\u0027]).\n    bytes32 public constant UPGRADE_DELAY_SLOT =\n        0xc21dbb3089fcb2c4f4c6a67854ab4db2b0f233ea4b21b21f912d52d18fc5db1f;\n}\n"}}

              File 2 of 6: Proxy
              {"Common.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\n/*\n  Common Utility librarries.\n  I. Addresses (extending address).\n*/\nlibrary Addresses {\n    function isContract(address account) internal view returns (bool) {\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size \u003e 0;\n    }\n\n    function performEthTransfer(address recipient, uint256 amount) internal {\n        (bool success, ) = recipient.call{value: amount}(\"\"); // NOLINT: low-level-calls.\n        require(success, \"ETH_TRANSFER_FAILED\");\n    }\n\n    /*\n      Safe wrapper around ERC20/ERC721 calls.\n      This is required because many deployed ERC20 contracts don\u0027t return a value.\n      See https://github.com/ethereum/solidity/issues/4116.\n    */\n    function safeTokenContractCall(address tokenAddress, bytes memory callData) internal {\n        require(isContract(tokenAddress), \"BAD_TOKEN_ADDRESS\");\n        // NOLINTNEXTLINE: low-level-calls.\n        (bool success, bytes memory returndata) = tokenAddress.call(callData);\n        require(success, string(returndata));\n\n        if (returndata.length \u003e 0) {\n            require(abi.decode(returndata, (bool)), \"TOKEN_OPERATION_FAILED\");\n        }\n    }\n\n    /*\n      Validates that the passed contract address is of a real contract,\n      and that its id hash (as infered fromn identify()) matched the expected one.\n    */\n    function validateContractId(address contractAddress, bytes32 expectedIdHash) internal {\n        require(isContract(contractAddress), \"ADDRESS_NOT_CONTRACT\");\n        (bool success, bytes memory returndata) = contractAddress.call( // NOLINT: low-level-calls.\n            abi.encodeWithSignature(\"identify()\")\n        );\n        require(success, \"FAILED_TO_IDENTIFY_CONTRACT\");\n        string memory realContractId = abi.decode(returndata, (string));\n        require(\n            keccak256(abi.encodePacked(realContractId)) == expectedIdHash,\n            \"UNEXPECTED_CONTRACT_IDENTIFIER\"\n        );\n    }\n}\n\n/*\n  II. StarkExTypes - Common data types.\n*/\nlibrary StarkExTypes {\n    // Structure representing a list of verifiers (validity/availability).\n    // A statement is valid only if all the verifiers in the list agree on it.\n    // Adding a verifier to the list is immediate - this is used for fast resolution of\n    // any soundness issues.\n    // Removing from the list is time-locked, to ensure that any user of the system\n    // not content with the announced removal has ample time to leave the system before it is\n    // removed.\n    struct ApprovalChainData {\n        address[] list;\n        // Represents the time after which the verifier with the given address can be removed.\n        // Removal of the verifier with address A is allowed only in the case the value\n        // of unlockedForRemovalTime[A] != 0 and unlockedForRemovalTime[A] \u003c (current time).\n        mapping(address =\u003e uint256) unlockedForRemovalTime;\n    }\n}\n"},"Governance.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"MGovernance.sol\";\n\n/*\n  Implements Generic Governance, applicable for both proxy and main contract, and possibly others.\n  Notes:\n   The use of the same function names by both the Proxy and a delegated implementation\n   is not possible since calling the implementation functions is done via the default function\n   of the Proxy. For this reason, for example, the implementation of MainContract (MainGovernance)\n   exposes mainIsGovernor, which calls the internal isGovernor method.\n*/\nabstract contract Governance is MGovernance {\n    event LogNominatedGovernor(address nominatedGovernor);\n    event LogNewGovernorAccepted(address acceptedGovernor);\n    event LogRemovedGovernor(address removedGovernor);\n    event LogNominationCancelled();\n\n    function getGovernanceInfo() internal view virtual returns (GovernanceInfoStruct storage);\n\n    /*\n      Current code intentionally prevents governance re-initialization.\n      This may be a problem in an upgrade situation, in a case that the upgrade-to implementation\n      performs an initialization (for real) and within that calls initGovernance().\n\n      Possible workarounds:\n      1. Clearing the governance info altogether by changing the MAIN_GOVERNANCE_INFO_TAG.\n         This will remove existing main governance information.\n      2. Modify the require part in this function, so that it will exit quietly\n         when trying to re-initialize (uncomment the lines below).\n    */\n    function initGovernance() internal {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(!gub.initialized, \"ALREADY_INITIALIZED\");\n        gub.initialized = true; // to ensure addGovernor() won\u0027t fail.\n        // Add the initial governer.\n        addGovernor(msg.sender);\n    }\n\n    function isGovernor(address testGovernor) internal view override returns (bool) {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        return gub.effectiveGovernors[testGovernor];\n    }\n\n    /*\n      Cancels the nomination of a governor candidate.\n    */\n    function cancelNomination() internal onlyGovernance {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        gub.candidateGovernor = address(0x0);\n        emit LogNominationCancelled();\n    }\n\n    function nominateNewGovernor(address newGovernor) internal onlyGovernance {\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(!isGovernor(newGovernor), \"ALREADY_GOVERNOR\");\n        gub.candidateGovernor = newGovernor;\n        emit LogNominatedGovernor(newGovernor);\n    }\n\n    /*\n      The addGovernor is called in two cases:\n      1. by acceptGovernance when a new governor accepts its role.\n      2. by initGovernance to add the initial governor.\n      The difference is that the init path skips the nominate step\n      that would fail because of the onlyGovernance modifier.\n    */\n    function addGovernor(address newGovernor) private {\n        require(!isGovernor(newGovernor), \"ALREADY_GOVERNOR\");\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        gub.effectiveGovernors[newGovernor] = true;\n    }\n\n    function acceptGovernance() internal {\n        // The new governor was proposed as a candidate by the current governor.\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(msg.sender == gub.candidateGovernor, \"ONLY_CANDIDATE_GOVERNOR\");\n\n        // Update state.\n        addGovernor(gub.candidateGovernor);\n        gub.candidateGovernor = address(0x0);\n\n        // Send a notification about the change of governor.\n        emit LogNewGovernorAccepted(msg.sender);\n    }\n\n    /*\n      Remove a governor from office.\n    */\n    function removeGovernor(address governorForRemoval) internal onlyGovernance {\n        require(msg.sender != governorForRemoval, \"GOVERNOR_SELF_REMOVE\");\n        GovernanceInfoStruct storage gub = getGovernanceInfo();\n        require(isGovernor(governorForRemoval), \"NOT_GOVERNOR\");\n        gub.effectiveGovernors[governorForRemoval] = false;\n        emit LogRemovedGovernor(governorForRemoval);\n    }\n}\n"},"GovernanceStorage.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\nimport \"MGovernance.sol\";\n\n/*\n  Holds the governance slots for ALL entities, including proxy and the main contract.\n*/\ncontract GovernanceStorage {\n    // A map from a Governor tag to its own GovernanceInfoStruct.\n    mapping(string =\u003e GovernanceInfoStruct) internal governanceInfo; //NOLINT uninitialized-state.\n}\n"},"MGovernance.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nstruct GovernanceInfoStruct {\n    mapping(address =\u003e bool) effectiveGovernors;\n    address candidateGovernor;\n    bool initialized;\n}\n\nabstract contract MGovernance {\n    function isGovernor(address testGovernor) internal view virtual returns (bool);\n\n    /*\n      Allows calling the function only by a Governor.\n    */\n    modifier onlyGovernance() {\n        require(isGovernor(msg.sender), \"ONLY_GOVERNANCE\");\n        _;\n    }\n}\n"},"Proxy.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"ProxyGovernance.sol\";\nimport \"ProxyStorage.sol\";\nimport \"StorageSlots.sol\";\nimport \"Common.sol\";\n\n/**\n  The Proxy contract implements delegation of calls to other contracts (`implementations`), with\n  proper forwarding of return values and revert reasons. This pattern allows retaining the contract\n  storage while replacing implementation code.\n\n  The following operations are supported by the proxy contract:\n\n  - :sol:func:`addImplementation`: Defines a new implementation, the data with which it should be initialized and whether this will be the last version of implementation.\n  - :sol:func:`upgradeTo`: Once an implementation is added, the governor may upgrade to that implementation only after a safety time period has passed (time lock), the current implementation is not the last version and the implementation is not frozen (see :sol:mod:`FullWithdrawals`).\n  - :sol:func:`removeImplementation`: Any announced implementation may be removed. Removing an implementation is especially important once it has been used for an upgrade in order to avoid an additional unwanted revert to an older version.\n\n  The only entity allowed to perform the above operations is the proxy governor\n  (see :sol:mod:`ProxyGovernance`).\n\n  Every implementation is required to have an `initialize` function that replaces the constructor\n  of a normal contract. Furthermore, the only parameter of this function is an array of bytes\n  (`data`) which may be decoded arbitrarily by the `initialize` function. It is up to the\n  implementation to ensure that this function cannot be run more than once if so desired.\n\n  When an implementation is added (:sol:func:`addImplementation`) the initialization `data` is also\n  announced, allowing users of the contract to analyze the full effect of an upgrade to the new\n  implementation. During an :sol:func:`upgradeTo`, the `data` is provided again and only if it is\n  identical to the announced `data` is the upgrade performed by pointing the proxy to the new\n  implementation and calling its `initialize` function with this `data`.\n\n  It is the responsibility of the implementation not to overwrite any storage belonging to the\n  proxy (`ProxyStorage`). In addition, upon upgrade, the new implementation is assumed to be\n  backward compatible with previous implementations with respect to the storage used until that\n  point.\n*/\ncontract Proxy is ProxyStorage, ProxyGovernance, StorageSlots {\n    // Emitted when the active implementation is replaced.\n    event ImplementationUpgraded(address indexed implementation, bytes initializer);\n\n    // Emitted when an implementation is submitted as an upgrade candidate and a time lock\n    // is activated.\n    event ImplementationAdded(address indexed implementation, bytes initializer, bool finalize);\n\n    // Emitted when an implementation is removed from the list of upgrade candidates.\n    event ImplementationRemoved(address indexed implementation, bytes initializer, bool finalize);\n\n    // Emitted when the implementation is finalized.\n    event FinalizedImplementation(address indexed implementation);\n\n    using Addresses for address;\n\n    string public constant PROXY_VERSION = \"3.0.0\";\n\n    constructor(uint256 upgradeActivationDelay) public {\n        initGovernance();\n        setUpgradeActivationDelay(upgradeActivationDelay);\n    }\n\n    function setUpgradeActivationDelay(uint256 delayInSeconds) private {\n        bytes32 slot = UPGRADE_DELAY_SLOT;\n        assembly {\n            sstore(slot, delayInSeconds)\n        }\n    }\n\n    function getUpgradeActivationDelay() public view returns (uint256 delay) {\n        bytes32 slot = UPGRADE_DELAY_SLOT;\n        assembly {\n            delay := sload(slot)\n        }\n        return delay;\n    }\n\n    /*\n      Returns the address of the current implementation.\n    */\n    // NOLINTNEXTLINE external-function.\n    function implementation() public view returns (address _implementation) {\n        bytes32 slot = IMPLEMENTATION_SLOT;\n        assembly {\n            _implementation := sload(slot)\n        }\n    }\n\n    /*\n      Returns true if the implementation is frozen.\n      If the implementation was not assigned yet, returns false.\n    */\n    function implementationIsFrozen() private returns (bool) {\n        address _implementation = implementation();\n\n        // We can\u0027t call low level implementation before it\u0027s assigned. (i.e. ZERO).\n        if (_implementation == address(0x0)) {\n            return false;\n        }\n\n        // NOLINTNEXTLINE: low-level-calls.\n        (bool success, bytes memory returndata) = _implementation.delegatecall(\n            abi.encodeWithSignature(\"isFrozen()\")\n        );\n        require(success, string(returndata));\n        return abi.decode(returndata, (bool));\n    }\n\n    /*\n      This method blocks delegation to initialize().\n      Only upgradeTo should be able to delegate call to initialize().\n    */\n    function initialize(\n        bytes calldata /*data*/\n    ) external pure {\n        revert(\"CANNOT_CALL_INITIALIZE\");\n    }\n\n    modifier notFinalized() {\n        require(isNotFinalized(), \"IMPLEMENTATION_FINALIZED\");\n        _;\n    }\n\n    /*\n      Forbids calling the function if the implementation is frozen.\n      This modifier relies on the lower level (logical contract) implementation of isFrozen().\n    */\n    modifier notFrozen() {\n        require(!implementationIsFrozen(), \"STATE_IS_FROZEN\");\n        _;\n    }\n\n    /*\n      This entry point serves only transactions with empty calldata. (i.e. pure value transfer tx).\n      We don\u0027t expect to receive such, thus block them.\n    */\n    receive() external payable {\n        revert(\"CONTRACT_NOT_EXPECTED_TO_RECEIVE\");\n    }\n\n    /*\n      Contract\u0027s default function. Delegates execution to the implementation contract.\n      It returns back to the external caller whatever the implementation delegated code returns.\n    */\n    fallback() external payable {\n        address _implementation = implementation();\n        require(_implementation != address(0x0), \"MISSING_IMPLEMENTATION\");\n\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 for now, as we don\u0027t know the out size yet.\n            let result := delegatecall(gas(), _implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /*\n      Sets the implementation address of the proxy.\n    */\n    function setImplementation(address newImplementation) private {\n        bytes32 slot = IMPLEMENTATION_SLOT;\n        assembly {\n            sstore(slot, newImplementation)\n        }\n    }\n\n    /*\n      Returns true if the contract is not in the finalized state.\n    */\n    function isNotFinalized() public view returns (bool notFinal) {\n        bytes32 slot = FINALIZED_STATE_SLOT;\n        uint256 slotValue;\n        assembly {\n            slotValue := sload(slot)\n        }\n        notFinal = (slotValue == 0);\n    }\n\n    /*\n      Marks the current implementation as finalized.\n    */\n    function setFinalizedFlag() private {\n        bytes32 slot = FINALIZED_STATE_SLOT;\n        assembly {\n            sstore(slot, 0x1)\n        }\n    }\n\n    /*\n      Introduce an implementation and its initialization vector,\n      and start the time-lock before it can be upgraded to.\n      addImplementation is not blocked when frozen or finalized.\n      (upgradeTo API is blocked when finalized or frozen).\n    */\n    function addImplementation(\n        address newImplementation,\n        bytes calldata data,\n        bool finalize\n    ) external onlyGovernance {\n        require(newImplementation.isContract(), \"ADDRESS_NOT_CONTRACT\");\n\n        bytes32 implVectorHash = keccak256(abi.encode(newImplementation, data, finalize));\n\n        uint256 activationTime = block.timestamp + getUpgradeActivationDelay();\n\n        // First implementation should not have time-lock.\n        if (implementation() == address(0x0)) {\n            activationTime = block.timestamp;\n        }\n\n        enabledTime[implVectorHash] = activationTime;\n        emit ImplementationAdded(newImplementation, data, finalize);\n    }\n\n    /*\n      Removes a candidate implementation.\n      Note that it is possible to remove the current implementation. Doing so doesn\u0027t affect the\n      current implementation, but rather revokes it as a future candidate.\n    */\n    function removeImplementation(\n        address removedImplementation,\n        bytes calldata data,\n        bool finalize\n    ) external onlyGovernance {\n        bytes32 implVectorHash = keccak256(abi.encode(removedImplementation, data, finalize));\n\n        // If we have initializer, we set the hash of it.\n        uint256 activationTime = enabledTime[implVectorHash];\n        require(activationTime \u003e 0, \"UNKNOWN_UPGRADE_INFORMATION\");\n        delete enabledTime[implVectorHash];\n        emit ImplementationRemoved(removedImplementation, data, finalize);\n    }\n\n    /*\n      Upgrades the proxy to a new implementation, with its initialization.\n      to upgrade successfully, implementation must have been added time-lock agreeably\n      before, and the init vector must be identical ot the one submitted before.\n\n      Upon assignment of new implementation address,\n      its initialize will be called with the initializing vector (even if empty).\n      Therefore, the implementation MUST must have such a method.\n\n      Note - Initialization data is committed to in advance, therefore it must remain valid\n      until the actual contract upgrade takes place.\n\n      Care should be taken regarding initialization data and flow when planning the contract upgrade.\n\n      When planning contract upgrade, special care is also needed with regard to governance\n      (See comments in Governance.sol).\n    */\n    // NOLINTNEXTLINE: reentrancy-events timestamp.\n    function upgradeTo(\n        address newImplementation,\n        bytes calldata data,\n        bool finalize\n    ) external payable onlyGovernance notFinalized notFrozen {\n        bytes32 implVectorHash = keccak256(abi.encode(newImplementation, data, finalize));\n        uint256 activationTime = enabledTime[implVectorHash];\n        require(activationTime \u003e 0, \"UNKNOWN_UPGRADE_INFORMATION\");\n        require(newImplementation.isContract(), \"ADDRESS_NOT_CONTRACT\");\n        // NOLINTNEXTLINE: timestamp.\n        require(activationTime \u003c= block.timestamp, \"UPGRADE_NOT_ENABLED_YET\");\n\n        setImplementation(newImplementation);\n\n        // NOLINTNEXTLINE: low-level-calls controlled-delegatecall.\n        (bool success, bytes memory returndata) = newImplementation.delegatecall(\n            abi.encodeWithSelector(this.initialize.selector, data)\n        );\n        require(success, string(returndata));\n\n        // Verify that the new implementation is not frozen post initialization.\n        // NOLINTNEXTLINE: low-level-calls controlled-delegatecall.\n        (success, returndata) = newImplementation.delegatecall(\n            abi.encodeWithSignature(\"isFrozen()\")\n        );\n        require(success, \"CALL_TO_ISFROZEN_REVERTED\");\n        require(!abi.decode(returndata, (bool)), \"NEW_IMPLEMENTATION_FROZEN\");\n\n        if (finalize) {\n            setFinalizedFlag();\n            emit FinalizedImplementation(newImplementation);\n        }\n\n        emit ImplementationUpgraded(newImplementation, data);\n    }\n}\n"},"ProxyGovernance.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"Governance.sol\";\nimport \"GovernanceStorage.sol\";\n\n/**\n  The Proxy contract is governed by one or more Governors of which the initial one is the\n  deployer of the contract.\n\n  A governor has the sole authority to perform the following operations:\n\n  1. Nominate additional governors (:sol:func:`proxyNominateNewGovernor`)\n  2. Remove other governors (:sol:func:`proxyRemoveGovernor`)\n  3. Add new `implementations` (proxied contracts)\n  4. Remove (new or old) `implementations`\n  5. Update `implementations` after a timelock allows it\n\n  Adding governors is performed in a two step procedure:\n\n  1. First, an existing governor nominates a new governor (:sol:func:`proxyNominateNewGovernor`)\n  2. Then, the new governor must accept governance to become a governor (:sol:func:`proxyAcceptGovernance`)\n\n  This two step procedure ensures that a governor public key cannot be nominated unless there is an\n  entity that has the corresponding private key. This is intended to prevent errors in the addition\n  process.\n\n  The governor private key should typically be held in a secure cold wallet or managed via a\n  multi-sig contract.\n*/\n/*\n  Implements Governance for the proxy contract.\n  It is a thin wrapper to the Governance contract,\n  which is needed so that it can have non-colliding function names,\n  and a specific tag (key) to allow unique state storage.\n*/\ncontract ProxyGovernance is GovernanceStorage, Governance {\n    // The tag is the string key that is used in the Governance storage mapping.\n    string public constant PROXY_GOVERNANCE_TAG = \"StarkEx.Proxy.2019.GovernorsInformation\";\n\n    /*\n      Returns the GovernanceInfoStruct associated with the governance tag.\n    */\n    function getGovernanceInfo() internal view override returns (GovernanceInfoStruct storage) {\n        return governanceInfo[PROXY_GOVERNANCE_TAG];\n    }\n\n    function proxyIsGovernor(address testGovernor) external view returns (bool) {\n        return isGovernor(testGovernor);\n    }\n\n    function proxyNominateNewGovernor(address newGovernor) external {\n        nominateNewGovernor(newGovernor);\n    }\n\n    function proxyRemoveGovernor(address governorForRemoval) external {\n        removeGovernor(governorForRemoval);\n    }\n\n    function proxyAcceptGovernance() external {\n        acceptGovernance();\n    }\n\n    function proxyCancelNomination() external {\n        cancelNomination();\n    }\n}\n"},"ProxyStorage.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\nimport \"GovernanceStorage.sol\";\n\n/*\n  Holds the Proxy-specific state variables.\n  This contract is inherited by the GovernanceStorage (and indirectly by MainStorage)\n  to prevent collision hazard.\n*/\ncontract ProxyStorage is GovernanceStorage {\n    // NOLINTNEXTLINE: naming-convention uninitialized-state.\n    mapping(address =\u003e bytes32) internal initializationHash_DEPRECATED;\n\n    // The time after which we can switch to the implementation.\n    // Hash(implementation, data, finalize) =\u003e time.\n    mapping(bytes32 =\u003e uint256) internal enabledTime;\n\n    // A central storage of the flags whether implementation has been initialized.\n    // Note - it can be used flexibly enough to accommodate multiple levels of initialization\n    // (i.e. using different key salting schemes for different initialization levels).\n    mapping(bytes32 =\u003e bool) internal initialized;\n}\n"},"StorageSlots.sol":{"content":"/*\n  Copyright 2019-2021 StarkWare Industries Ltd.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\").\n  You may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  https://www.starkware.co/open-source-license/\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions\n  and limitations under the License.\n*/\n// SPDX-License-Identifier: Apache-2.0.\npragma solidity ^0.6.12;\n\n/**\n  StorageSlots holds the arbitrary storage slots used throughout the Proxy pattern.\n  Storage address slots are a mechanism to define an arbitrary location, that will not be\n  overlapped by the logical contracts.\n*/\ncontract StorageSlots {\n    // Storage slot with the address of the current implementation.\n    // The address of the slot is keccak256(\"StarkWare2019.implemntation-slot\").\n    // We need to keep this variable stored outside of the commonly used space,\n    // so that it\u0027s not overrun by the logical implementation (the proxied contract).\n    bytes32 internal constant IMPLEMENTATION_SLOT =\n        0x177667240aeeea7e35eabe3a35e18306f336219e1386f7710a6bf8783f761b24;\n\n    // Storage slot with the address of the call-proxy current implementation.\n    // The address of the slot is keccak256(\"\u0027StarkWare2020.CallProxy.Implemntation.Slot\u0027\").\n    // We need to keep this variable stored outside of the commonly used space.\n    // so that it\u0027s not overrun by the logical implementation (the proxied contract).\n    bytes32 internal constant CALL_PROXY_IMPL_SLOT =\n        0x7184681641399eb4ad2fdb92114857ee6ff239f94ad635a1779978947b8843be;\n\n    // This storage slot stores the finalization flag.\n    // Once the value stored in this slot is set to non-zero\n    // the proxy blocks implementation upgrades.\n    // The current implementation is then referred to as Finalized.\n    // Web3.solidityKeccak([\u0027string\u0027], [\"StarkWare2019.finalization-flag-slot\"]).\n    bytes32 internal constant FINALIZED_STATE_SLOT =\n        0x7d433c6f837e8f93009937c466c82efbb5ba621fae36886d0cac433c5d0aa7d2;\n\n    // Storage slot to hold the upgrade delay (time-lock).\n    // The intention of this slot is to allow modification using an EIC.\n    // Web3.solidityKeccak([\u0027string\u0027], [\u0027StarkWare.Upgradibility.Delay.Slot\u0027]).\n    bytes32 public constant UPGRADE_DELAY_SLOT =\n        0xc21dbb3089fcb2c4f4c6a67854ab4db2b0f233ea4b21b21f912d52d18fc5db1f;\n}\n"}}

              File 3 of 6: FiatTokenProxy
              pragma solidity ^0.4.24;
              
              // File: zos-lib/contracts/upgradeability/Proxy.sol
              
              /**
               * @title Proxy
               * @dev Implements delegation of calls to other contracts, with proper
               * forwarding of return values and bubbling of failures.
               * It defines a fallback function that delegates all calls to the address
               * returned by the abstract _implementation() internal function.
               */
              contract Proxy {
                /**
                 * @dev Fallback function.
                 * Implemented entirely in `_fallback`.
                 */
                function () payable external {
                  _fallback();
                }
              
                /**
                 * @return The Address of the implementation.
                 */
                function _implementation() internal view returns (address);
              
                /**
                 * @dev Delegates execution to an implementation contract.
                 * This is a low level function that doesn't return to its internal call site.
                 * It will return to the external caller whatever the implementation returns.
                 * @param implementation Address to delegate.
                 */
                function _delegate(address implementation) internal {
                  assembly {
                    // Copy msg.data. We take full control of memory in this inline assembly
                    // block because it will not return to Solidity code. We overwrite the
                    // Solidity scratch pad at memory position 0.
                    calldatacopy(0, 0, calldatasize)
              
                    // Call the implementation.
                    // out and outsize are 0 because we don't know the size yet.
                    let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
              
                    // Copy the returned data.
                    returndatacopy(0, 0, returndatasize)
              
                    switch result
                    // delegatecall returns 0 on error.
                    case 0 { revert(0, returndatasize) }
                    default { return(0, returndatasize) }
                  }
                }
              
                /**
                 * @dev Function that is run as the first thing in the fallback function.
                 * Can be redefined in derived contracts to add functionality.
                 * Redefinitions must call super._willFallback().
                 */
                function _willFallback() internal {
                }
              
                /**
                 * @dev fallback implementation.
                 * Extracted to enable manual triggering.
                 */
                function _fallback() internal {
                  _willFallback();
                  _delegate(_implementation());
                }
              }
              
              // File: openzeppelin-solidity/contracts/AddressUtils.sol
              
              /**
               * Utility library of inline functions on addresses
               */
              library AddressUtils {
              
                /**
                 * Returns whether the target address is a contract
                 * @dev This function will return false if invoked during the constructor of a contract,
                 * as the code is not actually created until after the constructor finishes.
                 * @param addr address to check
                 * @return whether the target address is a contract
                 */
                function isContract(address addr) internal view returns (bool) {
                  uint256 size;
                  // XXX Currently there is no better way to check if there is a contract in an address
                  // than to check the size of the code at that address.
                  // See https://ethereum.stackexchange.com/a/14016/36603
                  // for more details about how this works.
                  // TODO Check this again before the Serenity release, because all addresses will be
                  // contracts then.
                  // solium-disable-next-line security/no-inline-assembly
                  assembly { size := extcodesize(addr) }
                  return size > 0;
                }
              
              }
              
              // File: zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol
              
              /**
               * @title UpgradeabilityProxy
               * @dev This contract implements a proxy that allows to change the
               * implementation address to which it will delegate.
               * Such a change is called an implementation upgrade.
               */
              contract UpgradeabilityProxy is Proxy {
                /**
                 * @dev Emitted when the implementation is upgraded.
                 * @param implementation Address of the new implementation.
                 */
                event Upgraded(address implementation);
              
                /**
                 * @dev Storage slot with the address of the current implementation.
                 * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
                 * validated in the constructor.
                 */
                bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
              
                /**
                 * @dev Contract constructor.
                 * @param _implementation Address of the initial implementation.
                 */
                constructor(address _implementation) public {
                  assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
              
                  _setImplementation(_implementation);
                }
              
                /**
                 * @dev Returns the current implementation.
                 * @return Address of the current implementation
                 */
                function _implementation() internal view returns (address impl) {
                  bytes32 slot = IMPLEMENTATION_SLOT;
                  assembly {
                    impl := sload(slot)
                  }
                }
              
                /**
                 * @dev Upgrades the proxy to a new implementation.
                 * @param newImplementation Address of the new implementation.
                 */
                function _upgradeTo(address newImplementation) internal {
                  _setImplementation(newImplementation);
                  emit Upgraded(newImplementation);
                }
              
                /**
                 * @dev Sets the implementation address of the proxy.
                 * @param newImplementation Address of the new implementation.
                 */
                function _setImplementation(address newImplementation) private {
                  require(AddressUtils.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
              
                  bytes32 slot = IMPLEMENTATION_SLOT;
              
                  assembly {
                    sstore(slot, newImplementation)
                  }
                }
              }
              
              // File: zos-lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol
              
              /**
               * @title AdminUpgradeabilityProxy
               * @dev This contract combines an upgradeability proxy with an authorization
               * mechanism for administrative tasks.
               * All external functions in this contract must be guarded by the
               * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity
               * feature proposal that would enable this to be done automatically.
               */
              contract AdminUpgradeabilityProxy is UpgradeabilityProxy {
                /**
                 * @dev Emitted when the administration has been transferred.
                 * @param previousAdmin Address of the previous admin.
                 * @param newAdmin Address of the new admin.
                 */
                event AdminChanged(address previousAdmin, address newAdmin);
              
                /**
                 * @dev Storage slot with the admin of the contract.
                 * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is
                 * validated in the constructor.
                 */
                bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;
              
                /**
                 * @dev Modifier to check whether the `msg.sender` is the admin.
                 * If it is, it will run the function. Otherwise, it will delegate the call
                 * to the implementation.
                 */
                modifier ifAdmin() {
                  if (msg.sender == _admin()) {
                    _;
                  } else {
                    _fallback();
                  }
                }
              
                /**
                 * Contract constructor.
                 * It sets the `msg.sender` as the proxy administrator.
                 * @param _implementation address of the initial implementation.
                 */
                constructor(address _implementation) UpgradeabilityProxy(_implementation) public {
                  assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin"));
              
                  _setAdmin(msg.sender);
                }
              
                /**
                 * @return The address of the proxy admin.
                 */
                function admin() external view ifAdmin returns (address) {
                  return _admin();
                }
              
                /**
                 * @return The address of the implementation.
                 */
                function implementation() external view ifAdmin returns (address) {
                  return _implementation();
                }
              
                /**
                 * @dev Changes the admin of the proxy.
                 * Only the current admin can call this function.
                 * @param newAdmin Address to transfer proxy administration to.
                 */
                function changeAdmin(address newAdmin) external ifAdmin {
                  require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
                  emit AdminChanged(_admin(), newAdmin);
                  _setAdmin(newAdmin);
                }
              
                /**
                 * @dev Upgrade the backing implementation of the proxy.
                 * Only the admin can call this function.
                 * @param newImplementation Address of the new implementation.
                 */
                function upgradeTo(address newImplementation) external ifAdmin {
                  _upgradeTo(newImplementation);
                }
              
                /**
                 * @dev Upgrade the backing implementation of the proxy and call a function
                 * on the new implementation.
                 * This is useful to initialize the proxied contract.
                 * @param newImplementation Address of the new implementation.
                 * @param data Data to send as msg.data in the low level call.
                 * It should include the signature and the parameters of the function to be
                 * called, as described in
                 * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
                 */
                function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin {
                  _upgradeTo(newImplementation);
                  require(address(this).call.value(msg.value)(data));
                }
              
                /**
                 * @return The admin slot.
                 */
                function _admin() internal view returns (address adm) {
                  bytes32 slot = ADMIN_SLOT;
                  assembly {
                    adm := sload(slot)
                  }
                }
              
                /**
                 * @dev Sets the address of the proxy admin.
                 * @param newAdmin Address of the new proxy admin.
                 */
                function _setAdmin(address newAdmin) internal {
                  bytes32 slot = ADMIN_SLOT;
              
                  assembly {
                    sstore(slot, newAdmin)
                  }
                }
              
                /**
                 * @dev Only fall back when the sender is not the admin.
                 */
                function _willFallback() internal {
                  require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
                  super._willFallback();
                }
              }
              
              // File: contracts/FiatTokenProxy.sol
              
              /**
              * Copyright CENTRE SECZ 2018
              *
              * Permission is hereby granted, free of charge, to any person obtaining a copy 
              * of this software and associated documentation files (the "Software"), to deal 
              * in the Software without restriction, including without limitation the rights 
              * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
              * copies of the Software, and to permit persons to whom the Software is furnished to 
              * do so, subject to the following conditions:
              *
              * The above copyright notice and this permission notice shall be included in all 
              * copies or substantial portions of the Software.
              *
              * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
              * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
              * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
              * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
              * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
              * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
              */
              
              pragma solidity ^0.4.24;
              
              
              /**
               * @title FiatTokenProxy
               * @dev This contract proxies FiatToken calls and enables FiatToken upgrades
              */ 
              contract FiatTokenProxy is AdminUpgradeabilityProxy {
                  constructor(address _implementation) public AdminUpgradeabilityProxy(_implementation) {
                  }
              }

              File 4 of 6: StarknetERC20Bridge
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                Common Utility Libraries.
                I. Addresses (extending address).
              */
              library Addresses {
                  /*
                    Note: isContract function has some known limitation.
                    See https://github.com/OpenZeppelin/
                    openzeppelin-contracts/blob/master/contracts/utils/Address.sol.
                  */
                  function isContract(address account) internal view returns (bool) {
                      uint256 size;
                      assembly {
                          size := extcodesize(account)
                      }
                      return size > 0;
                  }
                  function performEthTransfer(address recipient, uint256 amount) internal {
                      if (amount == 0) return;
                      (bool success, ) = recipient.call{value: amount}(""); // NOLINT: low-level-calls.
                      require(success, "ETH_TRANSFER_FAILED");
                  }
                  /*
                    Safe wrapper around ERC20/ERC721 calls.
                    This is required because many deployed ERC20 contracts don't return a value.
                    See https://github.com/ethereum/solidity/issues/4116.
                  */
                  function safeTokenContractCall(address tokenAddress, bytes memory callData) internal {
                      require(isContract(tokenAddress), "BAD_TOKEN_ADDRESS");
                      // NOLINTNEXTLINE: low-level-calls.
                      (bool success, bytes memory returndata) = tokenAddress.call(callData);
                      require(success, string(returndata));
                      if (returndata.length > 0) {
                          require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED");
                      }
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                This contract provides means to block direct call of an external function.
                A derived contract (e.g. MainDispatcherBase) should decorate sensitive functions with the
                notCalledDirectly modifier, thereby preventing it from being called directly, and allowing only
                calling using delegate_call.
              */
              abstract contract BlockDirectCall {
                  address immutable this_;
                  constructor() internal {
                      this_ = address(this);
                  }
                  modifier notCalledDirectly() {
                      require(this_ != address(this), "DIRECT_CALL_DISALLOWED");
                      _;
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              library CairoConstants {
                  uint256 public constant FIELD_PRIME =
                      0x800000000000011000000000000000000000000000000000000000000000001;
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /**
                Interface for contract initialization.
                The functions it exposes are the app specific parts of the contract initialization,
                and are called by the ProxySupport contract that implement the generic part of behind-proxy
                initialization.
              */
              abstract contract ContractInitializer {
                  /*
                    The number of sub-contracts that the proxied contract consists of.
                  */
                  function numOfSubContracts() internal pure virtual returns (uint256);
                  /*
                    Indicates if the proxied contract has already been initialized.
                    Used to prevent re-init.
                  */
                  function isInitialized() internal view virtual returns (bool);
                  /*
                    Validates the init data that is passed into the proxied contract.
                  */
                  function validateInitData(bytes calldata data) internal view virtual;
                  /*
                    For a proxied contract that consists of sub-contracts, this function processes
                    the sub-contract addresses, e.g. validates them, stores them etc.
                  */
                  function processSubContractAddresses(bytes calldata subContractAddresses) internal virtual;
                  /*
                    This function applies the logic of initializing the proxied contract state,
                    e.g. setting root values etc.
                  */
                  function initializeContractState(bytes calldata data) internal virtual;
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Governance.sol";
              contract GenericGovernance is Governance {
                  bytes32 immutable GOVERNANCE_INFO_TAG_HASH;
                  constructor(string memory governanceContext) public {
                      GOVERNANCE_INFO_TAG_HASH = keccak256(abi.encodePacked(governanceContext));
                  }
                  /*
                    Returns the GovernanceInfoStruct associated with the governance tag.
                  */
                  function getGovernanceInfo() internal view override returns (GovernanceInfoStruct storage gub) {
                      bytes32 location = GOVERNANCE_INFO_TAG_HASH;
                      assembly {
                          gub_slot := location
                      }
                  }
                  function isGovernor(address user) external view returns (bool) {
                      return _isGovernor(user);
                  }
                  function nominateNewGovernor(address newGovernor) external {
                      _nominateNewGovernor(newGovernor);
                  }
                  function removeGovernor(address governorForRemoval) external {
                      _removeGovernor(governorForRemoval);
                  }
                  function acceptGovernance() external {
                      _acceptGovernance();
                  }
                  function cancelNomination() external {
                      _cancelNomination();
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "MGovernance.sol";
              /*
                Implements Generic Governance, applicable for both proxy and main contract, and possibly others.
                Notes:
                 The use of the same function names by both the Proxy and a delegated implementation
                 is not possible since calling the implementation functions is done via the default function
                 of the Proxy. For this reason, for example, the implementation of MainContract (MainGovernance)
                 exposes mainIsGovernor, which calls the internal _isGovernor method.
              */
              struct GovernanceInfoStruct {
                  mapping(address => bool) effectiveGovernors;
                  address candidateGovernor;
                  bool initialized;
              }
              abstract contract Governance is MGovernance {
                  event LogNominatedGovernor(address nominatedGovernor);
                  event LogNewGovernorAccepted(address acceptedGovernor);
                  event LogRemovedGovernor(address removedGovernor);
                  event LogNominationCancelled();
                  function getGovernanceInfo() internal view virtual returns (GovernanceInfoStruct storage);
                  /*
                    Current code intentionally prevents governance re-initialization.
                    This may be a problem in an upgrade situation, in a case that the upgrade-to implementation
                    performs an initialization (for real) and within that calls initGovernance().
                    Possible workarounds:
                    1. Clearing the governance info altogether by changing the MAIN_GOVERNANCE_INFO_TAG.
                       This will remove existing main governance information.
                    2. Modify the require part in this function, so that it will exit quietly
                       when trying to re-initialize (uncomment the lines below).
                  */
                  function initGovernance() internal {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(!gub.initialized, "ALREADY_INITIALIZED");
                      gub.initialized = true; // to ensure acceptNewGovernor() won't fail.
                      // Add the initial governer.
                      acceptNewGovernor(msg.sender);
                  }
                  function _isGovernor(address user) internal view override returns (bool) {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      return gub.effectiveGovernors[user];
                  }
                  /*
                    Cancels the nomination of a governor candidate.
                  */
                  function _cancelNomination() internal onlyGovernance {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      if (gub.candidateGovernor != address(0x0)) {
                          gub.candidateGovernor = address(0x0);
                          emit LogNominationCancelled();
                      }
                  }
                  function _nominateNewGovernor(address newGovernor) internal onlyGovernance {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(newGovernor != address(0x0), "BAD_ADDRESS");
                      require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR");
                      require(gub.candidateGovernor == address(0x0), "OTHER_CANDIDATE_PENDING");
                      gub.candidateGovernor = newGovernor;
                      emit LogNominatedGovernor(newGovernor);
                  }
                  /*
                    The acceptNewGovernor is called in two cases:
                    1. by _acceptGovernance when a new governor accepts its role.
                    2. by initGovernance to add the initial governor.
                    The difference is that the init path skips the nominate step
                    that would fail because of the onlyGovernance modifier.
                  */
                  function acceptNewGovernor(address newGovernor) private {
                      require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR");
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      gub.effectiveGovernors[newGovernor] = true;
                      // Emit governance information.
                      emit LogNewGovernorAccepted(newGovernor);
                  }
                  function _acceptGovernance() internal {
                      // The new governor was proposed as a candidate by the current governor.
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(msg.sender == gub.candidateGovernor, "ONLY_CANDIDATE_GOVERNOR");
                      // Update state.
                      acceptNewGovernor(msg.sender);
                      gub.candidateGovernor = address(0x0);
                  }
                  /*
                    Remove a governor from office.
                  */
                  function _removeGovernor(address governorForRemoval) internal onlyGovernance {
                      require(msg.sender != governorForRemoval, "GOVERNOR_SELF_REMOVE");
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(_isGovernor(governorForRemoval), "NOT_GOVERNOR");
                      gub.effectiveGovernors[governorForRemoval] = false;
                      emit LogRemovedGovernor(governorForRemoval);
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /**
                Interface of the ERC20 standard as defined in the EIP. Does not include
                the optional functions; to access them see {ERC20Detailed}.
              */
              interface IERC20 {
                  function totalSupply() external view returns (uint256);
                  function balanceOf(address account) external view returns (uint256);
                  function transfer(address recipient, uint256 amount) external returns (bool);
                  function allowance(address owner, address spender) external view returns (uint256);
                  function approve(address spender, uint256 amount) external returns (bool);
                  function transferFrom(
                      address sender,
                      address recipient,
                      uint256 amount
                  ) external returns (bool);
                  event Transfer(address indexed from, address indexed to, uint256 value);
                  event Approval(address indexed owner, address indexed spender, uint256 value);
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "IStarknetMessagingEvents.sol";
              interface IStarknetMessaging is IStarknetMessagingEvents {
                  /**
                    Returns the max fee (in Wei) that StarkNet will accept per single message.
                  */
                  function getMaxL1MsgFee() external pure returns (uint256);
                  /**
                    Sends a message to an L2 contract.
                    This function is payable, the payed amount is the message fee.
                    Returns the hash of the message and the nonce of the message.
                  */
                  function sendMessageToL2(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload
                  ) external payable returns (bytes32, uint256);
                  /**
                    Consumes a message that was sent from an L2 contract.
                    Returns the hash of the message.
                  */
                  function consumeMessageFromL2(uint256 fromAddress, uint256[] calldata payload)
                      external
                      returns (bytes32);
                  /**
                    Starts the cancellation of an L1 to L2 message.
                    A message can be canceled messageCancellationDelay() seconds after this function is called.
                    Note: This function may only be called for a message that is currently pending and the caller
                    must be the sender of the that message.
                  */
                  function startL1ToL2MessageCancellation(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) external returns (bytes32);
                  /**
                    Cancels an L1 to L2 message, this function should be called at least
                    messageCancellationDelay() seconds after the call to startL1ToL2MessageCancellation().
                    A message may only be cancelled by its sender.
                    If the message is missing, the call will revert.
                    Note that the message fee is not refunded.
                  */
                  function cancelL1ToL2Message(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) external returns (bytes32);
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              interface IStarknetMessagingEvents {
                  // This event needs to be compatible with the one defined in Output.sol.
                  event LogMessageToL1(uint256 indexed fromAddress, address indexed toAddress, uint256[] payload);
                  // An event that is raised when a message is sent from L1 to L2.
                  event LogMessageToL2(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce,
                      uint256 fee
                  );
                  // An event that is raised when a message from L2 to L1 is consumed.
                  event ConsumedMessageToL1(
                      uint256 indexed fromAddress,
                      address indexed toAddress,
                      uint256[] payload
                  );
                  // An event that is raised when a message from L1 to L2 is consumed.
                  event ConsumedMessageToL2(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
                  // An event that is raised when a message from L1 to L2 Cancellation is started.
                  event MessageToL2CancellationStarted(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
                  // An event that is raised when a message from L1 to L2 is canceled.
                  event MessageToL2Canceled(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              interface Identity {
                  /*
                    Allows a caller to ensure that the provided address is of the expected type and version.
                  */
                  function identify() external pure returns (string memory);
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              abstract contract MGovernance {
                  function _isGovernor(address user) internal view virtual returns (bool);
                  /*
                    Allows calling the function only by a Governor.
                  */
                  modifier onlyGovernance() {
                      require(_isGovernor(msg.sender), "ONLY_GOVERNANCE");
                      _;
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                Library to provide basic storage, in storage location out of the low linear address space.
                New types of storage variables should be added here upon need.
              */
              library NamedStorage {
                  function bytes32ToUint256Mapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(bytes32 => uint256) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function bytes32ToAddressMapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(bytes32 => address) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function uintToAddressMapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(uint256 => address) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function addressToBoolMapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(address => bool) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function getUintValue(string memory tag_) internal view returns (uint256 retVal) {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          retVal := sload(slot)
                      }
                  }
                  function setUintValue(string memory tag_, uint256 value) internal {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          sstore(slot, value)
                      }
                  }
                  function setUintValueOnce(string memory tag_, uint256 value) internal {
                      require(getUintValue(tag_) == 0, "ALREADY_SET");
                      setUintValue(tag_, value);
                  }
                  function getAddressValue(string memory tag_) internal view returns (address retVal) {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          retVal := sload(slot)
                      }
                  }
                  function setAddressValue(string memory tag_, address value) internal {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          sstore(slot, value)
                      }
                  }
                  function setAddressValueOnce(string memory tag_, address value) internal {
                      require(getAddressValue(tag_) == address(0x0), "ALREADY_SET");
                      setAddressValue(tag_, value);
                  }
                  function getBoolValue(string memory tag_) internal view returns (bool retVal) {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          retVal := sload(slot)
                      }
                  }
                  function setBoolValue(string memory tag_, bool value) internal {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          sstore(slot, value)
                      }
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Governance.sol";
              import "Addresses.sol";
              import "BlockDirectCall.sol";
              import "ContractInitializer.sol";
              /**
                This contract contains the code commonly needed for a contract to be deployed behind
                an upgradability proxy.
                It perform the required semantics of the proxy pattern,
                but in a generic manner.
                Instantiation of the Governance and of the ContractInitializer, that are the app specific
                part of initialization, has to be done by the using contract.
              */
              abstract contract ProxySupport is Governance, BlockDirectCall, ContractInitializer {
                  using Addresses for address;
                  // The two function below (isFrozen & initialize) needed to bind to the Proxy.
                  function isFrozen() external view virtual returns (bool) {
                      return false;
                  }
                  /*
                    The initialize() function serves as an alternative constructor for a proxied deployment.
                    Flow and notes:
                    1. This function cannot be called directly on the deployed contract, but only via
                       delegate call.
                    2. If an EIC is provided - init is passed onto EIC and the standard init flow is skipped.
                       This true for both first intialization or a later one.
                    3. The data passed to this function is as follows:
                       [sub_contracts addresses, eic address, initData].
                       When calling on an initialized contract (no EIC scenario), initData.length must be 0.
                  */
                  function initialize(bytes calldata data) external notCalledDirectly {
                      uint256 eicOffset = 32 * numOfSubContracts();
                      uint256 expectedBaseSize = eicOffset + 32;
                      require(data.length >= expectedBaseSize, "INIT_DATA_TOO_SMALL");
                      address eicAddress = abi.decode(data[eicOffset:expectedBaseSize], (address));
                      bytes calldata subContractAddresses = data[:eicOffset];
                      processSubContractAddresses(subContractAddresses);
                      bytes calldata initData = data[expectedBaseSize:];
                      // EIC Provided - Pass initData to EIC and the skip standard init flow.
                      if (eicAddress != address(0x0)) {
                          callExternalInitializer(eicAddress, initData);
                          return;
                      }
                      if (isInitialized()) {
                          require(initData.length == 0, "UNEXPECTED_INIT_DATA");
                      } else {
                          // Contract was not initialized yet.
                          validateInitData(initData);
                          initializeContractState(initData);
                          initGovernance();
                      }
                  }
                  function callExternalInitializer(address externalInitializerAddr, bytes calldata eicData)
                      private
                  {
                      require(externalInitializerAddr.isContract(), "EIC_NOT_A_CONTRACT");
                      // NOLINTNEXTLINE: low-level-calls, controlled-delegatecall.
                      (bool success, bytes memory returndata) = externalInitializerAddr.delegatecall(
                          abi.encodeWithSelector(this.initialize.selector, eicData)
                      );
                      require(success, string(returndata));
                      require(returndata.length == 0, string(returndata));
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              contract StarknetBridgeConstants {
                  // The selector of the deposit handler in L2.
                  uint256 constant DEPOSIT_SELECTOR =
                      1285101517810983806491589552491143496277809242732141897358598292095611420389;
                  uint256 constant TRANSFER_FROM_STARKNET = 0;
                  uint256 constant UINT256_PART_SIZE_BITS = 128;
                  uint256 constant UINT256_PART_SIZE = 2**UINT256_PART_SIZE_BITS;
                  string constant GOVERNANCE_TAG = "STARKWARE_DEFAULT_GOVERNANCE_INFO";
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "NamedStorage.sol";
              import "IERC20.sol";
              import "StarknetTokenBridge.sol";
              import "Transfers.sol";
              contract StarknetERC20Bridge is StarknetTokenBridge {
                  function deposit(uint256 amount, uint256 l2Recipient) external payable override {
                      uint256 currentBalance = IERC20(bridgedToken()).balanceOf(address(this));
                      require(currentBalance <= currentBalance + amount, "OVERFLOW");
                      require(currentBalance + amount <= maxTotalBalance(), "MAX_BALANCE_EXCEEDED");
                      sendMessage(amount, l2Recipient, msg.value);
                      Transfers.transferIn(bridgedToken(), msg.sender, amount);
                  }
                  function transferOutFunds(uint256 amount, address recipient) internal override {
                      Transfers.transferOut(bridgedToken(), recipient, amount);
                  }
                  /**
                    Returns a string that identifies the contract.
                  */
                  function identify() external pure override returns (string memory) {
                      return "StarkWare_StarknetERC20Bridge_2023_1";
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "GenericGovernance.sol";
              import "Identity.sol";
              import "ProxySupport.sol";
              import "Addresses.sol";
              import "CairoConstants.sol";
              import "StarknetBridgeConstants.sol";
              import "StarknetTokenStorage.sol";
              import "IStarknetMessaging.sol";
              abstract contract StarknetTokenBridge is
                  Identity,
                  StarknetTokenStorage,
                  StarknetBridgeConstants,
                  GenericGovernance,
                  ProxySupport
              {
                  event LogDeposit(
                      address indexed sender,
                      uint256 amount,
                      uint256 indexed l2Recipient,
                      uint256 nonce,
                      uint256 fee
                  );
                  event LogDepositCancelRequest(
                      address indexed sender,
                      uint256 amount,
                      uint256 indexed l2Recipient,
                      uint256 nonce
                  );
                  event LogDepositReclaimed(
                      address indexed sender,
                      uint256 amount,
                      uint256 indexed l2Recipient,
                      uint256 nonce
                  );
                  event LogWithdrawal(address indexed recipient, uint256 amount);
                  event LogSetL2TokenBridge(uint256 value);
                  event LogSetMaxTotalBalance(uint256 value);
                  event LogSetMaxDeposit(uint256 value);
                  event LogBridgeActivated();
                  function deposit(uint256 amount, uint256 l2Recipient) external payable virtual;
                  function transferOutFunds(uint256 amount, address recipient) internal virtual;
                  /*
                    The constructor is in use here only to set the immutable tag in GenericGovernance.
                  */
                  constructor() internal GenericGovernance(GOVERNANCE_TAG) {}
                  function isTokenContractRequired() internal pure virtual returns (bool) {
                      return true;
                  }
                  function isInitialized() internal view override returns (bool) {
                      if (!isTokenContractRequired()) {
                          return (messagingContract() != IStarknetMessaging(0));
                      }
                      return (messagingContract() != IStarknetMessaging(0)) && (bridgedToken() != address(0));
                  }
                  function numOfSubContracts() internal pure override returns (uint256) {
                      return 0;
                  }
                  function validateInitData(bytes calldata data) internal view virtual override {
                      require(data.length == 64, "ILLEGAL_DATA_SIZE");
                      (address bridgedToken_, address messagingContract_) = abi.decode(data, (address, address));
                      if (isTokenContractRequired()) {
                          require(bridgedToken_.isContract(), "INVALID_BRIDGE_TOKEN_ADDRESS");
                      } else {
                          require(bridgedToken_ == address(0), "NON_ZERO_TOKEN_ADDRESS_PROVIDED");
                      }
                      require(messagingContract_.isContract(), "INVALID_MESSAGING_CONTRACT_ADDRESS");
                  }
                  /*
                    No processing needed, as there are no sub-contracts to this contract.
                  */
                  function processSubContractAddresses(bytes calldata subContractAddresses) internal override {}
                  /*
                    Gets the addresses of bridgedToken & messagingContract from the ProxySupport initialize(),
                    and sets the storage slot accordingly.
                  */
                  function initializeContractState(bytes calldata data) internal override {
                      (address bridgedToken_, address messagingContract_) = abi.decode(data, (address, address));
                      bridgedToken(bridgedToken_);
                      messagingContract(messagingContract_);
                  }
                  function isValidL2Address(uint256 l2Address) internal pure returns (bool) {
                      return (l2Address > 0 && l2Address < CairoConstants.FIELD_PRIME);
                  }
                  modifier onlyActive() {
                      require(isActive(), "NOT_ACTIVE_YET");
                      _;
                  }
                  modifier onlyDepositor(uint256 nonce) {
                      address depositor_ = depositors()[nonce];
                      require(depositor_ != address(0x0), "NO_DEPOSIT_TO_CANCEL");
                      require(depositor_ == msg.sender, "ONLY_DEPOSITOR");
                      _;
                  }
                  function setL2TokenBridge(uint256 l2TokenBridge_) external onlyGovernance {
                      require(isInitialized(), "CONTRACT_NOT_INITIALIZED");
                      require(isValidL2Address(l2TokenBridge_), "L2_ADDRESS_OUT_OF_RANGE");
                      l2TokenBridge(l2TokenBridge_);
                      setActive();
                      emit LogSetL2TokenBridge(l2TokenBridge_);
                      emit LogBridgeActivated();
                  }
                  /*
                    Sets the maximum allowed balance of the bridge.
                    Note: It is possible to set a lower value than the current total balance.
                    In this case, deposits will not be possible, until enough withdrawls are done, such that the
                    total balance gets below the limit.
                  */
                  function setMaxTotalBalance(uint256 maxTotalBalance_) external onlyGovernance {
                      emit LogSetMaxTotalBalance(maxTotalBalance_);
                      maxTotalBalance(maxTotalBalance_);
                  }
                  function setMaxDeposit(uint256 maxDeposit_) external onlyGovernance {
                      emit LogSetMaxDeposit(maxDeposit_);
                      maxDeposit(maxDeposit_);
                  }
                  function depositMessagePayload(uint256 amount, uint256 l2Recipient)
                      private
                      pure
                      returns (uint256[] memory)
                  {
                      uint256[] memory payload = new uint256[](3);
                      payload[0] = l2Recipient;
                      payload[1] = amount & (UINT256_PART_SIZE - 1);
                      payload[2] = amount >> UINT256_PART_SIZE_BITS;
                      return payload;
                  }
                  function sendMessage(
                      uint256 amount,
                      uint256 l2Recipient,
                      uint256 fee
                  ) internal onlyActive {
                      require(amount > 0, "ZERO_DEPOSIT");
                      require(msg.value >= fee, "INSUFFICIENT_MSG_VALUE");
                      require(isValidL2Address(l2Recipient), "L2_ADDRESS_OUT_OF_RANGE");
                      require(amount <= maxDeposit(), "TRANSFER_TO_STARKNET_AMOUNT_EXCEEDED");
                      (, uint256 nonce) = messagingContract().sendMessageToL2{value: fee}(
                          l2TokenBridge(),
                          DEPOSIT_SELECTOR,
                          depositMessagePayload(amount, l2Recipient)
                      );
                      require(depositors()[nonce] == address(0x0), "DEPOSIT_ALREADY_REGISTERED");
                      depositors()[nonce] = msg.sender;
                      emit LogDeposit(msg.sender, amount, l2Recipient, nonce, fee);
                  }
                  function consumeMessage(uint256 amount, address recipient) internal onlyActive {
                      uint256[] memory payload = new uint256[](4);
                      payload[0] = TRANSFER_FROM_STARKNET;
                      payload[1] = uint256(recipient);
                      payload[2] = amount & (UINT256_PART_SIZE - 1);
                      payload[3] = amount >> UINT256_PART_SIZE_BITS;
                      messagingContract().consumeMessageFromL2(l2TokenBridge(), payload);
                  }
                  function withdraw(uint256 amount, address recipient) public {
                      // Make sure we don't accidentally burn funds.
                      require(recipient != address(0x0), "INVALID_RECIPIENT");
                      // The call to consumeMessage will succeed only if a matching L2->L1 message
                      // exists and is ready for consumption.
                      consumeMessage(amount, recipient);
                      transferOutFunds(amount, recipient);
                      emit LogWithdrawal(recipient, amount);
                  }
                  function withdraw(uint256 amount) external {
                      withdraw(amount, msg.sender);
                  }
                  /*
                    A deposit cancellation requires two steps:
                    1. The depositor should send a depositCancelRequest request with deposit details & nonce.
                    2. Only the depositor is allowed to cancel a deposit.
                    3. After a certain threshold time, (cancellation delay), they can claim back the funds
                       by calling depositReclaim (using the same arguments).
                    The nonce should be extracted from the LogMessageToL2 event that was emitted by the
                    StarknetMessaging contract upon deposit.
                    Note: As long as the depositReclaim was not performed, the deposit may be processed,
                          even if the cancellation delay time as already passed.
                  */
                  function depositCancelRequest(
                      uint256 amount,
                      uint256 l2Recipient,
                      uint256 nonce
                  ) external onlyActive onlyDepositor(nonce) {
                      messagingContract().startL1ToL2MessageCancellation(
                          l2TokenBridge(),
                          DEPOSIT_SELECTOR,
                          depositMessagePayload(amount, l2Recipient),
                          nonce
                      );
                      // Only the depositor is allowed to cancel a deposit.
                      emit LogDepositCancelRequest(msg.sender, amount, l2Recipient, nonce);
                  }
                  function depositReclaim(
                      uint256 amount,
                      uint256 l2Recipient,
                      uint256 nonce
                  ) external onlyActive onlyDepositor(nonce) {
                      messagingContract().cancelL1ToL2Message(
                          l2TokenBridge(),
                          DEPOSIT_SELECTOR,
                          depositMessagePayload(amount, l2Recipient),
                          nonce
                      );
                      transferOutFunds(amount, msg.sender);
                      emit LogDepositReclaimed(msg.sender, amount, l2Recipient, nonce);
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "NamedStorage.sol";
              import "IStarknetMessaging.sol";
              abstract contract StarknetTokenStorage {
                  // Random storage slot tags.
                  string internal constant BRIDGED_TOKEN_TAG = "STARKNET_ERC20_TOKEN_BRIDGE_TOKEN_ADDRESS";
                  string internal constant L2_TOKEN_TAG = "STARKNET_TOKEN_BRIDGE_L2_TOKEN_CONTRACT";
                  string internal constant MAX_DEPOSIT_TAG = "STARKNET_TOKEN_BRIDGE_MAX_DEPOSIT";
                  string internal constant MAX_TOTAL_BALANCE_TAG = "STARKNET_TOKEN_BRIDGE_MAX_TOTAL_BALANCE";
                  string internal constant MESSAGING_CONTRACT_TAG = "STARKNET_TOKEN_BRIDGE_MESSAGING_CONTRACT";
                  string internal constant DEPOSITOR_ADDRESSES_TAG = "STARKNET_TOKEN_BRIDGE_DEPOSITOR_ADDRESSES";
                  string internal constant BRIDGE_IS_ACTIVE_TAG = "STARKNET_TOKEN_BRIDGE_IS_ACTIVE";
                  // Storage Getters.
                  function bridgedToken() internal view returns (address) {
                      return NamedStorage.getAddressValue(BRIDGED_TOKEN_TAG);
                  }
                  function l2TokenBridge() internal view returns (uint256) {
                      return NamedStorage.getUintValue(L2_TOKEN_TAG);
                  }
                  function maxDeposit() public view returns (uint256) {
                      return NamedStorage.getUintValue(MAX_DEPOSIT_TAG);
                  }
                  function maxTotalBalance() public view returns (uint256) {
                      return NamedStorage.getUintValue(MAX_TOTAL_BALANCE_TAG);
                  }
                  function messagingContract() internal view returns (IStarknetMessaging) {
                      return IStarknetMessaging(NamedStorage.getAddressValue(MESSAGING_CONTRACT_TAG));
                  }
                  function isActive() public view returns (bool) {
                      return NamedStorage.getBoolValue(BRIDGE_IS_ACTIVE_TAG);
                  }
                  function depositors() internal pure returns (mapping(uint256 => address) storage) {
                      return NamedStorage.uintToAddressMapping(DEPOSITOR_ADDRESSES_TAG);
                  }
                  // Storage Setters.
                  function bridgedToken(address contract_) internal {
                      NamedStorage.setAddressValueOnce(BRIDGED_TOKEN_TAG, contract_);
                  }
                  function l2TokenBridge(uint256 value) internal {
                      NamedStorage.setUintValueOnce(L2_TOKEN_TAG, value);
                  }
                  function maxDeposit(uint256 value) internal {
                      NamedStorage.setUintValue(MAX_DEPOSIT_TAG, value);
                  }
                  function maxTotalBalance(uint256 value) internal {
                      NamedStorage.setUintValue(MAX_TOTAL_BALANCE_TAG, value);
                  }
                  function messagingContract(address contract_) internal {
                      NamedStorage.setAddressValueOnce(MESSAGING_CONTRACT_TAG, contract_);
                  }
                  function setActive() internal {
                      return NamedStorage.setBoolValue(BRIDGE_IS_ACTIVE_TAG, true);
                  }
              }
              /*
                Copyright 2019-2023 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Addresses.sol";
              import "IERC20.sol";
              library Transfers {
                  using Addresses for address;
                  /*
                    Transfers funds from sender to the bridge.
                  */
                  function transferIn(
                      address token,
                      address sender,
                      uint256 amount
                  ) internal {
                      if (amount == 0) return;
                      IERC20 erc20Token = IERC20(token);
                      uint256 bridgeBalanceBefore = erc20Token.balanceOf(address(this));
                      uint256 expectedAfter = bridgeBalanceBefore + amount;
                      require(expectedAfter >= bridgeBalanceBefore, "OVERFLOW");
                      bytes memory callData = abi.encodeWithSelector(
                          erc20Token.transferFrom.selector,
                          sender,
                          address(this),
                          amount
                      );
                      token.safeTokenContractCall(callData);
                      uint256 bridgeBalanceAfter = erc20Token.balanceOf(address(this));
                      require(bridgeBalanceAfter == expectedAfter, "INCORRECT_AMOUNT_TRANSFERRED");
                  }
                  /*
                    Transfers funds from the bridge to recipient.
                  */
                  function transferOut(
                      address token,
                      address recipient,
                      uint256 amount
                  ) internal {
                      // Make sure we don't accidentally burn funds.
                      require(recipient != address(0x0), "INVALID_RECIPIENT");
                      if (amount == 0) return;
                      IERC20 erc20Token = IERC20(token);
                      uint256 bridgeBalanceBefore = erc20Token.balanceOf(address(this));
                      uint256 expectedAfter = bridgeBalanceBefore - amount;
                      require(expectedAfter <= bridgeBalanceBefore, "UNDERFLOW");
                      bytes memory callData = abi.encodeWithSelector(
                          erc20Token.transfer.selector,
                          recipient,
                          amount
                      );
                      token.safeTokenContractCall(callData);
                      uint256 bridgeBalanceAfter = erc20Token.balanceOf(address(this));
                      require(bridgeBalanceAfter == expectedAfter, "INCORRECT_AMOUNT_TRANSFERRED");
                  }
              }
              

              File 5 of 6: Starknet
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                Common Utility Libraries.
                I. Addresses (extending address).
              */
              library Addresses {
                  /*
                    Note: isContract function has some known limitation.
                    See https://github.com/OpenZeppelin/
                    openzeppelin-contracts/blob/master/contracts/utils/Address.sol.
                  */
                  function isContract(address account) internal view returns (bool) {
                      uint256 size;
                      assembly {
                          size := extcodesize(account)
                      }
                      return size > 0;
                  }
                  function performEthTransfer(address recipient, uint256 amount) internal {
                      if (amount == 0) return;
                      (bool success, ) = recipient.call{value: amount}(""); // NOLINT: low-level-calls.
                      require(success, "ETH_TRANSFER_FAILED");
                  }
                  /*
                    Safe wrapper around ERC20/ERC721 calls.
                    This is required because many deployed ERC20 contracts don't return a value.
                    See https://github.com/ethereum/solidity/issues/4116.
                  */
                  function safeTokenContractCall(address tokenAddress, bytes memory callData) internal {
                      require(isContract(tokenAddress), "BAD_TOKEN_ADDRESS");
                      // NOLINTNEXTLINE: low-level-calls.
                      (bool success, bytes memory returndata) = tokenAddress.call(callData);
                      require(success, string(returndata));
                      if (returndata.length > 0) {
                          require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED");
                      }
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                This contract provides means to block direct call of an external function.
                A derived contract (e.g. MainDispatcherBase) should decorate sensitive functions with the
                notCalledDirectly modifier, thereby preventing it from being called directly, and allowing only
                calling using delegate_call.
              */
              abstract contract BlockDirectCall {
                  address immutable this_;
                  constructor() internal {
                      this_ = address(this);
                  }
                  modifier notCalledDirectly() {
                      require(this_ != address(this), "DIRECT_CALL_DISALLOWED");
                      _;
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /**
                Interface for contract initialization.
                The functions it exposes are the app specific parts of the contract initialization,
                and are called by the ProxySupport contract that implement the generic part of behind-proxy
                initialization.
              */
              abstract contract ContractInitializer {
                  /*
                    The number of sub-contracts that the proxied contract consists of.
                  */
                  function numOfSubContracts() internal pure virtual returns (uint256);
                  /*
                    Indicates if the proxied contract has already been initialized.
                    Used to prevent re-init.
                  */
                  function isInitialized() internal view virtual returns (bool);
                  /*
                    Validates the init data that is passed into the proxied contract.
                  */
                  function validateInitData(bytes calldata data) internal view virtual;
                  /*
                    For a proxied contract that consists of sub-contracts, this function processes
                    the sub-contract addresses, e.g. validates them, stores them etc.
                  */
                  function processSubContractAddresses(bytes calldata subContractAddresses) internal virtual;
                  /*
                    This function applies the logic of initializing the proxied contract state,
                    e.g. setting root values etc.
                  */
                  function initializeContractState(bytes calldata data) internal virtual;
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "MGovernance.sol";
              /*
                Implements Generic Governance, applicable for both proxy and main contract, and possibly others.
                Notes:
                 The use of the same function names by both the Proxy and a delegated implementation
                 is not possible since calling the implementation functions is done via the default function
                 of the Proxy. For this reason, for example, the implementation of MainContract (MainGovernance)
                 exposes mainIsGovernor, which calls the internal _isGovernor method.
              */
              struct GovernanceInfoStruct {
                  mapping(address => bool) effectiveGovernors;
                  address candidateGovernor;
                  bool initialized;
              }
              abstract contract Governance is MGovernance {
                  event LogNominatedGovernor(address nominatedGovernor);
                  event LogNewGovernorAccepted(address acceptedGovernor);
                  event LogRemovedGovernor(address removedGovernor);
                  event LogNominationCancelled();
                  function getGovernanceInfo() internal view virtual returns (GovernanceInfoStruct storage);
                  /*
                    Current code intentionally prevents governance re-initialization.
                    This may be a problem in an upgrade situation, in a case that the upgrade-to implementation
                    performs an initialization (for real) and within that calls initGovernance().
                    Possible workarounds:
                    1. Clearing the governance info altogether by changing the MAIN_GOVERNANCE_INFO_TAG.
                       This will remove existing main governance information.
                    2. Modify the require part in this function, so that it will exit quietly
                       when trying to re-initialize (uncomment the lines below).
                  */
                  function initGovernance() internal {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(!gub.initialized, "ALREADY_INITIALIZED");
                      gub.initialized = true; // to ensure acceptNewGovernor() won't fail.
                      // Add the initial governer.
                      acceptNewGovernor(msg.sender);
                  }
                  function _isGovernor(address user) internal view override returns (bool) {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      return gub.effectiveGovernors[user];
                  }
                  /*
                    Cancels the nomination of a governor candidate.
                  */
                  function _cancelNomination() internal onlyGovernance {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      if (gub.candidateGovernor != address(0x0)) {
                          gub.candidateGovernor = address(0x0);
                          emit LogNominationCancelled();
                      }
                  }
                  function _nominateNewGovernor(address newGovernor) internal onlyGovernance {
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(newGovernor != address(0x0), "BAD_ADDRESS");
                      require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR");
                      require(gub.candidateGovernor == address(0x0), "OTHER_CANDIDATE_PENDING");
                      gub.candidateGovernor = newGovernor;
                      emit LogNominatedGovernor(newGovernor);
                  }
                  /*
                    The acceptNewGovernor is called in two cases:
                    1. by _acceptGovernance when a new governor accepts its role.
                    2. by initGovernance to add the initial governor.
                    The difference is that the init path skips the nominate step
                    that would fail because of the onlyGovernance modifier.
                  */
                  function acceptNewGovernor(address newGovernor) private {
                      require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR");
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      gub.effectiveGovernors[newGovernor] = true;
                      // Emit governance information.
                      emit LogNewGovernorAccepted(newGovernor);
                  }
                  function _acceptGovernance() internal {
                      // The new governor was proposed as a candidate by the current governor.
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(msg.sender == gub.candidateGovernor, "ONLY_CANDIDATE_GOVERNOR");
                      // Update state.
                      acceptNewGovernor(msg.sender);
                      gub.candidateGovernor = address(0x0);
                  }
                  /*
                    Remove a governor from office.
                  */
                  function _removeGovernor(address governorForRemoval) internal onlyGovernance {
                      require(msg.sender != governorForRemoval, "GOVERNOR_SELF_REMOVE");
                      GovernanceInfoStruct storage gub = getGovernanceInfo();
                      require(_isGovernor(governorForRemoval), "NOT_GOVERNOR");
                      gub.effectiveGovernors[governorForRemoval] = false;
                      emit LogRemovedGovernor(governorForRemoval);
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "MGovernance.sol";
              import "NamedStorage.sol";
              /**
                A Governor controlled finalizable contract.
                The inherited contract (the one that is GovernedFinalizable) implements the Governance.
              */
              abstract contract GovernedFinalizable is MGovernance {
                  event Finalized();
                  string constant STORAGE_TAG = "STARKWARE_CONTRACTS_GOVERENED_FINALIZABLE_1.0_TAG";
                  function isFinalized() public view returns (bool) {
                      return NamedStorage.getBoolValue(STORAGE_TAG);
                  }
                  modifier notFinalized() {
                      require(!isFinalized(), "FINALIZED");
                      _;
                  }
                  function finalize() external onlyGovernance notFinalized {
                      NamedStorage.setBoolValue(STORAGE_TAG, true);
                      emit Finalized();
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                The Fact Registry design pattern is a way to separate cryptographic verification from the
                business logic of the contract flow.
                A fact registry holds a hash table of verified "facts" which are represented by a hash of claims
                that the registry hash check and found valid. This table may be queried by accessing the
                isValid() function of the registry with a given hash.
                In addition, each fact registry exposes a registry specific function for submitting new claims
                together with their proofs. The information submitted varies from one registry to the other
                depending of the type of fact requiring verification.
                For further reading on the Fact Registry design pattern see this
                `StarkWare blog post <https://medium.com/starkware/the-fact-registry-a64aafb598b6>`_.
              */
              interface IFactRegistry {
                  /*
                    Returns true if the given fact was previously registered in the contract.
                  */
                  function isValid(bytes32 fact) external view returns (bool);
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "IStarknetMessagingEvents.sol";
              interface IStarknetMessaging is IStarknetMessagingEvents {
                  /**
                    Returns the max fee (in Wei) that StarkNet will accept per single message.
                  */
                  function getMaxL1MsgFee() external pure returns (uint256);
                  /**
                    Sends a message to an L2 contract.
                    This function is payable, the payed amount is the message fee.
                    Returns the hash of the message and the nonce of the message.
                  */
                  function sendMessageToL2(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload
                  ) external payable returns (bytes32, uint256);
                  /**
                    Consumes a message that was sent from an L2 contract.
                    Returns the hash of the message.
                  */
                  function consumeMessageFromL2(uint256 fromAddress, uint256[] calldata payload)
                      external
                      returns (bytes32);
                  /**
                    Starts the cancellation of an L1 to L2 message.
                    A message can be canceled messageCancellationDelay() seconds after this function is called.
                    Note: This function may only be called for a message that is currently pending and the caller
                    must be the sender of the that message.
                  */
                  function startL1ToL2MessageCancellation(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) external returns (bytes32);
                  /**
                    Cancels an L1 to L2 message, this function should be called at least
                    messageCancellationDelay() seconds after the call to startL1ToL2MessageCancellation().
                    A message may only be cancelled by its sender.
                    If the message is missing, the call will revert.
                    Note that the message fee is not refunded.
                  */
                  function cancelL1ToL2Message(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) external returns (bytes32);
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              interface IStarknetMessagingEvents {
                  // This event needs to be compatible with the one defined in Output.sol.
                  event LogMessageToL1(uint256 indexed fromAddress, address indexed toAddress, uint256[] payload);
                  // An event that is raised when a message is sent from L1 to L2.
                  event LogMessageToL2(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce,
                      uint256 fee
                  );
                  // An event that is raised when a message from L2 to L1 is consumed.
                  event ConsumedMessageToL1(
                      uint256 indexed fromAddress,
                      address indexed toAddress,
                      uint256[] payload
                  );
                  // An event that is raised when a message from L1 to L2 is consumed.
                  event ConsumedMessageToL2(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
                  // An event that is raised when a message from L1 to L2 Cancellation is started.
                  event MessageToL2CancellationStarted(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
                  // An event that is raised when a message from L1 to L2 is canceled.
                  event MessageToL2Canceled(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              interface Identity {
                  /*
                    Allows a caller to ensure that the provided address is of the expected type and version.
                  */
                  function identify() external pure returns (string memory);
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              abstract contract MGovernance {
                  function _isGovernor(address user) internal view virtual returns (bool);
                  /*
                    Allows calling the function only by a Governor.
                  */
                  modifier onlyGovernance() {
                      require(_isGovernor(msg.sender), "ONLY_GOVERNANCE");
                      _;
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "MGovernance.sol";
              abstract contract MOperator {
                  event LogOperatorAdded(address operator);
                  event LogOperatorRemoved(address operator);
                  function isOperator(address user) public view virtual returns (bool);
                  modifier onlyOperator() {
                      require(isOperator(msg.sender), "ONLY_OPERATOR");
                      _;
                  }
                  function registerOperator(address newOperator) external virtual;
                  function unregisterOperator(address removedOperator) external virtual;
                  function getOperators() internal view virtual returns (mapping(address => bool) storage);
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              /*
                Library to provide basic storage, in storage location out of the low linear address space.
                New types of storage variables should be added here upon need.
              */
              library NamedStorage {
                  function bytes32ToUint256Mapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(bytes32 => uint256) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function bytes32ToAddressMapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(bytes32 => address) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function uintToAddressMapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(uint256 => address) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function addressToBoolMapping(string memory tag_)
                      internal
                      pure
                      returns (mapping(address => bool) storage randomVariable)
                  {
                      bytes32 location = keccak256(abi.encodePacked(tag_));
                      assembly {
                          randomVariable_slot := location
                      }
                  }
                  function getUintValue(string memory tag_) internal view returns (uint256 retVal) {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          retVal := sload(slot)
                      }
                  }
                  function setUintValue(string memory tag_, uint256 value) internal {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          sstore(slot, value)
                      }
                  }
                  function setUintValueOnce(string memory tag_, uint256 value) internal {
                      require(getUintValue(tag_) == 0, "ALREADY_SET");
                      setUintValue(tag_, value);
                  }
                  function getAddressValue(string memory tag_) internal view returns (address retVal) {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          retVal := sload(slot)
                      }
                  }
                  function setAddressValue(string memory tag_, address value) internal {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          sstore(slot, value)
                      }
                  }
                  function setAddressValueOnce(string memory tag_, address value) internal {
                      require(getAddressValue(tag_) == address(0x0), "ALREADY_SET");
                      setAddressValue(tag_, value);
                  }
                  function getBoolValue(string memory tag_) internal view returns (bool retVal) {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          retVal := sload(slot)
                      }
                  }
                  function setBoolValue(string memory tag_, bool value) internal {
                      bytes32 slot = keccak256(abi.encodePacked(tag_));
                      assembly {
                          sstore(slot, value)
                      }
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              library OnchainDataFactTreeEncoder {
                  struct DataAvailabilityFact {
                      uint256 onchainDataHash;
                      uint256 onchainDataSize;
                  }
                  // The number of additional words appended to the public input when using the
                  // OnchainDataFactTreeEncoder format.
                  uint256 internal constant ONCHAIN_DATA_FACT_ADDITIONAL_WORDS = 2;
                  /*
                    Encodes a GPS fact Merkle tree where the root has two children.
                    The left child contains the data we care about and the right child contains
                    on-chain data for the fact.
                  */
                  function encodeFactWithOnchainData(
                      uint256[] calldata programOutput,
                      DataAvailabilityFact memory factData
                  ) internal pure returns (bytes32) {
                      // The state transition fact is computed as a Merkle tree, as defined in
                      // GpsOutputParser.
                      //
                      // In our case the fact tree looks as follows:
                      //   The root has two children.
                      //   The left child is a leaf that includes the main part - the information regarding
                      //   the state transition required by this contract.
                      //   The right child contains the onchain-data which shouldn't be accessed by this
                      //   contract, so we are only given its hash and length
                      //   (it may be a leaf or an inner node, this has no effect on this contract).
                      // Compute the hash without the two additional fields.
                      uint256 mainPublicInputLen = programOutput.length;
                      bytes32 mainPublicInputHash = keccak256(abi.encodePacked(programOutput));
                      // Compute the hash of the fact Merkle tree.
                      bytes32 hashResult = keccak256(
                          abi.encodePacked(
                              mainPublicInputHash,
                              mainPublicInputLen,
                              factData.onchainDataHash,
                              mainPublicInputLen + factData.onchainDataSize
                          )
                      );
                      // Add one to the hash to indicate it represents an inner node, rather than a leaf.
                      return bytes32(uint256(hashResult) + 1);
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "MOperator.sol";
              import "MGovernance.sol";
              /**
                The Operator of the contract is the entity entitled to submit state update requests
                by calling :sol:func:`updateState`.
                An Operator may be instantly appointed or removed by the contract Governor
                (see :sol:mod:`Governance`). Typically, the Operator is the hot wallet of the service
                submitting proofs for state updates.
              */
              abstract contract Operator is MGovernance, MOperator {
                  function registerOperator(address newOperator) external override onlyGovernance {
                      if (!isOperator(newOperator)) {
                          getOperators()[newOperator] = true;
                          emit LogOperatorAdded(newOperator);
                      }
                  }
                  function unregisterOperator(address removedOperator) external override onlyGovernance {
                      if (isOperator(removedOperator)) {
                          getOperators()[removedOperator] = false;
                          emit LogOperatorRemoved(removedOperator);
                      }
                  }
                  function isOperator(address user) public view override returns (bool) {
                      return getOperators()[user];
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              library CommitmentTreeUpdateOutput {
                  /**
                    Returns the previous commitment tree root.
                  */
                  function getPrevRoot(uint256[] calldata commitmentTreeUpdateData)
                      internal
                      pure
                      returns (uint256)
                  {
                      return commitmentTreeUpdateData[0];
                  }
                  /**
                    Returns the new commitment tree root.
                  */
                  function getNewRoot(uint256[] calldata commitmentTreeUpdateData)
                      internal
                      pure
                      returns (uint256)
                  {
                      return commitmentTreeUpdateData[1];
                  }
              }
              library StarknetOutput {
                  uint256 internal constant MERKLE_UPDATE_OFFSET = 0;
                  uint256 internal constant BLOCK_NUMBER_OFFSET = 2;
                  uint256 internal constant BLOCK_HASH_OFFSET = 3;
                  uint256 internal constant CONFIG_HASH_OFFSET = 4;
                  uint256 internal constant HEADER_SIZE = 5;
                  uint256 constant MESSAGE_TO_L1_FROM_ADDRESS_OFFSET = 0;
                  uint256 constant MESSAGE_TO_L1_TO_ADDRESS_OFFSET = 1;
                  uint256 constant MESSAGE_TO_L1_PAYLOAD_SIZE_OFFSET = 2;
                  uint256 constant MESSAGE_TO_L1_PREFIX_SIZE = 3;
                  uint256 constant MESSAGE_TO_L2_FROM_ADDRESS_OFFSET = 0;
                  uint256 constant MESSAGE_TO_L2_TO_ADDRESS_OFFSET = 1;
                  uint256 constant MESSAGE_TO_L2_NONCE_OFFSET = 2;
                  uint256 constant MESSAGE_TO_L2_SELECTOR_OFFSET = 3;
                  uint256 constant MESSAGE_TO_L2_PAYLOAD_SIZE_OFFSET = 4;
                  uint256 constant MESSAGE_TO_L2_PREFIX_SIZE = 5;
                  // An event that is raised when a message is sent from L2 to L1.
                  event LogMessageToL1(uint256 indexed fromAddress, address indexed toAddress, uint256[] payload);
                  // An event that is raised when a message from L1 to L2 is consumed.
                  event ConsumedMessageToL2(
                      address indexed fromAddress,
                      uint256 indexed toAddress,
                      uint256 indexed selector,
                      uint256[] payload,
                      uint256 nonce
                  );
                  /**
                    Does a sanity check of the output_data length.
                  */
                  function validate(uint256[] calldata output_data) internal pure {
                      require(output_data.length > HEADER_SIZE, "STARKNET_OUTPUT_TOO_SHORT");
                  }
                  /**
                    Returns a slice of the 'output_data' with the commitment tree update information.
                  */
                  function getMerkleUpdate(uint256[] calldata output_data)
                      internal
                      pure
                      returns (uint256[] calldata)
                  {
                      return output_data[MERKLE_UPDATE_OFFSET:MERKLE_UPDATE_OFFSET + 2];
                  }
                  /**
                    Processes a message segment from the program output.
                    The format of a message segment is the length of the messages in words followed
                    by the concatenation of all the messages.
                    The 'messages' mapping is updated according to the messages and the direction ('isL2ToL1').
                  */
                  function processMessages(
                      bool isL2ToL1,
                      uint256[] calldata programOutputSlice,
                      mapping(bytes32 => uint256) storage messages
                  ) internal returns (uint256) {
                      uint256 messageSegmentSize = programOutputSlice[0];
                      require(messageSegmentSize < 2**30, "INVALID_MESSAGE_SEGMENT_SIZE");
                      uint256 offset = 1;
                      uint256 messageSegmentEnd = offset + messageSegmentSize;
                      uint256 payloadSizeOffset = (
                          isL2ToL1 ? MESSAGE_TO_L1_PAYLOAD_SIZE_OFFSET : MESSAGE_TO_L2_PAYLOAD_SIZE_OFFSET
                      );
                      uint256 totalMsgFees = 0;
                      while (offset < messageSegmentEnd) {
                          uint256 payloadLengthOffset = offset + payloadSizeOffset;
                          require(payloadLengthOffset < programOutputSlice.length, "MESSAGE_TOO_SHORT");
                          uint256 payloadLength = programOutputSlice[payloadLengthOffset];
                          require(payloadLength < 2**30, "INVALID_PAYLOAD_LENGTH");
                          uint256 endOffset = payloadLengthOffset + 1 + payloadLength;
                          require(endOffset <= programOutputSlice.length, "TRUNCATED_MESSAGE_PAYLOAD");
                          if (isL2ToL1) {
                              bytes32 messageHash = keccak256(
                                  abi.encodePacked(programOutputSlice[offset:endOffset])
                              );
                              emit LogMessageToL1(
                                  // from=
                                  programOutputSlice[offset + MESSAGE_TO_L1_FROM_ADDRESS_OFFSET],
                                  // to=
                                  address(programOutputSlice[offset + MESSAGE_TO_L1_TO_ADDRESS_OFFSET]),
                                  // payload=
                                  (uint256[])(programOutputSlice[offset + MESSAGE_TO_L1_PREFIX_SIZE:endOffset])
                              );
                              messages[messageHash] += 1;
                          } else {
                              {
                                  bytes32 messageHash = keccak256(
                                      abi.encodePacked(programOutputSlice[offset:endOffset])
                                  );
                                  uint256 msgFeePlusOne = messages[messageHash];
                                  require(msgFeePlusOne > 0, "INVALID_MESSAGE_TO_CONSUME");
                                  totalMsgFees += msgFeePlusOne - 1;
                                  messages[messageHash] = 0;
                              }
                              uint256 nonce = programOutputSlice[offset + MESSAGE_TO_L2_NONCE_OFFSET];
                              uint256[] memory messageSlice = (uint256[])(
                                  programOutputSlice[offset + MESSAGE_TO_L2_PREFIX_SIZE:endOffset]
                              );
                              emit ConsumedMessageToL2(
                                  // from=
                                  address(programOutputSlice[offset + MESSAGE_TO_L2_FROM_ADDRESS_OFFSET]),
                                  // to=
                                  programOutputSlice[offset + MESSAGE_TO_L2_TO_ADDRESS_OFFSET],
                                  // selector=
                                  programOutputSlice[offset + MESSAGE_TO_L2_SELECTOR_OFFSET],
                                  // payload=
                                  messageSlice,
                                  // nonce =
                                  nonce
                              );
                          }
                          offset = endOffset;
                      }
                      require(offset == messageSegmentEnd, "INVALID_MESSAGE_SEGMENT_SIZE");
                      if (totalMsgFees > 0) {
                          // NOLINTNEXTLINE: low-level-calls.
                          (bool success, ) = msg.sender.call{value: totalMsgFees}("");
                          require(success, "ETH_TRANSFER_FAILED");
                      }
                      return offset;
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Governance.sol";
              import "Addresses.sol";
              import "BlockDirectCall.sol";
              import "ContractInitializer.sol";
              /**
                This contract contains the code commonly needed for a contract to be deployed behind
                an upgradability proxy.
                It perform the required semantics of the proxy pattern,
                but in a generic manner.
                Instantiation of the Governance and of the ContractInitializer, that are the app specific
                part of initialization, has to be done by the using contract.
              */
              abstract contract ProxySupport is Governance, BlockDirectCall, ContractInitializer {
                  using Addresses for address;
                  // The two function below (isFrozen & initialize) needed to bind to the Proxy.
                  function isFrozen() external view virtual returns (bool) {
                      return false;
                  }
                  /*
                    The initialize() function serves as an alternative constructor for a proxied deployment.
                    Flow and notes:
                    1. This function cannot be called directly on the deployed contract, but only via
                       delegate call.
                    2. If an EIC is provided - init is passed onto EIC and the standard init flow is skipped.
                       This true for both first intialization or a later one.
                    3. The data passed to this function is as follows:
                       [sub_contracts addresses, eic address, initData].
                       When calling on an initialized contract (no EIC scenario), initData.length must be 0.
                  */
                  function initialize(bytes calldata data) external notCalledDirectly {
                      uint256 eicOffset = 32 * numOfSubContracts();
                      uint256 expectedBaseSize = eicOffset + 32;
                      require(data.length >= expectedBaseSize, "INIT_DATA_TOO_SMALL");
                      address eicAddress = abi.decode(data[eicOffset:expectedBaseSize], (address));
                      bytes calldata subContractAddresses = data[:eicOffset];
                      processSubContractAddresses(subContractAddresses);
                      bytes calldata initData = data[expectedBaseSize:];
                      // EIC Provided - Pass initData to EIC and the skip standard init flow.
                      if (eicAddress != address(0x0)) {
                          callExternalInitializer(eicAddress, initData);
                          return;
                      }
                      if (isInitialized()) {
                          require(initData.length == 0, "UNEXPECTED_INIT_DATA");
                      } else {
                          // Contract was not initialized yet.
                          validateInitData(initData);
                          initializeContractState(initData);
                          initGovernance();
                      }
                  }
                  function callExternalInitializer(address externalInitializerAddr, bytes calldata eicData)
                      private
                  {
                      require(externalInitializerAddr.isContract(), "EIC_NOT_A_CONTRACT");
                      // NOLINTNEXTLINE: low-level-calls, controlled-delegatecall.
                      (bool success, bytes memory returndata) = externalInitializerAddr.delegatecall(
                          abi.encodeWithSelector(this.initialize.selector, eicData)
                      );
                      require(success, string(returndata));
                      require(returndata.length == 0, string(returndata));
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              pragma experimental ABIEncoderV2;
              import "Output.sol";
              import "StarknetGovernance.sol";
              import "StarknetMessaging.sol";
              import "StarknetOperator.sol";
              import "StarknetState.sol";
              import "GovernedFinalizable.sol";
              import "OnchainDataFactTreeEncoder.sol";
              import "ContractInitializer.sol";
              import "Identity.sol";
              import "IFactRegistry.sol";
              import "ProxySupport.sol";
              import "NamedStorage.sol";
              contract Starknet is
                  Identity,
                  StarknetMessaging,
                  StarknetGovernance,
                  GovernedFinalizable,
                  StarknetOperator,
                  ContractInitializer,
                  ProxySupport
              {
                  using StarknetState for StarknetState.State;
                  // Indicates a change of the Starknet config hash.
                  event ConfigHashChanged(
                      address indexed changedBy,
                      uint256 oldConfigHash,
                      uint256 newConfigHash
                  );
                  // Logs the new state following a state update.
                  event LogStateUpdate(uint256 globalRoot, int256 blockNumber, uint256 blockHash);
                  // Logs a stateTransitionFact that was used to update the state.
                  event LogStateTransitionFact(bytes32 stateTransitionFact);
                  // Indicates a change of the Starknet OS program hash.
                  event ProgramHashChanged(
                      address indexed changedBy,
                      uint256 oldProgramHash,
                      uint256 newProgramHash
                  );
                  // Random storage slot tags.
                  string internal constant PROGRAM_HASH_TAG = "STARKNET_1.0_INIT_PROGRAM_HASH_UINT";
                  string internal constant VERIFIER_ADDRESS_TAG = "STARKNET_1.0_INIT_VERIFIER_ADDRESS";
                  string internal constant STATE_STRUCT_TAG = "STARKNET_1.0_INIT_STARKNET_STATE_STRUCT";
                  // The hash of the StarkNet config.
                  string internal constant CONFIG_HASH_TAG = "STARKNET_1.0_STARKNET_CONFIG_HASH";
                  function setProgramHash(uint256 newProgramHash) external notFinalized onlyGovernance {
                      emit ProgramHashChanged(msg.sender, programHash(), newProgramHash);
                      programHash(newProgramHash);
                  }
                  function setConfigHash(uint256 newConfigHash) external notFinalized onlyGovernance {
                      emit ConfigHashChanged(msg.sender, configHash(), newConfigHash);
                      configHash(newConfigHash);
                  }
                  function setMessageCancellationDelay(uint256 delayInSeconds)
                      external
                      notFinalized
                      onlyGovernance
                  {
                      messageCancellationDelay(delayInSeconds);
                  }
                  // State variable "programHash" read-access function.
                  function programHash() public view returns (uint256) {
                      return NamedStorage.getUintValue(PROGRAM_HASH_TAG);
                  }
                  // State variable "programHash" write-access function.
                  function programHash(uint256 value) internal {
                      NamedStorage.setUintValue(PROGRAM_HASH_TAG, value);
                  }
                  // State variable "verifier" access function.
                  function verifier() internal view returns (address) {
                      return NamedStorage.getAddressValue(VERIFIER_ADDRESS_TAG);
                  }
                  // State variable "configHash" write-access function.
                  function configHash(uint256 value) internal {
                      NamedStorage.setUintValue(CONFIG_HASH_TAG, value);
                  }
                  // State variable "configHash" read-access function.
                  function configHash() public view returns (uint256) {
                      return NamedStorage.getUintValue(CONFIG_HASH_TAG);
                  }
                  function setVerifierAddress(address value) internal {
                      NamedStorage.setAddressValueOnce(VERIFIER_ADDRESS_TAG, value);
                  }
                  // State variable "state" access function.
                  function state() internal pure returns (StarknetState.State storage stateStruct) {
                      bytes32 location = keccak256(abi.encodePacked(STATE_STRUCT_TAG));
                      assembly {
                          stateStruct_slot := location
                      }
                  }
                  function isInitialized() internal view override returns (bool) {
                      return programHash() != 0;
                  }
                  function numOfSubContracts() internal pure override returns (uint256) {
                      return 0;
                  }
                  function validateInitData(bytes calldata data) internal view override {
                      require(data.length == 6 * 32, "ILLEGAL_INIT_DATA_SIZE");
                      uint256 programHash_ = abi.decode(data[:32], (uint256));
                      require(programHash_ != 0, "BAD_INITIALIZATION");
                  }
                  function processSubContractAddresses(bytes calldata subContractAddresses) internal override {}
                  function initializeContractState(bytes calldata data) internal override {
                      (
                          uint256 programHash_,
                          address verifier_,
                          uint256 configHash_,
                          StarknetState.State memory initialState
                      ) = abi.decode(data, (uint256, address, uint256, StarknetState.State));
                      programHash(programHash_);
                      setVerifierAddress(verifier_);
                      state().copy(initialState);
                      configHash(configHash_);
                      messageCancellationDelay(5 days);
                  }
                  /**
                    Returns a string that identifies the contract.
                  */
                  function identify() external pure override returns (string memory) {
                      return "StarkWare_Starknet_2023_6";
                  }
                  /**
                    Returns the current state root.
                  */
                  function stateRoot() external view returns (uint256) {
                      return state().globalRoot;
                  }
                  /**
                    Returns the current block number.
                  */
                  function stateBlockNumber() external view returns (int256) {
                      return state().blockNumber;
                  }
                  /**
                    Returns the current block hash.
                  */
                  function stateBlockHash() external view returns (uint256) {
                      return state().blockHash;
                  }
                  /**
                    Updates the state of the StarkNet, based on a proof of the
                    StarkNet OS that the state transition is valid.
                    Arguments:
                      programOutput - The main part of the StarkNet OS program output.
                      data_availability_fact - An encoding of the on-chain data associated
                      with the 'programOutput'.
                  */
                  function updateState(
                      uint256[] calldata programOutput,
                      uint256 onchainDataHash,
                      uint256 onchainDataSize
                  ) external onlyOperator {
                      // We protect against re-entrancy attacks by reading the block number at the beginning
                      // and validating that we have the expected block number at the end.
                      int256 initialBlockNumber = state().blockNumber;
                      // Validate program output.
                      StarknetOutput.validate(programOutput);
                      // Validate config hash.
                      require(
                          configHash() == programOutput[StarknetOutput.CONFIG_HASH_OFFSET],
                          "INVALID_CONFIG_HASH"
                      );
                      bytes32 stateTransitionFact = OnchainDataFactTreeEncoder.encodeFactWithOnchainData(
                          programOutput,
                          OnchainDataFactTreeEncoder.DataAvailabilityFact(onchainDataHash, onchainDataSize)
                      );
                      bytes32 sharpFact = keccak256(abi.encode(programHash(), stateTransitionFact));
                      require(IFactRegistry(verifier()).isValid(sharpFact), "NO_STATE_TRANSITION_PROOF");
                      emit LogStateTransitionFact(stateTransitionFact);
                      // Perform state update.
                      state().update(programOutput);
                      // Process the messages after updating the state.
                      // This is safer, as there is a call to transfer the fees during
                      // the processing of the L1 -> L2 messages.
                      // Process L2 -> L1 messages.
                      uint256 outputOffset = StarknetOutput.HEADER_SIZE;
                      outputOffset += StarknetOutput.processMessages(
                          // isL2ToL1=
                          true,
                          programOutput[outputOffset:],
                          l2ToL1Messages()
                      );
                      // Process L1 -> L2 messages.
                      outputOffset += StarknetOutput.processMessages(
                          // isL2ToL1=
                          false,
                          programOutput[outputOffset:],
                          l1ToL2Messages()
                      );
                      require(outputOffset == programOutput.length, "STARKNET_OUTPUT_TOO_LONG");
                      // Note that processing L1 -> L2 messages does an external call, and it shouldn't be
                      // followed by storage changes.
                      StarknetState.State storage state_ = state();
                      emit LogStateUpdate(state_.globalRoot, state_.blockNumber, state_.blockHash);
                      // Re-entrancy protection (see above).
                      require(state_.blockNumber == initialBlockNumber + 1, "INVALID_FINAL_BLOCK_NUMBER");
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Governance.sol";
              contract StarknetGovernance is Governance {
                  string constant STARKNET_GOVERNANCE_INFO_TAG = "STARKNET_1.0_GOVERNANCE_INFO";
                  /*
                    Returns the GovernanceInfoStruct associated with the governance tag.
                  */
                  function getGovernanceInfo() internal view override returns (GovernanceInfoStruct storage gub) {
                      bytes32 location = keccak256(abi.encodePacked(STARKNET_GOVERNANCE_INFO_TAG));
                      assembly {
                          gub_slot := location
                      }
                  }
                  function starknetIsGovernor(address user) external view returns (bool) {
                      return _isGovernor(user);
                  }
                  function starknetNominateNewGovernor(address newGovernor) external {
                      _nominateNewGovernor(newGovernor);
                  }
                  function starknetRemoveGovernor(address governorForRemoval) external {
                      _removeGovernor(governorForRemoval);
                  }
                  function starknetAcceptGovernance() external {
                      _acceptGovernance();
                  }
                  function starknetCancelNomination() external {
                      _cancelNomination();
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "IStarknetMessaging.sol";
              import "NamedStorage.sol";
              /**
                Implements sending messages to L2 by adding them to a pipe and consuming messages from L2 by
                removing them from a different pipe. A deriving contract can handle the former pipe and add items
                to the latter pipe while interacting with L2.
              */
              contract StarknetMessaging is IStarknetMessaging {
                  /*
                    Random slot storage elements and accessors.
                  */
                  string constant L1L2_MESSAGE_MAP_TAG = "STARKNET_1.0_MSGING_L1TOL2_MAPPPING_V2";
                  string constant L2L1_MESSAGE_MAP_TAG = "STARKNET_1.0_MSGING_L2TOL1_MAPPPING";
                  string constant L1L2_MESSAGE_NONCE_TAG = "STARKNET_1.0_MSGING_L1TOL2_NONCE";
                  string constant L1L2_MESSAGE_CANCELLATION_MAP_TAG = (
                      "STARKNET_1.0_MSGING_L1TOL2_CANCELLATION_MAPPPING"
                  );
                  string constant L1L2_MESSAGE_CANCELLATION_DELAY_TAG = (
                      "STARKNET_1.0_MSGING_L1TOL2_CANCELLATION_DELAY"
                  );
                  uint256 constant MAX_L1_MSG_FEE = 1 ether;
                  function getMaxL1MsgFee() public pure override returns (uint256) {
                      return MAX_L1_MSG_FEE;
                  }
                  /**
                    Returns the msg_fee + 1 for the message with the given 'msgHash',
                    or 0 if no message with such a hash is pending.
                  */
                  function l1ToL2Messages(bytes32 msgHash) external view returns (uint256) {
                      return l1ToL2Messages()[msgHash];
                  }
                  function l2ToL1Messages(bytes32 msgHash) external view returns (uint256) {
                      return l2ToL1Messages()[msgHash];
                  }
                  function l1ToL2Messages() internal pure returns (mapping(bytes32 => uint256) storage) {
                      return NamedStorage.bytes32ToUint256Mapping(L1L2_MESSAGE_MAP_TAG);
                  }
                  function l2ToL1Messages() internal pure returns (mapping(bytes32 => uint256) storage) {
                      return NamedStorage.bytes32ToUint256Mapping(L2L1_MESSAGE_MAP_TAG);
                  }
                  function l1ToL2MessageNonce() public view returns (uint256) {
                      return NamedStorage.getUintValue(L1L2_MESSAGE_NONCE_TAG);
                  }
                  function messageCancellationDelay() public view returns (uint256) {
                      return NamedStorage.getUintValue(L1L2_MESSAGE_CANCELLATION_DELAY_TAG);
                  }
                  function messageCancellationDelay(uint256 delayInSeconds) internal {
                      NamedStorage.setUintValue(L1L2_MESSAGE_CANCELLATION_DELAY_TAG, delayInSeconds);
                  }
                  /**
                    Returns the timestamp at the time cancelL1ToL2Message was called with a message
                    matching 'msgHash'.
                    The function returns 0 if cancelL1ToL2Message was never called.
                  */
                  function l1ToL2MessageCancellations(bytes32 msgHash) external view returns (uint256) {
                      return l1ToL2MessageCancellations()[msgHash];
                  }
                  function l1ToL2MessageCancellations()
                      internal
                      pure
                      returns (mapping(bytes32 => uint256) storage)
                  {
                      return NamedStorage.bytes32ToUint256Mapping(L1L2_MESSAGE_CANCELLATION_MAP_TAG);
                  }
                  /**
                    Returns the hash of an L1 -> L2 message from msg.sender.
                  */
                  function getL1ToL2MsgHash(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) internal view returns (bytes32) {
                      return
                          keccak256(
                              abi.encodePacked(
                                  uint256(msg.sender),
                                  toAddress,
                                  nonce,
                                  selector,
                                  payload.length,
                                  payload
                              )
                          );
                  }
                  /**
                    Sends a message to an L2 contract.
                  */
                  function sendMessageToL2(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload
                  ) external payable override returns (bytes32, uint256) {
                      require(msg.value > 0, "L1_MSG_FEE_MUST_BE_GREATER_THAN_0");
                      require(msg.value <= getMaxL1MsgFee(), "MAX_L1_MSG_FEE_EXCEEDED");
                      uint256 nonce = l1ToL2MessageNonce();
                      NamedStorage.setUintValue(L1L2_MESSAGE_NONCE_TAG, nonce + 1);
                      emit LogMessageToL2(msg.sender, toAddress, selector, payload, nonce, msg.value);
                      bytes32 msgHash = getL1ToL2MsgHash(toAddress, selector, payload, nonce);
                      // Note that the inclusion of the unique nonce in the message hash implies that
                      // l1ToL2Messages()[msgHash] was not accessed before.
                      l1ToL2Messages()[msgHash] = msg.value + 1;
                      return (msgHash, nonce);
                  }
                  /**
                    Consumes a message that was sent from an L2 contract.
                    Returns the hash of the message.
                  */
                  function consumeMessageFromL2(uint256 fromAddress, uint256[] calldata payload)
                      external
                      override
                      returns (bytes32)
                  {
                      bytes32 msgHash = keccak256(
                          abi.encodePacked(fromAddress, uint256(msg.sender), payload.length, payload)
                      );
                      require(l2ToL1Messages()[msgHash] > 0, "INVALID_MESSAGE_TO_CONSUME");
                      emit ConsumedMessageToL1(fromAddress, msg.sender, payload);
                      l2ToL1Messages()[msgHash] -= 1;
                      return msgHash;
                  }
                  function startL1ToL2MessageCancellation(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) external override returns (bytes32) {
                      emit MessageToL2CancellationStarted(msg.sender, toAddress, selector, payload, nonce);
                      bytes32 msgHash = getL1ToL2MsgHash(toAddress, selector, payload, nonce);
                      uint256 msgFeePlusOne = l1ToL2Messages()[msgHash];
                      require(msgFeePlusOne > 0, "NO_MESSAGE_TO_CANCEL");
                      l1ToL2MessageCancellations()[msgHash] = block.timestamp;
                      return msgHash;
                  }
                  function cancelL1ToL2Message(
                      uint256 toAddress,
                      uint256 selector,
                      uint256[] calldata payload,
                      uint256 nonce
                  ) external override returns (bytes32) {
                      emit MessageToL2Canceled(msg.sender, toAddress, selector, payload, nonce);
                      // Note that the message hash depends on msg.sender, which prevents one contract from
                      // cancelling another contract's message.
                      // Trying to do so will result in NO_MESSAGE_TO_CANCEL.
                      bytes32 msgHash = getL1ToL2MsgHash(toAddress, selector, payload, nonce);
                      uint256 msgFeePlusOne = l1ToL2Messages()[msgHash];
                      require(msgFeePlusOne != 0, "NO_MESSAGE_TO_CANCEL");
                      uint256 requestTime = l1ToL2MessageCancellations()[msgHash];
                      require(requestTime != 0, "MESSAGE_CANCELLATION_NOT_REQUESTED");
                      uint256 cancelAllowedTime = requestTime + messageCancellationDelay();
                      require(cancelAllowedTime >= requestTime, "CANCEL_ALLOWED_TIME_OVERFLOW");
                      require(block.timestamp >= cancelAllowedTime, "MESSAGE_CANCELLATION_NOT_ALLOWED_YET");
                      l1ToL2Messages()[msgHash] = 0;
                      return (msgHash);
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Operator.sol";
              import "NamedStorage.sol";
              abstract contract StarknetOperator is Operator {
                  string constant OPERATORS_MAPPING_TAG = "STARKNET_1.0_ROLES_OPERATORS_MAPPING_TAG";
                  function getOperators() internal view override returns (mapping(address => bool) storage) {
                      return NamedStorage.addressToBoolMapping(OPERATORS_MAPPING_TAG);
                  }
              }
              /*
                Copyright 2019-2022 StarkWare Industries Ltd.
                Licensed under the Apache License, Version 2.0 (the "License").
                You may not use this file except in compliance with the License.
                You may obtain a copy of the License at
                https://www.starkware.co/open-source-license/
                Unless required by applicable law or agreed to in writing,
                software distributed under the License is distributed on an "AS IS" BASIS,
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                See the License for the specific language governing permissions
                and limitations under the License.
              */
              // SPDX-License-Identifier: Apache-2.0.
              pragma solidity ^0.6.12;
              import "Output.sol";
              library StarknetState {
                  struct State {
                      uint256 globalRoot;
                      int256 blockNumber;
                      uint256 blockHash;
                  }
                  function copy(State storage state, State memory stateFrom) internal {
                      state.globalRoot = stateFrom.globalRoot;
                      state.blockNumber = stateFrom.blockNumber;
                      state.blockHash = stateFrom.blockHash;
                  }
                  /**
                    Validates that the 'blockNumber' and the previous root are consistent with the
                    current state and updates the state.
                  */
                  function update(State storage state, uint256[] calldata starknetOutput) internal {
                      // Check the blockNumber first as the error is less ambiguous then INVALID_PREVIOUS_ROOT.
                      state.blockNumber += 1;
                      require(
                          uint256(state.blockNumber) == starknetOutput[StarknetOutput.BLOCK_NUMBER_OFFSET],
                          "INVALID_BLOCK_NUMBER"
                      );
                      state.blockHash = starknetOutput[StarknetOutput.BLOCK_HASH_OFFSET];
                      uint256[] calldata commitment_tree_update = StarknetOutput.getMerkleUpdate(starknetOutput);
                      require(
                          state.globalRoot == CommitmentTreeUpdateOutput.getPrevRoot(commitment_tree_update),
                          "INVALID_PREVIOUS_ROOT"
                      );
                      state.globalRoot = CommitmentTreeUpdateOutput.getNewRoot(commitment_tree_update);
                  }
              }
              

              File 6 of 6: FiatTokenV2_1
              // File: @openzeppelin/contracts/math/SafeMath.sol
              
              // SPDX-License-Identifier: MIT
              
              pragma solidity ^0.6.0;
              
              /**
               * @dev Wrappers over Solidity's arithmetic operations with added overflow
               * checks.
               *
               * Arithmetic operations in Solidity wrap on overflow. This can easily result
               * in bugs, because programmers usually assume that an overflow raises an
               * error, which is the standard behavior in high level programming languages.
               * `SafeMath` restores this intuition by reverting the transaction when an
               * operation overflows.
               *
               * Using this library instead of the unchecked operations eliminates an entire
               * class of bugs, so it's recommended to use it always.
               */
              library SafeMath {
                  /**
                   * @dev Returns the addition of two unsigned integers, reverting on
                   * overflow.
                   *
                   * Counterpart to Solidity's `+` operator.
                   *
                   * Requirements:
                   *
                   * - Addition cannot overflow.
                   */
                  function add(uint256 a, uint256 b) internal pure returns (uint256) {
                      uint256 c = a + b;
                      require(c >= a, "SafeMath: addition overflow");
              
                      return c;
                  }
              
                  /**
                   * @dev Returns the subtraction of two unsigned integers, reverting on
                   * overflow (when the result is negative).
                   *
                   * Counterpart to Solidity's `-` operator.
                   *
                   * Requirements:
                   *
                   * - Subtraction cannot overflow.
                   */
                  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
                      return sub(a, b, "SafeMath: subtraction overflow");
                  }
              
                  /**
                   * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
                   * overflow (when the result is negative).
                   *
                   * Counterpart to Solidity's `-` operator.
                   *
                   * Requirements:
                   *
                   * - Subtraction cannot overflow.
                   */
                  function sub(
                      uint256 a,
                      uint256 b,
                      string memory errorMessage
                  ) internal pure returns (uint256) {
                      require(b <= a, errorMessage);
                      uint256 c = a - b;
              
                      return c;
                  }
              
                  /**
                   * @dev Returns the multiplication of two unsigned integers, reverting on
                   * overflow.
                   *
                   * Counterpart to Solidity's `*` operator.
                   *
                   * Requirements:
                   *
                   * - Multiplication cannot overflow.
                   */
                  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
                      // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
                      // benefit is lost if 'b' is also tested.
                      // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
                      if (a == 0) {
                          return 0;
                      }
              
                      uint256 c = a * b;
                      require(c / a == b, "SafeMath: multiplication overflow");
              
                      return c;
                  }
              
                  /**
                   * @dev Returns the integer division of two unsigned integers. Reverts on
                   * division by zero. The result is rounded towards zero.
                   *
                   * Counterpart to Solidity's `/` operator. Note: this function uses a
                   * `revert` opcode (which leaves remaining gas untouched) while Solidity
                   * uses an invalid opcode to revert (consuming all remaining gas).
                   *
                   * Requirements:
                   *
                   * - The divisor cannot be zero.
                   */
                  function div(uint256 a, uint256 b) internal pure returns (uint256) {
                      return div(a, b, "SafeMath: division by zero");
                  }
              
                  /**
                   * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
                   * division by zero. The result is rounded towards zero.
                   *
                   * Counterpart to Solidity's `/` operator. Note: this function uses a
                   * `revert` opcode (which leaves remaining gas untouched) while Solidity
                   * uses an invalid opcode to revert (consuming all remaining gas).
                   *
                   * Requirements:
                   *
                   * - The divisor cannot be zero.
                   */
                  function div(
                      uint256 a,
                      uint256 b,
                      string memory errorMessage
                  ) internal pure returns (uint256) {
                      require(b > 0, errorMessage);
                      uint256 c = a / b;
                      // assert(a == b * c + a % b); // There is no case in which this doesn't hold
              
                      return c;
                  }
              
                  /**
                   * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
                   * Reverts when dividing by zero.
                   *
                   * Counterpart to Solidity's `%` operator. This function uses a `revert`
                   * opcode (which leaves remaining gas untouched) while Solidity uses an
                   * invalid opcode to revert (consuming all remaining gas).
                   *
                   * Requirements:
                   *
                   * - The divisor cannot be zero.
                   */
                  function mod(uint256 a, uint256 b) internal pure returns (uint256) {
                      return mod(a, b, "SafeMath: modulo by zero");
                  }
              
                  /**
                   * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
                   * Reverts with custom message when dividing by zero.
                   *
                   * Counterpart to Solidity's `%` operator. This function uses a `revert`
                   * opcode (which leaves remaining gas untouched) while Solidity uses an
                   * invalid opcode to revert (consuming all remaining gas).
                   *
                   * Requirements:
                   *
                   * - The divisor cannot be zero.
                   */
                  function mod(
                      uint256 a,
                      uint256 b,
                      string memory errorMessage
                  ) internal pure returns (uint256) {
                      require(b != 0, errorMessage);
                      return a % b;
                  }
              }
              
              // File: @openzeppelin/contracts/token/ERC20/IERC20.sol
              
              pragma solidity ^0.6.0;
              
              /**
               * @dev Interface of the ERC20 standard as defined in the EIP.
               */
              interface IERC20 {
                  /**
                   * @dev Returns the amount of tokens in existence.
                   */
                  function totalSupply() external view returns (uint256);
              
                  /**
                   * @dev Returns the amount of tokens owned by `account`.
                   */
                  function balanceOf(address account) external view returns (uint256);
              
                  /**
                   * @dev Moves `amount` tokens from the caller's account to `recipient`.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transfer(address recipient, uint256 amount)
                      external
                      returns (bool);
              
                  /**
                   * @dev Returns the remaining number of tokens that `spender` will be
                   * allowed to spend on behalf of `owner` through {transferFrom}. This is
                   * zero by default.
                   *
                   * This value changes when {approve} or {transferFrom} are called.
                   */
                  function allowance(address owner, address spender)
                      external
                      view
                      returns (uint256);
              
                  /**
                   * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * IMPORTANT: Beware that changing an allowance with this method brings the risk
                   * that someone may use both the old and the new allowance by unfortunate
                   * transaction ordering. One possible solution to mitigate this race
                   * condition is to first reduce the spender's allowance to 0 and set the
                   * desired value afterwards:
                   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
                   *
                   * Emits an {Approval} event.
                   */
                  function approve(address spender, uint256 amount) external returns (bool);
              
                  /**
                   * @dev Moves `amount` tokens from `sender` to `recipient` using the
                   * allowance mechanism. `amount` is then deducted from the caller's
                   * allowance.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transferFrom(
                      address sender,
                      address recipient,
                      uint256 amount
                  ) external returns (bool);
              
                  /**
                   * @dev Emitted when `value` tokens are moved from one account (`from`) to
                   * another (`to`).
                   *
                   * Note that `value` may be zero.
                   */
                  event Transfer(address indexed from, address indexed to, uint256 value);
              
                  /**
                   * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                   * a call to {approve}. `value` is the new allowance.
                   */
                  event Approval(
                      address indexed owner,
                      address indexed spender,
                      uint256 value
                  );
              }
              
              // File: contracts/v1/AbstractFiatTokenV1.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              abstract contract AbstractFiatTokenV1 is IERC20 {
                  function _approve(
                      address owner,
                      address spender,
                      uint256 value
                  ) internal virtual;
              
                  function _transfer(
                      address from,
                      address to,
                      uint256 value
                  ) internal virtual;
              }
              
              // File: contracts/v1/Ownable.sol
              
              /**
               * Copyright (c) 2018 zOS Global Limited.
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              pragma solidity 0.6.12;
              
              /**
               * @notice The Ownable contract has an owner address, and provides basic
               * authorization control functions
               * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-labs/blob/3887ab77b8adafba4a26ace002f3a684c1a3388b/upgradeability_ownership/contracts/ownership/Ownable.sol
               * Modifications:
               * 1. Consolidate OwnableStorage into this contract (7/13/18)
               * 2. Reformat, conform to Solidity 0.6 syntax, and add error messages (5/13/20)
               * 3. Make public functions external (5/27/20)
               */
              contract Ownable {
                  // Owner of the contract
                  address private _owner;
              
                  /**
                   * @dev Event to show ownership has been transferred
                   * @param previousOwner representing the address of the previous owner
                   * @param newOwner representing the address of the new owner
                   */
                  event OwnershipTransferred(address previousOwner, address newOwner);
              
                  /**
                   * @dev The constructor sets the original owner of the contract to the sender account.
                   */
                  constructor() public {
                      setOwner(msg.sender);
                  }
              
                  /**
                   * @dev Tells the address of the owner
                   * @return the address of the owner
                   */
                  function owner() external view returns (address) {
                      return _owner;
                  }
              
                  /**
                   * @dev Sets a new owner address
                   */
                  function setOwner(address newOwner) internal {
                      _owner = newOwner;
                  }
              
                  /**
                   * @dev Throws if called by any account other than the owner.
                   */
                  modifier onlyOwner() {
                      require(msg.sender == _owner, "Ownable: caller is not the owner");
                      _;
                  }
              
                  /**
                   * @dev Allows the current owner to transfer control of the contract to a newOwner.
                   * @param newOwner The address to transfer ownership to.
                   */
                  function transferOwnership(address newOwner) external onlyOwner {
                      require(
                          newOwner != address(0),
                          "Ownable: new owner is the zero address"
                      );
                      emit OwnershipTransferred(_owner, newOwner);
                      setOwner(newOwner);
                  }
              }
              
              // File: contracts/v1/Pausable.sol
              
              /**
               * Copyright (c) 2016 Smart Contract Solutions, Inc.
               * Copyright (c) 2018-2020 CENTRE SECZ0
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @notice Base contract which allows children to implement an emergency stop
               * mechanism
               * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/feb665136c0dae9912e08397c1a21c4af3651ef3/contracts/lifecycle/Pausable.sol
               * Modifications:
               * 1. Added pauser role, switched pause/unpause to be onlyPauser (6/14/2018)
               * 2. Removed whenNotPause/whenPaused from pause/unpause (6/14/2018)
               * 3. Removed whenPaused (6/14/2018)
               * 4. Switches ownable library to use ZeppelinOS (7/12/18)
               * 5. Remove constructor (7/13/18)
               * 6. Reformat, conform to Solidity 0.6 syntax and add error messages (5/13/20)
               * 7. Make public functions external (5/27/20)
               */
              contract Pausable is Ownable {
                  event Pause();
                  event Unpause();
                  event PauserChanged(address indexed newAddress);
              
                  address public pauser;
                  bool public paused = false;
              
                  /**
                   * @dev Modifier to make a function callable only when the contract is not paused.
                   */
                  modifier whenNotPaused() {
                      require(!paused, "Pausable: paused");
                      _;
                  }
              
                  /**
                   * @dev throws if called by any account other than the pauser
                   */
                  modifier onlyPauser() {
                      require(msg.sender == pauser, "Pausable: caller is not the pauser");
                      _;
                  }
              
                  /**
                   * @dev called by the owner to pause, triggers stopped state
                   */
                  function pause() external onlyPauser {
                      paused = true;
                      emit Pause();
                  }
              
                  /**
                   * @dev called by the owner to unpause, returns to normal state
                   */
                  function unpause() external onlyPauser {
                      paused = false;
                      emit Unpause();
                  }
              
                  /**
                   * @dev update the pauser role
                   */
                  function updatePauser(address _newPauser) external onlyOwner {
                      require(
                          _newPauser != address(0),
                          "Pausable: new pauser is the zero address"
                      );
                      pauser = _newPauser;
                      emit PauserChanged(pauser);
                  }
              }
              
              // File: contracts/v1/Blacklistable.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title Blacklistable Token
               * @dev Allows accounts to be blacklisted by a "blacklister" role
               */
              contract Blacklistable is Ownable {
                  address public blacklister;
                  mapping(address => bool) internal blacklisted;
              
                  event Blacklisted(address indexed _account);
                  event UnBlacklisted(address indexed _account);
                  event BlacklisterChanged(address indexed newBlacklister);
              
                  /**
                   * @dev Throws if called by any account other than the blacklister
                   */
                  modifier onlyBlacklister() {
                      require(
                          msg.sender == blacklister,
                          "Blacklistable: caller is not the blacklister"
                      );
                      _;
                  }
              
                  /**
                   * @dev Throws if argument account is blacklisted
                   * @param _account The address to check
                   */
                  modifier notBlacklisted(address _account) {
                      require(
                          !blacklisted[_account],
                          "Blacklistable: account is blacklisted"
                      );
                      _;
                  }
              
                  /**
                   * @dev Checks if account is blacklisted
                   * @param _account The address to check
                   */
                  function isBlacklisted(address _account) external view returns (bool) {
                      return blacklisted[_account];
                  }
              
                  /**
                   * @dev Adds account to blacklist
                   * @param _account The address to blacklist
                   */
                  function blacklist(address _account) external onlyBlacklister {
                      blacklisted[_account] = true;
                      emit Blacklisted(_account);
                  }
              
                  /**
                   * @dev Removes account from blacklist
                   * @param _account The address to remove from the blacklist
                   */
                  function unBlacklist(address _account) external onlyBlacklister {
                      blacklisted[_account] = false;
                      emit UnBlacklisted(_account);
                  }
              
                  function updateBlacklister(address _newBlacklister) external onlyOwner {
                      require(
                          _newBlacklister != address(0),
                          "Blacklistable: new blacklister is the zero address"
                      );
                      blacklister = _newBlacklister;
                      emit BlacklisterChanged(blacklister);
                  }
              }
              
              // File: contracts/v1/FiatTokenV1.sol
              
              /**
               *
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title FiatToken
               * @dev ERC20 Token backed by fiat reserves
               */
              contract FiatTokenV1 is AbstractFiatTokenV1, Ownable, Pausable, Blacklistable {
                  using SafeMath for uint256;
              
                  string public name;
                  string public symbol;
                  uint8 public decimals;
                  string public currency;
                  address public masterMinter;
                  bool internal initialized;
              
                  mapping(address => uint256) internal balances;
                  mapping(address => mapping(address => uint256)) internal allowed;
                  uint256 internal totalSupply_ = 0;
                  mapping(address => bool) internal minters;
                  mapping(address => uint256) internal minterAllowed;
              
                  event Mint(address indexed minter, address indexed to, uint256 amount);
                  event Burn(address indexed burner, uint256 amount);
                  event MinterConfigured(address indexed minter, uint256 minterAllowedAmount);
                  event MinterRemoved(address indexed oldMinter);
                  event MasterMinterChanged(address indexed newMasterMinter);
              
                  function initialize(
                      string memory tokenName,
                      string memory tokenSymbol,
                      string memory tokenCurrency,
                      uint8 tokenDecimals,
                      address newMasterMinter,
                      address newPauser,
                      address newBlacklister,
                      address newOwner
                  ) public {
                      require(!initialized, "FiatToken: contract is already initialized");
                      require(
                          newMasterMinter != address(0),
                          "FiatToken: new masterMinter is the zero address"
                      );
                      require(
                          newPauser != address(0),
                          "FiatToken: new pauser is the zero address"
                      );
                      require(
                          newBlacklister != address(0),
                          "FiatToken: new blacklister is the zero address"
                      );
                      require(
                          newOwner != address(0),
                          "FiatToken: new owner is the zero address"
                      );
              
                      name = tokenName;
                      symbol = tokenSymbol;
                      currency = tokenCurrency;
                      decimals = tokenDecimals;
                      masterMinter = newMasterMinter;
                      pauser = newPauser;
                      blacklister = newBlacklister;
                      setOwner(newOwner);
                      initialized = true;
                  }
              
                  /**
                   * @dev Throws if called by any account other than a minter
                   */
                  modifier onlyMinters() {
                      require(minters[msg.sender], "FiatToken: caller is not a minter");
                      _;
                  }
              
                  /**
                   * @dev Function to mint tokens
                   * @param _to The address that will receive the minted tokens.
                   * @param _amount The amount of tokens to mint. Must be less than or equal
                   * to the minterAllowance of the caller.
                   * @return A boolean that indicates if the operation was successful.
                   */
                  function mint(address _to, uint256 _amount)
                      external
                      whenNotPaused
                      onlyMinters
                      notBlacklisted(msg.sender)
                      notBlacklisted(_to)
                      returns (bool)
                  {
                      require(_to != address(0), "FiatToken: mint to the zero address");
                      require(_amount > 0, "FiatToken: mint amount not greater than 0");
              
                      uint256 mintingAllowedAmount = minterAllowed[msg.sender];
                      require(
                          _amount <= mintingAllowedAmount,
                          "FiatToken: mint amount exceeds minterAllowance"
                      );
              
                      totalSupply_ = totalSupply_.add(_amount);
                      balances[_to] = balances[_to].add(_amount);
                      minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount);
                      emit Mint(msg.sender, _to, _amount);
                      emit Transfer(address(0), _to, _amount);
                      return true;
                  }
              
                  /**
                   * @dev Throws if called by any account other than the masterMinter
                   */
                  modifier onlyMasterMinter() {
                      require(
                          msg.sender == masterMinter,
                          "FiatToken: caller is not the masterMinter"
                      );
                      _;
                  }
              
                  /**
                   * @dev Get minter allowance for an account
                   * @param minter The address of the minter
                   */
                  function minterAllowance(address minter) external view returns (uint256) {
                      return minterAllowed[minter];
                  }
              
                  /**
                   * @dev Checks if account is a minter
                   * @param account The address to check
                   */
                  function isMinter(address account) external view returns (bool) {
                      return minters[account];
                  }
              
                  /**
                   * @notice Amount of remaining tokens spender is allowed to transfer on
                   * behalf of the token owner
                   * @param owner     Token owner's address
                   * @param spender   Spender's address
                   * @return Allowance amount
                   */
                  function allowance(address owner, address spender)
                      external
                      override
                      view
                      returns (uint256)
                  {
                      return allowed[owner][spender];
                  }
              
                  /**
                   * @dev Get totalSupply of token
                   */
                  function totalSupply() external override view returns (uint256) {
                      return totalSupply_;
                  }
              
                  /**
                   * @dev Get token balance of an account
                   * @param account address The account
                   */
                  function balanceOf(address account)
                      external
                      override
                      view
                      returns (uint256)
                  {
                      return balances[account];
                  }
              
                  /**
                   * @notice Set spender's allowance over the caller's tokens to be a given
                   * value.
                   * @param spender   Spender's address
                   * @param value     Allowance amount
                   * @return True if successful
                   */
                  function approve(address spender, uint256 value)
                      external
                      override
                      whenNotPaused
                      notBlacklisted(msg.sender)
                      notBlacklisted(spender)
                      returns (bool)
                  {
                      _approve(msg.sender, spender, value);
                      return true;
                  }
              
                  /**
                   * @dev Internal function to set allowance
                   * @param owner     Token owner's address
                   * @param spender   Spender's address
                   * @param value     Allowance amount
                   */
                  function _approve(
                      address owner,
                      address spender,
                      uint256 value
                  ) internal override {
                      require(owner != address(0), "ERC20: approve from the zero address");
                      require(spender != address(0), "ERC20: approve to the zero address");
                      allowed[owner][spender] = value;
                      emit Approval(owner, spender, value);
                  }
              
                  /**
                   * @notice Transfer tokens by spending allowance
                   * @param from  Payer's address
                   * @param to    Payee's address
                   * @param value Transfer amount
                   * @return True if successful
                   */
                  function transferFrom(
                      address from,
                      address to,
                      uint256 value
                  )
                      external
                      override
                      whenNotPaused
                      notBlacklisted(msg.sender)
                      notBlacklisted(from)
                      notBlacklisted(to)
                      returns (bool)
                  {
                      require(
                          value <= allowed[from][msg.sender],
                          "ERC20: transfer amount exceeds allowance"
                      );
                      _transfer(from, to, value);
                      allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
                      return true;
                  }
              
                  /**
                   * @notice Transfer tokens from the caller
                   * @param to    Payee's address
                   * @param value Transfer amount
                   * @return True if successful
                   */
                  function transfer(address to, uint256 value)
                      external
                      override
                      whenNotPaused
                      notBlacklisted(msg.sender)
                      notBlacklisted(to)
                      returns (bool)
                  {
                      _transfer(msg.sender, to, value);
                      return true;
                  }
              
                  /**
                   * @notice Internal function to process transfers
                   * @param from  Payer's address
                   * @param to    Payee's address
                   * @param value Transfer amount
                   */
                  function _transfer(
                      address from,
                      address to,
                      uint256 value
                  ) internal override {
                      require(from != address(0), "ERC20: transfer from the zero address");
                      require(to != address(0), "ERC20: transfer to the zero address");
                      require(
                          value <= balances[from],
                          "ERC20: transfer amount exceeds balance"
                      );
              
                      balances[from] = balances[from].sub(value);
                      balances[to] = balances[to].add(value);
                      emit Transfer(from, to, value);
                  }
              
                  /**
                   * @dev Function to add/update a new minter
                   * @param minter The address of the minter
                   * @param minterAllowedAmount The minting amount allowed for the minter
                   * @return True if the operation was successful.
                   */
                  function configureMinter(address minter, uint256 minterAllowedAmount)
                      external
                      whenNotPaused
                      onlyMasterMinter
                      returns (bool)
                  {
                      minters[minter] = true;
                      minterAllowed[minter] = minterAllowedAmount;
                      emit MinterConfigured(minter, minterAllowedAmount);
                      return true;
                  }
              
                  /**
                   * @dev Function to remove a minter
                   * @param minter The address of the minter to remove
                   * @return True if the operation was successful.
                   */
                  function removeMinter(address minter)
                      external
                      onlyMasterMinter
                      returns (bool)
                  {
                      minters[minter] = false;
                      minterAllowed[minter] = 0;
                      emit MinterRemoved(minter);
                      return true;
                  }
              
                  /**
                   * @dev allows a minter to burn some of its own tokens
                   * Validates that caller is a minter and that sender is not blacklisted
                   * amount is less than or equal to the minter's account balance
                   * @param _amount uint256 the amount of tokens to be burned
                   */
                  function burn(uint256 _amount)
                      external
                      whenNotPaused
                      onlyMinters
                      notBlacklisted(msg.sender)
                  {
                      uint256 balance = balances[msg.sender];
                      require(_amount > 0, "FiatToken: burn amount not greater than 0");
                      require(balance >= _amount, "FiatToken: burn amount exceeds balance");
              
                      totalSupply_ = totalSupply_.sub(_amount);
                      balances[msg.sender] = balance.sub(_amount);
                      emit Burn(msg.sender, _amount);
                      emit Transfer(msg.sender, address(0), _amount);
                  }
              
                  function updateMasterMinter(address _newMasterMinter) external onlyOwner {
                      require(
                          _newMasterMinter != address(0),
                          "FiatToken: new masterMinter is the zero address"
                      );
                      masterMinter = _newMasterMinter;
                      emit MasterMinterChanged(masterMinter);
                  }
              }
              
              // File: @openzeppelin/contracts/utils/Address.sol
              
              pragma solidity ^0.6.2;
              
              /**
               * @dev Collection of functions related to the address type
               */
              library Address {
                  /**
                   * @dev Returns true if `account` is a contract.
                   *
                   * [IMPORTANT]
                   * ====
                   * It is unsafe to assume that an address for which this function returns
                   * false is an externally-owned account (EOA) and not a contract.
                   *
                   * Among others, `isContract` will return false for the following
                   * types of addresses:
                   *
                   *  - an externally-owned account
                   *  - a contract in construction
                   *  - an address where a contract will be created
                   *  - an address where a contract lived, but was destroyed
                   * ====
                   */
                  function isContract(address account) internal view returns (bool) {
                      // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
                      // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
                      // for accounts without code, i.e. `keccak256('')`
                      bytes32 codehash;
              
                          bytes32 accountHash
                       = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
                      // solhint-disable-next-line no-inline-assembly
                      assembly {
                          codehash := extcodehash(account)
                      }
                      return (codehash != accountHash && codehash != 0x0);
                  }
              
                  /**
                   * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
                   * `recipient`, forwarding all available gas and reverting on errors.
                   *
                   * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
                   * of certain opcodes, possibly making contracts go over the 2300 gas limit
                   * imposed by `transfer`, making them unable to receive funds via
                   * `transfer`. {sendValue} removes this limitation.
                   *
                   * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
                   *
                   * IMPORTANT: because control is transferred to `recipient`, care must be
                   * taken to not create reentrancy vulnerabilities. Consider using
                   * {ReentrancyGuard} or the
                   * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
                   */
                  function sendValue(address payable recipient, uint256 amount) internal {
                      require(
                          address(this).balance >= amount,
                          "Address: insufficient balance"
                      );
              
                      // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                      (bool success, ) = recipient.call{ value: amount }("");
                      require(
                          success,
                          "Address: unable to send value, recipient may have reverted"
                      );
                  }
              
                  /**
                   * @dev Performs a Solidity function call using a low level `call`. A
                   * plain`call` is an unsafe replacement for a function call: use this
                   * function instead.
                   *
                   * If `target` reverts with a revert reason, it is bubbled up by this
                   * function (like regular Solidity function calls).
                   *
                   * Returns the raw returned data. To convert to the expected return value,
                   * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
                   *
                   * Requirements:
                   *
                   * - `target` must be a contract.
                   * - calling `target` with `data` must not revert.
                   *
                   * _Available since v3.1._
                   */
                  function functionCall(address target, bytes memory data)
                      internal
                      returns (bytes memory)
                  {
                      return functionCall(target, data, "Address: low-level call failed");
                  }
              
                  /**
                   * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
                   * `errorMessage` as a fallback revert reason when `target` reverts.
                   *
                   * _Available since v3.1._
                   */
                  function functionCall(
                      address target,
                      bytes memory data,
                      string memory errorMessage
                  ) internal returns (bytes memory) {
                      return _functionCallWithValue(target, data, 0, errorMessage);
                  }
              
                  /**
                   * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                   * but also transferring `value` wei to `target`.
                   *
                   * Requirements:
                   *
                   * - the calling contract must have an ETH balance of at least `value`.
                   * - the called Solidity function must be `payable`.
                   *
                   * _Available since v3.1._
                   */
                  function functionCallWithValue(
                      address target,
                      bytes memory data,
                      uint256 value
                  ) internal returns (bytes memory) {
                      return
                          functionCallWithValue(
                              target,
                              data,
                              value,
                              "Address: low-level call with value failed"
                          );
                  }
              
                  /**
                   * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
                   * with `errorMessage` as a fallback revert reason when `target` reverts.
                   *
                   * _Available since v3.1._
                   */
                  function functionCallWithValue(
                      address target,
                      bytes memory data,
                      uint256 value,
                      string memory errorMessage
                  ) internal returns (bytes memory) {
                      require(
                          address(this).balance >= value,
                          "Address: insufficient balance for call"
                      );
                      return _functionCallWithValue(target, data, value, errorMessage);
                  }
              
                  function _functionCallWithValue(
                      address target,
                      bytes memory data,
                      uint256 weiValue,
                      string memory errorMessage
                  ) private returns (bytes memory) {
                      require(isContract(target), "Address: call to non-contract");
              
                      // solhint-disable-next-line avoid-low-level-calls
                      (bool success, bytes memory returndata) = target.call{
                          value: weiValue
                      }(data);
                      if (success) {
                          return returndata;
                      } else {
                          // Look for revert reason and bubble it up if present
                          if (returndata.length > 0) {
                              // The easiest way to bubble the revert reason is using memory via assembly
              
                              // solhint-disable-next-line no-inline-assembly
                              assembly {
                                  let returndata_size := mload(returndata)
                                  revert(add(32, returndata), returndata_size)
                              }
                          } else {
                              revert(errorMessage);
                          }
                      }
                  }
              }
              
              // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
              
              pragma solidity ^0.6.0;
              
              /**
               * @title SafeERC20
               * @dev Wrappers around ERC20 operations that throw on failure (when the token
               * contract returns false). Tokens that return no value (and instead revert or
               * throw on failure) are also supported, non-reverting calls are assumed to be
               * successful.
               * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
               * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
               */
              library SafeERC20 {
                  using SafeMath for uint256;
                  using Address for address;
              
                  function safeTransfer(
                      IERC20 token,
                      address to,
                      uint256 value
                  ) internal {
                      _callOptionalReturn(
                          token,
                          abi.encodeWithSelector(token.transfer.selector, to, value)
                      );
                  }
              
                  function safeTransferFrom(
                      IERC20 token,
                      address from,
                      address to,
                      uint256 value
                  ) internal {
                      _callOptionalReturn(
                          token,
                          abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
                      );
                  }
              
                  /**
                   * @dev Deprecated. This function has issues similar to the ones found in
                   * {IERC20-approve}, and its usage is discouraged.
                   *
                   * Whenever possible, use {safeIncreaseAllowance} and
                   * {safeDecreaseAllowance} instead.
                   */
                  function safeApprove(
                      IERC20 token,
                      address spender,
                      uint256 value
                  ) internal {
                      // safeApprove should only be called when setting an initial allowance,
                      // or when resetting it to zero. To increase and decrease it, use
                      // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                      // solhint-disable-next-line max-line-length
                      require(
                          (value == 0) || (token.allowance(address(this), spender) == 0),
                          "SafeERC20: approve from non-zero to non-zero allowance"
                      );
                      _callOptionalReturn(
                          token,
                          abi.encodeWithSelector(token.approve.selector, spender, value)
                      );
                  }
              
                  function safeIncreaseAllowance(
                      IERC20 token,
                      address spender,
                      uint256 value
                  ) internal {
                      uint256 newAllowance = token.allowance(address(this), spender).add(
                          value
                      );
                      _callOptionalReturn(
                          token,
                          abi.encodeWithSelector(
                              token.approve.selector,
                              spender,
                              newAllowance
                          )
                      );
                  }
              
                  function safeDecreaseAllowance(
                      IERC20 token,
                      address spender,
                      uint256 value
                  ) internal {
                      uint256 newAllowance = token.allowance(address(this), spender).sub(
                          value,
                          "SafeERC20: decreased allowance below zero"
                      );
                      _callOptionalReturn(
                          token,
                          abi.encodeWithSelector(
                              token.approve.selector,
                              spender,
                              newAllowance
                          )
                      );
                  }
              
                  /**
                   * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                   * on the return value: the return value is optional (but if data is returned, it must not be false).
                   * @param token The token targeted by the call.
                   * @param data The call data (encoded using abi.encode or one of its variants).
                   */
                  function _callOptionalReturn(IERC20 token, bytes memory data) private {
                      // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                      // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                      // the target address contains contract code and also asserts for success in the low-level call.
              
                      bytes memory returndata = address(token).functionCall(
                          data,
                          "SafeERC20: low-level call failed"
                      );
                      if (returndata.length > 0) {
                          // Return data is optional
                          // solhint-disable-next-line max-line-length
                          require(
                              abi.decode(returndata, (bool)),
                              "SafeERC20: ERC20 operation did not succeed"
                          );
                      }
                  }
              }
              
              // File: contracts/v1.1/Rescuable.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              contract Rescuable is Ownable {
                  using SafeERC20 for IERC20;
              
                  address private _rescuer;
              
                  event RescuerChanged(address indexed newRescuer);
              
                  /**
                   * @notice Returns current rescuer
                   * @return Rescuer's address
                   */
                  function rescuer() external view returns (address) {
                      return _rescuer;
                  }
              
                  /**
                   * @notice Revert if called by any account other than the rescuer.
                   */
                  modifier onlyRescuer() {
                      require(msg.sender == _rescuer, "Rescuable: caller is not the rescuer");
                      _;
                  }
              
                  /**
                   * @notice Rescue ERC20 tokens locked up in this contract.
                   * @param tokenContract ERC20 token contract address
                   * @param to        Recipient address
                   * @param amount    Amount to withdraw
                   */
                  function rescueERC20(
                      IERC20 tokenContract,
                      address to,
                      uint256 amount
                  ) external onlyRescuer {
                      tokenContract.safeTransfer(to, amount);
                  }
              
                  /**
                   * @notice Assign the rescuer role to a given address.
                   * @param newRescuer New rescuer's address
                   */
                  function updateRescuer(address newRescuer) external onlyOwner {
                      require(
                          newRescuer != address(0),
                          "Rescuable: new rescuer is the zero address"
                      );
                      _rescuer = newRescuer;
                      emit RescuerChanged(newRescuer);
                  }
              }
              
              // File: contracts/v1.1/FiatTokenV1_1.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title FiatTokenV1_1
               * @dev ERC20 Token backed by fiat reserves
               */
              contract FiatTokenV1_1 is FiatTokenV1, Rescuable {
              
              }
              
              // File: contracts/v2/AbstractFiatTokenV2.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              abstract contract AbstractFiatTokenV2 is AbstractFiatTokenV1 {
                  function _increaseAllowance(
                      address owner,
                      address spender,
                      uint256 increment
                  ) internal virtual;
              
                  function _decreaseAllowance(
                      address owner,
                      address spender,
                      uint256 decrement
                  ) internal virtual;
              }
              
              // File: contracts/util/ECRecover.sol
              
              /**
               * Copyright (c) 2016-2019 zOS Global Limited
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title ECRecover
               * @notice A library that provides a safe ECDSA recovery function
               */
              library ECRecover {
                  /**
                   * @notice Recover signer's address from a signed message
                   * @dev Adapted from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/65e4ffde586ec89af3b7e9140bdc9235d1254853/contracts/cryptography/ECDSA.sol
                   * Modifications: Accept v, r, and s as separate arguments
                   * @param digest    Keccak-256 hash digest of the signed message
                   * @param v         v of the signature
                   * @param r         r of the signature
                   * @param s         s of the signature
                   * @return Signer address
                   */
                  function recover(
                      bytes32 digest,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) internal pure returns (address) {
                      // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
                      // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
                      // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
                      // signatures from current libraries generate a unique signature with an s-value in the lower half order.
                      //
                      // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
                      // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
                      // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
                      // these malleable signatures as well.
                      if (
                          uint256(s) >
                          0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
                      ) {
                          revert("ECRecover: invalid signature 's' value");
                      }
              
                      if (v != 27 && v != 28) {
                          revert("ECRecover: invalid signature 'v' value");
                      }
              
                      // If the signature is valid (and not malleable), return the signer address
                      address signer = ecrecover(digest, v, r, s);
                      require(signer != address(0), "ECRecover: invalid signature");
              
                      return signer;
                  }
              }
              
              // File: contracts/util/EIP712.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title EIP712
               * @notice A library that provides EIP712 helper functions
               */
              library EIP712 {
                  /**
                   * @notice Make EIP712 domain separator
                   * @param name      Contract name
                   * @param version   Contract version
                   * @return Domain separator
                   */
                  function makeDomainSeparator(string memory name, string memory version)
                      internal
                      view
                      returns (bytes32)
                  {
                      uint256 chainId;
                      assembly {
                          chainId := chainid()
                      }
                      return
                          keccak256(
                              abi.encode(
                                  // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
                                  0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
                                  keccak256(bytes(name)),
                                  keccak256(bytes(version)),
                                  chainId,
                                  address(this)
                              )
                          );
                  }
              
                  /**
                   * @notice Recover signer's address from a EIP712 signature
                   * @param domainSeparator   Domain separator
                   * @param v                 v of the signature
                   * @param r                 r of the signature
                   * @param s                 s of the signature
                   * @param typeHashAndData   Type hash concatenated with data
                   * @return Signer's address
                   */
                  function recover(
                      bytes32 domainSeparator,
                      uint8 v,
                      bytes32 r,
                      bytes32 s,
                      bytes memory typeHashAndData
                  ) internal pure returns (address) {
                      bytes32 digest = keccak256(
                          abi.encodePacked(
                              "\x19\x01",
                              domainSeparator,
                              keccak256(typeHashAndData)
                          )
                      );
                      return ECRecover.recover(digest, v, r, s);
                  }
              }
              
              // File: contracts/v2/EIP712Domain.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title EIP712 Domain
               */
              contract EIP712Domain {
                  /**
                   * @dev EIP712 Domain Separator
                   */
                  bytes32 public DOMAIN_SEPARATOR;
              }
              
              // File: contracts/v2/EIP3009.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title EIP-3009
               * @notice Provide internal implementation for gas-abstracted transfers
               * @dev Contracts that inherit from this must wrap these with publicly
               * accessible functions, optionally adding modifiers where necessary
               */
              abstract contract EIP3009 is AbstractFiatTokenV2, EIP712Domain {
                  // keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
                  bytes32
                      public constant TRANSFER_WITH_AUTHORIZATION_TYPEHASH = 0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267;
              
                  // keccak256("ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
                  bytes32
                      public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH = 0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8;
              
                  // keccak256("CancelAuthorization(address authorizer,bytes32 nonce)")
                  bytes32
                      public constant CANCEL_AUTHORIZATION_TYPEHASH = 0x158b0a9edf7a828aad02f63cd515c68ef2f50ba807396f6d12842833a1597429;
              
                  /**
                   * @dev authorizer address => nonce => bool (true if nonce is used)
                   */
                  mapping(address => mapping(bytes32 => bool)) private _authorizationStates;
              
                  event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
                  event AuthorizationCanceled(
                      address indexed authorizer,
                      bytes32 indexed nonce
                  );
              
                  /**
                   * @notice Returns the state of an authorization
                   * @dev Nonces are randomly generated 32-byte data unique to the
                   * authorizer's address
                   * @param authorizer    Authorizer's address
                   * @param nonce         Nonce of the authorization
                   * @return True if the nonce is used
                   */
                  function authorizationState(address authorizer, bytes32 nonce)
                      external
                      view
                      returns (bool)
                  {
                      return _authorizationStates[authorizer][nonce];
                  }
              
                  /**
                   * @notice Execute a transfer with a signed authorization
                   * @param from          Payer's address (Authorizer)
                   * @param to            Payee's address
                   * @param value         Amount to be transferred
                   * @param validAfter    The time after which this is valid (unix time)
                   * @param validBefore   The time before which this is valid (unix time)
                   * @param nonce         Unique nonce
                   * @param v             v of the signature
                   * @param r             r of the signature
                   * @param s             s of the signature
                   */
                  function _transferWithAuthorization(
                      address from,
                      address to,
                      uint256 value,
                      uint256 validAfter,
                      uint256 validBefore,
                      bytes32 nonce,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) internal {
                      _requireValidAuthorization(from, nonce, validAfter, validBefore);
              
                      bytes memory data = abi.encode(
                          TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
                          from,
                          to,
                          value,
                          validAfter,
                          validBefore,
                          nonce
                      );
                      require(
                          EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == from,
                          "FiatTokenV2: invalid signature"
                      );
              
                      _markAuthorizationAsUsed(from, nonce);
                      _transfer(from, to, value);
                  }
              
                  /**
                   * @notice Receive a transfer with a signed authorization from the payer
                   * @dev This has an additional check to ensure that the payee's address
                   * matches the caller of this function to prevent front-running attacks.
                   * @param from          Payer's address (Authorizer)
                   * @param to            Payee's address
                   * @param value         Amount to be transferred
                   * @param validAfter    The time after which this is valid (unix time)
                   * @param validBefore   The time before which this is valid (unix time)
                   * @param nonce         Unique nonce
                   * @param v             v of the signature
                   * @param r             r of the signature
                   * @param s             s of the signature
                   */
                  function _receiveWithAuthorization(
                      address from,
                      address to,
                      uint256 value,
                      uint256 validAfter,
                      uint256 validBefore,
                      bytes32 nonce,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) internal {
                      require(to == msg.sender, "FiatTokenV2: caller must be the payee");
                      _requireValidAuthorization(from, nonce, validAfter, validBefore);
              
                      bytes memory data = abi.encode(
                          RECEIVE_WITH_AUTHORIZATION_TYPEHASH,
                          from,
                          to,
                          value,
                          validAfter,
                          validBefore,
                          nonce
                      );
                      require(
                          EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == from,
                          "FiatTokenV2: invalid signature"
                      );
              
                      _markAuthorizationAsUsed(from, nonce);
                      _transfer(from, to, value);
                  }
              
                  /**
                   * @notice Attempt to cancel an authorization
                   * @param authorizer    Authorizer's address
                   * @param nonce         Nonce of the authorization
                   * @param v             v of the signature
                   * @param r             r of the signature
                   * @param s             s of the signature
                   */
                  function _cancelAuthorization(
                      address authorizer,
                      bytes32 nonce,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) internal {
                      _requireUnusedAuthorization(authorizer, nonce);
              
                      bytes memory data = abi.encode(
                          CANCEL_AUTHORIZATION_TYPEHASH,
                          authorizer,
                          nonce
                      );
                      require(
                          EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == authorizer,
                          "FiatTokenV2: invalid signature"
                      );
              
                      _authorizationStates[authorizer][nonce] = true;
                      emit AuthorizationCanceled(authorizer, nonce);
                  }
              
                  /**
                   * @notice Check that an authorization is unused
                   * @param authorizer    Authorizer's address
                   * @param nonce         Nonce of the authorization
                   */
                  function _requireUnusedAuthorization(address authorizer, bytes32 nonce)
                      private
                      view
                  {
                      require(
                          !_authorizationStates[authorizer][nonce],
                          "FiatTokenV2: authorization is used or canceled"
                      );
                  }
              
                  /**
                   * @notice Check that authorization is valid
                   * @param authorizer    Authorizer's address
                   * @param nonce         Nonce of the authorization
                   * @param validAfter    The time after which this is valid (unix time)
                   * @param validBefore   The time before which this is valid (unix time)
                   */
                  function _requireValidAuthorization(
                      address authorizer,
                      bytes32 nonce,
                      uint256 validAfter,
                      uint256 validBefore
                  ) private view {
                      require(
                          now > validAfter,
                          "FiatTokenV2: authorization is not yet valid"
                      );
                      require(now < validBefore, "FiatTokenV2: authorization is expired");
                      _requireUnusedAuthorization(authorizer, nonce);
                  }
              
                  /**
                   * @notice Mark an authorization as used
                   * @param authorizer    Authorizer's address
                   * @param nonce         Nonce of the authorization
                   */
                  function _markAuthorizationAsUsed(address authorizer, bytes32 nonce)
                      private
                  {
                      _authorizationStates[authorizer][nonce] = true;
                      emit AuthorizationUsed(authorizer, nonce);
                  }
              }
              
              // File: contracts/v2/EIP2612.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title EIP-2612
               * @notice Provide internal implementation for gas-abstracted approvals
               */
              abstract contract EIP2612 is AbstractFiatTokenV2, EIP712Domain {
                  // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
                  bytes32
                      public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
              
                  mapping(address => uint256) private _permitNonces;
              
                  /**
                   * @notice Nonces for permit
                   * @param owner Token owner's address (Authorizer)
                   * @return Next nonce
                   */
                  function nonces(address owner) external view returns (uint256) {
                      return _permitNonces[owner];
                  }
              
                  /**
                   * @notice Verify a signed approval permit and execute if valid
                   * @param owner     Token owner's address (Authorizer)
                   * @param spender   Spender's address
                   * @param value     Amount of allowance
                   * @param deadline  The time at which this expires (unix time)
                   * @param v         v of the signature
                   * @param r         r of the signature
                   * @param s         s of the signature
                   */
                  function _permit(
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) internal {
                      require(deadline >= now, "FiatTokenV2: permit is expired");
              
                      bytes memory data = abi.encode(
                          PERMIT_TYPEHASH,
                          owner,
                          spender,
                          value,
                          _permitNonces[owner]++,
                          deadline
                      );
                      require(
                          EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == owner,
                          "EIP2612: invalid signature"
                      );
              
                      _approve(owner, spender, value);
                  }
              }
              
              // File: contracts/v2/FiatTokenV2.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              /**
               * @title FiatToken V2
               * @notice ERC20 Token backed by fiat reserves, version 2
               */
              contract FiatTokenV2 is FiatTokenV1_1, EIP3009, EIP2612 {
                  uint8 internal _initializedVersion;
              
                  /**
                   * @notice Initialize v2
                   * @param newName   New token name
                   */
                  function initializeV2(string calldata newName) external {
                      // solhint-disable-next-line reason-string
                      require(initialized && _initializedVersion == 0);
                      name = newName;
                      DOMAIN_SEPARATOR = EIP712.makeDomainSeparator(newName, "2");
                      _initializedVersion = 1;
                  }
              
                  /**
                   * @notice Increase the allowance by a given increment
                   * @param spender   Spender's address
                   * @param increment Amount of increase in allowance
                   * @return True if successful
                   */
                  function increaseAllowance(address spender, uint256 increment)
                      external
                      whenNotPaused
                      notBlacklisted(msg.sender)
                      notBlacklisted(spender)
                      returns (bool)
                  {
                      _increaseAllowance(msg.sender, spender, increment);
                      return true;
                  }
              
                  /**
                   * @notice Decrease the allowance by a given decrement
                   * @param spender   Spender's address
                   * @param decrement Amount of decrease in allowance
                   * @return True if successful
                   */
                  function decreaseAllowance(address spender, uint256 decrement)
                      external
                      whenNotPaused
                      notBlacklisted(msg.sender)
                      notBlacklisted(spender)
                      returns (bool)
                  {
                      _decreaseAllowance(msg.sender, spender, decrement);
                      return true;
                  }
              
                  /**
                   * @notice Execute a transfer with a signed authorization
                   * @param from          Payer's address (Authorizer)
                   * @param to            Payee's address
                   * @param value         Amount to be transferred
                   * @param validAfter    The time after which this is valid (unix time)
                   * @param validBefore   The time before which this is valid (unix time)
                   * @param nonce         Unique nonce
                   * @param v             v of the signature
                   * @param r             r of the signature
                   * @param s             s of the signature
                   */
                  function transferWithAuthorization(
                      address from,
                      address to,
                      uint256 value,
                      uint256 validAfter,
                      uint256 validBefore,
                      bytes32 nonce,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                      _transferWithAuthorization(
                          from,
                          to,
                          value,
                          validAfter,
                          validBefore,
                          nonce,
                          v,
                          r,
                          s
                      );
                  }
              
                  /**
                   * @notice Receive a transfer with a signed authorization from the payer
                   * @dev This has an additional check to ensure that the payee's address
                   * matches the caller of this function to prevent front-running attacks.
                   * @param from          Payer's address (Authorizer)
                   * @param to            Payee's address
                   * @param value         Amount to be transferred
                   * @param validAfter    The time after which this is valid (unix time)
                   * @param validBefore   The time before which this is valid (unix time)
                   * @param nonce         Unique nonce
                   * @param v             v of the signature
                   * @param r             r of the signature
                   * @param s             s of the signature
                   */
                  function receiveWithAuthorization(
                      address from,
                      address to,
                      uint256 value,
                      uint256 validAfter,
                      uint256 validBefore,
                      bytes32 nonce,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                      _receiveWithAuthorization(
                          from,
                          to,
                          value,
                          validAfter,
                          validBefore,
                          nonce,
                          v,
                          r,
                          s
                      );
                  }
              
                  /**
                   * @notice Attempt to cancel an authorization
                   * @dev Works only if the authorization is not yet used.
                   * @param authorizer    Authorizer's address
                   * @param nonce         Nonce of the authorization
                   * @param v             v of the signature
                   * @param r             r of the signature
                   * @param s             s of the signature
                   */
                  function cancelAuthorization(
                      address authorizer,
                      bytes32 nonce,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external whenNotPaused {
                      _cancelAuthorization(authorizer, nonce, v, r, s);
                  }
              
                  /**
                   * @notice Update allowance with a signed permit
                   * @param owner       Token owner's address (Authorizer)
                   * @param spender     Spender's address
                   * @param value       Amount of allowance
                   * @param deadline    Expiration time, seconds since the epoch
                   * @param v           v of the signature
                   * @param r           r of the signature
                   * @param s           s of the signature
                   */
                  function permit(
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external whenNotPaused notBlacklisted(owner) notBlacklisted(spender) {
                      _permit(owner, spender, value, deadline, v, r, s);
                  }
              
                  /**
                   * @notice Internal function to increase the allowance by a given increment
                   * @param owner     Token owner's address
                   * @param spender   Spender's address
                   * @param increment Amount of increase
                   */
                  function _increaseAllowance(
                      address owner,
                      address spender,
                      uint256 increment
                  ) internal override {
                      _approve(owner, spender, allowed[owner][spender].add(increment));
                  }
              
                  /**
                   * @notice Internal function to decrease the allowance by a given decrement
                   * @param owner     Token owner's address
                   * @param spender   Spender's address
                   * @param decrement Amount of decrease
                   */
                  function _decreaseAllowance(
                      address owner,
                      address spender,
                      uint256 decrement
                  ) internal override {
                      _approve(
                          owner,
                          spender,
                          allowed[owner][spender].sub(
                              decrement,
                              "ERC20: decreased allowance below zero"
                          )
                      );
                  }
              }
              
              // File: contracts/v2/FiatTokenV2_1.sol
              
              /**
               * Copyright (c) 2018-2020 CENTRE SECZ
               *
               * Permission is hereby granted, free of charge, to any person obtaining a copy
               * of this software and associated documentation files (the "Software"), to deal
               * in the Software without restriction, including without limitation the rights
               * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
               * copies of the Software, and to permit persons to whom the Software is
               * furnished to do so, subject to the following conditions:
               *
               * The above copyright notice and this permission notice shall be included in
               * copies or substantial portions of the Software.
               *
               * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
               * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
               * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
               * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
               * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
               * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
               * SOFTWARE.
               */
              
              pragma solidity 0.6.12;
              
              // solhint-disable func-name-mixedcase
              
              /**
               * @title FiatToken V2.1
               * @notice ERC20 Token backed by fiat reserves, version 2.1
               */
              contract FiatTokenV2_1 is FiatTokenV2 {
                  /**
                   * @notice Initialize v2.1
                   * @param lostAndFound  The address to which the locked funds are sent
                   */
                  function initializeV2_1(address lostAndFound) external {
                      // solhint-disable-next-line reason-string
                      require(_initializedVersion == 1);
              
                      uint256 lockedAmount = balances[address(this)];
                      if (lockedAmount > 0) {
                          _transfer(address(this), lostAndFound, lockedAmount);
                      }
                      blacklisted[address(this)] = true;
              
                      _initializedVersion = 2;
                  }
              
                  /**
                   * @notice Version string for the EIP712 domain separator
                   * @return Version string
                   */
                  function version() external view returns (string memory) {
                      return "2";
                  }
              }