@paraspell/sdk-common 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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Supported Polkadot / Kusama / Westend / Paseo parachains.
3
3
  */
4
- declare const PARACHAINS: readonly ["AssetHubPolkadot", "Acala", "Ajuna", "Astar", "BifrostPolkadot", "BridgeHubPolkadot", "Centrifuge", "Darwinia", "EnergyWebX", "Hydration", "Interlay", "Heima", "Jamton", "Moonbeam", "CoretimePolkadot", "Collectives", "Crust", "NeuroWeb", "Pendulum", "Mythos", "Peaq", "PeoplePolkadot", "Unique", "Xode", "AssetHubKusama", "BridgeHubKusama", "Karura", "Kintsugi", "Moonriver", "CoretimeKusama", "Encointer", "Basilisk", "BifrostKusama", "CrustShadow", "Crab", "Laos", "Quartz", "RobonomicsPolkadot", "PeopleKusama", "Shiden", "Zeitgeist", "AssetHubWestend", "BridgeHubWestend", "CollectivesWestend", "CoretimeWestend", "Penpal", "PeopleWestend", "AjunaPaseo", "AssetHubPaseo", "BifrostPaseo", "BridgeHubPaseo", "CoretimePaseo", "EnergyWebXPaseo", "HeimaPaseo", "HydrationPaseo", "LaosPaseo", "NeuroWebPaseo", "PeoplePaseo", "ZeitgeistPaseo"];
4
+ declare const PARACHAINS: readonly ["AssetHubPolkadot", "Acala", "Ajuna", "Astar", "BifrostPolkadot", "BridgeHubPolkadot", "Centrifuge", "Darwinia", "EnergyWebX", "Hydration", "Interlay", "Heima", "Jamton", "Moonbeam", "CoretimePolkadot", "Collectives", "Crust", "NeuroWeb", "Pendulum", "Mythos", "Peaq", "PeoplePolkadot", "Unique", "Xode", "AssetHubKusama", "BridgeHubKusama", "Karura", "Kintsugi", "Moonriver", "CoretimeKusama", "Encointer", "Basilisk", "BifrostKusama", "CrustShadow", "Crab", "Quartz", "RobonomicsPolkadot", "PeopleKusama", "Shiden", "Zeitgeist", "AssetHubWestend", "BridgeHubWestend", "CollectivesWestend", "CoretimeWestend", "Penpal", "PeopleWestend", "AjunaPaseo", "AssetHubPaseo", "BifrostPaseo", "BridgeHubPaseo", "CoretimePaseo", "EnergyWebXPaseo", "HeimaPaseo", "HydrationPaseo", "NeuroWebPaseo", "PeoplePaseo", "ZeitgeistPaseo"];
5
5
  /**
6
6
  * Relaychains.
7
7
  */
@@ -9,15 +9,19 @@ declare const RELAYCHAINS: readonly ["Polkadot", "Kusama", "Westend", "Paseo"];
9
9
  /**
10
10
  * All Substrate chains (parachains + relaychains).
11
11
  */
