ETH Price: $3,396.53 (-0.61%)
Gas: 11 Gwei

Contract

0xAC7DB1339Cf7E85B6221cF791356f3ff3D6fB030
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040158481562022-10-28 17:49:11629 days ago1666979351IN
 Create: Bridge
0 ETH0.1049366827.48559854

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Bridge

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 47 : Bridge.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "./Admin.sol";
import "./BridgeOut.sol";
import "./BridgeIn.sol";
import "./Governance.sol";

/// @title Bridge allowing transfer of tokens (both fungible and non-fungible)
/// to/from GalaChain. The bridge can operate in two mods: locking or burning and depending on the mode
/// the tokens will either be locked/burnt or released/minted. For a locking bridge, if the bridge doesn't hold
/// enough tokens to release, it can mint the missing amount.
/// @author Piotr Buda
contract Bridge is Admin, Governance, BridgeOut, BridgeIn {
    constructor() initializer {}
}

File 2 of 47 : Governance.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";

import "./Structs.sol";
import "./Authority.sol";
import "./Setters.sol";

/// @title Governance
/// @notice This contract is a message handler for governance messages.
/// @author Piotr "pibu" Buda
contract Governance is Authority, Setters, ERC1967Upgrade {
    /// @notice This error is raised when the BridgeUpgrade message contains a timelock setting - the value of onlyAfterBlock != 0
    /// and the current block.number is not after that value.
    /// @param currentBlock the value of block.number
    /// @param onlyAfterBlock the value of the BridgeUpgrade.onlyAfterBlock
    error UpgradeTimelockViolation(uint256 currentBlock, uint256 onlyAfterBlock);

    /// @notice Allows to change the authorities responsible for signing the messages sent to the bridge.
    /// new authorities MUST contain at least one address
    /// @param message the message signed by the current authority with payload allowing to change the authorities
    function changeAuthorities(Structs.VSM calldata message) external {
        verifyAndUseGovernanceMessage(message);

        address[] memory keys = abi.decode(message.payload, (address[]));
        require(keys.length > 0, "NO_AUTHORITIES");

        setAuthorities(keys);
        emit AuthoritiesChanged(keys);
    }

    /// @notice Executes the upgrade message and if the init value is set, executes the call. If the onlyAfterBlock value is set,
    /// then the upgrade will fail if the current block number is not after the set value. This method reverts if the message is not signed,
    /// there is no quorum or the message doesn't come from the governance chaincode from the Play blockchain.
    /// @param message The VSM containing the Structs.BridgeUpgrade as payload.
    function upgrade(Structs.VSM calldata message) external {
        verifyAndUseGovernanceMessage(message);

        Structs.BridgeUpgrade memory bu = abi.decode(message.payload, (Structs.BridgeUpgrade));

        if (block.number < bu.onlyAfterBlock) {
            revert UpgradeTimelockViolation(block.number, bu.onlyAfterBlock);
        }

        _upgradeToAndCall(bu.newImplementation, bu.init, false);
    }

    /// @notice This is an extension of the verifyMessage function from the Authority contract that verifies that a message comes from governance entity.
    /// @dev The governance messages must originate from a specific contract, configured during the bridge deployment.
    /// This methodusedGovernanceMessagesr field of the VSM is not set to governanceContract value in the state.
    function verifyGovernanceMessage(Structs.VSM calldata message, bytes32 messageHash) public view returns (bool result, string memory failureReason) {
        if (isGovernanceMessageUsed(messageHash)) {
            return (false, "GOVERNANCE_MESSAGE_CONSUMED");
        }

        if (message.emitter != governanceContract()) {
            return (false, "NOT_FROM_GOVERNANCE_CONTRACT");
        }

        return verifyMessage(message, messageHash);
    }

    /// @dev a helper method to prevent recalculation of the message hash
    function verifyAndUseGovernanceMessage(Structs.VSM calldata message) internal {
        bytes32 messageHash = keccak256(abi.encodePacked(message.emitter, message.chainId, message.sequence, message.nonce, message.payload));
        (bool isValid, string memory reason) = verifyGovernanceMessage(message, messageHash);
        require(isValid, reason);
        useGovernanceMessage(messageHash);
    }
}

File 3 of 47 : Admin.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "./Getters.sol";
import "./Setters.sol";

/// @title Admin
/// @notice This contract exposes methods to carry out administrative tasks not handled by governance.
/// These methods are used for configuring the token mappings, enabling/disabling token bridges and pausing/unpausing bridge out operations.
/// @author Piotr "pibu" Buda
contract Admin is Getters, Setters {
    event BridgeInitialized(bytes tokenClassKey, address indexed token, uint256 baseType, TokenType tokenType, bool isburning);
    event ConversionInitialized(address indexed token, uint256 baseType, bytes tokenClassKey);
    event EnabledUpdated(bytes tokenClassKey, bool isEnabled);

    /// @notice Allows to setup a token bridge between this chain and the hub chain. This is a two-way bridge allowing
    /// to bridge tokens in and out of this EVM chain.
    /// @param tokenClassKey the token class key in the hub chain, uniquely identifying the token there
    /// @param token contract address of the EVM token
    /// @param baseType the base type (which is used to build token ids) of the EVM token
    /// @param tokenType the type of the EVM token (ERC20, ERC721 or ERC1155)
    /// @param burning whether the token bridge should work in the burning (true) or locking (false) mode
    /// @param enabled whether the token bridge should be enabled immediately (true) or not (false)
    function setupTokenBridge(
        bytes memory tokenClassKey,
        address token,
        uint256 baseType,
        TokenType tokenType,
        bool burning,
        bool enabled
    ) external onlyOwner {
        require(tokenClassKey.length > 0, "INVALID_TOKEN_CLASS_KEY");
        require(!isInitialized(tokenClassKey), "BRIDGE_INITIALIZED");
        require(token != address(0), "INVALID_TOKEN");
        require(tokenType != TokenType.UNKNOWN, "INVALID_TOKEN_TYPE");

        setTokenBridge(
            Structs.TokenBridge({tokenClassKey: tokenClassKey, initialized: true, burning: burning, enabled: enabled, token: token, baseType: baseType}),
            tokenType
        );

        emit BridgeInitialized(tokenClassKey, token, baseType, tokenType, burning);
        emit EnabledUpdated(tokenClassKey, enabled);
    }

    /// @notice Allows to setup a conversion funnel. This mechanism allows to bridge out tokens from this EVM chain from multiple contracts
    /// to a single token in the hub chain.
    /// @param token contract address of the EVM token
    /// @param baseType the base type (which is used to build token ids) of the EVM token
    /// @param tokenClassKey the token class key in the hub chain, uniquely identifying the token there
    function setupConversionFunnel(
        address token,
        uint256 baseType,
        bytes memory tokenClassKey
    ) external onlyOwner {
        require(token != address(0), "INVALID_TOKEN");
        require(tokenClassKey.length > 0, "INVALID_TOKEN_CLASS_KEY");
        address originalToken = getToken(tokenClassKey);
        setConversionFunnel(token, baseType, tokenClassKey, getTokenType(originalToken));
        emit ConversionInitialized(token, baseType, tokenClassKey);
    }

    /// @notice Sets the enabled flag for token bridge.
    /// @param tokenClassKey the token class key for which the enabled flag should be toggled
    /// @param enabled a flag indication whether to set the bridge as enabled or not
    function setTokenBridgeEnabled(bytes memory tokenClassKey, bool enabled) external onlyOwner {
        //use the getter to verify the enabled flag can be set on it
        require(isInitialized(tokenClassKey), "NOT_INITIALIZED");

        setEnabled(tokenClassKey, enabled);

        emit EnabledUpdated(tokenClassKey, enabled);
    }

    function pause() external whenNotPaused onlyOwner {
        _pause();
    }

    function unpause() external whenPaused onlyOwner {
        _unpause();
    }
}

File 4 of 47 : BridgeOut.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";

import "./interfaces/IGalaGameItems.sol";
import "./interfaces/IGalaERC20.sol";
import "./interfaces/IERC721GalaMintableBurnable.sol";

import "./TokenHolder.sol";
import "./Getters.sol";
import "./Setters.sol";

/// @title Bridge Out
/// @notice This contract allows to bridge tokens out from EVM blockchain to the Play blockchain.
/// @author Piotr "pibu" Buda
contract BridgeOut is Getters, Setters, TokenHolder {
    using SafeERC20 for IERC20;

    event BridgeTokens(bytes32 emitter, uint16 chainId, uint64 sequence, bytes32 nonce, bytes payload);

    /// @notice Interact with this method to start the bridging out process
    /// @param token the address of the token contract, must be non-zero
    /// @param amount the amount of tokens to bridge out, disregarded for ERC-721 tokens
    /// @param tokenId the id of the token to bridge out, disregarded for ERC-20 tokens
    /// @param recipient the recipient on the Play blockchain, formatted in a way understandable by it
    function bridgeOut(
        address token,
        uint256 amount,
        uint256 tokenId,
        bytes calldata recipient
    ) external whenNotPaused {
        require(token != address(0), "INVALID_TOKEN");
        require(recipient.length > 0, "INVALID_RECIPIENT");
        TokenType tokenType = getTokenType(token);

        if (tokenType == TokenType.ERC20) {
            //in case of ERC20 the tokenId parameter is disregarded
            bridgeOutERC20(token, amount, recipient);
        } else if (tokenType == TokenType.ERC721) {
            //in case of ERC721 the amount parameter is disregarded
            bridgeOutERC721(token, tokenId, recipient);
        } else if (tokenType == TokenType.ERC1155) {
            bridgeOutERC1155(token, tokenId, amount, recipient);
        } else {
            revert("UNKNOWN_TOKEN_TYPE");
        }
    }

    /// @notice Allows to bridge out ERC20 tokens. The tokens are first transferred to the bridge and if the burning flag
    /// is set to true, then the tokens are burnt.
    /// The caller needs to approve the bridge to allow it to transfer funds.
    /// @param token address of the ERC20 token
    /// @param amount the amount to be bridged out
    /// @param recipient the id of the recipient on the other side of the bridge
    function bridgeOutERC20(
        address token,
        uint256 amount,
        bytes calldata recipient
    ) private {
        require(amount != 0, "INVALID_AMOUNT");
        require(isEnabled(token, DEFAULT_TOKEN_BASE_TYPE), "DISABLED");

        publishBridgeOutMessage(token, DEFAULT_TOKEN_BASE_TYPE, amount, 0, recipient);

        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);

        if (isBurningBridge(token, DEFAULT_TOKEN_BASE_TYPE)) {
            //this bridge assumes that all burnable ERC-20 assets will implement this burn method
            IGalaERC20(token).burn(amount);
        }
    }

    /// @notice Allows to bridge out ERC721 tokens. The tokens are first transferred to the bridge
    /// and then burnt if it is configured as burning.
    /// The caller needs to approve the bridge to allow it to transfer tokens.
    /// @param token address of the ERC721 token
    /// @param tokenId the id of the token to bridge
    /// @param recipient the id of the recipient on the other side of the bridge
    function bridgeOutERC721(
        address token,
        uint256 tokenId,
        bytes calldata recipient
    ) private {
        require(isEnabled(token, DEFAULT_TOKEN_BASE_TYPE), "DISABLED");

        publishBridgeOutMessage(token, DEFAULT_TOKEN_BASE_TYPE, 1, tokenId, recipient);

        IERC721GalaMintableBurnable(token).safeTransferFrom(msg.sender, address(this), tokenId);

        if (isBurningBridge(token, DEFAULT_TOKEN_BASE_TYPE)) {
            //this bridge assumes that all burnable ERC-721 assets will implement this burn method
            IERC721GalaMintableBurnable(token).burn(tokenId);
        }
    }

    /// @notice Allows to deposit ERC1155 tokens to the bridge.
    /// The caller needs to approve the bridge to allow it to transfer the token(s).
    /// @param token address of the ERC1155 token
    /// @param tokenId the id of the token to bridge
    /// @param amount the amount of the said token to be bridged
    /// @param recipient the id of the recipient on the other side of the bridge
    function bridgeOutERC1155(
        address token,
        uint256 tokenId,
        uint256 amount,
        bytes calldata recipient
    ) private {
        require(amount != 0, "INVALID_AMOUNT");

        uint256 baseType;
        uint256 instance;
        IGalaGameItems ggi = IGalaGameItems(token);
        if (ggi.isFungible(tokenId)) {
            baseType = tokenId;
            instance = 0;
        } else {
            baseType = ggi.getNonFungibleBaseType(tokenId);
            instance = ggi.getNonFungibleIndex(tokenId);
        }

        require(isEnabled(token, baseType), "DISABLED");

        publishBridgeOutMessage(token, baseType, amount, instance, recipient);

        IERC1155(token).safeTransferFrom(msg.sender, address(this), tokenId, amount, "");

        if (isBurningBridge(token, baseType)) {
            uint256[] memory _ids = new uint256[](1);
            uint256[] memory _values = new uint256[](1);
            _ids[0] = tokenId;
            _values[0] = amount;
            //this bridge assumes that all burnable ERC-1155 assets will implement this burn method
            IGalaGameItems(token).burn(address(this), _ids, _values);
        }
    }

    /// @dev This method allows to publish an event in a specific format. Other parts of the bridge (i.e. the Validator nodes)
    /// can pick up this event and process it.
    function publishBridgeOutMessage(
        address token,
        uint256 baseType,
        uint256 amount,
        uint256 instance,
        bytes calldata recipient
    ) internal {
        bytes memory tokenClassKey = getTokenClassKey(token, baseType);
        Structs.BridgeToken memory payload = Structs.BridgeToken(tokenClassKey, hubChainId(), amount, instance, recipient);

        bytes32 emitter = bytes32(uint256(uint160(address(this))));
        uint64 msgSequence = useSequence();

        emit BridgeTokens(emitter, chainId(), msgSequence, keccak256(abi.encodePacked(emitter, chainId(), msgSequence)), abi.encode(payload));
    }
}

