此页内容

项目-合约文档

1332字约4分钟

2024-05-22

Interface

pragma solidity >=0.6.12;
interface ITarget {
    /**
    @dev 创建项目
    @param user 用户地址
    @param targetId id
     */
    event NewTargetCreated(address indexed user, uint256 targetId);

    /**
    @dev target 状态更改事件
    @param targetId     id
    @param statusFrom   修改前状态
    @param statusTo     修改后状态
     */
    event NewTargetStatus(
        uint256 indexed targetId,
        uint16 statusFrom,
        uint16 statusTo
    );

    /**
    @dev 【事件】注册 contractor
    @param user 用户地址
    @param targetId target
     */
    event NewContractor(address indexed user, uint256 targetId);

    /**
    @dev 获取target的状态
    @param _targetId id
    @return _status 状态码
     */
    function target2Status(
        uint256 _targetId
    ) external view returns (uint16 _status);
    /**
    @dev 获取用户地址是否是某个target的contractor
    @param _targetId id
    @param _user    地址
    @return _isBool 状态
     */
    function contractorMap(
        uint256 _targetId,
        address _user
    ) external view returns (bool _isBool);

    /**
    @dev 获取 target 绑定的有效支票
    @param _targetId id
     */
    function target2ActiveCheque(
        uint256 _targetId
    ) external view returns (uint256 _id);
    /**
    @dev 获取 target 绑定的有效分发
    @param _targetId id
     */
    function taregt2ActiveDistribution(
        uint256 _targetId
    ) external view returns (uint256 _id);

    /**
    @dev 获取当前项目数量
     */
    function targetLength() external view returns (uint256);

    /**
    @dev 获取某个 target 的所有 contractor
    @param _targetId id
    @return _arr   地址列表
    @return _length 数量
     */
    function gettTargetContractorList(
        uint256 _targetId
    ) external view returns (address[] memory _arr, uint256 _length);
    /**
    @dev 获取某个地址创建的所有的项目
    @param _user   用户地址
    @return _ids   用户持有的项目id列表
    @return _length 数量
     */
    function getAddrAllTarget(
        address _user
    ) external view returns (uint256[] memory _ids, uint256 _length);

    // ---------------------------------- SEND ----------------------------------
    /**
    @dev 创建一个项目-基础数据nft生成
    @notice 将 chainID、DataId、name、info、ipfsHash等数据上传到ipfs,使用ipfs的metadata铸造一枚nft
    */
    function createTarget(string memory uri) external;

    /**
    @dev 申请 contractor  成为管理员
    @notice 需要支付 SYT 手续费  (contractorFee 金额到 feeTo)
    @param _targetId 分发id
     */
    function registerContractor(uint256 _targetId) external;

    // ---------------------------------- Managers ----------------------------------

    /**
    @dev 管理员修改 target 的状态,支持 分发和支票合约
     */
    function updateTargetStatus(uint256 _targetId, uint16 _statusId) external;

    /**
    @dev 管理员修改 target 绑定的有效分发,支持 分发合约修改
     */
    function updateActiveDistribution(
        uint256 _targetId,
        uint256 _distributionId
    ) external;

    /**
    @dev 管理员修改 target 绑定的有效支票,支持 支票合约修改
     */
    function updateActiveCheque(uint256 _targetId, uint256 _chequeId) external;

    //--------------------- CONFIG -----------------------------

    function TargetNFT() external view returns (address);
    function TOKEN() external view returns (address);
    function feeTo() external view returns (address);
    function Vault() external view returns (address);

    function USDT() external view returns (address);
    function WETH() external view returns (address);
    function Router() external view returns (address);
    function PToken() external view returns (address);
    function YToken() external view returns (address);

    function contractorFee() external view returns (uint256);
    function creationFee() external view returns (uint256);
    function BASE() external view returns (uint256);
    function BaseEth2PT() external view returns (uint256);
    function startCheckInterval() external view returns (uint32);
    function endCheckInterval() external view returns (uint32);

