@paraspell/sdk-common 11.14.8 → 12.0.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 +1 -9
- package/package.json +1 -1
- package/dist/index.cjs +0 -344
package/dist/index.d.ts
CHANGED
|
@@ -24,14 +24,6 @@ type TRelaychain = (typeof RELAYCHAINS)[number];
|
|
|
24
24
|
type TSubstrateChain = (typeof SUBSTRATE_CHAINS)[number];
|
|
25
25
|
type TExternalChain = (typeof EXTERNAL_CHAINS)[number];
|
|
26
26
|
type TChain = (typeof CHAINS)[number];
|
|
27
|
-
/** @deprecated Use `TChain` instead. */
|
|
28
|
-
type TNode = TChain;
|
|
29
|
-
/** @deprecated Use `TChain` instead. */
|
|
30
|
-
type TNodeWithRelayChains = TChain;
|
|
31
|
-
/** @deprecated Use `TParachain` instead. */
|
|
32
|
-
type TNodePolkadotKusama = TParachain;
|
|
33
|
-
/** @deprecated Use `TSubstrateChain` instead. */
|
|
34
|
-
type TNodeDotKsmWithRelayChains = TSubstrateChain;
|
|
35
27
|
|
|
36
28
|
declare enum Parents {
|
|
37
29
|
ZERO = 0,
|
|
@@ -152,4 +144,4 @@ declare const hasJunction: (location: TLocation, junctionType: TJunctionType, ju
|
|
|
152
144
|
declare const replaceBigInt: (_key: string, value: unknown) => unknown;
|
|
153
145
|
|
|
154
146
|
export { CHAINS, EXTERNAL_CHAINS, PARACHAINS, Parents, RELAYCHAINS, SUBSTRATE_CHAINS, Version, deepEqual, getJunctionValue, hasJunction, isExternalChain, isPrimitive, isRelayChain, isSubstrateBridge, isSystemChain, isTLocation, isTrustedChain, replaceBigInt };
|
|
155
|
-
export type { TChain, TExternalChain, TJunction, TJunctionGeneralIndex, TJunctionParachain, TJunctionType, TJunctions, TLocation,
|
|
147
|
+
export type { TChain, TExternalChain, TJunction, TJunctionGeneralIndex, TJunctionParachain, TJunctionType, TJunctions, TLocation, TParachain, TRelaychain, TSubstrateChain };
|
package/package.json
CHANGED
package/dist/index.cjs
DELETED
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Supported Polkadot / Kusama / Westend / Paseo parachains.
|
|
5
|
-
*/
|
|
6
|
-
var PARACHAINS = [
|
|
7
|
-
// Polkadot chains
|
|
8
|
-
'AssetHubPolkadot', 'Acala', 'Ajuna', 'Astar', 'BifrostPolkadot', 'BridgeHubPolkadot', 'Centrifuge', 'Darwinia', 'EnergyWebX', 'Hydration', 'Interlay', 'Heima', 'Jamton', 'Moonbeam', 'CoretimePolkadot', 'Collectives', 'Crust', 'Manta', 'Nodle', 'NeuroWeb', 'Pendulum', 'Phala', 'KiltSpiritnet', 'Curio', 'Mythos', 'Peaq', 'RobonomicsPolkadot', 'PeoplePolkadot', 'Unique', 'Xode',
|
|
9
|
-
// Kusama chains
|
|
10
|
-
'AssetHubKusama', 'BridgeHubKusama', 'Karura', 'Kintsugi', 'Moonriver', 'CoretimeKusama', 'Encointer', 'Altair', 'Amplitude', 'Basilisk', 'BifrostKusama', 'CrustShadow', 'Crab', 'Laos', 'Quartz', 'RobonomicsKusama', 'PeopleKusama', 'Shiden', 'Zeitgeist',
|
|
11
|
-
// Westend testnet chains
|
|
12
|
-
'AssetHubWestend', 'BridgeHubWestend', 'CollectivesWestend', 'CoretimeWestend', 'Penpal', 'PeopleWestend',
|
|
13
|
-
// Paseo testnet chains
|
|
14
|
-
'AjunaPaseo', 'AssetHubPaseo', 'BifrostPaseo', 'BridgeHubPaseo', 'CoretimePaseo', 'EnergyWebXPaseo', 'HeimaPaseo', 'HydrationPaseo', 'KiltPaseo', 'LaosPaseo', 'NeuroWebPaseo', 'PAssetHub', 'PeoplePaseo', 'ZeitgeistPaseo'];
|
|
15
|
-
/**
|
|
16
|
-
* Relaychains.
|
|
17
|
-
*/
|
|
18
|
-
var RELAYCHAINS = ['Polkadot', 'Kusama', 'Westend', 'Paseo'];
|
|
19
|
-
/**
|
|
20
|
-
* All Substrate chains (parachains + relaychains).
|
|
21
|
-
*/
|
|
22
|
-
var SUBSTRATE_CHAINS = [].concat(PARACHAINS, RELAYCHAINS);
|
|
23
|
-
/**
|
|
24
|
-
* External chains (non-Substrate/Polkadot ecosystem chains).
|
|
25
|
-
*/
|
|
26
|
-
var EXTERNAL_CHAINS = ['Ethereum'];
|
|
27
|
-
/**
|
|
28
|
-
* All supported chains.
|
|
29
|
-
*/
|
|
30
|
-
var CHAINS = [].concat(PARACHAINS, RELAYCHAINS, EXTERNAL_CHAINS);
|
|
31
|
-
|
|
32
|
-
function _arrayLikeToArray(r, a) {
|
|
33
|
-
(null == a || a > r.length) && (a = r.length);
|
|
34
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
35
|
-
return n;
|
|
36
|
-
}
|
|
37
|
-
function _arrayWithHoles(r) {
|
|
38
|
-
if (Array.isArray(r)) return r;
|
|
39
|
-
}
|
|
40
|
-
function _arrayWithoutHoles(r) {
|
|
41
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
42
|
-
}
|
|
43
|
-
function _createForOfIteratorHelper(r, e) {
|
|
44
|
-
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
45
|
-
if (!t) {
|
|
46
|
-
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
47
|
-
t && (r = t);
|
|
48
|
-
var n = 0,
|
|
49
|
-
F = function () {};
|
|
50
|
-
return {
|
|
51
|
-
s: F,
|
|
52
|
-
n: function () {
|
|
53
|
-
return n >= r.length ? {
|
|
54
|
-
done: true
|
|
55
|
-
} : {
|
|
56
|
-
done: false,
|
|
57
|
-
value: r[n++]
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
e: function (r) {
|
|
61
|
-
throw r;
|
|
62
|
-
},
|
|
63
|
-
f: F
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
67
|
-
}
|
|
68
|
-
var o,
|
|
69
|
-
a = true,
|
|
70
|
-
u = false;
|
|
71
|
-
return {
|
|
72
|
-
s: function () {
|
|
73
|
-
t = t.call(r);
|
|
74
|
-
},
|
|
75
|
-
n: function () {
|
|
76
|
-
var r = t.next();
|
|
77
|
-
return a = r.done, r;
|
|
78
|
-
},
|
|
79
|
-
e: function (r) {
|
|
80
|
-
u = true, o = r;
|
|
81
|
-
},
|
|
82
|
-
f: function () {
|
|
83
|
-
try {
|
|
84
|
-
a || null == t.return || t.return();
|
|
85
|
-
} finally {
|
|
86
|
-
if (u) throw o;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function _iterableToArray(r) {
|
|
92
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
93
|
-
}
|
|
94
|
-
function _iterableToArrayLimit(r, l) {
|
|
95
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
96
|
-
if (null != t) {
|
|
97
|
-
var e,
|
|
98
|
-
n,
|
|
99
|
-
i,
|
|
100
|
-
u,
|
|
101
|
-
a = [],
|
|
102
|
-
f = true,
|
|
103
|
-
o = false;
|
|
104
|
-
try {
|
|
105
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
106
|
-
} catch (r) {
|
|
107
|
-
o = true, n = r;
|
|
108
|
-
} finally {
|
|
109
|
-
try {
|
|
110
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
111
|
-
} finally {
|
|
112
|
-
if (o) throw n;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return a;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function _nonIterableRest() {
|
|
119
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
120
|
-
}
|
|
121
|
-
function _nonIterableSpread() {
|
|
122
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
123
|
-
}
|
|
124
|
-
function _slicedToArray(r, e) {
|
|
125
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
126
|
-
}
|
|
127
|
-
function _toConsumableArray(r) {
|
|
128
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
129
|
-
}
|
|
130
|
-
function _typeof(o) {
|
|
131
|
-
"@babel/helpers - typeof";
|
|
132
|
-
|
|
133
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
134
|
-
return typeof o;
|
|
135
|
-
} : function (o) {
|
|
136
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
137
|
-
}, _typeof(o);
|
|
138
|
-
}
|
|
139
|
-
function _unsupportedIterableToArray(r, a) {
|
|
140
|
-
if (r) {
|
|
141
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
142
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
143
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
var isTLocation = function isTLocation(value) {
|
|
148
|
-
return _typeof(value) === 'object' && value !== null && 'parents' in value && 'interior' in value;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
exports.Parents = void 0;
|
|
152
|
-
(function (Parents) {
|
|
153
|
-
Parents[Parents["ZERO"] = 0] = "ZERO";
|
|
154
|
-
Parents[Parents["ONE"] = 1] = "ONE";
|
|
155
|
-
Parents[Parents["TWO"] = 2] = "TWO";
|
|
156
|
-
})(exports.Parents || (exports.Parents = {}));
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The XCM version.
|
|
160
|
-
*/
|
|
161
|
-
exports.Version = void 0;
|
|
162
|
-
(function (Version) {
|
|
163
|
-
Version["V3"] = "V3";
|
|
164
|
-
Version["V4"] = "V4";
|
|
165
|
-
Version["V5"] = "V5";
|
|
166
|
-
})(exports.Version || (exports.Version = {}));
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Determines whether a given chain is a relaychain.
|
|
170
|
-
*
|
|
171
|
-
* @param chain - The chain to check.
|
|
172
|
-
* @returns True if the chain is a relaychain; otherwise, false.
|
|
173
|
-
*/
|
|
174
|
-
var isRelayChain = function isRelayChain(chain) {
|
|
175
|
-
return RELAYCHAINS.includes(chain);
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Determines whether a given chain is an external chain.
|
|
179
|
-
*
|
|
180
|
-
* @param chain - The chain to check.
|
|
181
|
-
* @returns True if the chain is an external chain; otherwise, false.
|
|
182
|
-
*/
|
|
183
|
-
var isExternalChain = function isExternalChain(chain) {
|
|
184
|
-
return EXTERNAL_CHAINS.includes(chain);
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Checks if a given chain is a system chain.
|
|
188
|
-
*
|
|
189
|
-
* @param chain - The chain to check.
|
|
190
|
-
* @returns True if the chain is a system chain; otherwise, false.
|
|
191
|
-
*/
|
|
192
|
-
var isSystemChain = function isSystemChain(chain) {
|
|
193
|
-
var systemChains = ['AssetHubPolkadot', 'AssetHubKusama', 'AssetHubWestend', 'AssetHubPaseo', 'BridgeHubPolkadot', 'BridgeHubKusama', 'BridgeHubWestend', 'BridgeHubPaseo', 'PeoplePolkadot', 'PeopleKusama', 'PeopleWestend', 'PeoplePaseo', 'CoretimePolkadot', 'CoretimeKusama', 'CoretimeWestend', 'CoretimePaseo', 'Collectives', 'Encointer', 'CollectivesWestend', 'PAssetHub'];
|
|
194
|
-
return systemChains.includes(chain) || isRelayChain(chain);
|
|
195
|
-
};
|
|
196
|
-
var isTrustedChain = function isTrustedChain(chain) {
|
|
197
|
-
var trusted = ['Mythos', 'Encointer'];
|
|
198
|
-
var isTrustedByAh = function isTrustedByAh(chain) {
|
|
199
|
-
return trusted.includes(chain);
|
|
200
|
-
};
|
|
201
|
-
return isTrustedByAh(chain) || isSystemChain(chain);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
var isPrimitive = function isPrimitive(obj) {
|
|
205
|
-
return obj !== Object(obj);
|
|
206
|
-
};
|
|
207
|
-
var _deepEqual = function deepEqual(obj1, obj2) {
|
|
208
|
-
if (obj1 === obj2) return true;
|
|
209
|
-
if (isPrimitive(obj1) && isPrimitive(obj2)) return obj1 === obj2;
|
|
210
|
-
if (_typeof(obj1) !== 'object' || obj1 === null || _typeof(obj2) !== 'object' || obj2 === null) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
if (Array.isArray(obj1) !== Array.isArray(obj2)) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
var obj1Keys = Object.keys(obj1).map(function (key) {
|
|
217
|
-
return key.toLowerCase();
|
|
218
|
-
});
|
|
219
|
-
var obj2Keys = Object.keys(obj2).map(function (key) {
|
|
220
|
-
return key.toLowerCase();
|
|
221
|
-
});
|
|
222
|
-
if (obj1Keys.length !== obj2Keys.length) return false;
|
|
223
|
-
var _iterator = _createForOfIteratorHelper(obj1Keys),
|
|
224
|
-
_step;
|
|
225
|
-
try {
|
|
226
|
-
var _loop = function _loop() {
|
|
227
|
-
var key = _step.value;
|
|
228
|
-
var keyInObj2 = obj2Keys.find(function (k) {
|
|
229
|
-
return k === key;
|
|
230
|
-
});
|
|
231
|
-
if (!keyInObj2) return {
|
|
232
|
-
v: false
|
|
233
|
-
};
|
|
234
|
-
var obj1Value = obj1[Object.keys(obj1).find(function (k) {
|
|
235
|
-
return k.toLowerCase() === key;
|
|
236
|
-
})];
|
|
237
|
-
var obj2Value = obj2[Object.keys(obj2).find(function (k) {
|
|
238
|
-
return k.toLowerCase() === key;
|
|
239
|
-
})];
|
|
240
|
-
if (!_deepEqual(obj1Value, obj2Value)) return {
|
|
241
|
-
v: false
|
|
242
|
-
};
|
|
243
|
-
},
|
|
244
|
-
_ret;
|
|
245
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
246
|
-
_ret = _loop();
|
|
247
|
-
if (_ret) return _ret.v;
|
|
248
|
-
}
|
|
249
|
-
} catch (err) {
|
|
250
|
-
_iterator.e(err);
|
|
251
|
-
} finally {
|
|
252
|
-
_iterator.f();
|
|
253
|
-
}
|
|
254
|
-
return true;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
var COMPATIBLE_BRIDGES = [['AssetHubPolkadot', 'AssetHubKusama']];
|
|
258
|
-
var isSubstrateBridge = function isSubstrateBridge(origin, destination) {
|
|
259
|
-
if (isExternalChain(origin) || isExternalChain(destination)) return false;
|
|
260
|
-
if (!origin.startsWith('AssetHub') || !destination.startsWith('AssetHub')) return false;
|
|
261
|
-
return COMPATIBLE_BRIDGES.some(function (_ref) {
|
|
262
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
263
|
-
a = _ref2[0],
|
|
264
|
-
b = _ref2[1];
|
|
265
|
-
return a === origin && b === destination || b === origin && a === destination;
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
var flattenJunctions = function flattenJunctions(junctions) {
|
|
270
|
-
if (junctions.Here !== undefined) {
|
|
271
|
-
return [];
|
|
272
|
-
}
|
|
273
|
-
var result = [];
|
|
274
|
-
if (junctions.X1) {
|
|
275
|
-
if (Array.isArray(junctions.X1)) {
|
|
276
|
-
result.push.apply(result, _toConsumableArray(junctions.X1));
|
|
277
|
-
} else {
|
|
278
|
-
result.push(junctions.X1);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (junctions.X2) result.push.apply(result, _toConsumableArray(junctions.X2));
|
|
282
|
-
if (junctions.X3) result.push.apply(result, _toConsumableArray(junctions.X3));
|
|
283
|
-
if (junctions.X4) result.push.apply(result, _toConsumableArray(junctions.X4));
|
|
284
|
-
if (junctions.X5) result.push.apply(result, _toConsumableArray(junctions.X5));
|
|
285
|
-
if (junctions.X6) result.push.apply(result, _toConsumableArray(junctions.X6));
|
|
286
|
-
if (junctions.X7) result.push.apply(result, _toConsumableArray(junctions.X7));
|
|
287
|
-
if (junctions.X8) result.push.apply(result, _toConsumableArray(junctions.X8));
|
|
288
|
-
return result;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
var findMatchingJunction = function findMatchingJunction(location, junctionType) {
|
|
292
|
-
if (location.interior === 'Here') {
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
|
-
var allJunctions = flattenJunctions(location.interior);
|
|
296
|
-
return allJunctions.find(function (junction) {
|
|
297
|
-
var keys = Object.keys(junction);
|
|
298
|
-
if (keys.length !== 1) {
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
var key = keys[0];
|
|
302
|
-
return key === junctionType;
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
var getJunctionValue = function getJunctionValue(location, junctionType) {
|
|
306
|
-
var matchingJunction = findMatchingJunction(location, junctionType);
|
|
307
|
-
return matchingJunction ? matchingJunction[junctionType] : undefined;
|
|
308
|
-
};
|
|
309
|
-
var hasJunction = function hasJunction(location, junctionType, junctionValue) {
|
|
310
|
-
var matchingJunction = findMatchingJunction(location, junctionType);
|
|
311
|
-
if (!matchingJunction) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
if (junctionValue === undefined) {
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
var jv = matchingJunction[junctionType];
|
|
318
|
-
try {
|
|
319
|
-
return JSON.stringify(jv) === JSON.stringify(junctionValue);
|
|
320
|
-
} catch (_unused) {
|
|
321
|
-
return jv === junctionValue;
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
var replaceBigInt = function replaceBigInt(_key, value) {
|
|
326
|
-
return typeof value === 'bigint' ? value.toString() : value;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
exports.CHAINS = CHAINS;
|
|
330
|
-
exports.EXTERNAL_CHAINS = EXTERNAL_CHAINS;
|
|
331
|
-
exports.PARACHAINS = PARACHAINS;
|
|
332
|
-
exports.RELAYCHAINS = RELAYCHAINS;
|
|
333
|
-
exports.SUBSTRATE_CHAINS = SUBSTRATE_CHAINS;
|
|
334
|
-
exports.deepEqual = _deepEqual;
|
|
335
|
-
exports.getJunctionValue = getJunctionValue;
|
|
336
|
-
exports.hasJunction = hasJunction;
|
|
337
|
-
exports.isExternalChain = isExternalChain;
|
|
338
|
-
exports.isPrimitive = isPrimitive;
|
|
339
|
-
exports.isRelayChain = isRelayChain;
|
|
340
|
-
exports.isSubstrateBridge = isSubstrateBridge;
|
|
341
|
-
exports.isSystemChain = isSystemChain;
|
|
342
|
-
exports.isTLocation = isTLocation;
|
|
343
|
-
exports.isTrustedChain = isTrustedChain;
|
|
344
|
-
exports.replaceBigInt = replaceBigInt;
|