@matterlabs/zksync-js 0.0.23 → 0.0.25
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 +155 -82
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +7 -7
- package/dist/adapters/ethers/resources/deposits/services/fee.d.ts +1 -0
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +9 -2
- package/dist/adapters/ethers/sdk.cjs +155 -91
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +6 -6
- package/dist/adapters/viem/client.js +4 -4
- package/dist/adapters/viem/index.cjs +182 -122
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +7 -7
- package/dist/adapters/viem/resources/deposits/services/fee.d.ts +1 -0
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +9 -2
- package/dist/adapters/viem/sdk.cjs +182 -135
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +6 -6
- package/dist/{chunk-4GPIHYVF.js → chunk-4ZANKNIK.js} +1 -1
- package/dist/{chunk-JJ523MOL.js → chunk-BQ2YCWV2.js} +1 -1
- package/dist/{chunk-4M7VNYGC.js → chunk-H5A6GU3D.js} +2 -2
- package/dist/{chunk-2DDJFHHD.js → chunk-JNS4XZE2.js} +1 -1
- package/dist/{chunk-WPCZNITC.js → chunk-JWN26CQ6.js} +31 -11
- package/dist/{chunk-V2TDNGI5.js → chunk-N5E4FLBF.js} +127 -74
- package/dist/{chunk-NVOFHV3A.js → chunk-NFRRRT5X.js} +155 -120
- package/dist/{chunk-URHDNDFN.js → chunk-PNTR5FTL.js} +2 -2
- package/dist/{chunk-TUN6NH5D.js → chunk-RZH7HBH3.js} +2 -2
- package/dist/{chunk-6WIAMFIW.js → chunk-YEA74D2L.js} +2 -2
- package/dist/{chunk-X2JJDQ4O.js → chunk-YGXEIOK6.js} +1 -1
- package/dist/core/index.js +3 -3
- package/dist/core/resources/deposits/gas.d.ts +11 -1
- package/dist/core/types/errors.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { createViemSdk } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
export { createViemSdk } from '../../chunk-NFRRRT5X.js';
|
|
2
|
+
import '../../chunk-JWN26CQ6.js';
|
|
3
|
+
import '../../chunk-BQ2YCWV2.js';
|
|
4
4
|
import '../../chunk-OEUDZFXH.js';
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
5
|
+
import '../../chunk-H5A6GU3D.js';
|
|
6
|
+
import '../../chunk-4ZANKNIK.js';
|
|
7
|
+
import '../../chunk-JNS4XZE2.js';
|
|
8
8
|
import '../../chunk-3IPSDGHO.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertNever, createError, OP_WITHDRAWALS } from './chunk-
|
|
1
|
+
import { assertNever, createError, OP_WITHDRAWALS } from './chunk-JNS4XZE2.js';
|
|
2
2
|
import { L2_INTEROP_CENTER_ADDRESS, L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS, BUNDLE_IDENTIFIER } from './chunk-3IPSDGHO.js';
|
|
3
3
|
import { keccak_256 } from '@noble/hashes/sha3';
|
|
4
4
|
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createErrorOps, REVERT_TO_READINESS } from './chunk-
|
|
2
|
-
import { IL1Nullifier_default, IERC20_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default, IL1ContractErrors_default, IInteropErrors_default } from './chunk-
|
|
1
|
+
import { createErrorOps, REVERT_TO_READINESS } from './chunk-4ZANKNIK.js';
|
|
2
|
+
import { IL1Nullifier_default, IERC20_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default, IL1ContractErrors_default, IInteropErrors_default } from './chunk-JNS4XZE2.js';
|
|
3
3
|
import { decodeErrorResult } from 'viem';
|
|
4
4
|
|
|
5
5
|
var ERROR_ABIS = [];
|
|
@@ -7252,7 +7252,7 @@ var OP_DEPOSITS = {
|
|
|
7252
7252
|
baseCost: "deposits.eth-nonbase:l2TransactionBaseCost",
|
|
7253
7253
|
allowanceBase: "deposits.eth-nonbase:allowanceBaseToken",
|
|
7254
7254
|
ethBalance: "deposits.eth-nonbase:getEthBalance",
|
|
7255
|
-
encodeCalldata: "deposits.eth-nonbase:
|
|
7255
|
+
encodeCalldata: "deposits.eth-nonbase:encodeSecondBridgeEthDepositCalldata",
|
|
7256
7256
|
estGas: "deposits.eth-nonbase:estimateGas",
|
|
7257
7257
|
assertEthAsset: "deposits.eth-nonbase:assertEthAsset",
|
|
7258
7258
|
assertNonEthBase: "deposits.eth-nonbase:assertNonEthBase",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isL1MessageSentLog } from './chunk-OEUDZFXH.js';
|
|
2
|
-
import { IBridgehub_default, isHash66, isBigint, isHash, assertNever, createError, OP_INTEROP, isNumber, isAddress, isHash66Array } from './chunk-
|
|
2
|
+
import { IBridgehub_default, isHash66, isBigint, isHash, assertNever, createError, OP_INTEROP, isNumber, isAddress, isHash66Array } from './chunk-JNS4XZE2.js';
|
|
3
3
|
import { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, TX_MEMORY_OVERHEAD_GAS, TX_OVERHEAD_GAS, L1_TX_MIN_L2_GAS_BASE, L1_TX_INTRINSIC_L2_GAS, L1_TX_DELTA_544_ENCODING_BYTES, L1_TX_DELTA_FACTORY_DEPS_L2_GAS, L1_TX_INTRINSIC_PUBDATA, L1_TX_DELTA_FACTORY_DEPS_PUBDATA, TX_SLOT_OVERHEAD_L2_GAS, PRIORITY_TX_MAX_GAS_LIMIT, REGISTERED_TOKEN_BRIDGE_MINT_EXECUTION_GAS, REGISTERED_TOKEN_BRIDGE_MINT_PUBDATA_BYTES, L2_INTEROP_CENTER_ADDRESS, BUNDLE_IDENTIFIER, L1_TX_INTRINSIC_PUBDATA_ZKSYNC_OS, L1_TX_NATIVE_PER_GAS, MAX_NATIVE_COMPUTATIONAL_ZKSYNC_OS, L1_TX_INTRINSIC_L2_GAS_ZKSYNC_OS, L1_TX_CALLDATA_FLOOR_PRICE_L2_GAS_ZKSYNC_OS } from './chunk-3IPSDGHO.js';
|
|
4
4
|
|
|
5
5
|
// src/core/resources/deposits/chains.ts
|
|
@@ -10,6 +10,7 @@ function isEraVmChain(chainIdL2) {
|
|
|
10
10
|
|
|
11
11
|
// src/core/resources/deposits/gas.ts
|
|
12
12
|
var CREATE_REESTIMATE_BUFFER = 15n;
|
|
13
|
+
var ZERO_FEES = { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
|
|
13
14
|
var maxBigInt = (a, b) => a > b ? a : b;
|
|
14
15
|
function applyGasBuffer(gasLimit, bufferPct = BUFFER) {
|
|
15
16
|
return gasLimit * (100n + bufferPct) / 100n;
|
|
@@ -60,15 +61,39 @@ async function fetchFees(estimator) {
|
|
|
60
61
|
const gp = await estimator.getGasPrice();
|
|
61
62
|
return { maxFeePerGas: gp, maxPriorityFeePerGas: 0n };
|
|
62
63
|
} catch {
|
|
63
|
-
return
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function quoteL1Fees(input) {
|
|
68
|
+
const { estimator, overrides } = input;
|
|
69
|
+
const maxFeeOverride = overrides?.maxFeePerGas;
|
|
70
|
+
const tipOverride = overrides?.maxPriorityFeePerGas;
|
|
71
|
+
if (maxFeeOverride != null && tipOverride != null) {
|
|
72
|
+
return { maxFeePerGas: maxFeeOverride, maxPriorityFeePerGas: tipOverride };
|
|
73
|
+
}
|
|
74
|
+
const market = await fetchFees(estimator);
|
|
75
|
+
if (maxFeeOverride != null) {
|
|
76
|
+
const tip = market?.maxPriorityFeePerGas ?? 0n;
|
|
77
|
+
return {
|
|
78
|
+
maxFeePerGas: maxFeeOverride,
|
|
79
|
+
maxPriorityFeePerGas: tip < maxFeeOverride ? tip : maxFeeOverride
|
|
80
|
+
};
|
|
64
81
|
}
|
|
82
|
+
if (market == null) {
|
|
83
|
+
throw new Error("Could not fetch L1 gas price for Bridgehub base cost calculation.");
|
|
84
|
+
}
|
|
85
|
+
if (tipOverride != null) {
|
|
86
|
+
const headroom = market.maxFeePerGas > market.maxPriorityFeePerGas ? market.maxFeePerGas - market.maxPriorityFeePerGas : 0n;
|
|
87
|
+
return { maxFeePerGas: headroom + tipOverride, maxPriorityFeePerGas: tipOverride };
|
|
88
|
+
}
|
|
89
|
+
return market;
|
|
65
90
|
}
|
|
66
91
|
async function quoteL1Gas(input) {
|
|
67
92
|
const { estimator, tx, overrides, fallbackGasLimit } = input;
|
|
68
93
|
let market;
|
|
69
94
|
const getMarket = async () => {
|
|
70
95
|
if (market) return market;
|
|
71
|
-
market = await fetchFees(estimator);
|
|
96
|
+
market = await fetchFees(estimator) ?? ZERO_FEES;
|
|
72
97
|
return market;
|
|
73
98
|
};
|
|
74
99
|
const maxFeePerGas = overrides?.maxFeePerGas ?? (tx.maxFeePerGas != null ? BigInt(tx.maxFeePerGas) : (await getMarket()).maxFeePerGas);
|
|
@@ -90,7 +115,7 @@ async function quoteL1Gas(input) {
|
|
|
90
115
|
}
|
|
91
116
|
async function quoteL2Gas(input) {
|
|
92
117
|
const { estimator, route, tx, gasPerPubdata, l2GasLimit, overrideGasLimit, stateOverrides } = input;
|
|
93
|
-
const market = await fetchFees(estimator);
|
|
118
|
+
const market = await fetchFees(estimator) ?? ZERO_FEES;
|
|
94
119
|
const maxFeePerGas = market.maxFeePerGas || market.maxPriorityFeePerGas || 0n;
|
|
95
120
|
const txGasLimit = tx?.gasLimit != null ? BigInt(tx.gasLimit) : void 0;
|
|
96
121
|
const explicit = overrideGasLimit ?? txGasLimit;
|
|
@@ -131,12 +156,7 @@ async function quoteL2Gas(input) {
|
|
|
131
156
|
}
|
|
132
157
|
}
|
|
133
158
|
async function quoteL2BaseCost(input) {
|
|
134
|
-
const { estimator, encode, bridgehub, chainIdL2, l2GasLimit, gasPerPubdata } = input;
|
|
135
|
-
const market = await fetchFees(estimator);
|
|
136
|
-
const l1GasPrice = market.maxFeePerGas || market.maxPriorityFeePerGas || 0n;
|
|
137
|
-
if (l1GasPrice === 0n) {
|
|
138
|
-
throw new Error("Could not fetch L1 gas price for Bridgehub base cost calculation.");
|
|
139
|
-
}
|
|
159
|
+
const { estimator, encode, bridgehub, chainIdL2, l2GasLimit, gasPerPubdata, l1GasPrice } = input;
|
|
140
160
|
const data = encode(IBridgehub_default, "l2TransactionBaseCost", [
|
|
141
161
|
chainIdL2,
|
|
142
162
|
l1GasPrice,
|
|
@@ -682,4 +702,4 @@ async function quoteL2Gas2(input) {
|
|
|
682
702
|
}
|
|
683
703
|
}
|
|
684
704
|
|
|
685
|
-
export { DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, ZERO_HASH, applyL1ToL2Alias, applyPriorityL2GasLimitBuffer, assertProtocolVersion, buildDirectBundle, buildFeeBreakdown, buildFinalizationInfo, buildIndirectBundle, clampPriorityL2GasLimit, createAttributesResource, createNTVCodec, derivePriorityBodyGasEstimateCap, derivePriorityTxGasBreakdown, isInteropFinalizationInfo, parseBundleReceiptInfo, parseBundleSentFromReceipt, pickInteropRoute, preflightDirect, preflightIndirect, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, resolveCreateDepositL1GasLimit, resolveIdsFromWaitable, resolveRegisteredTokenPriorityL2GasLimit, toGasOverrides };
|
|
705
|
+
export { DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, ZERO_HASH, applyL1ToL2Alias, applyPriorityL2GasLimitBuffer, assertProtocolVersion, buildDirectBundle, buildFeeBreakdown, buildFinalizationInfo, buildIndirectBundle, clampPriorityL2GasLimit, createAttributesResource, createNTVCodec, derivePriorityBodyGasEstimateCap, derivePriorityTxGasBreakdown, isInteropFinalizationInfo, parseBundleReceiptInfo, parseBundleSentFromReceipt, pickInteropRoute, preflightDirect, preflightIndirect, quoteL1Fees, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, resolveCreateDepositL1GasLimit, resolveIdsFromWaitable, resolveRegisteredTokenPriorityL2GasLimit, toGasOverrides };
|