@matterlabs/zksync-js 0.0.21 → 0.0.23
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 +31 -8
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +11 -0
- package/dist/adapters/ethers/client.js +6 -5
- package/dist/adapters/ethers/index.cjs +1194 -364
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.d.ts +2 -1
- package/dist/adapters/ethers/index.js +10 -8
- package/dist/adapters/ethers/resources/deposits/context.d.ts +2 -0
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +3 -0
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +12 -1
- package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
- package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
- package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
- package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
- package/dist/adapters/ethers/sdk.cjs +1166 -370
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +3 -1
- package/dist/adapters/ethers/sdk.js +8 -7
- package/dist/adapters/viem/client.cjs +44 -7
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +11 -0
- package/dist/adapters/viem/client.js +6 -5
- package/dist/adapters/viem/index.cjs +1237 -383
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +2 -1
- package/dist/adapters/viem/index.js +10 -8
- package/dist/adapters/viem/resources/deposits/context.d.ts +2 -0
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +3 -0
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
- package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
- package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
- package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
- package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
- package/dist/adapters/viem/sdk.cjs +1191 -385
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +3 -1
- package/dist/adapters/viem/sdk.js +8 -7
- package/dist/{chunk-UEKFQAOS.js → chunk-2DDJFHHD.js} +304 -9
- package/dist/{chunk-MT4X5FEO.js → chunk-3IPSDGHO.js} +19 -1
- package/dist/{chunk-JSBMIT4S.js → chunk-4GPIHYVF.js} +1 -1
- package/dist/{chunk-SBGBYZJM.js → chunk-4M7VNYGC.js} +2 -2
- package/dist/{chunk-CK5UFAZK.js → chunk-6WIAMFIW.js} +37 -3
- package/dist/chunk-JJ523MOL.js +157 -0
- package/dist/{chunk-7GZDTLHX.js → chunk-NVOFHV3A.js} +666 -304
- package/dist/{chunk-LGTYM5XP.js → chunk-OEUDZFXH.js} +1 -1
- package/dist/{chunk-NJK325XV.js → chunk-TUN6NH5D.js} +2 -2
- package/dist/chunk-UMPAKZCQ.js +19 -0
- package/dist/{chunk-24TE2NNJ.js → chunk-URHDNDFN.js} +24 -4
- package/dist/{chunk-2CGBLD5H.js → chunk-V2TDNGI5.js} +642 -288
- package/dist/{chunk-IDXSGCGF.js → chunk-WPCZNITC.js} +63 -50
- package/dist/{chunk-TYYUG5GA.js → chunk-X2JJDQ4O.js} +1 -1
- package/dist/core/abi.d.ts +1 -0
- package/dist/core/adapters/interfaces.d.ts +2 -0
- package/dist/core/constants.cjs +18 -0
- package/dist/core/constants.cjs.map +1 -1
- package/dist/core/constants.d.ts +17 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +504 -7
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +6 -1
- package/dist/core/index.js +6 -4
- package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
- package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
- package/dist/core/internal/abis/IL2AssetRouter.d.ts +0 -14
- package/dist/core/resources/deposits/priority.d.ts +30 -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/protocol/semver.d.ts +18 -0
- package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
- package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
- package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
- package/dist/core/types/flows/withdrawals.d.ts +30 -0
- package/dist/index.cjs +320 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L2_BASE_TOKEN_ADDRESS, L1_MESSENGER_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L1_SOPH_TOKEN_ADDRESS, } from './constants';
|
|
1
|
+
export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L2_BASE_TOKEN_ADDRESS, L1_MESSENGER_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS, } from './constants';
|
|
2
2
|
export * as abi from './abi';
|
|
3
3
|
export * as errors from './errors/factory';
|
|
4
4
|
export { formatEnvelopePretty } from './errors/formatter';
|
|
@@ -9,6 +9,11 @@ export * from './utils/addr';
|
|
|
9
9
|
export * from './utils/hash';
|
|
10
10
|
export * from './resources/deposits/route';
|
|
11
11
|
export * from './resources/withdrawals/route';
|
|
12
|
+
export * from './resources/withdrawals/protocol';
|
|
13
|
+
export * from './resources/withdrawals/status';
|
|
14
|
+
export * from './resources/withdrawals/bundle';
|
|
15
|
+
export * from './resources/withdrawals/finalization';
|
|
16
|
+
export * from './resources/protocol/semver';
|
|
12
17
|
export * from './utils/events';
|
|
13
18
|
export * from './resources/withdrawals/logs';
|
|
14
19
|
export type * from './types';
|
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { pickDepositRoute } from '../chunk-
|
|
2
|
-
export {
|
|
1
|
+
export { pickDepositRoute } from '../chunk-X2JJDQ4O.js';
|
|
2
|
+
export { BundleStatus, CallStatus, MIN_INTEROP_WITHDRAWAL_MINOR, buildWithdrawalBundle, buildWithdrawalFinalization, classifyWithdrawalOutcome, detectWithdrawalProtocol, isBundleFinalized, keccakHex, parseBundleHashFromLogs, phaseFromReadiness, protocolFromVersion, stripBundleIdentifier, withdrawalBundleSalt } from '../chunk-JJ523MOL.js';
|
|
3
|
+
export { findL1MessageSentLog, isL1MessageSentLog, l1MessageSentSender, messengerLogIndex, pickWithdrawRoute } from '../chunk-OEUDZFXH.js';
|
|
4
|
+
export { SEMVER_MAJOR_OFFSET, SEMVER_MINOR_OFFSET, formatProtocolVersion, packSemver, unpackSemver } from '../chunk-UMPAKZCQ.js';
|
|
3
5
|
export { makeTransportFromEthers, makeTransportFromViem } from '../chunk-BWKWWLY4.js';
|
|
4
|
-
export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token, zks_exports as zksRpc } from '../chunk-
|
|
5
|
-
export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L1_MESSENGER_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS } from '../chunk-
|
|
6
|
+
export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token, zks_exports as zksRpc } from '../chunk-2DDJFHHD.js';
|
|
7
|
+
export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L1_MESSENGER_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS } from '../chunk-3IPSDGHO.js';
|
|
@@ -28,6 +28,16 @@ declare const IERC7786AttributesABI: readonly [{
|
|
|
28
28
|
}];
|
|
29
29
|
readonly outputs: readonly [];
|
|
30
30
|
readonly stateMutability: "pure";
|
|
31
|
+
}, {
|
|
32
|
+
readonly type: "function";
|
|
33
|
+
readonly name: "interopBundleSalt";
|
|
34
|
+
readonly inputs: readonly [{
|
|
35
|
+
readonly name: "_salt";
|
|
36
|
+
readonly type: "bytes32";
|
|
37
|
+
readonly internalType: "bytes32";
|
|
38
|
+
}];
|
|
39
|
+
readonly outputs: readonly [];
|
|
40
|
+
readonly stateMutability: "pure";
|
|
31
41
|
}, {
|
|
32
42
|
readonly type: "function";
|
|
33
43
|
readonly name: "unbundlerAddress";
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
declare const IL1NullifierV32ABI: readonly [{
|
|
2
|
+
readonly anonymous: false;
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly indexed: true;
|
|
5
|
+
readonly internalType: "uint256";
|
|
6
|
+
readonly name: "chainId";
|
|
7
|
+
readonly type: "uint256";
|
|
8
|
+
}, {
|
|
9
|
+
readonly indexed: true;
|
|
10
|
+
readonly internalType: "bytes32";
|
|
11
|
+
readonly name: "txDataHash";
|
|
12
|
+
readonly type: "bytes32";
|
|
13
|
+
}, {
|
|
14
|
+
readonly indexed: true;
|
|
15
|
+
readonly internalType: "bytes32";
|
|
16
|
+
readonly name: "l2DepositTxHash";
|
|
17
|
+
readonly type: "bytes32";
|
|
18
|
+
}];
|
|
19
|
+
readonly name: "BridgehubDepositFinalized";
|
|
20
|
+
readonly type: "event";
|
|
21
|
+
}, {
|
|
22
|
+
readonly inputs: readonly [];
|
|
23
|
+
readonly name: "BRIDGE_HUB";
|
|
24
|
+
readonly outputs: readonly [{
|
|
25
|
+
readonly internalType: "contract IL1Bridgehub";
|
|
26
|
+
readonly name: "";
|
|
27
|
+
readonly type: "address";
|
|
28
|
+
}];
|
|
29
|
+
readonly stateMutability: "view";
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
}, {
|
|
32
|
+
readonly inputs: readonly [];
|
|
33
|
+
readonly name: "l1AssetRouter";
|
|
34
|
+
readonly outputs: readonly [{
|
|
35
|
+
readonly internalType: "contract IL1AssetRouter";
|
|
36
|
+
readonly name: "";
|
|
37
|
+
readonly type: "address";
|
|
38
|
+
}];
|
|
39
|
+
readonly stateMutability: "view";
|
|
40
|
+
readonly type: "function";
|
|
41
|
+
}, {
|
|
42
|
+
readonly inputs: readonly [];
|
|
43
|
+
readonly name: "l1InteropHandler";
|
|
44
|
+
readonly outputs: readonly [{
|
|
45
|
+
readonly internalType: "address";
|
|
46
|
+
readonly name: "";
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
}];
|
|
49
|
+
readonly stateMutability: "view";
|
|
50
|
+
readonly type: "function";
|
|
51
|
+
}, {
|
|
52
|
+
readonly inputs: readonly [];
|
|
53
|
+
readonly name: "l1NativeTokenVault";
|
|
54
|
+
readonly outputs: readonly [{
|
|
55
|
+
readonly internalType: "contract IL1NativeTokenVault";
|
|
56
|
+
readonly name: "";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
}];
|
|
59
|
+
readonly stateMutability: "view";
|
|
60
|
+
readonly type: "function";
|
|
61
|
+
}, {
|
|
62
|
+
readonly inputs: readonly [{
|
|
63
|
+
readonly internalType: "uint256";
|
|
64
|
+
readonly name: "_chainId";
|
|
65
|
+
readonly type: "uint256";
|
|
66
|
+
}, {
|
|
67
|
+
readonly internalType: "bytes32";
|
|
68
|
+
readonly name: "_l2TxHash";
|
|
69
|
+
readonly type: "bytes32";
|
|
70
|
+
}];
|
|
71
|
+
readonly name: "depositHappened";
|
|
72
|
+
readonly outputs: readonly [{
|
|
73
|
+
readonly internalType: "bytes32";
|
|
74
|
+
readonly name: "";
|
|
75
|
+
readonly type: "bytes32";
|
|
76
|
+
}];
|
|
77
|
+
readonly stateMutability: "view";
|
|
78
|
+
readonly type: "function";
|
|
79
|
+
}, {
|
|
80
|
+
readonly inputs: readonly [{
|
|
81
|
+
readonly internalType: "uint256";
|
|
82
|
+
readonly name: "_chainId";
|
|
83
|
+
readonly type: "uint256";
|
|
84
|
+
}, {
|
|
85
|
+
readonly internalType: "bytes32";
|
|
86
|
+
readonly name: "_txDataHash";
|
|
87
|
+
readonly type: "bytes32";
|
|
88
|
+
}, {
|
|
89
|
+
readonly internalType: "bytes32";
|
|
90
|
+
readonly name: "_txHash";
|
|
91
|
+
readonly type: "bytes32";
|
|
92
|
+
}];
|
|
93
|
+
readonly name: "bridgehubConfirmL2TransactionForwarded";
|
|
94
|
+
readonly outputs: readonly [];
|
|
95
|
+
readonly stateMutability: "nonpayable";
|
|
96
|
+
readonly type: "function";
|
|
97
|
+
}, {
|
|
98
|
+
readonly inputs: readonly [{
|
|
99
|
+
readonly components: readonly [{
|
|
100
|
+
readonly internalType: "uint256";
|
|
101
|
+
readonly name: "_chainId";
|
|
102
|
+
readonly type: "uint256";
|
|
103
|
+
}, {
|
|
104
|
+
readonly internalType: "address";
|
|
105
|
+
readonly name: "_depositSender";
|
|
106
|
+
readonly type: "address";
|
|
107
|
+
}, {
|
|
108
|
+
readonly internalType: "uint16";
|
|
109
|
+
readonly name: "_l2TxNumberInBatch";
|
|
110
|
+
readonly type: "uint16";
|
|
111
|
+
}, {
|
|
112
|
+
readonly internalType: "enum TxStatus";
|
|
113
|
+
readonly name: "_txStatus";
|
|
114
|
+
readonly type: "uint8";
|
|
115
|
+
}, {
|
|
116
|
+
readonly internalType: "bytes32";
|
|
117
|
+
readonly name: "_assetId";
|
|
118
|
+
readonly type: "bytes32";
|
|
119
|
+
}, {
|
|
120
|
+
readonly internalType: "bytes";
|
|
121
|
+
readonly name: "_assetData";
|
|
122
|
+
readonly type: "bytes";
|
|
123
|
+
}, {
|
|
124
|
+
readonly internalType: "bytes32";
|
|
125
|
+
readonly name: "_l2TxHash";
|
|
126
|
+
readonly type: "bytes32";
|
|
127
|
+
}, {
|
|
128
|
+
readonly internalType: "uint256";
|
|
129
|
+
readonly name: "_l2BatchNumber";
|
|
130
|
+
readonly type: "uint256";
|
|
131
|
+
}, {
|
|
132
|
+
readonly internalType: "uint256";
|
|
133
|
+
readonly name: "_l2MessageIndex";
|
|
134
|
+
readonly type: "uint256";
|
|
135
|
+
}, {
|
|
136
|
+
readonly internalType: "bytes32[]";
|
|
137
|
+
readonly name: "_merkleProof";
|
|
138
|
+
readonly type: "bytes32[]";
|
|
139
|
+
}];
|
|
140
|
+
readonly internalType: "struct ConfirmTransferResultData";
|
|
141
|
+
readonly name: "_confirmTransferResultData";
|
|
142
|
+
readonly type: "tuple";
|
|
143
|
+
}];
|
|
144
|
+
readonly name: "bridgeConfirmTransferResult";
|
|
145
|
+
readonly outputs: readonly [];
|
|
146
|
+
readonly stateMutability: "nonpayable";
|
|
147
|
+
readonly type: "function";
|
|
148
|
+
}, {
|
|
149
|
+
readonly inputs: readonly [{
|
|
150
|
+
readonly internalType: "uint256";
|
|
151
|
+
readonly name: "_chainId";
|
|
152
|
+
readonly type: "uint256";
|
|
153
|
+
}, {
|
|
154
|
+
readonly internalType: "address";
|
|
155
|
+
readonly name: "_depositSender";
|
|
156
|
+
readonly type: "address";
|
|
157
|
+
}, {
|
|
158
|
+
readonly internalType: "bytes32";
|
|
159
|
+
readonly name: "_assetId";
|
|
160
|
+
readonly type: "bytes32";
|
|
161
|
+
}, {
|
|
162
|
+
readonly internalType: "bytes";
|
|
163
|
+
readonly name: "_assetData";
|
|
164
|
+
readonly type: "bytes";
|
|
165
|
+
}, {
|
|
166
|
+
readonly internalType: "bytes32";
|
|
167
|
+
readonly name: "_l2TxHash";
|
|
168
|
+
readonly type: "bytes32";
|
|
169
|
+
}, {
|
|
170
|
+
readonly internalType: "uint256";
|
|
171
|
+
readonly name: "_l2BatchNumber";
|
|
172
|
+
readonly type: "uint256";
|
|
173
|
+
}, {
|
|
174
|
+
readonly internalType: "uint256";
|
|
175
|
+
readonly name: "_l2MessageIndex";
|
|
176
|
+
readonly type: "uint256";
|
|
177
|
+
}, {
|
|
178
|
+
readonly internalType: "uint16";
|
|
179
|
+
readonly name: "_l2TxNumberInBatch";
|
|
180
|
+
readonly type: "uint16";
|
|
181
|
+
}, {
|
|
182
|
+
readonly internalType: "bytes32[]";
|
|
183
|
+
readonly name: "_merkleProof";
|
|
184
|
+
readonly type: "bytes32[]";
|
|
185
|
+
}];
|
|
186
|
+
readonly name: "bridgeRecoverFailedTransfer";
|
|
187
|
+
readonly outputs: readonly [];
|
|
188
|
+
readonly stateMutability: "nonpayable";
|
|
189
|
+
readonly type: "function";
|
|
190
|
+
}, {
|
|
191
|
+
readonly inputs: readonly [{
|
|
192
|
+
readonly internalType: "contract IL1NativeTokenVault";
|
|
193
|
+
readonly name: "_nativeTokenVault";
|
|
194
|
+
readonly type: "address";
|
|
195
|
+
}];
|
|
196
|
+
readonly name: "setL1NativeTokenVault";
|
|
197
|
+
readonly outputs: readonly [];
|
|
198
|
+
readonly stateMutability: "nonpayable";
|
|
199
|
+
readonly type: "function";
|
|
200
|
+
}, {
|
|
201
|
+
readonly inputs: readonly [{
|
|
202
|
+
readonly internalType: "address";
|
|
203
|
+
readonly name: "_l1AssetRouter";
|
|
204
|
+
readonly type: "address";
|
|
205
|
+
}];
|
|
206
|
+
readonly name: "setL1AssetRouter";
|
|
207
|
+
readonly outputs: readonly [];
|
|
208
|
+
readonly stateMutability: "nonpayable";
|
|
209
|
+
readonly type: "function";
|
|
210
|
+
}, {
|
|
211
|
+
readonly inputs: readonly [{
|
|
212
|
+
readonly internalType: "address";
|
|
213
|
+
readonly name: "_l1InteropHandler";
|
|
214
|
+
readonly type: "address";
|
|
215
|
+
}];
|
|
216
|
+
readonly name: "setL1InteropHandler";
|
|
217
|
+
readonly outputs: readonly [];
|
|
218
|
+
readonly stateMutability: "nonpayable";
|
|
219
|
+
readonly type: "function";
|
|
220
|
+
}];
|
|
221
|
+
export default IL1NullifierV32ABI;
|
|
@@ -202,20 +202,6 @@ declare const IL2AssetRouterABI: readonly [{
|
|
|
202
202
|
readonly internalType: "address";
|
|
203
203
|
}];
|
|
204
204
|
readonly stateMutability: "view";
|
|
205
|
-
}, {
|
|
206
|
-
readonly type: "function";
|
|
207
|
-
readonly name: "l1TokenAddress";
|
|
208
|
-
readonly inputs: readonly [{
|
|
209
|
-
readonly name: "_l2Token";
|
|
210
|
-
readonly type: "address";
|
|
211
|
-
readonly internalType: "address";
|
|
212
|
-
}];
|
|
213
|
-
readonly outputs: readonly [{
|
|
214
|
-
readonly name: "";
|
|
215
|
-
readonly type: "address";
|
|
216
|
-
readonly internalType: "address";
|
|
217
|
-
}];
|
|
218
|
-
readonly stateMutability: "view";
|
|
219
205
|
}, {
|
|
220
206
|
readonly type: "function";
|
|
221
207
|
readonly name: "l2TokenAddress";
|
|
@@ -8,6 +8,12 @@ export type PriorityTxGasBreakdown = {
|
|
|
8
8
|
priorityTxMaxGasLimit: bigint;
|
|
9
9
|
priorityTxMaxGasLimitExceeded: boolean;
|
|
10
10
|
};
|
|
11
|
+
/** The L2 call a priority tx performs, as seen from L2 (aliased L1 sender). */
|
|
12
|
+
export type PriorityTxL2Leg = {
|
|
13
|
+
from: Address;
|
|
14
|
+
to: Address;
|
|
15
|
+
data: `0x${string}`;
|
|
16
|
+
};
|
|
11
17
|
export declare const DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 7n;
|
|
12
18
|
export declare function applyL1ToL2Alias(address: Address): Address;
|
|
13
19
|
/**
|
|
@@ -39,3 +45,27 @@ export declare function applyPriorityL2GasLimitBuffer(input: {
|
|
|
39
45
|
chainIdL2: bigint;
|
|
40
46
|
gasLimit: bigint;
|
|
41
47
|
}): bigint;
|
|
48
|
+
/**
|
|
49
|
+
* Minimum `l2GasLimit` the L1 Mailbox accepts for a priority tx on ZKsync OS (protocol v33+).
|
|
50
|
+
* Below it `requestL2TransactionDirect` reverts with `ValidateTxnNotEnoughGas()`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function minimalPriorityTxL2Gas(input: {
|
|
53
|
+
calldataLength: bigint;
|
|
54
|
+
gasPerPubdata: bigint;
|
|
55
|
+
}): bigint;
|
|
56
|
+
export declare function clampPriorityL2GasLimit(input: {
|
|
57
|
+
gasLimit: bigint;
|
|
58
|
+
l2Calldata: `0x${string}`;
|
|
59
|
+
gasPerPubdata: bigint;
|
|
60
|
+
}): bigint;
|
|
61
|
+
/**
|
|
62
|
+
* `l2GasLimit` for finalizing a deposit of a token that already exists on L2.
|
|
63
|
+
* The validator floor only covers L1-side validation, so the real execution comes from the node's
|
|
64
|
+
* priority-tx estimate, or from the measured bridge-mint model when the node cannot provide one.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveRegisteredTokenPriorityL2GasLimit(input: {
|
|
67
|
+
chainIdL2: bigint;
|
|
68
|
+
priorityFloorGasLimit: bigint;
|
|
69
|
+
gasPerPubdata: bigint;
|
|
70
|
+
nodeEstimate?: bigint;
|
|
71
|
+
}): bigint;
|
|
@@ -8,6 +8,7 @@ export declare function createAttributesResource(codec: AttributesCodec): {
|
|
|
8
8
|
executionAddress: (executor: import("../../..").Address) => import("../../..").Hex;
|
|
9
9
|
unbundlerAddress: (addr: import("../../..").Address) => import("../../..").Hex;
|
|
10
10
|
useFixedFee: (enabled: boolean) => import("../../..").Hex;
|
|
11
|
+
interopBundleSalt: (salt: import("../../..").Hex) => import("../../..").Hex;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
export type AttributesResource = ReturnType<typeof createAttributesResource>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ProtocolVersion } from '../../types/primitives';
|
|
2
|
+
/** Bit offset of the `minor` component inside a packed protocol version. */
|
|
3
|
+
export declare const SEMVER_MINOR_OFFSET = 32n;
|
|
4
|
+
/** Bit offset of the `major` component inside a packed protocol version. */
|
|
5
|
+
export declare const SEMVER_MAJOR_OFFSET = 64n;
|
|
6
|
+
/**
|
|
7
|
+
* Unpacks a `uint256`/`uint96` packed protocol version into `[major, minor, patch]`.
|
|
8
|
+
*
|
|
9
|
+
* This is the layout returned by `ChainTypeManager.getProtocolVersion(chainId)`, which — unlike
|
|
10
|
+
* `getSemverProtocolVersion()` — reports the version of a *specific chain* rather than the latest
|
|
11
|
+
* version the CTM knows about. During a rolling ecosystem upgrade the two disagree, so anything
|
|
12
|
+
* gating behaviour on a chain's capabilities must use the per-chain value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function unpackSemver(packed: bigint): ProtocolVersion;
|
|
15
|
+
/** Packs `[major, minor, patch]` back into a single integer. Inverse of {@link unpackSemver}. */
|
|
16
|
+
export declare function packSemver(version: ProtocolVersion): bigint;
|
|
17
|
+
/** Formats a protocol version for messages, e.g. `0.32.0`. */
|
|
18
|
+
export declare function formatProtocolVersion(version: ProtocolVersion): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Address, Hex } from '../../types/primitives';
|
|
2
|
+
import type { InteropAddressCodec, InteropStarter } from '../interop/plan';
|
|
3
|
+
/** Attribute encoders the bundle builder needs, injected by the adapter. */
|
|
4
|
+
export interface WithdrawalAttributeCodec {
|
|
5
|
+
/** `indirectCall(uint256 indirectCallMessageValue)` */
|
|
6
|
+
indirectCall(messageValue: bigint): Hex;
|
|
7
|
+
/** `interopCallValue(uint256 interopCallValue)` */
|
|
8
|
+
interopCallValue(amount: bigint): Hex;
|
|
9
|
+
/** `interopBundleSalt(bytes32 salt)` — required on v32, see {@link withdrawalBundleSalt}. */
|
|
10
|
+
interopBundleSalt(salt: Hex): Hex;
|
|
11
|
+
}
|
|
12
|
+
/** ABI encoders the bundle builder needs, injected by the adapter. */
|
|
13
|
+
export interface WithdrawalTransferDataCodec {
|
|
14
|
+
/** `DataEncoding.encodeBridgeBurnData(amount, remoteReceiver, maybeTokenAddress)` */
|
|
15
|
+
encodeBridgeBurnData(amount: bigint, receiver: Address, token: Address): Hex;
|
|
16
|
+
/** `DataEncoding.encodeAssetRouterBridgehubDepositData(assetId, transferData)` */
|
|
17
|
+
encodeAssetRouterDepositData(assetId: Hex, transferData: Hex): Hex;
|
|
18
|
+
}
|
|
19
|
+
export interface BuildWithdrawalBundleInput {
|
|
20
|
+
/** Asset id of the withdrawn asset, as registered in the NativeTokenVault. */
|
|
21
|
+
assetId: Hex;
|
|
22
|
+
/** Amount to withdraw. */
|
|
23
|
+
amount: bigint;
|
|
24
|
+
/** L1 recipient of the funds. */
|
|
25
|
+
l1Receiver: Address;
|
|
26
|
+
/**
|
|
27
|
+
* L2 token being burned, or the zero address for a base-token withdrawal (which lets the vault
|
|
28
|
+
* resolve the token from `assetId`).
|
|
29
|
+
*/
|
|
30
|
+
l2Token: Address;
|
|
31
|
+
/** True when withdrawing the chain's base token. */
|
|
32
|
+
isBaseToken: boolean;
|
|
33
|
+
/** Chain id of L1 — the bundle's destination. */
|
|
34
|
+
l1ChainId: bigint;
|
|
35
|
+
/** L2 AssetRouter address (the bundle's single call target). */
|
|
36
|
+
l2AssetRouter: Address;
|
|
37
|
+
/** Unique-per-sender salt; see {@link withdrawalBundleSalt}. */
|
|
38
|
+
salt: Hex;
|
|
39
|
+
codec: InteropAddressCodec;
|
|
40
|
+
attributes: WithdrawalAttributeCodec;
|
|
41
|
+
transferData: WithdrawalTransferDataCodec;
|
|
42
|
+
}
|
|
43
|
+
export interface WithdrawalBundle {
|
|
44
|
+
/** ERC-7930 encoded destination chain (L1). */
|
|
45
|
+
destinationChain: Hex;
|
|
46
|
+
/** The bundle's single call starter. */
|
|
47
|
+
starters: InteropStarter[];
|
|
48
|
+
/** Bundle-level attributes. */
|
|
49
|
+
bundleAttributes: Hex[];
|
|
50
|
+
/**
|
|
51
|
+
* `msg.value` for the `sendBundle` call. Non-zero only for base-token withdrawals, where the
|
|
52
|
+
* withdrawn amount is forwarded as the indirect call's message value.
|
|
53
|
+
*
|
|
54
|
+
* L2 -> L1 withdrawals pay no interop protocol fee, so nothing else is added here.
|
|
55
|
+
*/
|
|
56
|
+
value: bigint;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Builds the `sendBundle` arguments for a withdrawal.
|
|
60
|
+
*
|
|
61
|
+
* The returned `value` is exactly the amount forwarded to the indirect call — callers must not add
|
|
62
|
+
* an interop fee on top: unlike L2 -> L2 bundles, L1-destined withdrawal bundles are free.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildWithdrawalBundle(input: BuildWithdrawalBundleInput): WithdrawalBundle;
|
|
65
|
+
/**
|
|
66
|
+
* Derives the bundle salt for a withdrawal.
|
|
67
|
+
*
|
|
68
|
+
* v32 replaced the InteropCenter's per-sender bundle nonce with a user-supplied salt: the center
|
|
69
|
+
* stores `keccak256(sender, salt)` and rejects a repeat, so every bundle from the same sender needs
|
|
70
|
+
* a fresh value. Deriving it from `(sender, l2 nonce)` rather than randomness keeps the resulting
|
|
71
|
+
* bundle hash reproducible for a given transaction — which matters because the caller may want to
|
|
72
|
+
* predict the hash before sending — while the monotonic nonce guarantees freshness.
|
|
73
|
+
*/
|
|
74
|
+
export interface WithdrawalSaltInput {
|
|
75
|
+
sender: Address;
|
|
76
|
+
nonce: number;
|
|
77
|
+
/** `keccak256(abi.encode(address, uint256))`, injected by the adapter. */
|
|
78
|
+
hash: (sender: Address, nonce: bigint) => Hex;
|
|
79
|
+
}
|
|
80
|
+
export declare function withdrawalBundleSalt(input: WithdrawalSaltInput): Hex;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Address, Hex } from '../../types/primitives';
|
|
2
|
+
/**
|
|
3
|
+
* `MessageInclusionProof` as consumed by `L1InteropHandler.executeBundle`.
|
|
4
|
+
*
|
|
5
|
+
* Note the handler substitutes `message.data` with `BUNDLE_IDENTIFIER || bundle` before proving
|
|
6
|
+
* inclusion, so the value passed here only has to be well-formed, and `message.sender` must be the
|
|
7
|
+
* L2 InteropCenter — the handler rejects anything else.
|
|
8
|
+
*/
|
|
9
|
+
export interface WithdrawalInclusionProof {
|
|
10
|
+
chainId: bigint;
|
|
11
|
+
l1BatchNumber: bigint;
|
|
12
|
+
l2MessageIndex: bigint;
|
|
13
|
+
message: {
|
|
14
|
+
txNumberInBatch: number;
|
|
15
|
+
sender: Address;
|
|
16
|
+
data: Hex;
|
|
17
|
+
};
|
|
18
|
+
proof: Hex[];
|
|
19
|
+
}
|
|
20
|
+
/** Everything needed to finalize a v32 withdrawal on L1. */
|
|
21
|
+
export interface WithdrawalBundleFinalization {
|
|
22
|
+
/** ABI-encoded `InteropBundle` — the `_bundle` argument of `executeBundle`. */
|
|
23
|
+
bundle: Hex;
|
|
24
|
+
/** `keccak256(bundle)`, the handler's key for bundle status. */
|
|
25
|
+
bundleHash: Hex;
|
|
26
|
+
/** The `_proof` argument of `executeBundle`. */
|
|
27
|
+
proof: WithdrawalInclusionProof;
|
|
28
|
+
}
|
|
29
|
+
/** keccak256 over raw hex bytes. */
|
|
30
|
+
export declare function keccakHex(data: Hex): Hex;
|
|
31
|
+
/**
|
|
32
|
+
* Strips the `BUNDLE_IDENTIFIER` prefix the InteropCenter puts in front of every published bundle
|
|
33
|
+
* message, yielding the ABI-encoded `InteropBundle`.
|
|
34
|
+
*
|
|
35
|
+
* A message that does not carry the prefix is not a withdrawal bundle — most likely a v31-style
|
|
36
|
+
* withdrawal message being fed to the v32 path — so this fails loudly rather than truncating.
|
|
37
|
+
*/
|
|
38
|
+
export declare function stripBundleIdentifier(messageData: Hex): Hex;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the authoritative `interopBundleHash` out of the `InteropBundleSent` log the L2
|
|
41
|
+
* InteropCenter emits, or `undefined` when no such log is present.
|
|
42
|
+
*
|
|
43
|
+
* This is the value the InteropCenter itself computed and the handler keys `bundleStatus` on, so
|
|
44
|
+
* using it means the SDK never has to assume a hash derivation. On the current contracts that
|
|
45
|
+
* derivation is `keccak256(bundle)` and the emitted value matches it exactly — the point is not to
|
|
46
|
+
* paper over a mismatch but to avoid re-deriving a protocol detail we are handed for free, out of a
|
|
47
|
+
* receipt we already fetch.
|
|
48
|
+
*
|
|
49
|
+
* Read **positionally rather than by ABI**: all three of the event's parameters are non-indexed and
|
|
50
|
+
* the first two are static `bytes32`, so the hash is always the second data word. That keeps it
|
|
51
|
+
* working across the `topic0` change that `BundleAttributes.salt` caused, without needing a
|
|
52
|
+
* version-aware ABI for the bundle tuple. Identified by emitter plus arity — `InteropBundleSent` is
|
|
53
|
+
* the InteropCenter's only fully non-indexed event, so it is the one with a single topic.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseBundleHashFromLogs(logs: readonly {
|
|
56
|
+
address: string;
|
|
57
|
+
topics: readonly string[];
|
|
58
|
+
data: string;
|
|
59
|
+
}[], interopCenter?: Address): Hex | undefined;
|
|
60
|
+
export interface BuildWithdrawalFinalizationInput {
|
|
61
|
+
/** Raw `bytes` payload of the `L1MessageSent` event, including the `0x01` prefix. */
|
|
62
|
+
messageData: Hex;
|
|
63
|
+
/** Chain id of the source L2. */
|
|
64
|
+
sourceChainId: bigint;
|
|
65
|
+
/** Index of the withdrawing transaction within its batch. */
|
|
66
|
+
txNumberInBatch: number;
|
|
67
|
+
/** Normalized `zks_getL2ToL1LogProof` result. */
|
|
68
|
+
proof: {
|
|
69
|
+
batchNumber: bigint;
|
|
70
|
+
id: bigint;
|
|
71
|
+
proof: Hex[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The bundle hash as emitted by the InteropCenter, from {@link parseBundleHashFromLogs}. Strongly
|
|
75
|
+
* preferred over the computed fallback — see that function for why.
|
|
76
|
+
*/
|
|
77
|
+
bundleHash?: Hex;
|
|
78
|
+
/**
|
|
79
|
+
* The InteropCenter that actually sent the bundle. Must be the resolved address rather than the
|
|
80
|
+
* canonical constant: the L1 handler checks `message.sender` against the center it expects, so a
|
|
81
|
+
* client using `overrides.interopCenter` would otherwise send through the override and then build
|
|
82
|
+
* a proof naming the canonical address, which cannot finalize.
|
|
83
|
+
*/
|
|
84
|
+
interopCenter?: Address;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Assembles the `executeBundle` arguments.
|
|
88
|
+
*
|
|
89
|
+
* `bundleHash` is whatever the chain emitted when it accepted the bundle, falling back to
|
|
90
|
+
* `keccak256(bundle)` — `InteropDataEncoding.encodeInteropBundleHash` — when no log is available.
|
|
91
|
+
*
|
|
92
|
+
* The hash keys `bundleStatus` on the handler, so getting it wrong does not break finalization
|
|
93
|
+
* itself but does make the withdrawal look permanently unfinalized, which in turn makes a retry
|
|
94
|
+
* re-send a transaction that then reverts with `BundleAlreadyProcessed`. That failure mode is why
|
|
95
|
+
* the emitted value is preferred over a derivation.
|
|
96
|
+
*/
|
|
97
|
+
export declare function buildWithdrawalFinalization(input: BuildWithdrawalFinalizationInput): WithdrawalBundleFinalization;
|
|
98
|
+
/**
|
|
99
|
+
* `BundleStatus` as stored by `InteropHandlerBase.bundleStatus`. Stable across v31/v32.
|
|
100
|
+
*/
|
|
101
|
+
export declare enum BundleStatus {
|
|
102
|
+
Unreceived = 0,
|
|
103
|
+
Verified = 1,
|
|
104
|
+
FullyExecuted = 2,
|
|
105
|
+
Unbundled = 3
|
|
106
|
+
}
|
|
107
|
+
/** `CallStatus` as stored by `InteropHandlerBase.callStatus`. */
|
|
108
|
+
export declare enum CallStatus {
|
|
109
|
+
Unprocessed = 0,
|
|
110
|
+
Executed = 1,
|
|
111
|
+
Cancelled = 2
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Outcome of a withdrawal, on either protocol.
|
|
115
|
+
*
|
|
116
|
+
* - `finalized` — the funds are released on L1.
|
|
117
|
+
* - `failed` — terminally unwound without paying out. Reachable only on `interop-bundle`, where the
|
|
118
|
+
* destination can cancel the withdrawal's call; the legacy protocol has no equivalent.
|
|
119
|
+
* - `pending` — not resolved yet.
|
|
120
|
+
*/
|
|
121
|
+
export type WithdrawalOutcome = 'finalized' | 'failed' | 'pending';
|
|
122
|
+
/**
|
|
123
|
+
* Classifies a withdrawal bundle from its on-chain status.
|
|
124
|
+
*
|
|
125
|
+
* `FullyExecuted` is the only status that means "done" on its own. `Unbundled` is *terminal but not
|
|
126
|
+
* a success*: `unbundleBundle` lets the unbundler mark each call `Executed` or `Cancelled`, so a
|
|
127
|
+
* withdrawal whose single call was cancelled never delivered the funds. Treating `Unbundled` as
|
|
128
|
+
* finalized would make `status()` report `FINALIZED` for a withdrawal that paid out nothing, and
|
|
129
|
+
* silence any further `finalize()` attempt.
|
|
130
|
+
*
|
|
131
|
+
* @param bundleStatus Value of `bundleStatus(bundleHash)`.
|
|
132
|
+
* @param callStatus Value of `callStatus(bundleHash, 0)` — a withdrawal bundle has exactly one
|
|
133
|
+
* call. Only consulted when `bundleStatus` is `Unbundled`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function classifyWithdrawalOutcome(bundleStatus: BundleStatus, callStatus?: CallStatus): WithdrawalOutcome;
|
|
136
|
+
/**
|
|
137
|
+
* True once the withdrawal's funds are released on L1.
|
|
138
|
+
*
|
|
139
|
+
* @deprecated Cannot distinguish a cancelled unbundle from a successful one — pass the call status
|
|
140
|
+
* to {@link classifyWithdrawalOutcome} instead.
|
|
141
|
+
*/
|
|
142
|
+
export declare function isBundleFinalized(status: BundleStatus): boolean;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Address, ProtocolVersion } from '../../types/primitives';
|
|
2
|
+
/**
|
|
3
|
+
* Which withdrawal protocol a chain speaks.
|
|
4
|
+
*
|
|
5
|
+
* - `legacy-withdrawal` — protocol v31 and below: dedicated `withdraw` entry points, finalized on
|
|
6
|
+
* the `L1Nullifier`.
|
|
7
|
+
* - `interop-bundle` — protocol v32 and above: withdrawals are single-call interop bundles
|
|
8
|
+
* destined for the L1 chain, finalized on the `L1InteropHandler`.
|
|
9
|
+
*/
|
|
10
|
+
export type WithdrawalProtocol = 'legacy-withdrawal' | 'interop-bundle';
|
|
11
|
+
/** First protocol minor version that uses the interop-bundle withdrawal protocol. */
|
|
12
|
+
export declare const MIN_INTEROP_WITHDRAWAL_MINOR = 32;
|
|
13
|
+
/** How the protocol was determined — surfaced for logging and error context. */
|
|
14
|
+
export type WithdrawalProtocolSource = {
|
|
15
|
+
via: 'override';
|
|
16
|
+
} | {
|
|
17
|
+
via: 'protocol-version';
|
|
18
|
+
version: ProtocolVersion;
|
|
19
|
+
} | {
|
|
20
|
+
via: 'code-probe';
|
|
21
|
+
address: Address;
|
|
22
|
+
};
|
|
23
|
+
export interface WithdrawalProtocolDetection {
|
|
24
|
+
protocol: WithdrawalProtocol;
|
|
25
|
+
source: WithdrawalProtocolSource;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Probes a chain has to expose for detection. Both are allowed to fail: `protocolVersion` returns
|
|
29
|
+
* `undefined` when the version cannot be read (unregistered CTM, restricted RPC, a node that does
|
|
30
|
+
* not expose the Bridgehub), and detection then falls back to the code probe.
|
|
31
|
+
*/
|
|
32
|
+
export interface WithdrawalProtocolProbes {
|
|
33
|
+
/** Per-chain protocol version, or `undefined` when it cannot be read. */
|
|
34
|
+
protocolVersion(): Promise<ProtocolVersion | undefined>;
|
|
35
|
+
/** True when the given L2 address holds non-empty bytecode. */
|
|
36
|
+
hasCodeAt(address: Address): Promise<boolean>;
|
|
37
|
+
}
|
|
38
|
+
/** Decides the protocol from a known protocol version. */
|
|
39
|
+
export declare function protocolFromVersion(version: ProtocolVersion): WithdrawalProtocol;
|
|
40
|
+
/**
|
|
41
|
+
* Detects the withdrawal protocol of the connected L2.
|
|
42
|
+
*
|
|
43
|
+
* Two probes, in order of trustworthiness:
|
|
44
|
+
*
|
|
45
|
+
* 1. **Per-chain protocol version.** `ChainTypeManager.getProtocolVersion(chainId)` is
|
|
46
|
+
* authoritative and cheap, so it wins whenever it can be read.
|
|
47
|
+
* 2. **Bytecode probe.** Falls back to asking the L2 whether the v32-only
|
|
48
|
+
* `InteropAttributeParser` (`0x…010015`) has code. That contract is force-deployed on *every*
|
|
49
|
+
* v32 chain, EraVM and ZKsync OS alike, which is what makes it a safe sentinel — unlike the
|
|
50
|
+
* atomic-interop built-ins, which are ZKsync-OS-only and would misreport an EraVM v32 chain.
|
|
51
|
+
*
|
|
52
|
+
* A caller-supplied `override` short-circuits both probes, which is the escape hatch for chains
|
|
53
|
+
* whose Bridgehub is not reachable from the configured L1 provider.
|
|
54
|
+
*/
|
|
55
|
+
export declare function detectWithdrawalProtocol(probes: WithdrawalProtocolProbes, override?: WithdrawalProtocol): Promise<WithdrawalProtocolDetection>;
|