Skip to content

Commit

Permalink
zk fmt and zk lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Jan 22, 2024
1 parent 19162e6 commit c300a76
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
9 changes: 6 additions & 3 deletions l1-contracts/contracts/bridge/L1WethBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract L1WethBridge is IL1Bridge, ReentrancyGuard, Initializable, Ownable2Step
/// @dev A mapping chainId => bridgeProxyTxHash. Used to check the deploy transaction (which depends on its place in the priority queue).
mapping(uint256 => bytes32) public bridgeProxyDeployOnL2TxHash;

/// @dev A mapping chainId => L2 deposit transaction hash => keccak256(account, amount)
/// @dev A mapping chainId => L2 deposit transaction hash => keccak256(account, amount)
/// @dev Used for saving the number of deposited funds, to claim them in case the deposit transaction will fail
/// @dev only used when it is not the base token, as then it is sent to refund recipient
mapping(uint256 => mapping(bytes32 => bytes32)) internal depositHappened;
Expand Down Expand Up @@ -545,7 +545,7 @@ contract L1WethBridge is IL1Bridge, ReentrancyGuard, Initializable, Ownable2Step
bytes32 _txHash
) external override onlyBridgehub {
require(depositHappened[_chainId][_txHash] == 0x00, "L1WETHBridge: tx already happened");
depositHappened[_chainId][_txHash] = _txDataHash;
depositHappened[_chainId][_txHash] = _txDataHash;
emit BridgehubDepositFinalized(_chainId, _txDataHash, _txHash);
}

Expand Down Expand Up @@ -588,7 +588,10 @@ contract L1WethBridge is IL1Bridge, ReentrancyGuard, Initializable, Ownable2Step
require(proofValid, "L1WB: Invalid L2 transaction status proof");

bytes32 txDataHash = depositHappened[_chainId][_l2TxHash];
require(((_amount > 0) && (txDataHash == keccak256(abi.encode(_depositSender, _amount)))), "L1WB: _amount is zero or deposit did not happen");
require(
((_amount > 0) && (txDataHash == keccak256(abi.encode(_depositSender, _amount)))),
"L1WB: _amount is zero or deposit did not happen"
);
if (!hyperbridgingEnabled[_chainId]) {
require(chainBalance[_chainId] >= _amount, "L1WB: chainBalance is too low");
chainBalance[_chainId] -= _amount;
Expand Down
11 changes: 2 additions & 9 deletions l1-contracts/src.ts/erc20-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export async function initializeErc20Bridge(
// Governor should always be smart contract (except for unit tests)
const l2GovernorAddress = applyL1ToL2Alias(l1GovernorAddress);

const { l2TokenFactoryAddr, l2ERC20BridgeProxyAddr } = calculateERC20Addresses(
l2GovernorAddress,
erc20Bridge
);
const { l2TokenFactoryAddr, l2ERC20BridgeProxyAddr } = calculateERC20Addresses(l2GovernorAddress, erc20Bridge);

const tx1 = await erc20Bridge.initialize();
const tx2 = await erc20Bridge.initializeV2(
Expand Down Expand Up @@ -165,12 +162,8 @@ export async function startErc20BridgeInitOnChain(
// Governor should always be smart contract (except for unit tests)
const l2GovernorAddress = applyL1ToL2Alias(l1GovernorAddress);

const { l2ERC20BridgeProxyAddr } = calculateERC20Addresses(
l2GovernorAddress,
erc20Bridge
);
const { l2ERC20BridgeProxyAddr } = calculateERC20Addresses(l2GovernorAddress, erc20Bridge);

console.log(`CONTRACTS_L2_ERC20_BRIDGE_ADDR=${l2ERC20BridgeProxyAddr}`);
}

}
16 changes: 9 additions & 7 deletions l1-contracts/src.ts/weth-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export async function initializeWethBridge(deployer: Deployer, deployWallet: Wal
const {
l2WethProxyAddress: l2WethProxyAddressEthIsBase,
l2WethBridgeProxyAddress: l2WethBridgeProxyAddressEthIsBase,
} = calculateWethAddresses( l2GovernorAddress, l1WethBridge.address, l1WethAddress, true);
} = calculateWethAddresses(l2GovernorAddress, l1WethBridge.address, l1WethAddress, true);

const {
l2WethProxyAddress: l2WethProxyAddressEthIsNotBase,
l2WethBridgeProxyAddress: l2WethBridgeProxyAddressEthIsNotBase,
} = calculateWethAddresses( l2GovernorAddress, l1WethBridge.address, l1WethAddress, false);
} = calculateWethAddresses(l2GovernorAddress, l1WethBridge.address, l1WethAddress, false);

const tx1 = await l1WethBridge.initialize(
[L2_WETH_BRIDGE_IMPLEMENTATION_BYTECODE, L2_WETH_BRIDGE_PROXY_BYTECODE],
Expand Down Expand Up @@ -158,12 +158,14 @@ export async function startWethBridgeInitOnChain(

// Note governor can not be EOA
const l2GovernorAddress = applyL1ToL2Alias(l1GovernorAddress);

const l1WethAddress = await l1WethBridge.l1WethAddress();
const {
l2WethProxyAddress,
l2WethBridgeProxyAddress,
} = calculateWethAddresses( l2GovernorAddress, l1WethBridge.address, l1WethAddress, ethIsBaseToken);
const { l2WethProxyAddress, l2WethBridgeProxyAddress } = calculateWethAddresses(
l2GovernorAddress,
l1WethBridge.address,
l1WethAddress,
ethIsBaseToken
);

console.log(`CONTRACTS_L2_WETH_BRIDGE_ADDR=${l2WethBridgeProxyAddress}`);
console.log(`CONTRACTS_L2_WETH_TOKEN_PROXY_ADDR=${l2WethProxyAddress}`);
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"types": ["node", "mocha"],
"downlevelIteration": true
}
"downlevelIteration": true,
},
}
4 changes: 2 additions & 2 deletions l2-contracts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"types": ["node", "mocha"],
"downlevelIteration": true
}
"downlevelIteration": true,
},
}

0 comments on commit c300a76

Please sign in to comment.