1Hive / radspec-registry

A public mapping between deployed contracts, function signatures, and radspec docstrings
0 stars 0 forks source link

Specification: Registry Interface #3

Open onbjerg opened 4 years ago

onbjerg commented 4 years ago

The registry is the manifestation of the curation game specification in #2, and it stores data as specified in #1.

This is the proposed interface for the contract.

pragma solidity ^0.5.8;

import "@aragon/court/contracts/arbitration/IArbitrable.sol";
import "@aragon/os/contracts/apps/AragonApp.sol";
import "@aragon/court/contracts/arbitration/IArbitrator.sol";

contract RadspecRegistry is IArbitrable, AragonApp {
    bytes32 public constant SET_BENEFICIARY_ROLE = keccak256("SET_BENEFICIARY_ROLE");
    bytes32 public constant SET_FEE_PERCENTAGE_ROLE = keccak256("SET_FEE_PERCENTAGE_ROLE");
    bytes32 public constant SET_ARBITRATOR_ROLE = keccak256("SET_ARBITRATOR_ROLE");
    bytes32 public constant STAKED_UPSERT_ENTRY_ROLE = keccak256("STAKED_UPSERT_ENTRY_ROLE");
    bytes32 public constant UPSERT_ENTRY_ROLE = keccak256("UPSERT_ENTRY_ROLE");
    bytes32 public constant REMOVE_ENTRY_ROLE = keccak256("REMOVE_ENTRY_ROLE");

    string public constant ERROR_FEE_PCT_TOO_BIG = "ERROR_FEE_PCT_TOO_BIG";
    string public constant ERROR_STAKE_TOO_LOW = "ERROR_STAKE_TOO_LOW";
    string public constant ERROR_DISPUTE_EXISTS = "ERROR_DISPUTE_EXISTS";
    string public constant ERROR_ENTRY_DOESNT_EXIST = "ERROR_ENTRY_DOESNT_EXIST";

    uint64 public constant PCT_BASE = 10 ** 18; // 0% = 0; 1% = 10^16; 100% = 10^18

    /**
     * @dev Emitted when an entry is inserted or updated.
     * @param scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param sig
     *        The signature of the method the entry is describing.
     * @param submitter
     *        The address that upserted the entry.
     * @param stake
     *        The stake that was used to upsert the entry.
     * @param cid
     *        The IPFS CID of the file containing the Radspec description.
     */
    event EntryUpserted(
        address indexed scope,
        bytes4 indexed sig,
        address submitter,
        uint256 stake,
        string cid
    );

    /**
     * @dev Emitted when an entry is removed.
     * @param scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param sig
     *        The signature of the method the entry is describing.
     */
    event EntryRemoved(
        address indexed scope,
        bytes4 indexed sig
    );

    /**
     * @dev Emitted when a dispute for an entry is created.
     * @param scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param sig
     *        The signature of the method the entry is describing.
     * @param disputeId
     *        The Aragon Court dispute ID for the dispute.
     */
    event EntryDisputed(address indexed scope, bytes4 indexed sig, uint256 disputeId);

    /**
     * @dev Initializes the registry.
     * @param _arbitrator The arbitrator of the registry.
     * @param _feesPct The percentage of stakes sent to `_beneficiary`
     * @param _beneficiary The beneficiary of registry fees
     */
    function initialize(IArbitrator _arbitrator, uint64 _feesPct, address _beneficiary) external;

    /**
     * @dev Set the arbitrator of the registry.
     * @param _arbitrator The arbitrator of the registry.
     */
    function setArbitrator(IArbitrator _arbitrator) external;

    /**
     * @dev Set fee perecentage of the registry.
     * @param _feesPct The percentage of stakes sent to `_beneficiary`
     */
    function setFeesPct(uint64 _feesPct) external;

    /**
     * @dev Set beneficiary of registry fees.
     * @param _beneficiary The beneficiary of registry fees
     */
    function setBeneficiary(address _beneficiary) external;

    /**
     * @dev Upsert a registry entry with a stake.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     * @param _cid
     *        The IPFS CID of the file containing the Radspec description.
     */
    function stakeAndUpsertEntry(address _scope, bytes4 _sig, string _cid) external payable;

    /**
     * @dev Upsert a registry entry without a stake.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     * @param _cid
     *        The IPFS CID of the file containing the Radspec description.
     */
    function upsertEntry(address _scope, bytes4 _sig, string _cid) external;

    /**
     * @dev Get an entry from the registry.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     * @return The CID of the entry, the submitter of the entry and the stake for the entry.
     */
    function getEntry(address _scope, bytes4 _sig) external view returns (string, address, uint256);

    /**
     * @dev Check whether an entry exists in the registry.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     * @return True if the entry exists, false otherwise.
     */
    function hasEntry(address _scope, bytes4 _sig) external view returns (bool);

    /**
     * @dev Remove an entry from the registry.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     */
    function removeEntry(address _scope, bytes4 _sig) external;

    /**
     * @dev Dispute an entry in the registry.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     * @return The dispute ID.
     */
    function createDispute(address _scope, bytes4 _sig) external returns (uint256);

    /**
     * @dev Creates a dispute for an entry in the registry and submits some evidence.
     * @param _scope
     *        The scope of the entry.
     *        If the scope is the zero address, then the entry is global.
     * @param _sig
     *        The signature of the method the entry is describing.
     * @param _evidence Data submitted for the evidence of the dispute
     * @return The dispute ID.
     */
    function createDisputeAndSubmitEvidence(
        address _scope,
        bytes4 _sig,
        bytes calldata _evidence
    ) external returns (uint256);

    /**
    * @dev Emitted when an IArbitrable instance's dispute is ruled by an IArbitrator
    * @param arbitrator IArbitrator instance ruling the dispute
    * @param disputeId Identification number of the dispute being ruled by the arbitrator
    * @param ruling Ruling given by the arbitrator
    */
    event Ruled(IArbitrator indexed arbitrator, uint256 indexed disputeId, uint256 ruling);

    /**
    * @dev Emitted when new evidence is submitted for the IArbitrable instance's dispute
    * @param disputeId Identification number of the dispute receiving new evidence
    * @param submitter Address of the account submitting the evidence
    * @param evidence Data submitted for the evidence of the dispute
    * @param finished Whether or not the submitter has finished submitting evidence
    */
    event EvidenceSubmitted(uint256 indexed disputeId, address indexed submitter, bytes evidence, bool finished);

    /**
    * @dev Submit evidence for a dispute
    * @param _disputeId Id of the dispute in the Court
    * @param _evidence Data submitted for the evidence related to the dispute
    * @param _finished Whether or not the submitter has finished submitting evidence
    */
    function submitEvidence(uint256 _disputeId, bytes calldata _evidence, bool _finished) external;

    /**
    * @dev Give a ruling for a certain dispute, the account calling it must have rights to rule on the contract
    * @param _disputeId Identification number of the dispute to be ruled
    * @param _ruling Ruling given by the arbitrator, where 0 is reserved for "refused to make a decision"
    */
    function rule(uint256 _disputeId, uint256 _ruling) external;
}
lkngtn commented 4 years ago
string public constant ERROR_ENTRY_DOESNT_EXIST = "ERROR_ENTRY_DOESNT_EXIST"; 

Seems to be duplicated.

onbjerg commented 4 years ago

Fixed

onbjerg commented 4 years ago

Added a new event, EntryRemoved.

Also, a question: Should we emit an event when the fee percentage changes, and/or when the arbitrator or beneficiary changes? For historical changes it might make sense, but it is not strictly required for the front-end.