@moonbeam-network/xcm-builder 3.1.1 → 3.2.0

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/build/index.d.ts CHANGED
@@ -429,23 +429,38 @@ interface FeeConfigBuilderParams {
429
429
  asset: ChainAsset;
430
430
  destination: AnyParachain;
431
431
  feeAsset: ChainAsset;
432
+ source: AnyChain;
432
433
  }
433
434
  interface XcmPaymentFeeProps {
434
435
  isAssetReserveChain: boolean;
435
436
  shouldTransferAssetPrecedeFeeAsset?: boolean;
437
+ parents?: number;
436
438
  }
437
439
  interface MoonbeamRuntimeXcmConfigAssetType extends Enum {
438
440
  readonly isXcm: boolean;
439
441
  readonly asXcm: StagingXcmV3MultiLocation;
440
442
  readonly type: 'Xcm';
441
443
  }
444
+ type GetVersionedAssetId = (params: FeeConfigBuilderParams) => Promise<object> | object;
445
+
446
+ declare function xcmPaymentApi(): {
447
+ fromCurrencyIdToLocations: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
448
+ fromAssetIdQuery: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
449
+ fromSourceAccountKey20: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
450
+ fromSourcePalletInstance: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
451
+ fromHere: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
452
+ fromHereAndGeneralIndex: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
453
+ fromPalletInstanceAndGeneralIndex: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
454
+ fromHereAndSourceGeneralIndex: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
455
+ fromGeneralIndex: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
456
+ fromPalletInstance: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
457
+ fromPalletInstanceAndAccountKey20: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
458
+ fromGlobalConsensus: (options: XcmPaymentFeeProps) => FeeConfigBuilder;
459
+ };
442
460
 
443
461
  declare function FeeBuilder(): {
444
462
  xcmPaymentApi: typeof xcmPaymentApi;
445
463
  };
446
- declare function xcmPaymentApi(): {
447
- xcmPaymentFee: ({ isAssetReserveChain, shouldTransferAssetPrecedeFeeAsset, }: XcmPaymentFeeProps) => FeeConfigBuilder;
448
- };
449
464
 