12
- declare const SUBSTRATE_CHAINS: readonly ["AssetHubPolkadot", "Acala", "Ajuna", "Astar", "BifrostPolkadot", "BridgeHubPolkadot", "Centrifuge", "Darwinia", "EnergyWebX", "Hydration", "Interlay", "Heima", "Jamton", "Moonbeam", "CoretimePolkadot", "Collectives", "Crust", "NeuroWeb", "Pendulum", "Mythos", "Peaq", "PeoplePolkadot", "Unique", "Xode", "AssetHubKusama", "BridgeHubKusama", "Karura", "Kintsugi", "Moonriver", "CoretimeKusama", "Encointer", "Basilisk", "BifrostKusama", "CrustShadow", "Crab", "Laos", "Quartz", "RobonomicsPolkadot", "PeopleKusama", "Shiden", "Zeitgeist", "AssetHubWestend", "BridgeHubWestend", "CollectivesWestend", "CoretimeWestend", "Penpal", "PeopleWestend", "AjunaPaseo", "AssetHubPaseo", "BifrostPaseo", "BridgeHubPaseo", "CoretimePaseo", "EnergyWebXPaseo", "HeimaPaseo", "HydrationPaseo", "LaosPaseo", "NeuroWebPaseo", "PeoplePaseo", "ZeitgeistPaseo", "Polkadot", "Kusama", "Westend", "Paseo"];
12
+ declare const SUBSTRATE_CHAINS: readonly ["AssetHubPolkadot", "Acala", "Ajuna", "Astar", "BifrostPolkadot", "BridgeHubPolkadot", "Centrifuge", "Darwinia", "EnergyWebX", "Hydration", "Interlay", "Heima", "Jamton", "Moonbeam", "CoretimePolkadot", "Collectives", "Crust", "NeuroWeb", "Pendulum", "Mythos", "Peaq", "PeoplePolkadot", "Unique", "Xode", "AssetHubKusama", "BridgeHubKusama", "Karura", "Kintsugi", "Moonriver", "CoretimeKusama", "Encointer", "Basilisk", "BifrostKusama", "CrustShadow", "Crab", "Quartz", "RobonomicsPolkadot", "PeopleKusama", "Shiden", "Zeitgeist", "AssetHubWestend", "BridgeHubWestend", "CollectivesWestend", "CoretimeWestend", "Penpal", "PeopleWestend", "AjunaPaseo", "AssetHubPaseo", "BifrostPaseo", "BridgeHubPaseo", "CoretimePaseo", "EnergyWebXPaseo", "HeimaPaseo", "HydrationPaseo", "NeuroWebPaseo", "PeoplePaseo", "ZeitgeistPaseo", "Polkadot", "Kusama", "Westend", "Paseo"];
13
13
  /**
14
14
  * External chains (non-Substrate/Polkadot ecosystem chains).
15
15
  */
16
16
  declare const EXTERNAL_CHAINS: readonly ["Ethereum", "EthereumTestnet"];
17
+ /**
18
+ * Default SS58 address prefix.
19
+ */
20
+ declare const DEFAULT_SS58_PREFIX = 42;
17
21
  /**
18
22
  * All supported chains.
19
23
  */
20
- declare const CHAINS: readonly ["AssetHubPolkadot", "Acala", "Ajuna", "Astar", "BifrostPolkadot", "BridgeHubPolkadot", "Centrifuge", "Darwinia", "EnergyWebX", "Hydration", "Interlay", "Heima", "Jamton", "Moonbeam", "CoretimePolkadot", "Collectives", "Crust", "NeuroWeb", "Pendulum", "Mythos", "Peaq", "PeoplePolkadot", "Unique", "Xode", "AssetHubKusama", "BridgeHubKusama", "Karura", "Kintsugi", "Moonriver", "CoretimeKusama", "Encointer", "Basilisk", "BifrostKusama", "CrustShadow", "Crab", "Laos", "Quartz", "RobonomicsPolkadot", "PeopleKusama", "Shiden", "Zeitgeist", "AssetHubWestend", "BridgeHubWestend", "CollectivesWestend", "CoretimeWestend", "Penpal", "PeopleWestend", "AjunaPaseo", "AssetHubPaseo", "BifrostPaseo", "BridgeHubPaseo", "CoretimePaseo", "EnergyWebXPaseo", "HeimaPaseo", "HydrationPaseo", "LaosPaseo", "NeuroWebPaseo", "PeoplePaseo", "ZeitgeistPaseo", "Polkadot", "Kusama", "Westend", "Paseo", "Ethereum", "EthereumTestnet"];
24
+ declare const CHAINS: readonly ["AssetHubPolkadot", "Acala", "Ajuna", "Astar", "BifrostPolkadot", "BridgeHubPolkadot", "Centrifuge", "Darwinia", "EnergyWebX", "Hydration", "Interlay", "Heima", "Jamton", "Moonbeam", "CoretimePolkadot", "Collectives", "Crust", "NeuroWeb", "Pendulum", "Mythos", "Peaq", "PeoplePolkadot", "Unique", "Xode", "AssetHubKusama", "BridgeHubKusama", "Karura", "Kintsugi", "Moonriver", "CoretimeKusama", "Encointer", "Basilisk", "BifrostKusama", "CrustShadow", "Crab", "Quartz", "RobonomicsPolkadot", "PeopleKusama", "Shiden", "Zeitgeist", "AssetHubWestend", "BridgeHubWestend", "CollectivesWestend", "CoretimeWestend", "Penpal", "PeopleWestend", "AjunaPaseo", "AssetHubPaseo", "BifrostPaseo", "BridgeHubPaseo", "CoretimePaseo", "EnergyWebXPaseo", "HeimaPaseo", "HydrationPaseo", "NeuroWebPaseo", "PeoplePaseo", "ZeitgeistPaseo", "Polkadot", "Kusama", "Westend", "Paseo", "Ethereum", "EthereumTestnet"];
21
25
 
