Contract 0x831153c6b9537d0fF5b7DB830C2749DE3042e776

  Note: Our ETH balance display is temporarily unavailable. Please check back later.

Contract Overview

Balance:
Txn Hash Method
Block
From
To
Value
0x4cfe669b4c24a47d20608ff27206dfd57db6d48e4c7cac7468be89adcecc5a4eFinalize Recover...87700682023-05-01 19:10:04356 days 1 hr ago0x3cfdc212769c890907bce93d3d8c2c53de6a7a89 IN  0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH0.0001647943011.50000005
0x04abb3600d5a257b85f1ed6c8a5f7b7dcddb16fbea1b5f7258246f202039bc64Multi Confirm Re...87690322023-05-01 18:35:32356 days 2 hrs ago0xbdbc5fbc9ca8c3f514d073ec3de840ac84fc6d31 IN  0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH0.0003462891571.50000005
0x5e166a0b512b1bc0089fbd3f429e8e6234e025d77b19400c6fb7eb06fab146ddFinalize Recover...84965512023-04-25 11:12:50362 days 9 hrs ago0x3cfdc212769c890907bce93d3d8c2c53de6a7a89 IN  0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH0.0006408208711.50000005
0xc05c9d2aee642c0d922bc93c391bc0b8fe0315dce8aa2be65e4e93ca3578f1a1Multi Confirm Re...84906622023-04-25 7:56:32362 days 12 hrs ago0xbdbc5fbc9ca8c3f514d073ec3de840ac84fc6d31 IN  0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH0.0015598438861.50000005
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x97a3f471a466f43037a9ea9b7555fe2c5d373a687dd7801e6e6f9c700357f41896973012023-05-23 6:17:50334 days 14 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x97a3f471a466f43037a9ea9b7555fe2c5d373a687dd7801e6e6f9c700357f41896973012023-05-23 6:17:50334 days 14 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x97a3f471a466f43037a9ea9b7555fe2c5d373a687dd7801e6e6f9c700357f41896973012023-05-23 6:17:50334 days 14 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH
0x1075e225ef52782af80fd67463b2ca3d8872f1d80d7817456417018639a0081e96812892023-05-22 21:24:06334 days 23 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x1075e225ef52782af80fd67463b2ca3d8872f1d80d7817456417018639a0081e96812892023-05-22 21:24:06334 days 23 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x1075e225ef52782af80fd67463b2ca3d8872f1d80d7817456417018639a0081e96812892023-05-22 21:24:06334 days 23 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x1075e225ef52782af80fd67463b2ca3d8872f1d80d7817456417018639a0081e96812892023-05-22 21:24:06334 days 23 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x1075e225ef52782af80fd67463b2ca3d8872f1d80d7817456417018639a0081e96812892023-05-22 21:24:06334 days 23 hrs ago 0x77b6132dc082e9e3ead70a5fe73a6c42997d5a34 0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH
0x4cfe669b4c24a47d20608ff27206dfd57db6d48e4c7cac7468be89adcecc5a4e87700682023-05-01 19:10:04356 days 1 hr ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0x9f469607425da1a9070ff74f0404eeb6f69caaf20 ETH
0x4cfe669b4c24a47d20608ff27206dfd57db6d48e4c7cac7468be89adcecc5a4e87700682023-05-01 19:10:04356 days 1 hr ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x4cfe669b4c24a47d20608ff27206dfd57db6d48e4c7cac7468be89adcecc5a4e87700682023-05-01 19:10:04356 days 1 hr ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0x9f469607425da1a9070ff74f0404eeb6f69caaf20 ETH
0x04abb3600d5a257b85f1ed6c8a5f7b7dcddb16fbea1b5f7258246f202039bc6487690322023-05-01 18:35:32356 days 2 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x04abb3600d5a257b85f1ed6c8a5f7b7dcddb16fbea1b5f7258246f202039bc6487690322023-05-01 18:35:32356 days 2 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x04abb3600d5a257b85f1ed6c8a5f7b7dcddb16fbea1b5f7258246f202039bc6487690322023-05-01 18:35:32356 days 2 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x0fe56e1a326d01ca0bb4b1cdb9e28e43eb0fc2ed0860494e1f3d08a34420377886025362023-04-27 22:05:40359 days 22 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x0fe56e1a326d01ca0bb4b1cdb9e28e43eb0fc2ed0860494e1f3d08a34420377886025362023-04-27 22:05:40359 days 22 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x0fe56e1a326d01ca0bb4b1cdb9e28e43eb0fc2ed0860494e1f3d08a34420377886025362023-04-27 22:05:40359 days 22 hrs ago 0x77b6132dc082e9e3ead70a5fe73a6c42997d5a34 0x831153c6b9537d0ff5b7db830c2749de3042e7760 ETH
0x5e166a0b512b1bc0089fbd3f429e8e6234e025d77b19400c6fb7eb06fab146dd84965512023-04-25 11:12:50362 days 9 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0x9f469607425da1a9070ff74f0404eeb6f69caaf20 ETH
0x5e166a0b512b1bc0089fbd3f429e8e6234e025d77b19400c6fb7eb06fab146dd84965512023-04-25 11:12:50362 days 9 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0x5e166a0b512b1bc0089fbd3f429e8e6234e025d77b19400c6fb7eb06fab146dd84965512023-04-25 11:12:50362 days 9 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0x9f469607425da1a9070ff74f0404eeb6f69caaf20 ETH
0xc05c9d2aee642c0d922bc93c391bc0b8fe0315dce8aa2be65e4e93ca3578f1a184906622023-04-25 7:56:32362 days 12 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0xc05c9d2aee642c0d922bc93c391bc0b8fe0315dce8aa2be65e4e93ca3578f1a184906622023-04-25 7:56:32362 days 12 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0xc05c9d2aee642c0d922bc93c391bc0b8fe0315dce8aa2be65e4e93ca3578f1a184906622023-04-25 7:56:32362 days 12 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0xd7fb7ee56f1bca0d7e50327ac288765b8bf0e28a2c0e11b6dafd16d34c18a6d583783472023-04-22 17:32:42365 days 3 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
0xd7fb7ee56f1bca0d7e50327ac288765b8bf0e28a2c0e11b6dafd16d34c18a6d583783472023-04-22 17:32:42365 days 3 hrs ago 0x831153c6b9537d0ff5b7db830c2749de3042e776 0xa7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SocialRecoveryModule

Compiler Version
v0.8.12+commit.f00d7308

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 24 : Executor.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "../common/Enum.sol";

/**
 * @title Executor - A contract that can execute transactions
 * @author Richard Meissner - @rmeissner
 */
abstract contract Executor {
    /**
     * @notice Executes either a delegatecall or a call with provided parameters.
     * @dev This method doesn't perform any sanity check of the transaction, such as:
     *      - if the contract at `to` address has code or not
     *      It is the responsibility of the caller to perform such checks.
     * @param to Destination address.
     * @param value Ether value.
     * @param data Data payload.
     * @param operation Operation type.
     * @return success boolean flag indicating if the call succeeded.
     */
    function execute(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256 txGas
    ) internal returns (bool success) {
        if (operation == Enum.Operation.DelegateCall) {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)
            }
        } else {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)
            }
        }
    }
}

File 2 of 24 : FallbackManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "../common/SelfAuthorized.sol";

/**
 * @title Fallback Manager - A contract managing fallback calls made to this contract
 * @author Richard Meissner - @rmeissner
 */
abstract contract FallbackManager is SelfAuthorized {
    event ChangedFallbackHandler(address indexed handler);

    // keccak256("fallback_manager.handler.address")
    bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;

    /**
     *  @notice Internal function to set the fallback handler.
     *  @param handler contract to handle fallback calls.
     */
    function internalSetFallbackHandler(address handler) internal {
        /*
            If a fallback handler is set to self, then the following attack vector is opened:
            Imagine we have a function like this:
            function withdraw() internal authorized {
                withdrawalAddress.call.value(address(this).balance)("");
            }

            If the fallback method is triggered, the fallback handler appends the msg.sender address to the calldata and calls the fallback handler.
            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,
            the call would end in a fallback handler. Since it appends the msg.sender address to the calldata, the attacker could craft an address 
            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.
            For some reason, solidity matches the first 4 bytes of the calldata to a function signature, regardless if more data follow these 4 bytes.
        */
        require(handler != address(this), "GS400");

        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(slot, handler)
        }
    }

    /**
     * @notice Set Fallback Handler to `handler` for the Safe.
     * @dev Only fallback calls without value and with data will be forwarded.
     *      This can only be done via a Safe transaction.
     *      Cannot be set to the Safe itself.
     * @param handler contract to handle fallback calls.
     */
    function setFallbackHandler(address handler) public authorized {
        internalSetFallbackHandler(handler);
        emit ChangedFallbackHandler(handler);
    }

    // @notice Forwards all calls to the fallback handler if set. Returns 0 if no handler is set.
    // @dev Appends the non-padded caller address to the calldata to be optionally used in the handler
    //      The handler can make us of `HandlerContext.sol` to extract the address.
    //      This is done because in the next call frame the `msg.sender` will be FallbackManager's address
    //      and having the original caller address may enable additional verification scenarios.
    // solhint-disable-next-line payable-fallback,no-complex-fallback
    fallback() external {
        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let handler := sload(slot)
            if iszero(handler) {
                return(0, 0)
            }
            calldatacopy(0, 0, calldatasize())
            // The msg.sender address is shifted to the left by 12 bytes to remove the padding
            // Then the address without padding is stored right after the calldata
            mstore(calldatasize(), shl(96, caller()))
            // Add 20 bytes for the address appended add the end
            let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)
            returndatacopy(0, 0, returndatasize())
            if iszero(success) {
                revert(0, returndatasize())
            }
            return(0, returndatasize())
        }
    }
}

File 3 of 24 : GuardManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "../common/Enum.sol";
import "../common/SelfAuthorized.sol";
import "../interfaces/IERC165.sol";

interface Guard is IERC165 {
    function checkTransaction(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver,
        bytes memory signatures,
        address msgSender
    ) external;

    function checkAfterExecution(bytes32 txHash, bool success) external;
}

abstract contract BaseGuard is Guard {
    function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
        return
            interfaceId == type(Guard).interfaceId || // 0xe6d7a83a
            interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7
    }
}

/**
 * @title Guard Manager - A contract managing transaction guards which perform pre and post-checks on Safe transactions.
 * @author Richard Meissner - @rmeissner
 */
abstract contract GuardManager is SelfAuthorized {
    event ChangedGuard(address indexed guard);

    // keccak256("guard_manager.guard.address")
    bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;

    /**
     * @dev Set a guard that checks transactions before execution
     *      This can only be done via a Safe transaction.
     *      ⚠️ IMPORTANT: Since a guard has full power to block Safe transaction execution,
     *        a broken guard can cause a denial of service for the Safe. Make sure to carefully
     *        audit the guard code and design recovery mechanisms.
     * @notice Set Transaction Guard `guard` for the Safe. Make sure you trust the guard.
     * @param guard The address of the guard to be used or the 0 address to disable the guard
     */
    function setGuard(address guard) external authorized {
        if (guard != address(0)) {
            require(Guard(guard).supportsInterface(type(Guard).interfaceId), "GS300");
        }
        bytes32 slot = GUARD_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(slot, guard)
        }
        emit ChangedGuard(guard);
    }

    /**
     * @dev Internal method to retrieve the current guard
     *      We do not have a public method because we're short on bytecode size limit,
     *      to retrieve the guard address, one can use `getStorageAt` from `StorageAccessible` contract
     *      with the slot `GUARD_STORAGE_SLOT`
     * @return guard The address of the guard
     */
    function getGuard() internal view returns (address guard) {
        bytes32 slot = GUARD_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            guard := sload(slot)
        }
    }
}

File 4 of 24 : ModuleManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "../common/Enum.sol";
import "../common/SelfAuthorized.sol";
import "./Executor.sol";

/**
 * @title Module Manager - A contract managing Safe modules
 * @notice Modules are extensions with unlimited access to a Safe that can be added to a Safe by its owners.
           ⚠️ WARNING: Modules are a security risk since they can execute arbitrary transactions, 
           so only trusted and audited modules should be added to a Safe. A malicious module can
           completely takeover a Safe.
 * @author Stefan George - @Georgi87
 * @author Richard Meissner - @rmeissner
 */
