@matterlabs/zksync-js 0.0.15 → 0.0.17
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 +112 -19
- 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 +7 -3
- package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +6 -1
- package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +2 -1
- package/dist/adapters/ethers/sdk.cjs +112 -19
- 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 +121 -21
- 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 +7 -3
- package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +6 -1
- package/dist/adapters/viem/resources/interop/services/finalization/index.d.ts +2 -1
- package/dist/adapters/viem/sdk.cjs +121 -21
- 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-K2UVKMLN.js → chunk-6LYAENO6.js} +4 -7
- package/dist/{chunk-JHRYNLZG.js → chunk-CK5UFAZK.js} +2 -2
- package/dist/{chunk-HGB3DOV2.js → chunk-J2RPWU2R.js} +112 -17
- package/dist/{chunk-MDPX5LNW.js → chunk-JSBMIT4S.js} +1 -1
- package/dist/{chunk-65HAYKVL.js → chunk-NJK325XV.js} +2 -2
- package/dist/{chunk-4PZCNTQ3.js → chunk-ONCNOWNC.js} +121 -19
- 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/resources/deposits/priority.d.ts +1 -1
- package/dist/core/types/errors.d.ts +1 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createEthersClient } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersClient } from '../../chunk-24TE2NNJ.js';
|
|
2
|
+
import '../../chunk-NJK325XV.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';
|
|
@@ -389,6 +389,7 @@ var OP_INTEROP = {
|
|
|
389
389
|
tryWait: "interop.tryWait",
|
|
390
390
|
finalize: "interop.finalize",
|
|
391
391
|
tryFinalize: "interop.tryFinalize",
|
|
392
|
+
verify: "interop.verify",
|
|
392
393
|
context: {
|
|
393
394
|
chainTypeManager: "interop.chainTypeManager",
|
|
394
395
|
protocolVersion: "interop.protocolVersion"
|
|
@@ -8403,8 +8404,8 @@ function buildFeeBreakdown(p) {
|
|
|
8403
8404
|
|
|
8404
8405
|
// src/core/resources/deposits/priority.ts
|
|
8405
8406
|
var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
|
|
8406
|
-
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER =
|
|
8407
|
-
var
|
|
8407
|
+
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 7n;
|
|
8408
|
+
var PRIORITY_L2_GAS_BUFFER = 40n;
|
|
8408
8409
|
var maxBigInt2 = (a, b) => a > b ? a : b;
|
|
8409
8410
|
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
8410
8411
|
function derivePriorityTxGasBreakdown(input) {
|
|
@@ -8432,10 +8433,7 @@ function derivePriorityBodyGasEstimateCap(input) {
|
|
|
8432
8433
|
return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
|
|
8433
8434
|
}
|
|
8434
8435
|
function applyPriorityL2GasLimitBuffer(input) {
|
|
8435
|
-
|
|
8436
|
-
return input.gasLimit;
|
|
8437
|
-
}
|
|
8438
|
-
return input.gasLimit * (100n + ERAVM_PRIORITY_L2_GAS_BUFFER) / 100n;
|
|
8436
|
+
return input.gasLimit * (100n + PRIORITY_L2_GAS_BUFFER) / 100n;
|
|
8439
8437
|
}
|
|
8440
8438
|
var EMPTY_BYTES = "0x";
|
|
8441
8439
|
var ZERO_RESERVED_WORDS = [0n, 0n, 0n, 0n];
|
|
@@ -8944,7 +8942,7 @@ function routeEthNonBase() {
|
|
|
8944
8942
|
const requestStruct = {
|
|
8945
8943
|
chainId: ctx.chainIdL2,
|
|
8946
8944
|
mintValue,
|
|
8947
|
-
l2Value:
|
|
8945
|
+
l2Value: 0n,
|
|
8948
8946
|
l2GasLimit: l2GasParams.gasLimit,
|
|
8949
8947
|
l2GasPerPubdataByteLimit: ctx.gasPerPubdata,
|
|
8950
8948
|
refundRecipient: ctx.refundRecipient,
|
|
@@ -8952,6 +8950,7 @@ function routeEthNonBase() {
|
|
|
8952
8950
|
secondBridgeValue: p.amount,
|
|
8953
8951
|
secondBridgeCalldata
|
|
8954
8952
|
};
|
|
8953
|
+
const bridgehubValue = p.amount;
|
|
8955
8954
|
const bridgehub = await ctx.contracts.bridgehub();
|
|
8956
8955
|
const data = bridgehub.interface.encodeFunctionData("requestL2TransactionTwoBridges", [
|
|
8957
8956
|
requestStruct
|
|
@@ -8959,8 +8958,7 @@ function routeEthNonBase() {
|
|
|
8959
8958
|
const l1TxCandidate = {
|
|
8960
8959
|
to: ctx.bridgehub,
|
|
8961
8960
|
data,
|
|
8962
|
-
value:
|
|
8963
|
-
// base ≠ ETH ⇒ msg.value == secondBridgeValue
|
|
8961
|
+
value: bridgehubValue,
|
|
8964
8962
|
from: ctx.sender,
|
|
8965
8963
|
...ctx.gasOverrides
|
|
8966
8964
|
};
|
|
@@ -11090,13 +11088,23 @@ function routeIndirect() {
|
|
|
11090
11088
|
// src/adapters/ethers/resources/interop/routes/direct.ts
|
|
11091
11089
|
function routeDirect() {
|
|
11092
11090
|
return {
|
|
11093
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
11094
11091
|
async preflight(params, ctx) {
|
|
11095
11092
|
preflightDirect(params, {
|
|
11096
11093
|
dstChainId: ctx.dstChainId,
|
|
11097
11094
|
baseTokens: ctx.baseTokens,
|
|
11098
11095
|
l2AssetRouter: ctx.l2AssetRouter,
|
|
11099
11096
|
l2NativeTokenVault: ctx.l2NativeTokenVault});
|
|
11097
|
+
for (const action of params.actions) {
|
|
11098
|
+
const code = await ctx.dstProvider.getCode(action.to);
|
|
11099
|
+
if (!code || code === "0x") {
|
|
11100
|
+
throw createError("VALIDATION", {
|
|
11101
|
+
resource: "interop",
|
|
11102
|
+
operation: OP_INTEROP.routes.direct.preflight,
|
|
11103
|
+
message: `Destination address ${action.to} is not a contract on the destination chain. The receiver must be a contract that implements the IERC7786Recipient interface (receiveMessage).`,
|
|
11104
|
+
context: { to: action.to, action: action.type }
|
|
11105
|
+
});
|
|
11106
|
+
}
|
|
11107
|
+
}
|
|
11100
11108
|
},
|
|
11101
11109
|
async build(params, ctx) {
|
|
11102
11110
|
const steps = [];
|
|
@@ -11346,7 +11354,7 @@ async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
|
|
|
11346
11354
|
}
|
|
11347
11355
|
return { phase: "SENT" };
|
|
11348
11356
|
}
|
|
11349
|
-
async function executeBundle(client, dstProvider, info, opts) {
|
|
11357
|
+
async function executeBundle(client, dstProvider, info, opts, txOverrides) {
|
|
11350
11358
|
const { topics } = getTopics();
|
|
11351
11359
|
const { bundleHash, encodedData, proof } = info;
|
|
11352
11360
|
const dstStatus = await getBundleStatus(client, dstProvider, topics, bundleHash, opts);
|
|
@@ -11364,7 +11372,11 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
11364
11372
|
const { interopHandler } = await client.ensureAddresses();
|
|
11365
11373
|
const handler = new ethers.Contract(interopHandler, IInteropHandler_default, signer);
|
|
11366
11374
|
try {
|
|
11367
|
-
const txResponse = await handler.executeBundle(
|
|
11375
|
+
const txResponse = await handler.executeBundle(
|
|
11376
|
+
encodedData,
|
|
11377
|
+
proof,
|
|
11378
|
+
txOverrides ?? {}
|
|
11379
|
+
);
|
|
11368
11380
|
const hash = txResponse.hash;
|
|
11369
11381
|
return {
|
|
11370
11382
|
hash,
|
|
@@ -11407,6 +11419,60 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
11407
11419
|
);
|
|
11408
11420
|
}
|
|
11409
11421
|
}
|
|
11422
|
+
async function verifyBundle(client, dstProvider, info) {
|
|
11423
|
+
const signer = await wrap5(OP_INTEROP.verify, () => client.signerFor(dstProvider), {
|
|
11424
|
+
message: "Failed to resolve destination signer for verifyBundle."
|
|
11425
|
+
});
|
|
11426
|
+
const { interopHandler } = await client.ensureAddresses();
|
|
11427
|
+
const handler = new ethers.Contract(interopHandler, IInteropHandler_default, signer);
|
|
11428
|
+
try {
|
|
11429
|
+
const txResponse = await handler.verifyBundle(
|
|
11430
|
+
info.encodedData,
|
|
11431
|
+
info.proof
|
|
11432
|
+
);
|
|
11433
|
+
const hash = txResponse.hash;
|
|
11434
|
+
return {
|
|
11435
|
+
hash,
|
|
11436
|
+
wait: async () => {
|
|
11437
|
+
try {
|
|
11438
|
+
const receipt = await txResponse.wait();
|
|
11439
|
+
if (!receipt || receipt.status !== 1) {
|
|
11440
|
+
throw createError("EXECUTION", {
|
|
11441
|
+
resource: "interop",
|
|
11442
|
+
operation: OP_INTEROP.verify,
|
|
11443
|
+
message: "Interop bundle verification reverted on destination.",
|
|
11444
|
+
context: { txHash: hash }
|
|
11445
|
+
});
|
|
11446
|
+
}
|
|
11447
|
+
return receipt;
|
|
11448
|
+
} catch (e) {
|
|
11449
|
+
if (isZKsyncError(e)) throw e;
|
|
11450
|
+
throw toZKsyncError(
|
|
11451
|
+
"EXECUTION",
|
|
11452
|
+
{
|
|
11453
|
+
resource: "interop",
|
|
11454
|
+
operation: OP_INTEROP.verify,
|
|
11455
|
+
message: "Failed while waiting for verifyBundle transaction on destination.",
|
|
11456
|
+
context: { txHash: hash }
|
|
11457
|
+
},
|
|
11458
|
+
e
|
|
11459
|
+
);
|
|
11460
|
+
}
|
|
11461
|
+
}
|
|
11462
|
+
};
|
|
11463
|
+
} catch (e) {
|
|
11464
|
+
if (isZKsyncError(e)) throw e;
|
|
11465
|
+
throw toZKsyncError(
|
|
11466
|
+
"EXECUTION",
|
|
11467
|
+
{
|
|
11468
|
+
resource: "interop",
|
|
11469
|
+
operation: OP_INTEROP.verify,
|
|
11470
|
+
message: "Failed to send verifyBundle transaction on destination chain."
|
|
11471
|
+
},
|
|
11472
|
+
e
|
|
11473
|
+
);
|
|
11474
|
+
}
|
|
11475
|
+
}
|
|
11410
11476
|
|
|
11411
11477
|
// src/core/resources/interop/finalization.ts
|
|
11412
11478
|
var DEFAULT_POLL_MS = 1e3;
|
|
@@ -11758,8 +11824,8 @@ function createInteropFinalizationServices(client) {
|
|
|
11758
11824
|
wait(dstProvider, gwProvider, input, opts) {
|
|
11759
11825
|
return waitForFinalization(client, dstProvider, gwProvider, input, opts);
|
|
11760
11826
|
},
|
|
11761
|
-
async finalize(dstProvider, info, opts) {
|
|
11762
|
-
const execResult = await executeBundle(client, dstProvider, info, opts);
|
|
11827
|
+
async finalize(dstProvider, info, opts, txOverrides) {
|
|
11828
|
+
const execResult = await executeBundle(client, dstProvider, info, opts, txOverrides);
|
|
11763
11829
|
await execResult.wait();
|
|
11764
11830
|
return {
|
|
11765
11831
|
bundleHash: info.bundleHash,
|
|
@@ -11969,22 +12035,47 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
11969
12035
|
ctx: { where: "interop.wait" }
|
|
11970
12036
|
});
|
|
11971
12037
|
const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
|
|
11972
|
-
const finalize = (dstChain, h, opts) => wrap7(
|
|
12038
|
+
const finalize = (dstChain, h, opts, txOverrides) => wrap7(
|
|
11973
12039
|
OP_INTEROP.finalize,
|
|
11974
12040
|
async () => {
|
|
11975
12041
|
const dstProvider = resolveChainRef(dstChain);
|
|
11976
12042
|
if (isInteropFinalizationInfo(h)) {
|
|
11977
|
-
return svc.finalize(dstProvider, h, opts);
|
|
12043
|
+
return svc.finalize(dstProvider, h, opts, txOverrides);
|
|
11978
12044
|
}
|
|
11979
12045
|
const info = await svc.wait(dstProvider, getGwProvider(), h);
|
|
11980
|
-
return svc.finalize(dstProvider, info, opts);
|
|
12046
|
+
return svc.finalize(dstProvider, info, opts, txOverrides);
|
|
11981
12047
|
},
|
|
11982
12048
|
{
|
|
11983
12049
|
message: "Failed to finalize/execute interop bundle on destination.",
|
|
11984
12050
|
ctx: { where: "interop.finalize" }
|
|
11985
12051
|
}
|
|
11986
12052
|
);
|
|
11987
|
-
const tryFinalize = (dstChain, h, opts
|
|
12053
|
+
const tryFinalize = (dstChain, h, opts, txOverrides) => toResult2(
|
|
12054
|
+
OP_INTEROP.tryFinalize,
|
|
12055
|
+
() => finalize(dstChain, h, opts, txOverrides)
|
|
12056
|
+
);
|
|
12057
|
+
const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap7(
|
|
12058
|
+
OP_INTEROP.svc.status.getRoot,
|
|
12059
|
+
() => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),
|
|
12060
|
+
{
|
|
12061
|
+
message: "Failed to get interop root from the destination chain.",
|
|
12062
|
+
ctx: { where: "interop.getInteropRoot" }
|
|
12063
|
+
}
|
|
12064
|
+
);
|
|
12065
|
+
const verifyBundle2 = (dstChain, h) => wrap7(
|
|
12066
|
+
OP_INTEROP.verify,
|
|
12067
|
+
async () => {
|
|
12068
|
+
const dstProvider = resolveChainRef(dstChain);
|
|
12069
|
+
const info = isInteropFinalizationInfo(h) ? h : await svc.wait(dstProvider, getGwProvider(), h);
|
|
12070
|
+
const result = await verifyBundle(client, dstProvider, info);
|
|
12071
|
+
await result.wait();
|
|
12072
|
+
return { bundleHash: info.bundleHash, dstExecTxHash: result.hash };
|
|
12073
|
+
},
|
|
12074
|
+
{
|
|
12075
|
+
message: "Failed to verify interop bundle on destination.",
|
|
12076
|
+
ctx: { where: "interop.verifyBundle" }
|
|
12077
|
+
}
|
|
12078
|
+
);
|
|
11988
12079
|
return {
|
|
11989
12080
|
quote,
|
|
11990
12081
|
tryQuote,
|
|
@@ -11996,7 +12087,9 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
11996
12087
|
wait,
|
|
11997
12088
|
tryWait,
|
|
11998
12089
|
finalize,
|
|
11999
|
-
tryFinalize
|
|
12090
|
+
tryFinalize,
|
|
12091
|
+
getInteropRoot: interopGetRoot,
|
|
12092
|
+
verifyBundle: verifyBundle2
|
|
12000
12093
|
};
|
|
12001
12094
|
}
|
|
12002
12095
|
|