22
26
  type TParachain = (typeof PARACHAINS)[number];
23
27
  type TRelaychain = (typeof RELAYCHAINS)[number];
@@ -110,32 +114,52 @@ declare enum Version {
110
114
 
111
115
  declare const isTLocation: (value: unknown) => value is TLocation;
112
116
 
113
- declare const isSubstrateBridge: (origin: TChain, destination: TChain) => boolean;
114
- declare const isSnowbridge: (_origin: TChain, destination: TChain) => boolean;
115
- declare const isBridge: (origin: TChain, destination: TChain) => boolean;
117
+ declare const isSubstrateBridge: <TCustomChain extends string = never>(origin: TChain | TCustomChain, destination: TChain | TCustomChain) => boolean;
118
+ declare const isSnowbridge: <TCustomChain extends string = never>(_origin: TChain | TCustomChain, destination: TChain | TCustomChain) => boolean;
119
+ declare const isBridge: <TCustomChain extends string = never>(origin: TChain | TCustomChain, destination: TChain | TCustomChain) => boolean;
116
120
 
121
+ /** * Checks if a given string is a valid chain.
122
+ *
123
+ * @param chain - The string to check.
124
+ * @returns True if the string is a valid chain; otherwise, false.
125
+ */
126
+ declare const isChain: (chain: string) => chain is TChain;
127
+ /**
128
+ * Checks if a given string is a valid substrate chain.
129
+ *
130
+ * @param chain - The string to check.
131
+ * @returns True if the string is a valid substrate chain; otherwise, false.
132
+ */
133
+ declare const isSubstrateChain: (chain: string) => chain is TSubstrateChain;
117
134
  /**
118
135
  * Determines whether a given chain is a relaychain.
119
136
  *
120
137
  * @param chain - The chain to check.
121
138
  * @returns True if the chain is a relaychain; otherwise, false.
122
139
  */
123
- declare const isRelayChain: (chain: TChain) => chain is TRelaychain;
140
+ declare const isRelayChain: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => chain is TRelaychain;
124
141
  /**
125
142
  * Determines whether a given chain is an external chain.
126
143
  *
127
144
  * @param chain - The chain to check.
128
145
  * @returns True if the chain is an external chain; otherwise, false.
129
146
  */
130
- declare const isExternalChain: (chain: TChain) => chain is TExternalChain;
147
+ declare const isExternalChain: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => chain is TExternalChain;
148
+ /**
149
+ * Determines whether a given chain is a custom (user-registered) chain.
150
+ *
151
+ * @param chain - The chain to check.
152
+ * @returns True if the chain is a custom added chain; otherwise, false.
153
+ */
154
+ declare const isCustomChain: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => chain is TCustomChain;
131
155
  /**
132
156
  * Checks if a given chain is a system chain.
133
157
  *
134
158
  * @param chain - The chain to check.
135
159
  * @returns True if the chain is a system chain; otherwise, false.
136
160
  */
137
- declare const isSystemChain: (chain: TChain) => boolean;
138
- declare const isTrustedChain: (chain: TChain) => boolean;
161
+ declare const isSystemChain: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => boolean;
162
+ declare const isTrustedChain: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => boolean;
139
163
 
140
164
  declare const isPrimitive: (obj: unknown) => boolean;
141
165
  declare const deepEqual: (obj1: unknown, obj2: unknown) => boolean;
@@ -145,5 +169,5 @@ declare const hasJunction: (location: TLocation, junctionType: TJunctionType, ju
145
169
 
146
170
  declare const replaceBigInt: (_key: string, value: unknown) => unknown;
147
171
 
148
- export { CHAINS, EXTERNAL_CHAINS, PARACHAINS, Parents, RELAYCHAINS, SUBSTRATE_CHAINS, Version, deepEqual, getJunctionValue, hasJunction, isBridge, isExternalChain, isPrimitive, isRelayChain, isSnowbridge, isSubstrateBridge, isSystemChain, isTLocation, isTrustedChain, replaceBigInt };
172
+ export { CHAINS, DEFAULT_SS58_PREFIX, EXTERNAL_CHAINS, PARACHAINS, Parents, RELAYCHAINS, SUBSTRATE_CHAINS, Version, deepEqual, getJunctionValue, hasJunction, isBridge, isChain, isCustomChain, isExternalChain, isPrimitive, isRelayChain, isSnowbridge, isSubstrateBridge, isSubstrateChain, isSystemChain, isTLocation, isTrustedChain, replaceBigInt };
149
173
  export type { TChain, TExternalChain, TJunction, TJunctionAccountId32, TJunctionAccountIndex64, TJunctionAccountKey20, TJunctionGeneralIndex, TJunctionGeneralKey, TJunctionGlobalConsensus, TJunctionOnlyChild, TJunctionPalletInstance, TJunctionParachain, TJunctionPlurality, TJunctionType, TJunctions, TLocation, TParachain, TRelaychain, TSubstrateChain };
package/dist/index.mjs CHANGED
@@ -5,11 +5,11 @@ var PARACHAINS = [
5
5
  // Polkadot chains
6
6
  'AssetHubPolkadot', 'Acala', 'Ajuna', 'Astar', 'BifrostPolkadot', 'BridgeHubPolkadot', 'Centrifuge', 'Darwinia', 'EnergyWebX', 'Hydration', 'Interlay', 'Heima', 'Jamton', 'Moonbeam', 'CoretimePolkadot', 'Collectives', 'Crust', 'NeuroWeb', 'Pendulum', 'Mythos', 'Peaq', 'PeoplePolkadot', 'Unique', 'Xode',
7
7
  // Kusama chains
8
- 'AssetHubKusama', 'BridgeHubKusama', 'Karura', 'Kintsugi', 'Moonriver', 'CoretimeKusama', 'Encointer', 'Basilisk', 'BifrostKusama', 'CrustShadow', 'Crab', 'Laos', 'Quartz', 'RobonomicsPolkadot', 'PeopleKusama', 'Shiden', 'Zeitgeist',
8
+ 'AssetHubKusama', 'BridgeHubKusama', 'Karura', 'Kintsugi', 'Moonriver', 'CoretimeKusama', 'Encointer', 'Basilisk', 'BifrostKusama', 'CrustShadow', 'Crab', 'Quartz', 'RobonomicsPolkadot', 'PeopleKusama', 'Shiden', 'Zeitgeist',
9
9
  // Westend testnet chains
10
10
  'AssetHubWestend', 'BridgeHubWestend', 'CollectivesWestend', 'CoretimeWestend', 'Penpal', 'PeopleWestend',
11
11
  // Paseo testnet chains
12
- 'AjunaPaseo', 'AssetHubPaseo', 'BifrostPaseo', 'BridgeHubPaseo', 'CoretimePaseo', 'EnergyWebXPaseo', 'HeimaPaseo', 'HydrationPaseo', 'LaosPaseo', 'NeuroWebPaseo', 'PeoplePaseo', 'ZeitgeistPaseo'];
12
+ 'AjunaPaseo', 'AssetHubPaseo', 'BifrostPaseo', 'BridgeHubPaseo', 'CoretimePaseo', 'EnergyWebXPaseo', 'HeimaPaseo', 'HydrationPaseo', 'NeuroWebPaseo', 'PeoplePaseo', 'ZeitgeistPaseo'];
13
13
  /**
14
14
  * Relaychains.
15
15
  */
@@ -22,6 +22,10 @@ var SUBSTRATE_CHAINS = [].concat(PARACHAINS, RELAYCHAINS);
22
22
  * External chains (non-Substrate/Polkadot ecosystem chains).
23
23
  */
24
24
  var EXTERNAL_CHAINS = ['Ethereum', 'EthereumTestnet'];
25
+ /**
26
+ * Default SS58 address prefix.
27
+ */
28
+ var DEFAULT_SS58_PREFIX = 42;
25
29
  /**
26
30
  * All supported chains.
27
31
  */
@@ -163,6 +167,27 @@ var Version;
163
167
  Version["V5"] = "V5";
164
168
  })(Version || (Version = {}));
