creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "london",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "ipfs",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": false,
        "runs": 200
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "contracts/NXV.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport {Executor} from \"./base/Executor.sol\";\nimport {OwnerManager} from \"./base/OwnerManager.sol\";\nimport {FallbackManager} from \"./base/FallbackManager.sol\";\nimport {NativeCurrencyPaymentFallback} from \"./common/NativeCurrencyPaymentFallback.sol\";\nimport {Singleton} from \"./common/Singleton.sol\";\nimport {SignatureDecoder} from \"./common/SignatureDecoder.sol\";\nimport {SecuredTokenTransfer} from \"./common/SecuredTokenTransfer.sol\";\nimport {StorageAccessible} from \"./common/StorageAccessible.sol\";\nimport {Enum} from \"./common/Enum.sol\";\nimport {ISignatureValidator, ISignatureValidatorConstants} from \"./interfaces/ISignatureValidator.sol\";\nimport {SafeMath} from \"./external/SafeMath.sol\";\n\n/**\n * @title NXV - A multisignature wallet with support for confirmations using signed messages based on EIP-712.\n * @dev Most important concepts:\n *      - Threshold: Number of required confirmations for a NXV transaction.\n *      - Owners: List of addresses that control the NXV. They are the only ones that can add/remove owners, change the threshold and\n *        approve transactions. Managed in `OwnerManager`.\n *      - Transaction Hash: Hash of a transaction is calculated using the EIP-712 typed structured data hashing scheme.\n *      - Nonce: Each transaction should have a different nonce to prevent replay attacks.\n *      - Signature: A valid signature of an owner of the NXV for a transaction hash.\n *      - Fallback: Fallback handler is a contract that can provide additional read-only functional for NXV. Managed in `FallbackManager`.\n * @author Stefan George - @Georgi87\n * @author Richard Meissner - @rmeissner\n */\ncontract NXV is\n    Singleton,\n    NativeCurrencyPaymentFallback,\n    Executor,\n    OwnerManager,\n    SignatureDecoder,\n    ISignatureValidatorConstants,\n    FallbackManager,\n    StorageAccessible\n{\n    using SafeMath for uint256;\n\n    string public constant VERSION = \"1.0.0\";\n\n    /*\n     *  Constants\n     */\n    // bytes32 public DOMAIN_SEPARATOR;\n    bytes32 private constant EIP712DOMAIN_TYPEHASH = keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n    bytes32 private constant TRANSACTION_TYPEHASH = keccak256(\"Transaction(address to,uint256 value,bytes data,uint8 operation,uint256 nonce)\");\n\n    /*\n     *  Events\n     */\n    event NXVSetup(address indexed initiator, address[] owners, uint256 threshold, address fallbackHandler);\n    event ExecutionSuccess(bytes32 indexed txHash, uint256 indexed nonce);\n    event ExecutionFailure(bytes32 indexed txHash, uint256 indexed nonce);\n\n    /*\n     *  Storage\n     */\n    mapping(uint256 => bool) public txNonces;\n\n    // Mapping to keep track of all message hashes that have been approved by ALL REQUIRED owners\n    mapping(bytes32 => uint256) public signedMessages;\n\n    // This constructor ensures that this contract can only be used as a singleton for Proxy contracts\n    constructor() {\n        /**\n         * By setting the threshold it is not possible to call setup anymore,\n         * so we create a NXV with 0 owners and threshold 1.\n         * This is an unusable NXV, perfect for the singleton\n         */\n        threshold = 1;\n    }\n\n    /**\n     * @notice Sets an initial storage of the NXV contract.\n     * @dev This method can only be called once.\n     *      If a proxy was created without setting up, anyone can call setup and claim the proxy.\n     * @param _owners List of NXV owners.\n     * @param _threshold Number of required confirmations for a NXV transaction.\n     * @param fallbackHandler Handler for fallback calls to this contract\n     */\n    function setup(\n        address[] calldata _owners,\n        uint256 _threshold,\n        address fallbackHandler\n    ) external {\n        // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n        setupOwners(_owners, _threshold);\n        if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n        emit NXVSetup(msg.sender, _owners, _threshold, fallbackHandler);\n    }\n\n    /**\n     * @notice Executes a `operation` {0: Call, 1: DelegateCall}} transaction to `to` with `value` (Native Currency)\n     * @param to to address of NXV transaction.\n     * @param value Ether value of NXV transaction.\n     * @param data Data payload of NXV transaction.\n     * @param operation Operation type of NXV transaction.\n     * @param nonce Transaction nonce\n     * @param signatures Signature data that should be verified.\n     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.\n     * @return success Boolean indicating transaction's success.\n     */\n    function execTransaction(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        Enum.Operation operation,\n        uint256 nonce,\n        bytes memory signatures\n    ) public payable virtual returns (bool success) {\n        // require(signatures.length >= threshold, \"invalid signature data length\");\n\n        // \"txHash\" is the unique hash of transaction data\n        bytes32 txHash = getTransactionHash(to, value, data, operation, nonce);\n\n        // two identical nonce only allow one to be executed\n        // uint256 nonce = nonce;\n        require(!txNonces[nonce], \"tx-nonce-exist\");\n\n        checkSignatures(txHash, \"\", signatures);\n\n        txNonces[nonce] = true;\n\n        success = execute(to, value, data, operation, (gasleft() - 2500));\n        if (success) {\n            emit ExecutionSuccess(txHash, nonce);\n        } else {\n            emit ExecutionFailure(txHash, nonce);\n        }\n    }\n\n    /**\n     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.\n     * @param txHash Hash of the data (could be either a message hash or transaction hash)\n     * @param data That should be signed (this is passed to an external validator contract)\n     * @param signatures Signature data that should be verified.\n     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.\n     */\n    function checkSignatures(bytes32 txHash, bytes memory data, bytes memory signatures) public view {\n        // Load threshold to avoid multiple storage loads\n        uint256 _threshold = threshold;\n        // Check that a threshold is set\n        require(_threshold > 0, \"Threshold needs defined\");\n        checkNSignatures(txHash, data, signatures, _threshold);\n    }\n\n    /**\n     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.\n     * @dev Since the EIP-1271 does an external call, be mindful of reentrancy attacks.\n     * @param txHash Hash of the data (could be either a message hash or transaction hash)\n     * @param signatures Signature data that should be verified.\n     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.\n     * @param requiredSignatures Amount of required valid signatures.\n     */\n    function checkNSignatures(bytes32 txHash, bytes memory /* data */, bytes memory signatures, uint256 requiredSignatures) public view {\n        // Check that the provided signature data is not too short\n        require(signatures.length >= requiredSignatures * 65, \"invalid sig length\");\n        // There cannot be an owner with address 0.\n        address lastOwner = address(0);\n        address currentOwner;\n        uint8 v;\n        bytes32 r;\n        bytes32 s;\n        uint256 i;\n        for(i = 0; i < requiredSignatures; i++) {\n            (v, r, s) = signatureSplit(signatures, i);\n            currentOwner = ecrecover(txHash, v, r, s);\n            // to save gas, need signature sorted\n            require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"error-sig\");\n            lastOwner = currentOwner;\n        }\n    }\n\n    /**\n     * @notice Returns the ID of the chain the contract is currently deployed on.\n     * @return The ID of the current chain as a uint256.\n     */\n    function getChainId() public view returns (uint256) {\n        uint256 id;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            id := chainid()\n        }\n        return id;\n    }\n\n    /**\n     * @dev Returns the domain separator for this contract, as defined in the EIP-712 standard.\n     * @return bytes32 The domain separator hash.\n     */\n    function domainSeparator() public view returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                EIP712DOMAIN_TYPEHASH,\n                keccak256(\"NXVWallet\"), // name\n                getChainId(),\n                address(this)\n            )\n        );\n    }\n\n    /**\n     * @notice Returns the pre-image of the transaction hash (see getTransactionHash).\n     * @param to to address.\n     * @param value Ether value.\n     * @param data Data payload.\n     * @param operation Operation type.\n     * @param _nonce Transaction nonce.\n     * @return Transaction hash bytes.\n     */\n    function encodeTransactionData(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        Enum.Operation operation,\n        uint256 _nonce\n    ) private view returns (bytes memory) {\n        bytes32 txHash = keccak256(\n            abi.encode(\n                TRANSACTION_TYPEHASH,\n                to,\n                value,\n                keccak256(data),\n                operation,\n                _nonce\n            )\n        );\n        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), txHash);\n    }\n\n    /**\n     * @notice Returns transaction hash to be signed by owners.\n     * @param to to address.\n     * @param value Ether value.\n     * @param data Data payload.\n     * @param operation Operation type.\n     * @param _nonce Transaction nonce.\n     * @return Transaction hash.\n     */\n    function getTransactionHash(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        Enum.Operation operation,\n        uint256 _nonce\n    ) public view returns (bytes32) {\n        return keccak256(encodeTransactionData(to, value, data, operation, _nonce));\n    }\n}\n\n// ."
      },
      "contracts/base/Executor.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport {Enum} from \"../common/Enum.sol\";\n\n/**\n * @title Executor - A contract that can execute transactions\n * @author Richard Meissner - @rmeissner\n */\nabstract contract Executor {\n    /**\n     * @notice Executes either a delegatecall or a call with provided parameters.\n     * @dev This method doesn't perform any sanity check of the transaction, such as:\n     *      - if the contract at `to` address has code or not\n     *      It is the responsibility of the caller to perform such checks.\n     * @param to Destination address.\n     * @param value Ether value.\n     * @param data Data payload.\n     * @param operation Operation type.\n     * @return success boolean flag indicating if the call succeeded.\n     */\n    function execute(\n        address to,\n        uint256 value,\n        bytes memory data,\n        Enum.Operation operation,\n        uint256 txGas\n    ) internal returns (bool success) {\n        if (operation == Enum.Operation.DelegateCall) {\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n            }\n        } else {\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n            }\n        }\n    }\n}\n\n// ."
      },
      "contracts/base/FallbackManager.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport {SelfAuthorized} from \"../common/SelfAuthorized.sol\";\n\n/**\n * @title Fallback Manager - A contract managing fallback calls made to this contract\n * @author Richard Meissner - @rmeissner\n */\nabstract contract FallbackManager is SelfAuthorized {\n    event ChangedFallbackHandler(address indexed handler);\n\n    // keccak256(\"fallback_manager.handler.address\")\n    bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n    /**\n     *  @notice Internal function to set the fallback handler.\n     *  @param handler contract to handle fallback calls.\n     */\n    function internalSetFallbackHandler(address handler) internal {\n        /*\n            If a fallback handler is set to self, then the following attack vector is opened:\n            Imagine we have a function like this:\n            function withdraw() internal authorized {\n                withdrawalAddress.call.value(address(this).balance)(\"\");\n            }\n\n            If the fallback method is triggered, the fallback handler appends the msg.sender address to the calldata and calls the fallback handler.\n            A potential attacker could call a Safe with the 3 bytes signature of a withdraw function. Since 3 bytes do not create a valid signature,\n            the call would end in a fallback handler. Since it appends the msg.sender address to the calldata, the attacker could craft an address \n            where the first 3 bytes of the previous calldata + the first byte of the address make up a valid function signature. The subsequent call would result in unsanctioned access to Safe's internal protected methods.\n            For some reason, solidity matches the first 4 bytes of the calldata to a function signature, regardless if more data follow these 4 bytes.\n        */\n        require(handler != address(this), \"Fallback handler cannot be self\");\n\n        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, handler)\n        }\n    }\n\n    /**\n     * @notice Set Fallback Handler to `handler` for the Safe.\n     * @dev Only fallback calls without value and with data will be forwarded.\n     *      This can only be done via a Safe transaction.\n     *      Cannot be set to the Safe itself.\n     * @param handler contract to handle fallback calls.\n     */\n    function setFallbackHandler(address handler) public authorized {\n        internalSetFallbackHandler(handler);\n        emit ChangedFallbackHandler(handler);\n    }\n\n    // @notice Forwards all calls to the fallback handler if set. Returns 0 if no handler is set.\n    // @dev Appends the non-padded caller address to the calldata to be optionally used in the handler\n    //      The handler can make us of `HandlerContext.sol` to extract the address.\n    //      This is done because in the next call frame the `msg.sender` will be FallbackManager's address\n    //      and having the original caller address may enable additional verification scenarios.\n    // solhint-disable-next-line payable-fallback,no-complex-fallback\n    fallback() external {\n        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let handler := sload(slot)\n            if iszero(handler) {\n                return(0, 0)\n            }\n            calldatacopy(0, 0, calldatasize())\n            // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n            // Then the address without padding is stored right after the calldata\n            mstore(calldatasize(), shl(96, caller()))\n            // Add 20 bytes for the address appended add the end\n            let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n            returndatacopy(0, 0, returndatasize())\n            if iszero(success) {\n                revert(0, returndatasize())\n            }\n            return(0, returndatasize())\n        }\n    }\n}\n\n// ."
      },
      "contracts/base/OwnerManager.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport {SelfAuthorized} from \"../common/SelfAuthorized.sol\";\n\n/**\n * @title OwnerManager - Manages Safe owners and a threshold to authorize transactions.\n * @dev Uses a linked list to store the owners because the code generate by the solidity compiler\n *      is more efficient than using a dynamic array.\n * @author Stefan George - @Georgi87\n * @author Richard Meissner - @rmeissner\n */\nabstract contract OwnerManager is SelfAuthorized {\n    event AddedOwner(address indexed owner);\n    event RemovedOwner(address indexed owner);\n    event ChangedThreshold(uint256 threshold);\n\n    address internal constant SENTINEL_OWNERS = address(0x1);\n\n    mapping(address => address) internal owners;\n    uint256 internal ownerCount;\n    uint256 internal threshold;\n\n    /**\n     * @notice Sets the initial storage of the contract.\n     * @param _owners List of Safe owners.\n     * @param _threshold Number of required confirmations for a Safe transaction.\n     */\n    function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n        // Threshold can only be 0 at initialization.\n        // Check ensures that setup function can only be called once.\n        require(threshold == 0, \"Owners set up\");\n        // Validate that threshold is smaller than number of added owners.\n        require(_threshold <= _owners.length, \"Threshold exceed owner count\");\n        // There has to be at least one Safe owner.\n        require(_threshold >= 1, \"Threshold needs greater than 0\");\n        // Initializing Safe owners.\n        address currentOwner = SENTINEL_OWNERS;\n        for (uint256 i = 0; i < _owners.length; i++) {\n            // Owner address cannot be null.\n            address owner = _owners[i];\n            require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"Invalid owner\");\n            // No duplicate owners allowed.\n            require(owners[owner] == address(0), \"Address is already owner\");\n            owners[currentOwner] = owner;\n            currentOwner = owner;\n        }\n        owners[currentOwner] = SENTINEL_OWNERS;\n        ownerCount = _owners.length;\n        threshold = _threshold;\n    }\n\n    /**\n     * @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n     * @dev This can only be done via a Safe transaction.\n     * @param owner New owner address.\n     * @param _threshold New threshold.\n     */\n    function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n        // Owner address cannot be null, the sentinel or the Safe itself.\n        require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"Invalid owner\");\n        // No duplicate owners allowed.\n        require(owners[owner] == address(0), \"Address is already owner\");\n        owners[owner] = owners[SENTINEL_OWNERS];\n        owners[SENTINEL_OWNERS] = owner;\n        ownerCount++;\n        emit AddedOwner(owner);\n        // Change threshold if threshold was changed.\n        if (threshold != _threshold) changeThreshold(_threshold);\n    }\n\n    /**\n     * @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n     * @dev This can only be done via a Safe transaction.\n     * @param prevOwner Owner that pointed to the owner to be removed in the linked list\n     * @param owner Owner address to be removed.\n     * @param _threshold New threshold.\n     */\n    function removeOwner(address prevOwner, address owner, uint256 _threshold) public authorized {\n        // Only allow to remove an owner, if threshold can still be reached.\n        require(ownerCount - 1 >= _threshold, \"Threshold exceed owner count\");\n        // Validate owner address and check that it corresponds to owner index.\n        require(owner != address(0) && owner != SENTINEL_OWNERS, \"Invalid owner\");\n        require(owners[prevOwner] == owner, \"Invalid prevOwner, owner\");\n        owners[prevOwner] = owners[owner];\n        owners[owner] = address(0);\n        ownerCount--;\n        emit RemovedOwner(owner);\n        // Change threshold if threshold was changed.\n        if (threshold != _threshold) changeThreshold(_threshold);\n    }\n\n    /**\n     * @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n     * @dev This can only be done via a Safe transaction.\n     * @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n     * @param oldOwner Owner address to be replaced.\n     * @param newOwner New owner address.\n     */\n    function swapOwner(address prevOwner, address oldOwner, address newOwner) public authorized {\n        // Owner address cannot be null, the sentinel or the Safe itself.\n        require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"Invalid owner\");\n        // No duplicate owners allowed.\n        require(owners[newOwner] == address(0), \"Address is already owner\");\n        // Validate oldOwner address and check that it corresponds to owner index.\n        require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"Invalid owner\");\n        require(owners[prevOwner] == oldOwner, \"Invalid prevOwner, owner\");\n        owners[newOwner] = owners[oldOwner];\n        owners[prevOwner] = newOwner;\n        owners[oldOwner] = address(0);\n        emit RemovedOwner(oldOwner);\n        emit AddedOwner(newOwner);\n    }\n\n    /**\n     * @notice Changes the threshold of the Safe to `_threshold`.\n     * @dev This can only be done via a Safe transaction.\n     * @param _threshold New threshold.\n     */\n    function changeThreshold(uint256 _threshold) public authorized {\n        // Validate that threshold is smaller than number of owners.\n        require(_threshold <= ownerCount, \"Threshold exceed owner count\");\n        // There has to be at least one Safe owner.\n        require(_threshold >= 1, \"Threshold needs greater than 0\");\n        threshold = _threshold;\n        emit ChangedThreshold(threshold);\n    }\n\n    /**\n     * @notice Returns the number of required confirmations for a Safe transaction aka the threshold.\n     * @return Threshold number.\n     */\n    function getThreshold() public view returns (uint256) {\n        return threshold;\n    }\n\n    /**\n     * @notice Returns if `owner` is an owner of the Safe.\n     * @return Boolean if owner is an owner of the Safe.\n     */\n    function isOwner(address owner) public view returns (bool) {\n        return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n    }\n\n    /**\n     * @notice Returns a list of Safe owners.\n     * @return Array of Safe owners.\n     */\n    function getOwners() public view returns (address[] memory) {\n        address[] memory array = new address[](ownerCount);\n\n        // populate return array\n        uint256 index = 0;\n        address currentOwner = owners[SENTINEL_OWNERS];\n        while (currentOwner != SENTINEL_OWNERS) {\n            array[index] = currentOwner;\n            currentOwner = owners[currentOwner];\n            index++;\n        }\n        return array;\n    }\n}\n\n// ."
      },
      "contracts/common/Enum.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Enum - Collection of enums used in Safe contracts.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract Enum {\n    enum Operation {\n        Call,\n        DelegateCall\n    }\n}\n\n// ."
      },
      "contracts/common/NativeCurrencyPaymentFallback.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title NativeCurrencyPaymentFallback - A contract that has a fallback to accept native currency payments.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract NativeCurrencyPaymentFallback {\n    event NXVReceived(address indexed sender, uint256 value);\n\n    /**\n     * @notice Receive function accepts native currency transactions.\n     * @dev Emits an event with sender and received value.\n     */\n    receive() external payable {\n        emit NXVReceived(msg.sender, msg.value);\n    }\n}\n\n// ."
      },
      "contracts/common/SecuredTokenTransfer.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SecuredTokenTransfer - Secure token transfer.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract SecuredTokenTransfer {\n    /**\n     * @notice Transfers a token and returns a boolean if it was a success\n     * @dev It checks the return data of the transfer call and returns true if the transfer was successful.\n     *      It doesn't check if the `token` address is a contract or not.\n     * @param token Token that should be transferred\n     * @param receiver Receiver to whom the token should be transferred\n     * @param amount The amount of tokens that should be transferred\n     * @return transferred Returns true if the transfer was successful\n     */\n    function transferToken(address token, address receiver, uint256 amount) internal returns (bool transferred) {\n        // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n        bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // We write the return value to scratch space.\n            // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n            let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n            switch returndatasize()\n            case 0 {\n                transferred := success\n            }\n            case 0x20 {\n                transferred := iszero(or(iszero(success), iszero(mload(0))))\n            }\n            default {\n                transferred := 0\n            }\n        }\n    }\n}\n\n// ."
      },
      "contracts/common/SelfAuthorized.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SelfAuthorized - Authorizes current contract to perform actions to itself.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract SelfAuthorized {\n    function requireSelfCall() private view {\n        require(msg.sender == address(this), \"Only be called from this contract\");\n    }\n\n    modifier authorized() {\n        // Modifiers are copied around during compilation. This is a function call as it minimized the bytecode size\n        requireSelfCall();\n        _;\n    }\n}\n\n// ."
      },
      "contracts/common/SignatureDecoder.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SignatureDecoder - Decodes signatures encoded as bytes\n * @author Richard Meissner - @rmeissner\n */\nabstract contract SignatureDecoder {\n    /**\n     * @notice Splits signature bytes into `uint8 v, bytes32 r, bytes32 s`.\n     * @dev Make sure to perform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n     *      The signature format is a compact form of {bytes32 r}{bytes32 s}{uint8 v}\n     *      Compact means uint8 is not padded to 32 bytes.\n     * @param pos Which signature to read.\n     *            A prior bounds check of this parameter should be performed, to avoid out of bounds access.\n     * @param signatures Concatenated {r, s, v} signatures.\n     * @return v Recovery ID or Safe signature type.\n     * @return r Output value r of the signature.\n     * @return s Output value s of the signature.\n     */\n    function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns (uint8 v, bytes32 r, bytes32 s) {\n        /* solhint-disable no-inline-assembly */\n        /// @solidity memory-safe-assembly\n        assembly {\n            let signaturePos := mul(0x41, pos)\n            r := mload(add(signatures, add(signaturePos, 0x20)))\n            s := mload(add(signatures, add(signaturePos, 0x40)))\n            v := byte(0, mload(add(signatures, add(signaturePos, 0x60))))\n        }\n        /* solhint-enable no-inline-assembly */\n    }\n}\n\n// ."
      },
      "contracts/common/Singleton.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Singleton - Base for singleton contracts (should always be the first super contract)\n *        This contract is tightly coupled to our proxy contract (see `proxies/SafeProxy.sol`)\n * @author Richard Meissner - @rmeissner\n */\nabstract contract Singleton {\n    // singleton always has to be the first declared variable to ensure the same location as in the Proxy contract.\n    // It should also always be ensured the address is stored alone (uses a full word)\n    address private singleton;\n}\n\n// ."
      },
      "contracts/common/StorageAccessible.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title StorageAccessible - A generic base contract that allows callers to access all internal storage.\n * @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\n *         It removes a method from the original contract not needed for the Safe contracts.\n * @author Gnosis Developers\n */\nabstract contract StorageAccessible {\n    /**\n     * @notice Reads `length` bytes of storage in the currents contract\n     * @param offset - the offset in the current contract's storage in words to start reading from\n     * @param length - the number of words (32 bytes) of data to read\n     * @return the bytes that were read.\n     */\n    function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n        bytes memory result = new bytes(length * 32);\n        for (uint256 index = 0; index < length; index++) {\n            /* solhint-disable no-inline-assembly */\n            /// @solidity memory-safe-assembly\n            assembly {\n                let word := sload(add(offset, index))\n                mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n            }\n            /* solhint-enable no-inline-assembly */\n        }\n        return result;\n    }\n\n    /**\n     * @dev Performs a delegatecall on a targetContract in the context of self.\n     * Internally reverts execution to avoid side effects (making it static).\n     *\n     * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n     * Specifically, the `returndata` after a call to this method will be:\n     * `success:bool || response.length:uint256 || response:bytes`.\n     *\n     * @param targetContract Address of the contract containing the code to execute.\n     * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n     */\n    function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n        /* solhint-disable no-inline-assembly */\n        /// @solidity memory-safe-assembly\n        assembly {\n            let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n            // Load free memory location\n            let ptr := mload(0x40)\n            mstore(ptr, success)\n            mstore(add(ptr, 0x20), returndatasize())\n            returndatacopy(add(ptr, 0x40), 0, returndatasize())\n            revert(ptr, add(returndatasize(), 0x40))\n        }\n        /* solhint-enable no-inline-assembly */\n    }\n}\n\n// ."
      },
      "contracts/external/SafeMath.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SafeMath\n * @notice Math operations with safety checks that revert on error (overflow/underflow)\n */\nlibrary SafeMath {\n    /**\n     * @notice Multiplies two numbers, reverts on overflow.\n     * @param a First number\n     * @param b Second number\n     * @return Product of a and b\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b);\n\n        return c;\n    }\n\n    /**\n     * @notice Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n     * @param a First number\n     * @param b Second number\n     * @return Difference of a and b\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a);\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    /**\n     * @notice Adds two numbers, reverts on overflow.\n     * @param a First number\n     * @param b Second number\n     * @return Sum of a and b\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a);\n\n        return c;\n    }\n\n    /**\n     * @notice Returns the largest of two numbers.\n     * @param a First number\n     * @param b Second number\n     * @return Largest of a and b\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n}\n\n// ."
      },
      "contracts/interfaces/ISignatureValidator.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\n/* solhint-disable one-contract-per-file */\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n    // bytes4(keccak256(\"isValidSignature(bytes32,bytes)\")\n    bytes4 internal constant EIP1271_MAGIC_VALUE = 0x1626ba7e;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n    /**\n     * @notice EIP1271 method to validate a signature.\n     * @param _hash Hash of the data signed on the behalf of address(this).\n     * @param _signature Signature byte array associated with _data.\n     *\n     * MUST return the bytes4 magic value 0x1626ba7e when function passes.\n     * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n     * MUST allow external calls\n     */\n    function isValidSignature(bytes32 _hash, bytes memory _signature) external view virtual returns (bytes4);\n}\n\n// ."
      }
    }
  }}