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

Commit

Permalink
Merge pull request #560 from thehubbleproject/update-prettier-plugin-…
Browse files Browse the repository at this point in the history
…solidity

Update prettier-plugin-solidity
  • Loading branch information
jacque006 authored Apr 23, 2021
2 parents c922164 + 5777a75 commit 0032354
Show file tree
Hide file tree
Showing 21 changed files with 441 additions and 412 deletions.
8 changes: 2 additions & 6 deletions contracts/DepositManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,8 @@ contract DepositManager is DepositCore, IDepositManager {
IERC20(addr).safeTransferFrom(msg.sender, vault, l1Amount);
uint256 l2Amount = l1Amount / l2Unit;
// create a new state
Types.UserState memory newState = Types.UserState(
pubkeyID,
tokenID,
l2Amount,
0
);
Types.UserState memory newState =
Types.UserState(pubkeyID, tokenID, l2Amount, 0);
// get new state hash
bytes memory encodedState = newState.encode();
emit DepositQueued(pubkeyID, encodedState);
Expand Down
5 changes: 2 additions & 3 deletions contracts/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ contract Vault {
),
"Vault: Commitment is not present in batch"
);
(address addr, uint256 l2Unit) = tokenRegistry.safeGetRecord(
commitmentMP.commitment.body.tokenID
);
(address addr, uint256 l2Unit) =
tokenRegistry.safeGetRecord(commitmentMP.commitment.body.tokenID);
Bitmap.setClaimed(batchID, bitmap);
uint256 l1Amount = commitmentMP.commitment.body.amount * l2Unit;
require(
Expand Down
10 changes: 4 additions & 6 deletions contracts/WithdrawManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ contract WithdrawManager {
Types.MMCommitmentInclusionProof memory commitmentMP
) public {
vault.requestApproval(batchID, commitmentMP);
(address addr, uint256 l2Unit) = tokenRegistry.safeGetRecord(
commitmentMP.commitment.body.tokenID
);
(address addr, uint256 l2Unit) =
tokenRegistry.safeGetRecord(commitmentMP.commitment.body.tokenID);
processed[commitmentMP.commitment.body.withdrawRoot] = commitmentMP
.commitment
.body
Expand Down Expand Up @@ -96,9 +95,8 @@ contract WithdrawManager {
);
require(callSuccess, "WithdrawManager: Precompile call failed");
require(checkSuccess, "WithdrawManager: Bad signature");
(address addr, uint256 l2Unit) = tokenRegistry.safeGetRecord(
withdrawal.state.tokenID
);
(address addr, uint256 l2Unit) =
tokenRegistry.safeGetRecord(withdrawal.state.tokenID);
Bitmap.setClaimed(withdrawal.state.pubkeyID, bitmap[withdrawRoot]);
uint256 l1Amount = withdrawal.state.balance * l2Unit;
// transfer tokens from vault
Expand Down
79 changes: 38 additions & 41 deletions contracts/client/FrontendCreate2Transfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ contract FrontendCreate2Transfer {
pure
returns (bytes memory)
{
Tx.Create2Transfer[] memory txTxs = new Tx.Create2Transfer[](
encodedTxs.length
);
Tx.Create2Transfer[] memory txTxs =
new Tx.Create2Transfer[](encodedTxs.length);
for (uint256 i = 0; i < txTxs.length; i++) {
Offchain.Create2Transfer memory _tx = Offchain
.decodeCreate2Transfer(encodedTxs[i]);
Offchain.Create2Transfer memory _tx =
Offchain.decodeCreate2Transfer(encodedTxs[i]);
txTxs[i] = Tx.Create2Transfer(
_tx.fromIndex,
_tx.toIndex,
Expand Down Expand Up @@ -85,8 +84,8 @@ contract FrontendCreate2Transfer {
pure
returns (bytes memory)
{
Offchain.Create2TransferWithPub memory _tx = Offchain
.decodeCreate2TransferWithPub(encodedTxWithPub);
Offchain.Create2TransferWithPub memory _tx =
Offchain.decodeCreate2TransferWithPub(encodedTxWithPub);
Tx.Create2Transfer memory txTx;
txTx.fromIndex = _tx.fromIndex;
txTx.amount = _tx.amount;
Expand All @@ -101,23 +100,20 @@ contract FrontendCreate2Transfer {
uint256[4] calldata pubkeyReceiver,
bytes32 domain
) external view returns (bool) {
Offchain.Create2Transfer memory _tx = Offchain.decodeCreate2Transfer(
encodedTx
);
Offchain.Create2Transfer memory _tx =
Offchain.decodeCreate2Transfer(encodedTx);
Tx.encodeDecimal(_tx.amount);
Tx.encodeDecimal(_tx.fee);
Tx.Create2Transfer memory txTx = Tx.Create2Transfer(
_tx.fromIndex,
_tx.toIndex,
_tx.toPubkeyID,
_tx.amount,
_tx.fee
);
bytes memory txMsg = Tx.create2TransferMessageOf(
txTx,
_tx.nonce,
pubkeyReceiver
);
Tx.Create2Transfer memory txTx =
Tx.Create2Transfer(
_tx.fromIndex,
_tx.toIndex,
_tx.toPubkeyID,
_tx.amount,
_tx.fee
);
bytes memory txMsg =
Tx.create2TransferMessageOf(txTx, _tx.nonce, pubkeyReceiver);

bool callSuccess;
bool checkSuccess;
Expand All @@ -144,9 +140,8 @@ contract FrontendCreate2Transfer {
Types.Result result
)
{
Offchain.Create2Transfer memory _tx = Offchain.decodeCreate2Transfer(
encodedTx
);
Offchain.Create2Transfer memory _tx =
Offchain.decodeCreate2Transfer(encodedTx);
Types.UserState memory sender = Types.decodeState(senderEncoded);
uint256 tokenID = sender.tokenID;
(sender, result) = Transition.validateAndApplySender(
Expand All @@ -172,15 +167,16 @@ contract FrontendCreate2Transfer {
Types.StateMerkleProof memory from,
Types.StateMerkleProof memory to
) public pure returns (bytes32 newRoot, Types.Result result) {
Offchain.Create2Transfer memory offchainTx = Offchain
.decodeCreate2Transfer(encodedTx);
Tx.Create2Transfer memory _tx = Tx.Create2Transfer(
offchainTx.fromIndex,
offchainTx.toIndex,
offchainTx.toPubkeyID,
offchainTx.amount,
offchainTx.fee
);
Offchain.Create2Transfer memory offchainTx =
Offchain.decodeCreate2Transfer(encodedTx);
Tx.Create2Transfer memory _tx =
Tx.Create2Transfer(
offchainTx.fromIndex,
offchainTx.toIndex,
offchainTx.toPubkeyID,
offchainTx.amount,
offchainTx.fee
);
return
Transition.processCreate2Transfer(
stateRoot,
Expand All @@ -199,13 +195,14 @@ contract FrontendCreate2Transfer {
bytes32 domain,
bytes memory txs
) public view returns (Types.Result) {
Types.AuthCommon memory common = Types.AuthCommon({
signature: signature,
stateRoot: stateRoot,
accountRoot: accountRoot,
domain: domain,
txs: txs
});
Types.AuthCommon memory common =
Types.AuthCommon({
signature: signature,
stateRoot: stateRoot,
accountRoot: accountRoot,
domain: domain,
txs: txs
});

return Authenticity.verifyCreate2Transfer(common, proof);
}
Expand Down
77 changes: 32 additions & 45 deletions contracts/client/FrontendMassMigration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ contract FrontendMassMigration {
pure
returns (bytes memory)
{
Tx.MassMigration[] memory txTxs = new Tx.MassMigration[](
encodedTxs.length
);
Tx.MassMigration[] memory txTxs =
new Tx.MassMigration[](encodedTxs.length);
for (uint256 i = 0; i < txTxs.length; i++) {
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
encodedTxs[i]
);
Offchain.MassMigration memory _tx =
Offchain.decodeMassMigration(encodedTxs[i]);
txTxs[i] = Tx.MassMigration(_tx.fromIndex, _tx.amount, _tx.fee);
}
return Tx.serialize(txTxs);
Expand All @@ -64,14 +62,10 @@ contract FrontendMassMigration {
pure
returns (bytes memory)
{
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
encodedTx
);
Tx.MassMigration memory txTx = Tx.MassMigration(
_tx.fromIndex,
_tx.amount,
_tx.fee
);
Offchain.MassMigration memory _tx =
Offchain.decodeMassMigration(encodedTx);
Tx.MassMigration memory txTx =
Tx.MassMigration(_tx.fromIndex, _tx.amount, _tx.fee);
return Tx.massMigrationMessageOf(txTx, _tx.nonce, _tx.spokeID);
}

Expand All @@ -81,21 +75,14 @@ contract FrontendMassMigration {
uint256[4] calldata pubkey,
bytes32 domain
) external view returns (bool) {
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
encodedTx
);
Offchain.MassMigration memory _tx =
Offchain.decodeMassMigration(encodedTx);
Tx.encodeDecimal(_tx.amount);
Tx.encodeDecimal(_tx.fee);
Tx.MassMigration memory txTx = Tx.MassMigration(
_tx.fromIndex,
_tx.amount,
_tx.fee
);
bytes memory txMsg = Tx.massMigrationMessageOf(
txTx,
_tx.nonce,
_tx.spokeID
);
Tx.MassMigration memory txTx =
Tx.MassMigration(_tx.fromIndex, _tx.amount, _tx.fee);
bytes memory txMsg =
Tx.massMigrationMessageOf(txTx, _tx.nonce, _tx.spokeID);

bool callSuccess;
bool checkSuccess;
Expand All @@ -122,9 +109,8 @@ contract FrontendMassMigration {
Types.Result result
)
{
Offchain.MassMigration memory _tx = Offchain.decodeMassMigration(
encodedTx
);
Offchain.MassMigration memory _tx =
Offchain.decodeMassMigration(encodedTx);
Types.UserState memory sender = Types.decodeState(senderEncoded);
uint256 tokenID = sender.tokenID;
(sender, result) = Transition.validateAndApplySender(
Expand Down Expand Up @@ -156,14 +142,14 @@ contract FrontendMassMigration {
Types.Result result
)
{
Offchain.MassMigration memory offchainTx = Offchain.decodeMassMigration(
encodedTx
);
Tx.MassMigration memory _tx = Tx.MassMigration(
offchainTx.fromIndex,
offchainTx.amount,
offchainTx.fee
);
Offchain.MassMigration memory offchainTx =
Offchain.decodeMassMigration(encodedTx);
Tx.MassMigration memory _tx =
Tx.MassMigration(
offchainTx.fromIndex,
offchainTx.amount,
offchainTx.fee
);
return Transition.processMassMigration(stateRoot, _tx, tokenID, from);
}

Expand All @@ -176,13 +162,14 @@ contract FrontendMassMigration {
uint256 spokeID,
bytes memory txs
) public view returns (Types.Result) {
Types.AuthCommon memory common = Types.AuthCommon({
signature: signature,
stateRoot: stateRoot,
accountRoot: accountRoot,
domain: domain,
txs: txs
});
Types.AuthCommon memory common =
Types.AuthCommon({
signature: signature,
stateRoot: stateRoot,
accountRoot: accountRoot,
domain: domain,
txs: txs
});
return Authenticity.verifyMassMigration(common, proof, spokeID);
}
}
54 changes: 23 additions & 31 deletions contracts/client/FrontendTransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ contract FrontendTransfer {
{
Tx.Transfer[] memory txTxs = new Tx.Transfer[](encodedTxs.length);
for (uint256 i = 0; i < txTxs.length; i++) {
Offchain.Transfer memory _tx = Offchain.decodeTransfer(
encodedTxs[i]
);
Offchain.Transfer memory _tx =
Offchain.decodeTransfer(encodedTxs[i]);
txTxs[i] = Tx.Transfer(
_tx.fromIndex,
_tx.toIndex,
Expand Down Expand Up @@ -68,12 +67,8 @@ contract FrontendTransfer {
returns (bytes memory)
{
Offchain.Transfer memory _tx = Offchain.decodeTransfer(encodedTx);
Tx.Transfer memory txTx = Tx.Transfer(
_tx.fromIndex,
_tx.toIndex,
_tx.amount,
_tx.fee
);
Tx.Transfer memory txTx =
Tx.Transfer(_tx.fromIndex, _tx.toIndex, _tx.amount, _tx.fee);
return Tx.transferMessageOf(txTx, _tx.nonce);
}

Expand All @@ -86,12 +81,8 @@ contract FrontendTransfer {
Offchain.Transfer memory _tx = Offchain.decodeTransfer(encodedTx);
Tx.encodeDecimal(_tx.amount);
Tx.encodeDecimal(_tx.fee);
Tx.Transfer memory txTx = Tx.Transfer(
_tx.fromIndex,
_tx.toIndex,
_tx.amount,
_tx.fee
);
Tx.Transfer memory txTx =
Tx.Transfer(_tx.fromIndex, _tx.toIndex, _tx.amount, _tx.fee);
bytes memory txMsg = Tx.transferMessageOf(txTx, _tx.nonce);

bool callSuccess;
Expand Down Expand Up @@ -146,15 +137,15 @@ contract FrontendTransfer {
Types.StateMerkleProof memory from,
Types.StateMerkleProof memory to
) public pure returns (bytes32 newRoot, Types.Result result) {
Offchain.Transfer memory offchainTx = Offchain.decodeTransfer(
encodedTx
);
Tx.Transfer memory _tx = Tx.Transfer(
offchainTx.fromIndex,
offchainTx.toIndex,
offchainTx.amount,
offchainTx.fee
);
Offchain.Transfer memory offchainTx =
Offchain.decodeTransfer(encodedTx);
Tx.Transfer memory _tx =
Tx.Transfer(
offchainTx.fromIndex,
offchainTx.toIndex,
offchainTx.amount,
offchainTx.fee
);
return Transition.processTransfer(stateRoot, _tx, tokenID, from, to);
}

Expand All @@ -166,13 +157,14 @@ contract FrontendTransfer {
bytes32 domain,
bytes memory txs
) public view returns (Types.Result) {
Types.AuthCommon memory common = Types.AuthCommon({
signature: signature,
stateRoot: stateRoot,
accountRoot: accountRoot,
domain: domain,
txs: txs
});
Types.AuthCommon memory common =
Types.AuthCommon({
signature: signature,
stateRoot: stateRoot,
accountRoot: accountRoot,
domain: domain,
txs: txs
});
return Authenticity.verifyTransfer(common, proof);
}
}
5 changes: 2 additions & 3 deletions contracts/deployment/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ contract Deployer {
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;


bytes32 accountHash
= 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
bytes32 accountHash =
0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly {
codehash := extcodehash(account)
Expand Down
Loading

0 comments on commit 0032354

Please sign in to comment.