Skip to content

Commit

Permalink
fix: fix abi contract cache
Browse files Browse the repository at this point in the history
  • Loading branch information
petarTxFusion committed Jun 6, 2024
1 parent e71f765 commit bcd1607
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/integration/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ class TestEnvironment:


LOCAL_ENV = TestEnvironment(
EnvType.LOCAL_HOST, "http://localhost:15100", "http://127.0.0.1:15045"
EnvType.LOCAL_HOST, "http://localhost:3050", "http://127.0.0.1:8545"
)
4 changes: 2 additions & 2 deletions tests/integration/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def setUp(self) -> None:
self.CONTRACT_ADDRESS = "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049"
self.env = LOCAL_ENV
env_key = EnvPrivateKey("ZKSYNC_KEY1")
self.zksync = ZkSyncBuilder.build("http://127.0.0.1:15100")
self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045"))
self.zksync = ZkSyncBuilder.build("http://127.0.0.1:3050")
self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
self.account: LocalAccount = Account.from_key(env_key.key)
self.wallet = Wallet(self.zksync, self.eth_web3, self.account)
self.zksync_contract = self.eth_web3.eth.contract(
Expand Down
3 changes: 2 additions & 1 deletion zksync2/account/wallet_l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,8 @@ 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
18 changes: 10 additions & 8 deletions zksync2/manage_contracts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
erc_20_abi_cache = None
eth_token_abi_cache = None
test_net_erc_20_abi_cache = None
l1_shared_bridge_abi_cache = None
bridgehub_abi_cache = None


def zksync_abi_default():
Expand Down Expand Up @@ -85,25 +87,25 @@ def l1_bridge_abi_default():


def bridgehub_abi_default():
global l1_bridge_abi_cache
global bridgehub_abi_cache

if l1_bridge_abi_cache is None:
if bridgehub_abi_cache is None:
with pkg_resources.path(contract_abi, "IBridgehub.json") as p:
with p.open(mode="r") as json_file:
data = json.load(json_file)
l1_bridge_abi_cache = data["abi"]
return l1_bridge_abi_cache
bridgehub_abi_cache = data["abi"]
return bridgehub_abi_cache


def l1_shared_bridge_abi_default():
global l1_bridge_abi_cache
global l1_shared_bridge_abi_cache

if l1_bridge_abi_cache is None:
if l1_shared_bridge_abi_cache is None:
with pkg_resources.path(contract_abi, "IL1SharedBridge.json") as p:
with p.open(mode="r") as json_file:
data = json.load(json_file)
l1_bridge_abi_cache = data["abi"]
return l1_bridge_abi_cache
l1_shared_bridge_abi_cache = data["abi"]
return l1_shared_bridge_abi_cache


def eth_token_abi_default():
Expand Down

0 comments on commit bcd1607

Please sign in to comment.