此页内容

分发-合约文档

1375字约5分钟

2024-05-22

Interface

pragma solidity >=0.6.12;

pragma experimental ABIEncoderV2;
interface IDistribution {
    /**
    @dev 创建分发
    @param user 用户地址
    @param distributionId 分发id
     */
    event NewDistributionCreated(address indexed user, uint256 distributionId);

    /**
    @dev 用户参与
    @param user 用户地址
    @param distributionId 分发id
    @param targetID 分发对应的tagret
    @param amount 参与金额
     */
    event NewJoin(
        address indexed user,
        uint256 distributionId,
        uint256 targetID,
        uint256 amount
    );

    /**
    @dev 用户领取分红
    @param user 用户地址
    @param amount 涉及金额
     */
    event HarvestDividends(address indexed user, uint256 amount);

    struct DistributionStruct {
        uint256 indexer1; //字节码1
        uint256 indexer2; //字节码2
        address payAddr; // 打款地址,项目方的资金支付地址
        address tokenAddr; //代币合约地址
    }

    //分发总数量
    function distributionIndex() external view returns (uint256);

    /**
    @dev 根据Id获取分发详情
     */
    function distributions(
        uint256
    ) external view returns (DistributionStruct memory);

    /**
    @dev 根据分发Id获取对应所有者
     */
    function distribution2Owner(uint256) external view returns (address);
    /**
    @dev 根据分发Id获取对应已经融资金额
     */
    function distribution2Funding(uint256) external view returns (uint256);

    /**
    @dev 创建一个分发,只有申请成为 contractor 才能进行
    @param _indexer1 分发索引编码1
    @param _indexer2 分发索引编码1
    @param _payAddr  打款地址,项目方的资金支付地址
    @param _tokenAddr 代币合约地址
     */
    function createDistribution(
        uint256 _indexer1,
        uint256 _indexer2,
        address _payAddr,
        address _tokenAddr
    ) external;

    /**
    @dev 用户使用eth参与
    @notice msg.value 携带参与金额
    @param _distributionId 分发
     */
    function userJoin(uint256 _distributionId) external payable;
    /**
    @dev 用户查看自己可以领取的 分红
     */
    function pendingDividends(
        address _user
    ) external view returns (uint256 _amount);
    /**
    @dev 用户领取自己的分红
     */
    function harvestDividends() external;

    /**
     @dev 项目方进行打款,将所有资产全部转入
    - 这里转入 totalShares 总股份数量的代币
    @param _distributionId 分发地址
     */
    function payToken(uint256 _distributionId) external;

    /**
    @dev 根据编码数据获取 对应的targetId
     */
    function getTargetIdFromDis(uint256 _data) external pure returns (uint256);

    /**
    @dev 获取一个地址是否是白名单
    @param _user  用户
    @param _distributionId  分发id
     */
    function distribution2WhiteList(
        uint256 _user,
        uint256 _distributionId
    ) external view returns (bool);
    /**
    @dev 获取分发id对应的targetId
    @param _distributionId  分发id
     */
    function distribution2TargetId(
        uint256 _distributionId
    ) external view returns (uint256);

    /**
    @dev 根据分发Id获取分发的聚合信息
    @param _user            用户地址
    @param _distributionId  分发id
    
    @return _disStruct  分发结构体
    @return _owner     分发所有者
    @return _funding   分发当前募资金额
    @return _targetId  分发对应targetId
    @return _joinAmount 用户对当前分发参与金额

     */
    function getArgInfo2DisId(
        address _user,
        uint256 _distributionId
    )
        external
        view
        returns (
            DistributionStruct memory _disStruct,
            address _owner,
            uint256 _funding,
            uint256 _targetId,
            uint256 _joinAmount
        );

    /**
    @dev 设置白名单,分发所有者设置不受限制的地址白名单
    - 只有分发所有者可以设置
    - _isBool 默认可以全部放 true,为了适配特殊情况,所以允许使用false进行删除
    @param _distributionId  分发Id              1
    @param _whiteList       白名单地址列表       [user1,user2]
    @param _isBool          状态列表            [true,false]
     */
    function setCheckWhitelist(
        uint256 _distributionId,
        address[] memory _whiteList,
        bool[] memory _isBool
    ) external;

    /**
    @dev 获取指定用户的所有分发
    @param _user 用户地址
     */
    function getUserAllDis(
        address _user
    ) external view returns (DistributionStruct[] memory, uint256 _length);