165
169
 
170
+ /** * Checks if a given string is a valid chain.
171
+ *
172
+ * @param chain - The string to check.
173
+ * @returns True if the string is a valid chain; otherwise, false.
174
+ */
175
+ var isChain = function isChain(chain) {
176
+ return CHAINS.some(function (c) {
177
+ return c === chain;
178
+ });
179
+ };
180
+ /**
181
+ * Checks if a given string is a valid substrate chain.
182
+ *
183
+ * @param chain - The string to check.
184
+ * @returns True if the string is a valid substrate chain; otherwise, false.
185
+ */
186
+ var isSubstrateChain = function isSubstrateChain(chain) {
187
+ return SUBSTRATE_CHAINS.some(function (c) {
188
+ return c === chain;
189
+ });
190
+ };
166
191
  /**
167
192
  * Determines whether a given chain is a relaychain.
168
193
  *
@@ -170,7 +195,9 @@ var Version;
170
195
  * @returns True if the chain is a relaychain; otherwise, false.
171
196
  */
172
197
  var isRelayChain = function isRelayChain(chain) {
173
- return RELAYCHAINS.includes(chain);
198
+ return RELAYCHAINS.some(function (c) {
199
+ return c === chain;
200
+ });
174
201
  };
175
202
  /**
176
203
  * Determines whether a given chain is an external chain.
@@ -179,7 +206,20 @@ var isRelayChain = function isRelayChain(chain) {
179
206
  * @returns True if the chain is an external chain; otherwise, false.
180
207
  */