File 5 of 47 : BridgeIn.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC721.sol";

import "./interfaces/IGalaGameItems.sol";
import "./interfaces/IERC721GalaMintableBurnable.sol";
import "./interfaces/IGalaERC20.sol";

import "./Authority.sol";
import "./Setters.sol";

/// @title Bridge In
/// @notice Bridge in message handler allowing to process messages sent from the Play blockchain in order to mint and/or release tokens.
/// @author Piotr "pibu" Buda
contract BridgeIn is Authority, Setters {
    using SafeERC20 for IGalaERC20;

    event BridgedIn(address token, uint256 quantity, uint256 tokenId, address recipient);

    /// @notice The message handler responsible for bridging the tokens in.
    /// @param message the VSM sent from the Play blockchain with Structs.BridgeTokenIn as payload
    function bridgeIn(Structs.VSM calldata message) external {
        bytes32 messageHash = keccak256(abi.encodePacked(message.emitter, message.chainId, message.sequence, message.nonce, message.payload));
        (bool isValid, string memory reason) = verifyMessage(message, messageHash);
        require(isValid, reason);
        require(!isBridgeMessageUsed(messageHash), "BRIDGE_MESSAGE_USED");
        useBridgeMessage(messageHash);

        Structs.BridgeToken memory bt = abi.decode(message.payload, (Structs.BridgeToken));
        require(bt.destinationChainId == chainId(), "WRONG_CHAINID");
        require(bt.recipient.length == 20, "INVALID_RECIPIENT_LENGTH");

        address recipient = decodeRecipient(bt.recipient);

        (address token, uint256 baseType) = getTokenAndBaseType(bt.tokenClassKey);

        uint256 tokenId = 0;
        TokenType tokenType = getTokenType(token);
        if (tokenType == TokenType.ERC20) {
            bridgeInERC20(token, bt.quantity, recipient);
        } else if (tokenType == TokenType.ERC721) {
            tokenId = bt.instance;
            bridgeInERC721(token, tokenId, recipient);
        } else if (tokenType == TokenType.ERC1155) {
            tokenId = baseType | bt.instance;
            bridgeInERC1155(token, tokenId, bt.quantity, recipient);
        }

        emit BridgedIn(token, bt.quantity, tokenId, recipient);
    }

    function decodeRecipient(bytes memory encodedAddress) internal pure returns (address recipient) {
        assembly {
            recipient := mload(add(encodedAddress, 20))
        }
        require(recipient != address(0), "INVALID_RECIPIENT");
    }

    /// @notice Allows to bridge in ERC20 tokens.
    /// @dev When the bridge is a burning bridge, the tokens are minted to the bridge's account and only then released
    /// to the recipient. In case it's a locking bridge, the tokens are released directly. In case the bridge doesn't have enough
    /// balance, it can mint the missing amount to itself and then send the full amount.
    /// @param token address of the ERC20 token guaranteed to be a valid, non-zero address
    /// @param amount the amount of tokens to be bridged in
    /// @param recipient account to which the tokens should be minted guaranteed to be a valid, non-zero address
    function bridgeInERC20(
        address token,
        uint256 amount,
        address recipient
    ) private {
        require(amount != 0, "INVALID_AMOUNT");

        uint256 balance = IGalaERC20(token).balanceOf(address(this));

        //the tokens must be minted in two cases:
        // - the bridge works as a burning bridge
        // - the bridge doesn't have enough tokens while being a locking bridge
        //but both of these cases can be checked with the balance < amount condition
        //because if the bridge works as a burning bridge, balance will always be equal to zero
        if (balance < amount) {
            address[] memory accounts = new address[](1);
            uint256[] memory amounts = new uint256[](1);
            accounts[0] = address(this);
            amounts[0] = amount - balance;
            require(IGalaERC20(token).mintBulk(accounts, amounts), "MINT_FAILED");
        }

        IGalaERC20(token).safeTransfer(recipient, amount);
    }

    /// @notice Allows to bridge in ERC721 token.
    /// It reverts with TOKEN_EXISTS if the token with tokenId already exists.
    /// @dev The tokens are minted to the bridge's account (if bridge is a burning bridge) and then released to the recipient.
    /// @param token the address of the ERC721 token guaranteed to be a valid, non-zero address
    /// @param tokenId the id of the token to withdraw
    /// @param recipient the account to which the token should be minted guaranteed to be a valid, non-zero address
    function bridgeInERC721(
        address token,
        uint256 tokenId,
        address recipient
    ) private {
        try IERC721(token).ownerOf(tokenId) returns (address tokenOwner) {
            //the token exists, only proceed if the bridge owns it
            //this check is here because there is no other way to verify if the bridge holds the token
            //as the call to ownerOf will fail if the token doesn't exist (as would be the case for a burning bridge)
            require(tokenOwner == address(this), "TOKEN_NOT_OWNED");
        } catch {
            //this token doesn't exist, it has to be minted first
            //there are two kinds of ERC721 that this bridge aimed to support
            //they use different mint methods
            //here an attempt is made to mint tokens using one of them
            try IERC721GalaMintableBurnable(token).mint(address(this), tokenId) {
                //token minted using mint
            } catch {
                try IERC721GalaMintableBurnable(token).safeMint(address(this), tokenId) {
                    //token minted using safeMint
                } catch {
                    revert("UNKNOWN_ERC721_MINT");
                }
            }
        }

        IERC721GalaMintableBurnable(token).safeTransferFrom(address(this), recipient, tokenId);
    }

    /// @notice Allows to withdraw ERC1155 token to the recipient. Depending on the bridge mode the tokens are first minted to the bridge and then sent to the recipient's account.
    /// It reverts with TOKEN_EXISTS if the NFT with tokenId already exists.
    /// @param token address of the ERC1155 token guaranteed to be a valid, non-zero address
    /// @param tokenId the id of the token to withdraw
    /// @param amount the amount of fungible tokens to withdraw
    /// @param recipient account to which the tokens should be withdrawn guaranteed to be a valid, non-zero address
    function bridgeInERC1155(
        address token,
        uint256 tokenId,
        uint256 amount,
        address recipient
    ) private {
        require(amount != 0, "INVALID_AMOUNT");

        IGalaGameItems ggi = IGalaGameItems(token);
        bool isFungible = ggi.isFungible(tokenId);
        uint256 balance = ggi.balanceOf(address(this), tokenId);
        address[] memory _to = new address[](1);
        _to[0] = address(this);

        //this condition will be true for both cases of a burning and locking bridge
        //for burning bridge, balance will always be zero
        if (balance < amount) {
            if (isFungible) {
                uint256[] memory _quantities = new uint256[](1);
                _quantities[0] = amount - balance;
                ggi.mintFungible(tokenId, _to, _quantities, "");
            } else {
                //if the bridge is operating in locking mode and said nft is already owned
                //not by the bridge, then the minting of it will fail
                //however, if this happens, there must be some issue with token accounting
                //as in this case Play blockchain should never allow to bridge that token out
                uint256[] memory _ids = new uint256[](1);
                _ids[0] = tokenId;
                ggi.mintNonFungible(_ids, _to, "");
            }
        }

        ggi.safeTransferFrom(address(this), recipient, tokenId, amount, "");
    }
}

File 6 of 47 : Structs.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "./Enums.sol";

interface Structs {
    struct VSM {
        bytes32 emitter;
        uint16 chainId;
        uint64 sequence;
        bytes32 nonce;
        bytes payload;
        //signatures must be in ascending order, correlated with the authorities
        Signature[] signatures;
    }

    struct BridgeToken {
        bytes tokenClassKey;
        uint16 destinationChainId;
        uint256 quantity;
        uint256 instance;
        bytes recipient;
    }

    struct BridgeUpgrade {
        address newImplementation;
        uint256 onlyAfterBlock;
        bytes init;
    }

    struct Signature {
        bytes32 r;
        bytes32 s;
        uint8 v;
        uint8 index;
    }

    /// @notice This struct defines a collection configuration in the bridge.
    /// All data, except enabled flag, is immutable as changing these values
    /// on a collection that is already operating can be catastrophic.
    struct TokenBridge {
        bytes tokenClassKey;
        bool initialized;
        bool burning;
        bool enabled;
        address token;
        uint256 baseType;
    }
}

File 7 of 47 : Authority.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "./Getters.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/// @title Authority
/// @notice This is a base contract to be used by other contracts which provide functionality based on messages
/// signed by the authority. Furthermore it allows off-chain entities which are willing to send messages to the bridge
/// to verify whether the message is correct.
/// @author Piotr "pibu" Buda
contract Authority is Getters {
    event AuthoritiesChanged(address[] newAuthorities);

    /// @notice verifies whether a message was signed by the quorum of current authorities
    /// @param message the message to verify
    /// @param digest the hash of the message content
    /// @return result the boolean result of the verification operation
    /// @return failureReason the description of an error if result is false, or an empty string if result is true
    function verifyMessage(Structs.VSM memory message, bytes32 digest) public view returns (bool result, string memory failureReason) {
        //because of the way the bridge is going to work, this contract will receive messages only from a specific chainId
        if (message.chainId != hubChainId()) {
            return (false, "IMPROPER_ORIGIN");
        }
        uint256 authorityLength = authoritiesLength();
        if (!quorum(message.signatures.length, authorityLength)) {
            return (false, "NO_QUORUM");
        }

        uint256 lastIndex = 0;

        for (uint256 i = 0; i < message.signatures.length; i++) {
            Structs.Signature memory signature = message.signatures[i];
            //on first iteration we assume the order is correct
            //on subsequent iterations the signature index must be
            require(i == 0 || signature.index > lastIndex, "INVALID_SIGNER_ORDER");
            lastIndex = signature.index;
            require(signature.index < authorityLength, "SIGNER_INDEX_OUT_OF_BOUNDS");
            (address authority, ECDSA.RecoverError error) = ECDSA.tryRecover(digest, signature.v, signature.r, signature.s);
            if (error != ECDSA.RecoverError.NoError || authority != getAuthority(signature.index)) {
                return (false, "INVALID_SIGNATURE");
            }
        }
        return (true, "");
    }

    /// @notice this method is used to check if some number of signatures are enough to reach quorum
    /// thus marking the message as clear for verification
    /// @param sigLength the actual number of signatures
    /// @param allKeys the number of keys in the authority
    function quorum(uint256 sigLength, uint256 allKeys) private pure returns (bool) {
        return sigLength >= (allKeys * 2) / 3 + 1;
    }
}

File 8 of 47 : Setters.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "./State.sol";

/// @title State mutators.
/// @notice This contract encapsulates access to the State.getState() method. It's not enforced, since that method is internal.
/// It is a good practice though, to keep the getState() usage limited to this, and the Getter contracts.
/// @author Piotr "pibu" Buda
contract Setters is State {
    /// @notice use this method to change authorities of the contract
    /// @param newAuthorities authorities to set
    function setAuthorities(address[] memory newAuthorities) internal {
        getState().authorities = newAuthorities;
    }

    ///@notice marks a governance message as used so that it cannot be reused
    /// @param digest the keccak256 of the Structs.VSM message
    function useGovernanceMessage(bytes32 digest) internal {
        getState().usedGovernanceMessages[digest] = true;
    }

    ///@notice marks a bridge message as used so that it cannot be reused
    /// @param digest the keccak256 of the Structs.VSM message
    function useBridgeMessage(bytes32 digest) internal {
        getState().usedBridgeMessages[digest] = true;
    }

    /// @notice provides a sequence number for the next message. After returning it, the sequence number is updated.
    /// @return seq the current value of the sequence number
    function useSequence() internal returns (uint64 seq) {
        seq = getState().sequence;
        getState().sequence += 1;
    }

    function setChainId(uint16 chainId) internal {
        getState().chainId = chainId;
    }

    function setHubChainId(uint16 hubChainId) internal {
        getState().hubChainId = hubChainId;
    }

    function setGovernanceContract(bytes32 governanceContract) internal {
        getState().governanceContract = governanceContract;
    }

    function setTokenBridge(Structs.TokenBridge memory tokenBridge, TokenType tokenType) internal {
        bytes32 collectionId = keccak256(tokenBridge.tokenClassKey);
        getState().bridges[collectionId] = tokenBridge;
        getState().tokenTypes[tokenBridge.token] = tokenType;
        getState().reverseBridges[tokenBridge.token][tokenBridge.baseType] = collectionId;
    }

    function setConversionFunnel(
        address token,
        uint256 baseType,
        bytes memory tokenClassKey,
        TokenType tokenType
    ) internal {
        getState().reverseBridges[token][baseType] = keccak256(tokenClassKey);
        getState().tokenTypes[token] = tokenType;
    }

    function setEnabled(bytes memory tokenClassKey, bool enabled) internal {
        getState().bridges[keccak256(tokenClassKey)].enabled = enabled;
    }
}