abstract contract ModuleManager is SelfAuthorized, Executor {
    event EnabledModule(address indexed module);
    event DisabledModule(address indexed module);
    event ExecutionFromModuleSuccess(address indexed module);
    event ExecutionFromModuleFailure(address indexed module);

    address internal constant SENTINEL_MODULES = address(0x1);

    mapping(address => address) internal modules;

    /**
     * @notice Setup function sets the initial storage of the contract.
     *         Optionally executes a delegate call to another contract to setup the modules.
     * @param to Optional destination address of call to execute.
     * @param data Optional data of call to execute.
     */
    function setupModules(address to, bytes memory data) internal {
        require(modules[SENTINEL_MODULES] == address(0), "GS100");
        modules[SENTINEL_MODULES] = SENTINEL_MODULES;
        if (to != address(0)) {
            require(isContract(to), "GS002");
            // Setup has to complete successfully or transaction fails.
            require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), "GS000");
        }
    }

    /**
     * @notice Enables the module `module` for the Safe.
     * @dev This can only be done via a Safe transaction.
     * @param module Module to be whitelisted.
     */
    function enableModule(address module) public authorized {
        // Module address cannot be null or sentinel.
        require(module != address(0) && module != SENTINEL_MODULES, "GS101");
        // Module cannot be added twice.
        require(modules[module] == address(0), "GS102");
        modules[module] = modules[SENTINEL_MODULES];
        modules[SENTINEL_MODULES] = module;
        emit EnabledModule(module);
    }

    /**
     * @notice Disables the module `module` for the Safe.
     * @dev This can only be done via a Safe transaction.
     * @param prevModule Previous module in the modules linked list.
     * @param module Module to be removed.
     */
    function disableModule(address prevModule, address module) public authorized {
        // Validate module address and check that it corresponds to module index.
        require(module != address(0) && module != SENTINEL_MODULES, "GS101");
        require(modules[prevModule] == module, "GS103");
        modules[prevModule] = modules[module];
        modules[module] = address(0);
        emit DisabledModule(module);
    }

    /**
     * @notice Execute `operation` (0: Call, 1: DelegateCall) to `to` with `value` (Native Token)
     * @dev Function is virtual to allow overriding for L2 singleton to emit an event for indexing.
     * @param to Destination address of module transaction.
     * @param value Ether value of module transaction.
     * @param data Data payload of module transaction.
     * @param operation Operation type of module transaction.
     * @return success Boolean flag indicating if the call succeeded.
     */
    function execTransactionFromModule(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation
    ) public virtual returns (bool success) {
        // Only whitelisted modules are allowed.
        require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "GS104");
        // Execute transaction without further confirmations.
        success = execute(to, value, data, operation, type(uint256).max);
        if (success) emit ExecutionFromModuleSuccess(msg.sender);
        else emit ExecutionFromModuleFailure(msg.sender);
    }

    /**
     * @notice Execute `operation` (0: Call, 1: DelegateCall) to `to` with `value` (Native Token) and return data
     * @param to Destination address of module transaction.
     * @param value Ether value of module transaction.
     * @param data Data payload of module transaction.
     * @param operation Operation type of module transaction.
     * @return success Boolean flag indicating if the call succeeded.
     * @return returnData Data returned by the call.
     */
    function execTransactionFromModuleReturnData(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation
    ) public returns (bool success, bytes memory returnData) {
        success = execTransactionFromModule(to, value, data, operation);
        // solhint-disable-next-line no-inline-assembly
        assembly {
            // Load free memory location
            let ptr := mload(0x40)
            // We allocate memory for the return data by setting the free memory location to
            // current free memory location + data size + 32 bytes for data size value
            mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
            // Store the size
            mstore(ptr, returndatasize())
            // Store the data
            returndatacopy(add(ptr, 0x20), 0, returndatasize())
            // Point the return data to the correct memory location
            returnData := ptr
        }
    }

    /**
     * @notice Returns if an module is enabled
     * @return True if the module is enabled
     */
    function isModuleEnabled(address module) public view returns (bool) {
        return SENTINEL_MODULES != module && modules[module] != address(0);
    }

    /**
     * @notice Returns an array of modules.
     *         If all entries fit into a single page, the next pointer will be 0x1.
     *         If another page is present, next will be the last element of the returned array.
     * @param start Start of the page. Has to be a module or start pointer (0x1 address)
     * @param pageSize Maximum number of modules that should be returned. Has to be > 0
     * @return array Array of modules.
     * @return next Start of the next page.
     */
    function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {
        require(start == SENTINEL_MODULES || isModuleEnabled(start), "GS105");
        require(pageSize > 0, "GS106");
        // Init array with max page size
        array = new address[](pageSize);

        // Populate return array
        uint256 moduleCount = 0;
        next = modules[start];
        while (next != address(0) && next != SENTINEL_MODULES && moduleCount < pageSize) {
            array[moduleCount] = next;
            next = modules[next];
            moduleCount++;
        }

        /**
          Because of the argument validation, we can assume that the loop will always iterate over the valid module list values
          and the `next` variable will either be an enabled module or a sentinel address (signalling the end). 
          
          If we haven't reached the end inside the loop, we need to set the next pointer to the last element of the modules array
          because the `next` variable (which is a module by itself) acting as a pointer to the start of the next page is neither 
          included to the current page, nor will it be included in the next one if you pass it as a start.
        */
        if (next != SENTINEL_MODULES) {
            next = array[moduleCount - 1];
        }
        // Set correct size of returned array
        // solhint-disable-next-line no-inline-assembly
        assembly {
            mstore(array, moduleCount)
        }
    }

    /**
     * @notice Returns true if `account` 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 account The address being queried
     */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }
}

File 5 of 24 : OwnerManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "../common/SelfAuthorized.sol";

/**
 * @title OwnerManager - Manages Safe owners and a threshold to authorize transactions.
 * @dev Uses a linked list to store the owners because the code generate by the solidity compiler
 *      is more efficient than using a dynamic array.
 * @author Stefan George - @Georgi87
 * @author Richard Meissner - @rmeissner
 */
abstract contract OwnerManager is SelfAuthorized {
    event AddedOwner(address indexed owner);
    event RemovedOwner(address indexed owner);
    event ChangedThreshold(uint256 threshold);

    address internal constant SENTINEL_OWNERS = address(0x1);

    mapping(address => address) internal owners;
    uint256 internal ownerCount;
    uint256 internal threshold;

    /**
     * @notice Sets the initial storage of the contract.
     * @param _owners List of Safe owners.
     * @param _threshold Number of required confirmations for a Safe transaction.
     */
    function setupOwners(address[] memory _owners, uint256 _threshold) internal {
        // Threshold can only be 0 at initialization.
        // Check ensures that setup function can only be called once.
        require(threshold == 0, "GS200");
        // Validate that threshold is smaller than number of added owners.
        require(_threshold <= _owners.length, "GS201");
        // There has to be at least one Safe owner.
        require(_threshold >= 1, "GS202");
        // Initializing Safe owners.
        address currentOwner = SENTINEL_OWNERS;
        for (uint256 i = 0; i < _owners.length; i++) {
            // Owner address cannot be null.
            address owner = _owners[i];
            require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, "GS203");
            // No duplicate owners allowed.
            require(owners[owner] == address(0), "GS204");
            owners[currentOwner] = owner;
            currentOwner = owner;
        }
        owners[currentOwner] = SENTINEL_OWNERS;
        ownerCount = _owners.length;
        threshold = _threshold;
    }

    /**
     * @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.
     * @dev This can only be done via a Safe transaction.
     * @param owner New owner address.
     * @param _threshold New threshold.
     */
    function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {
        // Owner address cannot be null, the sentinel or the Safe itself.
        require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), "GS203");
        // No duplicate owners allowed.
        require(owners[owner] == address(0), "GS204");
        owners[owner] = owners[SENTINEL_OWNERS];
        owners[SENTINEL_OWNERS] = owner;
        ownerCount++;
        emit AddedOwner(owner);
        // Change threshold if threshold was changed.
        if (threshold != _threshold) changeThreshold(_threshold);
    }

    /**
     * @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.
     * @dev This can only be done via a Safe transaction.
     * @param prevOwner Owner that pointed to the owner to be removed in the linked list
     * @param owner Owner address to be removed.
     * @param _threshold New threshold.
     */
    function removeOwner(address prevOwner, address owner, uint256 _threshold) public authorized {
        // Only allow to remove an owner, if threshold can still be reached.
        require(ownerCount - 1 >= _threshold, "GS201");
        // Validate owner address and check that it corresponds to owner index.
        require(owner != address(0) && owner != SENTINEL_OWNERS, "GS203");
        require(owners[prevOwner] == owner, "GS205");
        owners[prevOwner] = owners[owner];
        owners[owner] = address(0);
        ownerCount--;
        emit RemovedOwner(owner);
        // Change threshold if threshold was changed.
        if (threshold != _threshold) changeThreshold(_threshold);
    }

    /**
     * @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.
     * @dev This can only be done via a Safe transaction.
     * @param prevOwner Owner that pointed to the owner to be replaced in the linked list
     * @param oldOwner Owner address to be replaced.
     * @param newOwner New owner address.
     */
    function swapOwner(address prevOwner, address oldOwner, address newOwner) public authorized {
        // Owner address cannot be null, the sentinel or the Safe itself.
        require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "GS203");
        // No duplicate owners allowed.
        require(owners[newOwner] == address(0), "GS204");
        // Validate oldOwner address and check that it corresponds to owner index.
        require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "GS203");
        require(owners[prevOwner] == oldOwner, "GS205");
        owners[newOwner] = owners[oldOwner];
        owners[prevOwner] = newOwner;
        owners[oldOwner] = address(0);
        emit RemovedOwner(oldOwner);
        emit AddedOwner(newOwner);
    }

    /**
     * @notice Changes the threshold of the Safe to `_threshold`.
     * @dev This can only be done via a Safe transaction.
     * @param _threshold New threshold.
     */
    function changeThreshold(uint256 _threshold) public authorized {
        // Validate that threshold is smaller than number of owners.
        require(_threshold <= ownerCount, "GS201");
        // There has to be at least one Safe owner.
        require(_threshold >= 1, "GS202");
        threshold = _threshold;
        emit ChangedThreshold(threshold);
    }

    /**
     * @notice Returns the number of required confirmations for a Safe transaction aka the threshold.
     * @return Threshold number.
     */
    function getThreshold() public view returns (uint256) {
        return threshold;
    }

    /**
     * @notice Returns if `owner` is an owner of the Safe.
     * @return Boolean if owner is an owner of the Safe.
     */
    function isOwner(address owner) public view returns (bool) {
        return owner != SENTINEL_OWNERS && owners[owner] != address(0);
    }

    /**
     * @notice Returns a list of Safe owners.
     * @return Array of Safe owners.
     */
    function getOwners() public view returns (address[] memory) {
        address[] memory array = new address[](ownerCount);

        // populate return array
        uint256 index = 0;
        address currentOwner = owners[SENTINEL_OWNERS];
        while (currentOwner != SENTINEL_OWNERS) {
            array[index] = currentOwner;
            currentOwner = owners[currentOwner];
            index++;
        }
        return array;
    }
}

File 6 of 24 : Enum.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Enum - Collection of enums used in Safe contracts.
 * @author Richard Meissner - @rmeissner
 */
abstract contract Enum {
    enum Operation {
        Call,
        DelegateCall
    }
}

File 7 of 24 : NativeCurrencyPaymentFallback.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title NativeCurrencyPaymentFallback - A contract that has a fallback to accept native currency payments.
 * @author Richard Meissner - @rmeissner
 */
abstract contract NativeCurrencyPaymentFallback {
    event SafeReceived(address indexed sender, uint256 value);

    /**
     * @notice Receive function accepts native currency transactions.
     * @dev Emits an event with sender and received value.
     */
    receive() external payable {
        emit SafeReceived(msg.sender, msg.value);
    }
}

File 8 of 24 : SecuredTokenTransfer.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SecuredTokenTransfer - Secure token transfer.
 * @author Richard Meissner - @rmeissner
 */
abstract contract SecuredTokenTransfer {
    /**
     * @notice Transfers a token and returns a boolean if it was a success
     * @dev It checks the return data of the transfer call and returns true if the transfer was successful.
     *      It doesn't check if the `token` address is a contract or not.
     * @param token Token that should be transferred
     * @param receiver Receiver to whom the token should be transferred
     * @param amount The amount of tokens that should be transferred
     * @return transferred Returns true if the transfer was successful
     */
    function transferToken(address token, address receiver, uint256 amount) internal returns (bool transferred) {
        // 0xa9059cbb - keccack("transfer(address,uint256)")
        bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);
        // solhint-disable-next-line no-inline-assembly
        assembly {
            // We write the return value to scratch space.
            // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory
            let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            switch returndatasize()
            case 0 {
                transferred := success
            }
            case 0x20 {
                transferred := iszero(or(iszero(success), iszero(mload(0))))
            }
            default {
                transferred := 0
            }
        }
    }
}

File 9 of 24 : SelfAuthorized.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SelfAuthorized - Authorizes current contract to perform actions to itself.
 * @author Richard Meissner - @rmeissner
 */
abstract contract SelfAuthorized {
    function requireSelfCall() private view {
        require(msg.sender == address(this), "GS031");
    }

    modifier authorized() {
        // Modifiers are copied around during compilation. This is a function call as it minimized the bytecode size
        requireSelfCall();
        _;
    }
}

File 10 of 24 : SignatureDecoder.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SignatureDecoder - Decodes signatures encoded as bytes
 * @author Richard Meissner - @rmeissner
 */
abstract contract SignatureDecoder {
    /**
     * @notice Splits signature bytes into `uint8 v, bytes32 r, bytes32 s`.
     * @dev Make sure to perform a bounds check for @param pos, to avoid out of bounds access on @param signatures
     *      The signature format is a compact form of {bytes32 r}{bytes32 s}{uint8 v}
     *      Compact means uint8 is not padded to 32 bytes.
     * @param pos Which signature to read.
     *            A prior bounds check of this parameter should be performed, to avoid out of bounds access.
     * @param signatures Concatenated {r, s, v} signatures.
     * @return v Recovery ID or Safe signature type.
     * @return r Output value r of the signature.
     * @return s Output value s of the signature.
     */
    function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let signaturePos := mul(0x41, pos)
            r := mload(add(signatures, add(signaturePos, 0x20)))
            s := mload(add(signatures, add(signaturePos, 0x40)))
            /**
             * Here we are loading the last 32 bytes, including 31 bytes
             * of 's'. There is no 'mload8' to do this.
             * 'byte' is not working due to the Solidity parser, so lets
             * use the second best option, 'and'
             */
            v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)
        }
    }
}

File 11 of 24 : Singleton.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Singleton - Base for singleton contracts (should always be the first super contract)
 *        This contract is tightly coupled to our proxy contract (see `proxies/SafeProxy.sol`)
 * @author Richard Meissner - @rmeissner
 */
abstract contract Singleton {
    // singleton always has to be the first declared variable to ensure the same location as in the Proxy contract.
    // It should also always be ensured the address is stored alone (uses a full word)
    address private singleton;
}

File 12 of 24 : StorageAccessible.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title StorageAccessible - A generic base contract that allows callers to access all internal storage.
 * @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol
 *         It removes a method from the original contract not needed for the Safe contracts.
 * @author Gnosis Developers
 */
