@matterlabs/zksync-js 0.0.15 → 0.0.16
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.
- package/dist/adapters/ethers/client.js +4 -4
- package/dist/adapters/ethers/index.cjs +83 -4
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +6 -6
- package/dist/adapters/ethers/resources/interop/index.d.ts +4 -1
- package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +4 -0
- package/dist/adapters/ethers/sdk.cjs +83 -4
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +5 -5
- package/dist/adapters/viem/client.js +4 -4
- package/dist/adapters/viem/index.cjs +93 -6
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +6 -6
- package/dist/adapters/viem/resources/interop/index.d.ts +4 -1
- package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +4 -0
- package/dist/adapters/viem/sdk.cjs +93 -6
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +5 -5
- package/dist/{chunk-MZBKM3GH.js → chunk-24TE2NNJ.js} +2 -2
- package/dist/{chunk-4PZCNTQ3.js → chunk-3KH5PCD6.js} +96 -10
- package/dist/{chunk-HGB3DOV2.js → chunk-5HG2DUYW.js} +86 -8
- package/dist/{chunk-JHRYNLZG.js → chunk-CK5UFAZK.js} +2 -2
- package/dist/{chunk-MDPX5LNW.js → chunk-JSBMIT4S.js} +1 -1
- package/dist/{chunk-65HAYKVL.js → chunk-NJK325XV.js} +2 -2
- package/dist/{chunk-K2UVKMLN.js → chunk-NLUCYVMX.js} +1 -1
- package/dist/{chunk-YIWXIP2M.js → chunk-SBGBYZJM.js} +2 -2
- package/dist/{chunk-HVHMLAYH.js → chunk-TYYUG5GA.js} +1 -1
- package/dist/{chunk-JXR5V5YK.js → chunk-UEKFQAOS.js} +1 -0
- package/dist/core/index.js +2 -2
- package/dist/core/types/errors.d.ts +1 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createEthersSdk } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersSdk } from '../../chunk-5HG2DUYW.js';
|
|
2
|
+
import '../../chunk-NJK325XV.js';
|
|
3
|
+
import '../../chunk-NLUCYVMX.js';
|
|
4
4
|
import '../../chunk-3HHUZXSV.js';
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
5
|
+
import '../../chunk-JSBMIT4S.js';
|
|
6
|
+
import '../../chunk-UEKFQAOS.js';
|
|
7
7
|
import '../../chunk-MT4X5FEO.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createViemClient } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { createViemClient } from '../../chunk-CK5UFAZK.js';
|
|
2
|
+
import '../../chunk-SBGBYZJM.js';
|
|
3
3
|
import '../../chunk-BWKWWLY4.js';
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
4
|
+
import '../../chunk-JSBMIT4S.js';
|
|
5
|
+
import '../../chunk-UEKFQAOS.js';
|
|
6
6
|
import '../../chunk-MT4X5FEO.js';
|
|
@@ -391,6 +391,7 @@ var OP_INTEROP = {
|
|
|
391
391
|
tryWait: "interop.tryWait",
|
|
392
392
|
finalize: "interop.finalize",
|
|
393
393
|
tryFinalize: "interop.tryFinalize",
|
|
394
|
+
verify: "interop.verify",
|
|
394
395
|
context: {
|
|
395
396
|
chainTypeManager: "interop.chainTypeManager",
|
|
396
397
|
protocolVersion: "interop.protocolVersion"
|
|
@@ -8666,7 +8667,7 @@ function routeEthNonBase() {
|
|
|
8666
8667
|
const requestStruct = {
|
|
8667
8668
|
chainId: ctx.chainIdL2,
|
|
8668
8669
|
mintValue,
|
|
8669
|
-
l2Value:
|
|
8670
|
+
l2Value: 0n,
|
|
8670
8671
|
l2GasLimit: l2Gas.gasLimit,
|
|
8671
8672
|
l2GasPerPubdataByteLimit: ctx.gasPerPubdata,
|
|
8672
8673
|
refundRecipient: ctx.refundRecipient,
|
|
@@ -8674,6 +8675,7 @@ function routeEthNonBase() {
|
|
|
8674
8675
|
secondBridgeValue: p.amount,
|
|
8675
8676
|
secondBridgeCalldata
|
|
8676
8677
|
};
|
|
8678
|
+
const bridgehubValue = p.amount;
|
|
8677
8679
|
let bridgeTx;
|
|
8678
8680
|
let calldata;
|
|
8679
8681
|
if (needsApprove) {
|
|
@@ -8682,8 +8684,7 @@ function routeEthNonBase() {
|
|
|
8682
8684
|
abi: IBridgehub_default,
|
|
8683
8685
|
functionName: "requestL2TransactionTwoBridges",
|
|
8684
8686
|
args: [requestStruct],
|
|
8685
|
-
value:
|
|
8686
|
-
// base ≠ ETH ⇒ msg.value == secondBridgeValue
|
|
8687
|
+
value: bridgehubValue,
|
|
8687
8688
|
account: ctx.client.account
|
|
8688
8689
|
};
|
|
8689
8690
|
calldata = viem.encodeFunctionData({
|
|
@@ -8700,7 +8701,7 @@ function routeEthNonBase() {
|
|
|
8700
8701
|
abi: IBridgehub_default,
|
|
8701
8702
|
functionName: "requestL2TransactionTwoBridges",
|
|
8702
8703
|
args: [requestStruct],
|
|
8703
|
-
value:
|
|
8704
|
+
value: bridgehubValue,
|
|
8704
8705
|
account: ctx.client.account
|
|
8705
8706
|
}),
|
|
8706
8707
|
{
|
|
@@ -8718,7 +8719,7 @@ function routeEthNonBase() {
|
|
|
8718
8719
|
const l1TxCandidate = {
|
|
8719
8720
|
to: ctx.bridgehub,
|
|
8720
8721
|
data: calldata,
|
|
8721
|
-
value:
|
|
8722
|
+
value: bridgehubValue,
|
|
8722
8723
|
from: ctx.sender,
|
|
8723
8724
|
...ctx.gasOverrides
|
|
8724
8725
|
};
|
|
@@ -11492,6 +11493,68 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
11492
11493
|
);
|
|
11493
11494
|
}
|
|
11494
11495
|
}
|
|
11496
|
+
async function verifyBundle(client, dstProvider, info) {
|
|
11497
|
+
const { interopHandler } = await client.ensureAddresses();
|
|
11498
|
+
const dstWallet = await wrap5(
|
|
11499
|
+
OP_INTEROP.verify,
|
|
11500
|
+
() => viem.createWalletClient({
|
|
11501
|
+
account: client.account,
|
|
11502
|
+
transport: viem.custom(dstProvider.transport),
|
|
11503
|
+
chain: dstProvider.chain
|
|
11504
|
+
}),
|
|
11505
|
+
{ message: "Failed to create destination wallet client for verifyBundle." }
|
|
11506
|
+
);
|
|
11507
|
+
try {
|
|
11508
|
+
const hash = await dstWallet.writeContract({
|
|
11509
|
+
address: interopHandler,
|
|
11510
|
+
abi: IInteropHandler_default,
|
|
11511
|
+
functionName: "verifyBundle",
|
|
11512
|
+
args: [info.encodedData, info.proof],
|
|
11513
|
+
account: client.account,
|
|
11514
|
+
chain: dstProvider.chain ?? null
|
|
11515
|
+
});
|
|
11516
|
+
return {
|
|
11517
|
+
hash,
|
|
11518
|
+
wait: async () => {
|
|
11519
|
+
try {
|
|
11520
|
+
const receipt = await dstProvider.waitForTransactionReceipt({ hash });
|
|
11521
|
+
if (receipt.status === "reverted") {
|
|
11522
|
+
throw createError("EXECUTION", {
|
|
11523
|
+
resource: "interop",
|
|
11524
|
+
operation: OP_INTEROP.verify,
|
|
11525
|
+
message: "Interop bundle verification reverted on destination.",
|
|
11526
|
+
context: { txHash: hash }
|
|
11527
|
+
});
|
|
11528
|
+
}
|
|
11529
|
+
return receipt;
|
|
11530
|
+
} catch (e) {
|
|
11531
|
+
if (isZKsyncError(e)) throw e;
|
|
11532
|
+
throw toZKsyncError(
|
|
11533
|
+
"EXECUTION",
|
|
11534
|
+
{
|
|
11535
|
+
resource: "interop",
|
|
11536
|
+
operation: OP_INTEROP.verify,
|
|
11537
|
+
message: "Failed while waiting for verifyBundle transaction on destination.",
|
|
11538
|
+
context: { txHash: hash }
|
|
11539
|
+
},
|
|
11540
|
+
e
|
|
11541
|
+
);
|
|
11542
|
+
}
|
|
11543
|
+
}
|
|
11544
|
+
};
|
|
11545
|
+
} catch (e) {
|
|
11546
|
+
if (isZKsyncError(e)) throw e;
|
|
11547
|
+
throw toZKsyncError(
|
|
11548
|
+
"EXECUTION",
|
|
11549
|
+
{
|
|
11550
|
+
resource: "interop",
|
|
11551
|
+
operation: OP_INTEROP.verify,
|
|
11552
|
+
message: "Failed to send verifyBundle transaction on destination chain."
|
|
11553
|
+
},
|
|
11554
|
+
e
|
|
11555
|
+
);
|
|
11556
|
+
}
|
|
11557
|
+
}
|
|
11495
11558
|
|
|
11496
11559
|
// src/core/resources/interop/finalization.ts
|
|
11497
11560
|
var DEFAULT_POLL_MS = 1e3;
|
|
@@ -12089,6 +12152,28 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
12089
12152
|
}
|
|
12090
12153
|
);
|
|
12091
12154
|
const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
|
|
12155
|
+
const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap7(
|
|
12156
|
+
OP_INTEROP.svc.status.getRoot,
|
|
12157
|
+
() => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),
|
|
12158
|
+
{
|
|
12159
|
+
message: "Failed to get interop root from the destination chain.",
|
|
12160
|
+
ctx: { where: "interop.getInteropRoot" }
|
|
12161
|
+
}
|
|
12162
|
+
);
|
|
12163
|
+
const verifyBundle2 = (dstChain, h) => wrap7(
|
|
12164
|
+
OP_INTEROP.verify,
|
|
12165
|
+
async () => {
|
|
12166
|
+
const dstProvider = resolveChainRef(dstChain);
|
|
12167
|
+
const info = isInteropFinalizationInfo(h) ? h : await svc.wait(dstProvider, getGwProvider(), h);
|
|
12168
|
+
const result = await verifyBundle(client, dstProvider, info);
|
|
12169
|
+
await result.wait();
|
|
12170
|
+
return { bundleHash: info.bundleHash, dstExecTxHash: result.hash };
|
|
12171
|
+
},
|
|
12172
|
+
{
|
|
12173
|
+
message: "Failed to verify interop bundle on destination.",
|
|
12174
|
+
ctx: { where: "interop.verifyBundle" }
|
|
12175
|
+
}
|
|
12176
|
+
);
|
|
12092
12177
|
return {
|
|
12093
12178
|
quote,
|
|
12094
12179
|
tryQuote,
|
|
@@ -12100,7 +12185,9 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
12100
12185
|
wait,
|
|
12101
12186
|
tryWait,
|
|
12102
12187
|
finalize,
|
|
12103
|
-
tryFinalize
|
|
12188
|
+
tryFinalize,
|
|
12189
|
+
getInteropRoot: interopGetRoot,
|
|
12190
|
+
verifyBundle: verifyBundle2
|
|
12104
12191
|
};
|
|
12105
12192
|
}
|
|
12106
12193
|
|