creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/upgradeable_contracts/modules/factory/TokenFactory.sol": {
        "content": "pragma solidity 0.7.5;\n\nimport \"./TokenProxy.sol\";\nimport \"../OwnableModule.sol\";\n\n/**\n * @title TokenFactory\n * @dev Factory contract for deployment of new TokenProxy contracts.\n */\ncontract TokenFactory is OwnableModule {\n    address public tokenImage;\n\n    /**\n     * @dev Initializes this contract\n     * @param _owner of this factory contract.\n     * @param _tokenImage address of the token image contract that should be used for creation of new tokens.\n     */\n    constructor(address _owner, address _tokenImage) OwnableModule(_owner) {\n        tokenImage = _tokenImage;\n    }\n\n    /**\n     * @dev Tells the module interface version that this contract supports.\n     * @return major value of the version\n     * @return minor value of the version\n     * @return patch value of the version\n     */\n    function getModuleInterfacesVersion()\n        external\n        pure\n        returns (\n            uint64 major,\n            uint64 minor,\n            uint64 patch\n        )\n    {\n        return (1, 0, 0);\n    }\n\n    /**\n     * @dev Updates the address of the used token image contract.\n     * Only owner can call this method.\n     * @param _tokenImage address of the new token image used for further deployments.\n     */\n    function setTokenImage(address _tokenImage) external onlyOwner {\n        require(Address.isContract(_tokenImage));\n        tokenImage = _tokenImage;\n    }\n\n    /**\n     * @dev Deploys a new TokenProxy contract, using saved token image contract as a template.\n     * @param _name deployed token name.\n     * @param _symbol deployed token symbol.\n     * @param _decimals deployed token decimals.\n     * @param _chainId chain id of the current environment.\n     * @return address of a newly created contract.\n     */\n    function deploy(\n        string calldata _name,\n        string calldata _symbol,\n        uint8 _decimals,\n        uint256 _chainId,\n        address _feeAddr,\n        uint256 _feeAmount\n    ) external returns (address) {\n        return address(new TokenProxy(tokenImage, _name, _symbol, _decimals, _chainId, msg.sender, _feeAddr, _feeAmount));\n    }\n}\n"
      },
      "contracts/upgradeable_contracts/modules/OwnableModule.sol": {
        "content": "pragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\n\n/**\n * @title OwnableModule\n * @dev Common functionality for multi-token extension non-upgradeable module.\n */\ncontract OwnableModule {\n    address public owner;\n\n    /**\n     * @dev Initializes this contract.\n     * @param _owner address of the owner that is allowed to perform additional actions on the particular module.\n     */\n    constructor(address _owner) {\n        owner = _owner;\n    }\n\n    /**\n     * @dev Throws if sender is not the owner of this contract.\n     */\n    modifier onlyOwner {\n        require(msg.sender == owner);\n        _;\n    }\n\n    /**\n     * @dev Changes the owner of this contract.\n     * @param _newOwner address of the new owner.\n     */\n    function transferOwnership(address _newOwner) external onlyOwner {\n        owner = _newOwner;\n    }\n}\n"
      },
      "contracts/upgradeable_contracts/modules/factory/TokenProxy.sol": {
        "content": "pragma solidity 0.7.5;\n\nimport \"../../../upgradeability/Proxy.sol\";\n\ninterface IPermittableTokenVersion {\n    function version() external pure returns (string memory);\n}\n\n/**\n * @title TokenProxy\n * @dev Helps to reduces the size of the deployed bytecode for automatically created tokens, by using a proxy contract.\n */\ncontract TokenProxy is Proxy {\n    // storage layout is copied from PermittableToken.sol\n    string internal name;\n    string internal symbol;\n    uint8 internal decimals;\n    mapping(address => uint256) internal balances;\n    uint256 internal totalSupply;\n    mapping(address => mapping(address => uint256)) internal allowed;\n    address internal owner;\n    bool internal mintingFinished;\n    address internal bridgeContractAddr;\n    address internal bridgeFeeAddr;\n    uint256 internal bridgeFeeAmount;\n    // string public constant version = \"1\";\n    bytes32 internal DOMAIN_SEPARATOR;\n\n    // bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;\n    mapping(address => uint256) internal nonces;\n    mapping(address => mapping(address => uint256)) internal expirations;\n\n    /**\n     * @dev Creates a non-upgradeable token proxy for PermitableToken.sol, initializes its eternalStorage.\n     * @param _tokenImage address of the token image used for mirroring all functions.\n     * @param _name token name.\n     * @param _symbol token symbol.\n     * @param _decimals token decimals.\n     * @param _chainId chain id for current network.\n     * @param _owner address of the owner for this contract.\n     */\n    constructor(\n        address _tokenImage,\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals,\n        uint256 _chainId,\n        address _owner,\n        address _feeAddr,\n        uint256 _feeAmount\n    ) {\n        string memory version = IPermittableTokenVersion(_tokenImage).version();\n        assembly {\n            // EIP 1967\n            // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)\n            sstore(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, _tokenImage)\n        }\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n        owner = _owner; // _owner == HomeOmnibridge/ForeignOmnibridge mediator\n        bridgeContractAddr = _owner;\n        bridgeFeeAddr = _feeAddr;\n        bridgeFeeAmount = _feeAmount;\n\n        DOMAIN_SEPARATOR = keccak256(\n            abi.encode(\n                keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n                keccak256(bytes(_name)),\n                keccak256(bytes(version)),\n                _chainId,\n                address(this)\n            )\n        );\n    }\n\n    /**\n     * @dev Retrieves the implementation contract address, mirrored token image.\n     * @return impl token image address.\n     */\n    function implementation() public view override returns (address impl) {\n        assembly {\n            impl := sload(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc)\n        }\n    }\n\n    /**\n     * @dev Tells the current version of the token proxy interfaces.\n     */\n    function getTokenProxyInterfacesVersion()\n        external\n        pure\n        returns (\n            uint64 major,\n            uint64 minor,\n            uint64 patch\n        )\n    {\n        return (1, 0, 0);\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n        // for accounts without code, i.e. `keccak256('')`\n        bytes32 codehash;\n        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { codehash := extcodehash(account) }\n        return (codehash != accountHash && codehash != 0x0);\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{ value: amount }(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain`call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n      return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n        return _functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        return _functionCallWithValue(target, data, value, errorMessage);\n    }\n\n    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {\n        require(isContract(target), \"Address: call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                // solhint-disable-next-line no-inline-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "contracts/upgradeability/Proxy.sol": {
        "content": "pragma solidity 0.7.5;\n\n/**\n * @title Proxy\n * @dev Gives the possibility to delegate any call to a foreign implementation.\n */\nabstract contract Proxy {\n    /**\n     * @dev Tells the address of the implementation where every call will be delegated.\n     * @return address of the implementation to which it will be delegated\n     */\n    function implementation() public view virtual returns (address);\n\n    /**\n     * @dev Fallback function allowing to perform a delegatecall to the given implementation.\n     * This function will return whatever the implementation call returns\n     */\n    fallback() external payable {\n        // solhint-disable-previous-line no-complex-fallback\n        address _impl = implementation();\n        require(_impl != address(0));\n        assembly {\n            /*\n                0x40 is the \"free memory slot\", meaning a pointer to next slot of empty memory. mload(0x40)\n                loads the data in the free memory slot, so `ptr` is a pointer to the next slot of empty\n                memory. It's needed because we're going to write the return data of delegatecall to the\n                free memory slot.\n            */\n            let ptr := mload(0x40)\n            /*\n                `calldatacopy` is copy calldatasize bytes from calldata\n                First argument is the destination to which data is copied(ptr)\n                Second argument specifies the start position of the copied data.\n                    Since calldata is sort of its own unique location in memory,\n                    0 doesn't refer to 0 in memory or 0 in storage - it just refers to the zeroth byte of calldata.\n                    That's always going to be the zeroth byte of the function selector.\n                Third argument, calldatasize, specifies how much data will be copied.\n                    calldata is naturally calldatasize bytes long (same thing as msg.data.length)\n            */\n            calldatacopy(ptr, 0, calldatasize())\n            /*\n                delegatecall params explained:\n                gas: the amount of gas to provide for the call. `gas` is an Opcode that gives\n                    us the amount of gas still available to execution\n\n                _impl: address of the contract to delegate to\n\n                ptr: to pass copied data\n\n                calldatasize: loads the size of `bytes memory data`, same as msg.data.length\n\n                0, 0: These are for the `out` and `outsize` params. Because the output could be dynamic,\n                        these are set to 0, 0 so the output data will not be written to memory. The output\n                        data will be read using `returndatasize` and `returdatacopy` instead.\n\n                result: This will be 0 if the call fails and 1 if it succeeds\n            */\n            let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0)\n            /*\n\n            */\n            /*\n                ptr current points to the value stored at 0x40,\n                because we assigned it like ptr := mload(0x40).\n                Because we use 0x40 as a free memory pointer,\n                we want to make sure that the next time we want to allocate memory,\n                we aren't overwriting anything important.\n                So, by adding ptr and returndatasize,\n                we get a memory location beyond the end of the data we will be copying to ptr.\n                We place this in at 0x40, and any reads from 0x40 will now read from free memory\n            */\n            mstore(0x40, add(ptr, returndatasize()))\n            /*\n                `returndatacopy` is an Opcode that copies the last return data to a slot. `ptr` is the\n                    slot it will copy to, 0 means copy from the beginning of the return data, and size is\n                    the amount of data to copy.\n                `returndatasize` is an Opcode that gives us the size of the last return data. In this case, that is the size of the data returned from delegatecall\n            */\n            returndatacopy(ptr, 0, returndatasize())\n\n            /*\n                if `result` is 0, revert.\n                if `result` is 1, return `size` amount of data from `ptr`. This is the data that was\n                copied to `ptr` from the delegatecall return data\n            */\n            switch result\n                case 0 {\n                    revert(ptr, returndatasize())\n                }\n                default {\n                    return(ptr, returndatasize())\n                }\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}