File 9 of 47 : ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeacon.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            Address.isContract(IBeacon(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        }
    }
}

File 10 of 47 : Enums.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

enum TokenType {
    UNKNOWN,
    ERC20,
    ERC721,
    ERC1155
}

File 11 of 47 : Getters.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "./State.sol";

/// @title Getters for the state.
/// @notice This contract is used to encapsulate the calls to State.getState() method and to expose helper functions
/// that allow both contracts and off-chain apps to query the state of the Bridge.
/// @author Piotr "pibu" Buda
contract Getters is State {
    
    function getTokenAndBaseType(bytes memory tokenClassKey) public view returns (address token, uint256 baseType) {
        Structs.TokenBridge memory bridge = getState().bridges[keccak256(tokenClassKey)];
        require(bridge.initialized, "NOT_INITIALIZED");
        require(bridge.enabled, "DISABLED");
        require(bridge.token != address(0), "TOKEN_NOT_CONFIGURED");
        token = bridge.token;
        baseType = bridge.baseType;
    }

    /// @dev this method does not perform the check of the enabled flag of the token bridge
    function getToken(bytes memory tokenClassKey) internal view returns (address token) {
        Structs.TokenBridge memory bridge = getState().bridges[keccak256(tokenClassKey)];
        require(bridge.initialized, "NOT_INITIALIZED");
        require(bridge.token != address(0), "TOKEN_NOT_CONFIGURED");
        token = bridge.token;
    }

    /// @dev this method does not perform the check of the enabled flag of the token bridge
    function getBaseType(bytes memory tokenClassKey) internal view returns (uint256 baseType) {
        Structs.TokenBridge memory bridge = getState().bridges[keccak256(tokenClassKey)];
        require(bridge.initialized, "NOT_INITIALIZED");
        require(bridge.token != address(0), "TOKEN_NOT_CONFIGURED");
        baseType = bridge.baseType;
    }

    function isEnabled(address token, uint256 baseType) public view returns (bool enabled) {
        enabled = getState().bridges[getState().reverseBridges[token][baseType]].enabled;
    }

    function getTokenClassKey(address token, uint256 baseType) public view returns (bytes memory tokenClassKey) {
        Structs.TokenBridge memory bridge = getState().bridges[getState().reverseBridges[token][baseType]];
        require(bridge.initialized, "NOT_INITIALIZED");
        require(bridge.token != address(0), "TOKEN_NOT_CONFIGURED");
        tokenClassKey = bridge.tokenClassKey;
    }

    function isInitialized(bytes memory tokenClassKey) public view returns (bool initialized) {
        initialized = getState().bridges[keccak256(tokenClassKey)].initialized;
    }

    function isBurningBridge(address token, uint256 baseType) public view returns (bool) {
        return getState().bridges[getState().reverseBridges[token][baseType]].burning;
    }

    function getTokenType(address token) public view returns (TokenType) {
        return getState().tokenTypes[token];
    }

    function chainId() public view returns (uint16) {
        return getState().chainId;
    }

    function isGovernanceMessageUsed(bytes32 digest) public view returns (bool) {
        return getState().usedGovernanceMessages[digest];
    }

    function isBridgeMessageUsed(bytes32 digest) public view returns (bool) {
        return getState().usedBridgeMessages[digest];
    }

    function sequence() external view returns (uint64) {
        return getState().sequence;
    }

    function hubChainId() public view returns (uint16) {
        return getState().hubChainId;
    }

    function authoritiesLength() public view returns (uint256) {
        return getState().authorities.length;
    }

    function getAuthority(uint256 index) public view returns (address) {
        return getState().authorities[index];
    }

    function governanceContract() public view returns (bytes32) {
        return getState().governanceContract;
    }
}

File 12 of 47 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (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
    }

    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");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' 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 (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // 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 13 of 47 : State.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "./Structs.sol";

/// @title Base state contract
/// @notice This is a base contract for storing state. It has to be upgrade-safe so it uses an assignable slot for state storage.
/// Based on https://medium.com/1milliondevs/new-storage-layout-for-proxy-contracts-and-diamonds-98d01d0eadb.
/// @author Piotr "pibu" Buda
contract State is PausableUpgradeable, OwnableUpgradeable {
    uint256 constant DEFAULT_TOKEN_BASE_TYPE = 0;

    //bytes32 is used as ids for collections and base types
    struct BridgeState {
        //keccak256(tokenClassKey) => TokenBridge
        mapping(bytes32 => Structs.TokenBridge) bridges;
        //token contract => TokenType
        mapping(address => TokenType) tokenTypes;
        //token contract => base type => keccak256(tokenClassKey)
        mapping(address => mapping(uint256 => bytes32)) reverseBridges;
        //keccak256(VSM) => bool
        mapping(bytes32 => bool) usedGovernanceMessages;
        //keccak256(VSM) => bool
        mapping(bytes32 => bool) usedBridgeMessages;
        //this bridge's chain id
        uint16 chainId;
        //chain id of the hub
        uint16 hubChainId;
        //id of the governance contract
        bytes32 governanceContract;
        //sequence number for BridgeMessage to use
        uint64 sequence;
        //current set of signing authority
        address[] authorities;
    }

    /// @notice This method allows to retrieve the Bridge's state by using an assignable storage slot.
    /// @return ms the Bridge's state represented by the BridgeState struct
    function getState() internal pure returns (BridgeState storage ms) {
        assembly {
            //keccak256("gala.bridge.storage")
            ms.slot := 0x07b26557da28ba49062e0328822024c4af75c9bcd1fcb0d96f1702cfe37e7d70
        }
    }
}

File 14 of 47 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 15 of 47 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 16 of 47 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 17 of 47 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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 functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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 47 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_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) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_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 20 of 47 : draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 21 of 47 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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 22 of 47 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

File 23 of 47 : IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 24 of 47 : TokenHolder.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";

/// @title Token Holder
/// @notice This is a helper contract.
/// @author Piotr "pibu" Buda
abstract contract TokenHolder is ERC1155Holder, ERC721Holder {

}

File 25 of 47 : IGalaERC20.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IGalaERC20 is IERC20 {
    function mintBulk(address[] memory accounts, uint256[] memory amounts) external returns (bool);

    function burn(uint256 amount) external;
}

File 26 of 47 : IERC721GalaMintableBurnable.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IERC721GalaMintableBurnable is IERC721 {
    function mint(address owner, uint256 tokenId) external;

    function safeMint(address owner, uint256 tokenId) external;

    function burn(uint256 tokenId) external;
}

File 27 of 47 : IGalaGameItems.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/interfaces/IERC1155.sol";

interface IGalaGameItems is IERC1155 {
    function mintNonFungible(
        uint256[] calldata _ids,
        address[] calldata _to,
        bytes calldata _data
    ) external;

    function mintFungible(
        uint256 _id,
        address[] calldata _to,
        uint256[] calldata _quantities,
        bytes calldata _data
    ) external;

    function burn(
        address _from,
        uint256[] calldata _ids,
        uint256[] calldata _values
    ) external;

    function isFungible(uint256 _id) external pure returns (bool);

    function isNonFungible(uint256 _id) external pure returns (bool);

    function getNonFungibleIndex(uint256 _id) external pure returns (uint256);

    function getNonFungibleBaseType(uint256 _id) external pure returns (uint256);
}

File 28 of 47 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

File 29 of 47 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol)

pragma solidity ^0.8.0;

import "../token/ERC1155/IERC1155.sol";

File 30 of 47 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 31 of 47 : ERC721Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "../../../utils/Context.sol";

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
        _burn(tokenId);
    }
}

File 32 of 47 : ERC1155Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 33 of 47 : ERC721Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

File 34 of 47 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}

File 35 of 47 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 36 of 47 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 37 of 47 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * 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 38 of 47 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 39 of 47 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 40 of 47 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 41 of 47 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 42 of 47 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 43 of 47 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 44 of 47 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 45 of 47 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

File 46 of 47 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 47 of 47 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol)

pragma solidity ^0.8.0;

