Skip to content

Commit 730c950

Browse files
nambrotcelo-ci-bot-user
authored andcommitted
Prettify Solidity files (#1623)
1 parent 6c5d794 commit 730c950

File tree

104 files changed

+677
-1705
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+677
-1705
lines changed

.prettierrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ module.exports = {
66
printWidth: 100,
77
tabWidth: 2,
88
bracketSpacing: true,
9+
overrides: [
10+
{
11+
files: '**/*.sol',
12+
options: {
13+
singleQuote: false,
14+
},
15+
},
16+
],
917
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"scripts": {
88
"install-pkg": "yarn install --link-duplicates",
99
"lint": "yarn lerna run lint",
10-
"prettify": "yarn run prettier --config .prettierrc.js --write '**/*.+(ts|tsx|js|jsx)'",
11-
"prettify:diff": "yarn run prettier --config .prettierrc.js --list-different '**/*.+(ts|tsx|js|jsx)'",
10+
"prettify": "yarn run prettier --config .prettierrc.js --write '**/*.+(ts|tsx|js|jsx|sol)'",
11+
"prettify:diff": "yarn run prettier --config .prettierrc.js --list-different '**/*.+(ts|tsx|js|jsx|sol)'",
1212
"reset": "yarn reset-modules && yarn reset-cache",
1313
"reset-cache": "yarn reset-yarn && yarn reset-rn",
1414
"reset-modules": "rm -rf node_modules/ packages/*/node_modules",
@@ -51,6 +51,7 @@
5151
"lerna": "^3.16.0",
5252
"patch-package": "^5.1.1",
5353
"prettier": "1.13.5",
54+
"prettier-plugin-solidity": "1.0.0-alpha.34",
5455
"pretty-quick": "^1.11.1",
5556
"solc": "0.5.8",
5657
"tslint": "^5.20.0",
@@ -76,4 +77,4 @@
7677
"**/extend": "^3.0.2",
7778
"sha3": "1.2.3"
7879
}
79-
}
80+
}

packages/protocol/contracts/Migrations.sol

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
pragma solidity ^0.5.3;
22

