@matterlabs/zksync-js 0.0.12 → 0.0.14
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.cjs +735 -8
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.js +7 -6
- package/dist/adapters/ethers/index.cjs +1421 -441
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +10 -9
- package/dist/adapters/ethers/resources/deposits/routes/priority.d.ts +12 -0
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +4 -0
- package/dist/adapters/ethers/resources/interop/index.d.ts +14 -14
- package/dist/adapters/ethers/resources/interop/resolvers.d.ts +3 -8
- package/dist/adapters/ethers/resources/interop/routes/types.d.ts +2 -1
- package/dist/adapters/ethers/resources/interop/services/erc20.d.ts +10 -0
- package/dist/adapters/ethers/resources/interop/services/fee.d.ts +12 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +1 -1
- package/dist/adapters/ethers/resources/interop/services/finalization/polling.d.ts +1 -1
- package/dist/adapters/ethers/resources/interop/types.d.ts +6 -14
- package/dist/adapters/ethers/sdk.cjs +3068 -1685
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +6 -1
- package/dist/adapters/ethers/sdk.js +8 -7
- package/dist/adapters/viem/client.cjs +10 -8
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.js +7 -6
- package/dist/adapters/viem/index.cjs +317 -77
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +10 -9
- package/dist/adapters/viem/resources/deposits/routes/priority.d.ts +13 -0
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +4 -0
- package/dist/adapters/viem/sdk.cjs +307 -69
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +7 -7
- package/dist/{chunk-E3KP7XCG.js → chunk-3HHUZXSV.js} +1 -1
- package/dist/{chunk-4PFO3J7W.js → chunk-5RRJDPAJ.js} +10 -2
- package/dist/{chunk-AUN5Y2A3.js → chunk-75IOOODG.js} +253 -53
- package/dist/{chunk-LWA7LC3N.js → chunk-7CAVFIMW.js} +5 -4
- package/dist/chunk-BWKWWLY4.js +9 -0
- package/dist/{chunk-NBQVHW2N.js → chunk-DYJKK5FW.js} +19 -19
- package/dist/{chunk-I5VQBVQ2.js → chunk-EOBXYHTZ.js} +35 -7
- package/dist/{chunk-GMNLOTNG.js → chunk-HP3EWKJL.js} +1 -1
- package/dist/{chunk-IUSH7YBZ.js → chunk-J47RI3G7.js} +1 -1
- package/dist/{chunk-6CLYCJMV.js → chunk-JY62QO3W.js} +759 -22
- package/dist/{chunk-QQ2OR434.js → chunk-MT4X5FEO.js} +18 -2
- package/dist/{chunk-BGUNJK2H.js → chunk-OTXPSNNC.js} +5 -4
- package/dist/{chunk-TE2YQHVI.js → chunk-XDRCN4FC.js} +2 -2
- package/dist/{chunk-6JM4PE62.js → chunk-XKRNLFET.js} +407 -210
- package/dist/core/abi.d.ts +2 -0
- package/dist/core/constants.cjs +17 -1
- package/dist/core/constants.cjs.map +1 -1
- package/dist/core/constants.d.ts +9 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +768 -28
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +6 -5
- package/dist/core/internal/abis/IERC7786Attributes.d.ts +21 -11
- package/dist/core/internal/abis/IInteropCenter.d.ts +4 -0
- package/dist/core/internal/abis/IInteropErrors.d.ts +197 -0
- package/dist/core/internal/abis/IL1ContractErrors.d.ts +1021 -0
- package/dist/core/resources/deposits/priority.d.ts +37 -0
- package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
- package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
- package/dist/core/resources/interop/plan.d.ts +11 -3
- package/dist/core/rpc/types.d.ts +1 -1
- package/dist/core/rpc/zks.d.ts +5 -1
- package/dist/core/types/errors.d.ts +5 -0
- package/dist/core/types/flows/interop.d.ts +11 -18
- package/dist/index.cjs +785 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBridgehub_default } from './chunk-
|
|
2
|
-
import { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES,
|
|
1
|
+
import { IBridgehub_default } from './chunk-JY62QO3W.js';
|
|
2
|
+
import { 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_MEMORY_OVERHEAD_GAS, TX_SLOT_OVERHEAD_L2_GAS, PRIORITY_TX_MAX_GAS_LIMIT, BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, TX_OVERHEAD_GAS } from './chunk-MT4X5FEO.js';
|
|
3
3
|
|
|
4
4
|
// src/core/codec/ntv.ts
|
|
5
5
|
function createNTVCodec(deps) {
|
|
@@ -49,6 +49,36 @@ function buildFeeBreakdown(p) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// src/core/resources/deposits/priority.ts
|
|
53
|
+
var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
|
|
54
|
+
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 6n;
|
|
55
|
+
var maxBigInt = (a, b) => a > b ? a : b;
|
|
56
|
+
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
57
|
+
function derivePriorityTxGasBreakdown(input) {
|
|
58
|
+
const factoryDepsCount = input.factoryDepsCount ?? 0n;
|
|
59
|
+
const minBodyGas = maxBigInt(
|
|
60
|
+
L1_TX_INTRINSIC_L2_GAS + ceilDiv(
|
|
61
|
+
input.encodedLength * L1_TX_DELTA_544_ENCODING_BYTES,
|
|
62
|
+
PRIORITY_TX_ENCODING_STEP_BYTES
|
|
63
|
+
) + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_L2_GAS,
|
|
64
|
+
L1_TX_MIN_L2_GAS_BASE
|
|
65
|
+
) + L1_TX_INTRINSIC_PUBDATA * input.gasPerPubdata + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_PUBDATA * input.gasPerPubdata;
|
|
66
|
+
const overhead = maxBigInt(TX_SLOT_OVERHEAD_L2_GAS, TX_MEMORY_OVERHEAD_GAS * input.encodedLength);
|
|
67
|
+
const derivedBodyGas = minBodyGas;
|
|
68
|
+
return {
|
|
69
|
+
encodedLength: input.encodedLength,
|
|
70
|
+
minBodyGas,
|
|
71
|
+
overhead,
|
|
72
|
+
derivedBodyGas,
|
|
73
|
+
derivedL2GasLimit: derivedBodyGas + overhead,
|
|
74
|
+
priorityTxMaxGasLimit: PRIORITY_TX_MAX_GAS_LIMIT,
|
|
75
|
+
priorityTxMaxGasLimitExceeded: derivedBodyGas > PRIORITY_TX_MAX_GAS_LIMIT
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function derivePriorityBodyGasEstimateCap(input) {
|
|
79
|
+
return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
|
|
80
|
+
}
|
|
81
|
+
|
|
52
82
|
// src/core/resources/deposits/gas.ts
|
|
53
83
|
function makeGasQuote(p) {
|
|
54
84
|
const maxPriorityFeePerGas = p.maxPriorityFeePerGas ?? 0n;
|
|
@@ -102,11 +132,10 @@ async function quoteL1Gas(input) {
|
|
|
102
132
|
const est = await estimator.estimateGas(tx);
|
|
103
133
|
const buffered = BigInt(est) * (100n + BUFFER) / 100n;
|
|
104
134
|
return makeGasQuote({ gasLimit: buffered, maxFeePerGas, maxPriorityFeePerGas });
|
|
105
|
-
} catch
|
|
135
|
+
} catch {
|
|
106
136
|
if (fallbackGasLimit != null) {
|
|
107
137
|
return makeGasQuote({ gasLimit: fallbackGasLimit, maxFeePerGas, maxPriorityFeePerGas });
|
|
108
138
|
}
|
|
109
|
-
console.warn("L1 gas estimation failed", err);
|
|
110
139
|
return void 0;
|
|
111
140
|
}
|
|
112
141
|
}
|
|
@@ -144,8 +173,7 @@ async function quoteL2Gas(input) {
|
|
|
144
173
|
maxFeePerGas,
|
|
145
174
|
gasPerPubdata: pp
|
|
146
175
|
});
|
|
147
|
-
} catch
|
|
148
|
-
console.warn("L2 gas estimation failed", err);
|
|
176
|
+
} catch {
|
|
149
177
|
return makeGasQuote({
|
|
150
178
|
gasLimit: l2GasLimit ?? 0n,
|
|
151
179
|
maxFeePerGas,
|
|
@@ -234,4 +262,4 @@ async function quoteL2Gas2(input) {
|
|
|
234
262
|
}
|
|
235
263
|
}
|
|
236
264
|
|
|
237
|
-
export { buildFeeBreakdown, createNTVCodec, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, toGasOverrides };
|
|
265
|
+
export { buildFeeBreakdown, createNTVCodec, derivePriorityBodyGasEstimateCap, derivePriorityTxGasBreakdown, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, toGasOverrides };
|