// File: /Users/ahmedali/Desktop/work/mainnet-deployment/ocean-contracts/contracts/interfaces/IERC20Template.sol



pragma solidity >=0.5.0;

interface IERC20Template {
    function initialize(
        string calldata name,
        string calldata symbol,
        address minter,
        uint256 cap,
        string calldata blob,
        address collector
    ) external returns (bool);

    function mint(address account, uint256 value) external;
    function minter() external view returns(address);    
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    function cap() external view returns (uint256);
    function isMinter(address account) external view returns (bool);
    function isInitialized() external view returns (bool);
    function allowance(address owner, address spender)
        external
        view
        returns (uint256);
    function transferFrom(
        address from,
        address to,
        uint256 value
    ) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 value) external returns (bool);
    function proposeMinter(address newMinter) external;
    function approveMinter() external;
}

// File: /Users/ahmedali/Desktop/work/mainnet-deployment/ocean-contracts/contracts/metadata/Metadata.sol



pragma solidity 0.5.7;
// Copyright BigchainDB GmbH and Ocean Protocol contributors
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0

import '../interfaces/IERC20Template.sol';


/**
* @title Metadata
*  
* @dev Metadata stands for Decentralized Document. It allows publishers
*      to publish their dataset metadata in decentralized way.
*      It follows the Ocean DID Document standard: 
*      https://github.com/oceanprotocol/OEPs/blob/master/7/v0.2/README.md
*/
contract Metadata {

    event MetadataCreated(
        address indexed dataToken,
        address indexed createdBy,
        bytes flags,
        bytes data
    );
    event MetadataUpdated(
        address indexed dataToken,
        address indexed updatedBy,
        bytes flags,
        bytes data
    );

    modifier onlyDataTokenMinter(address dataToken)
    {
        IERC20Template token = IERC20Template(dataToken);
        require(
            token.minter() == msg.sender,
            'Metadata: Invalid DataToken Minter'
        );
        _;
    }

    /**
     * @dev create
     *      creates/publishes new metadata/DDO document on-chain. 
     * @param dataToken refers to data token address
     * @param flags special flags associated with metadata
     * @param data referes to the actual metadata
     */
    function create(
        address dataToken,
        bytes calldata flags,
        bytes calldata data
    ) 
        external
        onlyDataTokenMinter(dataToken)
    {
        emit MetadataCreated(
            dataToken,
            msg.sender,
            flags,
            data
        );
    }

    /**
     * @dev update
     *      allows only datatoken minter(s) to update the DDO/metadata content
     * @param dataToken refers to data token address
     * @param flags special flags associated with metadata
     * @param data referes to the actual metadata
     */
    function update(
        address dataToken,
        bytes calldata flags,
        bytes calldata data
    ) 
        external
        onlyDataTokenMinter(dataToken)
    {
        emit MetadataUpdated(
            dataToken,
            msg.sender,
            flags,
            data
        );
    }
}