3-
43
contract Migrations {
5-
64
address public owner;
7-
uint public last_completed_migration; // solhint-disable var-name-mixedcase
5+
uint256 public last_completed_migration; // solhint-disable var-name-mixedcase
86

97
modifier restricted() {
108
if (msg.sender == owner) _;
@@ -14,7 +12,7 @@ contract Migrations {
1412
owner = msg.sender;
1513
}
1614

17-
function setCompleted(uint completed) external restricted {
15+
function setCompleted(uint256 completed) external restricted {
1816
last_completed_migration = completed; // solhint-disable var-name-mixedcase
1917
}
2018

packages/protocol/contracts/baklava/Freezable.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pragma solidity ^0.5.3;
22

3-
43
contract Freezable {
54
bool public frozen;
65
address public freezer;

packages/protocol/contracts/baklava/test/FreezableTest.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pragma solidity ^0.5.8;
22

33
import "../Freezable.sol";
44

5-
65
contract FreezableTest is Freezable {
76
event FunctionCalled();
87

packages/protocol/contracts/common/Accounts.sol

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,17 @@ import "../common/Signatures.sol";
1010
import "../common/UsingRegistry.sol";
1111

1212
contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
13-
1413
using SafeMath for uint256;
1514

1615
struct Signers {
1716
//The address that is authorized to vote in governance and validator elections on behalf of the
1817
// account. The account can vote as well, whether or not an vote signing key has been specified.
1918
address voting;
20-
2119
// The address that is authorized to manage a validator or validator group and sign consensus
2220
// messages on behalf of the account. The account can manage the validator, whether or not an
2321
// validation signing key has been specified. However if an validation signing key has been
2422
// specified, only that key may actually participate in consensus.
2523
address validating;
26-
2724
// The address of the key with which this account wants to sign attestations on the Attestations
2825
// contract
2926
address attesting;
@@ -35,17 +32,13 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
3532
// These keys may not be keys of other accounts, and may not be authorized by any other
3633
// account for any purpose.
3734
Signers signers;
38-
3935
// The address at which the account expects to receive transfers. If it's empty/0x0, the
4036
// account indicates that an address exchange should be initiated with the dataEncryptionKey
4137
address walletAddress;
42-
4338
// An optional human readable identifier for the account
4439
string name;
45-
4640
// The ECDSA public key used to encrypt and decrypt data for this account
4741
bytes dataEncryptionKey;
48-
4942
// The URL under which an account adds metadata and claims
5043
string metadataURL;
5144
}
@@ -54,7 +47,6 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
5447
// Maps voting and validating keys to the account that provided the authorization.
5548
mapping(address => address) public authorizedBy;
5649

57-
5850
event AttestationSignerAuthorized(address indexed account, address signer);
5951
event VoteSignerAuthorized(address indexed account, address signer);
6052
event ValidationSignerAuthorized(address indexed account, address signer);
@@ -70,14 +62,10 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
7062
* @param dataEncryptionKey secp256k1 public key for data encryption. Preferably compressed.
7163
* @param walletAddress The wallet address to set for the account
7264
*/
73-
function setAccount(
74-
string calldata name,
75-
bytes calldata dataEncryptionKey,
76-
address walletAddress
77-
)
65+
function setAccount(string calldata name, bytes calldata dataEncryptionKey, address walletAddress)
7866
external
7967
{
80-
if(!isAccount(msg.sender)) {
68+
if (!isAccount(msg.sender)) {
8169
createAccount();
8270
}
8371
setName(name);
@@ -103,15 +91,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
10391
* @param s Output value s of the ECDSA signature.
10492
* @dev v, r, s constitute `voter`'s signature on `msg.sender`.
10593
*/
106-
function authorizeVoteSigner(
107-
address voter,
108-
uint8 v,
109-
bytes32 r,
110-
bytes32 s
111-
)
112-
external
113-
nonReentrant
114-
{
94+
function authorizeVoteSigner(address voter, uint8 v, bytes32 r, bytes32 s) external nonReentrant {
11595
Account storage account = accounts[msg.sender];
11696
authorize(voter, account.signers.voting, v, r, s);
11797
account.signers.voting = voter;
@@ -126,12 +106,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
126106
* @param s Output value s of the ECDSA signature.
127107
* @dev v, r, s constitute `validator`'s signature on `msg.sender`.
128108
*/
129-
function authorizeValidationSigner(
130-
address validator,
131-
uint8 v,
132-
bytes32 r,
133-
bytes32 s
134-
)
109+
function authorizeValidationSigner(address validator, uint8 v, bytes32 r, bytes32 s)
135110
external
136111
nonReentrant
137112
{
@@ -179,11 +154,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
179154
* @dev Fails if the `accountOrVoteSigner` is not an account or active authorized vote signer.
180155
* @return The associated account.
181156
*/
182-
function activeVoteSignerToAccount(address accountOrVoteSigner)
183-
external
184-
view
185-
returns (address)
186-
{
157+
function activeVoteSignerToAccount(address accountOrVoteSigner) external view returns (address) {
187158
address authorizingAccount = authorizedBy[accountOrVoteSigner];
188159
if (authorizingAccount != address(0)) {
189160
require(accounts[authorizingAccount].signers.voting == accountOrVoteSigner);
@@ -228,7 +199,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
228199
return accounts[account].metadataURL;
229200
}
230201

231-
/**
202+
/**
232203
* @notice Getter for the data encryption key and version.
233204
* @param account The address of the account to get the key for
234205
* @return dataEncryptionKey secp256k1 public key for data encryption. Preferably compressed.
@@ -296,14 +267,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
296267
* @param s Output value s of the ECDSA signature.
297268
* @dev v, r, s constitute `attestor`'s signature on `msg.sender`.
298269
*/
299-
function authorizeAttestationSigner(
300-
address attestor,
301-
uint8 v,
302-
bytes32 r,
303-
bytes32 s
304-
)
305-
public
306-
{
270+
function authorizeAttestationSigner(address attestor, uint8 v, bytes32 r, bytes32 s) public {
307271
Account storage account = accounts[msg.sender];
308272
authorize(attestor, account.signers.attesting, v, r, s);
309273
account.signers.attesting = attestor;
@@ -444,15 +408,7 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
444408
* @dev Fails if the address is already authorized or is an account.
445409
* @dev v, r, s constitute `current`'s signature on `msg.sender`.
446410
*/
447-
function authorize(
448-
address current,
449-
address previous,
450-
uint8 v,
451-
bytes32 r,
452-
bytes32 s
453-
)
454-
private
455-
{
411+
function authorize(address current, address previous, uint8 v, bytes32 r, bytes32 s) private {
456412
require(isAccount(msg.sender) && isNotAccount(current) && isNotAuthorized(current));
457413

458414
address signer = Signatures.getSignerOfAddress(msg.sender, v, r, s);
@@ -461,4 +417,4 @@ contract Accounts is IAccounts, ReentrancyGuard, Initializable, UsingRegistry {
461417
authorizedBy[previous] = address(0);
462418
authorizedBy[current] = msg.sender;
463419
}
464-
}
420+
}

packages/protocol/contracts/common/ExtractFunctionSignature.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ library ExtractFunctionSignature {
77
* @return The first four bytes of `input`.
88
*/
99
function extractFunctionSignature(bytes memory input) internal pure returns (bytes4) {
10-
return (bytes4(input[0]) | bytes4(input[1])>>8 | bytes4(input[2])>>16 | bytes4(input[3])>>24);
10+
return (bytes4(input[0]) |
11+
(bytes4(input[1]) >> 8) |
12+
(bytes4(input[2]) >> 16) |
13+
(bytes4(input[3]) >> 24));
1114
}
1215
}
13-

packages/protocol/contracts/common/FixidityLib.sol

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pragma solidity ^0.5.0;
22

3-
43
/**
54
* @title FixidityLib
65
* @author Gadi Guy, Alberto Cuesta Canada
@@ -16,7 +15,6 @@ pragma solidity ^0.5.0;
1615
* overflow.
1716
*/
1817
library FixidityLib {
19-
2018
struct Fraction {
2119
uint256 value;
2220
}
@@ -120,11 +118,7 @@ library FixidityLib {
120118
* Test newFixed(maxNewFixed()) returns maxNewFixed() * fixed1()
121119
* Test newFixed(maxNewFixed()+1) fails
122120
*/
123-
function newFixed(uint256 x)
124-
internal
125-
pure
126-
returns (Fraction memory)
127-
{
121+
function newFixed(uint256 x) internal pure returns (Fraction memory) {
128122
require(x <= maxNewFixed());
129123
return Fraction(x * FIXED1_UINT);
130124
}
@@ -133,11 +127,7 @@ library FixidityLib {
133127
* @notice Converts a uint256 in the fixed point representation of this
134128
* library to a non decimal. All decimal digits will be truncated.
135129
*/
136-
function fromFixed(Fraction memory x)
137-
internal
138-
pure
139-
returns (uint256)
140-
{
130+
function fromFixed(Fraction memory x) internal pure returns (uint256) {
141131
return x.value / FIXED1_UINT;
142132
}
143133

@@ -153,10 +143,7 @@ library FixidityLib {
153143
* Test newFixedFraction(maxFixedDividend(),1) returns maxFixedDividend()*fixed1()
154144
* Test newFixedFraction(1,fixed1()) returns 1
155145
*/
156-
function newFixedFraction(
157-
uint256 numerator,
158-
uint256 denominator
159-
)
146+
function newFixedFraction(uint256 numerator, uint256 denominator)
160147
internal
161148
pure
162149
returns (Fraction memory)
@@ -278,7 +265,7 @@ library FixidityLib {
278265
*/
279266
function reciprocal(Fraction memory x) internal pure returns (Fraction memory) {
280267
require(x.value != 0);
281-
return Fraction((FIXED1_UINT*FIXED1_UINT) / x.value); // Can't overflow
268+
return Fraction((FIXED1_UINT * FIXED1_UINT) / x.value); // Can't overflow
282269
}
283270

284271
/**

0 commit comments

Comments
 (0)