450
465
  declare function wormhole$1(): {
451
466
  tokenTransfer: () => MrlConfigBuilder;
@@ -624,4 +639,4 @@ declare function MrlBuilder(): {
624
639
 
625
640
  declare const BATCH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000808";
626
641
 
627
- export { AssetMinBuilder, type AssetMinConfigBuilder, type AssetMinConfigBuilderParams, BATCH_CONTRACT_ABI, BATCH_CONTRACT_ADDRESS, BalanceBuilder, type BalanceBuilderParams, type BalanceConfigBuilder, type BuilderParams, type ConfigBuilder, ContractBuilder, ContractConfig, type ContractConfigBuilder, type ContractConfigConstructorParams, ERC20_ABI, type EquilibriumSystemBalanceData, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, type MoonbeamRuntimeXcmConfigAssetType, MrlBuilder, type MrlBuilderParams, type MrlConfigBuilder, type MrlExecuteBuilderParams, type MrlExecuteConfigBuilder, type PalletBalancesAccountDataOld, type Parents, type QueryConfigConstructorParams, SubstrateCallConfig, type SubstrateCallConfigConstructorParams, SubstrateQueryConfig, type TokensPalletAccountData, type Transact, WormholeConfig, type WormholeConfigConstructorParams, type WormholeFunctionArgs, type WormholeTransferFunctions, type XcmPaymentFeeProps, XcmVersion, calculateSystemAccountBalance, evm, substrate, wormhole, wormholeFactory };
642
+ export { AssetMinBuilder, type AssetMinConfigBuilder, type AssetMinConfigBuilderParams, BATCH_CONTRACT_ABI, BATCH_CONTRACT_ADDRESS, BalanceBuilder, type BalanceBuilderParams, type BalanceConfigBuilder, type BuilderParams, type ConfigBuilder, ContractBuilder, ContractConfig, type ContractConfigBuilder, type ContractConfigConstructorParams, ERC20_ABI, type EquilibriumSystemBalanceData, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, type GetVersionedAssetId, type MoonbeamRuntimeXcmConfigAssetType, MrlBuilder, type MrlBuilderParams, type MrlConfigBuilder, type MrlExecuteBuilderParams, type MrlExecuteConfigBuilder, type PalletBalancesAccountDataOld, type Parents, type QueryConfigConstructorParams, SubstrateCallConfig, type SubstrateCallConfigConstructorParams, SubstrateQueryConfig, type TokensPalletAccountData, type Transact, WormholeConfig, type WormholeConfigConstructorParams, type WormholeFunctionArgs, type WormholeTransferFunctions, type XcmPaymentFeeProps, XcmVersion, calculateSystemAccountBalance, evm, substrate, wormhole, wormholeFactory };
package/build/index.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  import "@polkadot/api-augment";
3
3
 
4
4
  // src/extrinsic/ExtrinsicBuilder.utils.ts
5
+ import { isEthAddress } from "@moonbeam-network/xcm-utils";
5
6
  import { getTypeDef } from "@polkadot/types";
6
7
  import { u8aToHex } from "@polkadot/util";
7
8
  import { decodeAddress } from "@polkadot/util-crypto";
@@ -44,8 +45,7 @@ function getExtrinsicArgumentVersion(func, index = 0) {
44
45
  throw new Error("Can't find XCM version");
45
46
  }
46
47
  function getExtrinsicAccount(address) {
47
- const isEthAddress = address.length === 42 && address.startsWith("0x");
48
- return isEthAddress ? {
48
+ return isEthAddress(address) ? {
49
49
  AccountKey20: {
50
50
  key: address
51
51
  }
@@ -2240,11 +2240,14 @@ function ExtrinsicBuilder() {
2240
2240
  }
2241
2241
 
2242
2242
  // src/fee/FeeBuilder.utils.ts
2243
+ import { isEthAddress as isEthAddress2 } from "@moonbeam-network/xcm-utils";
2244
+ import { u8aToHex as u8aToHex5 } from "@polkadot/util";
2245
+ import { decodeAddress as decodeAddress5 } from "@polkadot/util-crypto";
2243
2246
  var DEFAULT_AMOUNT = 10 ** 6;
2244
2247
  var DEFAULT_HEX_STRING = "0xabcdef1234567890fedcba0987654321abcdef1234567890fedcba0987654321";
2245
- var XCM_VERSION = "V4" /* v4 */;
2248
+ var STABLE_XCM_VERSION = "V4" /* v4 */;
2246
2249
  function isXcmV42() {
2247
- return XCM_VERSION === "V4" /* v4 */;
2250
+ return STABLE_XCM_VERSION === "V4" /* v4 */;
2248
2251
  }
2249
2252
  function getWithdrawAssetInstruction(assetTypes) {
2250
2253
  return {
@@ -2290,8 +2293,8 @@ function getBuyExecutionInstruction(assetType) {
2290
2293
  }
2291
2294
  function getDepositAssetInstruction(address, assets3) {
2292
2295
  const accountKey = {
2293
- AccountKey20: {
2294
- key: address,
2296
+ [isEthAddress2(address) ? "AccountKey20" : "AccountId32"]: {
2297
+ key: isEthAddress2(address) ? address : u8aToHex5(decodeAddress5(address)),
2295
2298
  network: null
2296
2299
  }
2297
2300
  };
@@ -2317,71 +2320,9 @@ function getSetTopicInstruction() {
2317
2320
  SetTopic: DEFAULT_HEX_STRING
2318
2321
  };
2319
2322
  }
2320
- function getNativeAssetId(palletInstanceNumber) {
2321
- if (!palletInstanceNumber) {
2322
- throw new Error(
2323
- "No pallet instance configured for the native asset for XcmPaymentApi fee calculation"
2324
- );
2325
- }
2326
- const palletInstance = {
2327
- PalletInstance: palletInstanceNumber
2328
- };
2329
- const id = {
2330
- interior: {
2331
- X1: isXcmV42() ? [palletInstance] : palletInstance
2332
- },
2333
- parents: "0"
2334
- };
2335
- return normalizeConcrete(XCM_VERSION, id);
2336
- }
2337
- function getConcreteAssetIdWithAccountKey20(asset, palletInstance) {
2338
- if (!palletInstance) {
2339
- throw new Error(
2340
- `No pallet instance configured for the asset ${asset} for XcmPaymentApi fee calculation`
2341
- );
2342
- }
2343
- const id = {
2344
- interior: {
2345
- X2: [
2346
- {
2347
- PalletInstance: palletInstance
2348
- },
2349
- {
2350
- AccountKey20: {
2351
- key: asset,
2352
- network: null
2353
- }
2354
- }
2355
- ]
2356
- },
2357
- parents: "0"
2358
- };
2359
- return normalizeConcrete(XCM_VERSION, id);
2360
- }
2361
- async function getAssetIdType(api, asset) {
2362
- const type = await api.query.assetManager.assetIdType(asset);
2363
- if (type.isNone || !type.unwrap().isXcm) {
2364
- throw new Error(`No asset type found for asset ${asset}`);
2365
- }
2366
- return type;
2367
- }
2368
- async function getVersionedAssetId(api, asset, chain) {
2369
- const assetId = asset.getAssetId();
2370
- const palletInstance = asset.getAssetPalletInstance();
2371
- if (assetId === chain.nativeAsset.originSymbol) {
2372
- return getNativeAssetId(palletInstance);
2373
- }
2374
- if (asset.hasOnlyAddress()) {
2375
- return getConcreteAssetIdWithAccountKey20(asset.address, palletInstance);
2376
- }
2377
- const assetType = await getAssetIdType(api, assetId);
2378
- const assetTypeObject = assetType.unwrap().asXcm.toJSON();
2379
- const normalizedAssetTypeObject = normalizeX1(XCM_VERSION, assetTypeObject);
2380
- return normalizeConcrete(XCM_VERSION, normalizedAssetTypeObject);
2381
- }
2382
2323
  async function getFeeForXcmInstructionsAndAsset(api, instructions, versionedAssetId) {
2383
2324
  const xcmToWeightResult = await api.call.xcmPaymentApi.queryXcmWeight({
2384
- [XCM_VERSION]: instructions
2325
+ [STABLE_XCM_VERSION]: instructions
2385
2326
  });
2386
2327
  if (!xcmToWeightResult.isOk) {
2387
2328
  throw new Error(
@@ -2390,68 +2331,342 @@ async function getFeeForXcmInstructionsAndAsset(api, instructions, versionedAsse
2390
2331
  }
2391
2332
  const xcmToWeight = xcmToWeightResult.asOk;
2392
2333
  const weightToForeignAssets = await api.call.xcmPaymentApi.queryWeightToAssetFee(xcmToWeight, {
2393
- [XCM_VERSION]: {
2334
+ [STABLE_XCM_VERSION]: {
2394
2335
  ...versionedAssetId
2395
2336
  }
2396
2337
  });
2397
2338
  if (!weightToForeignAssets.isOk) {
2398
- throw new Error(
2399
- "There was an error trying to get the fee with the weight and asset (weightToForeignAssets)"
2339
+ console.error(
2340
+ "Error trying to get the fee with the weight and asset (weightToForeignAssets) with V4, retrying with V5"
2400
2341
  );
2342
+ const weightToForeignAssetsV5 = await api.call.xcmPaymentApi.queryWeightToAssetFee(xcmToWeight, {
2343
+ ["V5" /* v5 */]: {
2344
+ ...versionedAssetId
2345
+ }
2346
+ });
2347
+ if (!weightToForeignAssetsV5.isOk) {
2348
+ throw new Error(
2349
+ "There was an error trying to get the fee with the weight and asset (weightToForeignAssets). Make sure the asset is supported by XcmPaymentApi."
2350
+ );
2351
+ }
2352
+ return weightToForeignAssetsV5.asOk.toBigInt();
2401
2353
  }
2402
2354
  return weightToForeignAssets.asOk.toBigInt();
2403
2355
  }
2404
2356
 
2405
- // src/fee/FeeBuilder.ts
2406
- function FeeBuilder() {
2407
- return {
2408
- xcmPaymentApi
2409
- };
2410
- }
2411
- function xcmPaymentApi() {
2357
+ // src/fee/VersionedAssetBuilder.ts
2358
+ import { Parachain } from "@moonbeam-network/xcm-types";
2359
+ function BuildVersionedAsset() {
2412
2360
  return {
2413
- xcmPaymentFee: ({
2414
- isAssetReserveChain,
2415
- shouldTransferAssetPrecedeFeeAsset = false
2416
- }) => ({
2417
- build: ({
2418
- address,
2419
- api,
2420
- asset,
2421
- destination,
2422
- feeAsset
2423
- }) => new SubstrateCallConfig({
2424
- api,
2425
- call: async () => {
2426
- const versionedFeeAssetId = await getVersionedAssetId(
2427
- api,
2428
- feeAsset,
2429
- destination
2361
+ fromHere: (parents = 1) => ({
2362
+ parents,
2363
+ interior: "Here"
2364
+ }),
2365
+ fromAccountKey20: (asset) => ({
2366
+ interior: {
2367
+ X2: [
2368
+ {
2369
+ PalletInstance: asset.getAssetPalletInstance()
2370
+ },
2371
+ {
2372
+ AccountKey20: {
2373
+ key: asset.address,
2374
+ network: null
2375
+ }
2376
+ }
2377
+ ]
2378
+ },
2379
+ parents: "0"
2380
+ }),
2381
+ fromGeneralIndex: (asset) => ({
2382
+ interior: {
2383
+ X1: [{ GeneralIndex: asset.getAssetId() }]
2384
+ },
2385
+ parents: "0"
2386
+ }),
2387
+ fromGlobalConsensus: (asset) => ({
2388
+ interior: {
2389
+ X2: [
2390
+ { GlobalConsensus: { Ethereum: { chainId: 1 } } },
2391
+ { AccountKey20: { key: asset.address, network: null } }
2392
+ ]
2393
+ },
2394
+ parents: 2
2395
+ }),
2396
+ fromPalletInstance: (asset) => {
2397
+ validatePalletInstance(asset);
2398
+ return {
2399
+ interior: {
2400
+ X1: [
2401
+ {
2402
+ PalletInstance: asset.getAssetPalletInstance()
2403
+ }
2404
+ ]
2405
+ },
2406
+ parents: "0"
2407
+ };
2408
+ },
2409
+ fromPalletInstanceAndGeneralIndex: (asset) => {
2410
+ validatePalletInstance(asset);
2411
+ return {
2412
+ interior: {
2413
+ X2: [
2414
+ {
2415
+ PalletInstance: asset.getAssetPalletInstance()
2416
+ },
2417
+ { GeneralIndex: asset.getAssetId() }
2418
+ ]
2419
+ },
2420
+ parents: "0"
2421
+ };
2422
+ },
2423
+ fromSource: () => ({
2424
+ accountKey20: (source, asset) => {
2425
+ if (!(source instanceof Parachain)) {
2426
+ throw new Error(
2427
+ `Chain ${source.name} must be a Parachain to build versioned asset id for XcmPaymentApi fee calculation`
2430
2428
  );
2431
- const versionedTransferAssetId = await getVersionedAssetId(
2432
- api,
2433
- asset,
2434
- destination
2429
+ }
2430
+ const sourceAsset = source.getChainAsset(asset);
2431
+ validatePalletInstance(sourceAsset);
2432
+ return {
2433
+ interior: {
2434
+ X3: [
2435
+ { Parachain: source.parachainId },
2436
+ { PalletInstance: sourceAsset.getAssetPalletInstance() },
2437
+ { AccountKey20: { key: sourceAsset.address, network: null } }
2438
+ ]
2439
+ },
2440
+ parents: 1
2441
+ };
2442
+ },
2443
+ palletInstance: (source, asset) => {
2444
+ if (!(source instanceof Parachain)) {
2445
+ throw new Error(
2446
+ `Chain ${source.name} must be a Parachain to build versioned asset id for XcmPaymentApi fee calculation`
2435
2447
  );
2436
- const versionedAssets = shouldTransferAssetPrecedeFeeAsset ? [versionedTransferAssetId, versionedFeeAssetId] : [versionedFeeAssetId, versionedTransferAssetId];
2437
- const assets3 = feeAsset === asset ? [versionedFeeAssetId] : versionedAssets;
2438
- const instructions = [
2439
- isAssetReserveChain ? getWithdrawAssetInstruction(assets3) : getReserveAssetDepositedInstruction(assets3),
2440
- getClearOriginInstruction(),
2441
- getBuyExecutionInstruction(versionedFeeAssetId),
2442
- getDepositAssetInstruction(address, assets3),
2443
- getSetTopicInstruction()
2444
- ];
2445
- return getFeeForXcmInstructionsAndAsset(
2446
- api,
2447
- instructions,
2448
- versionedFeeAssetId
2448
+ }
2449
+ const sourceAsset = source.getChainAsset(asset);
2450
+ validatePalletInstance(sourceAsset);
2451
+ return {
2452
+ interior: {
2453
+ X2: [
2454
+ { Parachain: source.parachainId },
2455
+ {
2456
+ PalletInstance: sourceAsset.getAssetPalletInstance()
2457
+ }
2458
+ ]
2459
+ },
2460
+ parents: 1
2461
+ };
2462
+ },
2463
+ palletInstanceAndGeneralIndex: (source, asset) => {
2464
+ if (!(source instanceof Parachain)) {
2465
+ throw new Error(
2466
+ `Chain ${source.name} must be a Parachain to build versioned asset id for XcmPaymentApi fee calculation`
2449
2467
  );
2450
2468
  }
2451
- })
2469
+ const sourceAsset = source.getChainAsset(asset);
2470
+ validatePalletInstance(sourceAsset);
2471
+ return {
2472
+ interior: {
2473
+ X3: [
2474
+ { Parachain: source.parachainId },
2475
+ { PalletInstance: sourceAsset.getAssetPalletInstance() },
2476
+ { GeneralIndex: sourceAsset.getAssetId() }
2477
+ ]
2478
+ },
2479
+ parents: 1
2480
+ };
2481
+ }
2452
2482
  })
2453
2483
  };
2454
2484
  }
2485
+ function QueryVersionedAsset() {
2486
+ return {
2487
+ fromCurrencyIdToLocations: async (asset, api) => {
2488
+ const result = await api.query.assetRegistry.currencyIdToLocations(
2489
+ asset.getAssetRegisteredId()
2490
+ );
2491
+ if (!result || result.isEmpty) {
2492
+ throw new Error(`No location found for asset ${asset.getSymbol()}`);
2493
+ }
2494
+ return result.toJSON();
2495
+ },
2496
+ fromAssetId: async (asset, api) => {
2497
+ if (!asset.getAssetRegisteredId()) {
2498
+ throw new Error(
2499
+ `No asset registered id found for asset ${asset.getSymbol()}`
2500
+ );
2501
+ }
2502
+ const assetManagerResult = await api.query.assetManager.assetIdType(asset.getAssetRegisteredId());
2503
+ if (assetManagerResult.isNone || assetManagerResult.isEmpty || !assetManagerResult.unwrap().isXcm) {
2504
+ const evmForeignAssetsResult = await api.query.evmForeignAssets.assetsById(asset.getAssetRegisteredId());
2505
+ if (!evmForeignAssetsResult || evmForeignAssetsResult.isEmpty || evmForeignAssetsResult.isNone) {
2506
+ throw new Error(`No asset type found for asset ${asset.getSymbol()}`);
2507
+ }
2508
+ return evmForeignAssetsResult.unwrapOrDefault().toJSON();
2509
+ }
2510
+ return normalizeX1(
2511
+ STABLE_XCM_VERSION,
2512
+ assetManagerResult.unwrapOrDefault().asXcm.toJSON()
2513
+ );
2514
+ }
2515
+ };
2516
+ }
2517
+ var validatePalletInstance = (asset) => {
2518
+ if (!asset.getAssetPalletInstance()) {
2519
+ throw new Error(
2520
+ `No pallet instance configured for the asset ${asset.key} for XcmPaymentApi fee calculation`
2521
+ );
2522
+ }
2523
+ };
2524
+
2525
+ // src/fee/xcmPaymentApi/xcmPaymentApi.utils.ts
2526
+ async function getVersionedAssets({
2527
+ getVersionedFeeAsset,
2528
+ getVersionedTransferAsset,
2529
+ options,
2530
+ params
2531
+ }) {
2532
+ const { asset: transferAsset, feeAsset } = params;
2533
+ const versionedFeeAssetId = await getVersionedFeeAsset(params);
2534
+ const assets3 = [versionedFeeAssetId];
2535
+ if (feeAsset !== transferAsset && getVersionedTransferAsset) {
2536
+ const versionedTransferAssetId = await getVersionedTransferAsset(params);
2537
+ if (options.shouldTransferAssetPrecedeFeeAsset) {
2538
+ assets3.unshift(versionedTransferAssetId);
2539
+ } else {
2540
+ assets3.push(versionedTransferAssetId);
2541
+ }
2542
+ }
2543
+ return [assets3, versionedFeeAssetId];
2544
+ }
2545
+ function getInstructions({
2546
+ isAssetReserveChain,
2547
+ assets: assets3,
2548
+ versionedFeeAssetId,
2549
+ address
2550
+ }) {
2551
+ return [
2552
+ isAssetReserveChain ? getWithdrawAssetInstruction(assets3) : getReserveAssetDepositedInstruction(assets3),
2553
+ getClearOriginInstruction(),
2554
+ getBuyExecutionInstruction(versionedFeeAssetId),
2555
+ getDepositAssetInstruction(address, assets3),
2556
+ getSetTopicInstruction()
2557
+ ];
2558
+ }
2559
+
2560
+ // src/fee/xcmPaymentApi/xcmPaymentApi.ts
2561
+ function xcmPaymentApi() {
2562
+ const localMethods = {
2563
+ fromHere: (options) => createXcmFeeBuilder({
2564
+ getVersionedFeeAsset: () => BuildVersionedAsset().fromHere(options.parents),
2565
+ options
2566
+ }),
2567
+ fromHereAndGeneralIndex: (options) => createXcmFeeBuilder({
2568
+ getVersionedFeeAsset: () => BuildVersionedAsset().fromHere(),
2569
+ getVersionedTransferAsset: ({ asset }) => BuildVersionedAsset().fromPalletInstanceAndGeneralIndex(asset),
2570
+ options
2571
+ }),
2572
+ fromPalletInstanceAndGeneralIndex: (options) => createXcmFeeBuilder({
2573
+ getVersionedFeeAsset: ({ feeAsset }) => BuildVersionedAsset().fromPalletInstanceAndGeneralIndex(feeAsset),
2574
+ options
2575
+ }),
2576
+ fromHereAndSourceGeneralIndex: (options) => createXcmFeeBuilder({
2577
+ getVersionedFeeAsset: () => BuildVersionedAsset().fromHere(),
2578
+ getVersionedTransferAsset: ({ source, asset }) => BuildVersionedAsset().fromSource().palletInstanceAndGeneralIndex(source, asset),
2579
+ options
2580
+ }),
2581
+ fromGeneralIndex: (options) => createXcmFeeBuilder({
2582
+ getVersionedFeeAsset: ({ feeAsset }) => BuildVersionedAsset().fromGeneralIndex(feeAsset),
2583
+ options
2584
+ }),
2585
+ fromPalletInstance: (options) => createXcmFeeBuilder({
2586
+ getVersionedFeeAsset: ({ feeAsset }) => BuildVersionedAsset().fromPalletInstance(feeAsset),
2587
+ options
2588
+ }),
2589
+ fromPalletInstanceAndAccountKey20: (options) => createXcmFeeBuilder({
2590
+ getVersionedFeeAsset: ({ feeAsset }) => BuildVersionedAsset().fromPalletInstance(feeAsset),
2591
+ getVersionedTransferAsset: ({ asset }) => BuildVersionedAsset().fromAccountKey20(asset),
2592
+ options
2593
+ }),
2594
+ fromGlobalConsensus: (options) => createXcmFeeBuilder({
2595
+ getVersionedFeeAsset: ({ feeAsset }) => BuildVersionedAsset().fromGlobalConsensus(feeAsset),
2596
+ options
2597
+ })
2598
+ };
2599
+ const sourceMethods = {
2600
+ fromSourceAccountKey20: (options) => createXcmFeeBuilder({
2601
+ getVersionedFeeAsset: ({ source, asset }) => BuildVersionedAsset().fromSource().accountKey20(source, asset),
2602
+ options
2603
+ }),
2604
+ fromSourcePalletInstance: (options) => createXcmFeeBuilder({
2605
+ getVersionedFeeAsset: ({ source, feeAsset }) => BuildVersionedAsset().fromSource().palletInstance(source, feeAsset),
2606
+ options
2607
+ })
2608
+ };
2609
+ const queryMethods = {
2610
+ fromCurrencyIdToLocations: (options) => createXcmFeeBuilder({
2611
+ getVersionedFeeAsset: async ({ feeAsset, api }) => {
2612
+ return await QueryVersionedAsset().fromCurrencyIdToLocations(
2613
+ feeAsset,
2614
+ api
2615
+ );
2616
+ },
2617
+ options
2618
+ }),
2619
+ fromAssetIdQuery: (options) => createXcmFeeBuilder({
2620
+ getVersionedFeeAsset: async ({ feeAsset, api }) => {
2621
+ return await QueryVersionedAsset().fromAssetId(feeAsset, api);
2622
+ },
2623
+ getVersionedTransferAsset: async ({ asset, api }) => {
2624
+ return await QueryVersionedAsset().fromAssetId(asset, api);
2625
+ },
2626
+ options
2627
+ })
2628
+ };
2629
+ return {
2630
+ ...localMethods,
2631
+ ...sourceMethods,
2632
+ ...queryMethods
2633
+ };
2634
+ }
2635
+ var createXcmFeeBuilder = ({
2636
+ getVersionedFeeAsset,
2637
+ getVersionedTransferAsset,
2638
+ options
2639
+ }) => ({
2640
+ build: (params) => new SubstrateCallConfig({
2641
+ api: params.api,
2642
+ call: async () => {
2643
+ const [assets3, versionedFeeAssetId] = await getVersionedAssets({
2644
+ getVersionedFeeAsset,
2645
+ getVersionedTransferAsset,
2646
+ options,
2647
+ params
2648
+ });
2649
+ const instructions = getInstructions({
2650
+ isAssetReserveChain: options.isAssetReserveChain,
2651
+ assets: assets3,
2652
+ versionedFeeAssetId,
2653
+ address: params.address
2654
+ });
2655
+ return getFeeForXcmInstructionsAndAsset(
2656
+ params.api,
2657
+ instructions,
2658
+ versionedFeeAssetId
2659
+ );
2660
+ }
2661
+ })
2662
+ });
2663
+
2664
+ // src/fee/FeeBuilder.ts
2665
+ function FeeBuilder() {
2666
+ return {
2667
+ xcmPaymentApi
2668
+ };
2669
+ }
2455
2670
 
2456
2671
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
2457
2672
  import {
@@ -2464,7 +2679,7 @@ import { encodeFunctionData as encodeFunctionData2, maxUint64 } from "viem";
2464
2679
  // src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts
2465
2680
  import {
2466
2681
  AssetAmount,
2467
- Parachain
2682
+ Parachain as Parachain2
2468
2683
  } from "@moonbeam-network/xcm-types";
2469
2684
  import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
2470
2685
  var BUY_EXECUTION_FEE = 100000000000000000n;
@@ -2493,7 +2708,7 @@ function polkadotXcm2() {
2493
2708
  if (!sourceApi) {
2494
2709
  throw new Error("Source API needs to be defined");
2495
2710
  }
2496
- if (!Parachain.is(source)) {
2711
+ if (!Parachain2.is(source)) {
2497
2712
  throw new Error("Source chain needs to be a parachain");
2498
2713
  }
2499
2714
  const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
@@ -3349,7 +3564,7 @@ function getCurrencies({ source, moonAsset, asset }) {
3349
3564
  }
3350
3565
 
3351
3566
  // src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
3352
- import { u8aToHex as u8aToHex5 } from "@polkadot/util";
3567
+ import { u8aToHex as u8aToHex6 } from "@polkadot/util";
3353
3568
 
3354
3569
  // src/mrl/providers/wormhole/contract/Gmp/GmpAbi.ts
3355
3570
  var GMP_ABI = [
@@ -3375,7 +3590,7 @@ function Gmp() {
3375
3590
  return {
3376
3591
  wormholeTransferERC20: () => ({
3377
3592
  build: ({ bytes }) => {
3378
- const hex = u8aToHex5(bytes);
3593
+ const hex = u8aToHex6(bytes);
3379
3594
  return new ContractConfig({
3380
3595
  address: GMP_CONTRACT_ADDRESS,
3381
3596
  abi: GMP_ABI,
@@ -3392,7 +3607,7 @@ function Gmp() {
3392
3607
  import { convertAddressTo32Bytes } from "@moonbeam-network/xcm-utils";
3393
3608
 
3394
3609
  // src/mrl/providers/wormhole/wormhole/wormhole.ts
3395
- import { EvmChain, EvmParachain as EvmParachain3, Parachain as Parachain2 } from "@moonbeam-network/xcm-types";
3610
+ import { EvmChain, EvmParachain as EvmParachain3, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
3396
3611
  import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
3397
3612
  import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
3398
3613
  import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
@@ -3414,7 +3629,20 @@ var WormholeConfig = class _WormholeConfig {
3414
3629
  import { Wormhole } from "@wormhole-foundation/sdk-connect";
3415
3630
  import { EvmPlatform } from "@wormhole-foundation/sdk-evm";
3416
3631
  function wormholeFactory(chain) {
3417
- return new Wormhole(chain.isTestChain ? "Testnet" : "Mainnet", [EvmPlatform]);
3632
+ return new Wormhole(
3633
+ chain.isTestChain ? "Testnet" : "Mainnet",
3634
+ [EvmPlatform],
3635
+ {
3636
+ chains: {
3637
+ Ethereum: {
3638
+ rpc: "https://eth.llamarpc.com"
3639
+ },
3640
+ Moonbeam: {
3641
+ rpc: "https://rpc.api.moonbeam.network"
3642
+ }
3643
+ }
3644
+ }
3645
+ );
3418
3646
  }
3419
3647
 
3420
3648
  // src/mrl/providers/wormhole/wormhole/wormhole.ts
@@ -3431,7 +3659,7 @@ function wormhole() {
3431
3659
  source,
3432
3660
  sourceAddress
3433
3661
  }) => {
3434
- const isSourceParachain = Parachain2.is(source);
3662
+ const isSourceParachain = Parachain3.is(source);
3435
3663
  const isDestinationMoonChain = destination.isEqual(moonChain);
3436
3664
  const isDestinationEvmChain = EvmChain.is(destination);
3437
3665
  const isNativeAsset = asset.isSame(