Skip to content

Commit da4ba56

Browse files
committed
forge fmt
1 parent 3ad35c0 commit da4ba56

File tree

4 files changed

+20
-32
lines changed

4 files changed

+20
-32
lines changed

src/FlexVotingClient.sol

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,12 @@ abstract contract FlexVotingClient {
185185
// totalVotesInternal totalTokenWeight
186186
//
187187
// userVoteWeight = userVotesInternal * totalTokenWeight / totalVotesInternal
188-
uint128 _forVotesToCast = SafeCast.toUint128(
189-
(_totalTokenWeight * _proposalVote.forVotes) / _totalVotesInternal
190-
);
191-
uint128 _againstVotesToCast = SafeCast.toUint128(
192-
(_totalTokenWeight * _proposalVote.againstVotes) / _totalVotesInternal
193-
);
194-
uint128 _abstainVotesToCast = SafeCast.toUint128(
195-
(_totalTokenWeight * _proposalVote.abstainVotes) / _totalVotesInternal
196-
);
188+
uint128 _forVotesToCast =
189+
SafeCast.toUint128((_totalTokenWeight * _proposalVote.forVotes) / _totalVotesInternal);
190+
uint128 _againstVotesToCast =
191+
SafeCast.toUint128((_totalTokenWeight * _proposalVote.againstVotes) / _totalVotesInternal);
192+
uint128 _abstainVotesToCast =
193+
SafeCast.toUint128((_totalTokenWeight * _proposalVote.abstainVotes) / _totalVotesInternal);
197194

198195
// Clear the stored votes so that we don't double-cast them.
199196
delete proposalVotes[proposalId];
@@ -205,10 +202,10 @@ abstract contract FlexVotingClient {
205202
);
206203
}
207204

208-
function _applyDeltaToCheckpoint(
209-
Checkpoints.Trace208 storage _checkpoint,
210-
int256 _delta
211-
) internal returns (uint208 _prevTotal, uint208 _newTotal) {
205+
function _applyDeltaToCheckpoint(Checkpoints.Trace208 storage _checkpoint, int256 _delta)
206+
internal
207+
returns (uint208 _prevTotal, uint208 _newTotal)
208+
{
212209
// The casting in this function is safe since:
213210
// - if oldTotal + delta > int256.max it will panic and revert.
214211
// - if |delta| <= oldTotal there is no risk of wrapping
@@ -234,10 +231,7 @@ abstract contract FlexVotingClient {
234231
}
235232

236233
/// @dev Checkpoints internal voting weight of `user` after applying `_delta`.
237-
function _checkpointVoteWeightOf(
238-
address _user,
239-
int256 _delta
240-
) internal virtual {
234+
function _checkpointVoteWeightOf(address _user, int256 _delta) internal virtual {
241235
_applyDeltaToCheckpoint(voteWeightCheckpoints[_user], _delta);
242236
}
243237

src/FlexVotingDelegatable.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ abstract contract FlexVotingDelegatable is Context, FlexVotingClient {
4848
_updateDelegateBalance(oldDelegate, delegatee, _delta);
4949
}
5050

51-
function _checkpointVoteWeightOf(
52-
address _user,
53-
int256 _delta
54-
) internal virtual override {
51+
function _checkpointVoteWeightOf(address _user, int256 _delta) internal virtual override {
5552
address _proxy = delegates(_user);
5653
_applyDeltaToCheckpoint(voteWeightCheckpoints[_proxy], _delta);
5754
}
@@ -66,8 +63,7 @@ abstract contract FlexVotingDelegatable is Context, FlexVotingClient {
6663
emit DelegateWeightChanged(from, _oldFrom, _newFrom);
6764

6865
// Increment new delegate's weight.
69-
(uint208 _oldTo, uint208 _newTo) =
70-
_applyDeltaToCheckpoint(voteWeightCheckpoints[to], _delta);
66+
(uint208 _oldTo, uint208 _newTo) = _applyDeltaToCheckpoint(voteWeightCheckpoints[to], _delta);
7167
emit DelegateWeightChanged(to, _oldTo, _newTo);
7268
}
7369
}

test/FlexVotingDelegatable.t.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,12 @@ abstract contract Delegation is FlexVotingClientTest {
338338
vm.prank(_delegateB);
339339
client().expressVote(_proposalB, uint8(_voteType));
340340

341-
(uint256 _againstA, uint256 _forA, uint256 _abstainA) =
342-
client().proposalVotes(_proposalA);
343-
assertEq(_forA, _voteType == GCS.VoteType.For ? _weight : 0);
341+
(uint256 _againstA, uint256 _forA, uint256 _abstainA) = client().proposalVotes(_proposalA);
342+
assertEq(_forA, _voteType == GCS.VoteType.For ? _weight : 0);
344343
assertEq(_againstA, _voteType == GCS.VoteType.Against ? _weight : 0);
345344
assertEq(_abstainA, _voteType == GCS.VoteType.Abstain ? _weight : 0);
346345

347-
(uint256 _againstB, uint256 _forB, uint256 _abstainB) =
348-
client().proposalVotes(_proposalB);
346+
(uint256 _againstB, uint256 _forB, uint256 _abstainB) = client().proposalVotes(_proposalB);
349347
assertEq(_forB, _voteType == GCS.VoteType.For ? _weight : 0);
350348
assertEq(_againstB, _voteType == GCS.VoteType.Against ? _weight : 0);
351349
assertEq(_abstainB, _voteType == GCS.VoteType.Abstain ? _weight : 0);

test/MockFlexVotingDelegatableClient.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {MockFlexVotingClient} from "test/MockFlexVotingClient.sol";
88
contract MockFlexVotingDelegatableClient is MockFlexVotingClient, FlexVotingDelegatable {
99
constructor(address _governor) MockFlexVotingClient(_governor) {}
1010

11-
function _checkpointVoteWeightOf(
12-
address _user,
13-
int256 _delta
14-
) internal override(FlexVotingClient, FlexVotingDelegatable) {
11+
function _checkpointVoteWeightOf(address _user, int256 _delta)
12+
internal
13+
override(FlexVotingClient, FlexVotingDelegatable)
14+
{
1515
return FlexVotingDelegatable._checkpointVoteWeightOf(_user, _delta);
1616
}
1717
}

0 commit comments

Comments
 (0)