Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Arbitrable #4

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"package.json": "sort-package-json"
},
"dependencies": {
"@defi-wonderland/prophet-core-contracts": "^0.0.0-e73df4c1",
"@defi-wonderland/prophet-modules-contracts": "^0.0.0-2c7deca8"
"@defi-wonderland/prophet-core-contracts": "0.0.0-438de1c5",
"@defi-wonderland/prophet-modules-contracts": "0.0.0-1197c328"
},
"devDependencies": {
"@commitlint/cli": "19.3.0",
Expand Down
2 changes: 2 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
forge-std/=node_modules/forge-std/src
halmos-cheatcodes=node_modules/halmos-cheatcodes
@defi-wonderland/prophet-core-contracts/=node_modules/@defi-wonderland/prophet-core-contracts
@defi-wonderland/prophet-modules-contracts/=node_modules/@defi-wonderland/prophet-modules-contracts

contracts/=src/contracts
interfaces/=src/interfaces
106 changes: 106 additions & 0 deletions src/contracts/Arbitrable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {IArbitrable} from 'interfaces/IArbitrable.sol';

/**
* @title Arbitrable
* @notice Makes a contract subject to arbitration by The Graph
*/
abstract contract Arbitrable is IArbitrable {
address private _arbitrator;
address private _council;
address private _pendingCouncil;

/**
* @notice Checks that the caller is The Graph's Arbitrator
*/
modifier onlyArbitrator() {
if (msg.sender != _arbitrator) revert Arbitrable_OnlyArbitrator();
_;
}

/**
* @notice Checks that the caller is The Graph's Council
*/
modifier onlyCouncil() {
if (msg.sender != _council) revert Arbitrable_OnlyCouncil();
_;
}

/**
* @notice Checks that the caller is the pending The Graph's Council
*/
modifier onlyPendingCouncil() {
if (msg.sender != _pendingCouncil) revert Arbitrable_OnlyPendingCouncil();
_;
}

/**
* @notice Constructor
* @param __arbitrator The address of The Graph's Arbitrator
* @param __council The address of The Graph's Council
*/
constructor(address __arbitrator, address __council) {
_setArbitrator(__arbitrator);
_setCouncil(__council);
}

/// @inheritdoc IArbitrable
function arbitrator() public view returns (address __arbitrator) {
__arbitrator = _arbitrator;
}

/// @inheritdoc IArbitrable
function council() public view returns (address __council) {
__council = _council;
}

/// @inheritdoc IArbitrable
function pendingCouncil() public view returns (address __pendingCouncil) {
__pendingCouncil = _pendingCouncil;
}

/// @inheritdoc IArbitrable
function setArbitrator(address __arbitrator) external onlyCouncil {

Check warning on line 65 in src/contracts/Arbitrable.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Function order is incorrect, external function can not go after public view function (line 60)
_setArbitrator(__arbitrator);
}

/// @inheritdoc IArbitrable
function setPendingCouncil(address __pendingCouncil) external onlyCouncil {
_setPendingCouncil(__pendingCouncil);
}

/// @inheritdoc IArbitrable
function confirmCouncil() external onlyPendingCouncil {
_setCouncil(_pendingCouncil);
delete _pendingCouncil;
}

/**
* @notice Sets the address of The Graph's Arbitrator
* @param __arbitrator The address of The Graph's Arbitrator
*/
function _setArbitrator(address __arbitrator) private {
_arbitrator = __arbitrator;
emit SetArbitrator(__arbitrator);
}

/**
* @notice Sets the address of The Graph's Council
* @param __council The address of The Graph's Council
*/
function _setCouncil(address __council) private {
_council = __council;
emit SetCouncil(__council);
}

/**
* @notice Sets the address of the pending The Graph's Council
* @param __pendingCouncil The address of the pending The Graph's Council
*/
function _setPendingCouncil(address __pendingCouncil) private {
_pendingCouncil = __pendingCouncil;
emit SetPendingCouncil(__pendingCouncil);
}
}
95 changes: 95 additions & 0 deletions src/interfaces/IArbitrable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/**
* @title Arbitrable
* @notice Makes a contract subject to arbitration by The Graph
*/
interface IArbitrable {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/

/**
* @notice Emitted when The Graph's Arbitrator is set
* @param _arbitrator The address of The Graph's Arbitrator
*/
event SetArbitrator(address _arbitrator);

/**
* @notice Emitted when The Graph's Council is set
* @param _council The address of The Graph's Council
*/
event SetCouncil(address _council);

/**
* @notice Emitted when the pending The Graph's Council is set
* @param _pendingCouncil The address of the pending The Graph's Council
*/
event SetPendingCouncil(address _pendingCouncil);

/*///////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

/**
* @notice Thrown when the caller is not The Graph's Arbitrator
*/
error Arbitrable_OnlyArbitrator();

/**
* @notice Thrown when the caller is not The Graph's Council
*/
error Arbitrable_OnlyCouncil();

/**
* @notice Thrown when the caller is not the pending The Graph's Council
*/
error Arbitrable_OnlyPendingCouncil();

/*///////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*/

/**
* @notice Returns the address of The Graph's Arbitrator
* @return _arbitrator The address of The Graph's Arbitrator
*/
function arbitrator() external view returns (address _arbitrator);

/**
* @notice Returns the address of The Graph's Council
* @return _council The address of The Graph's Council
*/
function council() external view returns (address _council);

/**
* @notice Returns the address of the pending The Graph's Council
* @return _pendingCouncil The address of the pending The Graph's Council
*/
function pendingCouncil() external view returns (address _pendingCouncil);

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/

/**
* @notice Changes the address of The Graph's Arbitrator
* @dev Callable only by The Graph's Council
* @param _arbitrator The address of The Graph's Arbitrator
*/
function setArbitrator(address _arbitrator) external;

Check warning on line 81 in src/interfaces/IArbitrable.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Function order is incorrect, external function can not go after external view function (line 70)

/**
* @notice Sets the address of the pending The Graph's Council
* @dev Callable only by The Graph's Council
* @param _pendingCouncil The address of the pending The Graph's Council
*/
function setPendingCouncil(address _pendingCouncil) external;

/**
* @notice Changes the address of The Graph's Council to the pending one
* @dev Callable only by the pending The Graph's Council
*/
function confirmCouncil() external;
}
Loading
Loading