Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit 0032354

Browse files
authored
Merge pull request #560 from thehubbleproject/update-prettier-plugin-solidity
Update prettier-plugin-solidity
2 parents c922164 + 5777a75 commit 0032354

21 files changed

+441
-412
lines changed

contracts/DepositManager.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,8 @@ contract DepositManager is DepositCore, IDepositManager {
146146
IERC20(addr).safeTransferFrom(msg.sender, vault, l1Amount);
147147
uint256 l2Amount = l1Amount / l2Unit;
148148
// create a new state
149-
Types.UserState memory newState = Types.UserState(
150-
pubkeyID,
151-
tokenID,
152-
l2Amount,
153-
0
154-
);
149+
Types.UserState memory newState =
150+
Types.UserState(pubkeyID, tokenID, l2Amount, 0);
155151
// get new state hash
156152
bytes memory encodedState = newState.encode();
157153
emit DepositQueued(pubkeyID, encodedState);

contracts/Vault.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ contract Vault {
6161
),
6262
"Vault: Commitment is not present in batch"
6363
);
64-
(address addr, uint256 l2Unit) = tokenRegistry.safeGetRecord(
65-
commitmentMP.commitment.body.tokenID
66-
);
64+
(address addr, uint256 l2Unit) =
65+
tokenRegistry.safeGetRecord(commitmentMP.commitment.body.tokenID);
6766
Bitmap.setClaimed(batchID, bitmap);
6867
uint256 l1Amount = commitmentMP.commitment.body.amount * l2Unit;
6968
require(

contracts/WithdrawManager.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ contract WithdrawManager {
4040
Types.MMCommitmentInclusionProof memory commitmentMP
4141
) public {
4242
vault.requestApproval(batchID, commitmentMP);
43-
(address addr, uint256 l2Unit) = tokenRegistry.safeGetRecord(
44-
commitmentMP.commitment.body.tokenID
45-
);
43+
(address addr, uint256 l2Unit) =
44+
tokenRegistry.safeGetRecord(commitmentMP.commitment.body.tokenID);
4645
processed[commitmentMP.commitment.body.withdrawRoot] = commitmentMP
4746
.commitment
4847
.body
@@ -96,9 +95,8 @@ contract WithdrawManager {
9695
);
9796
require(callSuccess, "WithdrawManager: Precompile call failed");
9897
require(checkSuccess, "WithdrawManager: Bad signature");
99-
(address addr, uint256 l2Unit) = tokenRegistry.safeGetRecord(
100-
withdrawal.state.tokenID
101-
);
98+
(address addr, uint256 l2Unit) =
99+
tokenRegistry.safeGetRecord(withdrawal.state.tokenID);
102100
Bitmap.setClaimed(withdrawal.state.pubkeyID, bitmap[withdrawRoot]);
103101
uint256 l1Amount = withdrawal.state.balance * l2Unit;
104102
// transfer tokens from vault

contracts/client/FrontendCreate2Transfer.sol

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ contract FrontendCreate2Transfer {
5050
pure
5151
returns (bytes memory)
5252
{
53-
Tx.Create2Transfer[] memory txTxs = new Tx.Create2Transfer[](
54-
encodedTxs.length
55-
);
53+
Tx.Create2Transfer[] memory txTxs =
54+
new Tx.Create2Transfer[](encodedTxs.length);
5655
for (uint256 i = 0; i < txTxs.length; i++) {
57-
Offchain.Create2Transfer memory _tx = Offchain
58-
.decodeCreate2Transfer(encodedTxs[i]);
56+
Offchain.Create2Transfer memory _tx =
57+
Offchain.decodeCreate2Transfer(encodedTxs[i]);
5958
txTxs[i] = Tx.Create2Transfer(
6059
_tx.fromIndex,
6160
_tx.toIndex,
@@ -85,8 +84,8 @@ contract FrontendCreate2Transfer {
8584
pure
8685
returns (bytes memory)
8786
{
88-
Offchain.Create2TransferWithPub memory _tx = Offchain
89-
.decodeCreate2TransferWithPub(encodedTxWithPub);
87+
Offchain.Create2TransferWithPub memory _tx =
88+
Offchain.decodeCreate2TransferWithPub(encodedTxWithPub);
9089
Tx.Create2Transfer memory txTx;
9190
txTx.fromIndex = _tx.fromIndex;
9291
txTx.amount = _tx.amount;
@@ -101,23 +100,20 @@ contract FrontendCreate2Transfer {
101100
uint256[4] calldata pubkeyReceiver,
102101
bytes32 domain
103102
) external view returns (bool) {
104-
Offchain.Create2Transfer memory _tx = Offchain.decodeCreate2Transfer(
105-
encodedTx
106-
);
103+
Offchain.Create2Transfer memory _tx =
104+
Offchain.decodeCreate2Transfer(encodedTx);
107105
Tx.encodeDecimal(_tx.amount);
108106
Tx.encodeDecimal(_tx.fee);
109-
Tx.Create2Transfer memory txTx = Tx.Create2Transfer(
110-
_tx.fromIndex,
111-
_tx.toIndex,
112-
_tx.toPubkeyID,
113-
_tx.amount,
114-
_tx.fee
115-
);
116-
bytes memory txMsg = Tx.create2TransferMessageOf(
117-
txTx,
118-
_tx.nonce,
119-
pubkeyReceiver
120-
);
107+
Tx.Create2Transfer memory txTx =
108+
Tx.Create2Transfer(
109+
_tx.fromIndex,
110+
_tx.toIndex,
111+
_tx.toPubkeyID,
112+
_tx.amount,
113+
_tx.fee
114+
);
115+
bytes memory txMsg =
116+
Tx.create2TransferMessageOf(txTx, _tx.nonce, pubkeyReceiver);
121117

122118
bool callSuccess;
123119
bool checkSuccess;
@@ -144,9 +140,8 @@ contract FrontendCreate2Transfer {
144140
Types.Result result
145141
)
146142
{
147-
Offchain.Create2Transfer memory _tx = Offchain.decodeCreate2Transfer(
148-
encodedTx
149-
);
143+
Offchain.Create2Transfer memory _tx =
144+
Offchain.decodeCreate2Transfer(encodedTx);
150145
Types.UserState memory sender = Types.decodeState(senderEncoded);
151146
uint256 tokenID = sender.tokenID;
152147
(sender, result) = Transition.validateAndApplySender(
@@ -172,15 +167,16 @@ contract FrontendCreate2Transfer {
172167
Types.StateMerkleProof memory from,
173168
Types.StateMerkleProof memory to
174169
) public pure returns (bytes32 newRoot, Types.Result result) {
175-
Offchain.Create2Transfer memory offchainTx = Offchain
176-
.decodeCreate2Transfer(encodedTx);
177-
Tx.Create2Transfer memory _tx = Tx.Create2Transfer(
178-
offchainTx.fromIndex,
179-
offchainTx.toIndex,
180-
offchainTx.toPubkeyID,
181-
offchainTx.amount,
182-
offchainTx.fee
183-
);
170+
Offchain.Create2Transfer memory offchainTx =
171+
Offchain.decodeCreate2Transfer(encodedTx);
172+
Tx.Create2Transfer memory _tx =
173+
Tx.Create2Transfer(
174+
offchainTx.fromIndex,
175+
offchainTx.toIndex,
176+
offchainTx.toPubkeyID,
177+
offchainTx.amount,
178+
offchainTx.fee
179+
);
184180
return
185181
Transition.processCreate2Transfer(
186182
stateRoot,
@@ -199,13 +195,14 @@ contract FrontendCreate2Transfer {
199195
bytes32 domain,
200196
bytes memory txs
201197
) public view returns (Types.Result) {
202-
Types.AuthCommon memory common = Types.AuthCommon({
203-
signature: signature,
204-
stateRoot: stateRoot,
205-
accountRoot: accountRoot,
206-
domain: domain,
207-
txs: txs
208-
});
198+
Types.AuthCommon memory common =
199+
Types.AuthCommon({
200+
signature: signature,
201+
stateRoot: stateRoot,
202+
accountRoot: accountRoot,
203+
domain: domain,
204+
txs: txs
205+
});
209206

210207
return Authenticity.verifyCreate2Transfer(common, proof);
211208
}

contracts/client/FrontendMassMigration.sol

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ contract FrontendMassMigration {
3434
pure
3535
returns (bytes memory)
3636
{
37-
Tx.MassMigration[] memory txTxs = new Tx.MassMigration[](
38-
encodedTxs.length
39-
);
37+
Tx.MassMigration[] memory txTxs =
38+
new Tx.MassMigration[](encodedTxs.length);
4039
for (uint256 i = 0; i < txTxs.length; i++) {
41-
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
42-
encodedTxs[i]
43-
);
40+
Offchain.MassMigration memory _tx =
41+
Offchain.decodeMassMigration(encodedTxs[i]);
4442
txTxs[i] = Tx.MassMigration(_tx.fromIndex, _tx.amount, _tx.fee);
4543
}
4644
return Tx.serialize(txTxs);
@@ -64,14 +62,10 @@ contract FrontendMassMigration {
6462
pure
6563
returns (bytes memory)
6664
{
67-
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
68-
encodedTx
69-
);
70-
Tx.MassMigration memory txTx = Tx.MassMigration(
71-
_tx.fromIndex,
72-
_tx.amount,
73-
_tx.fee
74-
);
65+
Offchain.MassMigration memory _tx =
66+
Offchain.decodeMassMigration(encodedTx);
67+
Tx.MassMigration memory txTx =
68+
Tx.MassMigration(_tx.fromIndex, _tx.amount, _tx.fee);
7569
return Tx.massMigrationMessageOf(txTx, _tx.nonce, _tx.spokeID);
7670
}
7771

@@ -81,21 +75,14 @@ contract FrontendMassMigration {
8175
uint256[4] calldata pubkey,
8276
bytes32 domain
8377
) external view returns (bool) {
84-
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
85-
encodedTx
86-
);
78+
Offchain.MassMigration memory _tx =
79+
Offchain.decodeMassMigration(encodedTx);
8780
Tx.encodeDecimal(_tx.amount);
8881
Tx.encodeDecimal(_tx.fee);
89-
Tx.MassMigration memory txTx = Tx.MassMigration(
90-
_tx.fromIndex,
91-
_tx.amount,
92-
_tx.fee
93-
);
94-
bytes memory txMsg = Tx.massMigrationMessageOf(
95-
txTx,
96-
_tx.nonce,
97-
_tx.spokeID
98-
);
82+
Tx.MassMigration memory txTx =
83+
Tx.MassMigration(_tx.fromIndex, _tx.amount, _tx.fee);
84+
bytes memory txMsg =
85+
Tx.massMigrationMessageOf(txTx, _tx.nonce, _tx.spokeID);
9986

10087
bool callSuccess;
10188
bool checkSuccess;
@@ -122,9 +109,8 @@ contract FrontendMassMigration {
122109
Types.Result result
123110
)
124111
{
125-
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
126-
encodedTx
127-
);
112+
Offchain.MassMigration memory _tx =
113+
Offchain.decodeMassMigration(encodedTx);
128114
Types.UserState memory sender = Types.decodeState(senderEncoded);
129115
uint256 tokenID = sender.tokenID;
130116
(sender, result) = Transition.validateAndApplySender(
@@ -156,14 +142,14 @@ contract FrontendMassMigration {
156142
Types.Result result
157143
)
158144
{
159-
Offchain.MassMigration memory offchainTx = Offchain.decodeMassMigration(
160-
encodedTx
161-
);
162-
Tx.MassMigration memory _tx = Tx.MassMigration(
163-
offchainTx.fromIndex,
164-
offchainTx.amount,
165-
offchainTx.fee
166-
);
145+
Offchain.MassMigration memory offchainTx =
146+
Offchain.decodeMassMigration(encodedTx);
147+
Tx.MassMigration memory _tx =
148+
Tx.MassMigration(
149+
offchainTx.fromIndex,
150+
offchainTx.amount,
151+
offchainTx.fee
152+
);
167153
return Transition.processMassMigration(stateRoot, _tx, tokenID, from);
168154
}
169155

@@ -176,13 +162,14 @@ contract FrontendMassMigration {
176162
uint256 spokeID,
177163
bytes memory txs
178164
) public view returns (Types.Result) {
179-
Types.AuthCommon memory common = Types.AuthCommon({
180-
signature: signature,
181-
stateRoot: stateRoot,
182-
accountRoot: accountRoot,
183-
domain: domain,
184-
txs: txs
185-
});
165+
Types.AuthCommon memory common =
166+
Types.AuthCommon({
167+
signature: signature,
168+
stateRoot: stateRoot,
169+
accountRoot: accountRoot,
170+
domain: domain,
171+
txs: txs
172+
});
186173
return Authenticity.verifyMassMigration(common, proof, spokeID);
187174
}
188175
}

contracts/client/FrontendTransfer.sol

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ contract FrontendTransfer {
3636
{
3737
Tx.Transfer[] memory txTxs = new Tx.Transfer[](encodedTxs.length);
3838
for (uint256 i = 0; i < txTxs.length; i++) {
39-
Offchain.Transfer memory _tx = Offchain.decodeTransfer(
40-
encodedTxs[i]
41-
);
39+
Offchain.Transfer memory _tx =
40+
Offchain.decodeTransfer(encodedTxs[i]);
4241
txTxs[i] = Tx.Transfer(
4342
_tx.fromIndex,
4443
_tx.toIndex,
@@ -68,12 +67,8 @@ contract FrontendTransfer {
6867
returns (bytes memory)
6968
{
7069
Offchain.Transfer memory _tx = Offchain.decodeTransfer(encodedTx);
71-
Tx.Transfer memory txTx = Tx.Transfer(
72-
_tx.fromIndex,
73-
_tx.toIndex,
74-
_tx.amount,
75-
_tx.fee
76-
);
70+
Tx.Transfer memory txTx =
71+
Tx.Transfer(_tx.fromIndex, _tx.toIndex, _tx.amount, _tx.fee);
7772
return Tx.transferMessageOf(txTx, _tx.nonce);
7873
}
7974

@@ -86,12 +81,8 @@ contract FrontendTransfer {
8681
Offchain.Transfer memory _tx = Offchain.decodeTransfer(encodedTx);
8782
Tx.encodeDecimal(_tx.amount);
8883
Tx.encodeDecimal(_tx.fee);
89-
Tx.Transfer memory txTx = Tx.Transfer(
90-
_tx.fromIndex,
91-
_tx.toIndex,
92-
_tx.amount,
93-
_tx.fee
94-
);
84+
Tx.Transfer memory txTx =
85+
Tx.Transfer(_tx.fromIndex, _tx.toIndex, _tx.amount, _tx.fee);
9586
bytes memory txMsg = Tx.transferMessageOf(txTx, _tx.nonce);
9687

9788
bool callSuccess;
@@ -146,15 +137,15 @@ contract FrontendTransfer {
146137
Types.StateMerkleProof memory from,
147138
Types.StateMerkleProof memory to
148139
) public pure returns (bytes32 newRoot, Types.Result result) {
149-
Offchain.Transfer memory offchainTx = Offchain.decodeTransfer(
150-
encodedTx
151-
);
152-
Tx.Transfer memory _tx = Tx.Transfer(
153-
offchainTx.fromIndex,
154-
offchainTx.toIndex,
155-
offchainTx.amount,
156-
offchainTx.fee
157-
);
140+
Offchain.Transfer memory offchainTx =
141+
Offchain.decodeTransfer(encodedTx);
142+
Tx.Transfer memory _tx =
143+
Tx.Transfer(
144+
offchainTx.fromIndex,
145+
offchainTx.toIndex,
146+
offchainTx.amount,
147+
offchainTx.fee
148+
);
158149
return Transition.processTransfer(stateRoot, _tx, tokenID, from, to);
159150
}
160151

@@ -166,13 +157,14 @@ contract FrontendTransfer {
166157
bytes32 domain,
167158
bytes memory txs
168159
) public view returns (Types.Result) {
169-
Types.AuthCommon memory common = Types.AuthCommon({
170-
signature: signature,
171-
stateRoot: stateRoot,
172-
accountRoot: accountRoot,
173-
domain: domain,
174-
txs: txs
175-
});
160+
Types.AuthCommon memory common =
161+
Types.AuthCommon({
162+
signature: signature,
163+
stateRoot: stateRoot,
164+
accountRoot: accountRoot,
165+
domain: domain,
166+
txs: txs
167+
});
176168
return Authenticity.verifyTransfer(common, proof);
177169
}
178170
}

contracts/deployment/Deployer.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ contract Deployer {
5656
// for accounts without code, i.e. `keccak256('')`
5757
bytes32 codehash;
5858

59-
60-
bytes32 accountHash
61-
= 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
59+
bytes32 accountHash =
60+
0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
6261
// solhint-disable-next-line no-inline-assembly
6362
assembly {
6463
codehash := extcodehash(account)

0 commit comments

Comments
 (0)