abstract contract StorageAccessible {
    /**
     * @notice Reads `length` bytes of storage in the currents contract
     * @param offset - the offset in the current contract's storage in words to start reading from
     * @param length - the number of words (32 bytes) of data to read
     * @return the bytes that were read.
     */
    function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {
        bytes memory result = new bytes(length * 32);
        for (uint256 index = 0; index < length; index++) {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                let word := sload(add(offset, index))
                mstore(add(add(result, 0x20), mul(index, 0x20)), word)
            }
        }
        return result;
    }

    /**
     * @dev Performs a delegatecall on a targetContract in the context of self.
     * Internally reverts execution to avoid side effects (making it static).
     *
     * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.
     * Specifically, the `returndata` after a call to this method will be:
     * `success:bool || response.length:uint256 || response:bytes`.
     *
     * @param targetContract Address of the contract containing the code to execute.
     * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).
     */
    function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)

            mstore(0x00, success)
            mstore(0x20, returndatasize())
            returndatacopy(0x40, 0, returndatasize())
            revert(0, add(returndatasize(), 0x40))
        }
    }
}

File 13 of 24 : SafeMath.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SafeMath
 * @notice Math operations with safety checks that revert on error (overflow/underflow)
 */
library SafeMath {
    /**
     * @notice Multiplies two numbers, reverts on overflow.
     * @param a First number
     * @param b Second number
     * @return Product of a and b
     */
    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-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }

    /**
     * @notice Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
     * @param a First number
     * @param b Second number
     * @return Difference of a and b
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a);
        uint256 c = a - b;

        return c;
    }

    /**
     * @notice Adds two numbers, reverts on overflow.
     * @param a First number
     * @param b Second number
     * @return Sum of a and b
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);

        return c;
    }

    /**
     * @notice Returns the largest of two numbers.
     * @param a First number
     * @param b Second number
     * @return Largest of a and b
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }
}

File 14 of 24 : IERC165.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by `interfaceId`.
     * See the corresponding EIP section
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 15 of 24 : ISignatureValidator.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

contract ISignatureValidatorConstants {
    // bytes4(keccak256("isValidSignature(bytes,bytes)")
    bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;
}

abstract contract ISignatureValidator is ISignatureValidatorConstants {
    /**
     * @notice Legacy EIP1271 method to validate a signature.
     * @param _data Arbitrary length data signed on the behalf of address(this).
     * @param _signature Signature byte array associated with _data.
     *
     * MUST return the bytes4 magic value 0x20c13b0b when function passes.
     * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
     * MUST allow external calls
     */
    function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);
}

File 16 of 24 : Safe.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "./base/ModuleManager.sol";
import "./base/OwnerManager.sol";
import "./base/FallbackManager.sol";
import "./base/GuardManager.sol";
import "./common/NativeCurrencyPaymentFallback.sol";
import "./common/Singleton.sol";
import "./common/SignatureDecoder.sol";
import "./common/SecuredTokenTransfer.sol";
import "./common/StorageAccessible.sol";
import "./interfaces/ISignatureValidator.sol";
import "./external/SafeMath.sol";

/**
 * @title Safe - A multisignature wallet with support for confirmations using signed messages based on EIP-712.
 * @dev Most important concepts:
 *      - Threshold: Number of required confirmations for a Safe transaction.
 *      - Owners: List of addresses that control the Safe. They are the only ones that can add/remove owners, change the threshold and
 *        approve transactions. Managed in `OwnerManager`.
 *      - Transaction Hash: Hash of a transaction is calculated using the EIP-712 typed structured data hashing scheme.
 *      - Nonce: Each transaction should have a different nonce to prevent replay attacks.
 *      - Signature: A valid signature of an owner of the Safe for a transaction hash.
 *      - Guard: Guard is a contract that can execute pre- and post- transaction checks. Managed in `GuardManager`.
 *      - Modules: Modules are contracts that can be used to extend the write functionality of a Safe. Managed in `ModuleManager`.
 *      - Fallback: Fallback handler is a contract that can provide additional read-only functional for Safe. Managed in `FallbackManager`.
 *      Note: This version of the implementation contract doesn't emit events for the sake of gas efficiency and therefore requires a tracing node for indexing/
 *      For the events-based implementation see `SafeL2.sol`.
 * @author Stefan George - @Georgi87
 * @author Richard Meissner - @rmeissner
 */
contract Safe is
    Singleton,
    NativeCurrencyPaymentFallback,
    ModuleManager,
    OwnerManager,
    SignatureDecoder,
    SecuredTokenTransfer,
    ISignatureValidatorConstants,
    FallbackManager,
    StorageAccessible,
    GuardManager
{
    using SafeMath for uint256;

    string public constant VERSION = "1.4.0";

    // keccak256(
    //     "EIP712Domain(uint256 chainId,address verifyingContract)"
    // );
    bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;

    // keccak256(
    //     "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
    // );
    bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;

    event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);
    event ApproveHash(bytes32 indexed approvedHash, address indexed owner);
    event SignMsg(bytes32 indexed msgHash);
    event ExecutionFailure(bytes32 indexed txHash, uint256 payment);
    event ExecutionSuccess(bytes32 indexed txHash, uint256 payment);

    uint256 public nonce;
    bytes32 private _deprecatedDomainSeparator;
    // Mapping to keep track of all message hashes that have been approved by ALL REQUIRED owners
    mapping(bytes32 => uint256) public signedMessages;
    // Mapping to keep track of all hashes (message or transaction) that have been approved by ANY owners
    mapping(address => mapping(bytes32 => uint256)) public approvedHashes;

    // This constructor ensures that this contract can only be used as a singleton for Proxy contracts
    constructor() {
        /**
         * By setting the threshold it is not possible to call setup anymore,
         * so we create a Safe with 0 owners and threshold 1.
         * This is an unusable Safe, perfect for the singleton
         */
        threshold = 1;
    }

    /**
     * @notice Sets an initial storage of the Safe contract.
     * @dev This method can only be called once.
     *      If a proxy was created without setting up, anyone can call setup and claim the proxy.
     * @param _owners List of Safe owners.
     * @param _threshold Number of required confirmations for a Safe transaction.
     * @param to Contract address for optional delegate call.
     * @param data Data payload for optional delegate call.
     * @param fallbackHandler Handler for fallback calls to this contract
     * @param paymentToken Token that should be used for the payment (0 is ETH)
     * @param payment Value that should be paid
     * @param paymentReceiver Address that should receive the payment (or 0 if tx.origin)
     */
    function setup(
        address[] calldata _owners,
        uint256 _threshold,
        address to,
        bytes calldata data,
        address fallbackHandler,
        address paymentToken,
        uint256 payment,
        address payable paymentReceiver
    ) external {
        // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice
        setupOwners(_owners, _threshold);
        if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
        // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
        setupModules(to, data);

        if (payment > 0) {
            // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)
            // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment
            handlePayment(payment, 0, 1, paymentToken, paymentReceiver);
        }
        emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);
    }

    /** @notice Executes a `operation` {0: Call, 1: DelegateCall}} transaction to `to` with `value` (Native Currency)
     *          and pays `gasPrice` * `gasLimit` in `gasToken` token to `refundReceiver`.
     * @dev The fees are always transferred, even if the user transaction fails.
     *      This method doesn't perform any sanity check of the transaction, such as:
     *      - if the contract at `to` address has code or not
     *      - if the `gasToken` is a contract or not
     *      It is the responsibility of the caller to perform such checks.
     * @param to Destination address of Safe transaction.
     * @param value Ether value of Safe transaction.
     * @param data Data payload of Safe transaction.
     * @param operation Operation type of Safe transaction.
     * @param safeTxGas Gas that should be used for the Safe transaction.
     * @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
     * @param gasPrice Gas price that should be used for the payment calculation.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     * @return success Boolean indicating transaction's success.
     */
    function execTransaction(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver,
        bytes memory signatures
    ) public payable virtual returns (bool success) {
        bytes32 txHash;
        // Use scope here to limit variable lifetime and prevent `stack too deep` errors
        {
            bytes memory txHashData = encodeTransactionData(
                // Transaction info
                to,
                value,
                data,
                operation,
                safeTxGas,
                // Payment info
                baseGas,
                gasPrice,
                gasToken,
                refundReceiver,
                // Signature info
                nonce
            );
            // Increase nonce and execute transaction.
            nonce++;
            txHash = keccak256(txHashData);
            checkSignatures(txHash, txHashData, signatures);
        }
        address guard = getGuard();
        {
            if (guard != address(0)) {
                Guard(guard).checkTransaction(
                    // Transaction info
                    to,
                    value,
                    data,
                    operation,
                    safeTxGas,
                    // Payment info
                    baseGas,
                    gasPrice,
                    gasToken,
                    refundReceiver,
                    // Signature info
                    signatures,
                    msg.sender
                );
            }
        }
        // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)
        // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150
        require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, "GS010");
        // Use scope here to limit variable lifetime and prevent `stack too deep` errors
        {
            uint256 gasUsed = gasleft();
            // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)
            // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas
            success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);
            gasUsed = gasUsed.sub(gasleft());
            // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful
            // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert
            require(success || safeTxGas != 0 || gasPrice != 0, "GS013");
            // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls
            uint256 payment = 0;
            if (gasPrice > 0) {
                payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);
            }
            if (success) emit ExecutionSuccess(txHash, payment);
            else emit ExecutionFailure(txHash, payment);
        }
        {
            if (guard != address(0)) {
                Guard(guard).checkAfterExecution(txHash, success);
            }
        }
    }

    /**
     * @notice Handles the payment for a Safe transaction.
     * @param gasUsed Gas used by the Safe transaction.
     * @param baseGas Gas costs that are independent of the transaction execution (e.g. base transaction fee, signature check, payment of the refund).
     * @param gasPrice Gas price that should be used for the payment calculation.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @return payment The amount of payment made in the specified token.
     */
    function handlePayment(
        uint256 gasUsed,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver
    ) private returns (uint256 payment) {
        // solhint-disable-next-line avoid-tx-origin
        address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;
        if (gasToken == address(0)) {
            // For ETH we will only adjust the gas price to not be higher than the actual used gas price
            payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);
            require(receiver.send(payment), "GS011");
        } else {
            payment = gasUsed.add(baseGas).mul(gasPrice);
            require(transferToken(gasToken, receiver, payment), "GS012");
        }
    }

    /**
     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.
     * @param dataHash Hash of the data (could be either a message hash or transaction hash)
     * @param data That should be signed (this is passed to an external validator contract)
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     */
    function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures) public view {
        // Load threshold to avoid multiple storage loads
        uint256 _threshold = threshold;
        // Check that a threshold is set
        require(_threshold > 0, "GS001");
        checkNSignatures(dataHash, data, signatures, _threshold);
    }

    /**
     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.
     * @dev Since the EIP-1271 does an external call, be mindful of reentrancy attacks.
     * @param dataHash Hash of the data (could be either a message hash or transaction hash)
     * @param data That should be signed (this is passed to an external validator contract)
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     * @param requiredSignatures Amount of required valid signatures.
     */
    function checkNSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, uint256 requiredSignatures) public view {
        // Check that the provided signature data is not too short
        require(signatures.length >= requiredSignatures.mul(65), "GS020");
        // There cannot be an owner with address 0.
        address lastOwner = address(0);
        address currentOwner;
        uint8 v;
        bytes32 r;
        bytes32 s;
        uint256 i;
        for (i = 0; i < requiredSignatures; i++) {
            (v, r, s) = signatureSplit(signatures, i);
            if (v == 0) {
                require(keccak256(data) == dataHash, "GS027");
                // If v is 0 then it is a contract signature
                // When handling contract signatures the address of the contract is encoded into r
                currentOwner = address(uint160(uint256(r)));

                // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes
                // This check is not completely accurate, since it is possible that more signatures than the threshold are send.
                // Here we only check that the pointer is not pointing inside the part that is being processed
                require(uint256(s) >= requiredSignatures.mul(65), "GS021");

                // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)
                require(uint256(s).add(32) <= signatures.length, "GS022");

                // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length
                uint256 contractSignatureLen;
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    contractSignatureLen := mload(add(add(signatures, s), 0x20))
                }
                require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, "GS023");

                // Check signature
                bytes memory contractSignature;
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s
                    contractSignature := add(add(signatures, s), 0x20)
                }
                require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, "GS024");
            } else if (v == 1) {
                // If v is 1 then it is an approved hash
                // When handling approved hashes the address of the approver is encoded into r
                currentOwner = address(uint160(uint256(r)));
                // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction
                require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "GS025");
            } else if (v > 30) {
                // If v > 30 then default va (27,28) has been adjusted for eth_sign flow
                // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover
                currentOwner = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash)), v - 4, r, s);
            } else {
                // Default is the ecrecover flow with the provided data hash
                // Use ecrecover with the messageHash for EOA signatures
                currentOwner = ecrecover(dataHash, v, r, s);
            }
            require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, "GS026");
            lastOwner = currentOwner;
        }
    }

    /**
     * @notice Marks hash `hashToApprove` as approved.
     * @dev This can be used with a pre-approved hash transaction signature.
     *      IMPORTANT: The approved hash stays approved forever. There's no revocation mechanism, so it behaves similarly to ECDSA signatures
     * @param hashToApprove The hash to mark as approved for signatures that are verified by this contract.
     */
    function approveHash(bytes32 hashToApprove) external {
        require(owners[msg.sender] != address(0), "GS030");
        approvedHashes[msg.sender][hashToApprove] = 1;
        emit ApproveHash(hashToApprove, msg.sender);
    }

    /**
     * @notice Returns the ID of the chain the contract is currently deployed on.
     * @return The ID of the current chain as a uint256.
     */
    function getChainId() public view returns (uint256) {
        uint256 id;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            id := chainid()
        }
        return id;
    }

    /**
     * @dev Returns the domain separator for this contract, as defined in the EIP-712 standard.
     * @return bytes32 The domain separator hash.
     */
    function domainSeparator() public view returns (bytes32) {
        return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));
    }

    /**
     * @notice Returns the pre-image of the transaction hash (see getTransactionHash).
     * @param to Destination address.
     * @param value Ether value.
     * @param data Data payload.
     * @param operation Operation type.
     * @param safeTxGas Gas that should be used for the safe transaction.
     * @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
     * @param gasPrice Maximum gas price that should be used for this transaction.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
     * @param _nonce Transaction nonce.
     * @return Transaction hash bytes.
     */
    function encodeTransactionData(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address refundReceiver,
        uint256 _nonce
    ) public view returns (bytes memory) {
        bytes32 safeTxHash = keccak256(
            abi.encode(
                SAFE_TX_TYPEHASH,
                to,
                value,
                keccak256(data),
                operation,
                safeTxGas,
                baseGas,
                gasPrice,
                gasToken,
                refundReceiver,
                _nonce
            )
        );
        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);
    }

    /**
     * @notice Returns transaction hash to be signed by owners.
     * @param to Destination address.
     * @param value Ether value.
     * @param data Data payload.
     * @param operation Operation type.
     * @param safeTxGas Fas that should be used for the safe transaction.
     * @param baseGas Gas costs for data used to trigger the safe transaction.
     * @param gasPrice Maximum gas price that should be used for this transaction.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
     * @param _nonce Transaction nonce.
     * @return Transaction hash.
     */
    function getTransactionHash(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address refundReceiver,
        uint256 _nonce
    ) public view returns (bytes32) {
        return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));
    }
}

