Skip to content

Commit

Permalink
refactor: lint main contracts (#212)
Browse files Browse the repository at this point in the history
Co-authored-by: Gas One Cent <[email protected]>
  • Loading branch information
turtlemoji and gas1cent authored Sep 28, 2023
1 parent d21f137 commit a732264
Show file tree
Hide file tree
Showing 34 changed files with 239 additions and 163 deletions.
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"const-name-snakecase": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"func-named-parameters": ["error", 4],
"private-vars-leading-underscore": ["warn", { "strict": false }],
"defi-wonderland/non-state-vars-leading-underscore": ["warn"],
"defi-wonderland/contract-data-order": ["warn"],
Expand Down
3 changes: 2 additions & 1 deletion .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ cache
out

// NOTE Unrequired linting check
solidity/test/invariant/imports/WETH9.sol
solidity/test/invariant/imports/WETH9.sol
solidity/contracts/libraries/MerkleLib.sol
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"lint-staged": {
"*.{js,css,md,ts,sol}": "forge fmt",
"*.sol": "solhint --fix 'solidity/**/*.sol'",
"*.sol": "solhint --fix 'solidity/contracts/**/*.sol' 'solidity/interfaces/**/*.sol' && solhint --fix -c .solhint.tests.json 'solidity/test/**/*.sol'",
"package.json": "sort-package-json"
},
"dependencies": {
Expand Down
17 changes: 9 additions & 8 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ contract Oracle is IOracle {
if (_responses[_responseId].proposer != _proposer) {
revert Oracle_CannotTamperParticipant();
}
emit Oracle_ResponseProposed(_requestId, _proposer, _responseId);

emit ResponseProposed(_requestId, _proposer, _responseId);
}

/// @inheritdoc IOracle
Expand All @@ -218,7 +219,7 @@ contract Oracle is IOracle {
delete _responses[_responseId];
_responseIds[_response.requestId].remove(_responseId);

emit Oracle_ResponseDeleted(_response.requestId, msg.sender, _responseId);
emit ResponseDeleted(_response.requestId, msg.sender, _responseId);
}

/// @inheritdoc IOracle
Expand Down Expand Up @@ -253,7 +254,7 @@ contract Oracle is IOracle {
_request.disputeModule.onDisputeStatusChange(_disputeId, _dispute);
}

emit Oracle_ResponseDisputed(msg.sender, _responseId, _disputeId);
emit ResponseDisputed(msg.sender, _responseId, _disputeId);
}

/// @inheritdoc IOracle
Expand All @@ -278,7 +279,7 @@ contract Oracle is IOracle {
_request.resolutionModule.startResolution(_disputeId);
}

emit Oracle_DisputeEscalated(msg.sender, _disputeId);
emit DisputeEscalated(msg.sender, _disputeId);
}

/// @inheritdoc IOracle
Expand All @@ -298,7 +299,7 @@ contract Oracle is IOracle {

_request.resolutionModule.resolveDispute(_disputeId);

emit Oracle_DisputeResolved(msg.sender, _disputeId);
emit DisputeResolved(msg.sender, _disputeId);
}

/// @inheritdoc IOracle
Expand All @@ -311,7 +312,7 @@ contract Oracle is IOracle {
_dispute.status = _status;
_request.disputeModule.onDisputeStatusChange(_disputeId, _dispute);

emit Oracle_DisputeStatusUpdated(_disputeId, _status);
emit DisputeStatusUpdated(_disputeId, _status);
}

/// @inheritdoc IOracle
Expand Down Expand Up @@ -405,7 +406,7 @@ contract Oracle is IOracle {
_request.responseModule.finalizeRequest(_requestId, msg.sender);
_request.requestModule.finalizeRequest(_requestId, msg.sender);

emit Oracle_RequestFinalized(_requestId, msg.sender);
emit OracleRequestFinalized(_requestId, msg.sender);
}

/**
Expand Down Expand Up @@ -446,7 +447,7 @@ contract Oracle is IOracle {
_request.finalityModule.setupRequest(_requestId, _request.finalityModuleData);
}

emit Oracle_RequestCreated(_requestId, msg.sender);
emit RequestCreated(_requestId, msg.sender);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/extensions/AccountingExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract AccountingExtension is IAccountingExtension {
}

/**
* @notice Checks that the caller is a allowed module used in the request.
* @notice Checks that the caller is an allowed module used in the request.
*/
modifier onlyAllowedModule(bytes32 _requestId) {
if (!ORACLE.allowedModule(_requestId, msg.sender)) revert AccountingExtension_UnauthorizedModule();
Expand Down Expand Up @@ -84,7 +84,7 @@ contract AccountingExtension is IAccountingExtension {
bondedAmountOf[_payer][_token][_requestId] -= _amount;
}

emit Paid(_requestId, _receiver, _payer, _token, _amount);
emit Paid({_requestId: _requestId, _beneficiary: _receiver, _payer: _payer, _token: _token, _amount: _amount});
}