181
208
  var isExternalChain = function isExternalChain(chain) {
182
- return EXTERNAL_CHAINS.includes(chain);
209
+ return EXTERNAL_CHAINS.some(function (c) {
210
+ return c === chain;
211
+ });
212
+ };
213
+ /**
214
+ * Determines whether a given chain is a custom (user-registered) chain.
215
+ *
216
+ * @param chain - The chain to check.
217
+ * @returns True if the chain is a custom added chain; otherwise, false.
218
+ */
219
+ var isCustomChain = function isCustomChain(chain) {
220
+ return !CHAINS.some(function (c) {
221
+ return c === chain;
222
+ });
183
223
  };
184
224
  /**
185
225
  * Checks if a given chain is a system chain.
@@ -189,14 +229,15 @@ var isExternalChain = function isExternalChain(chain) {
189
229
  */
190
230
  var isSystemChain = function isSystemChain(chain) {
191
231
  var systemChains = ['AssetHubPolkadot', 'AssetHubKusama', 'AssetHubWestend', 'AssetHubPaseo', 'BridgeHubPolkadot', 'BridgeHubKusama', 'BridgeHubWestend', 'BridgeHubPaseo', 'PeoplePolkadot', 'PeopleKusama', 'PeopleWestend', 'PeoplePaseo', 'CoretimePolkadot', 'CoretimeKusama', 'CoretimeWestend', 'CoretimePaseo', 'Collectives', 'Encointer', 'CollectivesWestend'];
192
- return systemChains.includes(chain) || isRelayChain(chain);
232
+ return systemChains.some(function (c) {
233
+ return c === chain;
234
+ }) || isRelayChain(chain);
193
235
  };