    /**
    @dev 获取用户所有的分发id列表
     */
    function getUserDisIds(
        address _user
    ) external view returns (uint256[] memory);

    /**
    @dev 获取指定地址是否是白名单
    @param _user 用户地址
    @param _id 分发id
     */
    function getDis2WhiteList(address _user,uint256 _id) external view returns(bool);

     /**
    @dev 取消分发-分发所有者-状态进入310-主动结束
     */
    function cancelDistribution(uint256 _distributionId) external;
}

ABI

{
  "_format": "hh-sol-artifact-1",
  "contractName": "IDistribution",
  "sourceName": "contracts/interface/IDistribution.sol",
  "abi": [
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "user",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "name": "HarvestDividends",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "user",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "distributionId",
          "type": "uint256"
        }
      ],
      "name": "NewDistributionCreated",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "user",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "distributionId",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "targetID",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "name": "NewJoin",
      "type": "event"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "cancelDistribution",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_indexer1",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_indexer2",
          "type": "uint256"
        },
        {
          "internalType": "address",
          "name": "_payAddr",
          "type": "address"
        },
        {
          "internalType": "address",
          "name": "_tokenAddr",
          "type": "address"
        }
      ],
      "name": "createDistribution",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "name": "distribution2Funding",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "name": "distribution2Owner",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "distribution2TargetId",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_user",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "distribution2WhiteList",
      "outputs": [
        {
          "internalType": "bool",
          "name": "",
          "type": "bool"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "distributionIndex",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "name": "distributions",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint256",
              "name": "indexer1",
              "type": "uint256"
            },
            {
              "internalType": "uint256",
              "name": "indexer2",
              "type": "uint256"
            },
            {
              "internalType": "address",
              "name": "payAddr",
              "type": "address"
            },
            {
              "internalType": "address",
              "name": "tokenAddr",
              "type": "address"
            }
          ],
          "internalType": "struct IDistribution.DistributionStruct",
          "name": "",
          "type": "tuple"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "getArgInfo2DisId",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint256",
              "name": "indexer1",
              "type": "uint256"
            },
            {
              "internalType": "uint256",
              "name": "indexer2",
              "type": "uint256"
            },
            {
              "internalType": "address",
              "name": "payAddr",
              "type": "address"
            },
            {
              "internalType": "address",
              "name": "tokenAddr",
              "type": "address"
            }
          ],
          "internalType": "struct IDistribution.DistributionStruct",
          "name": "_disStruct",
          "type": "tuple"
        },
        {
          "internalType": "address",
          "name": "_owner",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_funding",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_targetId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_joinAmount",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_id",
          "type": "uint256"
        }
      ],
      "name": "getDis2WhiteList",
      "outputs": [
        {
          "internalType": "bool",
          "name": "",
          "type": "bool"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_data",
          "type": "uint256"
        }
      ],
      "name": "getTargetIdFromDis",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "pure",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        }
      ],
      "name": "getUserAllDis",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint256",
              "name": "indexer1",
              "type": "uint256"
            },
            {
              "internalType": "uint256",
              "name": "indexer2",
              "type": "uint256"
            },
            {
              "internalType": "address",
              "name": "payAddr",
              "type": "address"
            },
            {
              "internalType": "address",
              "name": "tokenAddr",
              "type": "address"
            }
          ],
          "internalType": "struct IDistribution.DistributionStruct[]",
          "name": "",
          "type": "tuple[]"
        },
        {
          "internalType": "uint256",
          "name": "_length",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        }
      ],
      "name": "getUserDisIds",
      "outputs": [
        {
          "internalType": "uint256[]",
          "name": "",
          "type": "uint256[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "harvestDividends",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "payToken",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_user",
          "type": "address"
        }
      ],
      "name": "pendingDividends",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "_amount",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        },
        {
          "internalType": "address[]",
          "name": "_whiteList",
          "type": "address[]"
        },
        {
          "internalType": "bool[]",
          "name": "_isBool",
          "type": "bool[]"
        }
      ],
      "name": "setCheckWhitelist",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_distributionId",
          "type": "uint256"
        }
      ],
      "name": "userJoin",
      "outputs": [],
      "stateMutability": "payable",
      "type": "function"
    }
  ],
  "bytecode": "0x",
  "deployedBytecode": "0x",
  "linkReferences": {},
  "deployedLinkReferences": {}
}