    // --------------------- UPDATE -----------------------------
    function updateToken(address _token) external;
    function updateFeeTo(address _feeTo) external;
    function updateFeeRate(uint256 _feeRate) external;
    function updateRouter(address _router) external;
    function updateUSDT(address _usdt) external;
    function updateBase(uint256 _base) external;
    function updatePToken(address _ptoken) external;
    function updateYToken(address _ytoken) external;
    function updateBaseEth2PT(uint256 _base) external;
    function updateStartCheckInterval(uint32 _interval) external;
    function updateEndCheckInterval(uint32 _interval) external;
}

ABI

{
  "_format": "hh-sol-artifact-1",
  "contractName": "ITarget",
  "sourceName": "contracts/interface/ITarget.sol",
  "abi": [
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "user",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "targetId",
          "type": "uint256"
        }
      ],
      "name": "NewContractor",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "user",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "targetId",
          "type": "uint256"
        }
      ],
      "name": "NewTargetCreated",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "uint256",
          "name": "targetId",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "uint16",
          "name": "statusFrom",
          "type": "uint16"
        },
        {
          "indexed": false,
          "internalType": "uint16",
          "name": "statusTo",
          "type": "uint16"
        }
      ],
      "name": "NewTargetStatus",
      "type": "event"
    },
    {
      "inputs": [],
      "name": "BASE",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "BaseEth2PT",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "PToken",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "Router",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "TOKEN",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "TargetNFT",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "USDT",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "Vault",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "WETH",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "YToken",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "contractorFee",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        },
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        }
      ],
      "name": "contractorMap",
      "outputs": [
        {
          "internalType": "bool",
          "name": "_isBool",
          "type": "bool"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "uri",
          "type": "string"
        }
      ],
      "name": "createTarget",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "creationFee",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "endCheckInterval",
      "outputs": [
        {
          "internalType": "uint32",
          "name": "",
          "type": "uint32"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "feeTo",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        }
      ],
      "name": "getAddrAllTarget",
      "outputs": [
        {
          "internalType": "uint256[]",
          "name": "_ids",
          "type": "uint256[]"
        },
        {
          "internalType": "uint256",
          "name": "_length",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        }
      ],
      "name": "gettTargetContractorList",
      "outputs": [
        {
          "internalType": "address[]",
          "name": "_arr",
          "type": "address[]"
        },
        {
          "internalType": "uint256",
          "name": "_length",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        }
      ],
      "name": "registerContractor",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "startCheckInterval",
      "outputs": [
        {
          "internalType": "uint32",
          "name": "",
          "type": "uint32"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        }
      ],
      "name": "taregt2ActiveDistribution",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "_id",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        }
      ],
      "name": "target2ActiveCheque",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "_id",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        }
      ],
      "name": "target2Status",
      "outputs": [
        {
          "internalType": "uint16",
          "name": "_status",
          "type": "uint16"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "targetLength",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_chequeId",
          "type": "uint256"
        }
      ],
      "name": "updateActiveCheque",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "updateActiveDistribution",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_base",
          "type": "uint256"
        }
      ],
      "name": "updateBase",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_base",
          "type": "uint256"
        }
      ],
      "name": "updateBaseEth2PT",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint32",
          "name": "_interval",
          "type": "uint32"
        }
      ],
      "name": "updateEndCheckInterval",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_feeRate",
          "type": "uint256"
        }
      ],
      "name": "updateFeeRate",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_feeTo",
          "type": "address"
        }
      ],
      "name": "updateFeeTo",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_ptoken",
          "type": "address"
        }
      ],
      "name": "updatePToken",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_router",
          "type": "address"
        }
      ],
      "name": "updateRouter",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint32",
          "name": "_interval",
          "type": "uint32"
        }
      ],
      "name": "updateStartCheckInterval",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        },
        {
          "internalType": "uint16",
          "name": "_statusId",
          "type": "uint16"
        }
      ],
      "name": "updateTargetStatus",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_token",
          "type": "address"
        }
      ],
      "name": "updateToken",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_usdt",
          "type": "address"
        }
      ],
      "name": "updateUSDT",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_ytoken",
          "type": "address"
        }
      ],
      "name": "updateYToken",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ],
  "bytecode": "0x",
  "deployedBytecode": "0x",
  "linkReferences": {},
  "deployedLinkReferences": {}
}