/// @inheritdoc IAccountingExtension
Expand Down
28 changes: 23 additions & 5 deletions solidity/contracts/extensions/BondEscalationAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.19;

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

import {AccountingExtension} from './AccountingExtension.sol';

Expand Down Expand Up @@ -39,7 +38,7 @@ contract BondEscalationAccounting is AccountingExtension, IBondEscalationAccount
balanceOf[_pledger][_token] -= _amount;
}

emit Pledged(_pledger, _requestId, _disputeId, _token, _amount);
emit Pledged({_pledger: _pledger, _requestId: _requestId, _disputeId: _disputeId, _token: _token, _amount: _amount});
}

/// @inheritdoc IBondEscalationAccounting
Expand Down Expand Up @@ -68,7 +67,14 @@ contract BondEscalationAccounting is AccountingExtension, IBondEscalationAccount
bondEscalationModule: IBondEscalationModule(msg.sender)
});

emit BondEscalationSettled(_requestId, _disputeId, _forVotesWon, _token, _amountPerPledger, _winningPledgersLength);
emit BondEscalationSettled({
_requestId: _requestId,
_disputeId: _disputeId,
_forVotesWon: _forVotesWon,
_token: _token,
_amountPerPledger: _amountPerPledger,
_winningPledgersLength: _winningPledgersLength
});
}

/// @inheritdoc IBondEscalationAccounting
Expand All @@ -93,7 +99,13 @@ contract BondEscalationAccounting is AccountingExtension, IBondEscalationAccount
pledges[_disputeId][_token] -= _claimAmount;
}

emit EscalationRewardClaimed(_requestId, _disputeId, _pledger, _result.token, _claimAmount);
emit EscalationRewardClaimed({
_requestId: _requestId,
_disputeId: _disputeId,
_pledger: _pledger,
_token: _result.token,
_amount: _claimAmount
});
}

/// @inheritdoc IBondEscalationAccounting
Expand All @@ -112,6 +124,12 @@ contract BondEscalationAccounting is AccountingExtension, IBondEscalationAccount
pledges[_disputeId][_token] -= _amount;
}

emit PledgeReleased(_requestId, _disputeId, _pledger, _token, _amount);
emit PledgeReleased({
_requestId: _requestId,
_disputeId: _disputeId,
_pledger: _pledger,
_token: _token,
_amount: _amount
});
}
}
12 changes: 9 additions & 3 deletions solidity/contracts/modules/dispute/BondEscalationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity ^0.8.19;
import {FixedPointMathLib} from 'solmate/utils/FixedPointMathLib.sol';
import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEscalationModule.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';

// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract BondEscalationModule is Module, IBondEscalationModule {
Expand Down Expand Up @@ -153,9 +155,13 @@ contract BondEscalationModule is Module, IBondEscalationModule {
_winningPledgersLength: _won ? _escalation.amountOfPledgesForDispute : _escalation.amountOfPledgesAgainstDispute
});
}
emit DisputeStatusChanged(
_dispute.requestId, _dispute.responseId, _dispute.disputer, _dispute.proposer, _dispute.status
);
emit DisputeStatusChanged({
_requestId: _dispute.requestId,
_responseId: _dispute.responseId,
_disputer: _dispute.disputer,
_proposer: _dispute.proposer,
_status: _dispute.status
});
}

////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 9 additions & 3 deletions solidity/contracts/modules/dispute/BondedDisputeModule.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IBondedDisputeModule} from '../../../interfaces/modules/dispute/IBondedDisputeModule.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';
import {IAccountingExtension} from '../../../interfaces/extensions/IAccountingExtension.sol';

// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract BondedDisputeModule is Module, IBondedDisputeModule {
Expand Down Expand Up @@ -104,6 +104,12 @@ contract BondedDisputeModule is Module, IBondedDisputeModule {
});
}

emit DisputeStatusChanged(_dispute.requestId, _dispute.responseId, _disputer, _proposer, _status);
emit DisputeStatusChanged({
_requestId: _dispute.requestId,
_responseId: _dispute.responseId,
_disputer: _disputer,
_proposer: _proposer,
_status: _status
});
}
}
14 changes: 8 additions & 6 deletions solidity/contracts/modules/dispute/CircuitResolverModule.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

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

import {ICircuitResolverModule} from '../../../interfaces/modules/dispute/ICircuitResolverModule.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';
import {IAccountingExtension} from '../../../interfaces/extensions/IAccountingExtension.sol';

// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract CircuitResolverModule is Module, ICircuitResolverModule {
Expand Down Expand Up @@ -54,9 +52,13 @@ contract CircuitResolverModule is Module, ICircuitResolverModule {

delete _correctResponses[_dispute.requestId];

emit DisputeStatusChanged(
_dispute.requestId, _dispute.responseId, _dispute.disputer, _dispute.proposer, _dispute.status
);
emit DisputeStatusChanged({
_requestId: _dispute.requestId,
_responseId: _dispute.responseId,
_disputer: _dispute.disputer,
_proposer: _dispute.proposer,
_status: _dispute.status
});
}

/// @inheritdoc ICircuitResolverModule
Expand Down
15 changes: 8 additions & 7 deletions solidity/contracts/modules/dispute/RootVerificationModule.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

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

import {MerkleLib} from '../../libraries/MerkleLib.sol';

import {IRootVerificationModule} from '../../../interfaces/modules/dispute/IRootVerificationModule.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';
import {ITreeVerifier} from '../../../interfaces/ITreeVerifier.sol';
import {IAccountingExtension} from '../../../interfaces/extensions/IAccountingExtension.sol';

// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract RootVerificationModule is Module, IRootVerificationModule {
Expand Down Expand Up @@ -60,9 +57,13 @@ contract RootVerificationModule is Module, IRootVerificationModule {

delete _correctRoots[_dispute.requestId];

emit DisputeStatusChanged(
_dispute.requestId, _dispute.responseId, _dispute.disputer, _dispute.proposer, _dispute.status
);
emit DisputeStatusChanged({
_requestId: _dispute.requestId,
_responseId: _dispute.responseId,
_disputer: _dispute.disputer,
_proposer: _dispute.proposer,
_status: _dispute.status
});
}

/// @inheritdoc IRootVerificationModule
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/modules/finality/CallbackModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.19;

import {IOracle} from '../../../interfaces/IOracle.sol';
import {ICallbackModule} from '../../../interfaces/modules/finality/ICallbackModule.sol';
// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract CallbackModule is Module, ICallbackModule {
Expand Down Expand Up @@ -33,7 +34,6 @@ contract CallbackModule is Module, ICallbackModule {
address _finalizer
) external override(Module, ICallbackModule) onlyOracle {
RequestParameters memory _params = decodeRequestData(_requestId);
// solhint-disable-next-line
_params.target.call(_params.data);
emit Callback(_requestId, _params.target, _params.data);
emit RequestFinalized(_requestId, _finalizer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.19;

import {IOracle} from '../../../interfaces/IOracle.sol';
import {IMultipleCallbacksModule} from '../../../interfaces/modules/finality/IMultipleCallbacksModule.sol';
// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract MultipleCallbacksModule is Module, IMultipleCallbacksModule {
Expand Down Expand Up @@ -44,7 +45,6 @@ contract MultipleCallbacksModule is Module, IMultipleCallbacksModule {
uint256 _length = _params.targets.length;

for (uint256 _i; _i < _length;) {
// solhint-disable-next-line
_params.targets[_i].call(_params.data[_i]);
emit Callback(_requestId, _params.targets[_i], _params.data[_i]);
unchecked {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

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

import {IContractCallRequestModule} from '../../../interfaces/modules/request/IContractCallRequestModule.sol';
import {IAccountingExtension} from '../../../interfaces/extensions/IAccountingExtension.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';

// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract ContractCallRequestModule is Module, IContractCallRequestModule {
Expand Down
3 changes: 1 addition & 2 deletions solidity/contracts/modules/request/HttpRequestModule.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IHttpRequestModule} from '../../../interfaces/modules/request/IHttpRequestModule.sol';
import {IAccountingExtension} from '../../../interfaces/extensions/IAccountingExtension.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';
// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract HttpRequestModule is Module, IHttpRequestModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

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

import {ISparseMerkleTreeRequestModule} from '../../../interfaces/modules/request/ISparseMerkleTreeRequestModule.sol';
import {IAccountingExtension} from '../../../interfaces/extensions/IAccountingExtension.sol';
import {IOracle} from '../../../interfaces/IOracle.sol';
// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract SparseMerkleTreeRequestModule is Module, ISparseMerkleTreeRequestModule {
Expand Down
1 change: 1 addition & 0 deletions solidity/contracts/modules/resolution/ArbitratorModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {IArbitratorModule} from '../../../interfaces/modules/resolution/IArbitra
import {IOracle} from '../../../interfaces/IOracle.sol';
import {IArbitrator, IOracle} from '../../../interfaces/IArbitrator.sol';

// solhint-disable-next-line no-unused-import
import {Module, IModule} from '../../Module.sol';

contract ArbitratorModule is Module, IArbitratorModule {
Expand Down
Loading

0 comments on commit a732264

Please sign in to comment.