Skip to content

Commit

Permalink
re-add prettier-plugin-solidity and update prettier to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSilva committed Apr 1, 2024
1 parent ef566e2 commit fc2a302
Show file tree
Hide file tree
Showing 56 changed files with 529 additions and 677 deletions.
3 changes: 2 additions & 1 deletion packages/contracts/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ artifacts
cache
typechain-types
deployments
src/types
src/types
lib
2 changes: 1 addition & 1 deletion packages/contracts/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": [],
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.js",
Expand Down
8 changes: 3 additions & 5 deletions packages/contracts/contracts/RisingTide/RisingTide.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ abstract contract RisingTide {
* @param _amount amount to apply cap to
* @return capped amount
*/
function risingTide_applyCap(uint256 _amount)
public
view
returns (uint256)
{
function risingTide_applyCap(
uint256 _amount
) public view returns (uint256) {
if (!risingTide_isValidCap()) {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ contract TestRisingTideWithCustomAmounts is RisingTide {
return totalInvestors;
}

function investorAmountAt(uint256 i)
public
view
override(RisingTide)
returns (uint256)
{
function investorAmountAt(
uint256 i
) public view override(RisingTide) returns (uint256) {
return investors[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ contract TestRisingTideWithStaticAmounts is RisingTide {
return totalInvestors;
}

function investorAmountAt(uint256 i)
public
view
override(RisingTide)
returns (uint256)
{
function investorAmountAt(
uint256 i
) public view override(RisingTide) returns (uint256) {
return allZeros[i] + amountPerInvestor;
}

Expand Down
36 changes: 16 additions & 20 deletions packages/contracts/contracts/discovery/Batch.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ contract Batch is IBatch, ICommon, ProjectVoting {
_;
}

constructor(address[] memory _projects, uint256 _slotCount)
ProjectVoting(_projects)
{
constructor(
address[] memory _projects,
uint256 _slotCount
) ProjectVoting(_projects) {
uint256 numProjects = _projects.length;
require(numProjects > 0, "projects must not be empty");
require(_slotCount > 0, "slotCount must be greater than 0");
Expand Down Expand Up @@ -108,7 +109,7 @@ contract Batch is IBatch, ICommon, ProjectVoting {
override(ProjectVoting)
returns (int256)
{
return 0.05 * 10**18;
return 0.05 * 10 ** 18;
}

function projectVoting_finalBonus()
Expand All @@ -135,11 +136,10 @@ contract Batch is IBatch, ICommon, ProjectVoting {
return slotCount;
}

function hasVotedForProject(address _user, address _project)
external
view
returns (bool)
{
function hasVotedForProject(
address _user,
address _project
) external view returns (bool) {
return userHasVotedForProject[_project][_user];
}

Expand All @@ -161,11 +161,10 @@ contract Batch is IBatch, ICommon, ProjectVoting {
investmentEnd = votingPeriod.end + extraInvestmentDuration;
}

function vote(address projectAddress, bytes32[] calldata _merkleProof)
external
votingPeriodIsSet
inVotingPeriod
{
function vote(
address projectAddress,
bytes32[] calldata _merkleProof
) external votingPeriodIsSet inVotingPeriod {
require(
IController(controller).canVote(msg.sender, _merkleProof),
"not allowed to vote"
Expand All @@ -183,12 +182,9 @@ contract Batch is IBatch, ICommon, ProjectVoting {
return _getWinners();
}

function getProjectStatus(address projectAddress)
external
view
votingPeriodIsSet
returns (ProjectStatus)
{
function getProjectStatus(
address projectAddress
) external view votingPeriodIsSet returns (ProjectStatus) {
address[] memory computedWinners = _getWinners();

for (uint256 i = 0; i < computedWinners.length; i++) {
Expand Down
85 changes: 32 additions & 53 deletions packages/contracts/contracts/discovery/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ contract Controller is IController, ERC165, AccessControl {
// Merkle root to pass to the projects
bytes32 public merkleRoot;

constructor(
address _staking,
address _token,
bytes32 _merkleRoot
) {
constructor(address _staking, address _token, bytes32 _merkleRoot) {
staking = _staking;
token = _token;
merkleRoot = _merkleRoot;
Expand Down Expand Up @@ -95,11 +91,10 @@ contract Controller is IController, ERC165, AccessControl {
}

/// @inheritdoc IController
function createBatch(address[] calldata _projects, uint256 _slotCount)
external
override(IController)
onlyRole(BATCH_MANAGER_ROLE)
{
function createBatch(
address[] calldata _projects,
uint256 _slotCount
) external override(IController) onlyRole(BATCH_MANAGER_ROLE) {
IBatch batch = new Batch(_projects, _slotCount);

uint256 len = _projects.length;
Expand All @@ -119,12 +114,10 @@ contract Controller is IController, ERC165, AccessControl {
}

/// @inheritdoc IController
function isProjectInBatch(address _project, address _batch)
external
view
override(IController)
returns (bool)
{
function isProjectInBatch(
address _project,
address _batch
) external view override(IController) returns (bool) {
return projectsToBatches[_project] == _batch;
}

Expand Down Expand Up @@ -153,12 +146,10 @@ contract Controller is IController, ERC165, AccessControl {
batch.userHasVotedForProject(_project, _user);
}

function canVote(address _user, bytes32[] calldata _merkleProof)
external
view
override(IController)
returns (bool)
{
function canVote(
address _user,
bytes32[] calldata _merkleProof
) external view override(IController) returns (bool) {
return _hasKYC(_user, _merkleProof) && _belongsToDAO(_user);
}

Expand All @@ -172,11 +163,10 @@ contract Controller is IController, ERC165, AccessControl {
Batch(batch).setVotingPeriod(start, end, extraInvestmentDuration);
}

function _hasKYC(address _user, bytes32[] calldata _merkleProof)
internal
view
returns (bool)
{
function _hasKYC(
address _user,
bytes32[] calldata _merkleProof
) internal view returns (bool) {
bytes32 leaf = keccak256(abi.encodePacked(_user));
bool isValid = MerkleProof.verify(_merkleProof, merkleRoot, leaf);

Expand All @@ -194,29 +184,23 @@ contract Controller is IController, ERC165, AccessControl {
//

// Checks if a given account has the PROJECT_MANAGER_ROLE role
function hasProjectManagerRole(address _account)
external
view
returns (bool)
{
function hasProjectManagerRole(
address _account
) external view returns (bool) {
return hasRole(PROJECT_MANAGER_ROLE, _account);
}

// Checks if a given account has the BATCH_MANAGER_ROLE role
function hasBatchManagerRole(address _account)
external
view
returns (bool)
{
function hasBatchManagerRole(
address _account
) external view returns (bool) {
return hasRole(BATCH_MANAGER_ROLE, _account);
}

// Checks if a given account has the LEGAL_MANAGER_ROLE role
function hasLegalManagerRole(address _account)
external
view
returns (bool)
{
function hasLegalManagerRole(
address _account
) external view returns (bool) {
return hasRole(BATCH_MANAGER_ROLE, _account);
}

Expand All @@ -225,11 +209,9 @@ contract Controller is IController, ERC165, AccessControl {
//

/// @inheritdoc IController
function getBatchForProject(address _project)
external
view
returns (address)
{
function getBatchForProject(
address _project
) external view returns (address) {
return projectsToBatches[_project];
}

Expand All @@ -238,12 +220,9 @@ contract Controller is IController, ERC165, AccessControl {
//

/// @inheritdoc ERC165
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC165, AccessControl)
returns (bool)
{
function supportsInterface(
bytes4 interfaceId
) public view override(ERC165, AccessControl) returns (bool) {
return
interfaceId == type(IController).interfaceId ||
super.supportsInterface(interfaceId);
Expand Down
29 changes: 10 additions & 19 deletions packages/contracts/contracts/discovery/Project.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Project is IProject, ERC165 {
// Constants
//

uint256 public constant MUL = 10**18;
uint256 public constant MUL = 10 ** 18;

//
// State
Expand Down Expand Up @@ -156,22 +156,16 @@ contract Project is IProject, ERC165 {
}

/// @inheritdoc IProject
function investmentTokenToToken(uint256 _amount)
public
view
override(IProject)
returns (uint256)
{
function investmentTokenToToken(
uint256 _amount
) public view override(IProject) returns (uint256) {
return (_amount * MUL) / rate;
}

/// @inheritdoc IProject
function tokenToInvestmentToken(uint256 _amount)
public
view
override(IProject)
returns (uint256)
{
function tokenToInvestmentToken(
uint256 _amount
) public view override(IProject) returns (uint256) {
return (_amount * rate) / MUL;
}

Expand All @@ -180,12 +174,9 @@ contract Project is IProject, ERC165 {
//

/// @inheritdoc ERC165
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC165)
returns (bool)
{
function supportsInterface(
bytes4 interfaceId
) public view override(ERC165) returns (bool) {
return
interfaceId == type(IProject).interfaceId ||
super.supportsInterface(interfaceId);
Expand Down
16 changes: 6 additions & 10 deletions packages/contracts/contracts/discovery/ProjectVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,9 @@ abstract contract ProjectVoting is ICommon {
projectVoting_singleSlotDuration();
}

function _sortVotes(SortableVote[] memory _votes)
internal
view
returns (SortableVote[] memory)
{
function _sortVotes(
SortableVote[] memory _votes
) internal view returns (SortableVote[] memory) {
_quickSort(_votes, int256(0), int256(_votes.length - 1));
return _votes;
}
Expand Down Expand Up @@ -284,11 +282,9 @@ abstract contract ProjectVoting is ICommon {
if (i < right) _quickSort(_votes, i, right);
}

function _calculateWeightedVote(uint256 currentTime)
internal
view
returns (uint256)
{
function _calculateWeightedVote(
uint256 currentTime
) internal view returns (uint256) {
int256 bonusDelta = int256(
projectVoting_finalBonus() - projectVoting_initialBonus()
);
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/contracts/discovery/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,9 @@ contract Staking is IStaking {
token = _token;
}

function hasStaked(address _account)
external
view
override(IStaking)
returns (bool)
{
function hasStaked(
address _account
) external view override(IStaking) returns (bool) {
return stakes[_account].bonded > 0;
}

Expand Down
Loading

0 comments on commit fc2a302

Please sign in to comment.