@moonbeam-network/xcm-builder 4.1.2 → 4.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.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
  }
@@ -2269,9 +2284,9 @@ function polkadotXcm() {
2269
2284
  interior: {
2270
2285
  X3: [
2271
2286
  {
2272
- GlobalConsensus: {
2273
- ByGenesis: params.destination.relayGenesisHash
2274
- }
2287
+ GlobalConsensus: getGlobalConsensus(
2288
+ params.destination
2289
+ )
2275
2290
  },
2276
2291
  {
2277
2292
  Parachain: params.destination.parachainId
@@ -2309,6 +2324,7 @@ function polkadotXcm() {
2309
2324
  const assetInDestination = params.destination.getChainAsset(
2310
2325
  params.asset
2311
2326
  );
2327
+ const globalConsensus = getGlobalConsensus(params.destination);
2312
2328
  const assets3 = [
2313
2329
  {
2314
2330
  id: normalizeConcrete(version, {
@@ -2316,9 +2332,7 @@ function polkadotXcm() {
2316
2332
  interior: {
2317
2333
  X3: [
2318
2334
  {
2319
- GlobalConsensus: {
2320
- ByGenesis: params.destination.relayGenesisHash
2321
- }
2335
+ GlobalConsensus: globalConsensus
2322
2336
  },
2323
2337
  {
2324
2338
  Parachain: params.destination.parachainId
@@ -2339,9 +2353,7 @@ function polkadotXcm() {
2339
2353
  interior: {
2340
2354
  X4: [
2341
2355
  {
2342
- GlobalConsensus: {
2343
- ByGenesis: params.destination.relayGenesisHash
2344
- }
2356
+ GlobalConsensus: globalConsensus
2345
2357
  },
2346
2358
  {
2347
2359
  Parachain: params.destination.parachainId
@@ -2761,9 +2773,7 @@ function getUniversalOriginInstruction(source) {
2761
2773
  }
2762
2774
  return {
2763
2775
  UniversalOrigin: {
2764
- GlobalConsensus: {
2765
- ByGenesis: source.relayGenesisHash
2766
- }
2776
+ GlobalConsensus: getGlobalConsensus(source)
2767
2777
  }
2768
2778
  };
2769
2779
  }