@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,9 +1,9 @@
|
|
|
1
|
-
export { createEthersClient as createClient, createEthersClient } from '../../chunk-
|
|
2
|
-
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-
|
|
3
|
-
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersClient as createClient, createEthersClient } from '../../chunk-24TE2NNJ.js';
|
|
2
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-5HG2DUYW.js';
|
|
3
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-NJK325XV.js';
|
|
4
|
+
import '../../chunk-NLUCYVMX.js';
|
|
5
5
|
import '../../chunk-3HHUZXSV.js';
|
|
6
6
|
import '../../chunk-BWKWWLY4.js';
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
7
|
+
import '../../chunk-JSBMIT4S.js';
|
|
8
|
+
import '../../chunk-UEKFQAOS.js';
|
|
9
9
|
import '../../chunk-MT4X5FEO.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EthersClient } from '../../client';
|
|
2
|
+
import type { Hex } from '../../../../core/types/primitives';
|
|
2
3
|
import type { AttributesResource } from '../../../../core/resources/interop/attributes/resource';
|
|
3
4
|
import type { InteropRoute, InteropPlan, InteropQuote, InteropStatus, InteropFinalizationResult, InteropParams, InteropHandle, InteropWaitable, InteropFinalizationInfo } from '../../../../core/types/flows/interop';
|
|
4
5
|
import type { ContractsResource } from '../contracts';
|
|
@@ -6,7 +7,7 @@ import type { TokensResource } from '../../../../core/types/flows/token';
|
|
|
6
7
|
import type { InteropRouteStrategy } from './routes/types';
|
|
7
8
|
import type { TransactionRequest } from 'ethers';
|
|
8
9
|
import { createInteropFinalizationServices, type InteropFinalizationServices } from './services/finalization';
|
|
9
|
-
import type
|
|
10
|
+
import { type LogsQueryOptions } from './services/finalization/data-fetchers';
|
|
10
11
|
import type { ChainRef, InteropConfig } from './types';
|
|
11
12
|
export declare const ROUTES: Record<InteropRoute, InteropRouteStrategy>;
|
|
12
13
|
export interface InteropResource {
|
|
@@ -57,6 +58,8 @@ export interface InteropResource {
|
|
|
57
58
|
ok: false;
|
|
58
59
|
error: unknown;
|
|
59
60
|
}>;
|
|
61
|
+
getInteropRoot(dstChain: ChainRef, rootChainId: bigint, batchNumber: bigint): Promise<Hex>;
|
|
62
|
+
verifyBundle(dstChain: ChainRef, h: InteropWaitable | InteropFinalizationInfo): Promise<InteropFinalizationResult>;
|
|
60
63
|
}
|
|
61
64
|
export declare function createInteropResource(client: EthersClient, config?: InteropConfig, tokens?: TokensResource, contracts?: ContractsResource, attributes?: AttributesResource): InteropResource;
|
|
62
65
|
export { createInteropFinalizationServices };
|
|
@@ -13,3 +13,7 @@ export declare function executeBundle(client: EthersClient, dstProvider: Abstrac
|
|
|
13
13
|
hash: Hex;
|
|
14
14
|
wait: () => Promise<TransactionReceipt>;
|
|
15
15
|
}>;
|
|
16
|
+
export declare function verifyBundle(client: EthersClient, dstProvider: AbstractProvider, info: InteropFinalizationInfo): Promise<{
|
|
17
|
+
hash: Hex;
|
|
18
|
+
wait: () => Promise<TransactionReceipt>;
|
|
19
|
+
}>;
|
|
@@ -377,6 +377,7 @@ var OP_INTEROP = {
|
|
|
377
377
|
tryWait: "interop.tryWait",
|
|
378
378
|
finalize: "interop.finalize",
|
|
379
379
|
tryFinalize: "interop.tryFinalize",
|
|
380
|
+
verify: "interop.verify",
|
|
380
381
|
context: {
|
|
381
382
|
chainTypeManager: "interop.chainTypeManager",
|
|
382
383
|
protocolVersion: "interop.protocolVersion"
|
|
@@ -7026,7 +7027,7 @@ function routeEthNonBase() {
|
|
|
7026
7027
|
const requestStruct = {
|
|
7027
7028
|
chainId: ctx.chainIdL2,
|
|
7028
7029
|
mintValue,
|
|
7029
|
-
l2Value:
|
|
7030
|
+
l2Value: 0n,
|
|
7030
7031
|
l2GasLimit: l2GasParams.gasLimit,
|
|
7031
7032
|
l2GasPerPubdataByteLimit: ctx.gasPerPubdata,
|
|
7032
7033
|
refundRecipient: ctx.refundRecipient,
|
|
@@ -7034,6 +7035,7 @@ function routeEthNonBase() {
|
|
|
7034
7035
|
secondBridgeValue: p.amount,
|
|
7035
7036
|
secondBridgeCalldata
|
|
7036
7037
|
};
|
|
7038
|
+
const bridgehubValue = p.amount;
|
|
7037
7039
|
const bridgehub = await ctx.contracts.bridgehub();
|
|
7038
7040
|
const data = bridgehub.interface.encodeFunctionData("requestL2TransactionTwoBridges", [
|
|
7039
7041
|
requestStruct
|
|
@@ -7041,8 +7043,7 @@ function routeEthNonBase() {
|
|
|
7041
7043
|
const l1TxCandidate = {
|
|
7042
7044
|
to: ctx.bridgehub,
|
|
7043
7045
|
data,
|
|
7044
|
-
value:
|
|
7045
|
-
// base ≠ ETH ⇒ msg.value == secondBridgeValue
|
|
7046
|
+
value: bridgehubValue,
|
|
7046
7047
|
from: ctx.sender,
|
|
7047
7048
|
...ctx.gasOverrides
|
|
7048
7049
|
};
|
|
@@ -9489,6 +9490,60 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
9489
9490
|
);
|
|
9490
9491
|
}
|
|
9491
9492
|
}
|
|
9493
|
+
async function verifyBundle(client, dstProvider, info) {
|
|
9494
|
+
const signer = await wrap4(OP_INTEROP.verify, () => client.signerFor(dstProvider), {
|
|
9495
|
+
message: "Failed to resolve destination signer for verifyBundle."
|
|
9496
|
+
});
|
|
9497
|
+
const { interopHandler } = await client.ensureAddresses();
|
|
9498
|
+
const handler = new ethers.Contract(interopHandler, IInteropHandler_default, signer);
|
|
9499
|
+
try {
|
|
9500
|
+
const txResponse = await handler.verifyBundle(
|
|
9501
|
+
info.encodedData,
|
|
9502
|
+
info.proof
|
|
9503
|
+
);
|
|
9504
|
+
const hash = txResponse.hash;
|
|
9505
|
+
return {
|
|
9506
|
+
hash,
|
|
9507
|
+
wait: async () => {
|
|
9508
|
+
try {
|
|
9509
|
+
const receipt = await txResponse.wait();
|
|
9510
|
+
if (!receipt || receipt.status !== 1) {
|
|
9511
|
+
throw createError("EXECUTION", {
|
|
9512
|
+
resource: "interop",
|
|
9513
|
+
operation: OP_INTEROP.verify,
|
|
9514
|
+
message: "Interop bundle verification reverted on destination.",
|
|
9515
|
+
context: { txHash: hash }
|
|
9516
|
+
});
|
|
9517
|
+
}
|
|
9518
|
+
return receipt;
|
|
9519
|
+
} catch (e) {
|
|
9520
|
+
if (isZKsyncError(e)) throw e;
|
|
9521
|
+
throw toZKsyncError(
|
|
9522
|
+
"EXECUTION",
|
|
9523
|
+
{
|
|
9524
|
+
resource: "interop",
|
|
9525
|
+
operation: OP_INTEROP.verify,
|
|
9526
|
+
message: "Failed while waiting for verifyBundle transaction on destination.",
|
|
9527
|
+
context: { txHash: hash }
|
|
9528
|
+
},
|
|
9529
|
+
e
|
|
9530
|
+
);
|
|
9531
|
+
}
|
|
9532
|
+
}
|
|
9533
|
+
};
|
|
9534
|
+
} catch (e) {
|
|
9535
|
+
if (isZKsyncError(e)) throw e;
|
|
9536
|
+
throw toZKsyncError(
|
|
9537
|
+
"EXECUTION",
|
|
9538
|
+
{
|
|
9539
|
+
resource: "interop",
|
|
9540
|
+
operation: OP_INTEROP.verify,
|
|
9541
|
+
message: "Failed to send verifyBundle transaction on destination chain."
|
|
9542
|
+
},
|
|
9543
|
+
e
|
|
9544
|
+
);
|
|
9545
|
+
}
|
|
9546
|
+
}
|
|
9492
9547
|
|
|
9493
9548
|
// src/core/resources/interop/finalization.ts
|
|
9494
9549
|
var DEFAULT_POLL_MS = 1e3;
|
|
@@ -10067,6 +10122,28 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
10067
10122
|
}
|
|
10068
10123
|
);
|
|
10069
10124
|
const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
|
|
10125
|
+
const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap6(
|
|
10126
|
+
OP_INTEROP.svc.status.getRoot,
|
|
10127
|
+
() => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),
|
|
10128
|
+
{
|
|
10129
|
+
message: "Failed to get interop root from the destination chain.",
|
|
10130
|
+
ctx: { where: "interop.getInteropRoot" }
|
|
10131
|
+
}
|
|
10132
|
+
);
|
|
10133
|
+
const verifyBundle2 = (dstChain, h) => wrap6(
|
|
10134
|
+
OP_INTEROP.verify,
|
|
10135
|
+
async () => {
|
|
10136
|
+
const dstProvider = resolveChainRef(dstChain);
|
|
10137
|
+
const info = isInteropFinalizationInfo(h) ? h : await svc.wait(dstProvider, getGwProvider(), h);
|
|
10138
|
+
const result = await verifyBundle(client, dstProvider, info);
|
|
10139
|
+
await result.wait();
|
|
10140
|
+
return { bundleHash: info.bundleHash, dstExecTxHash: result.hash };
|
|
10141
|
+
},
|
|
10142
|
+
{
|
|
10143
|
+
message: "Failed to verify interop bundle on destination.",
|
|
10144
|
+
ctx: { where: "interop.verifyBundle" }
|
|
10145
|
+
}
|
|
10146
|
+
);
|
|
10070
10147
|
return {
|
|
10071
10148
|
quote,
|
|
10072
10149
|
tryQuote,
|
|
@@ -10078,7 +10155,9 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
10078
10155
|
wait,
|
|
10079
10156
|
tryWait,
|
|
10080
10157
|
finalize,
|
|
10081
|
-
tryFinalize
|
|
10158
|
+
tryFinalize,
|
|
10159
|
+
getInteropRoot: interopGetRoot,
|
|
10160
|
+
verifyBundle: verifyBundle2
|
|
10082
10161
|
};
|
|
10083
10162
|
}
|
|
10084
10163
|
|