@paraspell/pallets 13.5.0 → 13.6.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/dist/index.d.ts CHANGED
@@ -4,21 +4,24 @@ declare const CROSSCHAIN_PALLETS: readonly ["XTokens", "PolkadotXcm", "XcmPallet
4
4
  declare const ASSETS_PALLETS: readonly ["Balances", "Tokens", "Currencies", "Assets", "ForeignAssets", "AssetManager", "System", "Fungibles", "OrmlTokens"];
5
5
  declare const OTHER_PALLETS: readonly ["Utility", "AssetConversion"];
6
6
  declare const PALLETS: readonly ["XTokens", "PolkadotXcm", "XcmPallet", "Balances", "Tokens", "Currencies", "Assets", "ForeignAssets", "AssetManager", "System", "Fungibles", "OrmlTokens", "Utility", "AssetConversion"];
7
+ declare const NATIVE_ASSETS_PALLET_PRIORITY: readonly ["Balances", "Currencies", "Tokens"];
8
+ declare const OTHER_ASSETS_PALLET_PRIORITY: readonly ["Currencies", "Tokens", "Assets", "ForeignAssets", "AssetManager", "Fungibles", "OrmlTokens"];
7
9
 
8
10
  /**
9
11
  * Used to inform user, that no XCM pallet was found on the specified chain.
10
12
  */
11
- declare class XcmPalletNotFoundError extends Error {
13
+ declare class XcmPalletNotFoundError<TCustomChain extends string = never> extends Error {
12
14
  /**
13
15
  * Constructs a new XcmPalletNotFoundError.
14
16
  *
15
17
  * @param chain - The chain for which no XCM pallet was found.
16
18
  */
17
- constructor(chain: TSubstrateChain);
19
+ constructor(chain: TSubstrateChain | TCustomChain);
18
20
  }
19
21
 
20
22
  type TPallet = (typeof PALLETS)[number];
21
23
  type TAssetsPallet = (typeof ASSETS_PALLETS)[number];
24
+ type TCrosschainPallet = (typeof CROSSCHAIN_PALLETS)[number];
22
25
  type TPalletDetails = {
23
26
  name: TPallet;
24
27
  index: number;
@@ -30,6 +33,19 @@ interface TPalletMap {
30
33
  otherAssets: TAssetsPallet[];
31
34
  }
32
35
  type TPalletJsonMap = Record<TSubstrateChain, TPalletMap>;
36
+ type TPalletEntry = {
37
+ name: string;
38
+ index: number;
39
+ hasExtrinsics: boolean;
40
+ };
41
+ type TCustomChainPallets = {
42
+ nativeAssets: TAssetsPallet;
43
+ otherAssets: TAssetsPallet[];
44
+ supportedPallets?: TPalletEntry[];
45
+ };
46
+ type TPalletsCtx = {
47
+ customChainPallets?: Record<string, TCustomChainPallets>;
48
+ };
33
49
 
34
50
  /**
35
51
  * Retrieves the default pallet for a specified chain.
@@ -47,9 +63,10 @@ declare const getDefaultPallet: (chain: TSubstrateChain) => TPallet;
47
63
  declare const getSupportedPallets: (chain: TSubstrateChain) => TPallet[];
48
64
  declare const getSupportedPalletsDetails: (chain: TSubstrateChain) => TPalletDetails[];
49
65
  declare const getPalletIndex: (chain: TSubstrateChain, pallet: TPallet) => number | undefined;
50
- declare const getNativeAssetsPallet: (chain: TSubstrateChain) => TAssetsPallet;
51
- declare const getOtherAssetsPallets: (chain: TSubstrateChain) => TAssetsPallet[];
52
- declare const hasPallet: (chain: TSubstrateChain, pallet: TPallet) => boolean;
66
+ declare const getNativeAssetsPallet: <TCustomChain extends string = never>(chain: TSubstrateChain | TCustomChain, ctx?: TPalletsCtx) => TAssetsPallet;
67
+ declare const getOtherAssetsPallets: <TCustomChain extends string = never>(chain: TSubstrateChain | TCustomChain, ctx?: TPalletsCtx) => TAssetsPallet[];
68
+ declare const hasPallet: <TCustomChain extends string = never>(chain: TSubstrateChain | TCustomChain, pallet: TPallet) => boolean;
69
+ declare const hasPalletImpl: <TCustomChain extends string = never>(chain: TSubstrateChain | TCustomChain, pallet: TPallet, ctx?: TPalletsCtx) => boolean;
53
70
  /**
54
71
  * Retrieves the XCM pallet for a specified chain.
55
72
  *
@@ -57,7 +74,8 @@ declare const hasPallet: (chain: TSubstrateChain, pallet: TPallet) => boolean;
57
74
  * @returns The XCM pallet found on the chain (XcmPallet or PolkadotXcm).
58
75
  * @throws {@link XcmPalletNotFoundError} If no XCM pallet is found on the chain.
59
76
  */
60
- declare const getXcmPallet: (chain: TSubstrateChain) => TPallet;
77
+ declare const getXcmPallet: <TCustomChain extends string = never>(chain: TSubstrateChain | TCustomChain) => TPallet;
78
+ declare const getXcmPalletImpl: <TCustomChain extends string = never>(chain: TSubstrateChain | TCustomChain, ctx?: TPalletsCtx) => TPallet;
61
79
 
62
- export { ASSETS_PALLETS, CROSSCHAIN_PALLETS, OTHER_PALLETS, PALLETS, XcmPalletNotFoundError, getDefaultPallet, getNativeAssetsPallet, getOtherAssetsPallets, getPalletIndex, getSupportedPallets, getSupportedPalletsDetails, getXcmPallet, hasPallet };
63
- export type { TAssetsPallet, TPallet, TPalletDetails, TPalletJsonMap, TPalletMap };
80
+ export { ASSETS_PALLETS, CROSSCHAIN_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY, OTHER_PALLETS, PALLETS, XcmPalletNotFoundError, getDefaultPallet, getNativeAssetsPallet, getOtherAssetsPallets, getPalletIndex, getSupportedPallets, getSupportedPalletsDetails, getXcmPallet, getXcmPalletImpl, hasPallet, hasPalletImpl };
81
+ export type { TAssetsPallet, TCrosschainPallet, TCustomChainPallets, TPallet, TPalletDetails, TPalletEntry, TPalletJsonMap, TPalletMap, TPalletsCtx };
package/dist/index.mjs CHANGED
@@ -1,7 +1,11 @@
1
+ import { isCustomChain } from '@paraspell/sdk-common';
2
+
1
3
  var CROSSCHAIN_PALLETS = ['XTokens', 'PolkadotXcm', 'XcmPallet'];
2
4
  var ASSETS_PALLETS = ['Balances', 'Tokens', 'Currencies', 'Assets', 'ForeignAssets', 'AssetManager', 'System', 'Fungibles', 'OrmlTokens'];
3
5
  var OTHER_PALLETS = ['Utility', 'AssetConversion'];
4
6
  var PALLETS = [].concat(CROSSCHAIN_PALLETS, ASSETS_PALLETS, OTHER_PALLETS);
7
+ var NATIVE_ASSETS_PALLET_PRIORITY = ['Balances', 'Currencies', 'Tokens'];
8
+ var OTHER_ASSETS_PALLET_PRIORITY = ['Currencies', 'Tokens', 'Assets', 'ForeignAssets', 'AssetManager', 'Fungibles', 'OrmlTokens'];
5
9
 
6
10
  function _assertThisInitialized(e) {
7
11
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -982,22 +986,6 @@ var Ajuna = {
982
986
  "Assets"
983
987
  ]
984
988
  };
985
- var Laos = {
986
- defaultPallet: "PolkadotXcm",
987
- supportedPallets: [
988
- {
989
- name: "Balances",
990
- index: 10
991
- },
992
- {
993
- name: "PolkadotXcm",
994
- index: 31
995
- }
996
- ],
997
- nativeAssets: "Balances",
998
- otherAssets: [
999
- ]
1000
- };
1001
989
  var Jamton = {
1002
990
  defaultPallet: "XTokens",
1003
991
  supportedPallets: [
@@ -1326,22 +1314,6 @@ var HydrationPaseo = {
1326
1314
  "Tokens"
1327
1315
  ]
1328
1316
  };
1329
- var LaosPaseo = {
1330
- defaultPallet: "PolkadotXcm",
1331
- supportedPallets: [
1332
- {
1333
- name: "Balances",
1334
- index: 10
1335
- },
1336
- {
1337
- name: "PolkadotXcm",
1338
- index: 31
1339
- }
1340
- ],
1341
- nativeAssets: "Balances",
1342
- otherAssets: [
1343
- ]
1344
- };
1345
1317
  var NeuroWebPaseo = {
1346
1318
  defaultPallet: "PolkadotXcm",
1347
1319
  supportedPallets: [
@@ -1534,7 +1506,6 @@ var pallets = {
1534
1506
  Polkadot: Polkadot,
1535
1507
  Kusama: Kusama,
1536
1508
  Ajuna: Ajuna,
1537
- Laos: Laos,
1538
1509
  Jamton: Jamton,
1539
1510
  AssetHubWestend: AssetHubWestend,
1540
1511
  BridgeHubWestend: BridgeHubWestend,
@@ -1550,7 +1521,6 @@ var pallets = {
1550
1521
  BifrostPaseo: BifrostPaseo,
1551
1522
  HeimaPaseo: HeimaPaseo,
1552
1523
  HydrationPaseo: HydrationPaseo,
1553
- LaosPaseo: LaosPaseo,
1554
1524
  NeuroWebPaseo: NeuroWebPaseo,
1555
1525
  ZeitgeistPaseo: ZeitgeistPaseo,
1556
1526
  Westend: Westend,
@@ -1601,8 +1571,6 @@ var palletsMapJson = /*#__PURE__*/Object.freeze({
1601
1571
  Karura: Karura,
1602
1572
  Kintsugi: Kintsugi,
1603
1573
  Kusama: Kusama,
1604
- Laos: Laos,
1605
- LaosPaseo: LaosPaseo,
1606
1574
  Moonbeam: Moonbeam,
1607
1575
  Moonriver: Moonriver,
1608
1576
  Mythos: Mythos,
@@ -1659,13 +1627,41 @@ var getPalletIndex = function getPalletIndex(chain, pallet) {
1659
1627
  return p.name === pallet;
1660
1628
  })) === null || _palletsMap$chain$sup === void 0 ? void 0 : _palletsMap$chain$sup.index;
1661
1629
  };
1662
- var getNativeAssetsPallet = function getNativeAssetsPallet(chain) {
1630
+ var getNativeAssetsPallet = function getNativeAssetsPallet(chain, ctx) {
1631
+ if (isCustomChain(chain)) {
1632
+ var _ctx$customChainPalle;
1633
+ var entry = ctx === null || ctx === void 0 || (_ctx$customChainPalle = ctx.customChainPallets) === null || _ctx$customChainPalle === void 0 ? void 0 : _ctx$customChainPalle[chain];
1634
+ if (!entry) {
1635
+ // TODO: Fix this cast
1636
+ throw new XcmPalletNotFoundError(chain);
1637
+ }
1638
+ return entry.nativeAssets;
1639
+ }
1663
1640
  return palletsMap[chain].nativeAssets;
1664
1641
  };
1665
- var getOtherAssetsPallets = function getOtherAssetsPallets(chain) {
1642
+ var getOtherAssetsPallets = function getOtherAssetsPallets(chain, ctx) {
1643
+ if (isCustomChain(chain)) {
1644
+ var _ctx$customChainPalle2;
1645
+ var entry = ctx === null || ctx === void 0 || (_ctx$customChainPalle2 = ctx.customChainPallets) === null || _ctx$customChainPalle2 === void 0 ? void 0 : _ctx$customChainPalle2[chain];
1646
+ if (!entry) {
1647
+ // TODO: Fix this cast
1648
+ throw new XcmPalletNotFoundError(chain);
1649
+ }
1650
+ return entry.otherAssets;
1651
+ }
1666
1652
  return palletsMap[chain].otherAssets;
1667
1653
  };
1668
1654
  var hasPallet = function hasPallet(chain, pallet) {
1655
+ return hasPalletImpl(chain, pallet);
1656
+ };
1657
+ var hasPalletImpl = function hasPalletImpl(chain, pallet, ctx) {
1658
+ if (isCustomChain(chain)) {
1659
+ var _ctx$customChainPalle3, _entry$supportedPalle, _entry$supportedPalle2;
1660
+ var entry = ctx === null || ctx === void 0 || (_ctx$customChainPalle3 = ctx.customChainPallets) === null || _ctx$customChainPalle3 === void 0 ? void 0 : _ctx$customChainPalle3[chain];
1661
+ return (_entry$supportedPalle = entry === null || entry === void 0 || (_entry$supportedPalle2 = entry.supportedPallets) === null || _entry$supportedPalle2 === void 0 ? void 0 : _entry$supportedPalle2.some(function (p) {
1662
+ return p.name === pallet;
1663
+ })) !== null && _entry$supportedPalle !== void 0 ? _entry$supportedPalle : false;
1664
+ }
1669
1665
  return palletsMap[chain].supportedPallets.some(function (p) {
1670
1666
  return p.name === pallet;
1671
1667
  });
@@ -1678,12 +1674,15 @@ var hasPallet = function hasPallet(chain, pallet) {
1678
1674
  * @throws {@link XcmPalletNotFoundError} If no XCM pallet is found on the chain.
1679
1675
  */
1680
1676
  var getXcmPallet = function getXcmPallet(chain) {
1677
+ return getXcmPalletImpl(chain);
1678
+ };
1679
+ var getXcmPalletImpl = function getXcmPalletImpl(chain, ctx) {
1681
1680
  var candidates = ['XcmPallet', 'PolkadotXcm'];
1682
1681
  for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
1683
1682
  var pallet = _candidates[_i];
1684
- if (hasPallet(chain, pallet)) return pallet;
1683
+ if (hasPalletImpl(chain, pallet, ctx)) return pallet;
1685
1684
  }
1686
1685
  throw new XcmPalletNotFoundError(chain);
1687
1686
  };
1688
1687
 
1689
- export { ASSETS_PALLETS, CROSSCHAIN_PALLETS, OTHER_PALLETS, PALLETS, XcmPalletNotFoundError, getDefaultPallet, getNativeAssetsPallet, getOtherAssetsPallets, getPalletIndex, getSupportedPallets, getSupportedPalletsDetails, getXcmPallet, hasPallet };
1688
+ export { ASSETS_PALLETS, CROSSCHAIN_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY, OTHER_PALLETS, PALLETS, XcmPalletNotFoundError, getDefaultPallet, getNativeAssetsPallet, getOtherAssetsPallets, getPalletIndex, getSupportedPallets, getSupportedPalletsDetails, getXcmPallet, getXcmPalletImpl, hasPallet, hasPalletImpl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/pallets",
3
- "version": "13.5.0",
3
+ "version": "13.6.0",
4
4
  "description": "Pallets for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,21 +22,21 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@paraspell/sdk-common": "13.5.0"
25
+ "@paraspell/sdk-common": "13.6.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@babel/plugin-syntax-import-attributes": "^7.28.6",
29
- "@babel/preset-env": "^7.29.2",
28
+ "@babel/plugin-syntax-import-attributes": "^7.29.7",
29
+ "@babel/preset-env": "^7.29.7",
30
30
  "@codecov/rollup-plugin": "^2.0.1",
31
31
  "@polkadot/api": "^16.5.6",
32
32
  "@polkadot/types": "^16.5.6",
33
33
  "@rollup/plugin-babel": "^7.0.0",
34
34
  "@rollup/plugin-json": "^6.1.0",
35
35
  "@rollup/plugin-typescript": "^12.3.0",
36
- "@vitest/coverage-v8": "^4.1.5",
37
- "axios": "^1.15.2",
36
+ "@vitest/coverage-v8": "^4.1.7",
37
+ "axios": "^1.16.1",
38
38
  "dotenv": "^17.4.2",
39
- "rollup": "^4.60.2",
39
+ "rollup": "^4.60.4",
40
40
  "rollup-plugin-dts": "^6.4.1",
41
41
  "ts-node": "^10.9.2"
42
42
  },