@matterlabs/zksync-js 0.0.16 → 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/index.cjs +29 -15
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +2 -2
- package/dist/adapters/ethers/resources/interop/index.d.ts +3 -2
- package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +2 -1
- package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +2 -1
- package/dist/adapters/ethers/sdk.cjs +29 -15
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +2 -2
- package/dist/adapters/viem/index.cjs +28 -15
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +2 -2
- package/dist/adapters/viem/resources/interop/index.d.ts +3 -2
- package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +2 -1
- package/dist/adapters/viem/resources/interop/services/finalization/index.d.ts +2 -1
- package/dist/adapters/viem/sdk.cjs +28 -15
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +2 -2
- package/dist/{chunk-NLUCYVMX.js → chunk-6LYAENO6.js} +3 -6
- package/dist/{chunk-5HG2DUYW.js → chunk-J2RPWU2R.js} +27 -10
- package/dist/{chunk-3KH5PCD6.js → chunk-ONCNOWNC.js} +26 -10
- package/dist/core/resources/deposits/priority.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createViemSdk } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { createViemSdk } from '../../chunk-ONCNOWNC.js';
|
|
2
|
+
import '../../chunk-6LYAENO6.js';
|
|
3
3
|
import '../../chunk-3HHUZXSV.js';
|
|
4
4
|
import '../../chunk-SBGBYZJM.js';
|
|
5
5
|
import '../../chunk-JSBMIT4S.js';
|
|
@@ -237,8 +237,8 @@ function buildFeeBreakdown(p) {
|
|
|
237
237
|
|
|
238
238
|
// src/core/resources/deposits/priority.ts
|
|
239
239
|
var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
|
|
240
|
-
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER =
|
|
241
|
-
var
|
|
240
|
+
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 7n;
|
|
241
|
+
var PRIORITY_L2_GAS_BUFFER = 40n;
|
|
242
242
|
var maxBigInt2 = (a, b) => a > b ? a : b;
|
|
243
243
|
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
244
244
|
function derivePriorityTxGasBreakdown(input) {
|
|
@@ -266,10 +266,7 @@ function derivePriorityBodyGasEstimateCap(input) {
|
|
|
266
266
|
return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
|
|
267
267
|
}
|
|
268
268
|
function applyPriorityL2GasLimitBuffer(input) {
|
|
269
|
-
|
|
270
|
-
return input.gasLimit;
|
|
271
|
-
}
|
|
272
|
-
return input.gasLimit * (100n + ERAVM_PRIORITY_L2_GAS_BUFFER) / 100n;
|
|
269
|
+
return input.gasLimit * (100n + PRIORITY_L2_GAS_BUFFER) / 100n;
|
|
273
270
|
}
|
|
274
271
|
|
|
275
272
|
// src/core/resources/interop/attributes/call.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-NJK325XV.js';
|
|
2
|
-
import { createNTVCodec, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL2BaseCost, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-
|
|
2
|
+
import { createNTVCodec, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL2BaseCost, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-6LYAENO6.js';
|
|
3
3
|
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-3HHUZXSV.js';
|
|
4
4
|
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, OP_INTEROP, IInteropHandler_default, IERC7786Attributes_default, IInteropRootStorage_default, IInteropCenter_default, sleep, isETH, normalizeAddrEq, IL2AssetRouter_default, L2NativeTokenVault_default, assertNever } from './chunk-UEKFQAOS.js';
|
|
5
5
|
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_INTEROP_ROOT_STORAGE_ADDRESS, BUFFER, SAFE_L1_BRIDGE_GAS, L2_ASSET_ROUTER_ADDRESS, FORMAL_ETH_ADDRESS } from './chunk-MT4X5FEO.js';
|
|
@@ -2646,7 +2646,6 @@ function routeIndirect() {
|
|
|
2646
2646
|
// src/adapters/ethers/resources/interop/routes/direct.ts
|
|
2647
2647
|
function routeDirect() {
|
|
2648
2648
|
return {
|
|
2649
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
2650
2649
|
async preflight(params, ctx) {
|
|
2651
2650
|
preflightDirect(params, {
|
|
2652
2651
|
dstChainId: ctx.dstChainId,
|
|
@@ -2655,6 +2654,17 @@ function routeDirect() {
|
|
|
2655
2654
|
l2NativeTokenVault: ctx.l2NativeTokenVault,
|
|
2656
2655
|
codec: interopCodec
|
|
2657
2656
|
});
|
|
2657
|
+
for (const action of params.actions) {
|
|
2658
|
+
const code = await ctx.dstProvider.getCode(action.to);
|
|
2659
|
+
if (!code || code === "0x") {
|
|
2660
|
+
throw createError("VALIDATION", {
|
|
2661
|
+
resource: "interop",
|
|
2662
|
+
operation: OP_INTEROP.routes.direct.preflight,
|
|
2663
|
+
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).`,
|
|
2664
|
+
context: { to: action.to, action: action.type }
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2658
2668
|
},
|
|
2659
2669
|
async build(params, ctx) {
|
|
2660
2670
|
const steps = [];
|
|
@@ -2885,7 +2895,7 @@ async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
|
|
|
2885
2895
|
}
|
|
2886
2896
|
return { phase: "SENT" };
|
|
2887
2897
|
}
|
|
2888
|
-
async function executeBundle(client, dstProvider, info, opts) {
|
|
2898
|
+
async function executeBundle(client, dstProvider, info, opts, txOverrides) {
|
|
2889
2899
|
const { topics } = getTopics();
|
|
2890
2900
|
const { bundleHash, encodedData, proof } = info;
|
|
2891
2901
|
const dstStatus = await getBundleStatus(client, dstProvider, topics, bundleHash, opts);
|
|
@@ -2903,7 +2913,11 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
2903
2913
|
const { interopHandler } = await client.ensureAddresses();
|
|
2904
2914
|
const handler = new Contract(interopHandler, IInteropHandler_default, signer);
|
|
2905
2915
|
try {
|
|
2906
|
-
const txResponse = await handler.executeBundle(
|
|
2916
|
+
const txResponse = await handler.executeBundle(
|
|
2917
|
+
encodedData,
|
|
2918
|
+
proof,
|
|
2919
|
+
txOverrides ?? {}
|
|
2920
|
+
);
|
|
2907
2921
|
const hash = txResponse.hash;
|
|
2908
2922
|
return {
|
|
2909
2923
|
hash,
|
|
@@ -3219,8 +3233,8 @@ function createInteropFinalizationServices(client) {
|
|
|
3219
3233
|
wait(dstProvider, gwProvider, input, opts) {
|
|
3220
3234
|
return waitForFinalization(client, dstProvider, gwProvider, input, opts);
|
|
3221
3235
|
},
|
|
3222
|
-
async finalize(dstProvider, info, opts) {
|
|
3223
|
-
const execResult = await executeBundle(client, dstProvider, info, opts);
|
|
3236
|
+
async finalize(dstProvider, info, opts, txOverrides) {
|
|
3237
|
+
const execResult = await executeBundle(client, dstProvider, info, opts, txOverrides);
|
|
3224
3238
|
await execResult.wait();
|
|
3225
3239
|
return {
|
|
3226
3240
|
bundleHash: info.bundleHash,
|
|
@@ -3430,22 +3444,25 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
3430
3444
|
ctx: { where: "interop.wait" }
|
|
3431
3445
|
});
|
|
3432
3446
|
const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
|
|
3433
|
-
const finalize = (dstChain, h, opts) => wrap6(
|
|
3447
|
+
const finalize = (dstChain, h, opts, txOverrides) => wrap6(
|
|
3434
3448
|
OP_INTEROP.finalize,
|
|
3435
3449
|
async () => {
|
|
3436
3450
|
const dstProvider = resolveChainRef(dstChain);
|
|
3437
3451
|
if (isInteropFinalizationInfo(h)) {
|
|
3438
|
-
return svc.finalize(dstProvider, h, opts);
|
|
3452
|
+
return svc.finalize(dstProvider, h, opts, txOverrides);
|
|
3439
3453
|
}
|
|
3440
3454
|
const info = await svc.wait(dstProvider, getGwProvider(), h);
|
|
3441
|
-
return svc.finalize(dstProvider, info, opts);
|
|
3455
|
+
return svc.finalize(dstProvider, info, opts, txOverrides);
|
|
3442
3456
|
},
|
|
3443
3457
|
{
|
|
3444
3458
|
message: "Failed to finalize/execute interop bundle on destination.",
|
|
3445
3459
|
ctx: { where: "interop.finalize" }
|
|
3446
3460
|
}
|
|
3447
3461
|
);
|
|
3448
|
-
const tryFinalize = (dstChain, h, opts
|
|
3462
|
+
const tryFinalize = (dstChain, h, opts, txOverrides) => toResult2(
|
|
3463
|
+
OP_INTEROP.tryFinalize,
|
|
3464
|
+
() => finalize(dstChain, h, opts, txOverrides)
|
|
3465
|
+
);
|
|
3449
3466
|
const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap6(
|
|
3450
3467
|
OP_INTEROP.svc.status.getRoot,
|
|
3451
3468
|
() => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createNTVCodec, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-
|
|
1
|
+
import { createNTVCodec, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-6LYAENO6.js';
|
|
2
2
|
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-3HHUZXSV.js';
|
|
3
3
|
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-SBGBYZJM.js';
|
|
4
4
|
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, OP_INTEROP, IInteropHandler_default, IInteropRootStorage_default, IInteropCenter_default, sleep, IERC7786Attributes_default, IBridgehub_default, isETH, normalizeAddrEq, L2NativeTokenVault_default, IL2AssetRouter_default, IBaseToken_default, assertNever } from './chunk-UEKFQAOS.js';
|
|
@@ -3101,7 +3101,6 @@ function routeIndirect() {
|
|
|
3101
3101
|
}
|
|
3102
3102
|
function routeDirect() {
|
|
3103
3103
|
return {
|
|
3104
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
3105
3104
|
async preflight(params, ctx) {
|
|
3106
3105
|
preflightDirect(params, {
|
|
3107
3106
|
dstChainId: ctx.dstChainId,
|
|
@@ -3110,6 +3109,17 @@ function routeDirect() {
|
|
|
3110
3109
|
l2NativeTokenVault: ctx.l2NativeTokenVault,
|
|
3111
3110
|
codec: interopCodec
|
|
3112
3111
|
});
|
|
3112
|
+
for (const action of params.actions) {
|
|
3113
|
+
const bytecode = await ctx.dstPublicClient.getCode({ address: action.to });
|
|
3114
|
+
if (!bytecode || bytecode === "0x") {
|
|
3115
|
+
throw createError("VALIDATION", {
|
|
3116
|
+
resource: "interop",
|
|
3117
|
+
operation: OP_INTEROP.routes.direct.preflight,
|
|
3118
|
+
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).`,
|
|
3119
|
+
context: { to: action.to, action: action.type }
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3113
3123
|
},
|
|
3114
3124
|
async build(params, ctx) {
|
|
3115
3125
|
const steps = [];
|
|
@@ -3352,7 +3362,7 @@ async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
|
|
|
3352
3362
|
}
|
|
3353
3363
|
return { phase: "SENT" };
|
|
3354
3364
|
}
|
|
3355
|
-
async function executeBundle(client, dstProvider, info, opts) {
|
|
3365
|
+
async function executeBundle(client, dstProvider, info, opts, txOverrides) {
|
|
3356
3366
|
const { topics } = getTopics();
|
|
3357
3367
|
const { bundleHash, encodedData, proof } = info;
|
|
3358
3368
|
const dstStatus = await getBundleStatus(client, dstProvider, topics, bundleHash, opts);
|
|
@@ -3381,7 +3391,10 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
3381
3391
|
functionName: "executeBundle",
|
|
3382
3392
|
args: [encodedData, proof],
|
|
3383
3393
|
account: client.account,
|
|
3384
|
-
chain: dstProvider.chain ?? null
|
|
3394
|
+
chain: dstProvider.chain ?? null,
|
|
3395
|
+
gas: txOverrides?.gasLimit,
|
|
3396
|
+
maxFeePerGas: txOverrides?.maxFeePerGas,
|
|
3397
|
+
maxPriorityFeePerGas: txOverrides?.maxPriorityFeePerGas
|
|
3385
3398
|
});
|
|
3386
3399
|
return {
|
|
3387
3400
|
hash,
|
|
@@ -3706,8 +3719,8 @@ function createInteropFinalizationServices(client) {
|
|
|
3706
3719
|
wait(dstProvider, gwProvider, input, opts) {
|
|
3707
3720
|
return waitForFinalization(client, dstProvider, gwProvider, input, opts);
|
|
3708
3721
|
},
|
|
3709
|
-
async finalize(dstProvider, info, opts) {
|
|
3710
|
-
const execResult = await executeBundle(client, dstProvider, info, opts);
|
|
3722
|
+
async finalize(dstProvider, info, opts, txOverrides) {
|
|
3723
|
+
const execResult = await executeBundle(client, dstProvider, info, opts, txOverrides);
|
|
3711
3724
|
await execResult.wait();
|
|
3712
3725
|
return {
|
|
3713
3726
|
bundleHash: info.bundleHash,
|
|
@@ -3935,22 +3948,25 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
3935
3948
|
ctx: { where: "interop.wait" }
|
|
3936
3949
|
});
|
|
3937
3950
|
const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
|
|
3938
|
-
const finalize = (dstChain, h, opts) => wrap6(
|
|
3951
|
+
const finalize = (dstChain, h, opts, txOverrides) => wrap6(
|
|
3939
3952
|
OP_INTEROP.finalize,
|
|
3940
3953
|
async () => {
|
|
3941
3954
|
const dstProvider = resolveChainRef(dstChain);
|
|
3942
3955
|
if (isInteropFinalizationInfo(h)) {
|
|
3943
|
-
return svc.finalize(dstProvider, h, opts);
|
|
3956
|
+
return svc.finalize(dstProvider, h, opts, txOverrides);
|
|
3944
3957
|
}
|
|
3945
3958
|
const info = await svc.wait(dstProvider, getGwProvider(), h);
|
|
3946
|
-
return svc.finalize(dstProvider, info, opts);
|
|
3959
|
+
return svc.finalize(dstProvider, info, opts, txOverrides);
|
|
3947
3960
|
},
|
|
3948
3961
|
{
|
|
3949
3962
|
message: "Failed to finalize/execute interop bundle on destination.",
|
|
3950
3963
|
ctx: { where: "interop.finalize" }
|
|
3951
3964
|
}
|
|
3952
3965
|
);
|
|
3953
|
-
const tryFinalize = (dstChain, h, opts
|
|
3966
|
+
const tryFinalize = (dstChain, h, opts, txOverrides) => toResult2(
|
|
3967
|
+
OP_INTEROP.tryFinalize,
|
|
3968
|
+
() => finalize(dstChain, h, opts, txOverrides)
|
|
3969
|
+
);
|
|
3954
3970
|
const interopGetRoot = (dstChain, rootChainId, batchNumber) => wrap6(
|
|
3955
3971
|
OP_INTEROP.svc.status.getRoot,
|
|
3956
3972
|
() => getInteropRoot(resolveChainRef(dstChain), rootChainId, batchNumber),
|
|
@@ -8,7 +8,7 @@ export type PriorityTxGasBreakdown = {
|
|
|
8
8
|
priorityTxMaxGasLimit: bigint;
|
|
9
9
|
priorityTxMaxGasLimitExceeded: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare const DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER =
|
|
11
|
+
export declare const DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 7n;
|
|
12
12
|
export declare function applyL1ToL2Alias(address: Address): Address;
|
|
13
13
|
/**
|
|
14
14
|
* Mirrors the priority-tx floor math used by ZKsync's TransactionValidator.
|