File 17 of 24 : IERC1271.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 18 of 24 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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");

        (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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 19 of 24 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // 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 (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 20 of 24 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../Address.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Gnosis Safe.
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        if (error == ECDSA.RecoverError.NoError && recovered == signer) {
            return true;
        }

        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success &&
            result.length == 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

File 21 of 24 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 22 of 24 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 23 of 24 : SocialRecoveryModule.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

import "./storage/IGuardianStorage.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@gnosis.pm/safe-contracts/contracts/Safe.sol";

/// @title Social Recovery Module
/// @author CANDIDE Labs
contract SocialRecoveryModule {
    string public constant NAME = "Social Recovery Module";
    string public constant VERSION = "0.0.1";

    // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
    bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;

    // keccak256("ExecuteRecovery(address wallet,address[] newOwners,uint256 newThreshold,uint256 nonce)");
    bytes32 private constant EXECUTE_RECOVERY_TYPEHASH = 0x124b64921a7c7e677c6cc3b132eaaa57130bc6fc05ab157f35fe5264a7c198d5;

    address internal constant SENTINEL_OWNERS = address(0x1);

    struct SignatureData {
        address signer;
        bytes signature;
    }

    struct RecoveryRequest {
        uint256 guardiansApprovalCount;
        uint256 newThreshold;
        uint64 executeAfter;
        address[] newOwners;
    }

    mapping (address => RecoveryRequest) internal recoveryRequests;
    mapping (bytes32 => mapping (address => bool)) internal confirmedHashes;
    mapping (address => uint256) internal walletsNonces;

    // The guardians storage
    IGuardianStorage internal immutable guardianStorage;
    // Recovery period
    uint256 internal immutable recoveryPeriod;

    event GuardianAdded(address indexed wallet, address indexed guardian, uint256 threshold);
    event GuardianRevoked(address indexed wallet, address indexed guardian, uint256 threshold);
    event RecoveryExecuted(address indexed wallet, address[] indexed newOwners, uint256 newThreshold, uint256 nonce, uint64 executeAfter, uint256 guardiansApprovalCount);
    event RecoveryFinalized(address indexed wallet, address[] indexed newOwners, uint256 newThreshold, uint256 nonce);
    event RecoveryCanceled(address indexed wallet, uint256 nonce);

    /**
     * @notice Throws if the sender is not the module itself or the owner of the target wallet.
     */
    modifier authorized(address _wallet) {
        require(msg.sender == _wallet, "SM: unauthorized");
        _;
    }

    /**
     * @notice Throws if there is no ongoing recovery request.
     */
    modifier whenRecovery(address _wallet) {
        require(recoveryRequests[_wallet].executeAfter > 0, "SM: no ongoing recovery");
        _;
    }

    /**
     * @notice Throws if there is an ongoing recovery request.
     */
    modifier whenNotRecovery(address _wallet) {
        require(recoveryRequests[_wallet].executeAfter == 0, "SM: ongoing recovery");
        _;
    }

    constructor(IGuardianStorage _guardianStorage, uint256 _recoveryPeriod) {
        guardianStorage = _guardianStorage;
        recoveryPeriod = _recoveryPeriod;
    }

    ////////////////


    /// @dev Returns the chain id used by this contract.
    function getChainId() public view returns (uint256) {
        uint256 id;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            id := chainid()
        }
        return id;
    }

    function domainSeparator() public view returns (bytes32) {
        return keccak256(
            abi.encode(
                DOMAIN_SEPARATOR_TYPEHASH, 
                keccak256(abi.encodePacked(NAME)),
                keccak256(abi.encodePacked(VERSION)),
                getChainId(), 
                this
            )
        );
    }

    /// @dev Returns the bytes that are hashed to be signed by guardians.
    function encodeRecoveryData(address _wallet, address[] calldata _newOwners, uint256 _newThreshold, uint256 _nonce) public view returns (bytes memory) {
        bytes32 recoveryHash = keccak256(
            abi.encode(
                EXECUTE_RECOVERY_TYPEHASH, 
                _wallet,
                keccak256(abi.encodePacked(_newOwners)),
                _newThreshold,
                _nonce
            )
        );
        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), recoveryHash);
    }

    /// @dev Generates the recovery hash that should be signed by the guardian to authorize a recovery
    function getRecoveryHash(address _wallet, address[] calldata _newOwners, uint256 _newThreshold, uint256 _nonce) public view returns (bytes32) {
        return keccak256(encodeRecoveryData(_wallet, _newOwners, _newThreshold, _nonce));
    }

    /// @dev checks if valid signature to the provided signer, and if this signer is indeed a guardian, revert otherwise
    function validateGuardianSignature(
        address _wallet,
        bytes32 _signHash,
        address _signer,
        bytes memory _signature
    ) public view {
        require(isGuardian(_wallet, _signer), "SM: Signer not a guardian");
        require(SignatureChecker.isValidSignatureNow(_signer, _signHash, _signature), "SM: Invalid guardian signature");
    }


    /**
     * @notice Lets single guardian confirm the execution of the recovery request.
     * Can also trigger the start of the execution by passing true to '_execute' parameter.
     * Once triggered the recovery is pending for the recovery period before it can be finalised.
     * @param _wallet The target wallet.
     * @param _newOwners The new owners' addressess.
     * @param _newThreshold The new threshold for the safe.
     * @param _execute Whether to auto-start execution of recovery.
     */
    function confirmRecovery(address _wallet, address[] calldata _newOwners, uint256 _newThreshold, bool _execute) external {
        require(isGuardian(_wallet, msg.sender), "SM: sender not a guardian");
        require(_newOwners.length > 0, "SM: owners cannot be empty");
        require(_newThreshold > 0 && _newOwners.length >= _newThreshold, "SM: invalid new threshold");
        //
        uint256 _nonce = nonce(_wallet);
        bytes32 recoveryHash = keccak256(encodeRecoveryData(_wallet, _newOwners, _newThreshold, _nonce));
        confirmedHashes[recoveryHash][msg.sender] = true;
        //
        if (!_execute) return;
        uint256 guardiansThreshold = threshold(_wallet);
        uint256 _approvalCount = getRecoveryApprovals(_wallet, _newOwners, _newThreshold);
        require(_approvalCount >= guardiansThreshold, "SM: confirmed signatures less than threshold");
        _executeRecovery(_wallet, _newOwners, _newThreshold, _approvalCount);
    }

    /**
     * @notice Lets multiple guardians confirm the execution of the recovery request.
     * Can also trigger the start of the execution by passing true to '_execute' parameter.
     * Once triggered the recovery is pending for the recovery period before it can be finalised.
     * @param _wallet The target wallet.
     * @param _newOwners The new owners' addressess.
     * @param _newThreshold The new threshold for the safe.
     * @param _signatures The guardians signatures.
     * @param _execute Whether to auto-start execution of recovery.
     */
    function multiConfirmRecovery(address _wallet, address[] calldata _newOwners, uint256 _newThreshold, SignatureData[] memory _signatures, bool _execute) external {
        require(_newOwners.length > 0, "SM: owners cannot be empty");
        require(_newThreshold > 0 && _newOwners.length >= _newThreshold, "SM: invalid new threshold");
        require(_signatures.length > 0, "SM: empty signatures");
        uint256 guardiansThreshold = threshold(_wallet);
        require(guardiansThreshold > 0, "SM: empty guardians");
        //
        uint256 _nonce = nonce(_wallet);
        bytes32 recoveryHash = keccak256(encodeRecoveryData(_wallet, _newOwners, _newThreshold, _nonce));
        address lastSigner = address(0);
        for (uint256 i = 0; i < _signatures.length; i++) {
            SignatureData memory value = _signatures[i];
            if (value.signature.length == 0){
                require(isGuardian(_wallet, msg.sender), "SM: sender not a guardian");
                require(msg.sender == value.signer, "SM: null signature should have the signer as the sender");
            }else{
                validateGuardianSignature(_wallet, recoveryHash, value.signer, value.signature);
            }
            require(value.signer > lastSigner, "SM: duplicate signers/invalid ordering");
            confirmedHashes[recoveryHash][value.signer] = true;
            lastSigner = value.signer;
        }
        //
        if (!_execute) return;
        uint256 _approvalCount = getRecoveryApprovals(_wallet, _newOwners, _newThreshold);
        require(_approvalCount >= guardiansThreshold, "SM: confirmed signatures less than threshold");
        _executeRecovery(_wallet, _newOwners, _newThreshold, _approvalCount);
    }


    function executeRecovery(address _wallet, address[] calldata _newOwners, uint256 _newThreshold) external {
        uint256 guardiansThreshold = threshold(_wallet);
        require(guardiansThreshold > 0, "SM: empty guardians");
        //
        uint256 _approvalCount = getRecoveryApprovals(_wallet, _newOwners, _newThreshold);
        require(_approvalCount >= guardiansThreshold, "SM: confirmed signatures less than threshold");
        _executeRecovery(_wallet, _newOwners, _newThreshold, _approvalCount);
    }

    /**
     * @notice Lets the guardians start the execution of the recovery request.
     * Once triggered the recovery is pending for the recovery period before it can be finalised.
     * @param _wallet The target wallet.
     * @param _newOwners The new owners' addressess.
     * @param _newThreshold The new threshold for the safe.
     * @param _approvalCount The collected (confirmed) guardians signatures for this recovery operation.
     */
    function _executeRecovery(address _wallet, address[] calldata _newOwners, uint256 _newThreshold, uint256 _approvalCount) internal {
        uint256 _nonce = nonce(_wallet);
        // If an ongoing recovery exists, replace only if more guardians than the previous guardians have approved this replacement
        RecoveryRequest storage request = recoveryRequests[_wallet];
        if (request.executeAfter > 0){
            require(_approvalCount > request.guardiansApprovalCount, "SM: not enough approvals for replacement");
            delete recoveryRequests[_wallet];
            emit RecoveryCanceled(_wallet, _nonce - 1);
        }
        // Start recovery execution
        uint64 executeAfter = uint64(block.timestamp + recoveryPeriod);
        recoveryRequests[_wallet] = RecoveryRequest(_approvalCount, _newThreshold, executeAfter, _newOwners);
        walletsNonces[_wallet]++;
        emit RecoveryExecuted(_wallet, _newOwners, _newThreshold, _nonce, executeAfter, _approvalCount);
    }

    /**
     * @notice Finalizes an ongoing recovery request if the recovery period is over.
     * The method is public and callable by anyone to enable orchestration.
     * @param _wallet The target wallet.
     */
    function finalizeRecovery(address _wallet) external whenRecovery(_wallet) {
        RecoveryRequest storage request = recoveryRequests[_wallet];
        require(uint64(block.timestamp) >= request.executeAfter, "SM: recovery period still pending");
        address[] memory newOwners = request.newOwners;
        uint256 newThreshold = request.newThreshold;
        delete recoveryRequests[_wallet];

        Safe safe = Safe(payable(_wallet));
        address[] memory owners = safe.getOwners();

        for (uint256 i = (owners.length - 1); i > 0; --i) {
            bool success = safe.execTransactionFromModule({
                to: _wallet,
                value: 0,
                data: abi.encodeCall(OwnerManager.removeOwner, (owners[i - 1], owners[i], 1)),
                operation: Enum.Operation.Call
            });
            if (!success) {
                revert("SM: owner removal failed");
            }
        }

        for (uint256 i = 0; i < newOwners.length; i++) {
            require(!isGuardian(_wallet, newOwners[i]), "SM: new owner cannot be guardian");
            bool success;
            if (i == 0){
                if (newOwners[i] == owners[i]) continue;
                success = safe.execTransactionFromModule({
                    to: _wallet,
                    value: 0,
                    data: abi.encodeCall(OwnerManager.swapOwner, (SENTINEL_OWNERS, owners[i], newOwners[i])),
                    operation: Enum.Operation.Call
                });
                if (!success) {
                    revert("SM: owner replacement failed");
                }
                continue;
            }
            success = safe.execTransactionFromModule({
                to: _wallet,
                value: 0,
                data: abi.encodeCall(OwnerManager.addOwnerWithThreshold, (newOwners[i], 1)),
                operation: Enum.Operation.Call
            });
            if (!success) {
                revert("SM: owner addition failed");
            }
        }


        if (newThreshold > 1){
            bool success = safe.execTransactionFromModule({
                to: _wallet,
                value: 0,
                data: abi.encodeCall(OwnerManager.changeThreshold, (newThreshold)),
                operation: Enum.Operation.Call
            });
            if (!success) {
                revert("SM: change threshold failed");
            }
        }

        emit RecoveryFinalized(_wallet, newOwners, newThreshold, walletsNonces[_wallet] - 1);
    }

    /**
     * @notice Lets the owner cancel an ongoing recovery request.
     * @param _wallet The target wallet.
     */
    function cancelRecovery(address _wallet) external authorized(_wallet) whenRecovery(_wallet) {
        delete recoveryRequests[_wallet];
        emit RecoveryCanceled(_wallet, walletsNonces[_wallet] - 1);
    }

    /**
     * @notice Lets the owner add a guardian for its wallet.
     * @param _wallet The target wallet.
     * @param _guardian The guardian to add.
     * @param _threshold The new threshold that will be set after addition.
     */
    function addGuardianWithThreshold(address _wallet, address _guardian, uint256 _threshold) external authorized(_wallet) {
        guardianStorage.addGuardian(_wallet, _guardian);
        guardianStorage.changeThreshold(_wallet, _threshold);
        emit GuardianAdded(_wallet, _guardian, _threshold);
    }

    /**
     * @notice Lets the owner revoke a guardian from its wallet.
     * @param _wallet The target wallet.
     * @param _prevGuardian The previous guardian linking to the guardian in the linked list.
     * @param _guardian The guardian to revoke.
     * @param _threshold The new threshold that will be set after execution of revokation.
     */
    function revokeGuardianWithThreshold(address _wallet, address _prevGuardian, address _guardian, uint256 _threshold) external authorized(_wallet) {
        require(isGuardian(_wallet, _guardian), "SM: must be existing guardian");
        uint256 _guardiansCount = guardianStorage.guardiansCount(_wallet);
        require(_guardiansCount - 1 >= _threshold, "SM: invalid threshold");
        guardianStorage.revokeGuardian(_wallet, _prevGuardian, _guardian);
        guardianStorage.changeThreshold(_wallet, _threshold);
        emit GuardianRevoked(_wallet, _guardian, _threshold);
    }

    /**
     * @notice Lets the owner change the guardian threshold required to initiate a recovery.
     * @param _wallet The target wallet.
     * @param _threshold The new threshold that will be set after execution of revokation.
     */
    function changeThreshold(address _wallet, uint256 _threshold) external authorized(_wallet) {
        guardianStorage.changeThreshold(_wallet, _threshold);
    }

    /**
     * @notice Retrieves the wallet's current ongoing recovery request.
     * @param _wallet The target wallet.
     * @return request The wallet's current recovery request
     */
    function getRecoveryRequest(address _wallet) public view returns (RecoveryRequest memory request) {
        return recoveryRequests[_wallet];
    }

    /**
     * @notice Retrieves the guardian approval count for this particular recovery request at current nonce.
     * @param _wallet The target wallet.
     * @param _newOwners The new owners' addressess.
     * @param _newThreshold The new threshold for the safe.
     * @return approvalCount The wallet's current recovery request
     */
    function getRecoveryApprovals(address _wallet, address[] calldata _newOwners, uint256 _newThreshold) public view returns (uint256 approvalCount) {
        uint256 _nonce = nonce(_wallet);
        bytes32 recoveryHash = keccak256(encodeRecoveryData(_wallet, _newOwners, _newThreshold, _nonce));
        address[] memory guardians = getGuardians(_wallet);
        approvalCount = 0;
        for (uint256 i = 0; i < guardians.length; i++) {
            if (confirmedHashes[recoveryHash][guardians[i]]){
                approvalCount++;
            }
        }
    }

    /**
     * @notice Retrieves specific guardian approval status a particular recovery request at current nonce.
     * @param _wallet The target wallet.
     * @param _guardian The guardian.
     * @param _newOwners The new owners' addressess.
     * @param _newThreshold The new threshold for the safe.
     * @return approvalCount The wallet's current recovery request
     */
    function hasGuardianApproved(address _wallet, address _guardian, address[] calldata _newOwners, uint256 _newThreshold) public view returns (bool) {
        uint256 _nonce = nonce(_wallet);
        bytes32 recoveryHash = keccak256(encodeRecoveryData(_wallet, _newOwners, _newThreshold, _nonce));
        return confirmedHashes[recoveryHash][_guardian];
    }

    /**
     * @notice Checks if an address is a guardian for a wallet.
     * @param _wallet The target wallet.
     * @param _guardian The address to check.
     * @return _isGuardian `true` if the address is a guardian for the wallet otherwise `false`.
     */
    function isGuardian(address _wallet, address _guardian) public view returns (bool _isGuardian) {
        return guardianStorage.isGuardian(_wallet, _guardian);
    }

    /**
     * @notice Counts the number of active guardians for a wallet.
     * @param _wallet The target wallet.
     * @return _count The number of active guardians for a wallet.
     */
    function guardiansCount(address _wallet) public view returns (uint256 _count) {
        return guardianStorage.guardiansCount(_wallet);
    }

    /**
     * @dev Retrieves the wallet threshold count.
     * @param _wallet The target wallet.
     * @return _threshold Threshold count.
     */
    function threshold(address _wallet) public view returns (uint256 _threshold) {
        return guardianStorage.threshold(_wallet);
    }

    /**
     * @notice Get the active guardians for a wallet.
     * @param _wallet The target wallet.
     * @return _guardians the active guardians for a wallet.
     */
    function getGuardians(address _wallet) public view returns (address[] memory _guardians) {
        return guardianStorage.getGuardians(_wallet);
    }

    /**
     * @notice Get the module nonce for a wallet.
     * @param _wallet The target wallet.
     * @return _nonce the nonce for this wallet.
     */
    function nonce(address _wallet) public view returns (uint256 _nonce) {
        return walletsNonces[_wallet];
    }

}