import "../token/ERC721/IERC721.sol";

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"currentBlock","type":"uint256"},{"internalType":"uint256","name":"onlyAfterBlock","type":"uint256"}],"name":"UpgradeTimelockViolation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"newAuthorities","type":"address[]"}],"name":"AuthoritiesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"tokenClassKey","type":"bytes"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"baseType","type":"uint256"},{"indexed":false,"internalType":"enum TokenType","name":"tokenType","type":"uint8"},{"indexed":false,"internalType":"bool","name":"isburning","type":"bool"}],"name":"BridgeInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"emitter","type":"bytes32"},{"indexed":false,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"uint64","name":"sequence","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"nonce","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"}],"name":"BridgeTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"BridgedIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"baseType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"tokenClassKey","type":"bytes"}],"name":"ConversionInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"tokenClassKey","type":"bytes"},{"indexed":false,"internalType":"bool","name":"isEnabled","type":"bool"}],"name":"EnabledUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"authoritiesLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"emitter","type":"bytes32"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"bytes","name":"payload","type":"bytes"},{"components":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"index","type":"uint8"}],"internalType":"struct Structs.Signature[]","name":"signatures","type":"tuple[]"}],"internalType":"struct Structs.VSM","name":"message","type":"tuple"}],"name":"bridgeIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"recipient","type":"bytes"}],"name":"bridgeOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"emitter","type":"bytes32"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"bytes","name":"payload","type":"bytes"},{"components":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"index","type":"uint8"}],"internalType":"struct Structs.Signature[]","name":"signatures","type":"tuple[]"}],"internalType":"struct Structs.VSM","name":"message","type":"tuple"}],"name":"changeAuthorities","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getAuthority","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"tokenClassKey","type":"bytes"}],"name":"getTokenAndBaseType","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"baseType","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"baseType","type":"uint256"}],"name":"getTokenClassKey","outputs":[{"internalType":"bytes","name":"tokenClassKey","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenType","outputs":[{"internalType":"enum TokenType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governanceContract","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubChainId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"digest","type":"bytes32"}],"name":"isBridgeMessageUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"baseType","type":"uint256"}],"name":"isBurningBridge","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"baseType","type":"uint256"}],"name":"isEnabled","outputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"digest","type":"bytes32"}],"name":"isGovernanceMessageUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"tokenClassKey","type":"bytes"}],"name":"isInitialized","outputs":[{"internalType":"bool","name":"initialized","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sequence","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"tokenClassKey","type":"bytes"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setTokenBridgeEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"baseType","type":"uint256"},{"internalType":"bytes","name":"tokenClassKey","type":"bytes"}],"name":"setupConversionFunnel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"tokenClassKey","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"baseType","type":"uint256"},{"internalType":"enum TokenType","name":"tokenType","type":"uint8"},{"internalType":"bool","name":"burning","type":"bool"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setupTokenBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"emitter","type":"bytes32"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"bytes","name":"payload","type":"bytes"},{"components":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"index","type":"uint8"}],"internalType":"struct Structs.Signature[]","name":"signatures","type":"tuple[]"}],"internalType":"struct Structs.VSM","name":"message","type":"tuple"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"emitter","type":"bytes32"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"bytes","name":"payload","type":"bytes"},{"components":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"index","type":"uint8"}],"internalType":"struct Structs.Signature[]","name":"signatures","type":"tuple[]"}],"internalType":"struct Structs.VSM","name":"message","type":"tuple"},{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"verifyGovernanceMessage","outputs":[{"internalType":"bool","name":"result","type":"bool"},{"internalType":"string","name":"failureReason","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"emitter","type":"bytes32"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"bytes","name":"payload","type":"bytes"},{"components":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"index","type":"uint8"}],"internalType":"struct Structs.Signature[]","name":"signatures","type":"tuple[]"}],"internalType":"struct Structs.VSM","name":"message","type":"tuple"},{"internalType":"bytes32","name":"digest","type":"bytes32"}],"name":"verifyMessage","outputs":[{"internalType":"bool","name":"result","type":"bool"},{"internalType":"string","name":"failureReason","type":"string"}],"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b50600054610100900460ff1615808015620000335750600054600160ff909116105b8062000063575062000050306200013d60201b620016921760201c565b15801562000063575060005460ff166001145b620000cb5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000ef576000805461ff0019166101001790555b801562000136576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b506200014c565b6001600160a01b03163b151590565b614397806200015c6000396000f3fe608060405234801561001057600080fd5b50600436106101fb5760003560e01c80638456cb591161011a578063b172b222116100ad578063eaa7126b1161007c578063eaa7126b1461048d578063f23a6e61146104a0578063f2fde38b146104bf578063f8fd17cc146104d2578063ffae2c5b146104e557600080fd5b8063b172b22214610440578063bacdb26c14610448578063bc197c811461045b578063ea0954e91461047a57600080fd5b8063929f5840116100e9578063929f5840146103ea57806393272baf146104055780639a8a059214610425578063b05b63251461042d57600080fd5b80638456cb59146103975780638da5cb5b1461039f5780638e068765146103c45780638fc462c1146103d757600080fd5b806349149d78116101925780635da334d5116101615780635da334d5146103495780635e188e981461035c57806362a77cb91461036f578063715018a61461038f57600080fd5b806349149d78146102f857806349e3c9ce1461030b578063529d15cc1461031e5780635c975abb1461033e57600080fd5b80633743ad8e116101ce5780633743ad8e146102a4578063397c7fc2146102ba5780633f4ba83a146102db57806344cd9e66146102e557600080fd5b806301ffc9a714610200578063150b7a021461022857806320f4bd131461025f5780632d6e652e14610291575b600080fd5b61021361020e366004613896565b6104f8565b60405190151581526020015b60405180910390f35b6102466102363660046135d4565b630a85bd0160e11b949350505050565b6040516001600160e01b0319909116815260200161021f565b61027261026d3660046138c0565b61052f565b604080516001600160a01b03909316835260208301919091520161021f565b61021361029f3660046136a7565b6106d2565b6102ac61072f565b60405190815260200161021f565b6102cd6102c8366004613ba6565b610742565b60405161021f929190613e43565b6102e3610997565b005b6102136102f336600461387d565b6109b1565b6102136103063660046136a7565b6109d2565b61021361031936600461387d565b610a30565b610326610a51565b6040516001600160401b03909116815260200161021f565b60335460ff16610213565b6102e3610357366004613b2e565b610a6d565b6102e361036a3660046136d3565b610d49565b61038261037d3660046136a7565b610e2c565b60405161021f9190613e96565b6102e3610fba565b6102e3610fcc565b6065546001600160a01b03165b6040516001600160a01b03909116815260200161021f565b6102e36103d2366004613b2e565b610fe4565b6102e36103e53660046138f4565b611091565b6103f261127a565b60405161ffff909116815260200161021f565b6104186104133660046134ed565b611297565b60405161021f9190613f06565b6103f26112c6565b6102e361043b366004613b2e565b6112dd565b6102ac611350565b6102e3610456366004613989565b611363565b610246610469366004613527565b63bc197c8160e01b95945050505050565b6102136104883660046138c0565b6113cb565b6102cd61049b366004613b62565b6113f3565b6102466104ae36600461363f565b63f23a6e6160e01b95945050505050565b6102e36104cd3660046134ed565b6114a7565b6102e36104e036600461372b565b611520565b6103ac6104f336600461387d565b611659565b60006001600160e01b03198216630271189760e51b148061052957506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080600061053c6116a1565b6000016000858051906020012081526020019081526020016000206040518060c00160405290816000820180546105729061426f565b80601f016020809104026020016040519081016040528092919081815260200182805461059e9061426f565b80156105eb5780601f106105c0576101008083540402835291602001916105eb565b820191906000526020600020905b8154815290600101906020018083116105ce57829003601f168201915b5050509183525050600182015460ff808216151560208085019190915261010083048216151560408501526201000083049091161515606084015263010000009091046001600160a01b0316608083015260029092015460a0909101528101519091506106735760405162461bcd60e51b815260040161066a90613f69565b60405180910390fd5b80606001516106945760405162461bcd60e51b815260040161066a90613f92565b60808101516001600160a01b03166106be5760405162461bcd60e51b815260040161066a90613f14565b806080015192508060a00151915050915091565b60006106dc6116a1565b60006106e66116a1565b6001600160a01b0386166000908152600291909101602090815260408083208784528252808320548452908301939093529101902060010154610100900460ff16905092915050565b60006107396116a1565b60080154919050565b6000606061074e61127a565b61ffff16846020015161ffff161461079057505060408051808201909152600f81526e24a6a82927a822a92fa7a924a3a4a760891b6020820152600090610990565b600061079a61072f565b90506107ab8560a0015151826116c5565b6107da5750506040805180820190915260098152684e4f5f51554f52554d60b81b602082015260009150610990565b6000805b8660a00151518110156109765760008760a001518281518110610803576108036142eb565b602002602001015190508160001480610822575082816060015160ff16115b6108655760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa9a4a3a722a92fa7a92222a960611b604482015260640161066a565b606081015160ff1692508383106108be5760405162461bcd60e51b815260206004820152601a60248201527f5349474e45525f494e4445585f4f55545f4f465f424f554e4453000000000000604482015260640161066a565b6000806108d9898460400151856000015186602001516116f3565b909250905060008160048111156108f2576108f26142d5565b141580610920575061090a836060015160ff16611659565b6001600160a01b0316826001600160a01b031614155b1561096057600060405180604001604052806011815260200170494e56414c49445f5349474e415455524560781b81525097509750505050505050610990565b505050808061096e906142a4565b9150506107de565b506001604051806020016040528060008152509350935050505b9250929050565b61099f6117e0565b6109a7611829565b6109af611883565b565b60006109bb6116a1565b600092835260040160205250604090205460ff1690565b60006109dc6116a1565b60006109e66116a1565b6001600160a01b039590951660009081526002909501602090815260408087209587529481528486205482528101919091529091019091206001015462010000900460ff16919050565b6000610a3a6116a1565b600092835260030160205250604090205460ff1690565b6000610a5b6116a1565b600701546001600160401b0316919050565b60008135610a816040840160208501613bdb565b610a916060850160408601613c0f565b6060850135610aa36080870187614097565b604051602001610ab896959493929190613cec565b604051602081830303815290604052805190602001209050600080610ae684610ae090614237565b84610742565b91509150818190610b0a5760405162461bcd60e51b815260040161066a9190613e96565b50610b14836109b1565b15610b575760405162461bcd60e51b81526020600482015260136024820152721094925111d157d35154d4d051d157d554d151606a1b604482015260640161066a565b610b60836118d5565b6000610b6f6080860186614097565b810190610b7c91906139da565b9050610b866112c6565b61ffff16816020015161ffff1614610bd05760405162461bcd60e51b815260206004820152600d60248201526c15d493d391d7d0d21052539251609a1b604482015260640161066a565b806080015151601414610c255760405162461bcd60e51b815260206004820152601860248201527f494e56414c49445f524543495049454e545f4c454e4754480000000000000000604482015260640161066a565b6000610c348260800151611900565b9050600080610c46846000015161052f565b91509150600080610c5684611297565b90506001816003811115610c6c57610c6c6142d5565b1415610c8657610c8184876040015187611954565b610ce5565b6002816003811115610c9a57610c9a6142d5565b1415610cb25785606001519150610c81848387611b65565b6003816003811115610cc657610cc66142d5565b1415610ce557856060015183179150610ce58483886040015188611d8f565b60408087015181516001600160a01b0380881682526020820192909252918201849052861660608201527f339a78cc37814d54dd1a3ccbf16d932c40974436167cf02f9137bdd674375429906080015b60405180910390a150505050505050505050565b610d51611829565b6001600160a01b038316610d775760405162461bcd60e51b815260040161066a90613f42565b6000815111610dc25760405162461bcd60e51b8152602060048201526017602482015276494e56414c49445f544f4b454e5f434c4153535f4b455960481b604482015260640161066a565b6000610dcd826120d6565b9050610de3848484610dde85611297565b612243565b836001600160a01b03167f970cf9001ac6e5e23eb555839b7b51be91a81a32e14d2ac2ba320ecd32266b848484604051610e1e92919061407e565b60405180910390a250505050565b60606000610e386116a1565b6000610e426116a1565b6001600160a01b0387166000908152600291909101602090815260408083208884528252808320548452908301939093529082019020815160c08101909252805482908290610e909061426f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ebc9061426f565b8015610f095780601f10610ede57610100808354040283529160200191610f09565b820191906000526020600020905b815481529060010190602001808311610eec57829003601f168201915b5050509183525050600182015460ff808216151560208085019190915261010083048216151560408501526201000083049091161515606084015263010000009091046001600160a01b0316608083015260029092015460a090910152810151909150610f885760405162461bcd60e51b815260040161066a90613f69565b60808101516001600160a01b0316610fb25760405162461bcd60e51b815260040161066a90613f14565b519392505050565b610fc2611829565b6109af60006122c6565b610fd4612318565b610fdc611829565b6109af61235e565b610fed8161239b565b6000610ffc6080830183614097565b81019061100991906137c0565b9050600081511161104d5760405162461bcd60e51b815260206004820152600e60248201526d4e4f5f415554484f52495449455360901b604482015260640161066a565b61105681612439565b7f43dd54b693a773b597de134f3199f428256d72ae149cd72c7447ff0ee91235ce816040516110859190613dc2565b60405180910390a15050565b611099611829565b60008651116110e45760405162461bcd60e51b8152602060048201526017602482015276494e56414c49445f544f4b454e5f434c4153535f4b455960481b604482015260640161066a565b6110ed866113cb565b1561112f5760405162461bcd60e51b81526020600482015260126024820152711094925111d157d25392551250531256915160721b604482015260640161066a565b6001600160a01b0385166111555760405162461bcd60e51b815260040161066a90613f42565b6000836003811115611169576111696142d5565b14156111ac5760405162461bcd60e51b8152602060048201526012602482015271494e56414c49445f544f4b454e5f5459504560701b604482015260640161066a565b6111f26040518060c0016040528088815260200160011515815260200184151581526020018315158152602001876001600160a01b031681526020018681525084612458565b846001600160a01b03167fc3101dae71c94df4dc3fcd71f100b459c624f9a061f3aeb2f6991239677a6e70878686866040516112319493929190613ecd565b60405180910390a27fe560594cb1b0ce3eede97f8741b06bc5f57b6d94ce3d7f2b2e23c1f135d42be3868260405161126a929190613ea9565b60405180910390a1505050505050565b60006112846116a1565b6005015462010000900461ffff16919050565b60006112a16116a1565b6001600160a01b03909216600090815260019290920160205250604090205460ff1690565b60006112d06116a1565b6005015461ffff16919050565b6112e68161239b565b60006112f56080830183614097565b8101906113029190613a8f565b90508060200151431015611338576020810151604051630f947b6560e01b8152436004820152602481019190915260440161066a565b61134c81600001518260400151600061259d565b5050565b600061135a6116a1565b60060154905090565b61136b611829565b611374826113cb565b6113905760405162461bcd60e51b815260040161066a90613f69565b61139a82826125c7565b7fe560594cb1b0ce3eede97f8741b06bc5f57b6d94ce3d7f2b2e23c1f135d42be38282604051611085929190613ea9565b60006113d56116a1565b82516020938401206000908152925250604090206001015460ff1690565b6000606061140083610a30565b1561144357505060408051808201909152601b81527f474f5645524e414e43455f4d4553534147455f434f4e53554d454400000000006020820152600090610990565b61144b611350565b84351461149057505060408051808201909152601c81527f4e4f545f46524f4d5f474f5645524e414e43455f434f4e5452414354000000006020820152600090610990565b61149c610ae085614237565b915091509250929050565b6114af611829565b6001600160a01b0381166115145760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161066a565b61151d816122c6565b50565b611528612318565b6001600160a01b03851661154e5760405162461bcd60e51b815260040161066a90613f42565b8061158f5760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015260640161066a565b600061159a86611297565b905060018160038111156115b0576115b06142d5565b14156115c7576115c286868585612603565b611651565b60028160038111156115db576115db6142d5565b14156115ed576115c2868585856126dc565b6003816003811115611601576116016142d5565b1415611614576115c28685878686612784565b60405162461bcd60e51b8152602060048201526012602482015271554e4b4e4f574e5f544f4b454e5f5459504560701b604482015260640161066a565b505050505050565b60006116636116a1565b6008018281548110611677576116776142eb565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b03163b151590565b7f07b26557da28ba49062e0328822024c4af75c9bcd1fcb0d96f1702cfe37e7d7090565b600060036116d4836002614201565b6116de91906141df565b6116e990600161419c565b9092101592915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561172a57506000905060036117d7565b8460ff16601b1415801561174257508460ff16601c14155b1561175357506000905060046117d7565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156117a7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166117d0576000600192509250506117d7565b9150600090505b94509492505050565b60335460ff166109af5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161066a565b6065546001600160a01b031633146109af5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161066a565b61188b6117e0565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60016118df6116a1565b60009283526004016020526040909120805460ff1916911515919091179055565b60148101516001600160a01b03811661194f5760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015260640161066a565b919050565b816119715760405162461bcd60e51b815260040161066a90613fb4565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b1580156119b357600080fd5b505afa1580156119c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119eb9190613bf6565b905082811015611b4b576040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090503082600081518110611a4e57611a4e6142eb565b6001600160a01b0390921660209283029190910190910152611a708386614220565b81600081518110611a8357611a836142eb565b60209081029190910101526040516307fd30df60e41b81526001600160a01b03871690637fd30df090611abc9085908590600401613dd5565b602060405180830381600087803b158015611ad657600080fd5b505af1158015611aea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0e9190613860565b611b485760405162461bcd60e51b815260206004820152600b60248201526a1352539517d1905253115160aa1b604482015260640161066a565b50505b611b5f6001600160a01b0385168385612ac0565b50505050565b6040516331a9108f60e11b8152600481018390526001600160a01b03841690636352211e9060240160206040518083038186803b158015611ba557600080fd5b505afa925050508015611bd5575060408051601f3d908101601f19168201909252611bd29181019061350a565b60015b611cd6576040516340c10f1960e01b8152306004820152602481018390526001600160a01b038416906340c10f1990604401600060405180830381600087803b158015611c2157600080fd5b505af1925050508015611c32575060015b611cd157604051632851206560e21b8152306004820152602481018390526001600160a01b0384169063a144819490604401600060405180830381600087803b158015611c7e57600080fd5b505af1925050508015611c8f575060015b611cd15760405162461bcd60e51b8152602060048201526013602482015272155392d393d5d397d15490cdcc8c57d3525395606a1b604482015260640161066a565b611d22565b6001600160a01b0381163014611d205760405162461bcd60e51b815260206004820152600f60248201526e1513d2d15397d393d517d3d5d39151608a1b604482015260640161066a565b505b604051632142170760e11b81523060048201526001600160a01b038281166024830152604482018490528416906342842e0e90606401600060405180830381600087803b158015611d7257600080fd5b505af1158015611d86573d6000803e3d6000fd5b50505050505050565b81611dac5760405162461bcd60e51b815260040161066a90613fb4565b6040516356f5fb7960e11b81526004810184905284906000906001600160a01b0383169063adebf6f29060240160206040518083038186803b158015611df157600080fd5b505afa158015611e05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e299190613860565b604051627eeac760e11b8152306004820152602481018790529091506000906001600160a01b0384169062fdd58e9060440160206040518083038186803b158015611e7357600080fd5b505afa158015611e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eab9190613bf6565b60408051600180825281830190925291925060009190602080830190803683370190505090503081600081518110611ee557611ee56142eb565b60200260200101906001600160a01b031690816001600160a01b03168152505085821015612068578215611fc55760408051600180825281830190925260009160208083019080368337019050509050611f3f8388614220565b81600081518110611f5257611f526142eb565b602090810291909101015260405163060fec9560e21b81526001600160a01b0386169063183fb25490611f8d908b9086908690600401614037565b600060405180830381600087803b158015611fa757600080fd5b505af1158015611fbb573d6000803e3d6000fd5b5050505050612068565b604080516001808252818301909252600091602080830190803683370190505090508781600081518110611ffb57611ffb6142eb565b602090810291909101015260405163c5d5496560e01b81526001600160a01b0386169063c5d54965906120349084908690600401613e03565b600060405180830381600087803b15801561204e57600080fd5b505af1158015612062573d6000803e3d6000fd5b50505050505b604051637921219560e11b81526001600160a01b0385169063f242432a9061209a90309089908c908c90600401613d54565b600060405180830381600087803b1580156120b457600080fd5b505af11580156120c8573d6000803e3d6000fd5b505050505050505050505050565b6000806120e16116a1565b6000016000848051906020012081526020019081526020016000206040518060c00160405290816000820180546121179061426f565b80601f01602080910402602001604051908101604052809291908181526020018280546121439061426f565b80156121905780601f1061216557610100808354040283529160200191612190565b820191906000526020600020905b81548152906001019060200180831161217357829003601f168201915b5050509183525050600182015460ff808216151560208085019190915261010083048216151560408501526201000083049091161515606084015263010000009091046001600160a01b0316608083015260029092015460a09091015281015190915061220f5760405162461bcd60e51b815260040161066a90613f69565b60808101516001600160a01b03166122395760405162461bcd60e51b815260040161066a90613f14565b6080015192915050565b815160208301206122526116a1565b6001600160a01b038616600090815260029190910160209081526040808320878452909152902055806122836116a1565b6001600160a01b03861660009081526001918201602052604090208054909160ff19909116908360038111156122bb576122bb6142d5565b021790555050505050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60335460ff16156109af5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161066a565b612366612318565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586118b83390565b600081356123af6040840160208501613bdb565b6123bf6060850160408601613c0f565b60608501356123d16080870187614097565b6040516020016123e696959493929190613cec565b60405160208183030381529060405280519060200120905060008061240b84846113f3565b9150915081819061242f5760405162461bcd60e51b815260040161066a9190613e96565b50611b5f83612b23565b806124426116a1565b600801908051906020019061134c929190613174565b815180516020909101208261246b6116a1565b600083815260209182526040902082518051919261248e928492909101906131d9565b5060208201516001820180546040850151606086015160808701516001600160a01b03166301000000026301000000600160b81b031991151562010000029190911662010000600160b81b03199215156101000261ff00199615159690961661ffff199094169390931794909417161791909117905560a090910151600290910155816125196116a1565b60808501516001600160a01b031660009081526001918201602052604090208054909160ff1990911690836003811115612555576125556142d5565b0217905550806125636116a1565b60808501516001600160a01b031660009081526002919091016020908152604080832060a090970151835295905293909320929092555050565b6125a683612b4e565b6000825111806125b35750805b156125c257611b5f8383612b8e565b505050565b806125d06116a1565b83516020948501206000908152935260409092206001018054921515620100000262ff0000199093169290921790915550565b826126205760405162461bcd60e51b815260040161066a90613fb4565b61262b8460006109d2565b6126475760405162461bcd60e51b815260040161066a90613f92565b6126578460008560008686612bba565b61266c6001600160a01b038516333086612cf8565b6126778460006106d2565b15611b5f57604051630852cd8d60e31b8152600481018490526001600160a01b038516906342966c6890602401600060405180830381600087803b1580156126be57600080fd5b505af11580156126d2573d6000803e3d6000fd5b5050505050505050565b6126e78460006109d2565b6127035760405162461bcd60e51b815260040161066a90613f92565b6127138460006001868686612bba565b604051632142170760e11b8152336004820152306024820152604481018490526001600160a01b038516906342842e0e90606401600060405180830381600087803b15801561276157600080fd5b505af1158015612775573d6000803e3d6000fd5b505050506126778460006106d2565b826127a15760405162461bcd60e51b815260040161066a90613fb4565b6040516356f5fb7960e11b815260048101859052600090819087906001600160a01b0382169063adebf6f29060240160206040518083038186803b1580156127e857600080fd5b505afa1580156127fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128209190613860565b156128315786925060009150612927565b604051636f969c2d60e01b8152600481018890526001600160a01b03821690636f969c2d9060240160206040518083038186803b15801561287157600080fd5b505afa158015612885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a99190613bf6565b604051632732871960e21b8152600481018990529093506001600160a01b03821690639cca1c649060240160206040518083038186803b1580156128ec57600080fd5b505afa158015612900573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129249190613bf6565b91505b61293188846109d2565b61294d5760405162461bcd60e51b815260040161066a90613f92565b61295b888488858989612bba565b604051637921219560e11b81526001600160a01b0389169063f242432a9061298d90339030908c908c90600401613d54565b600060405180830381600087803b1580156129a757600080fd5b505af11580156129bb573d6000803e3d6000fd5b505050506129c988846106d2565b156126d2576040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090508882600081518110612a2757612a276142eb565b6020026020010181815250508781600081518110612a4757612a476142eb565b6020908102919091010152604051633db0f8ab60e01b81526001600160a01b038b1690633db0f8ab90612a8290309086908690600401613d8c565b600060405180830381600087803b158015612a9c57600080fd5b505af1158015612ab0573d6000803e3d6000fd5b5050505050505050505050505050565b6040516001600160a01b0383166024820152604481018290526125c290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d30565b6001612b2d6116a1565b60009283526003016020526040909120805460ff1916911515919091179055565b612b5781612e02565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060612bb3838360405180606001604052806027815260200161433b60279139612eb0565b9392505050565b6000612bc68787610e2c565b905060006040518060a00160405280838152602001612be361127a565b61ffff16815260200187815260200186815260200185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093909452509293503092509050612c3f612f8d565b90507fb2d93ec15439019c2bd2b7d1271afd1bab015bc32c9626b0f54483958e8f253082612c6b6112c6565b8385612c756112c6565b86604051602001612cb39392919092835260f09190911b6001600160f01b031916602083015260c01b6001600160c01b0319166022820152602a0190565b6040516020818303038152906040528051906020012087604051602001612cda9190613fdc565b60408051601f1981840301815290829052610d359594939291613e5e565b6040516001600160a01b0380851660248301528316604482015260648101829052611b5f9085906323b872dd60e01b90608401612aec565b6000612d85826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612ff39092919063ffffffff16565b8051909150156125c25780806020019051810190612da39190613860565b6125c25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161066a565b6001600160a01b0381163b612e6f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161066a565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b612f185760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161066a565b600080856001600160a01b031685604051612f339190613d38565b600060405180830381855af49150503d8060008114612f6e576040519150601f19603f3d011682016040523d82523d6000602084013e612f73565b606091505b5091509150612f8382828661300a565b9695505050505050565b6000612f976116a1565b600701546001600160401b031690506001612fb06116a1565b6007018054600090612fcc9084906001600160401b03166141b4565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555090565b60606130028484600085613043565b949350505050565b60608315613019575081612bb3565b8251156130295782518084602001fd5b8160405162461bcd60e51b815260040161066a9190613e96565b6060824710156130a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161066a565b6001600160a01b0385163b6130fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161066a565b600080866001600160a01b031685876040516131179190613d38565b60006040518083038185875af1925050503d8060008114613154576040519150601f19603f3d011682016040523d82523d6000602084013e613159565b606091505b509150915061316982828661300a565b979650505050505050565b8280548282559060005260206000209081019282156131c9579160200282015b828111156131c957825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613194565b506131d592915061324d565b5090565b8280546131e59061426f565b90600052602060002090601f01602090048101928261320757600085556131c9565b82601f1061322057805160ff19168380011785556131c9565b828001600101855582156131c9579182015b828111156131c9578251825591602001919060010190613232565b5b808211156131d5576000815560010161324e565b600082601f83011261327357600080fd5b8135602061328861328383614179565b614149565b80838252828201915082860187848660071b89010111156132a857600080fd5b6000805b8681101561330d57608080848c0312156132c4578283fd5b6132cc6140dd565b84358152878501358882015260406132e58187016134dc565b9082015260606132f68682016134dc565b9082015286529486019492909201916001016132ac565b509198975050505050505050565b600082601f83011261332c57600080fd5b8135602061333c61328383614179565b80838252828201915082860187848660051b890101111561335c57600080fd5b60005b8581101561337b5781358452928401929084019060010161335f565b5090979650505050505050565b600082601f83011261339957600080fd5b81356001600160401b038111156133b2576133b2614301565b6133c5601f8201601f1916602001614149565b8181528460208386010111156133da57600080fd5b816020850160208301376000918101602001919091529392505050565b600060c0828403121561340957600080fd5b50919050565b600060c0828403121561342157600080fd5b613429614105565b90508135815261343b602083016134b3565b602082015261344c604083016134c5565b60408201526060820135606082015260808201356001600160401b038082111561347557600080fd5b61348185838601613388565b608084015260a084013591508082111561349a57600080fd5b506134a784828501613262565b60a08301525092915050565b803561ffff8116811461194f57600080fd5b80356001600160401b038116811461194f57600080fd5b803560ff8116811461194f57600080fd5b6000602082840312156134ff57600080fd5b8135612bb381614317565b60006020828403121561351c57600080fd5b8151612bb381614317565b600080600080600060a0868803121561353f57600080fd5b853561354a81614317565b9450602086013561355a81614317565b935060408601356001600160401b038082111561357657600080fd5b61358289838a0161331b565b9450606088013591508082111561359857600080fd5b6135a489838a0161331b565b935060808801359150808211156135ba57600080fd5b506135c788828901613388565b9150509295509295909350565b600080600080608085870312156135ea57600080fd5b84356135f581614317565b9350602085013561360581614317565b92506040850135915060608501356001600160401b0381111561362757600080fd5b61363387828801613388565b91505092959194509250565b600080600080600060a0868803121561365757600080fd5b853561366281614317565b9450602086013561367281614317565b9350604086013592506060860135915060808601356001600160401b0381111561369b57600080fd5b6135c788828901613388565b600080604083850312156136ba57600080fd5b82356136c581614317565b946020939093013593505050565b6000806000606084860312156136e857600080fd5b83356136f381614317565b92506020840135915060408401356001600160401b0381111561371557600080fd5b61372186828701613388565b9150509250925092565b60008060008060006080868803121561374357600080fd5b853561374e81614317565b9450602086013593506040860135925060608601356001600160401b038082111561377857600080fd5b818801915088601f83011261378c57600080fd5b81358181111561379b57600080fd5b8960208285010111156137ad57600080fd5b9699959850939650602001949392505050565b600060208083850312156137d357600080fd5b82356001600160401b038111156137e957600080fd5b8301601f810185136137fa57600080fd5b803561380861328382614179565b80828252848201915084840188868560051b870101111561382857600080fd5b600094505b8385101561385457803561384081614317565b83526001949094019391850191850161382d565b50979650505050505050565b60006020828403121561387257600080fd5b8151612bb38161432c565b60006020828403121561388f57600080fd5b5035919050565b6000602082840312156138a857600080fd5b81356001600160e01b031981168114612bb357600080fd5b6000602082840312156138d257600080fd5b81356001600160401b038111156138e857600080fd5b61300284828501613388565b60008060008060008060c0878903121561390d57600080fd5b86356001600160401b0381111561392357600080fd5b61392f89828a01613388565b965050602087013561394081614317565b94506040870135935060608701356004811061395b57600080fd5b9250608087013561396b8161432c565b915060a087013561397b8161432c565b809150509295509295509295565b6000806040838503121561399c57600080fd5b82356001600160401b038111156139b257600080fd5b6139be85828601613388565b92505060208301356139cf8161432c565b809150509250929050565b6000602082840312156139ec57600080fd5b81356001600160401b0380821115613a0357600080fd5b9083019060a08286031215613a1757600080fd5b613a1f614127565b823582811115613a2e57600080fd5b613a3a87828601613388565b825250613a49602084016134b3565b60208201526040830135604082015260608301356060820152608083013582811115613a7457600080fd5b613a8087828601613388565b60808301525095945050505050565b600060208284031215613aa157600080fd5b81356001600160401b0380821115613ab857600080fd5b9083019060608286031215613acc57600080fd5b604051606081018181108382111715613ae757613ae7614301565b6040528235613af581614317565b815260208381013590820152604083013582811115613b1357600080fd5b613b1f87828601613388565b60408301525095945050505050565b600060208284031215613b4057600080fd5b81356001600160401b03811115613b5657600080fd5b613002848285016133f7565b60008060408385031215613b7557600080fd5b82356001600160401b03811115613b8b57600080fd5b613b97858286016133f7565b95602094909401359450505050565b60008060408385031215613bb957600080fd5b82356001600160401b03811115613bcf57600080fd5b613b978582860161340f565b600060208284031215613bed57600080fd5b612bb3826134b3565b600060208284031215613c0857600080fd5b5051919050565b600060208284031215613c2157600080fd5b612bb3826134c5565b600081518084526020808501945080840160005b83811015613c635781516001600160a01b031687529582019590820190600101613c3e565b509495945050505050565b600081518084526020808501945080840160005b83811015613c6357815187529582019590820190600101613c82565b60008151808452613cb6816020860160208601614243565b601f01601f19169290920160200192915050565b60048110613ce857634e487b7160e01b600052602160045260246000fd5b9052565b86815260f086901b6001600160f01b031916602082015260c085901b6001600160c01b0319166022820152602a81018490528183604a83013760009101604a0190815295945050505050565b60008251613d4a818460208701614243565b9190910192915050565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b6001600160a01b0384168152606060208201819052600090613db090830185613c6e565b8281036040840152612f838185613c6e565b602081526000612bb36020830184613c2a565b604081526000613de86040830185613c2a565b8281036020840152613dfa8185613c6e565b95945050505050565b606081526000613e166060830185613c6e565b8281036020840152613e288185613c2a565b83810360409094019390935250506000815260200192915050565b82151581526040602082015260006130026040830184613c9e565b85815261ffff851660208201526001600160401b038416604082015282606082015260a06080820152600061316960a0830184613c9e565b602081526000612bb36020830184613c9e565b604081526000613ebc6040830185613c9e565b905082151560208301529392505050565b608081526000613ee06080830187613c9e565b9050846020830152613ef56040830185613cca565b821515606083015295945050505050565b602081016105298284613cca565b6020808252601490820152731513d2d15397d393d517d0d3d3919251d554915160621b604082015260600190565b6020808252600d908201526c24a72b20a624a22faa27a5a2a760991b604082015260600190565b6020808252600f908201526e1393d517d253925512505312569151608a1b604082015260600190565b602080825260089082015267111254d05093115160c21b604082015260600190565b6020808252600e908201526d1253959053125117d05353d5539560921b604082015260600190565b602081526000825160a06020840152613ff860c0840182613c9e565b905061ffff602085015116604084015260408401516060840152606084015160808401526080840151601f198483030160a0850152613dfa8282613c9e565b8381526080602082015260006140506080830185613c2a565b82810360408401526140628185613c6e565b8381036060909401939093525050600081526020019392505050565b8281526040602082015260006130026040830184613c9e565b6000808335601e198436030181126140ae57600080fd5b8301803591506001600160401b038211156140c857600080fd5b60200191503681900382131561099057600080fd5b604051608081016001600160401b03811182821017156140ff576140ff614301565b60405290565b60405160c081016001600160401b03811182821017156140ff576140ff614301565b60405160a081016001600160401b03811182821017156140ff576140ff614301565b604051601f8201601f191681016001600160401b038111828210171561417157614171614301565b604052919050565b60006001600160401b0382111561419257614192614301565b5060051b60200190565b600082198211156141af576141af6142bf565b500190565b60006001600160401b038083168185168083038211156141d6576141d66142bf565b01949350505050565b6000826141fc57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561421b5761421b6142bf565b500290565b600082821015614232576142326142bf565b500390565b6000610529368361340f565b60005b8381101561425e578181015183820152602001614246565b83811115611b5f5750506000910152565b600181811c9082168061428357607f821691505b6020821081141561340957634e487b7160e01b600052602260045260246000fd5b60006000198214156142b8576142b86142bf565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461151d57600080fd5b801515811461151d57600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206c89e176051aeb66a9db79b36853b78dc9ee04ba9c2cd6d7ea965a19988ab00964736f6c63430008070033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c80638456cb591161011a578063b172b222116100ad578063eaa7126b1161007c578063eaa7126b1461048d578063f23a6e61146104a0578063f2fde38b146104bf578063f8fd17cc146104d2578063ffae2c5b146104e557600080fd5b8063b172b22214610440578063bacdb26c14610448578063bc197c811461045b578063ea0954e91461047a57600080fd5b8063929f5840116100e9578063929f5840146103ea57806393272baf146104055780639a8a059214610425578063b05b63251461042d57600080fd5b80638456cb59146103975780638da5cb5b1461039f5780638e068765146103c45780638fc462c1146103d757600080fd5b806349149d78116101925780635da334d5116101615780635da334d5146103495780635e188e981461035c57806362a77cb91461036f578063715018a61461038f57600080fd5b806349149d78146102f857806349e3c9ce1461030b578063529d15cc1461031e5780635c975abb1461033e57600080fd5b80633743ad8e116101ce5780633743ad8e146102a4578063397c7fc2146102ba5780633f4ba83a146102db57806344cd9e66146102e557600080fd5b806301ffc9a714610200578063150b7a021461022857806320f4bd131461025f5780632d6e652e14610291575b600080fd5b61021361020e366004613896565b6104f8565b60405190151581526020015b60405180910390f35b6102466102363660046135d4565b630a85bd0160e11b949350505050565b6040516001600160e01b0319909116815260200161021f565b61027261026d3660046138c0565b61052f565b604080516001600160a01b03909316835260208301919091520161021f565b61021361029f3660046136a7565b6106d2565b6102ac61072f565b60405190815260200161021f565b6102cd6102c8366004613ba6565b610742565b60405161021f929190613e43565b6102e3610997565b005b6102136102f336600461387d565b6109b1565b6102136103063660046136a7565b6109d2565b61021361031936600461387d565b610a30565b610326610a51565b6040516001600160401b03909116815260200161021f565b60335460ff16610213565b6102e3610357366004613b2e565b610a6d565b6102e361036a3660046136d3565b610d49565b61038261037d3660046136a7565b610e2c565b60405161021f9190613e96565b6102e3610fba565b6102e3610fcc565b6065546001600160a01b03165b6040516001600160a01b03909116815260200161021f565b6102e36103d2366004613b2e565b610fe4565b6102e36103e53660046138f4565b611091565b6103f261127a565b60405161ffff909116815260200161021f565b6104186104133660046134ed565b611297565b60405161021f9190613f06565b6103f26112c6565b6102e361043b366004613b2e565b6112dd565b6102ac611350565b6102e3610456366004613989565b611363565b610246610469366004613527565b63bc197c8160e01b95945050505050565b6102136104883660046138c0565b6113cb565b6102cd61049b366004613b62565b6113f3565b6102466104ae36600461363f565b63f23a6e6160e01b95945050505050565b6102e36104cd3660046134ed565b6114a7565b6102e36104e036600461372b565b611520565b6103ac6104f336600461387d565b611659565b60006001600160e01b03198216630271189760e51b148061052957506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080600061053c6116a1565b6000016000858051906020012081526020019081526020016000206040518060c00160405290816000820180546105729061426f565b80601f016020809104026020016040519081016040528092919081815260200182805461059e9061426f565b80156105eb5780601f106105c0576101008083540402835291602001916105eb565b820191906000526020600020905b8154815290600101906020018083116105ce57829003601f168201915b5050509183525050600182015460ff808216151560208085019190915261010083048216151560408501526201000083049091161515606084015263010000009091046001600160a01b0316608083015260029092015460a0909101528101519091506106735760405162461bcd60e51b815260040161066a90613f69565b60405180910390fd5b80606001516106945760405162461bcd60e51b815260040161066a90613f92565b60808101516001600160a01b03166106be5760405162461bcd60e51b815260040161066a90613f14565b806080015192508060a00151915050915091565b60006106dc6116a1565b60006106e66116a1565b6001600160a01b0386166000908152600291909101602090815260408083208784528252808320548452908301939093529101902060010154610100900460ff16905092915050565b60006107396116a1565b60080154919050565b6000606061074e61127a565b61ffff16846020015161ffff161461079057505060408051808201909152600f81526e24a6a82927a822a92fa7a924a3a4a760891b6020820152600090610990565b600061079a61072f565b90506107ab8560a0015151826116c5565b6107da5750506040805180820190915260098152684e4f5f51554f52554d60b81b602082015260009150610990565b6000805b8660a00151518110156109765760008760a001518281518110610803576108036142eb565b602002602001015190508160001480610822575082816060015160ff16115b6108655760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa9a4a3a722a92fa7a92222a960611b604482015260640161066a565b606081015160ff1692508383106108be5760405162461bcd60e51b815260206004820152601a60248201527f5349474e45525f494e4445585f4f55545f4f465f424f554e4453000000000000604482015260640161066a565b6000806108d9898460400151856000015186602001516116f3565b909250905060008160048111156108f2576108f26142d5565b141580610920575061090a836060015160ff16611659565b6001600160a01b0316826001600160a01b031614155b1561096057600060405180604001604052806011815260200170494e56414c49445f5349474e415455524560781b81525097509750505050505050610990565b505050808061096e906142a4565b9150506107de565b506001604051806020016040528060008152509350935050505b9250929050565b61099f6117e0565b6109a7611829565b6109af611883565b565b60006109bb6116a1565b600092835260040160205250604090205460ff1690565b60006109dc6116a1565b60006109e66116a1565b6001600160a01b039590951660009081526002909501602090815260408087209587529481528486205482528101919091529091019091206001015462010000900460ff16919050565b6000610a3a6116a1565b600092835260030160205250604090205460ff1690565b6000610a5b6116a1565b600701546001600160401b0316919050565b60008135610a816040840160208501613bdb565b610a916060850160408601613c0f565b6060850135610aa36080870187614097565b604051602001610ab896959493929190613cec565b604051602081830303815290604052805190602001209050600080610ae684610ae090614237565b84610742565b91509150818190610b0a5760405162461bcd60e51b815260040161066a9190613e96565b50610b14836109b1565b15610b575760405162461bcd60e51b81526020600482015260136024820152721094925111d157d35154d4d051d157d554d151606a1b604482015260640161066a565b610b60836118d5565b6000610b6f6080860186614097565b810190610b7c91906139da565b9050610b866112c6565b61ffff16816020015161ffff1614610bd05760405162461bcd60e51b815260206004820152600d60248201526c15d493d391d7d0d21052539251609a1b604482015260640161066a565b806080015151601414610c255760405162461bcd60e51b815260206004820152601860248201527f494e56414c49445f524543495049454e545f4c454e4754480000000000000000604482015260640161066a565b6000610c348260800151611900565b9050600080610c46846000015161052f565b91509150600080610c5684611297565b90506001816003811115610c6c57610c6c6142d5565b1415610c8657610c8184876040015187611954565b610ce5565b6002816003811115610c9a57610c9a6142d5565b1415610cb25785606001519150610c81848387611b65565b6003816003811115610cc657610cc66142d5565b1415610ce557856060015183179150610ce58483886040015188611d8f565b60408087015181516001600160a01b0380881682526020820192909252918201849052861660608201527f339a78cc37814d54dd1a3ccbf16d932c40974436167cf02f9137bdd674375429906080015b60405180910390a150505050505050505050565b610d51611829565b6001600160a01b038316610d775760405162461bcd60e51b815260040161066a90613f42565b6000815111610dc25760405162461bcd60e51b8152602060048201526017602482015276494e56414c49445f544f4b454e5f434c4153535f4b455960481b604482015260640161066a565b6000610dcd826120d6565b9050610de3848484610dde85611297565b612243565b836001600160a01b03167f970cf9001ac6e5e23eb555839b7b51be91a81a32e14d2ac2ba320ecd32266b848484604051610e1e92919061407e565b60405180910390a250505050565b60606000610e386116a1565b6000610e426116a1565b6001600160a01b0387166000908152600291909101602090815260408083208884528252808320548452908301939093529082019020815160c08101909252805482908290610e909061426f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ebc9061426f565b8015610f095780601f10610ede57610100808354040283529160200191610f09565b820191906000526020600020905b815481529060010190602001808311610eec57829003601f168201915b5050509183525050600182015460ff808216151560208085019190915261010083048216151560408501526201000083049091161515606084015263010000009091046001600160a01b0316608083015260029092015460a090910152810151909150610f885760405162461bcd60e51b815260040161066a90613f69565b60808101516001600160a01b0316610fb25760405162461bcd60e51b815260040161066a90613f14565b519392505050565b610fc2611829565b6109af60006122c6565b610fd4612318565b610fdc611829565b6109af61235e565b610fed8161239b565b6000610ffc6080830183614097565b81019061100991906137c0565b9050600081511161104d5760405162461bcd60e51b815260206004820152600e60248201526d4e4f5f415554484f52495449455360901b604482015260640161066a565b61105681612439565b7f43dd54b693a773b597de134f3199f428256d72ae149cd72c7447ff0ee91235ce816040516110859190613dc2565b60405180910390a15050565b611099611829565b60008651116110e45760405162461bcd60e51b8152602060048201526017602482015276494e56414c49445f544f4b454e5f434c4153535f4b455960481b604482015260640161066a565b6110ed866113cb565b1561112f5760405162461bcd60e51b81526020600482015260126024820152711094925111d157d25392551250531256915160721b604482015260640161066a565b6001600160a01b0385166111555760405162461bcd60e51b815260040161066a90613f42565b6000836003811115611169576111696142d5565b14156111ac5760405162461bcd60e51b8152602060048201526012602482015271494e56414c49445f544f4b454e5f5459504560701b604482015260640161066a565b6111f26040518060c0016040528088815260200160011515815260200184151581526020018315158152602001876001600160a01b031681526020018681525084612458565b846001600160a01b03167fc3101dae71c94df4dc3fcd71f100b459c624f9a061f3aeb2f6991239677a6e70878686866040516112319493929190613ecd565b60405180910390a27fe560594cb1b0ce3eede97f8741b06bc5f57b6d94ce3d7f2b2e23c1f135d42be3868260405161126a929190613ea9565b60405180910390a1505050505050565b60006112846116a1565b6005015462010000900461ffff16919050565b60006112a16116a1565b6001600160a01b03909216600090815260019290920160205250604090205460ff1690565b60006112d06116a1565b6005015461ffff16919050565b6112e68161239b565b60006112f56080830183614097565b8101906113029190613a8f565b90508060200151431015611338576020810151604051630f947b6560e01b8152436004820152602481019190915260440161066a565b61134c81600001518260400151600061259d565b5050565b600061135a6116a1565b60060154905090565b61136b611829565b611374826113cb565b6113905760405162461bcd60e51b815260040161066a90613f69565b61139a82826125c7565b7fe560594cb1b0ce3eede97f8741b06bc5f57b6d94ce3d7f2b2e23c1f135d42be38282604051611085929190613ea9565b60006113d56116a1565b82516020938401206000908152925250604090206001015460ff1690565b6000606061140083610a30565b1561144357505060408051808201909152601b81527f474f5645524e414e43455f4d4553534147455f434f4e53554d454400000000006020820152600090610990565b61144b611350565b84351461149057505060408051808201909152601c81527f4e4f545f46524f4d5f474f5645524e414e43455f434f4e5452414354000000006020820152600090610990565b61149c610ae085614237565b915091509250929050565b6114af611829565b6001600160a01b0381166115145760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161066a565b61151d816122c6565b50565b611528612318565b6001600160a01b03851661154e5760405162461bcd60e51b815260040161066a90613f42565b8061158f5760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015260640161066a565b600061159a86611297565b905060018160038111156115b0576115b06142d5565b14156115c7576115c286868585612603565b611651565b60028160038111156115db576115db6142d5565b14156115ed576115c2868585856126dc565b6003816003811115611601576116016142d5565b1415611614576115c28685878686612784565b60405162461bcd60e51b8152602060048201526012602482015271554e4b4e4f574e5f544f4b454e5f5459504560701b604482015260640161066a565b505050505050565b60006116636116a1565b6008018281548110611677576116776142eb565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b03163b151590565b7f07b26557da28ba49062e0328822024c4af75c9bcd1fcb0d96f1702cfe37e7d7090565b600060036116d4836002614201565b6116de91906141df565b6116e990600161419c565b9092101592915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561172a57506000905060036117d7565b8460ff16601b1415801561174257508460ff16601c14155b1561175357506000905060046117d7565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156117a7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166117d0576000600192509250506117d7565b9150600090505b94509492505050565b60335460ff166109af5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161066a565b6065546001600160a01b031633146109af5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161066a565b61188b6117e0565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60016118df6116a1565b60009283526004016020526040909120805460ff1916911515919091179055565b60148101516001600160a01b03811661194f5760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015260640161066a565b919050565b816119715760405162461bcd60e51b815260040161066a90613fb4565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b1580156119b357600080fd5b505afa1580156119c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119eb9190613bf6565b905082811015611b4b576040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090503082600081518110611a4e57611a4e6142eb565b6001600160a01b0390921660209283029190910190910152611a708386614220565b81600081518110611a8357611a836142eb565b60209081029190910101526040516307fd30df60e41b81526001600160a01b03871690637fd30df090611abc9085908590600401613dd5565b602060405180830381600087803b158015611ad657600080fd5b505af1158015611aea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0e9190613860565b611b485760405162461bcd60e51b815260206004820152600b60248201526a1352539517d1905253115160aa1b604482015260640161066a565b50505b611b5f6001600160a01b0385168385612ac0565b50505050565b6040516331a9108f60e11b8152600481018390526001600160a01b03841690636352211e9060240160206040518083038186803b158015611ba557600080fd5b505afa925050508015611bd5575060408051601f3d908101601f19168201909252611bd29181019061350a565b60015b611cd6576040516340c10f1960e01b8152306004820152602481018390526001600160a01b038416906340c10f1990604401600060405180830381600087803b158015611c2157600080fd5b505af1925050508015611c32575060015b611cd157604051632851206560e21b8152306004820152602481018390526001600160a01b0384169063a144819490604401600060405180830381600087803b158015611c7e57600080fd5b505af1925050508015611c8f575060015b611cd15760405162461bcd60e51b8152602060048201526013602482015272155392d393d5d397d15490cdcc8c57d3525395606a1b604482015260640161066a565b611d22565b6001600160a01b0381163014611d205760405162461bcd60e51b815260206004820152600f60248201526e1513d2d15397d393d517d3d5d39151608a1b604482015260640161066a565b505b604051632142170760e11b81523060048201526001600160a01b038281166024830152604482018490528416906342842e0e90606401600060405180830381600087803b158015611d7257600080fd5b505af1158015611d86573d6000803e3d6000fd5b50505050505050565b81611dac5760405162461bcd60e51b815260040161066a90613fb4565b6040516356f5fb7960e11b81526004810184905284906000906001600160a01b0383169063adebf6f29060240160206040518083038186803b158015611df157600080fd5b505afa158015611e05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e299190613860565b604051627eeac760e11b8152306004820152602481018790529091506000906001600160a01b0384169062fdd58e9060440160206040518083038186803b158015611e7357600080fd5b505afa158015611e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eab9190613bf6565b60408051600180825281830190925291925060009190602080830190803683370190505090503081600081518110611ee557611ee56142eb565b60200260200101906001600160a01b031690816001600160a01b03168152505085821015612068578215611fc55760408051600180825281830190925260009160208083019080368337019050509050611f3f8388614220565b81600081518110611f5257611f526142eb565b602090810291909101015260405163060fec9560e21b81526001600160a01b0386169063183fb25490611f8d908b9086908690600401614037565b600060405180830381600087803b158015611fa757600080fd5b505af1158015611fbb573d6000803e3d6000fd5b5050505050612068565b604080516001808252818301909252600091602080830190803683370190505090508781600081518110611ffb57611ffb6142eb565b602090810291909101015260405163c5d5496560e01b81526001600160a01b0386169063c5d54965906120349084908690600401613e03565b600060405180830381600087803b15801561204e57600080fd5b505af1158015612062573d6000803e3d6000fd5b50505050505b604051637921219560e11b81526001600160a01b0385169063f242432a9061209a90309089908c908c90600401613d54565b600060405180830381600087803b1580156120b457600080fd5b505af11580156120c8573d6000803e3d6000fd5b505050505050505050505050565b6000806120e16116a1565b6000016000848051906020012081526020019081526020016000206040518060c00160405290816000820180546121179061426f565b80601f01602080910402602001604051908101604052809291908181526020018280546121439061426f565b80156121905780601f1061216557610100808354040283529160200191612190565b820191906000526020600020905b81548152906001019060200180831161217357829003601f168201915b5050509183525050600182015460ff808216151560208085019190915261010083048216151560408501526201000083049091161515606084015263010000009091046001600160a01b0316608083015260029092015460a09091015281015190915061220f5760405162461bcd60e51b815260040161066a90613f69565b60808101516001600160a01b03166122395760405162461bcd60e51b815260040161066a90613f14565b6080015192915050565b815160208301206122526116a1565b6001600160a01b038616600090815260029190910160209081526040808320878452909152902055806122836116a1565b6001600160a01b03861660009081526001918201602052604090208054909160ff19909116908360038111156122bb576122bb6142d5565b021790555050505050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60335460ff16156109af5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161066a565b612366612318565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586118b83390565b600081356123af6040840160208501613bdb565b6123bf6060850160408601613c0f565b60608501356123d16080870187614097565b6040516020016123e696959493929190613cec565b60405160208183030381529060405280519060200120905060008061240b84846113f3565b9150915081819061242f5760405162461bcd60e51b815260040161066a9190613e96565b50611b5f83612b23565b806124426116a1565b600801908051906020019061134c929190613174565b815180516020909101208261246b6116a1565b600083815260209182526040902082518051919261248e928492909101906131d9565b5060208201516001820180546040850151606086015160808701516001600160a01b03166301000000026301000000600160b81b031991151562010000029190911662010000600160b81b03199215156101000261ff00199615159690961661ffff199094169390931794909417161791909117905560a090910151600290910155816125196116a1565b60808501516001600160a01b031660009081526001918201602052604090208054909160ff1990911690836003811115612555576125556142d5565b0217905550806125636116a1565b60808501516001600160a01b031660009081526002919091016020908152604080832060a090970151835295905293909320929092555050565b6125a683612b4e565b6000825111806125b35750805b156125c257611b5f8383612b8e565b505050565b806125d06116a1565b83516020948501206000908152935260409092206001018054921515620100000262ff0000199093169290921790915550565b826126205760405162461bcd60e51b815260040161066a90613fb4565b61262b8460006109d2565b6126475760405162461bcd60e51b815260040161066a90613f92565b6126578460008560008686612bba565b61266c6001600160a01b038516333086612cf8565b6126778460006106d2565b15611b5f57604051630852cd8d60e31b8152600481018490526001600160a01b038516906342966c6890602401600060405180830381600087803b1580156126be57600080fd5b505af11580156126d2573d6000803e3d6000fd5b5050505050505050565b6126e78460006109d2565b6127035760405162461bcd60e51b815260040161066a90613f92565b6127138460006001868686612bba565b604051632142170760e11b8152336004820152306024820152604481018490526001600160a01b038516906342842e0e90606401600060405180830381600087803b15801561276157600080fd5b505af1158015612775573d6000803e3d6000fd5b505050506126778460006106d2565b826127a15760405162461bcd60e51b815260040161066a90613fb4565b6040516356f5fb7960e11b815260048101859052600090819087906001600160a01b0382169063adebf6f29060240160206040518083038186803b1580156127e857600080fd5b505afa1580156127fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128209190613860565b156128315786925060009150612927565b604051636f969c2d60e01b8152600481018890526001600160a01b03821690636f969c2d9060240160206040518083038186803b15801561287157600080fd5b505afa158015612885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a99190613bf6565b604051632732871960e21b8152600481018990529093506001600160a01b03821690639cca1c649060240160206040518083038186803b1580156128ec57600080fd5b505afa158015612900573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129249190613bf6565b91505b61293188846109d2565b61294d5760405162461bcd60e51b815260040161066a90613f92565b61295b888488858989612bba565b604051637921219560e11b81526001600160a01b0389169063f242432a9061298d90339030908c908c90600401613d54565b600060405180830381600087803b1580156129a757600080fd5b505af11580156129bb573d6000803e3d6000fd5b505050506129c988846106d2565b156126d2576040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090508882600081518110612a2757612a276142eb565b6020026020010181815250508781600081518110612a4757612a476142eb565b6020908102919091010152604051633db0f8ab60e01b81526001600160a01b038b1690633db0f8ab90612a8290309086908690600401613d8c565b600060405180830381600087803b158015612a9c57600080fd5b505af1158015612ab0573d6000803e3d6000fd5b5050505050505050505050505050565b6040516001600160a01b0383166024820152604481018290526125c290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d30565b6001612b2d6116a1565b60009283526003016020526040909120805460ff1916911515919091179055565b612b5781612e02565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060612bb3838360405180606001604052806027815260200161433b60279139612eb0565b9392505050565b6000612bc68787610e2c565b905060006040518060a00160405280838152602001612be361127a565b61ffff16815260200187815260200186815260200185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093909452509293503092509050612c3f612f8d565b90507fb2d93ec15439019c2bd2b7d1271afd1bab015bc32c9626b0f54483958e8f253082612c6b6112c6565b8385612c756112c6565b86604051602001612cb39392919092835260f09190911b6001600160f01b031916602083015260c01b6001600160c01b0319166022820152602a0190565b6040516020818303038152906040528051906020012087604051602001612cda9190613fdc565b60408051601f1981840301815290829052610d359594939291613e5e565b6040516001600160a01b0380851660248301528316604482015260648101829052611b5f9085906323b872dd60e01b90608401612aec565b6000612d85826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612ff39092919063ffffffff16565b8051909150156125c25780806020019051810190612da39190613860565b6125c25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161066a565b6001600160a01b0381163b612e6f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161066a565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b612f185760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161066a565b600080856001600160a01b031685604051612f339190613d38565b600060405180830381855af49150503d8060008114612f6e576040519150601f19603f3d011682016040523d82523d6000602084013e612f73565b606091505b5091509150612f8382828661300a565b9695505050505050565b6000612f976116a1565b600701546001600160401b031690506001612fb06116a1565b6007018054600090612fcc9084906001600160401b03166141b4565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555090565b60606130028484600085613043565b949350505050565b60608315613019575081612bb3565b8251156130295782518084602001fd5b8160405162461bcd60e51b815260040161066a9190613e96565b6060824710156130a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161066a565b6001600160a01b0385163b6130fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161066a565b600080866001600160a01b031685876040516131179190613d38565b60006040518083038185875af1925050503d8060008114613154576040519150601f19603f3d011682016040523d82523d6000602084013e613159565b606091505b509150915061316982828661300a565b979650505050505050565b8280548282559060005260206000209081019282156131c9579160200282015b828111156131c957825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613194565b506131d592915061324d565b5090565b8280546131e59061426f565b90600052602060002090601f01602090048101928261320757600085556131c9565b82601f1061322057805160ff19168380011785556131c9565b828001600101855582156131c9579182015b828111156131c9578251825591602001919060010190613232565b5b808211156131d5576000815560010161324e565b600082601f83011261327357600080fd5b8135602061328861328383614179565b614149565b80838252828201915082860187848660071b89010111156132a857600080fd5b6000805b8681101561330d57608080848c0312156132c4578283fd5b6132cc6140dd565b84358152878501358882015260406132e58187016134dc565b9082015260606132f68682016134dc565b9082015286529486019492909201916001016132ac565b509198975050505050505050565b600082601f83011261332c57600080fd5b8135602061333c61328383614179565b80838252828201915082860187848660051b890101111561335c57600080fd5b60005b8581101561337b5781358452928401929084019060010161335f565b5090979650505050505050565b600082601f83011261339957600080fd5b81356001600160401b038111156133b2576133b2614301565b6133c5601f8201601f1916602001614149565b8181528460208386010111156133da57600080fd5b816020850160208301376000918101602001919091529392505050565b600060c0828403121561340957600080fd5b50919050565b600060c0828403121561342157600080fd5b613429614105565b90508135815261343b602083016134b3565b602082015261344c604083016134c5565b60408201526060820135606082015260808201356001600160401b038082111561347557600080fd5b61348185838601613388565b608084015260a084013591508082111561349a57600080fd5b506134a784828501613262565b60a08301525092915050565b803561ffff8116811461194f57600080fd5b80356001600160401b038116811461194f57600080fd5b803560ff8116811461194f57600080fd5b6000602082840312156134ff57600080fd5b8135612bb381614317565b60006020828403121561351c57600080fd5b8151612bb381614317565b600080600080600060a0868803121561353f57600080fd5b853561354a81614317565b9450602086013561355a81614317565b935060408601356001600160401b038082111561357657600080fd5b61358289838a0161331b565b9450606088013591508082111561359857600080fd5b6135a489838a0161331b565b935060808801359150808211156135ba57600080fd5b506135c788828901613388565b9150509295509295909350565b600080600080608085870312156135ea57600080fd5b84356135f581614317565b9350602085013561360581614317565b92506040850135915060608501356001600160401b0381111561362757600080fd5b61363387828801613388565b91505092959194509250565b600080600080600060a0868803121561365757600080fd5b853561366281614317565b9450602086013561367281614317565b9350604086013592506060860135915060808601356001600160401b0381111561369b57600080fd5b6135c788828901613388565b600080604083850312156136ba57600080fd5b82356136c581614317565b946020939093013593505050565b6000806000606084860312156136e857600080fd5b83356136f381614317565b92506020840135915060408401356001600160401b0381111561371557600080fd5b61372186828701613388565b9150509250925092565b60008060008060006080868803121561374357600080fd5b853561374e81614317565b9450602086013593506040860135925060608601356001600160401b038082111561377857600080fd5b818801915088601f83011261378c57600080fd5b81358181111561379b57600080fd5b8960208285010111156137ad57600080fd5b9699959850939650602001949392505050565b600060208083850312156137d357600080fd5b82356001600160401b038111156137e957600080fd5b8301601f810185136137fa57600080fd5b803561380861328382614179565b80828252848201915084840188868560051b870101111561382857600080fd5b600094505b8385101561385457803561384081614317565b83526001949094019391850191850161382d565b50979650505050505050565b60006020828403121561387257600080fd5b8151612bb38161432c565b60006020828403121561388f57600080fd5b5035919050565b6000602082840312156138a857600080fd5b81356001600160e01b031981168114612bb357600080fd5b6000602082840312156138d257600080fd5b81356001600160401b038111156138e857600080fd5b61300284828501613388565b60008060008060008060c0878903121561390d57600080fd5b86356001600160401b0381111561392357600080fd5b61392f89828a01613388565b965050602087013561394081614317565b94506040870135935060608701356004811061395b57600080fd5b9250608087013561396b8161432c565b915060a087013561397b8161432c565b809150509295509295509295565b6000806040838503121561399c57600080fd5b82356001600160401b038111156139b257600080fd5b6139be85828601613388565b92505060208301356139cf8161432c565b809150509250929050565b6000602082840312156139ec57600080fd5b81356001600160401b0380821115613a0357600080fd5b9083019060a08286031215613a1757600080fd5b613a1f614127565b823582811115613a2e57600080fd5b613a3a87828601613388565b825250613a49602084016134b3565b60208201526040830135604082015260608301356060820152608083013582811115613a7457600080fd5b613a8087828601613388565b60808301525095945050505050565b600060208284031215613aa157600080fd5b81356001600160401b0380821115613ab857600080fd5b9083019060608286031215613acc57600080fd5b604051606081018181108382111715613ae757613ae7614301565b6040528235613af581614317565b815260208381013590820152604083013582811115613b1357600080fd5b613b1f87828601613388565b60408301525095945050505050565b600060208284031215613b4057600080fd5b81356001600160401b03811115613b5657600080fd5b613002848285016133f7565b60008060408385031215613b7557600080fd5b82356001600160401b03811115613b8b57600080fd5b613b97858286016133f7565b95602094909401359450505050565b60008060408385031215613bb957600080fd5b82356001600160401b03811115613bcf57600080fd5b613b978582860161340f565b600060208284031215613bed57600080fd5b612bb3826134b3565b600060208284031215613c0857600080fd5b5051919050565b600060208284031215613c2157600080fd5b612bb3826134c5565b600081518084526020808501945080840160005b83811015613c635781516001600160a01b031687529582019590820190600101613c3e565b509495945050505050565b600081518084526020808501945080840160005b83811015613c6357815187529582019590820190600101613c82565b60008151808452613cb6816020860160208601614243565b601f01601f19169290920160200192915050565b60048110613ce857634e487b7160e01b600052602160045260246000fd5b9052565b86815260f086901b6001600160f01b031916602082015260c085901b6001600160c01b0319166022820152602a81018490528183604a83013760009101604a0190815295945050505050565b60008251613d4a818460208701614243565b9190910192915050565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b6001600160a01b0384168152606060208201819052600090613db090830185613c6e565b8281036040840152612f838185613c6e565b602081526000612bb36020830184613c2a565b604081526000613de86040830185613c2a565b8281036020840152613dfa8185613c6e565b95945050505050565b606081526000613e166060830185613c6e565b8281036020840152613e288185613c2a565b83810360409094019390935250506000815260200192915050565b82151581526040602082015260006130026040830184613c9e565b85815261ffff851660208201526001600160401b038416604082015282606082015260a06080820152600061316960a0830184613c9e565b602081526000612bb36020830184613c9e565b604081526000613ebc6040830185613c9e565b905082151560208301529392505050565b608081526000613ee06080830187613c9e565b9050846020830152613ef56040830185613cca565b821515606083015295945050505050565b602081016105298284613cca565b6020808252601490820152731513d2d15397d393d517d0d3d3919251d554915160621b604082015260600190565b6020808252600d908201526c24a72b20a624a22faa27a5a2a760991b604082015260600190565b6020808252600f908201526e1393d517d253925512505312569151608a1b604082015260600190565b602080825260089082015267111254d05093115160c21b604082015260600190565b6020808252600e908201526d1253959053125117d05353d5539560921b604082015260600190565b602081526000825160a06020840152613ff860c0840182613c9e565b905061ffff602085015116604084015260408401516060840152606084015160808401526080840151601f198483030160a0850152613dfa8282613c9e565b8381526080602082015260006140506080830185613c2a565b82810360408401526140628185613c6e565b8381036060909401939093525050600081526020019392505050565b8281526040602082015260006130026040830184613c9e565b6000808335601e198436030181126140ae57600080fd5b8301803591506001600160401b038211156140c857600080fd5b60200191503681900382131561099057600080fd5b604051608081016001600160401b03811182821017156140ff576140ff614301565b60405290565b60405160c081016001600160401b03811182821017156140ff576140ff614301565b60405160a081016001600160401b03811182821017156140ff576140ff614301565b604051601f8201601f191681016001600160401b038111828210171561417157614171614301565b604052919050565b60006001600160401b0382111561419257614192614301565b5060051b60200190565b600082198211156141af576141af6142bf565b500190565b60006001600160401b038083168185168083038211156141d6576141d66142bf565b01949350505050565b6000826141fc57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561421b5761421b6142bf565b500290565b600082821015614232576142326142bf565b500390565b6000610529368361340f565b60005b8381101561425e578181015183820152602001614246565b83811115611b5f5750506000910152565b600181811c9082168061428357607f821691505b6020821081141561340957634e487b7160e01b600052602260045260246000fd5b60006000198214156142b8576142b86142bf565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461151d57600080fd5b801515811461151d57600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206c89e176051aeb66a9db79b36853b78dc9ee04ba9c2cd6d7ea965a19988ab00964736f6c63430008070033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.