@paraspell/sdk-common 10.5.2 → 10.7.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.cjs +24 -15
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +24 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -209,31 +209,39 @@ var flattenJunctions = function flattenJunctions(junctions) {
|
|
|
209
209
|
return result;
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
var
|
|
212
|
+
var findMatchingJunction = function findMatchingJunction(multiLocation, junctionType) {
|
|
213
213
|
if (multiLocation.interior === 'Here') {
|
|
214
|
-
return
|
|
214
|
+
return undefined;
|
|
215
215
|
}
|
|
216
216
|
var allJunctions = flattenJunctions(multiLocation.interior);
|
|
217
|
-
return allJunctions.
|
|
217
|
+
return allJunctions.find(function (junction) {
|
|
218
218
|
var keys = Object.keys(junction);
|
|
219
219
|
if (keys.length !== 1) {
|
|
220
220
|
return false;
|
|
221
221
|
}
|
|
222
222
|
var key = keys[0];
|
|
223
|
-
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
if (junctionValue === undefined) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
var jv = junction[key];
|
|
230
|
-
try {
|
|
231
|
-
return JSON.stringify(jv) === JSON.stringify(junctionValue);
|
|
232
|
-
} catch (_unused) {
|
|
233
|
-
return jv === junctionValue;
|
|
234
|
-
}
|
|
223
|
+
return key === junctionType;
|
|
235
224
|
});
|
|
236
225
|
};
|
|
226
|
+
var getJunctionValue = function getJunctionValue(multiLocation, junctionType) {
|
|
227
|
+
var matchingJunction = findMatchingJunction(multiLocation, junctionType);
|
|
228
|
+
return matchingJunction ? matchingJunction[junctionType] : undefined;
|
|
229
|
+
};
|
|
230
|
+
var hasJunction = function hasJunction(multiLocation, junctionType, junctionValue) {
|
|
231
|
+
var matchingJunction = findMatchingJunction(multiLocation, junctionType);
|
|
232
|
+
if (!matchingJunction) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
if (junctionValue === undefined) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
var jv = matchingJunction[junctionType];
|
|
239
|
+
try {
|
|
240
|
+
return JSON.stringify(jv) === JSON.stringify(junctionValue);
|
|
241
|
+
} catch (_unused) {
|
|
242
|
+
return jv === junctionValue;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
237
245
|
|
|
238
246
|
var replaceBigInt = function replaceBigInt(_key, value) {
|
|
239
247
|
return typeof value === 'bigint' ? value.toString() : value;
|
|
@@ -244,6 +252,7 @@ exports.NODES_WITH_RELAY_CHAINS_DOT_KSM = NODES_WITH_RELAY_CHAINS_DOT_KSM;
|
|
|
244
252
|
exports.NODE_NAMES = NODE_NAMES;
|
|
245
253
|
exports.NODE_NAMES_DOT_KSM = NODE_NAMES_DOT_KSM;
|
|
246
254
|
exports.deepEqual = _deepEqual;
|
|
255
|
+
exports.getJunctionValue = getJunctionValue;
|
|
247
256
|
exports.hasJunction = hasJunction;
|
|
248
257
|
exports.isDotKsmBridge = isDotKsmBridge;
|
|
249
258
|
exports.isPrimitive = isPrimitive;
|
package/dist/index.d.ts
CHANGED
|
@@ -121,9 +121,10 @@ declare const isDotKsmBridge: (origin: TNodeDotKsmWithRelayChains, destination:
|
|
|
121
121
|
*/
|
|
122
122
|
declare const isRelayChain: (node: TNodeWithRelayChains) => node is "Polkadot" | "Kusama";
|
|
123
123
|
|
|
124
|
+
declare const getJunctionValue: <T = unknown>(multiLocation: TMultiLocation, junctionType: TJunctionType) => T | undefined;
|
|
124
125
|
declare const hasJunction: (multiLocation: TMultiLocation, junctionType: TJunctionType, junctionValue?: unknown) => boolean;
|
|
125
126
|
|
|
126
127
|
declare const replaceBigInt: (_key: string, value: unknown) => unknown;
|
|
127
128
|
|
|
128
|
-
export { NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, Parents, Version, deepEqual, hasJunction, isDotKsmBridge, isPrimitive, isRelayChain, isTMultiLocation, replaceBigInt };
|
|
129
|
+
export { NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, Parents, Version, deepEqual, getJunctionValue, hasJunction, isDotKsmBridge, isPrimitive, isRelayChain, isTMultiLocation, replaceBigInt };
|
|
129
130
|
export type { TEcosystemType, TJunction, TJunctionGeneralIndex, TJunctionParachain, TJunctionType, TJunctions, TMultiLocation, TNode, TNodeDotKsmWithRelayChains, TNodePolkadotKusama, TNodeWithRelayChains, TRelayChainSymbol };
|
package/dist/index.mjs
CHANGED
|
@@ -207,34 +207,42 @@ var flattenJunctions = function flattenJunctions(junctions) {
|
|
|
207
207
|
return result;
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
var
|
|
210
|
+
var findMatchingJunction = function findMatchingJunction(multiLocation, junctionType) {
|
|
211
211
|
if (multiLocation.interior === 'Here') {
|
|
212
|
-
return
|
|
212
|
+
return undefined;
|
|
213
213
|
}
|
|
214
214
|
var allJunctions = flattenJunctions(multiLocation.interior);
|
|
215
|
-
return allJunctions.
|
|
215
|
+
return allJunctions.find(function (junction) {
|
|
216
216
|
var keys = Object.keys(junction);
|
|
217
217
|
if (keys.length !== 1) {
|
|
218
218
|
return false;
|
|
219
219
|
}
|
|
220
220
|
var key = keys[0];
|
|
221
|
-
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
if (junctionValue === undefined) {
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
var jv = junction[key];
|
|
228
|
-
try {
|
|
229
|
-
return JSON.stringify(jv) === JSON.stringify(junctionValue);
|
|
230
|
-
} catch (_unused) {
|
|
231
|
-
return jv === junctionValue;
|
|
232
|
-
}
|
|
221
|
+
return key === junctionType;
|
|
233
222
|
});
|
|
234
223
|
};
|
|
224
|
+
var getJunctionValue = function getJunctionValue(multiLocation, junctionType) {
|
|
225
|
+
var matchingJunction = findMatchingJunction(multiLocation, junctionType);
|
|
226
|
+
return matchingJunction ? matchingJunction[junctionType] : undefined;
|
|
227
|
+
};
|
|
228
|
+
var hasJunction = function hasJunction(multiLocation, junctionType, junctionValue) {
|
|
229
|
+
var matchingJunction = findMatchingJunction(multiLocation, junctionType);
|
|
230
|
+
if (!matchingJunction) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
if (junctionValue === undefined) {
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
var jv = matchingJunction[junctionType];
|
|
237
|
+
try {
|
|
238
|
+
return JSON.stringify(jv) === JSON.stringify(junctionValue);
|
|
239
|
+
} catch (_unused) {
|
|
240
|
+
return jv === junctionValue;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
235
243
|
|
|
236
244
|
var replaceBigInt = function replaceBigInt(_key, value) {
|
|
237
245
|
return typeof value === 'bigint' ? value.toString() : value;
|
|
238
246
|
};
|
|
239
247
|
|
|
240
|
-
export { NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, Parents, Version, _deepEqual as deepEqual, hasJunction, isDotKsmBridge, isPrimitive, isRelayChain, isTMultiLocation, replaceBigInt };
|
|
248
|
+
export { NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, Parents, Version, _deepEqual as deepEqual, getJunctionValue, hasJunction, isDotKsmBridge, isPrimitive, isRelayChain, isTMultiLocation, replaceBigInt };
|