Skip to content

Commit

Permalink
feat: merge with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ashitakah committed Aug 8, 2024
2 parents 6bf9f06 + 79c9de5 commit 5f8fc37
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 14 deletions.
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-c25103ea",
"@defi-wonderland/prophet-modules-contracts": "0.0.0-ee716ee0"
"@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);
}
}
2 changes: 1 addition & 1 deletion src/contracts/EBORequestCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract EBORequestCreator is IEBORequestCreator {
if (requestIdPerChainAndEpoch[_chainIds[_i]][_epoch] == bytes32(0)) {
// TODO: COMPLETE THE REQUEST CREATION WITH THE PROPER MODULES
IOracle.Request memory _request = IOracle.Request({
nonce: 0,
nonce: uint96(0),
requester: address(this),
requestModule: _requestData.requestModule,
responseModule: _requestData.responseModule,
Expand Down
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;
}
2 changes: 2 additions & 0 deletions test/integration/IntegrationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.26;
import {Test} from 'forge-std/Test.sol';
import {IERC20} from 'forge-std/interfaces/IERC20.sol';

Check warning on line 5 in test/integration/IntegrationBase.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Variable "IERC20" is unused

import {Oracle} from '@defi-wonderland/prophet-core-contracts/solidity/contracts/Oracle.sol';
import {EBORequestCreator, IEBORequestCreator, IOracle} from 'contracts/EBORequestCreator.sol';

contract IntegrationBase is Test {
Expand All @@ -20,6 +21,7 @@ contract IntegrationBase is Test {
vm.createSelectFork(vm.rpcUrl('mainnet'), _FORK_BLOCK);
vm.startPrank(_owner);

_oracle = new Oracle();
_eboRequestCreator = new EBORequestCreator(_oracle, _arbitrator);

vm.stopPrank();
Expand Down
Loading

0 comments on commit 5f8fc37

Please sign in to comment.