@moonbeam-network/xcm-builder 1.0.0-dev.240 → 1.0.0-dev.241

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.mjs CHANGED
@@ -1479,6 +1479,7 @@ function eqBalances() {
1479
1479
  }
1480
1480
 
1481
1481
  // src/extrinsic/pallets/polkadotXcm/polkadotXcm.util.ts
1482
+ import { Ecosystem } from "@moonbeam-network/xcm-types";
1482
1483
  function getPolkadotXcmExtrinsicArgs({
1483
1484
  assets: assets3,
1484
1485
  destinationAddress,
@@ -1519,6 +1520,23 @@ function getPolkadotXcmExtrinsicArgs({
1519
1520
  "Unlimited"
1520
1521
  ];
1521
1522
  }
1523
+ function isKusamaDestination(destination) {
1524
+ return destination.ecosystem === Ecosystem.Kusama || destination.ecosystem === Ecosystem.MoonsamaRelay;
1525
+ }
1526
+ function isPolkadotDestination(destination) {
1527
+ return destination.ecosystem === Ecosystem.Polkadot || destination.ecosystem === Ecosystem.MoonlamaRelay;
1528
+ }
1529
+ function getGlobalConsensus(destination) {
1530
+ if (isKusamaDestination(destination)) {
1531
+ return "Kusama";
1532
+ }
1533
+ if (isPolkadotDestination(destination)) {
1534
+ return "Polkadot";
1535
+ }
1536
+ return {
1537
+ ByGenesis: destination.relayGenesisHash
1538
+ };
1539
+ }
1522
1540
  function getEcosystemTransferExtrinsicArgs({
1523
1541
  assets: assets3,
1524
1542
  destinationAddress,
@@ -1527,6 +1545,7 @@ function getEcosystemTransferExtrinsicArgs({
1527
1545
  feeIndex = 0
1528
1546
  }) {
1529
1547
  const version = getExtrinsicArgumentVersion(func);
1548
+ const globalConsensus = getGlobalConsensus(destination);
1530
1549
  return [
1531
1550
  // dest
1532
1551
  {
@@ -1534,11 +1553,7 @@ function getEcosystemTransferExtrinsicArgs({
1534
1553
  parents: 2,
1535
1554
  interior: {
1536
1555
  X2: [
1537
- {
1538
- GlobalConsensus: {
1539
- ByGenesis: destination.relayGenesisHash
1540
- }
1541
- },
1556
+ { GlobalConsensus: globalConsensus },
1542
1557
  {
1543
1558
  Parachain: destination.parachainId
1544
1559
  }
@@ -2243,11 +2258,12 @@ function polkadotXcm() {
2243
2258
  }
2244
2259
  }
2245
2260
  ];
2246
- return getEcosystemTransferExtrinsicArgs({
2261
+ const result = getEcosystemTransferExtrinsicArgs({
2247
2262
  ...params,
2248
2263
  func: extrinsicFunction,
2249
2264
  assets: assets3
2250
2265
  });
2266
+ return result;
2251
2267
  }
2252
2268
  });
2253
2269
  }
@@ -2269,9 +2285,9 @@ function polkadotXcm() {
2269
2285
  interior: {
2270
2286
  X3: [
2271
2287
  {
2272
- GlobalConsensus: {
2273
- ByGenesis: params.destination.relayGenesisHash
2274
- }
2288
+ GlobalConsensus: getGlobalConsensus(
2289
+ params.destination
2290
+ )
2275
2291
  },
2276
2292
  {
2277
2293
  Parachain: params.destination.parachainId
@@ -2309,6 +2325,7 @@ function polkadotXcm() {
2309
2325
  const assetInDestination = params.destination.getChainAsset(
2310
2326
  params.asset
2311
2327
  );
2328
+ const globalConsensus = getGlobalConsensus(params.destination);
2312
2329
  const assets3 = [
2313
2330
  {
2314
2331
  id: normalizeConcrete(version, {
@@ -2316,9 +2333,7 @@ function polkadotXcm() {
2316
2333
  interior: {
2317
2334
  X3: [
2318
2335
  {
2319
- GlobalConsensus: {
2320
- ByGenesis: params.destination.relayGenesisHash
2321
- }
2336
+ GlobalConsensus: globalConsensus
2322
2337
  },
2323
2338
  {
2324
2339
  Parachain: params.destination.parachainId
@@ -2339,9 +2354,7 @@ function polkadotXcm() {
2339
2354
  interior: {
2340
2355
  X4: [
2341
2356
  {
2342
- GlobalConsensus: {
2343
- ByGenesis: params.destination.relayGenesisHash
2344
- }
2357
+ GlobalConsensus: globalConsensus
2345
2358
  },
2346
2359
  {
2347
2360
  Parachain: params.destination.parachainId
@@ -2362,11 +2375,12 @@ function polkadotXcm() {
2362
2375
  }
2363
2376
  }
2364
2377
  ];
2365
- return getEcosystemTransferExtrinsicArgs({
2378
+ const result = getEcosystemTransferExtrinsicArgs({
2366
2379
  ...params,
2367
2380
  func: extrinsicFunction,
2368
2381
  assets: assets3
2369
2382
  });
2383
+ return result;
2370
2384
  }
2371
2385
  });
2372
2386
  }
@@ -2761,9 +2775,7 @@ function getUniversalOriginInstruction(source) {
2761
2775
  }
2762
2776
  return {
2763
2777
  UniversalOrigin: {
2764
- GlobalConsensus: {
2765
- ByGenesis: source.relayGenesisHash
2766
- }
2778
+ GlobalConsensus: getGlobalConsensus(source)
2767
2779
  }
2768
2780
  };
2769
2781
  }