Skip to content

Commit

Permalink
refactor: lint and remappings (#60)
Browse files Browse the repository at this point in the history
* feat: lint and remapping

* fix: lint
  • Loading branch information
ashitakah authored Sep 2, 2024
1 parent ef0def0 commit 6986fee
Show file tree
Hide file tree
Showing 22 changed files with 196 additions and 132 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bracket_spacing = false
int_types = 'long'
quote_style = 'single'
number_underscore = 'thousands'
multiline_func_header = 'params_first'
multiline_func_header = 'params_first_multi'
sort_imports = true

[profile.default]
Expand Down
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
11 changes: 7 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 Down Expand Up @@ -338,9 +338,12 @@ contract BondEscalationModule is Module, IBondEscalationModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0)
&& _params.bondSize != 0 && _params.bondEscalationDeadline != 0 && _params.maxNumberOfEscalations != 0
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/dispute/BondedDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ contract BondedDisputeModule is Module, IBondedDisputeModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0)
&& _params.bondSize != 0;
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/dispute/CircuitResolverModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ contract CircuitResolverModule is Module, ICircuitResolverModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external view override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
view
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0)
&& _params.bondSize != 0 && _targetHasBytecode(_params.verifier) && _params.callData.length != 0;
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/dispute/RootVerificationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ contract RootVerificationModule is Module, IRootVerificationModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0)
&& address(_params.treeVerifier) != address(0) && _params.bondSize != 0 && _params.treeData.length != 0
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/finality/CallbackModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ contract CallbackModule is Module, ICallbackModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external view override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
view
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = _params.data.length != 0 && _targetHasBytecode(_params.target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ contract MultipleCallbacksModule is Module, IMultipleCallbacksModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external view override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
view
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ contract ContractCallRequestModule is Module, IContractCallRequestModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.paymentToken) != address(0)
&& _params.target != address(0) && _params.paymentAmount != 0 && _params.functionSelector != bytes4(0);
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/request/HttpRequestModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ contract HttpRequestModule is Module, IHttpRequestModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.paymentToken) != address(0)
&& _params.paymentAmount != 0 && bytes(_params.url).length != 0 && bytes(_params.body).length != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ contract SparseMerkleTreeRequestModule is Module, ISparseMerkleTreeRequestModule
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.paymentToken) != address(0)
&& address(_params.treeVerifier) != address(0) && _params.paymentAmount != 0 && _params.treeData.length != 0
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/resolution/ArbitratorModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ contract ArbitratorModule is Module, IArbitratorModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = _params.arbitrator != address(0);
}
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 @@ -339,9 +340,12 @@ contract BondEscalationResolutionModule is Module, IBondEscalationResolutionModu
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0)
&& _params.percentageDiff != 0 && _params.pledgeThreshold != 0 && _params.timeUntilDeadline != 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ contract ERC20ResolutionModule is Module, IERC20ResolutionModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.votingToken) != address(0)
&& _params.minVotesForQuorum != 0 && _params.timeUntilDeadline != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ contract PrivateERC20ResolutionModule is Module, IPrivateERC20ResolutionModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.votingToken) != address(0)
&& _params.minVotesForQuorum != 0 && _params.committingTimeWindow != 0 && _params.revealingTimeWindow != 0;
Expand Down
9 changes: 6 additions & 3 deletions solidity/contracts/modules/response/BondedResponseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ contract BondedResponseModule is Module, IBondedResponseModule {
}

/// @inheritdoc IModule
function validateParameters(
bytes calldata _encodedParameters
) external pure override(Module, IModule) returns (bool _valid) {
function validateParameters(bytes calldata _encodedParameters)
external
pure
override(Module, IModule)
returns (bool _valid)
{
RequestParameters memory _params = decodeRequestData(_encodedParameters);
_valid = address(_params.accountingExtension) != address(0) && address(_params.bondToken) != address(0)
&& _params.bondSize != 0 && _params.disputeWindow != 0 && _params.deadline != 0;
Expand Down
4 changes: 1 addition & 3 deletions solidity/interfaces/extensions/IBondEscalationAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ interface IBondEscalationAccounting is IAccountingExtension {
* @return _amountPerPledger Amount of `_token` to be rewarded to each of the winning pledgers
* @return _bondEscalationModule The address of the bond escalation module that was used
*/
function escalationResults(
bytes32 _disputeId
)
function escalationResults(bytes32 _disputeId)
external
returns (bytes32 _requestId, IERC20 _token, uint256 _amountPerPledger, IBondEscalationModule _bondEscalationModule);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ interface IBondEscalationResolutionModule is IResolutionModule {
* @return _pledgesFor The amount of pledges in favor of the dispute.
* @return _pledgesAgainst The amount of pledges against the dispute.
*/
function escalations(
bytes32 _disputeId
) external view returns (Resolution _resolution, uint128 _startTime, uint256 _pledgesFor, uint256 _pledgesAgainst);
function escalations(bytes32 _disputeId)
external
view
returns (Resolution _resolution, uint128 _startTime, uint256 _pledgesFor, uint256 _pledgesAgainst);

/**
* @notice Returns the inequality status and its last update time of a given dispute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ contract BaseTest is Test, Helpers {
bytes32 indexed _requestId, bytes32 indexed _disputeId, address indexed _pledger, IERC20 _token, uint256 _amount
);

function _createWinningPledgersArray(
uint256 _numWinningPledgers
) internal returns (address[] memory _winningPledgers) {
function _createWinningPledgersArray(uint256 _numWinningPledgers)
internal
returns (address[] memory _winningPledgers)
{
_winningPledgers = new address[](_numWinningPledgers);
address _winningPledger;

Expand Down
Loading

0 comments on commit 6986fee

Please sign in to comment.