Skip to content

Commit

Permalink
feat: lint and remapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ashitakah committed Sep 2, 2024
1 parent ef0def0 commit ca44d53
Show file tree
Hide file tree
Showing 65 changed files with 506 additions and 172 deletions.
3 changes: 1 addition & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ds-test/=node_modules/ds-test/src
forge-std/=node_modules/forge-std/src
solmate/=node_modules/solmate/src
forge-std/=node_modules/forge-std/src
20 changes: 15 additions & 5 deletions solidity/contracts/extensions/AccountingExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ contract AccountingExtension is Validator, IAccountingExtension {
*/
mapping(address _bonder => EnumerableSet.AddressSet _modules) internal _approvals;

constructor(IOracle _oracle) Validator(_oracle) {}
constructor(
IOracle _oracle
) Validator(_oracle) {}

/**
* @notice Checks that the caller is an allowed module used in the request.
* @param _requestId The request ID.
*/
modifier onlyAllowedModule(bytes32 _requestId) {
modifier onlyAllowedModule(
bytes32 _requestId
) {
if (!ORACLE.allowedModule(_requestId, msg.sender)) revert AccountingExtension_UnauthorizedModule();
_;
}
Expand Down Expand Up @@ -159,17 +163,23 @@ contract AccountingExtension is Validator, IAccountingExtension {
}

/// @inheritdoc IAccountingExtension
function approveModule(address _module) external {
function approveModule(
address _module
) external {
_approvals[msg.sender].add(_module);
}

/// @inheritdoc IAccountingExtension
function revokeModule(address _module) external {
function revokeModule(
address _module
) external {
_approvals[msg.sender].remove(_module);
}

/// @inheritdoc IAccountingExtension
function approvedModules(address _user) external view returns (address[] memory _approvedModules) {
function approvedModules(
address _user
) external view returns (address[] memory _approvedModules) {
_approvedModules = _approvals[_user].values();
}
}
4 changes: 3 additions & 1 deletion solidity/contracts/extensions/BondEscalationAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ contract BondEscalationAccounting is AccountingExtension, IBondEscalationAccount
/// @inheritdoc IBondEscalationAccounting
mapping(bytes32 _requestId => mapping(address _pledger => bool _claimed)) public pledgerClaimed;

constructor(IOracle _oracle) AccountingExtension(_oracle) {}
constructor(
IOracle _oracle
) AccountingExtension(_oracle) {}

/// @inheritdoc IBondEscalationAccounting
function pledge(
Expand Down
4 changes: 3 additions & 1 deletion solidity/contracts/libraries/MerkleLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ library MerkleLib {
* @return _current bytes32 root.
*
*/
function root(Tree storage tree) internal view returns (bytes32 _current) {
function root(
Tree storage tree
) internal view returns (bytes32 _current) {
uint256 _index = tree.count;

if (_index == 0) {
Expand Down
14 changes: 10 additions & 4 deletions solidity/contracts/modules/dispute/BondEscalationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.19;

import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol';
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol';
import {FixedPointMathLib} from 'solmate/utils/FixedPointMathLib.sol';
import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol';

import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEscalationModule.sol';

Expand All @@ -19,7 +19,9 @@ contract BondEscalationModule is Module, IBondEscalationModule {
*/
mapping(bytes32 _requestId => BondEscalation) internal _escalations;

constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
Expand Down Expand Up @@ -328,12 +330,16 @@ contract BondEscalationModule is Module, IBondEscalationModule {
////////////////////////////////////////////////////////////////////

/// @inheritdoc IBondEscalationModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

/// @inheritdoc IBondEscalationModule
function getEscalation(bytes32 _requestId) public view returns (BondEscalation memory _escalation) {
function getEscalation(
bytes32 _requestId
) public view returns (BondEscalation memory _escalation) {
_escalation = _escalations[_requestId];
}

Expand Down
8 changes: 6 additions & 2 deletions solidity/contracts/modules/dispute/BondedDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle
import {IBondedDisputeModule} from '../../../interfaces/modules/dispute/IBondedDisputeModule.sol';

contract BondedDisputeModule is Module, IBondedDisputeModule {
constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
return 'BondedDisputeModule';
}

/// @inheritdoc IBondedDisputeModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down
12 changes: 9 additions & 3 deletions solidity/contracts/modules/dispute/CircuitResolverModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ contract CircuitResolverModule is Module, ICircuitResolverModule {
/// @notice Keeps track of the correct responses to requests
mapping(bytes32 _requestId => bytes _correctResponse) internal _correctResponses;

constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
return 'CircuitResolverModule';
}

/// @inheritdoc ICircuitResolverModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down Expand Up @@ -106,7 +110,9 @@ contract CircuitResolverModule is Module, ICircuitResolverModule {
* @param _target The address to check
* @return _hasBytecode Whether the target has bytecode or not
*/
function _targetHasBytecode(address _target) private view returns (bool _hasBytecode) {
function _targetHasBytecode(
address _target
) private view returns (bool _hasBytecode) {
uint256 _size;
assembly {
_size := extcodesize(_target)
Expand Down
8 changes: 6 additions & 2 deletions solidity/contracts/modules/dispute/RootVerificationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ contract RootVerificationModule is Module, IRootVerificationModule {
*/
mapping(bytes32 _requestId => bytes32 _correctRoot) internal _correctRoots;

constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
return 'RootVerificationModule';
}

/// @inheritdoc IRootVerificationModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down
12 changes: 9 additions & 3 deletions solidity/contracts/modules/finality/CallbackModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ import {IProphetCallback} from '../../../interfaces/IProphetCallback.sol';
import {ICallbackModule} from '../../../interfaces/modules/finality/ICallbackModule.sol';

contract CallbackModule is Module, ICallbackModule {
constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() public pure returns (string memory _moduleName) {
_moduleName = 'CallbackModule';
}

/// @inheritdoc ICallbackModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down Expand Up @@ -46,7 +50,9 @@ contract CallbackModule is Module, ICallbackModule {
* @param _target The address to check
* @return _hasBytecode Whether the target has bytecode or not
*/
function _targetHasBytecode(address _target) private view returns (bool _hasBytecode) {
function _targetHasBytecode(
address _target
) private view returns (bool _hasBytecode) {
uint256 _size;
assembly {
_size := extcodesize(_target)
Expand Down
12 changes: 9 additions & 3 deletions solidity/contracts/modules/finality/MultipleCallbacksModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import {IProphetCallback} from '../../../interfaces/IProphetCallback.sol';
import {IMultipleCallbacksModule} from '../../../interfaces/modules/finality/IMultipleCallbacksModule.sol';

contract MultipleCallbacksModule is Module, IMultipleCallbacksModule {
constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IMultipleCallbacksModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down Expand Up @@ -67,7 +71,9 @@ contract MultipleCallbacksModule is Module, IMultipleCallbacksModule {
* @param _target The address to check
* @return _hasBytecode Whether the target has bytecode or not
*/
function _targetHasBytecode(address _target) private view returns (bool _hasBytecode) {
function _targetHasBytecode(
address _target
) private view returns (bool _hasBytecode) {
uint256 _size;
assembly {
_size := extcodesize(_target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle
import {IContractCallRequestModule} from '../../../interfaces/modules/request/IContractCallRequestModule.sol';

contract ContractCallRequestModule is Module, IContractCallRequestModule {
constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() public pure returns (string memory _moduleName) {
_moduleName = 'ContractCallRequestModule';
}

/// @inheritdoc IContractCallRequestModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down
8 changes: 6 additions & 2 deletions solidity/contracts/modules/request/HttpRequestModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle
import {IHttpRequestModule} from '../../../interfaces/modules/request/IHttpRequestModule.sol';

contract HttpRequestModule is Module, IHttpRequestModule {
constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() public pure returns (string memory _moduleName) {
_moduleName = 'HttpRequestModule';
}

/// @inheritdoc IHttpRequestModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle
import {ISparseMerkleTreeRequestModule} from '../../../interfaces/modules/request/ISparseMerkleTreeRequestModule.sol';

contract SparseMerkleTreeRequestModule is Module, ISparseMerkleTreeRequestModule {
constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() public pure returns (string memory _moduleName) {
_moduleName = 'SparseMerkleTreeRequestModule';
}

/// @inheritdoc ISparseMerkleTreeRequestModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down
12 changes: 9 additions & 3 deletions solidity/contracts/modules/resolution/ArbitratorModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ contract ArbitratorModule is Module, IArbitratorModule {
*/
mapping(bytes32 _disputeId => ArbitrationStatus _status) internal _disputeData;

constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
return 'ArbitratorModule';
}

/// @inheritdoc IArbitratorModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

/// @inheritdoc IArbitratorModule
function getStatus(bytes32 _disputeId) external view returns (ArbitrationStatus _disputeStatus) {
function getStatus(
bytes32 _disputeId
) external view returns (ArbitrationStatus _disputeStatus) {
_disputeStatus = _disputeData[_disputeId];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
pragma solidity ^0.8.19;

// solhint-disable-next-line no-unused-import

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';

Check warning on line 6 in solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

imported name IERC20 is not used
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {FixedPointMathLib} from 'solmate/utils/FixedPointMathLib.sol';
import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol';

import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol';
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol';
Expand Down Expand Up @@ -34,15 +35,19 @@ contract BondEscalationResolutionModule is Module, IBondEscalationResolutionModu
/// @inheritdoc IBondEscalationResolutionModule
mapping(bytes32 _disputeId => mapping(address _pledger => uint256 pledges)) public pledgesAgainstDispute;

constructor(IOracle _oracle) Module(_oracle) {}
constructor(
IOracle _oracle
) Module(_oracle) {}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
return 'BondEscalationResolutionModule';
}

/// @inheritdoc IBondEscalationResolutionModule
function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) {
function decodeRequestData(
bytes calldata _data
) public pure returns (RequestParameters memory _params) {
_params = abi.decode(_data, (RequestParameters));
}

Expand Down
Loading

0 comments on commit ca44d53

Please sign in to comment.