Skip to content

Commit 1f3b793

Browse files
committed
try fix
1 parent 47402ca commit 1f3b793

File tree

1 file changed

+77
-20
lines changed

1 file changed

+77
-20
lines changed

core/tests/ts-integration/src/context-owner.ts

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -562,27 +562,33 @@ export class TestContextOwner {
562562
}
563563

564564
// Deposit base token on the second chain if it has a custom base token (needed for L2 gas)
565-
if (secondChainBaseTokenAddress && !secondChainEthIsBaseToken) {
566-
const baseTokenDepositHandle = this.secondChainMainSyncWallet!.deposit({
567-
token: secondChainBaseTokenAddress,
568-
amount: l2erc20DepositAmount,
569-
approveERC20: true,
570-
approveBaseERC20: true,
571-
approveBaseOverrides: {
572-
nonce: nonce,
573-
gasPrice
574-
},
575-
overrides: {
576-
nonce: nonce + 1,
577-
gasPrice
578-
}
579-
}).then((tx) => {
580-
this.reporter.debug(`Sent base token deposit on second chain. Hash: ${tx.hash}, nonce: ${tx.nonce}`);
581-
return tx.wait();
582-
});
565+
if (secondChainBaseTokenAddress && !secondChainEthIsBaseToken && ethIsBaseToken) {
566+
const baseTokenToChain1DepositHandle = this.mainSyncWallet
567+
.deposit({
568+
token: secondChainBaseTokenAddress,
569+
amount: l2erc20DepositAmount,
570+
approveERC20: true,
571+
approveBaseERC20: true,
572+
approveBaseOverrides: {
573+
nonce: nonce,
574+
gasPrice
575+
},
576+
overrides: {
577+
nonce: nonce + 1,
578+
gasPrice
579+
}
580+
})
581+
.then((tx) => {
582+
this.reporter.debug(
583+
`Sent second chain base token deposit to first chain. Hash: ${tx.hash}, nonce: ${tx.nonce}`
584+
);
585+
return tx.wait();
586+
});
583587
nonce = nonce + 2;
584-
this.reporter.debug(`Nonce changed by 2 for base token deposit on second chain, new nonce: ${nonce}`);
585-
await baseTokenDepositHandle;
588+
this.reporter.debug(
589+
`Nonce changed by 3 for second chain base token deposit to first chain, new nonce: ${nonce}`
590+
);
591+
await baseTokenToChain1DepositHandle;
586592
}
587593

588594
// Define values for handling ERC20 transfers/deposits.
@@ -660,6 +666,26 @@ export class TestContextOwner {
660666
);
661667

662668
nonce += erc20Transfers.length;
669+
670+
// Send second chain's base token on L1 to test wallets (for interop deposits)
671+
let secondChainBaseTokenL1Transfers: Promise<any>[] = [];
672+
if (
673+
secondChainBaseTokenAddress &&
674+
secondChainBaseTokenAddress !== baseTokenAddress &&
675+
!secondChainEthIsBaseToken
676+
) {
677+
secondChainBaseTokenL1Transfers = await sendTransfers(
678+
secondChainBaseTokenAddress,
679+
this.mainEthersWallet,
680+
wallets,
681+
ERC20_PER_ACCOUNT,
682+
nonce,
683+
gasPrice,
684+
this.reporter
685+
);
686+
nonce += secondChainBaseTokenL1Transfers.length;
687+
}
688+
663689
// Send ERC20 base token on L1.
664690
const baseErc20Transfers = await sendTransfers(
665691
baseTokenAddress,
@@ -674,6 +700,7 @@ export class TestContextOwner {
674700
l1TxPromises.push(erc20DepositPromise);
675701
l1TxPromises.push(...ethTransfers);
676702
l1TxPromises.push(...erc20Transfers);
703+
l1TxPromises.push(...secondChainBaseTokenL1Transfers);
677704
l1TxPromises.push(...baseErc20Transfers);
678705

679706
this.reporter.debug(`Sent ${l1TxPromises.length} initial transactions on L1`);
@@ -727,6 +754,36 @@ export class TestContextOwner {
727754
undefined,
728755
this.reporter
729756
);
757+
758+
// Distribute second chain's base token on chain 1 for interop tests
759+
if (this.env.l2ChainIdSecondChain) {
760+
const bridgehubContract = await this.mainSyncWallet.getBridgehubContract();
761+
const secondChainBaseTokenL1Address = await bridgehubContract.baseToken(this.env.l2ChainIdSecondChain);
762+
const firstChainBaseTokenL1Address = await bridgehubContract.baseToken(this.env.l2ChainId);
763+
764+
// Only distribute if second chain has custom base token AND first chain is ETH-based
765+
if (
766+
secondChainBaseTokenL1Address !== zksync.utils.ETH_ADDRESS_IN_CONTRACTS &&
767+
firstChainBaseTokenL1Address === zksync.utils.ETH_ADDRESS_IN_CONTRACTS
768+
) {
769+
const secondChainBaseTokenL2Address =
770+
await this.mainSyncWallet.l2TokenAddress(secondChainBaseTokenL1Address);
771+
if (secondChainBaseTokenL2Address !== ethers.ZeroAddress) {
772+
const secondChainBaseTokenTransfers = await sendTransfers(
773+
secondChainBaseTokenL2Address,
774+
this.mainSyncWallet,
775+
wallets,
776+
ERC20_PER_ACCOUNT,
777+
l2startNonce,
778+
undefined,
779+
this.reporter
780+
);
781+
l2startNonce += secondChainBaseTokenTransfers.length;
782+
l2TxPromises.push(...secondChainBaseTokenTransfers);
783+
}
784+
}
785+
}
786+
730787
l2TxPromises.push(...l2TxPromisesSecondChain, ...erc20Promises);
731788
await Promise.all(l2TxPromises);
732789

0 commit comments

Comments
 (0)