Skip to content

Commit

Permalink
chore: lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
petarTxFusion committed Jun 6, 2024
1 parent 3fb4876 commit f10165b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
17 changes: 11 additions & 6 deletions tests/integration/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ def test_prepare_deposit_transaction_token(self):

transaction = self.wallet.prepare_deposit_tx(
DepositTransaction(
token=l1_address, amount=5, refund_recipient=self.wallet.address, approve_erc20=True
token=l1_address,
amount=5,
refund_recipient=self.wallet.address,
approve_erc20=True,
)
)

Expand Down Expand Up @@ -806,7 +809,9 @@ def test_withdraw_eth_paymaster(self):

paymaster_balance_before = self.zksync.zksync.zks_get_balance(paymaster_address)
paymaster_token_balance_before = self.zksync.zksync.zks_get_balance(
paymaster_address, token_address=token_address, block_tag=ZkBlockParams.LATEST
paymaster_address,
token_address=token_address,
block_tag=ZkBlockParams.LATEST,
)

sender_balance_before = self.wallet.get_balance()
Expand Down Expand Up @@ -847,7 +852,9 @@ def test_withdraw_eth_paymaster(self):
)
paymaster_balance_after = self.zksync.zksync.zks_get_balance(paymaster_address)
paymaster_token_balance_after = self.zksync.zksync.zks_get_balance(
paymaster_address, token_address=token_address, block_tag=ZkBlockParams.LATEST
paymaster_address,
token_address=token_address,
block_tag=ZkBlockParams.LATEST,
)
sender_balance_after = self.wallet.get_balance()
sender_approval_token_balance_after = self.wallet.get_balance(
Expand All @@ -858,9 +865,7 @@ def test_withdraw_eth_paymaster(self):
self.assertEqual(
paymaster_token_balance_after - paymaster_token_balance_before, 1
)
self.assertEqual(
sender_balance_before - sender_balance_after, amount
)
self.assertEqual(sender_balance_before - sender_balance_after, amount)
self.assertEqual(
sender_approval_token_balance_after,
sender_approval_token_balance_before - 1,
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/test_zksync_web3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
ADDRESS_DEFAULT,
StorageProof,
)
from zksync2.core.utils import pad_front_bytes, to_bytes, pad_back_bytes, L2_BASE_TOKEN_ADDRESS
from zksync2.core.utils import (
pad_front_bytes,
to_bytes,
pad_back_bytes,
L2_BASE_TOKEN_ADDRESS,
)
from zksync2.manage_contracts.contract_encoder_base import (
ContractEncoder,
JsonConfiguration,
Expand Down Expand Up @@ -768,9 +773,6 @@ def test_contract_factory(self):
def test_get_all_account_balances(self):
balances = self.web3.zksync.zks_get_all_account_balances(self.account.address)

# @skip("Integration test, used for develop purposes only")
def test_get_token_price(self):
price = self.web3.zksync.zks_get_token_price(self.ETH_TOKEN.l2_address)

# @skip("Integration test, used for develop purposes only")
def test_get_l1_chain_id(self):
Expand Down
9 changes: 7 additions & 2 deletions zksync2/account/wallet_l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,12 @@ def finalize_withdrawal(self, withdraw_hash, index: int = 0):
nonce=self._eth_web3.eth.get_transaction_count(self.address),
)

shared_bridge = self.get_l1_bridge_contracts().shared
shared_bridge_address = (
self._zksync_web3.zksync.zks_get_bridge_contracts().shared_l1_default_bridge
)
shared_bridge = self._eth_web3.eth.contract(
address=shared_bridge_address, abi=l1_shared_bridge_abi_default()
)
tx = shared_bridge.functions.finalizeWithdrawal(
self._zksync_web3.eth.chain_id,
params["l1_batch_number"],
Expand Down Expand Up @@ -1189,7 +1194,7 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0):
abi=l1_shared_bridge_abi_default(),
)

return l1_bridge.functions.isWithdrawalFinalizedShared(
return l1_bridge.functions.isWithdrawalFinalizedShared(
self._zksync_web3.eth.chain_id, int(log["l1BatchNumber"], 16), proof.id
).call()

Expand Down
10 changes: 7 additions & 3 deletions zksync2/account/wallet_l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def transfer(self, tx: TransferTransaction) -> HexStr:
)

if tx.options.gas_limit is None or tx.options.gas_limit == 0:
tx.options.gas_limit = self._zksync_web3.zksync.eth_estimate_gas(tx_fun_call.tx)
tx.options.gas_limit = self._zksync_web3.zksync.eth_estimate_gas(
tx_fun_call.tx
)

tx_712 = tx_fun_call.tx712(tx.options.gas_limit)
signer = PrivateKeyEthSigner(self._l1_account, tx.options.chain_id)
Expand All @@ -123,9 +125,11 @@ def withdraw(self, tx: WithdrawTransaction):
tx, from_=self._l1_account.address
)
if tx.options.gas_limit is None:
transaction.tx['gas'] = self._zksync_web3.zksync.eth_estimate_gas(transaction.tx)
transaction.tx["gas"] = self._zksync_web3.zksync.eth_estimate_gas(
transaction.tx
)
else:
transaction.tx['gas'] = tx.options.gas_limit
transaction.tx["gas"] = tx.options.gas_limit
tx_712 = transaction.tx712()
signer = PrivateKeyEthSigner(self._l1_account, self._zksync_web3.eth.chain_id)
signed_message = signer.sign_typed_data(tx_712.to_eip712_struct())
Expand Down
2 changes: 1 addition & 1 deletion zksync2/module/zksync_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def get_withdraw_transaction(
token=tx.token,
bridge_address=tx.bridge_address,
from_=from_,
paymaster_params=tx.paymaster_params
paymaster_params=tx.paymaster_params,
)

return transaction
Expand Down

0 comments on commit f10165b

Please sign in to comment.