@matterlabs/zksync-js 0.0.13 → 0.0.15
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 +13 -4
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +1 -2
- package/dist/adapters/ethers/client.js +6 -6
- package/dist/adapters/ethers/index.cjs +607 -259
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +9 -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/services/gas.d.ts +12 -0
- package/dist/adapters/ethers/resources/interop/types.d.ts +6 -14
- package/dist/adapters/ethers/sdk.cjs +1008 -259
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +6 -1
- package/dist/adapters/ethers/sdk.js +7 -7
- package/dist/adapters/viem/client.cjs +795 -7
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +6 -1
- package/dist/adapters/viem/client.js +6 -6
- package/dist/adapters/viem/index.cjs +6490 -2799
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +5 -0
- package/dist/adapters/viem/index.js +9 -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/resources/interop/address.d.ts +18 -0
- package/dist/adapters/viem/resources/interop/attributes/resource.d.ts +6 -0
- package/dist/adapters/viem/resources/interop/context.d.ts +31 -0
- package/dist/adapters/viem/resources/interop/index.d.ts +62 -0
- package/dist/adapters/viem/resources/interop/resolvers.d.ts +4 -0
- package/dist/adapters/viem/resources/interop/routes/direct.d.ts +2 -0
- package/dist/adapters/viem/resources/interop/routes/indirect.d.ts +2 -0
- package/dist/adapters/viem/resources/interop/routes/types.d.ts +23 -0
- package/dist/adapters/viem/resources/interop/services/erc20.d.ts +25 -0
- package/dist/adapters/viem/resources/interop/services/fee.d.ts +12 -0
- package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +15 -0
- package/dist/adapters/viem/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
- package/dist/adapters/viem/resources/interop/services/finalization/decoders.d.ts +11 -0
- package/dist/adapters/viem/resources/interop/services/finalization/index.d.ts +13 -0
- package/dist/adapters/viem/resources/interop/services/finalization/polling.d.ts +7 -0
- package/dist/adapters/viem/resources/interop/services/finalization/status.d.ts +5 -0
- package/dist/adapters/viem/resources/interop/services/finalization/topics.d.ts +4 -0
- package/dist/adapters/viem/resources/interop/services/gas.d.ts +12 -0
- package/dist/adapters/viem/resources/interop/services/starter-data.d.ts +6 -0
- package/dist/adapters/viem/resources/interop/types.d.ts +8 -0
- package/dist/adapters/viem/sdk.cjs +6401 -2758
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +8 -1
- package/dist/adapters/viem/sdk.js +7 -7
- package/dist/{chunk-E3KP7XCG.js → chunk-3HHUZXSV.js} +1 -1
- package/dist/{chunk-EDWBCPO3.js → chunk-4PZCNTQ3.js} +1387 -71
- package/dist/{chunk-UDBRUBEK.js → chunk-65HAYKVL.js} +2 -2
- package/dist/chunk-BWKWWLY4.js +9 -0
- package/dist/{chunk-JHO2UQ5F.js → chunk-HGB3DOV2.js} +445 -554
- package/dist/{chunk-HI64OOAR.js → chunk-HVHMLAYH.js} +1 -1
- package/dist/{chunk-2RIARDXZ.js → chunk-JHRYNLZG.js} +65 -7
- package/dist/{chunk-RI73VJSH.js → chunk-JXR5V5YK.js} +463 -27
- package/dist/chunk-K2UVKMLN.js +658 -0
- package/dist/{chunk-53MC5BR2.js → chunk-MDPX5LNW.js} +1 -1
- package/dist/{chunk-QQ2OR434.js → chunk-MT4X5FEO.js} +18 -2
- package/dist/{chunk-R5WRFPK2.js → chunk-MZBKM3GH.js} +4 -4
- package/dist/{chunk-5R7L5NM5.js → chunk-YIWXIP2M.js} +10 -2
- 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 +52 -24
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +5 -5
- package/dist/core/internal/abis/IERC7786Attributes.d.ts +21 -11
- package/dist/core/internal/abis/IInteropCenter.d.ts +4 -0
- package/dist/core/resources/deposits/chains.d.ts +1 -0
- package/dist/core/resources/deposits/gas.d.ts +7 -0
- package/dist/core/resources/deposits/priority.d.ts +41 -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/resources/interop/protocol.d.ts +3 -0
- package/dist/core/rpc/types.d.ts +1 -0
- 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 -20
- package/dist/core/types/primitives.d.ts +2 -0
- package/dist/index.cjs +69 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-4S4XDA4N.js +0 -415
- package/dist/chunk-5L6EYUJB.js +0 -237
|
@@ -37,7 +37,15 @@ var TX_OVERHEAD_GAS = 10000n;
|
|
|
37
37
|
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
38
38
|
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
39
39
|
var DEFAULT_ABI_BYTES = 400n;
|
|
40
|
-
var SAFE_L1_BRIDGE_GAS =
|
|
40
|
+
var SAFE_L1_BRIDGE_GAS = 3000000n;
|
|
41
|
+
var L1_TX_INTRINSIC_L2_GAS = 167157n;
|
|
42
|
+
var L1_TX_INTRINSIC_PUBDATA = 88n;
|
|
43
|
+
var L1_TX_MIN_L2_GAS_BASE = 173484n;
|
|
44
|
+
var L1_TX_DELTA_544_ENCODING_BYTES = 1656n;
|
|
45
|
+
var L1_TX_DELTA_FACTORY_DEPS_L2_GAS = 2473n;
|
|
46
|
+
var L1_TX_DELTA_FACTORY_DEPS_PUBDATA = 64n;
|
|
47
|
+
var TX_SLOT_OVERHEAD_L2_GAS = 10000n;
|
|
48
|
+
var PRIORITY_TX_MAX_GAS_LIMIT = 72000000n;
|
|
41
49
|
|
|
42
50
|
// src/core/utils/number.ts
|
|
43
51
|
var isNumber = (x) => typeof x === "number" && Number.isFinite(x);
|
|
@@ -401,6 +409,11 @@ var OP_INTEROP = {
|
|
|
401
409
|
wait: {
|
|
402
410
|
poll: "interop.svc.wait:poll",
|
|
403
411
|
timeout: "interop.svc.wait:timeout"
|
|
412
|
+
},
|
|
413
|
+
fees: {
|
|
414
|
+
zkInteropFee: "interop.svc.fees:zkInteropFee",
|
|
415
|
+
zkToken: "interop.svc.fees:zkToken",
|
|
416
|
+
protocolFee: "interop.svc.fees:protocolFee"
|
|
404
417
|
}
|
|
405
418
|
}
|
|
406
419
|
};
|
|
@@ -2274,6 +2287,411 @@ var IL1NullifierABI = [
|
|
|
2274
2287
|
];
|
|
2275
2288
|
var IL1Nullifier_default = IL1NullifierABI;
|
|
2276
2289
|
|
|
2290
|
+
// src/core/internal/abis/IL2AssetRouter.ts
|
|
2291
|
+
var IL2AssetRouterABI = [
|
|
2292
|
+
{
|
|
2293
|
+
type: "function",
|
|
2294
|
+
name: "BASE_TOKEN_ASSET_ID",
|
|
2295
|
+
inputs: [],
|
|
2296
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
2297
|
+
stateMutability: "view"
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
type: "function",
|
|
2301
|
+
name: "BRIDGE_HUB",
|
|
2302
|
+
inputs: [],
|
|
2303
|
+
outputs: [{ name: "", type: "address", internalType: "contract IBridgehub" }],
|
|
2304
|
+
stateMutability: "view"
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
type: "function",
|
|
2308
|
+
name: "L1_ASSET_ROUTER",
|
|
2309
|
+
inputs: [],
|
|
2310
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2311
|
+
stateMutability: "view"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
type: "function",
|
|
2315
|
+
name: "L1_CHAIN_ID",
|
|
2316
|
+
inputs: [],
|
|
2317
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2318
|
+
stateMutability: "view"
|
|
2319
|
+
},
|
|
2320
|
+
{
|
|
2321
|
+
type: "function",
|
|
2322
|
+
name: "L2_LEGACY_SHARED_BRIDGE",
|
|
2323
|
+
inputs: [],
|
|
2324
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2325
|
+
stateMutability: "view"
|
|
2326
|
+
},
|
|
2327
|
+
{
|
|
2328
|
+
type: "function",
|
|
2329
|
+
name: "acceptOwnership",
|
|
2330
|
+
inputs: [],
|
|
2331
|
+
outputs: [],
|
|
2332
|
+
stateMutability: "nonpayable"
|
|
2333
|
+
},
|
|
2334
|
+
{
|
|
2335
|
+
type: "function",
|
|
2336
|
+
name: "assetDeploymentTracker",
|
|
2337
|
+
inputs: [{ name: "assetId", type: "bytes32", internalType: "bytes32" }],
|
|
2338
|
+
outputs: [{ name: "assetDeploymentTracker", type: "address", internalType: "address" }],
|
|
2339
|
+
stateMutability: "view"
|
|
2340
|
+
},
|
|
2341
|
+
{
|
|
2342
|
+
type: "function",
|
|
2343
|
+
name: "assetHandlerAddress",
|
|
2344
|
+
inputs: [{ name: "assetId", type: "bytes32", internalType: "bytes32" }],
|
|
2345
|
+
outputs: [{ name: "assetHandlerAddress", type: "address", internalType: "address" }],
|
|
2346
|
+
stateMutability: "view"
|
|
2347
|
+
},
|
|
2348
|
+
{
|
|
2349
|
+
type: "function",
|
|
2350
|
+
name: "eraChainId",
|
|
2351
|
+
inputs: [],
|
|
2352
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2353
|
+
stateMutability: "view"
|
|
2354
|
+
},
|
|
2355
|
+
{
|
|
2356
|
+
type: "function",
|
|
2357
|
+
name: "finalizeDeposit",
|
|
2358
|
+
inputs: [
|
|
2359
|
+
{ name: "", type: "uint256", internalType: "uint256" },
|
|
2360
|
+
{ name: "_assetId", type: "bytes32", internalType: "bytes32" },
|
|
2361
|
+
{ name: "_transferData", type: "bytes", internalType: "bytes" }
|
|
2362
|
+
],
|
|
2363
|
+
outputs: [],
|
|
2364
|
+
stateMutability: "payable"
|
|
2365
|
+
},
|
|
2366
|
+
{
|
|
2367
|
+
type: "function",
|
|
2368
|
+
name: "finalizeDeposit",
|
|
2369
|
+
inputs: [
|
|
2370
|
+
{ name: "_l1Sender", type: "address", internalType: "address" },
|
|
2371
|
+
{ name: "_l2Receiver", type: "address", internalType: "address" },
|
|
2372
|
+
{ name: "_l1Token", type: "address", internalType: "address" },
|
|
2373
|
+
{ name: "_amount", type: "uint256", internalType: "uint256" },
|
|
2374
|
+
{ name: "_data", type: "bytes", internalType: "bytes" }
|
|
2375
|
+
],
|
|
2376
|
+
outputs: [],
|
|
2377
|
+
stateMutability: "payable"
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
type: "function",
|
|
2381
|
+
name: "finalizeDepositLegacyBridge",
|
|
2382
|
+
inputs: [
|
|
2383
|
+
{ name: "_l1Sender", type: "address", internalType: "address" },
|
|
2384
|
+
{ name: "_l2Receiver", type: "address", internalType: "address" },
|
|
2385
|
+
{ name: "_l1Token", type: "address", internalType: "address" },
|
|
2386
|
+
{ name: "_amount", type: "uint256", internalType: "uint256" },
|
|
2387
|
+
{ name: "_data", type: "bytes", internalType: "bytes" }
|
|
2388
|
+
],
|
|
2389
|
+
outputs: [],
|
|
2390
|
+
stateMutability: "nonpayable"
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
type: "function",
|
|
2394
|
+
name: "initL2",
|
|
2395
|
+
inputs: [
|
|
2396
|
+
{ name: "_l1ChainId", type: "uint256", internalType: "uint256" },
|
|
2397
|
+
{ name: "_eraChainId", type: "uint256", internalType: "uint256" },
|
|
2398
|
+
{ name: "_l1AssetRouter", type: "address", internalType: "address" },
|
|
2399
|
+
{ name: "_legacySharedBridge", type: "address", internalType: "address" },
|
|
2400
|
+
{ name: "_baseTokenAssetId", type: "bytes32", internalType: "bytes32" },
|
|
2401
|
+
{ name: "_aliasedOwner", type: "address", internalType: "address" }
|
|
2402
|
+
],
|
|
2403
|
+
outputs: [],
|
|
2404
|
+
stateMutability: "nonpayable"
|
|
2405
|
+
},
|
|
2406
|
+
{
|
|
2407
|
+
type: "function",
|
|
2408
|
+
name: "l1Bridge",
|
|
2409
|
+
inputs: [],
|
|
2410
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2411
|
+
stateMutability: "view"
|
|
2412
|
+
},
|
|
2413
|
+
{
|
|
2414
|
+
type: "function",
|
|
2415
|
+
name: "l1TokenAddress",
|
|
2416
|
+
inputs: [{ name: "_l2Token", type: "address", internalType: "address" }],
|
|
2417
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2418
|
+
stateMutability: "view"
|
|
2419
|
+
},
|
|
2420
|
+
{
|
|
2421
|
+
type: "function",
|
|
2422
|
+
name: "l2TokenAddress",
|
|
2423
|
+
inputs: [{ name: "_l1Token", type: "address", internalType: "address" }],
|
|
2424
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2425
|
+
stateMutability: "view"
|
|
2426
|
+
},
|
|
2427
|
+
{
|
|
2428
|
+
type: "function",
|
|
2429
|
+
name: "owner",
|
|
2430
|
+
inputs: [],
|
|
2431
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2432
|
+
stateMutability: "view"
|
|
2433
|
+
},
|
|
2434
|
+
{
|
|
2435
|
+
type: "function",
|
|
2436
|
+
name: "pause",
|
|
2437
|
+
inputs: [],
|
|
2438
|
+
outputs: [],
|
|
2439
|
+
stateMutability: "nonpayable"
|
|
2440
|
+
},
|
|
2441
|
+
{
|
|
2442
|
+
type: "function",
|
|
2443
|
+
name: "paused",
|
|
2444
|
+
inputs: [],
|
|
2445
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2446
|
+
stateMutability: "view"
|
|
2447
|
+
},
|
|
2448
|
+
{
|
|
2449
|
+
type: "function",
|
|
2450
|
+
name: "pendingOwner",
|
|
2451
|
+
inputs: [],
|
|
2452
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2453
|
+
stateMutability: "view"
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
type: "function",
|
|
2457
|
+
name: "renounceOwnership",
|
|
2458
|
+
inputs: [],
|
|
2459
|
+
outputs: [],
|
|
2460
|
+
stateMutability: "nonpayable"
|
|
2461
|
+
},
|
|
2462
|
+
{
|
|
2463
|
+
type: "function",
|
|
2464
|
+
name: "setAssetHandlerAddress",
|
|
2465
|
+
inputs: [
|
|
2466
|
+
{ name: "_originChainId", type: "uint256", internalType: "uint256" },
|
|
2467
|
+
{ name: "_assetId", type: "bytes32", internalType: "bytes32" },
|
|
2468
|
+
{ name: "_assetHandlerAddress", type: "address", internalType: "address" }
|
|
2469
|
+
],
|
|
2470
|
+
outputs: [],
|
|
2471
|
+
stateMutability: "nonpayable"
|
|
2472
|
+
},
|
|
2473
|
+
{
|
|
2474
|
+
type: "function",
|
|
2475
|
+
name: "setAssetHandlerAddressThisChain",
|
|
2476
|
+
inputs: [
|
|
2477
|
+
{ name: "_assetRegistrationData", type: "bytes32", internalType: "bytes32" },
|
|
2478
|
+
{ name: "_assetHandlerAddress", type: "address", internalType: "address" }
|
|
2479
|
+
],
|
|
2480
|
+
outputs: [],
|
|
2481
|
+
stateMutability: "nonpayable"
|
|
2482
|
+
},
|
|
2483
|
+
{
|
|
2484
|
+
type: "function",
|
|
2485
|
+
name: "setLegacyTokenAssetHandler",
|
|
2486
|
+
inputs: [{ name: "_assetId", type: "bytes32", internalType: "bytes32" }],
|
|
2487
|
+
outputs: [],
|
|
2488
|
+
stateMutability: "nonpayable"
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
type: "function",
|
|
2492
|
+
name: "transferOwnership",
|
|
2493
|
+
inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
|
|
2494
|
+
outputs: [],
|
|
2495
|
+
stateMutability: "nonpayable"
|
|
2496
|
+
},
|
|
2497
|
+
{
|
|
2498
|
+
type: "function",
|
|
2499
|
+
name: "unpause",
|
|
2500
|
+
inputs: [],
|
|
2501
|
+
outputs: [],
|
|
2502
|
+
stateMutability: "nonpayable"
|
|
2503
|
+
},
|
|
2504
|
+
{
|
|
2505
|
+
type: "function",
|
|
2506
|
+
name: "updateL2",
|
|
2507
|
+
inputs: [
|
|
2508
|
+
{ name: "_l1ChainId", type: "uint256", internalType: "uint256" },
|
|
2509
|
+
{ name: "_eraChainId", type: "uint256", internalType: "uint256" },
|
|
2510
|
+
{ name: "_l1AssetRouter", type: "address", internalType: "address" },
|
|
2511
|
+
{ name: "_legacySharedBridge", type: "address", internalType: "address" },
|
|
2512
|
+
{ name: "_baseTokenAssetId", type: "bytes32", internalType: "bytes32" }
|
|
2513
|
+
],
|
|
2514
|
+
outputs: [],
|
|
2515
|
+
stateMutability: "nonpayable"
|
|
2516
|
+
},
|
|
2517
|
+
{
|
|
2518
|
+
type: "function",
|
|
2519
|
+
name: "withdraw",
|
|
2520
|
+
inputs: [
|
|
2521
|
+
{ name: "_assetId", type: "bytes32", internalType: "bytes32" },
|
|
2522
|
+
{ name: "_assetData", type: "bytes", internalType: "bytes" }
|
|
2523
|
+
],
|
|
2524
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
2525
|
+
stateMutability: "nonpayable"
|
|
2526
|
+
},
|
|
2527
|
+
{
|
|
2528
|
+
type: "function",
|
|
2529
|
+
name: "withdraw",
|
|
2530
|
+
inputs: [
|
|
2531
|
+
{ name: "_l1Receiver", type: "address", internalType: "address" },
|
|
2532
|
+
{ name: "_l2Token", type: "address", internalType: "address" },
|
|
2533
|
+
{ name: "_amount", type: "uint256", internalType: "uint256" }
|
|
2534
|
+
],
|
|
2535
|
+
outputs: [],
|
|
2536
|
+
stateMutability: "nonpayable"
|
|
2537
|
+
},
|
|
2538
|
+
{
|
|
2539
|
+
type: "function",
|
|
2540
|
+
name: "withdrawLegacyBridge",
|
|
2541
|
+
inputs: [
|
|
2542
|
+
{ name: "_l1Receiver", type: "address", internalType: "address" },
|
|
2543
|
+
{ name: "_l2Token", type: "address", internalType: "address" },
|
|
2544
|
+
{ name: "_amount", type: "uint256", internalType: "uint256" },
|
|
2545
|
+
{ name: "_sender", type: "address", internalType: "address" }
|
|
2546
|
+
],
|
|
2547
|
+
outputs: [],
|
|
2548
|
+
stateMutability: "nonpayable"
|
|
2549
|
+
},
|
|
2550
|
+
{
|
|
2551
|
+
type: "event",
|
|
2552
|
+
name: "AssetDeploymentTrackerRegistered",
|
|
2553
|
+
inputs: [
|
|
2554
|
+
{ name: "assetId", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2555
|
+
{ name: "additionalData", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2556
|
+
{
|
|
2557
|
+
name: "assetDeploymentTracker",
|
|
2558
|
+
type: "address",
|
|
2559
|
+
indexed: false,
|
|
2560
|
+
internalType: "address"
|
|
2561
|
+
}
|
|
2562
|
+
],
|
|
2563
|
+
anonymous: false
|
|
2564
|
+
},
|
|
2565
|
+
{
|
|
2566
|
+
type: "event",
|
|
2567
|
+
name: "AssetHandlerRegistered",
|
|
2568
|
+
inputs: [
|
|
2569
|
+
{ name: "assetId", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2570
|
+
{
|
|
2571
|
+
name: "_assetHandlerAddress",
|
|
2572
|
+
type: "address",
|
|
2573
|
+
indexed: true,
|
|
2574
|
+
internalType: "address"
|
|
2575
|
+
}
|
|
2576
|
+
],
|
|
2577
|
+
anonymous: false
|
|
2578
|
+
},
|
|
2579
|
+
{
|
|
2580
|
+
type: "event",
|
|
2581
|
+
name: "BridgehubDepositBaseTokenInitiated",
|
|
2582
|
+
inputs: [
|
|
2583
|
+
{ name: "chainId", type: "uint256", indexed: true, internalType: "uint256" },
|
|
2584
|
+
{ name: "from", type: "address", indexed: true, internalType: "address" },
|
|
2585
|
+
{ name: "assetId", type: "bytes32", indexed: false, internalType: "bytes32" },
|
|
2586
|
+
{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
|
|
2587
|
+
],
|
|
2588
|
+
anonymous: false
|
|
2589
|
+
},
|
|
2590
|
+
{
|
|
2591
|
+
type: "event",
|
|
2592
|
+
name: "BridgehubDepositInitiated",
|
|
2593
|
+
inputs: [
|
|
2594
|
+
{ name: "chainId", type: "uint256", indexed: true, internalType: "uint256" },
|
|
2595
|
+
{ name: "txDataHash", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2596
|
+
{ name: "from", type: "address", indexed: true, internalType: "address" },
|
|
2597
|
+
{ name: "assetId", type: "bytes32", indexed: false, internalType: "bytes32" },
|
|
2598
|
+
{ name: "bridgeMintCalldata", type: "bytes", indexed: false, internalType: "bytes" }
|
|
2599
|
+
],
|
|
2600
|
+
anonymous: false
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
type: "event",
|
|
2604
|
+
name: "BridgehubWithdrawalInitiated",
|
|
2605
|
+
inputs: [
|
|
2606
|
+
{ name: "chainId", type: "uint256", indexed: false, internalType: "uint256" },
|
|
2607
|
+
{ name: "sender", type: "address", indexed: true, internalType: "address" },
|
|
2608
|
+
{ name: "assetId", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2609
|
+
{ name: "assetDataHash", type: "bytes32", indexed: false, internalType: "bytes32" }
|
|
2610
|
+
],
|
|
2611
|
+
anonymous: false
|
|
2612
|
+
},
|
|
2613
|
+
{
|
|
2614
|
+
type: "event",
|
|
2615
|
+
name: "DepositFinalizedAssetRouter",
|
|
2616
|
+
inputs: [
|
|
2617
|
+
{ name: "chainId", type: "uint256", indexed: true, internalType: "uint256" },
|
|
2618
|
+
{ name: "assetId", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2619
|
+
{ name: "assetData", type: "bytes", indexed: false, internalType: "bytes" }
|
|
2620
|
+
],
|
|
2621
|
+
anonymous: false
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
type: "event",
|
|
2625
|
+
name: "Initialized",
|
|
2626
|
+
inputs: [{ name: "version", type: "uint8", indexed: false, internalType: "uint8" }],
|
|
2627
|
+
anonymous: false
|
|
2628
|
+
},
|
|
2629
|
+
{
|
|
2630
|
+
type: "event",
|
|
2631
|
+
name: "OwnershipTransferStarted",
|
|
2632
|
+
inputs: [
|
|
2633
|
+
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
2634
|
+
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
2635
|
+
],
|
|
2636
|
+
anonymous: false
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
type: "event",
|
|
2640
|
+
name: "OwnershipTransferred",
|
|
2641
|
+
inputs: [
|
|
2642
|
+
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
2643
|
+
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
2644
|
+
],
|
|
2645
|
+
anonymous: false
|
|
2646
|
+
},
|
|
2647
|
+
{
|
|
2648
|
+
type: "event",
|
|
2649
|
+
name: "Paused",
|
|
2650
|
+
inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
|
|
2651
|
+
anonymous: false
|
|
2652
|
+
},
|
|
2653
|
+
{
|
|
2654
|
+
type: "event",
|
|
2655
|
+
name: "Unpaused",
|
|
2656
|
+
inputs: [{ name: "account", type: "address", indexed: false, internalType: "address" }],
|
|
2657
|
+
anonymous: false
|
|
2658
|
+
},
|
|
2659
|
+
{
|
|
2660
|
+
type: "event",
|
|
2661
|
+
name: "WithdrawalInitiatedAssetRouter",
|
|
2662
|
+
inputs: [
|
|
2663
|
+
{ name: "chainId", type: "uint256", indexed: false, internalType: "uint256" },
|
|
2664
|
+
{ name: "l2Sender", type: "address", indexed: true, internalType: "address" },
|
|
2665
|
+
{ name: "assetId", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
2666
|
+
{ name: "assetData", type: "bytes", indexed: false, internalType: "bytes" }
|
|
2667
|
+
],
|
|
2668
|
+
anonymous: false
|
|
2669
|
+
},
|
|
2670
|
+
{ type: "error", name: "AmountMustBeGreaterThanZero", inputs: [] },
|
|
2671
|
+
{
|
|
2672
|
+
type: "error",
|
|
2673
|
+
name: "AssetIdNotSupported",
|
|
2674
|
+
inputs: [{ name: "assetId", type: "bytes32", internalType: "bytes32" }]
|
|
2675
|
+
},
|
|
2676
|
+
{ type: "error", name: "EmptyAddress", inputs: [] },
|
|
2677
|
+
{
|
|
2678
|
+
type: "error",
|
|
2679
|
+
name: "InvalidCaller",
|
|
2680
|
+
inputs: [{ name: "", type: "address", internalType: "address" }]
|
|
2681
|
+
},
|
|
2682
|
+
{ type: "error", name: "InvalidNTVBurnData", inputs: [] },
|
|
2683
|
+
{ type: "error", name: "NotInitializedReentrancyGuard", inputs: [] },
|
|
2684
|
+
{ type: "error", name: "Reentrancy", inputs: [] },
|
|
2685
|
+
{ type: "error", name: "SlotOccupied", inputs: [] },
|
|
2686
|
+
{ type: "error", name: "TokenNotLegacy", inputs: [] },
|
|
2687
|
+
{
|
|
2688
|
+
type: "error",
|
|
2689
|
+
name: "Unauthorized",
|
|
2690
|
+
inputs: [{ name: "caller", type: "address", internalType: "address" }]
|
|
2691
|
+
}
|
|
2692
|
+
];
|
|
2693
|
+
var IL2AssetRouter_default = IL2AssetRouterABI;
|
|
2694
|
+
|
|
2277
2695
|
// src/core/internal/abis/L1NativeTokenVault.ts
|
|
2278
2696
|
var L1NativeTokenVaultABI = [
|
|
2279
2697
|
{
|
|
@@ -3267,56 +3685,69 @@ var IERC20_default = IERC20ABI;
|
|
|
3267
3685
|
// src/core/internal/abis/IERC7786Attributes.ts
|
|
3268
3686
|
var IERC7786AttributesABI = [
|
|
3269
3687
|
{
|
|
3688
|
+
type: "function",
|
|
3689
|
+
name: "executionAddress",
|
|
3270
3690
|
inputs: [
|
|
3271
3691
|
{
|
|
3272
|
-
internalType: "bytes",
|
|
3273
3692
|
name: "_executionAddress",
|
|
3274
|
-
type: "bytes"
|
|
3693
|
+
type: "bytes",
|
|
3694
|
+
internalType: "bytes"
|
|
3275
3695
|
}
|
|
3276
3696
|
],
|
|
3277
|
-
name: "executionAddress",
|
|
3278
3697
|
outputs: [],
|
|
3279
|
-
stateMutability: "pure"
|
|
3280
|
-
type: "function"
|
|
3698
|
+
stateMutability: "pure"
|
|
3281
3699
|
},
|
|
3282
3700
|
{
|
|
3701
|
+
type: "function",
|
|
3702
|
+
name: "indirectCall",
|
|
3283
3703
|
inputs: [
|
|
3284
3704
|
{
|
|
3285
|
-
internalType: "uint256",
|
|
3286
3705
|
name: "_indirectCallMessageValue",
|
|
3287
|
-
type: "uint256"
|
|
3706
|
+
type: "uint256",
|
|
3707
|
+
internalType: "uint256"
|
|
3708
|
+
}
|
|
3709
|
+
],
|
|
3710
|
+
outputs: [],
|
|
3711
|
+
stateMutability: "pure"
|
|
3712
|
+
},
|
|
3713
|
+
{
|
|
3714
|
+
type: "function",
|
|
3715
|
+
name: "interopCallValue",
|
|
3716
|
+
inputs: [
|
|
3717
|
+
{
|
|
3718
|
+
name: "_interopCallValue",
|
|
3719
|
+
type: "uint256",
|
|
3720
|
+
internalType: "uint256"
|
|
3288
3721
|
}
|
|
3289
3722
|
],
|
|
3290
|
-
name: "indirectCall",
|
|
3291
3723
|
outputs: [],
|
|
3292
|
-
stateMutability: "pure"
|
|
3293
|
-
type: "function"
|
|
3724
|
+
stateMutability: "pure"
|
|
3294
3725
|
},
|
|
3295
3726
|
{
|
|
3727
|
+
type: "function",
|
|
3728
|
+
name: "unbundlerAddress",
|
|
3296
3729
|
inputs: [
|
|
3297
3730
|
{
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3731
|
+
name: "_unbundlerAddress",
|
|
3732
|
+
type: "bytes",
|
|
3733
|
+
internalType: "bytes"
|
|
3301
3734
|
}
|
|
3302
3735
|
],
|
|
3303
|
-
name: "interopCallValue",
|
|
3304
3736
|
outputs: [],
|
|
3305
|
-
stateMutability: "pure"
|
|
3306
|
-
type: "function"
|
|
3737
|
+
stateMutability: "pure"
|
|
3307
3738
|
},
|
|
3308
3739
|
{
|
|
3740
|
+
type: "function",
|
|
3741
|
+
name: "useFixedFee",
|
|
3309
3742
|
inputs: [
|
|
3310
3743
|
{
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3744
|
+
name: "_useFixed",
|
|
3745
|
+
type: "bool",
|
|
3746
|
+
internalType: "bool"
|
|
3314
3747
|
}
|
|
3315
3748
|
],
|
|
3316
|
-
name: "unbundlerAddress",
|
|
3317
3749
|
outputs: [],
|
|
3318
|
-
stateMutability: "pure"
|
|
3319
|
-
type: "function"
|
|
3750
|
+
stateMutability: "pure"
|
|
3320
3751
|
}
|
|
3321
3752
|
];
|
|
3322
3753
|
var IERC7786Attributes_default = IERC7786AttributesABI;
|
|
@@ -4164,6 +4595,11 @@ var IInteropCenterABI = [
|
|
|
4164
4595
|
type: "uint256",
|
|
4165
4596
|
internalType: "uint256"
|
|
4166
4597
|
},
|
|
4598
|
+
{
|
|
4599
|
+
name: "destinationBaseTokenAssetId",
|
|
4600
|
+
type: "bytes32",
|
|
4601
|
+
internalType: "bytes32"
|
|
4602
|
+
},
|
|
4167
4603
|
{
|
|
4168
4604
|
name: "interopBundleSalt",
|
|
4169
4605
|
type: "bytes32",
|
|
@@ -5494,7 +5930,33 @@ function buildDirectRequestStruct(args) {
|
|
|
5494
5930
|
};
|
|
5495
5931
|
}
|
|
5496
5932
|
|
|
5933
|
+
// src/core/resources/deposits/chains.ts
|
|
5934
|
+
var ERAVM_CHAIN_IDS = /* @__PURE__ */ new Set([324n, 2741n, 11124n, 300n]);
|
|
5935
|
+
function isEraVmChain(chainIdL2) {
|
|
5936
|
+
return ERAVM_CHAIN_IDS.has(chainIdL2);
|
|
5937
|
+
}
|
|
5938
|
+
|
|
5497
5939
|
// src/core/resources/deposits/gas.ts
|
|
5940
|
+
var CREATE_REESTIMATE_BUFFER = 15n;
|
|
5941
|
+
var maxBigInt = (a, b) => a > b ? a : b;
|
|
5942
|
+
function applyGasBuffer(gasLimit, bufferPct = BUFFER) {
|
|
5943
|
+
return gasLimit * (100n + bufferPct) / 100n;
|
|
5944
|
+
}
|
|
5945
|
+
function resolveCreateDepositL1GasLimit(input) {
|
|
5946
|
+
const { chainIdL2, stepKey, preparedGasLimit, estimatedGasLimit } = input;
|
|
5947
|
+
if (estimatedGasLimit == null) {
|
|
5948
|
+
return preparedGasLimit;
|
|
5949
|
+
}
|
|
5950
|
+
const isEraVmBridgeStep = isEraVmChain(chainIdL2) && stepKey.startsWith("bridgehub:");
|
|
5951
|
+
const reestimatedGasLimit = applyGasBuffer(
|
|
5952
|
+
estimatedGasLimit,
|
|
5953
|
+
isEraVmBridgeStep ? BUFFER : CREATE_REESTIMATE_BUFFER
|
|
5954
|
+
);
|
|
5955
|
+
if (isEraVmBridgeStep && preparedGasLimit != null) {
|
|
5956
|
+
return maxBigInt(preparedGasLimit, reestimatedGasLimit);
|
|
5957
|
+
}
|
|
5958
|
+
return reestimatedGasLimit;
|
|
5959
|
+
}
|
|
5498
5960
|
function makeGasQuote(p) {
|
|
5499
5961
|
const maxPriorityFeePerGas = p.maxPriorityFeePerGas ?? 0n;
|
|
5500
5962
|
return {
|
|
@@ -5545,13 +6007,12 @@ async function quoteL1Gas(input) {
|
|
|
5545
6007
|
}
|
|
5546
6008
|
try {
|
|
5547
6009
|
const est = await estimator.estimateGas(tx);
|
|
5548
|
-
const buffered = BigInt(est)
|
|
6010
|
+
const buffered = applyGasBuffer(BigInt(est));
|
|
5549
6011
|
return makeGasQuote({ gasLimit: buffered, maxFeePerGas, maxPriorityFeePerGas });
|
|
5550
|
-
} catch
|
|
6012
|
+
} catch {
|
|
5551
6013
|
if (fallbackGasLimit != null) {
|
|
5552
6014
|
return makeGasQuote({ gasLimit: fallbackGasLimit, maxFeePerGas, maxPriorityFeePerGas });
|
|
5553
6015
|
}
|
|
5554
|
-
console.warn("L1 gas estimation failed", err);
|
|
5555
6016
|
return void 0;
|
|
5556
6017
|
}
|
|
5557
6018
|
}
|
|
@@ -5583,14 +6044,13 @@ async function quoteL2Gas(input) {
|
|
|
5583
6044
|
const memoryOverhead = memoryBytes * TX_MEMORY_OVERHEAD_GAS;
|
|
5584
6045
|
const pubdataOverhead = pubdataBytes * pp;
|
|
5585
6046
|
let total = BigInt(execEstimate) + TX_OVERHEAD_GAS + memoryOverhead + pubdataOverhead;
|
|
5586
|
-
total = total
|
|
6047
|
+
total = applyGasBuffer(total);
|
|
5587
6048
|
return makeGasQuote({
|
|
5588
6049
|
gasLimit: total,
|
|
5589
6050
|
maxFeePerGas,
|
|
5590
6051
|
gasPerPubdata: pp
|
|
5591
6052
|
});
|
|
5592
|
-
} catch
|
|
5593
|
-
console.warn("L2 gas estimation failed", err);
|
|
6053
|
+
} catch {
|
|
5594
6054
|
return makeGasQuote({
|
|
5595
6055
|
gasLimit: l2GasLimit ?? 0n,
|
|
5596
6056
|
maxFeePerGas,
|
|
@@ -5708,7 +6168,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
5708
6168
|
throw toZKsyncError2(kind, { resource, operation, context: opts?.ctx ?? {}, message }, e);
|
|
5709
6169
|
}
|
|
5710
6170
|
}
|
|
5711
|
-
function
|
|
6171
|
+
function wrap7(operation, fn, opts) {
|
|
5712
6172
|
return run("INTERNAL", operation, fn, opts);
|
|
5713
6173
|
}
|
|
5714
6174
|
function wrapAs9(kind, operation, fn, opts) {
|
|
@@ -5716,7 +6176,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
5716
6176
|
}
|
|
5717
6177
|
async function toResult3(operation, fn, opts) {
|
|
5718
6178
|
try {
|
|
5719
|
-
const value = await
|
|
6179
|
+
const value = await wrap7(operation, fn, opts);
|
|
5720
6180
|
return { ok: true, value };
|
|
5721
6181
|
} catch (e) {
|
|
5722
6182
|
const shaped = isZKsyncError(e) ? e : toZKsyncError2(
|
|
@@ -5732,7 +6192,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
5732
6192
|
return { ok: false, error: shaped };
|
|
5733
6193
|
}
|
|
5734
6194
|
}
|
|
5735
|
-
return { wrap:
|
|
6195
|
+
return { wrap: wrap7, wrapAs: wrapAs9, toResult: toResult3 };
|
|
5736
6196
|
}
|
|
5737
6197
|
return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
|
|
5738
6198
|
}
|
|
@@ -5936,8 +6396,22 @@ async function determineNonBaseL2Gas(input) {
|
|
|
5936
6396
|
try {
|
|
5937
6397
|
const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).l2TokenAddress(l1Token));
|
|
5938
6398
|
if (l2TokenAddress === ZERO_L2_TOKEN_ADDRESS) {
|
|
6399
|
+
if (input.undeployedGasLimit != null) {
|
|
6400
|
+
return quoteL2Gas2({
|
|
6401
|
+
ctx,
|
|
6402
|
+
route,
|
|
6403
|
+
overrideGasLimit: input.undeployedGasLimit
|
|
6404
|
+
});
|
|
6405
|
+
}
|
|
5939
6406
|
return fallbackQuote();
|
|
5940
6407
|
}
|
|
6408
|
+
if (input.priorityFloorGasLimit != null) {
|
|
6409
|
+
return quoteL2Gas2({
|
|
6410
|
+
ctx,
|
|
6411
|
+
route,
|
|
6412
|
+
overrideGasLimit: input.priorityFloorGasLimit
|
|
6413
|
+
});
|
|
6414
|
+
}
|
|
5941
6415
|
const modelTx = {
|
|
5942
6416
|
to: input.modelTx?.to ?? ctx.sender,
|
|
5943
6417
|
from: input.modelTx?.from ?? ctx.sender,
|
|
@@ -5953,8 +6427,7 @@ async function determineNonBaseL2Gas(input) {
|
|
|
5953
6427
|
return fallbackQuote();
|
|
5954
6428
|
}
|
|
5955
6429
|
return gas;
|
|
5956
|
-
} catch
|
|
5957
|
-
console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
|
|
6430
|
+
} catch {
|
|
5958
6431
|
return fallbackQuote();
|
|
5959
6432
|
}
|
|
5960
6433
|
}
|
|
@@ -5971,7 +6444,9 @@ async function determineEthNonBaseL2Gas(input) {
|
|
|
5971
6444
|
route: "eth-nonbase",
|
|
5972
6445
|
l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
|
|
5973
6446
|
knownL2Token: input.ctx.resolvedToken?.l2,
|
|
5974
|
-
modelTx: input.modelTx
|
|
6447
|
+
modelTx: input.modelTx,
|
|
6448
|
+
priorityFloorGasLimit: input.priorityFloorGasLimit,
|
|
6449
|
+
undeployedGasLimit: input.undeployedGasLimit
|
|
5975
6450
|
});
|
|
5976
6451
|
}
|
|
5977
6452
|
|
|
@@ -6003,41 +6478,120 @@ function buildFeeBreakdown(p) {
|
|
|
6003
6478
|
};
|
|
6004
6479
|
}
|
|
6005
6480
|
|
|
6481
|
+
// src/core/resources/deposits/priority.ts
|
|
6482
|
+
var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
|
|
6483
|
+
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 6n;
|
|
6484
|
+
var ERAVM_PRIORITY_L2_GAS_BUFFER = 30n;
|
|
6485
|
+
var maxBigInt2 = (a, b) => a > b ? a : b;
|
|
6486
|
+
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
6487
|
+
function derivePriorityTxGasBreakdown(input) {
|
|
6488
|
+
const factoryDepsCount = input.factoryDepsCount ?? 0n;
|
|
6489
|
+
const minBodyGas = maxBigInt2(
|
|
6490
|
+
L1_TX_INTRINSIC_L2_GAS + ceilDiv(
|
|
6491
|
+
input.encodedLength * L1_TX_DELTA_544_ENCODING_BYTES,
|
|
6492
|
+
PRIORITY_TX_ENCODING_STEP_BYTES
|
|
6493
|
+
) + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_L2_GAS,
|
|
6494
|
+
L1_TX_MIN_L2_GAS_BASE
|
|
6495
|
+
) + L1_TX_INTRINSIC_PUBDATA * input.gasPerPubdata + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_PUBDATA * input.gasPerPubdata;
|
|
6496
|
+
const overhead = maxBigInt2(TX_SLOT_OVERHEAD_L2_GAS, TX_MEMORY_OVERHEAD_GAS * input.encodedLength);
|
|
6497
|
+
const derivedBodyGas = minBodyGas;
|
|
6498
|
+
return {
|
|
6499
|
+
encodedLength: input.encodedLength,
|
|
6500
|
+
minBodyGas,
|
|
6501
|
+
overhead,
|
|
6502
|
+
derivedBodyGas,
|
|
6503
|
+
derivedL2GasLimit: derivedBodyGas + overhead,
|
|
6504
|
+
priorityTxMaxGasLimit: PRIORITY_TX_MAX_GAS_LIMIT,
|
|
6505
|
+
priorityTxMaxGasLimitExceeded: derivedBodyGas > PRIORITY_TX_MAX_GAS_LIMIT
|
|
6506
|
+
};
|
|
6507
|
+
}
|
|
6508
|
+
function derivePriorityBodyGasEstimateCap(input) {
|
|
6509
|
+
return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
|
|
6510
|
+
}
|
|
6511
|
+
function applyPriorityL2GasLimitBuffer(input) {
|
|
6512
|
+
if (!isEraVmChain(input.chainIdL2)) {
|
|
6513
|
+
return input.gasLimit;
|
|
6514
|
+
}
|
|
6515
|
+
return input.gasLimit * (100n + ERAVM_PRIORITY_L2_GAS_BUFFER) / 100n;
|
|
6516
|
+
}
|
|
6517
|
+
var EMPTY_BYTES = "0x";
|
|
6518
|
+
var ZERO_RESERVED_WORDS = [0n, 0n, 0n, 0n];
|
|
6519
|
+
var L2_CANONICAL_TRANSACTION_TUPLE = "tuple(uint256 txType,uint256 from,uint256 to,uint256 gasLimit,uint256 gasPerPubdataByteLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,uint256 paymaster,uint256 nonce,uint256 value,uint256[4] reserved,bytes data,bytes signature,uint256[] factoryDeps,bytes paymasterInput,bytes reservedDynamic)";
|
|
6520
|
+
function hexByteLength(hex) {
|
|
6521
|
+
return BigInt(Math.max(hex.length - 2, 0) / 2);
|
|
6522
|
+
}
|
|
6523
|
+
function getPriorityTxEncodedLength(input) {
|
|
6524
|
+
const encoded = ethers.AbiCoder.defaultAbiCoder().encode(
|
|
6525
|
+
[L2_CANONICAL_TRANSACTION_TUPLE],
|
|
6526
|
+
[
|
|
6527
|
+
[
|
|
6528
|
+
0n,
|
|
6529
|
+
BigInt(input.sender),
|
|
6530
|
+
BigInt(input.l2Contract),
|
|
6531
|
+
0n,
|
|
6532
|
+
input.gasPerPubdata,
|
|
6533
|
+
0n,
|
|
6534
|
+
0n,
|
|
6535
|
+
0n,
|
|
6536
|
+
0n,
|
|
6537
|
+
input.l2Value,
|
|
6538
|
+
ZERO_RESERVED_WORDS,
|
|
6539
|
+
input.l2Calldata,
|
|
6540
|
+
EMPTY_BYTES,
|
|
6541
|
+
input.factoryDepsHashes ?? [],
|
|
6542
|
+
EMPTY_BYTES,
|
|
6543
|
+
EMPTY_BYTES
|
|
6544
|
+
]
|
|
6545
|
+
]
|
|
6546
|
+
);
|
|
6547
|
+
return hexByteLength(encoded);
|
|
6548
|
+
}
|
|
6549
|
+
function getPriorityTxGasBreakdown(input) {
|
|
6550
|
+
return derivePriorityTxGasBreakdown({
|
|
6551
|
+
encodedLength: getPriorityTxEncodedLength(input),
|
|
6552
|
+
gasPerPubdata: input.gasPerPubdata,
|
|
6553
|
+
factoryDepsCount: BigInt(input.factoryDepsHashes?.length ?? 0)
|
|
6554
|
+
});
|
|
6555
|
+
}
|
|
6556
|
+
|
|
6006
6557
|
// src/adapters/ethers/resources/deposits/routes/eth.ts
|
|
6558
|
+
var EMPTY_BYTES2 = "0x";
|
|
6007
6559
|
function routeEthDirect() {
|
|
6008
6560
|
return {
|
|
6009
6561
|
async build(p, ctx) {
|
|
6010
6562
|
const bh = await ctx.contracts.bridgehub();
|
|
6011
|
-
const
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6563
|
+
const l2Contract = p.to ?? ctx.sender;
|
|
6564
|
+
const l2Value = p.amount;
|
|
6565
|
+
const l2Calldata = EMPTY_BYTES2;
|
|
6566
|
+
const priorityFloorBreakdown = getPriorityTxGasBreakdown({
|
|
6567
|
+
sender: ctx.sender,
|
|
6568
|
+
l2Contract,
|
|
6569
|
+
l2Value,
|
|
6570
|
+
l2Calldata,
|
|
6571
|
+
gasPerPubdata: ctx.gasPerPubdata
|
|
6572
|
+
});
|
|
6573
|
+
const quotedL2GasLimit = ctx.l2GasLimit ?? applyPriorityL2GasLimitBuffer({
|
|
6574
|
+
chainIdL2: ctx.chainIdL2,
|
|
6575
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
6576
|
+
});
|
|
6017
6577
|
const l2GasParams = await quoteL2Gas2({
|
|
6018
6578
|
ctx,
|
|
6019
6579
|
route: "eth-base",
|
|
6020
|
-
|
|
6021
|
-
overrideGasLimit: ctx.l2GasLimit,
|
|
6022
|
-
stateOverrides: {
|
|
6023
|
-
[ctx.sender]: {
|
|
6024
|
-
balance: "0xffffffffffffffffffff"
|
|
6025
|
-
}
|
|
6026
|
-
}
|
|
6580
|
+
overrideGasLimit: quotedL2GasLimit
|
|
6027
6581
|
});
|
|
6028
6582
|
if (!l2GasParams) {
|
|
6029
6583
|
throw new Error("Failed to estimate L2 gas for deposit.");
|
|
6030
6584
|
}
|
|
6031
6585
|
const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
|
|
6032
|
-
const mintValue = baseCost + ctx.operatorTip +
|
|
6586
|
+
const mintValue = baseCost + ctx.operatorTip + l2Value;
|
|
6033
6587
|
const req = buildDirectRequestStruct({
|
|
6034
6588
|
chainId: ctx.chainIdL2,
|
|
6035
6589
|
mintValue,
|
|
6036
6590
|
l2GasLimit: l2GasParams.gasLimit,
|
|
6037
6591
|
gasPerPubdata: ctx.gasPerPubdata,
|
|
6038
6592
|
refundRecipient: ctx.refundRecipient,
|
|
6039
|
-
l2Contract
|
|
6040
|
-
l2Value
|
|
6593
|
+
l2Contract,
|
|
6594
|
+
l2Value
|
|
6041
6595
|
});
|
|
6042
6596
|
const data = bh.interface.encodeFunctionData("requestL2TransactionDirect", [req]);
|
|
6043
6597
|
const l1TxCandidate = {
|
|
@@ -6087,6 +6641,56 @@ var ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000
|
|
|
6087
6641
|
|
|
6088
6642
|
// src/adapters/ethers/resources/deposits/routes/erc20-nonbase.ts
|
|
6089
6643
|
var { wrapAs: wrapAs2 } = createErrorHandlers("deposits");
|
|
6644
|
+
var ZERO_L2_TOKEN_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
6645
|
+
var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
6646
|
+
async function getPriorityGasModel(input) {
|
|
6647
|
+
try {
|
|
6648
|
+
const l1NativeTokenVault = await input.ctx.contracts.l1NativeTokenVault();
|
|
6649
|
+
const l1AssetRouter = await input.ctx.contracts.l1AssetRouter();
|
|
6650
|
+
const { chainId: l1ChainId } = await input.ctx.client.l1.getNetwork();
|
|
6651
|
+
const isFirstBridge = input.ctx.resolvedToken.assetId.toLowerCase() === ZERO_ASSET_ID || input.ctx.resolvedToken.originChainId === 0n;
|
|
6652
|
+
const erc20MetadataOriginChainId = isFirstBridge ? BigInt(l1ChainId) : input.ctx.resolvedToken.originChainId;
|
|
6653
|
+
const erc20Metadata = await l1NativeTokenVault.getERC20Getters(
|
|
6654
|
+
input.token,
|
|
6655
|
+
erc20MetadataOriginChainId
|
|
6656
|
+
);
|
|
6657
|
+
const bridgeMintCalldata = ethers.AbiCoder.defaultAbiCoder().encode(
|
|
6658
|
+
["address", "address", "address", "uint256", "bytes"],
|
|
6659
|
+
[input.ctx.sender, input.receiver, input.token, input.amount, erc20Metadata]
|
|
6660
|
+
);
|
|
6661
|
+
const l2Calldata = isFirstBridge ? new ethers.Interface(IL2AssetRouter_default).encodeFunctionData(
|
|
6662
|
+
"finalizeDeposit(address,address,address,uint256,bytes)",
|
|
6663
|
+
[input.ctx.sender, input.receiver, input.token, input.amount, erc20Metadata]
|
|
6664
|
+
) : await (() => {
|
|
6665
|
+
return l1AssetRouter.getDepositCalldata(
|
|
6666
|
+
input.ctx.sender,
|
|
6667
|
+
input.ctx.resolvedToken.assetId,
|
|
6668
|
+
bridgeMintCalldata
|
|
6669
|
+
);
|
|
6670
|
+
})();
|
|
6671
|
+
const priorityFloorBreakdown = getPriorityTxGasBreakdown({
|
|
6672
|
+
sender: input.ctx.l1AssetRouter,
|
|
6673
|
+
l2Contract: L2_ASSET_ROUTER_ADDRESS,
|
|
6674
|
+
l2Value: 0n,
|
|
6675
|
+
l2Calldata,
|
|
6676
|
+
gasPerPubdata: input.ctx.gasPerPubdata
|
|
6677
|
+
});
|
|
6678
|
+
const model = {
|
|
6679
|
+
priorityFloorGasLimit: applyPriorityL2GasLimitBuffer({
|
|
6680
|
+
chainIdL2: input.ctx.chainIdL2,
|
|
6681
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
6682
|
+
})
|
|
6683
|
+
};
|
|
6684
|
+
if (isFirstBridge || input.ctx.resolvedToken.l2.toLowerCase() === ZERO_L2_TOKEN_ADDRESS2) {
|
|
6685
|
+
model.undeployedGasLimit = derivePriorityBodyGasEstimateCap({
|
|
6686
|
+
minBodyGas: priorityFloorBreakdown.minBodyGas
|
|
6687
|
+
}) + priorityFloorBreakdown.overhead;
|
|
6688
|
+
}
|
|
6689
|
+
return model;
|
|
6690
|
+
} catch {
|
|
6691
|
+
return {};
|
|
6692
|
+
}
|
|
6693
|
+
}
|
|
6090
6694
|
function routeErc20NonBase() {
|
|
6091
6695
|
return {
|
|
6092
6696
|
async preflight(p, ctx) {
|
|
@@ -6107,11 +6711,29 @@ function routeErc20NonBase() {
|
|
|
6107
6711
|
const l1Signer = ctx.client.getL1Signer();
|
|
6108
6712
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
6109
6713
|
const baseIsEth = ctx.baseIsEth ?? isETH(baseToken);
|
|
6714
|
+
const receiver = p.to ?? ctx.sender;
|
|
6715
|
+
const secondBridgeCalldata = await wrapAs2(
|
|
6716
|
+
"INTERNAL",
|
|
6717
|
+
OP_DEPOSITS.nonbase.encodeCalldata,
|
|
6718
|
+
() => Promise.resolve(encodeSecondBridgeErc20Args(p.token, p.amount, receiver)),
|
|
6719
|
+
{
|
|
6720
|
+
ctx: { where: "encodeSecondBridgeErc20Args" },
|
|
6721
|
+
message: "Failed to encode bridging calldata."
|
|
6722
|
+
}
|
|
6723
|
+
);
|
|
6724
|
+
const priorityGasModel = await getPriorityGasModel({
|
|
6725
|
+
ctx,
|
|
6726
|
+
token: p.token,
|
|
6727
|
+
amount: p.amount,
|
|
6728
|
+
receiver
|
|
6729
|
+
});
|
|
6110
6730
|
const l2GasParams = await determineErc20L2Gas({
|
|
6111
6731
|
ctx,
|
|
6112
6732
|
l1Token: p.token,
|
|
6733
|
+
priorityFloorGasLimit: priorityGasModel.priorityFloorGasLimit,
|
|
6734
|
+
undeployedGasLimit: priorityGasModel.undeployedGasLimit,
|
|
6113
6735
|
modelTx: {
|
|
6114
|
-
to:
|
|
6736
|
+
to: receiver,
|
|
6115
6737
|
from: ctx.sender,
|
|
6116
6738
|
data: "0x",
|
|
6117
6739
|
value: 0n
|
|
@@ -6173,15 +6795,6 @@ function routeErc20NonBase() {
|
|
|
6173
6795
|
});
|
|
6174
6796
|
}
|
|
6175
6797
|
}
|
|
6176
|
-
const secondBridgeCalldata = await wrapAs2(
|
|
6177
|
-
"INTERNAL",
|
|
6178
|
-
OP_DEPOSITS.nonbase.encodeCalldata,
|
|
6179
|
-
() => Promise.resolve(encodeSecondBridgeErc20Args(p.token, p.amount, p.to ?? ctx.sender)),
|
|
6180
|
-
{
|
|
6181
|
-
ctx: { where: "encodeSecondBridgeErc20Args" },
|
|
6182
|
-
message: "Failed to encode bridging calldata."
|
|
6183
|
-
}
|
|
6184
|
-
);
|
|
6185
6798
|
const requestStruct = {
|
|
6186
6799
|
chainId: ctx.chainIdL2,
|
|
6187
6800
|
mintValue,
|
|
@@ -6238,7 +6851,71 @@ function routeErc20NonBase() {
|
|
|
6238
6851
|
}
|
|
6239
6852
|
};
|
|
6240
6853
|
}
|
|
6854
|
+
|
|
6855
|
+
// src/core/codec/ntv.ts
|
|
6856
|
+
function createNTVCodec(deps) {
|
|
6857
|
+
function encodeAssetId(originChainId, ntvAddress, tokenAddress) {
|
|
6858
|
+
const encoded = deps.encode(
|
|
6859
|
+
["uint256", "address", "address"],
|
|
6860
|
+
[originChainId, ntvAddress, tokenAddress]
|
|
6861
|
+
);
|
|
6862
|
+
return deps.keccak256(encoded);
|
|
6863
|
+
}
|
|
6864
|
+
return {
|
|
6865
|
+
encodeAssetId
|
|
6866
|
+
};
|
|
6867
|
+
}
|
|
6868
|
+
|
|
6869
|
+
// src/adapters/ethers/resources/deposits/routes/eth-nonbase.ts
|
|
6241
6870
|
var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
|
|
6871
|
+
var ZERO_L2_TOKEN_ADDRESS3 = "0x0000000000000000000000000000000000000000";
|
|
6872
|
+
var ZERO_ASSET_ID2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
6873
|
+
var ntvCodec = createNTVCodec({
|
|
6874
|
+
encode: (types, values) => ethers.AbiCoder.defaultAbiCoder().encode(types, values),
|
|
6875
|
+
keccak256: (data) => ethers.keccak256(data)
|
|
6876
|
+
});
|
|
6877
|
+
async function getPriorityGasModel2(input) {
|
|
6878
|
+
try {
|
|
6879
|
+
const l1AssetRouter = await input.ctx.contracts.l1AssetRouter();
|
|
6880
|
+
const l1NativeTokenVault = await input.ctx.contracts.l1NativeTokenVault();
|
|
6881
|
+
const originChainId = input.ctx.resolvedToken.originChainId !== 0n ? input.ctx.resolvedToken.originChainId : BigInt((await input.ctx.client.l1.getNetwork()).chainId);
|
|
6882
|
+
const resolvedAssetId = input.ctx.resolvedToken.assetId.toLowerCase() === ZERO_ASSET_ID2 ? ntvCodec.encodeAssetId(originChainId, L2_NATIVE_TOKEN_VAULT_ADDRESS, ETH_ADDRESS) : input.ctx.resolvedToken.assetId;
|
|
6883
|
+
const erc20Metadata = await l1NativeTokenVault.getERC20Getters(
|
|
6884
|
+
ETH_ADDRESS,
|
|
6885
|
+
originChainId
|
|
6886
|
+
);
|
|
6887
|
+
const bridgeMintCalldata = ethers.AbiCoder.defaultAbiCoder().encode(
|
|
6888
|
+
["address", "address", "address", "uint256", "bytes"],
|
|
6889
|
+
[input.ctx.sender, input.receiver, ETH_ADDRESS, input.amount, erc20Metadata]
|
|
6890
|
+
);
|
|
6891
|
+
const l2Calldata = await l1AssetRouter.getDepositCalldata(
|
|
6892
|
+
input.ctx.sender,
|
|
6893
|
+
resolvedAssetId,
|
|
6894
|
+
bridgeMintCalldata
|
|
6895
|
+
);
|
|
6896
|
+
const priorityFloorBreakdown = getPriorityTxGasBreakdown({
|
|
6897
|
+
sender: input.ctx.l1AssetRouter,
|
|
6898
|
+
l2Contract: L2_ASSET_ROUTER_ADDRESS,
|
|
6899
|
+
l2Value: 0n,
|
|
6900
|
+
l2Calldata,
|
|
6901
|
+
gasPerPubdata: input.ctx.gasPerPubdata
|
|
6902
|
+
});
|
|
6903
|
+
const model = {
|
|
6904
|
+
priorityFloorGasLimit: applyPriorityL2GasLimitBuffer({
|
|
6905
|
+
chainIdL2: input.ctx.chainIdL2,
|
|
6906
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
6907
|
+
})
|
|
6908
|
+
};
|
|
6909
|
+
if (input.ctx.resolvedToken.l2.toLowerCase() === ZERO_L2_TOKEN_ADDRESS3) {
|
|
6910
|
+
model.undeployedGasLimit = derivePriorityBodyGasEstimateCap({
|
|
6911
|
+
minBodyGas: priorityFloorBreakdown.minBodyGas
|
|
6912
|
+
}) + priorityFloorBreakdown.overhead;
|
|
6913
|
+
}
|
|
6914
|
+
return model;
|
|
6915
|
+
} catch {
|
|
6916
|
+
return {};
|
|
6917
|
+
}
|
|
6918
|
+
}
|
|
6242
6919
|
function routeEthNonBase() {
|
|
6243
6920
|
return {
|
|
6244
6921
|
async preflight(p, ctx) {
|
|
@@ -6287,15 +6964,23 @@ function routeEthNonBase() {
|
|
|
6287
6964
|
async build(p, ctx) {
|
|
6288
6965
|
const l1Signer = ctx.client.getL1Signer();
|
|
6289
6966
|
const baseToken = ctx.baseTokenL1;
|
|
6967
|
+
const receiver = p.to ?? ctx.sender;
|
|
6968
|
+
const priorityGasModel = await getPriorityGasModel2({
|
|
6969
|
+
ctx,
|
|
6970
|
+
amount: p.amount,
|
|
6971
|
+
receiver
|
|
6972
|
+
});
|
|
6290
6973
|
const l2TxModel = {
|
|
6291
|
-
to:
|
|
6974
|
+
to: receiver,
|
|
6292
6975
|
from: ctx.sender,
|
|
6293
6976
|
data: "0x",
|
|
6294
6977
|
value: 0n
|
|
6295
6978
|
};
|
|
6296
6979
|
const l2GasParams = await determineEthNonBaseL2Gas({
|
|
6297
6980
|
ctx,
|
|
6298
|
-
modelTx: l2TxModel
|
|
6981
|
+
modelTx: l2TxModel,
|
|
6982
|
+
priorityFloorGasLimit: priorityGasModel.priorityFloorGasLimit,
|
|
6983
|
+
undeployedGasLimit: priorityGasModel.undeployedGasLimit
|
|
6299
6984
|
});
|
|
6300
6985
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
6301
6986
|
const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
|
|
@@ -6329,12 +7014,12 @@ function routeEthNonBase() {
|
|
|
6329
7014
|
const secondBridgeCalldata = await wrapAs3(
|
|
6330
7015
|
"INTERNAL",
|
|
6331
7016
|
OP_DEPOSITS.ethNonBase.encodeCalldata,
|
|
6332
|
-
() => Promise.resolve(encodeSecondBridgeEthArgs(p.amount,
|
|
7017
|
+
() => Promise.resolve(encodeSecondBridgeEthArgs(p.amount, receiver)),
|
|
6333
7018
|
{
|
|
6334
7019
|
ctx: {
|
|
6335
7020
|
where: "encodeSecondBridgeEthArgs",
|
|
6336
7021
|
amount: p.amount.toString(),
|
|
6337
|
-
to:
|
|
7022
|
+
to: receiver
|
|
6338
7023
|
}
|
|
6339
7024
|
}
|
|
6340
7025
|
);
|
|
@@ -6395,6 +7080,7 @@ function routeEthNonBase() {
|
|
|
6395
7080
|
};
|
|
6396
7081
|
}
|
|
6397
7082
|
var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
|
|
7083
|
+
var EMPTY_BYTES3 = "0x";
|
|
6398
7084
|
function routeErc20Base() {
|
|
6399
7085
|
return {
|
|
6400
7086
|
async preflight(p, ctx) {
|
|
@@ -6425,17 +7111,24 @@ function routeErc20Base() {
|
|
|
6425
7111
|
async build(p, ctx) {
|
|
6426
7112
|
const l1Signer = ctx.client.getL1Signer();
|
|
6427
7113
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
6428
|
-
const
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
7114
|
+
const l2Contract = p.to ?? ctx.sender;
|
|
7115
|
+
const l2Value = p.amount;
|
|
7116
|
+
const l2Calldata = EMPTY_BYTES3;
|
|
7117
|
+
const priorityFloorBreakdown = getPriorityTxGasBreakdown({
|
|
7118
|
+
sender: ctx.sender,
|
|
7119
|
+
l2Contract,
|
|
7120
|
+
l2Value,
|
|
7121
|
+
l2Calldata,
|
|
7122
|
+
gasPerPubdata: ctx.gasPerPubdata
|
|
7123
|
+
});
|
|
7124
|
+
const quotedL2GasLimit = ctx.l2GasLimit ?? applyPriorityL2GasLimitBuffer({
|
|
7125
|
+
chainIdL2: ctx.chainIdL2,
|
|
7126
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
7127
|
+
});
|
|
6434
7128
|
const l2GasParams = await quoteL2Gas2({
|
|
6435
7129
|
ctx,
|
|
6436
7130
|
route: "erc20-base",
|
|
6437
|
-
|
|
6438
|
-
overrideGasLimit: ctx.l2GasLimit
|
|
7131
|
+
overrideGasLimit: quotedL2GasLimit
|
|
6439
7132
|
});
|
|
6440
7133
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
6441
7134
|
const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
|
|
@@ -6474,8 +7167,8 @@ function routeErc20Base() {
|
|
|
6474
7167
|
l2GasLimit: l2GasParams.gasLimit,
|
|
6475
7168
|
gasPerPubdata: ctx.gasPerPubdata,
|
|
6476
7169
|
refundRecipient: ctx.refundRecipient,
|
|
6477
|
-
l2Contract
|
|
6478
|
-
l2Value
|
|
7170
|
+
l2Contract,
|
|
7171
|
+
l2Value
|
|
6479
7172
|
});
|
|
6480
7173
|
const bridgehub = await ctx.contracts.bridgehub();
|
|
6481
7174
|
const data = bridgehub.interface.encodeFunctionData("requestL2TransactionDirect", [
|
|
@@ -6522,25 +7215,9 @@ function routeErc20Base() {
|
|
|
6522
7215
|
}
|
|
6523
7216
|
};
|
|
6524
7217
|
}
|
|
6525
|
-
|
|
6526
|
-
// src/core/codec/ntv.ts
|
|
6527
|
-
function createNTVCodec(deps) {
|
|
6528
|
-
function encodeAssetId(originChainId, ntvAddress, tokenAddress) {
|
|
6529
|
-
const encoded = deps.encode(
|
|
6530
|
-
["uint256", "address", "address"],
|
|
6531
|
-
[originChainId, ntvAddress, tokenAddress]
|
|
6532
|
-
);
|
|
6533
|
-
return deps.keccak256(encoded);
|
|
6534
|
-
}
|
|
6535
|
-
return {
|
|
6536
|
-
encodeAssetId
|
|
6537
|
-
};
|
|
6538
|
-
}
|
|
6539
|
-
|
|
6540
|
-
// src/adapters/ethers/resources/tokens/tokens.ts
|
|
6541
7218
|
var { wrapAs: wrapAs5 } = createErrorHandlers("tokens");
|
|
6542
7219
|
var abi = ethers.AbiCoder.defaultAbiCoder();
|
|
6543
|
-
var
|
|
7220
|
+
var ntvCodec2 = createNTVCodec({
|
|
6544
7221
|
encode: (types, values) => abi.encode(types, values),
|
|
6545
7222
|
keccak256: (data) => ethers.ethers.keccak256(data)
|
|
6546
7223
|
});
|
|
@@ -6659,7 +7336,7 @@ function createTokensResource(client) {
|
|
|
6659
7336
|
return wrapAs5("CONTRACT", "tokens.isChainEthBased", async () => {
|
|
6660
7337
|
const baseAssetId = await getBaseTokenAssetId();
|
|
6661
7338
|
const l1ChainId = await getL1ChainId();
|
|
6662
|
-
const ethAssetId =
|
|
7339
|
+
const ethAssetId = ntvCodec2.encodeAssetId(
|
|
6663
7340
|
l1ChainId,
|
|
6664
7341
|
L2_NATIVE_TOKEN_VAULT_ADDRESS,
|
|
6665
7342
|
ETH_ADDRESS
|
|
@@ -6873,6 +7550,8 @@ function createDepositsResource(client, tokens, contracts) {
|
|
|
6873
7550
|
async () => {
|
|
6874
7551
|
const plan = await prepare(p);
|
|
6875
7552
|
const stepHashes = {};
|
|
7553
|
+
const { chainId } = await client.l2.getNetwork();
|
|
7554
|
+
const chainIdL2 = BigInt(chainId);
|
|
6876
7555
|
const managed = new ethers.NonceManager(client.signer);
|
|
6877
7556
|
const from = await managed.getAddress();
|
|
6878
7557
|
let next;
|
|
@@ -6918,8 +7597,14 @@ function createDepositsResource(client, tokens, contracts) {
|
|
|
6918
7597
|
}
|
|
6919
7598
|
if (!p.l1TxOverrides?.gasLimit) {
|
|
6920
7599
|
try {
|
|
7600
|
+
const preparedGasLimit = step.tx.gasLimit != null ? BigInt(step.tx.gasLimit.toString()) : void 0;
|
|
6921
7601
|
const est = await client.l1.estimateGas(step.tx);
|
|
6922
|
-
step.tx.gasLimit =
|
|
7602
|
+
step.tx.gasLimit = resolveCreateDepositL1GasLimit({
|
|
7603
|
+
chainIdL2,
|
|
7604
|
+
stepKey: step.key,
|
|
7605
|
+
preparedGasLimit,
|
|
7606
|
+
estimatedGasLimit: BigInt(est)
|
|
7607
|
+
});
|
|
6923
7608
|
} catch {
|
|
6924
7609
|
}
|
|
6925
7610
|
}
|
|
@@ -7670,7 +8355,7 @@ var ROUTES2 = {
|
|
|
7670
8355
|
};
|
|
7671
8356
|
function createWithdrawalsResource(client, tokens, contracts) {
|
|
7672
8357
|
const svc = createFinalizationServices(client);
|
|
7673
|
-
const { wrap:
|
|
8358
|
+
const { wrap: wrap7, toResult: toResult3 } = createErrorHandlers("withdrawals");
|
|
7674
8359
|
const tokensResource = tokens ?? createTokensResource(client);
|
|
7675
8360
|
const contractsResource = contracts ?? createContractsResource(client);
|
|
7676
8361
|
async function buildPlan(p) {
|
|
@@ -7691,7 +8376,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
7691
8376
|
};
|
|
7692
8377
|
}
|
|
7693
8378
|
const finalizeCache = /* @__PURE__ */ new Map();
|
|
7694
|
-
const quote = (p) =>
|
|
8379
|
+
const quote = (p) => wrap7(
|
|
7695
8380
|
OP_WITHDRAWALS.quote,
|
|
7696
8381
|
async () => {
|
|
7697
8382
|
const plan = await buildPlan(p);
|
|
@@ -7713,7 +8398,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
7713
8398
|
ctx: { token: p.token, where: "withdrawals.tryQuote" }
|
|
7714
8399
|
}
|
|
7715
8400
|
);
|
|
7716
|
-
const prepare = (p) =>
|
|
8401
|
+
const prepare = (p) => wrap7(OP_WITHDRAWALS.prepare, () => buildPlan(p), {
|
|
7717
8402
|
message: "Internal error while preparing a withdrawal plan.",
|
|
7718
8403
|
ctx: { token: p.token, where: "withdrawals.prepare" }
|
|
7719
8404
|
});
|
|
@@ -7721,7 +8406,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
7721
8406
|
message: "Internal error while preparing a withdrawal plan.",
|
|
7722
8407
|
ctx: { token: p.token, where: "withdrawals.tryPrepare" }
|
|
7723
8408
|
});
|
|
7724
|
-
const create = (p) =>
|
|
8409
|
+
const create = (p) => wrap7(
|
|
7725
8410
|
OP_WITHDRAWALS.create,
|
|
7726
8411
|
async () => {
|
|
7727
8412
|
const plan = await prepare(p);
|
|
@@ -7792,7 +8477,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
7792
8477
|
message: "Internal error while creating withdrawal transactions.",
|
|
7793
8478
|
ctx: { token: p.token, amount: p.amount, to: p.to, where: "withdrawals.tryCreate" }
|
|
7794
8479
|
});
|
|
7795
|
-
const status = (h) =>
|
|
8480
|
+
const status = (h) => wrap7(
|
|
7796
8481
|
OP_WITHDRAWALS.status,
|
|
7797
8482
|
async () => {
|
|
7798
8483
|
const l2TxHash = typeof h === "string" ? h : "l2TxHash" in h && h.l2TxHash ? h.l2TxHash : "0x";
|
|
@@ -7847,7 +8532,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
7847
8532
|
const wait = (h, opts = {
|
|
7848
8533
|
for: "l2",
|
|
7849
8534
|
pollMs: 5500
|
|
7850
|
-
}) =>
|
|
8535
|
+
}) => wrap7(
|
|
7851
8536
|
OP_WITHDRAWALS.wait,
|
|
7852
8537
|
async () => {
|
|
7853
8538
|
const l2Hash = typeof h === "string" ? h : "l2TxHash" in h && h.l2TxHash ? h.l2TxHash : "0x";
|
|
@@ -7912,7 +8597,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
7912
8597
|
}
|
|
7913
8598
|
}
|
|
7914
8599
|
);
|
|
7915
|
-
const finalize = (l2TxHash) =>
|
|
8600
|
+
const finalize = (l2TxHash) => wrap7(
|
|
7916
8601
|
OP_WITHDRAWALS.finalize.send,
|
|
7917
8602
|
async () => {
|
|
7918
8603
|
const pack = await (async () => {
|
|
@@ -8038,9 +8723,11 @@ function createCallAttributes(codec) {
|
|
|
8038
8723
|
function createBundleAttributes(codec) {
|
|
8039
8724
|
const executionAddress = (executor) => codec.encode("executionAddress", [executor]);
|
|
8040
8725
|
const unbundlerAddress = (addr) => codec.encode("unbundlerAddress", [addr]);
|
|
8726
|
+
const useFixedFee = (enabled) => codec.encode("useFixedFee", [enabled]);
|
|
8041
8727
|
return {
|
|
8042
8728
|
executionAddress,
|
|
8043
|
-
unbundlerAddress
|
|
8729
|
+
unbundlerAddress,
|
|
8730
|
+
useFixedFee
|
|
8044
8731
|
};
|
|
8045
8732
|
}
|
|
8046
8733
|
|
|
@@ -8061,6 +8748,7 @@ function getInteropAttributes(params, ctx) {
|
|
|
8061
8748
|
if (params.unbundling?.by) {
|
|
8062
8749
|
bundleAttributes.push(ctx.attributes.bundle.unbundlerAddress(params.unbundling.by));
|
|
8063
8750
|
}
|
|
8751
|
+
bundleAttributes.push(ctx.attributes.bundle.useFixedFee(params.fee?.useFixed ?? false));
|
|
8064
8752
|
const callAttributes = params.actions.map((action) => {
|
|
8065
8753
|
switch (action.type) {
|
|
8066
8754
|
case "sendNative": {
|
|
@@ -8090,11 +8778,6 @@ function createEthersAttributesResource(opts = {}) {
|
|
|
8090
8778
|
}
|
|
8091
8779
|
|
|
8092
8780
|
// src/core/types/flows/interop.ts
|
|
8093
|
-
function isInteropExpectedRoot(obj) {
|
|
8094
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
8095
|
-
const root = obj;
|
|
8096
|
-
return isBigint(root.rootChainId) && isBigint(root.batchNumber) && isHash(root.expectedRoot);
|
|
8097
|
-
}
|
|
8098
8781
|
function isInteropMessageProof(obj) {
|
|
8099
8782
|
if (typeof obj !== "object" || obj === null) return false;
|
|
8100
8783
|
const proof = obj;
|
|
@@ -8103,7 +8786,7 @@ function isInteropMessageProof(obj) {
|
|
|
8103
8786
|
function isInteropFinalizationInfo(obj) {
|
|
8104
8787
|
if (typeof obj !== "object" || obj === null) return false;
|
|
8105
8788
|
const info = obj;
|
|
8106
|
-
return isHash66(info.l2SrcTxHash) && isHash66(info.bundleHash) && isBigint(info.dstChainId) && isHash(info.encodedData) &&
|
|
8789
|
+
return isHash66(info.l2SrcTxHash) && isHash66(info.bundleHash) && isBigint(info.dstChainId) && isHash(info.encodedData) && isInteropMessageProof(info.proof);
|
|
8107
8790
|
}
|
|
8108
8791
|
|
|
8109
8792
|
// src/core/resources/interop/route.ts
|
|
@@ -8156,7 +8839,7 @@ function preflightDirect(params, ctx) {
|
|
|
8156
8839
|
}
|
|
8157
8840
|
}
|
|
8158
8841
|
}
|
|
8159
|
-
function buildDirectBundle(params, ctx, attrs) {
|
|
8842
|
+
function buildDirectBundle(params, ctx, attrs, interopFeeInfo) {
|
|
8160
8843
|
const totalActionValue = sumActionMsgValue(params.actions);
|
|
8161
8844
|
const starters = params.actions.map((action, index) => {
|
|
8162
8845
|
const to = ctx.codec.formatAddress(action.to);
|
|
@@ -8174,7 +8857,8 @@ function buildDirectBundle(params, ctx, attrs) {
|
|
|
8174
8857
|
dstChain: ctx.codec.formatChain(ctx.dstChainId),
|
|
8175
8858
|
starters,
|
|
8176
8859
|
bundleAttributes: attrs.bundleAttributes,
|
|
8177
|
-
approvals: [],
|
|
8860
|
+
approvals: interopFeeInfo.approval ? [interopFeeInfo.approval] : [],
|
|
8861
|
+
interopFee: interopFeeInfo.fee,
|
|
8178
8862
|
quoteExtras: {
|
|
8179
8863
|
totalActionValue,
|
|
8180
8864
|
bridgedTokenTotal: 0n
|
|
@@ -8219,7 +8903,7 @@ function preflightIndirect(params, ctx) {
|
|
|
8219
8903
|
}
|
|
8220
8904
|
}
|
|
8221
8905
|
}
|
|
8222
|
-
function buildIndirectBundle(params, ctx, attrs, starterData) {
|
|
8906
|
+
function buildIndirectBundle(params, ctx, attrs, starterData, interopFeeInfo) {
|
|
8223
8907
|
const totalActionValue = sumActionMsgValue(params.actions);
|
|
8224
8908
|
const bridgedTokenTotal = sumErc20Amounts(params.actions);
|
|
8225
8909
|
const approvalMap = /* @__PURE__ */ new Map();
|
|
@@ -8238,6 +8922,7 @@ function buildIndirectBundle(params, ctx, attrs, starterData) {
|
|
|
8238
8922
|
}
|
|
8239
8923
|
}
|
|
8240
8924
|
const approvals = Array.from(approvalMap.values());
|
|
8925
|
+
if (interopFeeInfo.approval) approvals.push(interopFeeInfo.approval);
|
|
8241
8926
|
const starters = params.actions.map((action, index) => {
|
|
8242
8927
|
const callAttributes = attrs.callAttributes[index] ?? [];
|
|
8243
8928
|
if (starterData[index]?.assetRouterPayload) {
|
|
@@ -8261,6 +8946,7 @@ function buildIndirectBundle(params, ctx, attrs, starterData) {
|
|
|
8261
8946
|
starters,
|
|
8262
8947
|
bundleAttributes: attrs.bundleAttributes,
|
|
8263
8948
|
approvals,
|
|
8949
|
+
interopFee: interopFeeInfo.fee,
|
|
8264
8950
|
quoteExtras: {
|
|
8265
8951
|
totalActionValue,
|
|
8266
8952
|
bridgedTokenTotal
|
|
@@ -8307,6 +8993,29 @@ function buildEnsureTokenSteps(erc20Tokens, ctx) {
|
|
|
8307
8993
|
}
|
|
8308
8994
|
}));
|
|
8309
8995
|
}
|
|
8996
|
+
async function buildApproveSteps(approvals, ctx) {
|
|
8997
|
+
const steps = [];
|
|
8998
|
+
for (const approval of approvals) {
|
|
8999
|
+
const erc20 = new ethers.Contract(approval.token, IERC20_default, ctx.client.l2);
|
|
9000
|
+
const currentAllowance = await erc20.allowance(ctx.sender, approval.spender);
|
|
9001
|
+
if (currentAllowance < approval.amount) {
|
|
9002
|
+
steps.push({
|
|
9003
|
+
key: `approve:${approval.token}:${approval.spender}`,
|
|
9004
|
+
kind: "approve",
|
|
9005
|
+
description: `Approve ${approval.spender} to spend ${approval.amount} of ${approval.token}`,
|
|
9006
|
+
tx: {
|
|
9007
|
+
to: approval.token,
|
|
9008
|
+
data: erc20.interface.encodeFunctionData("approve", [
|
|
9009
|
+
approval.spender,
|
|
9010
|
+
approval.amount
|
|
9011
|
+
]),
|
|
9012
|
+
...ctx.gasOverrides
|
|
9013
|
+
}
|
|
9014
|
+
});
|
|
9015
|
+
}
|
|
9016
|
+
}
|
|
9017
|
+
return steps;
|
|
9018
|
+
}
|
|
8310
9019
|
async function resolveErc20AssetIds(erc20Tokens, ctx) {
|
|
8311
9020
|
const assetIds = /* @__PURE__ */ new Map();
|
|
8312
9021
|
if (erc20Tokens.length === 0) return assetIds;
|
|
@@ -8360,6 +9069,44 @@ async function getStarterData(params, ctx, erc20AssetIds) {
|
|
|
8360
9069
|
}
|
|
8361
9070
|
return starterData;
|
|
8362
9071
|
}
|
|
9072
|
+
var { wrap: wrap2 } = createErrorHandlers("interop");
|
|
9073
|
+
async function buildFeeInfo(params, ctx, numStarters) {
|
|
9074
|
+
const useFixed = params.fee?.useFixed ?? false;
|
|
9075
|
+
const interopCenter = new ethers.Contract(ctx.interopCenter, IInteropCenter_default, ctx.client.l2);
|
|
9076
|
+
if (useFixed) {
|
|
9077
|
+
const zkFeePerCall = await wrap2(
|
|
9078
|
+
OP_INTEROP.svc.fees.zkInteropFee,
|
|
9079
|
+
() => interopCenter.ZK_INTEROP_FEE(),
|
|
9080
|
+
{ message: "Failed to fetch ZK interop fee from InteropCenter." }
|
|
9081
|
+
);
|
|
9082
|
+
const zkFeeTotal = zkFeePerCall * BigInt(numStarters);
|
|
9083
|
+
const zkTokenAddress = await wrap2(
|
|
9084
|
+
OP_INTEROP.svc.fees.zkToken,
|
|
9085
|
+
() => interopCenter.zkToken(),
|
|
9086
|
+
{ message: "Failed to fetch ZK token address from InteropCenter." }
|
|
9087
|
+
);
|
|
9088
|
+
const approval = {
|
|
9089
|
+
token: zkTokenAddress,
|
|
9090
|
+
spender: ctx.interopCenter,
|
|
9091
|
+
amount: zkFeeTotal
|
|
9092
|
+
};
|
|
9093
|
+
return {
|
|
9094
|
+
approval,
|
|
9095
|
+
fee: { token: zkTokenAddress, amount: zkFeeTotal }
|
|
9096
|
+
};
|
|
9097
|
+
} else {
|
|
9098
|
+
const protocolFeePerCall = await wrap2(
|
|
9099
|
+
OP_INTEROP.svc.fees.protocolFee,
|
|
9100
|
+
() => interopCenter.interopProtocolFee(),
|
|
9101
|
+
{ message: "Failed to fetch interop protocol fee from InteropCenter." }
|
|
9102
|
+
);
|
|
9103
|
+
const totalFee = protocolFeePerCall * BigInt(numStarters);
|
|
9104
|
+
return {
|
|
9105
|
+
approval: null,
|
|
9106
|
+
fee: { token: ctx.baseTokens.src, amount: totalFee }
|
|
9107
|
+
};
|
|
9108
|
+
}
|
|
9109
|
+
}
|
|
8363
9110
|
|
|
8364
9111
|
// src/adapters/ethers/resources/interop/routes/indirect.ts
|
|
8365
9112
|
function routeIndirect() {
|
|
@@ -8375,7 +9122,10 @@ function routeIndirect() {
|
|
|
8375
9122
|
async build(params, ctx) {
|
|
8376
9123
|
const steps = [];
|
|
8377
9124
|
const erc20Tokens = getErc20Tokens(params);
|
|
8378
|
-
const erc20AssetIds = await
|
|
9125
|
+
const [erc20AssetIds, feeInfo] = await Promise.all([
|
|
9126
|
+
resolveErc20AssetIds(erc20Tokens, ctx),
|
|
9127
|
+
buildFeeInfo(params, ctx, params.actions.length)
|
|
9128
|
+
]);
|
|
8379
9129
|
const attributes = getInteropAttributes(params, ctx);
|
|
8380
9130
|
const starterData = await getStarterData(params, ctx, erc20AssetIds);
|
|
8381
9131
|
const bundle = buildIndirectBundle(
|
|
@@ -8388,32 +9138,11 @@ function routeIndirect() {
|
|
|
8388
9138
|
codec: interopCodec
|
|
8389
9139
|
},
|
|
8390
9140
|
attributes,
|
|
8391
|
-
starterData
|
|
9141
|
+
starterData,
|
|
9142
|
+
feeInfo
|
|
8392
9143
|
);
|
|
8393
9144
|
steps.push(...buildEnsureTokenSteps(erc20Tokens, ctx));
|
|
8394
|
-
|
|
8395
|
-
const erc20 = new ethers.Contract(approval.token, IERC20_default, ctx.client.l2);
|
|
8396
|
-
const currentAllowance = await erc20.allowance(
|
|
8397
|
-
ctx.sender,
|
|
8398
|
-
ctx.l2NativeTokenVault
|
|
8399
|
-
);
|
|
8400
|
-
if (currentAllowance < approval.amount) {
|
|
8401
|
-
const approveData = erc20.interface.encodeFunctionData("approve", [
|
|
8402
|
-
ctx.l2NativeTokenVault,
|
|
8403
|
-
approval.amount
|
|
8404
|
-
]);
|
|
8405
|
-
steps.push({
|
|
8406
|
-
key: `approve:${approval.token}:${ctx.l2NativeTokenVault}`,
|
|
8407
|
-
kind: "approve",
|
|
8408
|
-
description: `Approve ${ctx.l2NativeTokenVault} to spend ${approval.amount} of ${approval.token}`,
|
|
8409
|
-
tx: {
|
|
8410
|
-
to: approval.token,
|
|
8411
|
-
data: approveData,
|
|
8412
|
-
...ctx.gasOverrides
|
|
8413
|
-
}
|
|
8414
|
-
});
|
|
8415
|
-
}
|
|
8416
|
-
}
|
|
9145
|
+
steps.push(...await buildApproveSteps(bundle.approvals, ctx));
|
|
8417
9146
|
const data = ctx.ifaces.interopCenter.encodeFunctionData("sendBundle", [
|
|
8418
9147
|
bundle.dstChain,
|
|
8419
9148
|
bundle.starters,
|
|
@@ -8426,14 +9155,15 @@ function routeIndirect() {
|
|
|
8426
9155
|
tx: {
|
|
8427
9156
|
to: ctx.interopCenter,
|
|
8428
9157
|
data,
|
|
8429
|
-
value: bundle.quoteExtras.totalActionValue,
|
|
9158
|
+
value: bundle.quoteExtras.totalActionValue + feeInfo.fee.amount,
|
|
8430
9159
|
...ctx.gasOverrides
|
|
8431
9160
|
}
|
|
8432
9161
|
});
|
|
8433
9162
|
return {
|
|
8434
9163
|
steps,
|
|
8435
9164
|
approvals: bundle.approvals,
|
|
8436
|
-
quoteExtras: bundle.quoteExtras
|
|
9165
|
+
quoteExtras: bundle.quoteExtras,
|
|
9166
|
+
interopFee: feeInfo.fee
|
|
8437
9167
|
};
|
|
8438
9168
|
}
|
|
8439
9169
|
};
|
|
@@ -8450,10 +9180,10 @@ function routeDirect() {
|
|
|
8450
9180
|
l2AssetRouter: ctx.l2AssetRouter,
|
|
8451
9181
|
l2NativeTokenVault: ctx.l2NativeTokenVault});
|
|
8452
9182
|
},
|
|
8453
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
8454
9183
|
async build(params, ctx) {
|
|
8455
9184
|
const steps = [];
|
|
8456
9185
|
const attrs = getInteropAttributes(params, ctx);
|
|
9186
|
+
const feeInfo = await buildFeeInfo(params, ctx, params.actions.length);
|
|
8457
9187
|
const built = buildDirectBundle(
|
|
8458
9188
|
params,
|
|
8459
9189
|
{
|
|
@@ -8463,8 +9193,10 @@ function routeDirect() {
|
|
|
8463
9193
|
l2NativeTokenVault: ctx.l2NativeTokenVault,
|
|
8464
9194
|
codec: interopCodec
|
|
8465
9195
|
},
|
|
8466
|
-
attrs
|
|
9196
|
+
attrs,
|
|
9197
|
+
feeInfo
|
|
8467
9198
|
);
|
|
9199
|
+
steps.push(...await buildApproveSteps(built.approvals, ctx));
|
|
8468
9200
|
const data = ctx.ifaces.interopCenter.encodeFunctionData("sendBundle", [
|
|
8469
9201
|
built.dstChain,
|
|
8470
9202
|
built.starters,
|
|
@@ -8474,43 +9206,47 @@ function routeDirect() {
|
|
|
8474
9206
|
key: "sendBundle",
|
|
8475
9207
|
kind: "interop.center",
|
|
8476
9208
|
description: `Send interop bundle (direct route; ${params.actions.length} actions)`,
|
|
8477
|
-
//
|
|
8478
|
-
// all calls (sendNative.amount + call.value).
|
|
9209
|
+
// msg.value = forwarded action value + protocol fee.
|
|
8479
9210
|
tx: {
|
|
8480
9211
|
to: ctx.interopCenter,
|
|
8481
9212
|
data,
|
|
8482
|
-
value: built.quoteExtras.totalActionValue,
|
|
9213
|
+
value: built.quoteExtras.totalActionValue + feeInfo.fee.amount,
|
|
8483
9214
|
...ctx.gasOverrides
|
|
8484
9215
|
}
|
|
8485
9216
|
});
|
|
8486
9217
|
return {
|
|
8487
9218
|
steps,
|
|
8488
9219
|
approvals: built.approvals,
|
|
8489
|
-
quoteExtras: built.quoteExtras
|
|
9220
|
+
quoteExtras: built.quoteExtras,
|
|
9221
|
+
interopFee: feeInfo.fee
|
|
8490
9222
|
};
|
|
8491
9223
|
}
|
|
8492
9224
|
};
|
|
8493
9225
|
}
|
|
9226
|
+
|
|
9227
|
+
// src/core/resources/interop/protocol.ts
|
|
8494
9228
|
var MIN_INTEROP_PROTOCOL = 31;
|
|
9229
|
+
function assertProtocolVersion(chainId, protocolVersion) {
|
|
9230
|
+
if (protocolVersion[1] < MIN_INTEROP_PROTOCOL) {
|
|
9231
|
+
throw createError("VALIDATION", {
|
|
9232
|
+
resource: "interop",
|
|
9233
|
+
operation: OP_INTEROP.context.protocolVersion,
|
|
9234
|
+
message: `Interop requires protocol version 31.0+. Found: ${protocolVersion[1]}.${protocolVersion[2]} for chain: ${chainId}.`,
|
|
9235
|
+
context: {
|
|
9236
|
+
chainId,
|
|
9237
|
+
requiredMinor: MIN_INTEROP_PROTOCOL,
|
|
9238
|
+
semver: protocolVersion
|
|
9239
|
+
}
|
|
9240
|
+
});
|
|
9241
|
+
}
|
|
9242
|
+
}
|
|
9243
|
+
|
|
9244
|
+
// src/adapters/ethers/resources/interop/context.ts
|
|
8495
9245
|
async function assertInteropProtocolVersion(client, srcChainId, dstChainId) {
|
|
8496
9246
|
const [srcProtocolVersion, dstProtocolVersion] = await Promise.all([
|
|
8497
9247
|
client.getProtocolVersion(srcChainId),
|
|
8498
9248
|
client.getProtocolVersion(dstChainId)
|
|
8499
9249
|
]);
|
|
8500
|
-
const assertProtocolVersion = (chainId, protocolVersion) => {
|
|
8501
|
-
if (protocolVersion[1] < MIN_INTEROP_PROTOCOL) {
|
|
8502
|
-
throw createError("VALIDATION", {
|
|
8503
|
-
resource: "interop",
|
|
8504
|
-
operation: OP_INTEROP.context.protocolVersion,
|
|
8505
|
-
message: `Interop requires protocol version 31.0+. Found: ${protocolVersion[1]}.${protocolVersion[2]} for chain: ${chainId}.`,
|
|
8506
|
-
context: {
|
|
8507
|
-
chainId,
|
|
8508
|
-
requiredMinor: MIN_INTEROP_PROTOCOL,
|
|
8509
|
-
semver: protocolVersion
|
|
8510
|
-
}
|
|
8511
|
-
});
|
|
8512
|
-
}
|
|
8513
|
-
};
|
|
8514
9250
|
assertProtocolVersion(srcChainId, srcProtocolVersion);
|
|
8515
9251
|
assertProtocolVersion(dstChainId, dstProtocolVersion);
|
|
8516
9252
|
}
|
|
@@ -8566,7 +9302,7 @@ function getTopics() {
|
|
|
8566
9302
|
};
|
|
8567
9303
|
return { topics, centerIface };
|
|
8568
9304
|
}
|
|
8569
|
-
var { wrap:
|
|
9305
|
+
var { wrap: wrap3 } = createErrorHandlers("interop");
|
|
8570
9306
|
var DEFAULT_BLOCKS_RANGE_SIZE = 1e4;
|
|
8571
9307
|
var DEFAULT_MAX_BLOCKS_BACK = 2e4;
|
|
8572
9308
|
var SAFE_BLOCKS_RANGE_SIZE = 1e3;
|
|
@@ -8579,9 +9315,16 @@ function parseMaxBlockRangeLimit(error) {
|
|
|
8579
9315
|
return Number.isInteger(limit) && limit > 0 ? limit : null;
|
|
8580
9316
|
}
|
|
8581
9317
|
async function getTxReceipt(provider, txHash) {
|
|
8582
|
-
const receipt = await
|
|
9318
|
+
const receipt = await wrap3(
|
|
8583
9319
|
OP_INTEROP.svc.status.sourceReceipt,
|
|
8584
|
-
() =>
|
|
9320
|
+
async () => {
|
|
9321
|
+
try {
|
|
9322
|
+
return await provider.getTransactionReceipt(txHash);
|
|
9323
|
+
} catch (error) {
|
|
9324
|
+
if (isReceiptNotFound(error)) return null;
|
|
9325
|
+
throw error;
|
|
9326
|
+
}
|
|
9327
|
+
},
|
|
8585
9328
|
{
|
|
8586
9329
|
ctx: { where: "l2.getTransactionReceipt", l2SrcTxHash: txHash },
|
|
8587
9330
|
message: "Failed to fetch source L2 receipt for interop tx."
|
|
@@ -8600,7 +9343,7 @@ async function getTxReceipt(provider, txHash) {
|
|
|
8600
9343
|
async function getLogs(provider, address, topics, opts) {
|
|
8601
9344
|
const maxBlocksBack = opts?.maxBlocksBack ?? DEFAULT_MAX_BLOCKS_BACK;
|
|
8602
9345
|
const initialChunkSize = opts?.logChunkSize ?? DEFAULT_BLOCKS_RANGE_SIZE;
|
|
8603
|
-
return await
|
|
9346
|
+
return await wrap3(
|
|
8604
9347
|
OP_INTEROP.svc.status.dstLogs,
|
|
8605
9348
|
async () => {
|
|
8606
9349
|
const currentBlock = await provider.getBlockNumber();
|
|
@@ -8647,7 +9390,7 @@ async function getLogs(provider, address, topics, opts) {
|
|
|
8647
9390
|
);
|
|
8648
9391
|
}
|
|
8649
9392
|
async function getInteropRoot(provider, rootChainId, batchNumber) {
|
|
8650
|
-
return await
|
|
9393
|
+
return await wrap3(
|
|
8651
9394
|
OP_INTEROP.svc.status.getRoot,
|
|
8652
9395
|
async () => {
|
|
8653
9396
|
const rootStorage = new ethers.Contract(
|
|
@@ -8665,7 +9408,7 @@ async function getInteropRoot(provider, rootChainId, batchNumber) {
|
|
|
8665
9408
|
}
|
|
8666
9409
|
|
|
8667
9410
|
// src/adapters/ethers/resources/interop/services/finalization/bundle.ts
|
|
8668
|
-
var { wrap:
|
|
9411
|
+
var { wrap: wrap4 } = createErrorHandlers("interop");
|
|
8669
9412
|
async function getBundleStatus(client, dstProvider, topics, bundleHash, opts) {
|
|
8670
9413
|
const { interopHandler } = await client.ensureAddresses();
|
|
8671
9414
|
const bundleLogs = await getLogs(dstProvider, interopHandler, [null, bundleHash], opts);
|
|
@@ -8697,7 +9440,7 @@ async function executeBundle(client, dstProvider, info, opts) {
|
|
|
8697
9440
|
context: { bundleHash }
|
|
8698
9441
|
});
|
|
8699
9442
|
}
|
|
8700
|
-
const signer = await
|
|
9443
|
+
const signer = await wrap4(OP_INTEROP.exec.sendStep, () => client.signerFor(dstProvider), {
|
|
8701
9444
|
message: "Failed to resolve destination signer."
|
|
8702
9445
|
});
|
|
8703
9446
|
const { interopHandler } = await client.ensureAddresses();
|
|
@@ -8859,11 +9602,6 @@ function getBundleEncodedData(messageData) {
|
|
|
8859
9602
|
return `0x${messageData.slice(4)}`;
|
|
8860
9603
|
}
|
|
8861
9604
|
function buildFinalizationInfo(ids, bundleInfo, proof, messageData) {
|
|
8862
|
-
const expectedRoot = {
|
|
8863
|
-
rootChainId: bundleInfo.sourceChainId,
|
|
8864
|
-
batchNumber: proof.batchNumber,
|
|
8865
|
-
expectedRoot: proof.root
|
|
8866
|
-
};
|
|
8867
9605
|
const messageProof = {
|
|
8868
9606
|
chainId: bundleInfo.sourceChainId,
|
|
8869
9607
|
l1BatchNumber: proof.batchNumber,
|
|
@@ -8879,7 +9617,6 @@ function buildFinalizationInfo(ids, bundleInfo, proof, messageData) {
|
|
|
8879
9617
|
l2SrcTxHash: ids.l2SrcTxHash,
|
|
8880
9618
|
bundleHash: bundleInfo.bundleHash,
|
|
8881
9619
|
dstChainId: bundleInfo.dstChainId,
|
|
8882
|
-
expectedRoot,
|
|
8883
9620
|
proof: messageProof,
|
|
8884
9621
|
encodedData: getBundleEncodedData(messageData)
|
|
8885
9622
|
};
|
|
@@ -8902,7 +9639,7 @@ function decodeL1MessageData(log) {
|
|
|
8902
9639
|
}
|
|
8903
9640
|
|
|
8904
9641
|
// src/adapters/ethers/resources/interop/services/finalization/polling.ts
|
|
8905
|
-
var { wrap:
|
|
9642
|
+
var { wrap: wrap5 } = createErrorHandlers("interop");
|
|
8906
9643
|
function isProofNotReadyError(error) {
|
|
8907
9644
|
return isZKsyncError(error, {
|
|
8908
9645
|
operation: "zksrpc.getL2ToL1LogProof",
|
|
@@ -8939,30 +9676,26 @@ async function waitForProof(client, l2SrcTxHash, logIndex, blockNumber, pollMs,
|
|
|
8939
9676
|
});
|
|
8940
9677
|
}
|
|
8941
9678
|
try {
|
|
8942
|
-
return await client.zks.getL2ToL1LogProof(l2SrcTxHash, logIndex);
|
|
9679
|
+
return await client.zks.getL2ToL1LogProof(l2SrcTxHash, logIndex, "messageRoot" /* MessageRoot */);
|
|
8943
9680
|
} catch (error) {
|
|
8944
9681
|
if (!isProofNotReadyError(error)) throw error;
|
|
8945
9682
|
}
|
|
8946
9683
|
await sleep(pollMs);
|
|
8947
9684
|
}
|
|
8948
9685
|
}
|
|
8949
|
-
async function waitForRoot(provider,
|
|
9686
|
+
async function waitForRoot(provider, chainId, batchNumber, pollMs, deadline) {
|
|
8950
9687
|
while (true) {
|
|
8951
9688
|
if (Date.now() > deadline) {
|
|
8952
9689
|
throw createError("TIMEOUT", {
|
|
8953
9690
|
resource: "interop",
|
|
8954
9691
|
operation: OP_INTEROP.svc.wait.timeout,
|
|
8955
9692
|
message: "Timed out waiting for interop root to become available.",
|
|
8956
|
-
context: {
|
|
9693
|
+
context: { chainId, batchNumber }
|
|
8957
9694
|
});
|
|
8958
9695
|
}
|
|
8959
9696
|
let interopRoot = null;
|
|
8960
9697
|
try {
|
|
8961
|
-
const root = await getInteropRoot(
|
|
8962
|
-
provider,
|
|
8963
|
-
expectedRoot.rootChainId,
|
|
8964
|
-
expectedRoot.batchNumber
|
|
8965
|
-
);
|
|
9698
|
+
const root = await getInteropRoot(provider, chainId, batchNumber);
|
|
8966
9699
|
if (root !== ZERO_HASH) {
|
|
8967
9700
|
interopRoot = root;
|
|
8968
9701
|
}
|
|
@@ -8971,18 +9704,7 @@ async function waitForRoot(provider, expectedRoot, pollMs, deadline) {
|
|
|
8971
9704
|
interopRoot = null;
|
|
8972
9705
|
}
|
|
8973
9706
|
if (interopRoot) {
|
|
8974
|
-
|
|
8975
|
-
return;
|
|
8976
|
-
}
|
|
8977
|
-
throw createError("STATE", {
|
|
8978
|
-
resource: "interop",
|
|
8979
|
-
operation: OP_INTEROP.wait,
|
|
8980
|
-
message: "Interop root mismatch.",
|
|
8981
|
-
context: {
|
|
8982
|
-
expected: expectedRoot.expectedRoot,
|
|
8983
|
-
got: interopRoot
|
|
8984
|
-
}
|
|
8985
|
-
});
|
|
9707
|
+
return interopRoot;
|
|
8986
9708
|
}
|
|
8987
9709
|
await sleep(pollMs);
|
|
8988
9710
|
}
|
|
@@ -8997,7 +9719,7 @@ async function waitForTxReceipt(client, txHash, pollMs, deadline) {
|
|
|
8997
9719
|
context: { txHash }
|
|
8998
9720
|
});
|
|
8999
9721
|
}
|
|
9000
|
-
const receipt = await
|
|
9722
|
+
const receipt = await wrap5(
|
|
9001
9723
|
OP_INTEROP.svc.status.sourceReceipt,
|
|
9002
9724
|
() => client.zks.getReceiptWithL2ToL1(txHash),
|
|
9003
9725
|
{
|
|
@@ -9011,7 +9733,7 @@ async function waitForTxReceipt(client, txHash, pollMs, deadline) {
|
|
|
9011
9733
|
await sleep(pollMs);
|
|
9012
9734
|
}
|
|
9013
9735
|
}
|
|
9014
|
-
async function waitForFinalization(client, dstProvider, input, opts) {
|
|
9736
|
+
async function waitForFinalization(client, dstProvider, gwProvider, input, opts) {
|
|
9015
9737
|
const { topics, centerIface } = getTopics();
|
|
9016
9738
|
const pollMs = opts?.pollMs ?? DEFAULT_POLL_MS;
|
|
9017
9739
|
const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -9060,7 +9782,16 @@ async function waitForFinalization(client, dstProvider, input, opts) {
|
|
|
9060
9782
|
proof,
|
|
9061
9783
|
bundleInfo.l1MessageData
|
|
9062
9784
|
);
|
|
9063
|
-
|
|
9785
|
+
if (proof.gatewayBlockNumber == null) {
|
|
9786
|
+
throw createError("STATE", {
|
|
9787
|
+
resource: "interop",
|
|
9788
|
+
operation: OP_INTEROP.svc.wait.timeout,
|
|
9789
|
+
message: "Proof missing gatewayBlockNumber required for interop finalization.",
|
|
9790
|
+
context: { l2SrcTxHash: ids.l2SrcTxHash }
|
|
9791
|
+
});
|
|
9792
|
+
}
|
|
9793
|
+
const { chainId: gwChainId } = await gwProvider.getNetwork();
|
|
9794
|
+
await waitForRoot(dstProvider, gwChainId, proof.gatewayBlockNumber, pollMs, deadline);
|
|
9064
9795
|
return finalizationInfo;
|
|
9065
9796
|
}
|
|
9066
9797
|
|
|
@@ -9106,8 +9837,8 @@ function createInteropFinalizationServices(client) {
|
|
|
9106
9837
|
status(dstProvider, input, opts) {
|
|
9107
9838
|
return getStatus(client, dstProvider, input, opts);
|
|
9108
9839
|
},
|
|
9109
|
-
wait(dstProvider, input, opts) {
|
|
9110
|
-
return waitForFinalization(client, dstProvider, input, opts);
|
|
9840
|
+
wait(dstProvider, gwProvider, input, opts) {
|
|
9841
|
+
return waitForFinalization(client, dstProvider, gwProvider, input, opts);
|
|
9111
9842
|
},
|
|
9112
9843
|
async finalize(dstProvider, info, opts) {
|
|
9113
9844
|
const execResult = await executeBundle(client, dstProvider, info, opts);
|
|
@@ -9119,27 +9850,59 @@ function createInteropFinalizationServices(client) {
|
|
|
9119
9850
|
}
|
|
9120
9851
|
};
|
|
9121
9852
|
}
|
|
9122
|
-
function
|
|
9123
|
-
return typeof
|
|
9853
|
+
function resolveChainRef(ref) {
|
|
9854
|
+
return typeof ref === "string" ? new ethers.JsonRpcProvider(ref) : ref;
|
|
9124
9855
|
}
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9856
|
+
|
|
9857
|
+
// src/adapters/ethers/resources/interop/services/gas.ts
|
|
9858
|
+
async function quoteStepsL2Fee(steps, ctx) {
|
|
9859
|
+
if (steps.length === 0) return 0n;
|
|
9860
|
+
const estimator = ethersToGasEstimator(ctx.client.l2);
|
|
9861
|
+
let maxFeePerGas;
|
|
9862
|
+
try {
|
|
9863
|
+
const fees = await estimator.estimateFeesPerGas();
|
|
9864
|
+
maxFeePerGas = fees.maxFeePerGas ?? fees.gasPrice ?? await estimator.getGasPrice();
|
|
9865
|
+
} catch {
|
|
9866
|
+
return void 0;
|
|
9867
|
+
}
|
|
9868
|
+
let total = 0n;
|
|
9869
|
+
for (const step of steps) {
|
|
9870
|
+
try {
|
|
9871
|
+
const coreTx = toCoreTx({ ...step.tx, from: ctx.sender });
|
|
9872
|
+
const est = await estimator.estimateGas(coreTx);
|
|
9873
|
+
const buffered = BigInt(est) * (100n + BUFFER) / 100n;
|
|
9874
|
+
total += buffered * maxFeePerGas;
|
|
9875
|
+
} catch {
|
|
9876
|
+
return void 0;
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9879
|
+
return total;
|
|
9131
9880
|
}
|
|
9132
9881
|
|
|
9133
9882
|
// src/adapters/ethers/resources/interop/index.ts
|
|
9134
|
-
var { wrap:
|
|
9883
|
+
var { wrap: wrap6, toResult: toResult2 } = createErrorHandlers("interop");
|
|
9135
9884
|
var ROUTES3 = {
|
|
9136
9885
|
direct: routeDirect(),
|
|
9137
9886
|
indirect: routeIndirect()
|
|
9138
9887
|
};
|
|
9139
|
-
function createInteropResource(client, tokens, contracts, attributes) {
|
|
9888
|
+
function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
9889
|
+
let gwProviderCache;
|
|
9890
|
+
function requireConfig() {
|
|
9891
|
+
if (!config)
|
|
9892
|
+
throw createError("STATE", {
|
|
9893
|
+
resource: "interop",
|
|
9894
|
+
operation: "interop.init",
|
|
9895
|
+
message: "Interop is not configured. Pass gwChain in createEthersSdk options."
|
|
9896
|
+
});
|
|
9897
|
+
return config;
|
|
9898
|
+
}
|
|
9899
|
+
function getGwProvider() {
|
|
9900
|
+
if (!gwProviderCache) gwProviderCache = resolveChainRef(requireConfig().gwChain);
|
|
9901
|
+
return gwProviderCache;
|
|
9902
|
+
}
|
|
9140
9903
|
const svc = createInteropFinalizationServices(client);
|
|
9141
|
-
const tokensResource = createTokensResource(client);
|
|
9142
|
-
const contractsResource = createContractsResource(client);
|
|
9904
|
+
const tokensResource = tokens ?? createTokensResource(client);
|
|
9905
|
+
const contractsResource = contracts ?? createContractsResource(client);
|
|
9143
9906
|
const attributesResource = createEthersAttributesResource();
|
|
9144
9907
|
async function buildPlanWithCtx(dstProvider, params) {
|
|
9145
9908
|
const ctx = await commonCtx3(
|
|
@@ -9160,11 +9923,11 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9160
9923
|
baseTokenDst: ctx.baseTokens.dst
|
|
9161
9924
|
}
|
|
9162
9925
|
});
|
|
9163
|
-
await
|
|
9926
|
+
await wrap6(OP_INTEROP.routes[route].preflight, () => ROUTES3[route].preflight?.(params, ctx), {
|
|
9164
9927
|
message: "Interop preflight failed.",
|
|
9165
9928
|
ctx: { where: `routes.${route}.preflight` }
|
|
9166
9929
|
});
|
|
9167
|
-
const { steps, approvals, quoteExtras } = await
|
|
9930
|
+
const { steps, approvals, quoteExtras, interopFee } = await wrap6(
|
|
9168
9931
|
OP_INTEROP.routes[route].build,
|
|
9169
9932
|
() => ROUTES3[route].build(params, ctx),
|
|
9170
9933
|
{
|
|
@@ -9172,11 +9935,14 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9172
9935
|
ctx: { where: `routes.${route}.build` }
|
|
9173
9936
|
}
|
|
9174
9937
|
);
|
|
9938
|
+
const l2Fee = await quoteStepsL2Fee(steps, ctx).catch(() => void 0);
|
|
9175
9939
|
const summary = {
|
|
9176
9940
|
route,
|
|
9177
9941
|
approvalsNeeded: approvals,
|
|
9178
9942
|
totalActionValue: quoteExtras.totalActionValue,
|
|
9179
|
-
bridgedTokenTotal: quoteExtras.bridgedTokenTotal
|
|
9943
|
+
bridgedTokenTotal: quoteExtras.bridgedTokenTotal,
|
|
9944
|
+
interopFee,
|
|
9945
|
+
l2Fee
|
|
9180
9946
|
};
|
|
9181
9947
|
return { plan: { route, summary, steps }, ctx };
|
|
9182
9948
|
}
|
|
@@ -9184,20 +9950,23 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9184
9950
|
const { plan } = await buildPlanWithCtx(dstProvider, params);
|
|
9185
9951
|
return plan;
|
|
9186
9952
|
}
|
|
9187
|
-
const quote = (params) =>
|
|
9188
|
-
const plan = await buildPlan(
|
|
9953
|
+
const quote = (dstChain, params) => wrap6(OP_INTEROP.quote, async () => {
|
|
9954
|
+
const plan = await buildPlan(resolveChainRef(dstChain), params);
|
|
9189
9955
|
return plan.summary;
|
|
9190
9956
|
});
|
|
9191
|
-
const tryQuote = (params) => toResult2(OP_INTEROP.tryQuote, () => quote(params));
|
|
9192
|
-
const prepare = (params) =>
|
|
9957
|
+
const tryQuote = (dstChain, params) => toResult2(OP_INTEROP.tryQuote, () => quote(dstChain, params));
|
|
9958
|
+
const prepare = (dstChain, params) => wrap6(OP_INTEROP.prepare, () => buildPlan(resolveChainRef(dstChain), params), {
|
|
9193
9959
|
message: "Internal error while preparing an interop plan.",
|
|
9194
9960
|
ctx: { where: "interop.prepare" }
|
|
9195
9961
|
});
|
|
9196
|
-
const tryPrepare = (params) => toResult2(
|
|
9197
|
-
|
|
9962
|
+
const tryPrepare = (dstChain, params) => toResult2(
|
|
9963
|
+
OP_INTEROP.tryPrepare,
|
|
9964
|
+
() => prepare(dstChain, params)
|
|
9965
|
+
);
|
|
9966
|
+
const create = (dstChain, params) => wrap6(
|
|
9198
9967
|
OP_INTEROP.create,
|
|
9199
9968
|
async () => {
|
|
9200
|
-
const { plan, ctx } = await buildPlanWithCtx(
|
|
9969
|
+
const { plan, ctx } = await buildPlanWithCtx(resolveChainRef(dstChain), params);
|
|
9201
9970
|
const signer = ctx.client.signerFor(ctx.client.l2);
|
|
9202
9971
|
const srcProvider = ctx.client.l2;
|
|
9203
9972
|
const from = await signer.getAddress();
|
|
@@ -9259,7 +10028,6 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9259
10028
|
const last = Object.values(stepHashes).pop();
|
|
9260
10029
|
return {
|
|
9261
10030
|
kind: "interop",
|
|
9262
|
-
dstChain: params.dstChain,
|
|
9263
10031
|
stepHashes,
|
|
9264
10032
|
plan,
|
|
9265
10033
|
l2SrcTxHash: last ?? "0x"
|
|
@@ -9270,46 +10038,27 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9270
10038
|
ctx: { where: "interop.create" }
|
|
9271
10039
|
}
|
|
9272
10040
|
);
|
|
9273
|
-
const tryCreate = (params) => toResult2(
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
}
|
|
9280
|
-
};
|
|
9281
|
-
const wait = (h, opts) => {
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
return { ...info, dstChain: h.dstChain };
|
|
9288
|
-
},
|
|
9289
|
-
{
|
|
9290
|
-
message: "Internal error while waiting for interop finalization.",
|
|
9291
|
-
ctx: { where: "interop.wait" }
|
|
9292
|
-
}
|
|
9293
|
-
);
|
|
9294
|
-
};
|
|
9295
|
-
const tryWait = (h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(h, opts));
|
|
9296
|
-
const finalize = (h, opts) => wrap5(
|
|
10041
|
+
const tryCreate = (dstChain, params) => toResult2(
|
|
10042
|
+
OP_INTEROP.tryCreate,
|
|
10043
|
+
() => create(dstChain, params)
|
|
10044
|
+
);
|
|
10045
|
+
const status = (dstChain, h, opts) => wrap6(OP_INTEROP.status, () => svc.status(resolveChainRef(dstChain), h, opts), {
|
|
10046
|
+
message: "Internal error while checking interop status.",
|
|
10047
|
+
ctx: { where: "interop.status" }
|
|
10048
|
+
});
|
|
10049
|
+
const wait = (dstChain, h, opts) => wrap6(OP_INTEROP.wait, () => svc.wait(resolveChainRef(dstChain), getGwProvider(), h, opts), {
|
|
10050
|
+
message: "Internal error while waiting for interop finalization.",
|
|
10051
|
+
ctx: { where: "interop.wait" }
|
|
10052
|
+
});
|
|
10053
|
+
const tryWait = (dstChain, h, opts) => toResult2(OP_INTEROP.tryWait, () => wait(dstChain, h, opts));
|
|
10054
|
+
const finalize = (dstChain, h, opts) => wrap6(
|
|
9297
10055
|
OP_INTEROP.finalize,
|
|
9298
10056
|
async () => {
|
|
10057
|
+
const dstProvider = resolveChainRef(dstChain);
|
|
9299
10058
|
if (isInteropFinalizationInfo(h)) {
|
|
9300
|
-
|
|
9301
|
-
throw createError("STATE", {
|
|
9302
|
-
resource: "interop",
|
|
9303
|
-
operation: OP_INTEROP.finalize,
|
|
9304
|
-
message: "Missing dstChain in interop finalization info.",
|
|
9305
|
-
context: { input: h }
|
|
9306
|
-
});
|
|
9307
|
-
}
|
|
9308
|
-
const dstProvider2 = resolveDstProvider(h.dstChain);
|
|
9309
|
-
return svc.finalize(dstProvider2, h, opts);
|
|
10059
|
+
return svc.finalize(dstProvider, h, opts);
|
|
9310
10060
|
}
|
|
9311
|
-
const
|
|
9312
|
-
const info = await svc.wait(dstProvider, waitable);
|
|
10061
|
+
const info = await svc.wait(dstProvider, getGwProvider(), h);
|
|
9313
10062
|
return svc.finalize(dstProvider, info, opts);
|
|
9314
10063
|
},
|
|
9315
10064
|
{
|
|
@@ -9317,7 +10066,7 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9317
10066
|
ctx: { where: "interop.finalize" }
|
|
9318
10067
|
}
|
|
9319
10068
|
);
|
|
9320
|
-
const tryFinalize = (h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(h, opts));
|
|
10069
|
+
const tryFinalize = (dstChain, h, opts) => toResult2(OP_INTEROP.tryFinalize, () => finalize(dstChain, h, opts));
|
|
9321
10070
|
return {
|
|
9322
10071
|
quote,
|
|
9323
10072
|
tryQuote,
|
|
@@ -9334,10 +10083,10 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
9334
10083
|
}
|
|
9335
10084
|
|
|
9336
10085
|
// src/adapters/ethers/sdk.ts
|
|
9337
|
-
function createEthersSdk(client) {
|
|
10086
|
+
function createEthersSdk(client, options) {
|
|
9338
10087
|
const tokens = createTokensResource(client);
|
|
9339
10088
|
const contracts = createContractsResource(client);
|
|
9340
|
-
const interop = createInteropResource(client);
|
|
10089
|
+
const interop = createInteropResource(client, options?.interop, tokens, contracts);
|
|
9341
10090
|
return {
|
|
9342
10091
|
deposits: createDepositsResource(client, tokens, contracts),
|
|
9343
10092
|
withdrawals: createWithdrawalsResource(client, tokens, contracts),
|