File 24 of 24 : IGuardianStorage.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

interface IGuardianStorage {

    /**
     * @dev Lets an authorised module add a guardian to a wallet.
     * @param _wallet The target wallet.
     * @param _guardian The guardian to add.
     */
    function addGuardian(address _wallet, address _guardian) external;

    /**
     * @dev Lets an authorised module revoke a guardian from a wallet.
     * @param _wallet The target wallet.
     * @param _prevGuardian Guardian that pointed to the guardian to be removed in the linked list
     * @param _guardian The guardian to revoke.
     */
    function revokeGuardian(address _wallet, address _prevGuardian, address _guardian) external;
    
    /**
     * @dev Allows to update the number of required confirmations by guardians.
     * @param _wallet The target wallet.
     * @param _threshold New threshold.
     */
    function changeThreshold(address _wallet, uint256 _threshold) external;

    /**
     * @dev Checks if an account is a guardian for a wallet.
     * @param _wallet The target wallet.
     * @param _guardian The account.
     * @return true if the account is a guardian for a wallet.
     */
    function isGuardian(address _wallet, address _guardian) external view returns (bool);
    
    /**
     * @dev Retrieves the wallet guardians count.
     * @param _wallet The target wallet.
     * @return uint256 Guardians count.
     */
    function guardiansCount(address _wallet) external view returns (uint256);

    /**
     * @dev Retrieves the wallet threshold count.
     * @param _wallet The target wallet.
     * @return uint256 Threshold count.
     */
    function threshold(address _wallet) external view returns (uint256);