194
236
  var isTrustedChain = function isTrustedChain(chain) {
195
- var trusted = ['Mythos', 'Encointer'];
196
- var isTrustedByAh = function isTrustedByAh(chain) {
197
- return trusted.includes(chain);
198
- };
199
- return isTrustedByAh(chain) || isSystemChain(chain);
237
+ var isTrustedByAh = ['Mythos', 'Encointer'];
238
+ return isTrustedByAh.some(function (t) {
239
+ return t === chain;
240
+ }) || isSystemChain(chain);
200
241
  };
201
242
 
202
243
  var COMPATIBLE_BRIDGES = [['AssetHubPolkadot', 'AssetHubKusama']];
@@ -330,4 +371,4 @@ var replaceBigInt = function replaceBigInt(_key, value) {
330
371
  return typeof value === 'bigint' ? value.toString() : value;
331
372
  };
332
373
 
333
- export { CHAINS, EXTERNAL_CHAINS, PARACHAINS, Parents, RELAYCHAINS, SUBSTRATE_CHAINS, Version, _deepEqual as deepEqual, getJunctionValue, hasJunction, isBridge, isExternalChain, isPrimitive, isRelayChain, isSnowbridge, isSubstrateBridge, isSystemChain, isTLocation, isTrustedChain, replaceBigInt };
374
+ export { CHAINS, DEFAULT_SS58_PREFIX, EXTERNAL_CHAINS, PARACHAINS, Parents, RELAYCHAINS, SUBSTRATE_CHAINS, Version, _deepEqual as deepEqual, getJunctionValue, hasJunction, isBridge, isChain, isCustomChain, isExternalChain, isPrimitive, isRelayChain, isSnowbridge, isSubstrateBridge, isSubstrateChain, isSystemChain, isTLocation, isTrustedChain, replaceBigInt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-common",
3
- "version": "13.5.0",
3
+ "version": "13.6.0",
4
4
  "description": "SDK common code for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,17 +23,17 @@
23
23
  ],
24
24
  "dependencies": {},
25
25
  "devDependencies": {
26
- "@babel/plugin-syntax-import-attributes": "^7.28.6",
27
- "@babel/preset-env": "^7.29.2",
26
+ "@babel/plugin-syntax-import-attributes": "^7.29.7",
27
+ "@babel/preset-env": "^7.29.7",
28
28
  "@codecov/rollup-plugin": "^2.0.1",
29
29
  "@polkadot/api": "^16.5.6",
30
30
  "@polkadot/types": "^16.5.6",
31
31
  "@rollup/plugin-babel": "^7.0.0",
32
32
  "@rollup/plugin-json": "^6.1.0",
33
33
  "@rollup/plugin-typescript": "^12.3.0",
34
- "@vitest/coverage-v8": "^4.1.5",
34
+ "@vitest/coverage-v8": "^4.1.7",
35
35
  "dotenv": "^17.4.2",
36
- "rollup": "^4.60.2",
36
+ "rollup": "^4.60.4",
37
37
  "rollup-plugin-dts": "^6.4.1"
38
38
  },
39
39
  "scripts": {