@matterlabs/zksync-js 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8559,6 +8559,22 @@ function routeEthDirect() {
8559
8559
  var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
8560
8560
  var ZERO_L2_TOKEN_ADDRESS2 = "0x0000000000000000000000000000000000000000";
8561
8561
  var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
8562
+ async function encodeSecondBridgeErc20DepositCalldata(input) {
8563
+ if (!input.ctx.resolvedToken) {
8564
+ return encodeSecondBridgeErc20Args(input.token, input.amount, input.receiver);
8565
+ }
8566
+ const { chainId: l1ChainId } = await input.ctx.client.l1.getNetwork();
8567
+ const isL1Origin = input.ctx.resolvedToken.assetId.toLowerCase() === ZERO_ASSET_ID || input.ctx.resolvedToken.originChainId === 0n || input.ctx.resolvedToken.originChainId === BigInt(l1ChainId);
8568
+ if (isL1Origin) {
8569
+ return encodeSecondBridgeErc20Args(input.token, input.amount, input.receiver);
8570
+ }
8571
+ const transferData = encodeNativeTokenVaultTransferData(
8572
+ input.amount,
8573
+ input.receiver,
8574
+ input.token
8575
+ );
8576
+ return encodeSecondBridgeDataV1(input.ctx.resolvedToken.assetId, transferData);
8577
+ }
8562
8578
  async function getPriorityGasModel(input) {
8563
8579
  try {
8564
8580
  const l1NativeTokenVault = await input.ctx.contracts.l1NativeTokenVault();
@@ -8631,9 +8647,14 @@ function routeErc20NonBase() {
8631
8647
  const secondBridgeCalldata = await wrapAs3(
8632
8648
  "INTERNAL",
8633
8649
  OP_DEPOSITS.nonbase.encodeCalldata,
8634
- () => Promise.resolve(encodeSecondBridgeErc20Args(p.token, p.amount, receiver)),
8650
+ () => encodeSecondBridgeErc20DepositCalldata({
8651
+ ctx,
8652
+ token: p.token,
8653
+ amount: p.amount,
8654
+ receiver
8655
+ }),
8635
8656
  {
8636
- ctx: { where: "encodeSecondBridgeErc20Args" },
8657
+ ctx: { where: "encodeSecondBridgeErc20DepositCalldata" },
8637
8658
  message: "Failed to encode bridging calldata."
8638
8659
  }
8639
8660
  );