    /**
     * @dev Retrieves all guardians for a wallet.
     * @param _wallet The target wallet.
     * @return address[] Array of guardians.
     */
    function getGuardians(address _wallet) external view returns (address[] memory);


}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"contract IGuardianStorage","name":"_guardianStorage","type":"address"},{"internalType":"uint256","name":"_recoveryPeriod","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address","name":"guardian","type":"address"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"GuardianAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address","name":"guardian","type":"address"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"GuardianRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"RecoveryCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address[]","name":"newOwners","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"newThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"executeAfter","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"guardiansApprovalCount","type":"uint256"}],"name":"RecoveryExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address[]","name":"newOwners","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"newThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"RecoveryFinalized","type":"event"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address","name":"_guardian","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"addGuardianWithThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"cancelRecovery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"changeThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"},{"internalType":"bool","name":"_execute","type":"bool"}],"name":"confirmRecovery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"encodeRecoveryData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"}],"name":"executeRecovery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"finalizeRecovery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"getGuardians","outputs":[{"internalType":"address[]","name":"_guardians","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"}],"name":"getRecoveryApprovals","outputs":[{"internalType":"uint256","name":"approvalCount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"getRecoveryHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"getRecoveryRequest","outputs":[{"components":[{"internalType":"uint256","name":"guardiansApprovalCount","type":"uint256"},{"internalType":"uint256","name":"newThreshold","type":"uint256"},{"internalType":"uint64","name":"executeAfter","type":"uint64"},{"internalType":"address[]","name":"newOwners","type":"address[]"}],"internalType":"struct SocialRecoveryModule.RecoveryRequest","name":"request","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"guardiansCount","outputs":[{"internalType":"uint256","name":"_count","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address","name":"_guardian","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"}],"name":"hasGuardianApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address","name":"_guardian","type":"address"}],"name":"isGuardian","outputs":[{"internalType":"bool","name":"_isGuardian","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address[]","name":"_newOwners","type":"address[]"},{"internalType":"uint256","name":"_newThreshold","type":"uint256"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct SocialRecoveryModule.SignatureData[]","name":"_signatures","type":"tuple[]"},{"internalType":"bool","name":"_execute","type":"bool"}],"name":"multiConfirmRecovery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"nonce","outputs":[{"internalType":"uint256","name":"_nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"address","name":"_prevGuardian","type":"address"},{"internalType":"address","name":"_guardian","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"revokeGuardianWithThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"threshold","outputs":[{"internalType":"uint256","name":"_threshold","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"bytes32","name":"_signHash","type":"bytes32"},{"internalType":"address","name":"_signer","type":"address"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"validateGuardianSignature","outputs":[],"stateMutability":"view","type":"function"}]

60c06040523480156200001157600080fd5b50604051620030043803806200300483398101604081905262000034916200004b565b6001600160a01b0390911660805260a05262000087565b600080604083850312156200005f57600080fd5b82516001600160a01b03811681146200007757600080fd5b6020939093015192949293505050565b60805160a051612f18620000ec600039600061205801526000818161097401528181610a6401528181610ae4015281816116c301528181611862015281816118e201528181611af801528181611b8e01528181611d210152611db70152612f186000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806370ae92d2116100c3578063c86ec2bf1161007c578063c86ec2bf146102ff578063c90db44714610312578063d4ee973414610325578063f18858ab14610338578063f698da2514610358578063ffa1ad741461036057600080fd5b806370ae92d2146102555780639b890b701461027e578063a3f4df7e14610291578063b00c57c5146102c6578063b1f85f69146102d9578063c026e7ee146102ec57600080fd5b80633408e470116101155780633408e470146101c957806337d82c36146101d95780634f9a28b9146101fc57806357cfebbc1461021c5780635f19df081461022f5780636c6595ca1461024257600080fd5b8063064e2d0e146101525780630728e1e7146101675780631a0487a01461017a5780631e01c4f01461018d578063315a7af3146101b6575b600080fd5b610165610160366004612547565b610384565b005b6101656101753660046126ba565b610537565b610165610188366004612836565b6108d3565b6101a061019b366004612887565b610b97565b6040516101ad9190612945565b60405180910390f35b6101656101c4366004612958565b610c8b565b465b6040519081526020016101ad565b6101ec6101e7366004612975565b611537565b60405190151581526020016101ad565b61020f61020a366004612958565b611596565b6040516101ad9190612a25565b61016561022a366004612a6f565b611674565b6101cb61023d366004612887565b611724565b6101cb610250366004612a9b565b611745565b6101cb610263366004612958565b6001600160a01b031660009081526002602052604090205490565b61016561028c366004612af6565b611812565b6101a060405180604001604052806016815260200175536f6369616c205265636f76657279204d6f64756c6560501b81525081565b6101656102d4366004612b37565b611993565b6101656102e7366004612a9b565b611a46565b6101cb6102fa366004612958565b611ad6565b6101cb61030d366004612958565b611b6c565b610165610320366004612958565b611bbf565b6101ec610333366004612ba2565b611cf7565b61034b610346366004612958565b611d95565b6040516101ad9190612bdb565b6101cb611e28565b6101a060405180604001604052806005815260200164302e302e3160d81b81525081565b61038e8533611cf7565b6103db5760405162461bcd60e51b815260206004820152601960248201527829a69d1039b2b73232b9103737ba10309033bab0b93234b0b760391b60448201526064015b60405180910390fd5b826104285760405162461bcd60e51b815260206004820152601a60248201527f534d3a206f776e6572732063616e6e6f7420626520656d70747900000000000060448201526064016103d2565b6000821180156104385750818310155b6104805760405162461bcd60e51b815260206004820152601960248201527814d34e881a5b9d985b1a59081b995dc81d1a1c995cda1bdb19603a1b60448201526064016103d2565b6001600160a01b038516600090815260026020526040812054906104a78787878786610b97565b8051602091820120600081815260018084526040808320338452909452929020805460ff19169092179091559050826104e1575050610530565b60006104ec88611b6c565b905060006104fc89898989611745565b90508181101561051e5760405162461bcd60e51b81526004016103d290612bee565b61052b8989898985611f2e565b505050505b5050505050565b836105845760405162461bcd60e51b815260206004820152601a60248201527f534d3a206f776e6572732063616e6e6f7420626520656d70747900000000000060448201526064016103d2565b6000831180156105945750828410155b6105dc5760405162461bcd60e51b815260206004820152601960248201527814d34e881a5b9d985b1a59081b995dc81d1a1c995cda1bdb19603a1b60448201526064016103d2565b60008251116106245760405162461bcd60e51b8152602060048201526014602482015273534d3a20656d707479207369676e61747572657360601b60448201526064016103d2565b600061062f87611b6c565b9050600081116106775760405162461bcd60e51b8152602060048201526013602482015272534d3a20656d70747920677561726469616e7360681b60448201526064016103d2565b6001600160a01b0387166000908152600260205260408120549061069e8989898986610b97565b8051906020012090506000805b86518110156108795760008782815181106106c8576106c8612c3a565b60200260200101519050806020015151600014156107b6576106ea8c33611cf7565b6107325760405162461bcd60e51b815260206004820152601960248201527829a69d1039b2b73232b9103737ba10309033bab0b93234b0b760391b60448201526064016103d2565b80516001600160a01b031633146107b15760405162461bcd60e51b815260206004820152603760248201527f534d3a206e756c6c207369676e61747572652073686f756c642068617665207460448201527f6865207369676e6572206173207468652073656e64657200000000000000000060648201526084016103d2565b6107ca565b6107ca8c8583600001518460200151611993565b80516001600160a01b038085169116116108355760405162461bcd60e51b815260206004820152602660248201527f534d3a206475706c6963617465207369676e6572732f696e76616c6964206f72604482015265646572696e6760d01b60648201526084016103d2565b600084815260016020818152604080842085516001600160a01b03168552909152909120805460ff191690911790555191508061087181612c66565b9150506106ab565b508461088857505050506108cb565b60006108968b8b8b8b611745565b9050848110156108b85760405162461bcd60e51b81526004016103d290612bee565b6108c58b8b8b8b85611f2e565b50505050505b505050505050565b83336001600160a01b038216146108fc5760405162461bcd60e51b81526004016103d290612c81565b6109068584611cf7565b6109525760405162461bcd60e51b815260206004820152601d60248201527f534d3a206d757374206265206578697374696e6720677561726469616e00000060448201526064016103d2565b60405163601373f760e11b81526001600160a01b0386811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063c026e7ee90602401602060405180830381865afa1580156109bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e19190612cab565b9050826109ef600183612cc4565b1015610a355760405162461bcd60e51b815260206004820152601560248201527414d34e881a5b9d985b1a59081d1a1c995cda1bdb19605a1b60448201526064016103d2565b6040516337993b9960e21b81526001600160a01b038781166004830152868116602483015285811660448301527f0000000000000000000000000000000000000000000000000000000000000000169063de64ee6490606401600060405180830381600087803b158015610aa857600080fd5b505af1158015610abc573d6000803e3d6000fd5b50506040516315f3faef60e21b81526001600160a01b038981166004830152602482018790527f00000000000000000000000000000000000000000000000000000000000000001692506357cfebbc9150604401600060405180830381600087803b158015610b2a57600080fd5b505af1158015610b3e573d6000803e3d6000fd5b50505050836001600160a01b0316866001600160a01b03167f27467b5307d3e9459421094efd94d076b4c6f8d00b78d5a12a3cecef307f0c4f85604051610b8791815260200190565b60405180910390a3505050505050565b606060007f124b64921a7c7e677c6cc3b132eaaa57130bc6fc05ab157f35fe5264a7c198d560001b878787604051602001610bd3929190612cdb565b60408051808303601f190181528282528051602091820120818401959095526001600160a01b03939093168282015260608201939093526080810187905260a08082018790528351808303909101815260c090910190925281519101209050601960f81b600160f81b610c44611e28565b6040516001600160f81b0319938416602082015292909116602183015260228201526042810182905260620160405160208183030381529060405291505095945050505050565b6001600160a01b03811660009081526020819052604090206002015481906001600160401b0316610cf85760405162461bcd60e51b8152602060048201526017602482015276534d3a206e6f206f6e676f696e67207265636f7665727960481b60448201526064016103d2565b6001600160a01b038216600090815260208190526040902060028101546001600160401b03908116429091161015610d7c5760405162461bcd60e51b815260206004820152602160248201527f534d3a207265636f7665727920706572696f64207374696c6c2070656e64696e6044820152606760f81b60648201526084016103d2565b600081600301805480602002602001604051908101604052809291908181526020018280548015610dd657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610db8575b505050506001848101546001600160a01b038816600090815260208190526040812081815592830181905560028301805467ffffffffffffffff1916905593945092909150610e286003830182612435565b505060008590506000816001600160a01b031663a0e67e2b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e6f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e979190810190612d1d565b9050600060018251610ea99190612cc4565b90505b801561101b5760006001600160a01b03841663468721a78a8386610ed1600188612cc4565b81518110610ee157610ee1612c3a565b6020026020010151878781518110610efb57610efb612c3a565b60209081029190910101516040516001600160a01b039283166024820152911660448201526001606482015260840160408051601f198184030181529181526020820180516001600160e01b031663f8dc5dd960e01b179052516001600160e01b031960e086901b168152610f7893929190600090600401612dcc565b6020604051808303816000875af1158015610f97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbb9190612e22565b90508061100a5760405162461bcd60e51b815260206004820152601860248201527f534d3a206f776e65722072656d6f76616c206661696c6564000000000000000060448201526064016103d2565b5061101481612e3f565b9050610eac565b5060005b845181101561138f5761104b8886838151811061103e5761103e612c3a565b6020026020010151611cf7565b156110985760405162461bcd60e51b815260206004820181905260248201527f534d3a206e6577206f776e65722063616e6e6f7420626520677561726469616e60448201526064016103d2565b60008161124f578282815181106110b1576110b1612c3a565b60200260200101516001600160a01b03168683815181106110d4576110d4612c3a565b60200260200101516001600160a01b031614156110f1575061137d565b836001600160a01b031663468721a78a6000600187878151811061111757611117612c3a565b60200260200101518b888151811061113157611131612c3a565b6020026020010151604051602401611169939291906001600160a01b0393841681529183166020830152909116604082015260600190565b60408051601f198184030181529181526020820180516001600160e01b031663e318b52b60e01b179052516001600160e01b031960e086901b1681526111b793929190600090600401612dcc565b6020604051808303816000875af11580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111fa9190612e22565b9050806112495760405162461bcd60e51b815260206004820152601c60248201527f534d3a206f776e6572207265706c6163656d656e74206661696c65640000000060448201526064016103d2565b5061137d565b836001600160a01b031663468721a78a600089868151811061127357611273612c3a565b60209081029190910101516040516001600160a01b0390911660248201526001604482015260640160408051601f198184030181529181526020820180516001600160e01b0316630d582f1360e01b179052516001600160e01b031960e086901b1681526112e993929190600090600401612dcc565b6020604051808303816000875af1158015611308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132c9190612e22565b90508061137b5760405162461bcd60e51b815260206004820152601960248201527f534d3a206f776e6572206164646974696f6e206661696c65640000000000000060448201526064016103d2565b505b8061138781612c66565b91505061101f565b5060018311156114a2576000826001600160a01b031663468721a7896000876040516024016113c091815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663694e80c360e01b179052516001600160e01b031960e086901b16815261140e93929190600090600401612dcc565b6020604051808303816000875af115801561142d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114519190612e22565b9050806114a05760405162461bcd60e51b815260206004820152601b60248201527f534d3a206368616e6765207468726573686f6c64206661696c6564000000000060448201526064016103d2565b505b836040516114b09190612e56565b6040518091039020876001600160a01b03167f8f02bbdd0d302f6cdd4a448157ae4156c07384b648beae077292ba804d60ad5a856001600260008d6001600160a01b03166001600160a01b03168152602001908152602001600020546115169190612cc4565b6040805192835260208301919091520160405180910390a350505050505050565b6001600160a01b038516600090815260026020526040812054600061155f8887878786610b97565b805160209182012060009081526001825260408082206001600160a01b038b168352909252205460ff169250505095945050505050565b6115ca6040518060800160405280600081526020016000815260200160006001600160401b03168152602001606081525090565b6001600160a01b0382166000908152602081815260409182902082516080810184528154815260018201548184015260028201546001600160401b031681850152600382018054855181860281018601909652808652919492936060860193929083018282801561166457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611646575b5050505050815250509050919050565b81336001600160a01b0382161461169d5760405162461bcd60e51b81526004016103d290612c81565b6040516315f3faef60e21b81526001600160a01b038481166004830152602482018490527f000000000000000000000000000000000000000000000000000000000000000016906357cfebbc90604401600060405180830381600087803b15801561170757600080fd5b505af115801561171b573d6000803e3d6000fd5b50505050505050565b60006117338686868686610b97565b80519060200120905095945050505050565b6001600160a01b038416600090815260026020526040812054600061176d8787878786610b97565b805190602001209050600061178188611d95565b90506000935060005b8151811015611806576001600084815260200190815260200160002060008383815181106117ba576117ba612c3a565b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff16156117f457846117f081612c66565b9550505b806117fe81612c66565b91505061178a565b50505050949350505050565b82336001600160a01b0382161461183b5760405162461bcd60e51b81526004016103d290612c81565b604051630c68452160e41b81526001600160a01b03858116600483015284811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063c684521090604401600060405180830381600087803b1580156118a657600080fd5b505af11580156118ba573d6000803e3d6000fd5b50506040516315f3faef60e21b81526001600160a01b038781166004830152602482018690527f00000000000000000000000000000000000000000000000000000000000000001692506357cfebbc9150604401600060405180830381600087803b15801561192857600080fd5b505af115801561193c573d6000803e3d6000fd5b50505050826001600160a01b0316846001600160a01b03167f6d0391926fd0fcb9e582cc3f9b1d2302bfd0866212cc067d5b137352a23a41bc8460405161198591815260200190565b60405180910390a350505050565b61199d8483611cf7565b6119e95760405162461bcd60e51b815260206004820152601960248201527f534d3a205369676e6572206e6f74206120677561726469616e0000000000000060448201526064016103d2565b6119f48284836121e9565b611a405760405162461bcd60e51b815260206004820152601e60248201527f534d3a20496e76616c696420677561726469616e207369676e6174757265000060448201526064016103d2565b50505050565b6000611a5185611b6c565b905060008111611a995760405162461bcd60e51b8152602060048201526013602482015272534d3a20656d70747920677561726469616e7360681b60448201526064016103d2565b6000611aa786868686611745565b905081811015611ac95760405162461bcd60e51b81526004016103d290612bee565b6108cb8686868685611f2e565b60405163601373f760e11b81526001600160a01b0382811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063c026e7ee906024015b602060405180830381865afa158015611b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b669190612cab565b92915050565b60405163c86ec2bf60e01b81526001600160a01b0382811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063c86ec2bf90602401611b25565b80336001600160a01b03821614611be85760405162461bcd60e51b81526004016103d290612c81565b6001600160a01b03821660009081526020819052604090206002015482906001600160401b0316611c555760405162461bcd60e51b8152602060048201526017602482015276534d3a206e6f206f6e676f696e67207265636f7665727960481b60448201526064016103d2565b6001600160a01b03831660009081526020819052604081208181556001810182905560028101805467ffffffffffffffff1916905590611c986003830182612435565b50506001600160a01b0383166000818152600260205260409020547f81da66c7aac3ee4365918a5d70f73e846a59e8a8af01ef155e8651819049051990611ce190600190612cc4565b60405190815260200160405180910390a2505050565b60405163353ba5cd60e21b81526001600160a01b03838116600483015282811660248301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063d4ee973490604401602060405180830381865afa158015611d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8e9190612e22565b9392505050565b60405163f18858ab60e01b81526001600160a01b0382811660048301526060917f00000000000000000000000000000000000000000000000000000000000000009091169063f18858ab90602401600060405180830381865afa158015611e00573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b669190810190612d1d565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60001b60405180604001604052806016815260200175536f6369616c205265636f76657279204d6f64756c6560501b815250604051602001611e8d9190612e95565b6040516020818303038152906040528051906020012060405180604001604052806005815260200164302e302e3160d81b815250604051602001611ed19190612e95565b60405160208183030381529060405280519060200120611eee4690565b604080516020810195909552840192909252606083015260808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b03851660009081526002602081815260408084205491849052909220908101546001600160401b0316156120515780548311611fc45760405162461bcd60e51b815260206004820152602860248201527f534d3a206e6f7420656e6f75676820617070726f76616c7320666f72207265706044820152671b1858d95b595b9d60c21b60648201526084016103d2565b6001600160a01b03871660009081526020819052604081208181556001810182905560028101805467ffffffffffffffff19169055906120076003830182612435565b50506001600160a01b0387167f81da66c7aac3ee4365918a5d70f73e846a59e8a8af01ef155e8651819049051961203f600185612cc4565b60405190815260200160405180910390a25b600061207d7f000000000000000000000000000000000000000000000000000000000000000042612eb1565b90506040518060800160405280858152602001868152602001826001600160401b0316815260200188888080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509390945250506001600160a01b038b1681526020818152604091829020845181558482015160018201559184015160028301805467ffffffffffffffff19166001600160401b03909216919091179055606084015180519293506121419260038501929190910190612456565b5050506001600160a01b038816600090815260026020526040812080549161216883612c66565b9190505550868660405161217d929190612cdb565b60408051918290038220878352602083018690526001600160401b0384168383015260608301879052905190916001600160a01b038b16917f1fa74635dcccfa96011b50295a26dd08b8c3c6ca7d66ede450288192674ebf019181900360800190a35050505050505050565b60008060006121f8858561232b565b9092509050600081600481111561221157612211612db6565b14801561222f5750856001600160a01b0316826001600160a01b0316145b1561223f57600192505050611d8e565b600080876001600160a01b0316631626ba7e60e01b8888604051602401612267929190612ec9565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516122a59190612e95565b600060405180830381855afa9150503d80600081146122e0576040519150601f19603f3d011682016040523d82523d6000602084013e6122e5565b606091505b50915091508180156122f8575080516020145b801561231f57508051630b135d3f60e11b9061231d9083016020908101908401612cab565b145b98975050505050505050565b6000808251604114156123625760208301516040840151606085015160001a61235687828585612371565b9450945050505061236a565b506000905060025b9250929050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156123a8575060009050600361242c565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156123fc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124255760006001925092505061242c565b9150600090505b94509492505050565b508054600082559060005260206000209081019061245391906124bb565b50565b8280548282559060005260206000209081019282156124ab579160200282015b828111156124ab57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612476565b506124b79291506124bb565b5090565b5b808211156124b757600081556001016124bc565b6001600160a01b038116811461245357600080fd5b60008083601f8401126124f757600080fd5b5081356001600160401b0381111561250e57600080fd5b6020830191508360208260051b850101111561236a57600080fd5b801515811461245357600080fd5b803561254281612529565b919050565b60008060008060006080868803121561255f57600080fd5b853561256a816124d0565b945060208601356001600160401b0381111561258557600080fd5b612591888289016124e5565b9095509350506040860135915060608601356125ac81612529565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156125f2576125f26125ba565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612620576126206125ba565b604052919050565b60006001600160401b03821115612641576126416125ba565b5060051b60200190565b600082601f83011261265c57600080fd5b81356001600160401b03811115612675576126756125ba565b612688601f8201601f19166020016125f8565b81815284602083860101111561269d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060a087890312156126d357600080fd5b6126dd87356124d0565b863595506001600160401b03602088013511156126f957600080fd5b61270988602089013589016124e5565b9095509350604087013592506001600160401b036060880135111561272d57600080fd5b6060870135870188601f82011261274357600080fd5b6127556127508235612628565b6125f8565b81358082526020808301929160051b8401018b101561277357600080fd5b602083015b6020843560051b850101811015612818576001600160401b038135111561279e57600080fd5b803584016040818e03601f190112156127b657600080fd5b6127be6125d0565b6127cb60208301356124d0565b602082013581526001600160401b03604083013511156127ea57600080fd5b6127fd8e6020604085013585010161264b565b60208201528085525050602083019250602081019050612778565b50935061282a91505060808801612537565b90509295509295509295565b6000806000806080858703121561284c57600080fd5b8435612857816124d0565b93506020850135612867816124d0565b92506040850135612877816124d0565b9396929550929360600135925050565b60008060008060006080868803121561289f57600080fd5b85356128aa816124d0565b945060208601356001600160401b038111156128c557600080fd5b6128d1888289016124e5565b9699909850959660408101359660609091013595509350505050565b60005b838110156129085781810151838201526020016128f0565b83811115611a405750506000910152565b600081518084526129318160208601602086016128ed565b601f01601f19169290920160200192915050565b602081526000611d8e6020830184612919565b60006020828403121561296a57600080fd5b8135611d8e816124d0565b60008060008060006080868803121561298d57600080fd5b8535612998816124d0565b945060208601356129a8816124d0565b935060408601356001600160401b038111156129c357600080fd5b6129cf888289016124e5565b96999598509660600135949350505050565b600081518084526020808501945080840160005b83811015612a1a5781516001600160a01b0316875295820195908201906001016129f5565b509495945050505050565b6020815281516020820152602082015160408201526001600160401b03604083015116606082015260006060830151608080840152612a6760a08401826129e1565b949350505050565b60008060408385031215612a8257600080fd5b8235612a8d816124d0565b946020939093013593505050565b60008060008060608587031215612ab157600080fd5b8435612abc816124d0565b935060208501356001600160401b03811115612ad757600080fd5b612ae3878288016124e5565b9598909750949560400135949350505050565b600080600060608486031215612b0b57600080fd5b8335612b16816124d0565b92506020840135612b26816124d0565b929592945050506040919091013590565b60008060008060808587031215612b4d57600080fd5b8435612b58816124d0565b9350602085013592506040850135612b6f816124d0565b915060608501356001600160401b03811115612b8a57600080fd5b612b968782880161264b565b91505092959194509250565b60008060408385031215612bb557600080fd5b8235612bc0816124d0565b91506020830135612bd0816124d0565b809150509250929050565b602081526000611d8e60208301846129e1565b6020808252602c908201527f534d3a20636f6e6669726d6564207369676e617475726573206c65737320746860408201526b185b881d1a1c995cda1bdb1960a21b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415612c7a57612c7a612c50565b5060010190565b60208082526010908201526f14d34e881d5b985d5d1a1bdc9a5e995960821b604082015260600190565b600060208284031215612cbd57600080fd5b5051919050565b600082821015612cd657612cd6612c50565b500390565b60008184825b85811015612d12578135612cf4816124d0565b6001600160a01b031683526020928301929190910190600101612ce1565b509095945050505050565b60006020808385031215612d3057600080fd5b82516001600160401b03811115612d4657600080fd5b8301601f81018513612d5757600080fd5b8051612d6561275082612628565b81815260059190911b82018301908381019087831115612d8457600080fd5b928401925b82841015612dab578351612d9c816124d0565b82529284019290840190612d89565b979650505050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000612df36080830185612919565b905060028310612e1357634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b600060208284031215612e3457600080fd5b8151611d8e81612529565b600081612e4e57612e4e612c50565b506000190190565b815160009082906020808601845b83811015612e895781516001600160a01b031685529382019390820190600101612e64565b50929695505050505050565b60008251612ea78184602087016128ed565b9190910192915050565b60008219821115612ec457612ec4612c50565b500190565b828152604060208201526000612a67604083018461291956fea26469706673582212205670aa5519d3b37874e5ac55f34618918aa17e52608b3f817219a598bf77df8a64736f6c634300080c0033000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40000000000000000000000000000000000000000000000000000000000000258

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806370ae92d2116100c3578063c86ec2bf1161007c578063c86ec2bf146102ff578063c90db44714610312578063d4ee973414610325578063f18858ab14610338578063f698da2514610358578063ffa1ad741461036057600080fd5b806370ae92d2146102555780639b890b701461027e578063a3f4df7e14610291578063b00c57c5146102c6578063b1f85f69146102d9578063c026e7ee146102ec57600080fd5b80633408e470116101155780633408e470146101c957806337d82c36146101d95780634f9a28b9146101fc57806357cfebbc1461021c5780635f19df081461022f5780636c6595ca1461024257600080fd5b8063064e2d0e146101525780630728e1e7146101675780631a0487a01461017a5780631e01c4f01461018d578063315a7af3146101b6575b600080fd5b610165610160366004612547565b610384565b005b6101656101753660046126ba565b610537565b610165610188366004612836565b6108d3565b6101a061019b366004612887565b610b97565b6040516101ad9190612945565b60405180910390f35b6101656101c4366004612958565b610c8b565b465b6040519081526020016101ad565b6101ec6101e7366004612975565b611537565b60405190151581526020016101ad565b61020f61020a366004612958565b611596565b6040516101ad9190612a25565b61016561022a366004612a6f565b611674565b6101cb61023d366004612887565b611724565b6101cb610250366004612a9b565b611745565b6101cb610263366004612958565b6001600160a01b031660009081526002602052604090205490565b61016561028c366004612af6565b611812565b6101a060405180604001604052806016815260200175536f6369616c205265636f76657279204d6f64756c6560501b81525081565b6101656102d4366004612b37565b611993565b6101656102e7366004612a9b565b611a46565b6101cb6102fa366004612958565b611ad6565b6101cb61030d366004612958565b611b6c565b610165610320366004612958565b611bbf565b6101ec610333366004612ba2565b611cf7565b61034b610346366004612958565b611d95565b6040516101ad9190612bdb565b6101cb611e28565b6101a060405180604001604052806005815260200164302e302e3160d81b81525081565b61038e8533611cf7565b6103db5760405162461bcd60e51b815260206004820152601960248201527829a69d1039b2b73232b9103737ba10309033bab0b93234b0b760391b60448201526064015b60405180910390fd5b826104285760405162461bcd60e51b815260206004820152601a60248201527f534d3a206f776e6572732063616e6e6f7420626520656d70747900000000000060448201526064016103d2565b6000821180156104385750818310155b6104805760405162461bcd60e51b815260206004820152601960248201527814d34e881a5b9d985b1a59081b995dc81d1a1c995cda1bdb19603a1b60448201526064016103d2565b6001600160a01b038516600090815260026020526040812054906104a78787878786610b97565b8051602091820120600081815260018084526040808320338452909452929020805460ff19169092179091559050826104e1575050610530565b60006104ec88611b6c565b905060006104fc89898989611745565b90508181101561051e5760405162461bcd60e51b81526004016103d290612bee565b61052b8989898985611f2e565b505050505b5050505050565b836105845760405162461bcd60e51b815260206004820152601a60248201527f534d3a206f776e6572732063616e6e6f7420626520656d70747900000000000060448201526064016103d2565b6000831180156105945750828410155b6105dc5760405162461bcd60e51b815260206004820152601960248201527814d34e881a5b9d985b1a59081b995dc81d1a1c995cda1bdb19603a1b60448201526064016103d2565b60008251116106245760405162461bcd60e51b8152602060048201526014602482015273534d3a20656d707479207369676e61747572657360601b60448201526064016103d2565b600061062f87611b6c565b9050600081116106775760405162461bcd60e51b8152602060048201526013602482015272534d3a20656d70747920677561726469616e7360681b60448201526064016103d2565b6001600160a01b0387166000908152600260205260408120549061069e8989898986610b97565b8051906020012090506000805b86518110156108795760008782815181106106c8576106c8612c3a565b60200260200101519050806020015151600014156107b6576106ea8c33611cf7565b6107325760405162461bcd60e51b815260206004820152601960248201527829a69d1039b2b73232b9103737ba10309033bab0b93234b0b760391b60448201526064016103d2565b80516001600160a01b031633146107b15760405162461bcd60e51b815260206004820152603760248201527f534d3a206e756c6c207369676e61747572652073686f756c642068617665207460448201527f6865207369676e6572206173207468652073656e64657200000000000000000060648201526084016103d2565b6107ca565b6107ca8c8583600001518460200151611993565b80516001600160a01b038085169116116108355760405162461bcd60e51b815260206004820152602660248201527f534d3a206475706c6963617465207369676e6572732f696e76616c6964206f72604482015265646572696e6760d01b60648201526084016103d2565b600084815260016020818152604080842085516001600160a01b03168552909152909120805460ff191690911790555191508061087181612c66565b9150506106ab565b508461088857505050506108cb565b60006108968b8b8b8b611745565b9050848110156108b85760405162461bcd60e51b81526004016103d290612bee565b6108c58b8b8b8b85611f2e565b50505050505b505050505050565b83336001600160a01b038216146108fc5760405162461bcd60e51b81526004016103d290612c81565b6109068584611cf7565b6109525760405162461bcd60e51b815260206004820152601d60248201527f534d3a206d757374206265206578697374696e6720677561726469616e00000060448201526064016103d2565b60405163601373f760e11b81526001600160a01b0386811660048301526000917f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd49091169063c026e7ee90602401602060405180830381865afa1580156109bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e19190612cab565b9050826109ef600183612cc4565b1015610a355760405162461bcd60e51b815260206004820152601560248201527414d34e881a5b9d985b1a59081d1a1c995cda1bdb19605a1b60448201526064016103d2565b6040516337993b9960e21b81526001600160a01b038781166004830152868116602483015285811660448301527f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd4169063de64ee6490606401600060405180830381600087803b158015610aa857600080fd5b505af1158015610abc573d6000803e3d6000fd5b50506040516315f3faef60e21b81526001600160a01b038981166004830152602482018790527f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd41692506357cfebbc9150604401600060405180830381600087803b158015610b2a57600080fd5b505af1158015610b3e573d6000803e3d6000fd5b50505050836001600160a01b0316866001600160a01b03167f27467b5307d3e9459421094efd94d076b4c6f8d00b78d5a12a3cecef307f0c4f85604051610b8791815260200190565b60405180910390a3505050505050565b606060007f124b64921a7c7e677c6cc3b132eaaa57130bc6fc05ab157f35fe5264a7c198d560001b878787604051602001610bd3929190612cdb565b60408051808303601f190181528282528051602091820120818401959095526001600160a01b03939093168282015260608201939093526080810187905260a08082018790528351808303909101815260c090910190925281519101209050601960f81b600160f81b610c44611e28565b6040516001600160f81b0319938416602082015292909116602183015260228201526042810182905260620160405160208183030381529060405291505095945050505050565b6001600160a01b03811660009081526020819052604090206002015481906001600160401b0316610cf85760405162461bcd60e51b8152602060048201526017602482015276534d3a206e6f206f6e676f696e67207265636f7665727960481b60448201526064016103d2565b6001600160a01b038216600090815260208190526040902060028101546001600160401b03908116429091161015610d7c5760405162461bcd60e51b815260206004820152602160248201527f534d3a207265636f7665727920706572696f64207374696c6c2070656e64696e6044820152606760f81b60648201526084016103d2565b600081600301805480602002602001604051908101604052809291908181526020018280548015610dd657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610db8575b505050506001848101546001600160a01b038816600090815260208190526040812081815592830181905560028301805467ffffffffffffffff1916905593945092909150610e286003830182612435565b505060008590506000816001600160a01b031663a0e67e2b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e6f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e979190810190612d1d565b9050600060018251610ea99190612cc4565b90505b801561101b5760006001600160a01b03841663468721a78a8386610ed1600188612cc4565b81518110610ee157610ee1612c3a565b6020026020010151878781518110610efb57610efb612c3a565b60209081029190910101516040516001600160a01b039283166024820152911660448201526001606482015260840160408051601f198184030181529181526020820180516001600160e01b031663f8dc5dd960e01b179052516001600160e01b031960e086901b168152610f7893929190600090600401612dcc565b6020604051808303816000875af1158015610f97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbb9190612e22565b90508061100a5760405162461bcd60e51b815260206004820152601860248201527f534d3a206f776e65722072656d6f76616c206661696c6564000000000000000060448201526064016103d2565b5061101481612e3f565b9050610eac565b5060005b845181101561138f5761104b8886838151811061103e5761103e612c3a565b6020026020010151611cf7565b156110985760405162461bcd60e51b815260206004820181905260248201527f534d3a206e6577206f776e65722063616e6e6f7420626520677561726469616e60448201526064016103d2565b60008161124f578282815181106110b1576110b1612c3a565b60200260200101516001600160a01b03168683815181106110d4576110d4612c3a565b60200260200101516001600160a01b031614156110f1575061137d565b836001600160a01b031663468721a78a6000600187878151811061111757611117612c3a565b60200260200101518b888151811061113157611131612c3a565b6020026020010151604051602401611169939291906001600160a01b0393841681529183166020830152909116604082015260600190565b60408051601f198184030181529181526020820180516001600160e01b031663e318b52b60e01b179052516001600160e01b031960e086901b1681526111b793929190600090600401612dcc565b6020604051808303816000875af11580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111fa9190612e22565b9050806112495760405162461bcd60e51b815260206004820152601c60248201527f534d3a206f776e6572207265706c6163656d656e74206661696c65640000000060448201526064016103d2565b5061137d565b836001600160a01b031663468721a78a600089868151811061127357611273612c3a565b60209081029190910101516040516001600160a01b0390911660248201526001604482015260640160408051601f198184030181529181526020820180516001600160e01b0316630d582f1360e01b179052516001600160e01b031960e086901b1681526112e993929190600090600401612dcc565b6020604051808303816000875af1158015611308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132c9190612e22565b90508061137b5760405162461bcd60e51b815260206004820152601960248201527f534d3a206f776e6572206164646974696f6e206661696c65640000000000000060448201526064016103d2565b505b8061138781612c66565b91505061101f565b5060018311156114a2576000826001600160a01b031663468721a7896000876040516024016113c091815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663694e80c360e01b179052516001600160e01b031960e086901b16815261140e93929190600090600401612dcc565b6020604051808303816000875af115801561142d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114519190612e22565b9050806114a05760405162461bcd60e51b815260206004820152601b60248201527f534d3a206368616e6765207468726573686f6c64206661696c6564000000000060448201526064016103d2565b505b836040516114b09190612e56565b6040518091039020876001600160a01b03167f8f02bbdd0d302f6cdd4a448157ae4156c07384b648beae077292ba804d60ad5a856001600260008d6001600160a01b03166001600160a01b03168152602001908152602001600020546115169190612cc4565b6040805192835260208301919091520160405180910390a350505050505050565b6001600160a01b038516600090815260026020526040812054600061155f8887878786610b97565b805160209182012060009081526001825260408082206001600160a01b038b168352909252205460ff169250505095945050505050565b6115ca6040518060800160405280600081526020016000815260200160006001600160401b03168152602001606081525090565b6001600160a01b0382166000908152602081815260409182902082516080810184528154815260018201548184015260028201546001600160401b031681850152600382018054855181860281018601909652808652919492936060860193929083018282801561166457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611646575b5050505050815250509050919050565b81336001600160a01b0382161461169d5760405162461bcd60e51b81526004016103d290612c81565b6040516315f3faef60e21b81526001600160a01b038481166004830152602482018490527f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd416906357cfebbc90604401600060405180830381600087803b15801561170757600080fd5b505af115801561171b573d6000803e3d6000fd5b50505050505050565b60006117338686868686610b97565b80519060200120905095945050505050565b6001600160a01b038416600090815260026020526040812054600061176d8787878786610b97565b805190602001209050600061178188611d95565b90506000935060005b8151811015611806576001600084815260200190815260200160002060008383815181106117ba576117ba612c3a565b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff16156117f457846117f081612c66565b9550505b806117fe81612c66565b91505061178a565b50505050949350505050565b82336001600160a01b0382161461183b5760405162461bcd60e51b81526004016103d290612c81565b604051630c68452160e41b81526001600160a01b03858116600483015284811660248301527f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd4169063c684521090604401600060405180830381600087803b1580156118a657600080fd5b505af11580156118ba573d6000803e3d6000fd5b50506040516315f3faef60e21b81526001600160a01b038781166004830152602482018690527f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd41692506357cfebbc9150604401600060405180830381600087803b15801561192857600080fd5b505af115801561193c573d6000803e3d6000fd5b50505050826001600160a01b0316846001600160a01b03167f6d0391926fd0fcb9e582cc3f9b1d2302bfd0866212cc067d5b137352a23a41bc8460405161198591815260200190565b60405180910390a350505050565b61199d8483611cf7565b6119e95760405162461bcd60e51b815260206004820152601960248201527f534d3a205369676e6572206e6f74206120677561726469616e0000000000000060448201526064016103d2565b6119f48284836121e9565b611a405760405162461bcd60e51b815260206004820152601e60248201527f534d3a20496e76616c696420677561726469616e207369676e6174757265000060448201526064016103d2565b50505050565b6000611a5185611b6c565b905060008111611a995760405162461bcd60e51b8152602060048201526013602482015272534d3a20656d70747920677561726469616e7360681b60448201526064016103d2565b6000611aa786868686611745565b905081811015611ac95760405162461bcd60e51b81526004016103d290612bee565b6108cb8686868685611f2e565b60405163601373f760e11b81526001600160a01b0382811660048301526000917f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd49091169063c026e7ee906024015b602060405180830381865afa158015611b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b669190612cab565b92915050565b60405163c86ec2bf60e01b81526001600160a01b0382811660048301526000917f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd49091169063c86ec2bf90602401611b25565b80336001600160a01b03821614611be85760405162461bcd60e51b81526004016103d290612c81565b6001600160a01b03821660009081526020819052604090206002015482906001600160401b0316611c555760405162461bcd60e51b8152602060048201526017602482015276534d3a206e6f206f6e676f696e67207265636f7665727960481b60448201526064016103d2565b6001600160a01b03831660009081526020819052604081208181556001810182905560028101805467ffffffffffffffff1916905590611c986003830182612435565b50506001600160a01b0383166000818152600260205260409020547f81da66c7aac3ee4365918a5d70f73e846a59e8a8af01ef155e8651819049051990611ce190600190612cc4565b60405190815260200160405180910390a2505050565b60405163353ba5cd60e21b81526001600160a01b03838116600483015282811660248301526000917f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd49091169063d4ee973490604401602060405180830381865afa158015611d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8e9190612e22565b9392505050565b60405163f18858ab60e01b81526001600160a01b0382811660048301526060917f000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd49091169063f18858ab90602401600060405180830381865afa158015611e00573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b669190810190612d1d565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60001b60405180604001604052806016815260200175536f6369616c205265636f76657279204d6f64756c6560501b815250604051602001611e8d9190612e95565b6040516020818303038152906040528051906020012060405180604001604052806005815260200164302e302e3160d81b815250604051602001611ed19190612e95565b60405160208183030381529060405280519060200120611eee4690565b604080516020810195909552840192909252606083015260808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b03851660009081526002602081815260408084205491849052909220908101546001600160401b0316156120515780548311611fc45760405162461bcd60e51b815260206004820152602860248201527f534d3a206e6f7420656e6f75676820617070726f76616c7320666f72207265706044820152671b1858d95b595b9d60c21b60648201526084016103d2565b6001600160a01b03871660009081526020819052604081208181556001810182905560028101805467ffffffffffffffff19169055906120076003830182612435565b50506001600160a01b0387167f81da66c7aac3ee4365918a5d70f73e846a59e8a8af01ef155e8651819049051961203f600185612cc4565b60405190815260200160405180910390a25b600061207d7f000000000000000000000000000000000000000000000000000000000000025842612eb1565b90506040518060800160405280858152602001868152602001826001600160401b0316815260200188888080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509390945250506001600160a01b038b1681526020818152604091829020845181558482015160018201559184015160028301805467ffffffffffffffff19166001600160401b03909216919091179055606084015180519293506121419260038501929190910190612456565b5050506001600160a01b038816600090815260026020526040812080549161216883612c66565b9190505550868660405161217d929190612cdb565b60408051918290038220878352602083018690526001600160401b0384168383015260608301879052905190916001600160a01b038b16917f1fa74635dcccfa96011b50295a26dd08b8c3c6ca7d66ede450288192674ebf019181900360800190a35050505050505050565b60008060006121f8858561232b565b9092509050600081600481111561221157612211612db6565b14801561222f5750856001600160a01b0316826001600160a01b0316145b1561223f57600192505050611d8e565b600080876001600160a01b0316631626ba7e60e01b8888604051602401612267929190612ec9565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516122a59190612e95565b600060405180830381855afa9150503d80600081146122e0576040519150601f19603f3d011682016040523d82523d6000602084013e6122e5565b606091505b50915091508180156122f8575080516020145b801561231f57508051630b135d3f60e11b9061231d9083016020908101908401612cab565b145b98975050505050505050565b6000808251604114156123625760208301516040840151606085015160001a61235687828585612371565b9450945050505061236a565b506000905060025b9250929050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156123a8575060009050600361242c565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156123fc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124255760006001925092505061242c565b9150600090505b94509492505050565b508054600082559060005260206000209081019061245391906124bb565b50565b8280548282559060005260206000209081019282156124ab579160200282015b828111156124ab57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612476565b506124b79291506124bb565b5090565b5b808211156124b757600081556001016124bc565b6001600160a01b038116811461245357600080fd5b60008083601f8401126124f757600080fd5b5081356001600160401b0381111561250e57600080fd5b6020830191508360208260051b850101111561236a57600080fd5b801515811461245357600080fd5b803561254281612529565b919050565b60008060008060006080868803121561255f57600080fd5b853561256a816124d0565b945060208601356001600160401b0381111561258557600080fd5b612591888289016124e5565b9095509350506040860135915060608601356125ac81612529565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156125f2576125f26125ba565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612620576126206125ba565b604052919050565b60006001600160401b03821115612641576126416125ba565b5060051b60200190565b600082601f83011261265c57600080fd5b81356001600160401b03811115612675576126756125ba565b612688601f8201601f19166020016125f8565b81815284602083860101111561269d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060a087890312156126d357600080fd5b6126dd87356124d0565b863595506001600160401b03602088013511156126f957600080fd5b61270988602089013589016124e5565b9095509350604087013592506001600160401b036060880135111561272d57600080fd5b6060870135870188601f82011261274357600080fd5b6127556127508235612628565b6125f8565b81358082526020808301929160051b8401018b101561277357600080fd5b602083015b6020843560051b850101811015612818576001600160401b038135111561279e57600080fd5b803584016040818e03601f190112156127b657600080fd5b6127be6125d0565b6127cb60208301356124d0565b602082013581526001600160401b03604083013511156127ea57600080fd5b6127fd8e6020604085013585010161264b565b60208201528085525050602083019250602081019050612778565b50935061282a91505060808801612537565b90509295509295509295565b6000806000806080858703121561284c57600080fd5b8435612857816124d0565b93506020850135612867816124d0565b92506040850135612877816124d0565b9396929550929360600135925050565b60008060008060006080868803121561289f57600080fd5b85356128aa816124d0565b945060208601356001600160401b038111156128c557600080fd5b6128d1888289016124e5565b9699909850959660408101359660609091013595509350505050565b60005b838110156129085781810151838201526020016128f0565b83811115611a405750506000910152565b600081518084526129318160208601602086016128ed565b601f01601f19169290920160200192915050565b602081526000611d8e6020830184612919565b60006020828403121561296a57600080fd5b8135611d8e816124d0565b60008060008060006080868803121561298d57600080fd5b8535612998816124d0565b945060208601356129a8816124d0565b935060408601356001600160401b038111156129c357600080fd5b6129cf888289016124e5565b96999598509660600135949350505050565b600081518084526020808501945080840160005b83811015612a1a5781516001600160a01b0316875295820195908201906001016129f5565b509495945050505050565b6020815281516020820152602082015160408201526001600160401b03604083015116606082015260006060830151608080840152612a6760a08401826129e1565b949350505050565b60008060408385031215612a8257600080fd5b8235612a8d816124d0565b946020939093013593505050565b60008060008060608587031215612ab157600080fd5b8435612abc816124d0565b935060208501356001600160401b03811115612ad757600080fd5b612ae3878288016124e5565b9598909750949560400135949350505050565b600080600060608486031215612b0b57600080fd5b8335612b16816124d0565b92506020840135612b26816124d0565b929592945050506040919091013590565b60008060008060808587031215612b4d57600080fd5b8435612b58816124d0565b9350602085013592506040850135612b6f816124d0565b915060608501356001600160401b03811115612b8a57600080fd5b612b968782880161264b565b91505092959194509250565b60008060408385031215612bb557600080fd5b8235612bc0816124d0565b91506020830135612bd0816124d0565b809150509250929050565b602081526000611d8e60208301846129e1565b6020808252602c908201527f534d3a20636f6e6669726d6564207369676e617475726573206c65737320746860408201526b185b881d1a1c995cda1bdb1960a21b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415612c7a57612c7a612c50565b5060010190565b60208082526010908201526f14d34e881d5b985d5d1a1bdc9a5e995960821b604082015260600190565b600060208284031215612cbd57600080fd5b5051919050565b600082821015612cd657612cd6612c50565b500390565b60008184825b85811015612d12578135612cf4816124d0565b6001600160a01b031683526020928301929190910190600101612ce1565b509095945050505050565b60006020808385031215612d3057600080fd5b82516001600160401b03811115612d4657600080fd5b8301601f81018513612d5757600080fd5b8051612d6561275082612628565b81815260059190911b82018301908381019087831115612d8457600080fd5b928401925b82841015612dab578351612d9c816124d0565b82529284019290840190612d89565b979650505050505050565b634e487b7160e01b600052602160045260246000fd5b60018060a01b0385168152836020820152608060408201526000612df36080830185612919565b905060028310612e1357634e487b7160e01b600052602160045260246000fd5b82606083015295945050505050565b600060208284031215612e3457600080fd5b8151611d8e81612529565b600081612e4e57612e4e612c50565b506000190190565b815160009082906020808601845b83811015612e895781516001600160a01b031685529382019390820190600101612e64565b50929695505050505050565b60008251612ea78184602087016128ed565b9190910192915050565b60008219821115612ec457612ec4612c50565b500190565b828152604060208201526000612a67604083018461291956fea26469706673582212205670aa5519d3b37874e5ac55f34618918aa17e52608b3f817219a598bf77df8a64736f6c634300080c0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd40000000000000000000000000000000000000000000000000000000000000258

-----Decoded View---------------
Arg [0] : _guardianStorage (address): 0xA7180e49f9E765d5bb3D3E2730bE5f4bbFD55cd4
Arg [1] : _recoveryPeriod (uint256): 600

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000a7180e49f9e765d5bb3d3e2730be5f4bbfd55cd4
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000258


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading