@paraspell/sdk-core 13.6.0 → 13.7.1
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 +8 -3
- package/dist/index.mjs +143 -49
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ declare abstract class PolkadotApi<TApi, TRes, TSigner, TCustomChain extends str
|
|
|
48
48
|
_api?: TApi;
|
|
49
49
|
_chain?: TSubstrateChain | TCustomChain;
|
|
50
50
|
readonly _config?: TBuilderOptions<TApiOrUrl<TApi>>;
|
|
51
|
-
|
|
51
|
+
_customCtx: TFullCustomCtx;
|
|
52
52
|
_ttlMs: number;
|
|
53
53
|
_disconnectAllowed: boolean;
|
|
54
54
|
abstract readonly type: TApiType;
|
|
@@ -72,7 +72,9 @@ declare abstract class PolkadotApi<TApi, TRes, TSigner, TCustomChain extends str
|
|
|
72
72
|
getRelayChainSymbol(chain: TChain): string;
|
|
73
73
|
hasDryRunSupport(chain: TChain): boolean;
|
|
74
74
|
hasXcmPaymentApiSupport(chain: TChain): boolean;
|
|
75
|
-
init(chain: TChain | TCustomChain, clientTtlMs?: number): Promise<void>;
|
|
75
|
+
init(chain: TChain | TCustomChain, clientTtlMs?: number, destination?: TDestination): Promise<void>;
|
|
76
|
+
setCustomCtx(ctx: TFullCustomCtx): void;
|
|
77
|
+
private hydrateCustomChain;
|
|
76
78
|
abstract leaseClient(wsUrl: TUrl, ttlMs: number): Promise<TApi>;
|
|
77
79
|
abstract accountToHex(address: string, isPrefixed?: boolean): string;
|
|
78
80
|
abstract accountToUint8a(address: string): Uint8Array;
|
|
@@ -114,6 +116,8 @@ declare abstract class PolkadotApi<TApi, TRes, TSigner, TCustomChain extends str
|
|
|
114
116
|
abstract signAndSubmit(tx: TRes, sender: TSender<TSigner>): Promise<string>;
|
|
115
117
|
abstract signAndSubmitFinalized(tx: TRes, sender: TSender<TSigner>): Promise<string>;
|
|
116
118
|
abstract getSystemProperties(): Promise<TSystemProperties>;
|
|
119
|
+
abstract getConstant<T = unknown>(pallet: string, name: string): Promise<T | undefined>;
|
|
120
|
+
private getNativeExistentialDeposit;
|
|
117
121
|
private maybeHydrateCustomChain;
|
|
118
122
|
}
|
|
119
123
|
|
|
@@ -984,6 +988,7 @@ type TCustomChainEntryHydrated = TCustomChainEntry & {
|
|
|
984
988
|
isEVM: boolean;
|
|
985
989
|
supportsDryRunApi: boolean;
|
|
986
990
|
supportsXcmPaymentApi: boolean;
|
|
991
|
+
nativeExistentialDeposit?: string;
|
|
987
992
|
pallets: TCustomChainPallets;
|
|
988
993
|
};
|
|
989
994
|
type TCustomChainsCtx = Record<string, TCustomChainEntry>;
|
|
@@ -2554,7 +2559,7 @@ declare const normalizeAmount: (amount: bigint) => bigint;
|
|
|
2554
2559
|
|
|
2555
2560
|
declare const resolveDestChain: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner>, originChain: TSubstrateChain | TCustomChain, paraId: number | undefined) => "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" | undefined;
|
|
2556
2561
|
|
|
2557
|
-
declare const resolveParaId: (paraId: number | undefined, destination: TDestination) => number | undefined;
|
|
2562
|
+
declare const resolveParaId: <TApi, TRes, TSigner>(paraId: number | undefined, destination: TDestination, api: PolkadotApi<TApi, TRes, TSigner>) => number | undefined;
|
|
2558
2563
|
|
|
2559
2564
|
declare const convertBuilderConfig: <TApi>(config: TBuilderOptions<TApiOrUrl<TApi>> | undefined) => TBuilderConfig<TUrl> | undefined;
|
|
2560
2565
|
declare const createSwapBuilder: <TApi, TRes, TSigner>(options: TTransferOptionsWithSwap<TApi, TRes, TSigner>) => TSwapBuilder<TApi, TRes, TSigner>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
2
|
-
import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, extractAssetLocation, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, getExistentialDepositOrThrow, hasDryRunSupport, normalizeSymbol, Native, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
2
|
+
import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, extractAssetLocation, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, getExistentialDepositOrThrowImpl, getExistentialDepositOrThrow, hasDryRunSupport, normalizeSymbol, Native, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, pad, toHex, getAddress, concat, keccak256, isHex, createPublicClient, http, getContract, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
|
|
6
|
-
import { isTLocation, replaceBigInt, isExternalChain, Version, isRelayChain, Parents, isSubstrateBridge, isSnowbridge, isCustomChain, getJunctionValue, deepEqual, hasJunction, RELAYCHAINS, PARACHAINS, isTrustedChain, isBridge, DEFAULT_SS58_PREFIX, CHAINS } from '@paraspell/sdk-common';
|
|
6
|
+
import { isTLocation, replaceBigInt, isExternalChain, Version, isRelayChain, Parents, isSubstrateBridge, isSnowbridge, isCustomChain, getJunctionValue, deepEqual, hasJunction, RELAYCHAINS, PARACHAINS, isTrustedChain, ETHEREUM_BRIDGE_ORIGINS, isBridge, DEFAULT_SS58_PREFIX, CHAINS } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
8
|
import { getXcmPallet, getSupportedPallets, hasPalletImpl, getOtherAssetsPallets, getNativeAssetsPallet, getXcmPalletImpl, getSupportedPalletsDetails, ASSETS_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
@@ -1420,6 +1420,20 @@ var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1420
1420
|
}]);
|
|
1421
1421
|
}(BaseAssetsPallet);
|
|
1422
1422
|
|
|
1423
|
+
var LOCATION_ID_CHAINS = ['EnergyWebX'];
|
|
1424
|
+
var BIGINT_ID_CHAINS = ['Astar', 'Shiden', 'Moonbeam', 'NeuroWeb', 'Darwinia'];
|
|
1425
|
+
var resolveAssetId = function resolveAssetId(asset, chain) {
|
|
1426
|
+
if (LOCATION_ID_CHAINS.some(function (prefix) {
|
|
1427
|
+
return chain.startsWith(prefix);
|
|
1428
|
+
})) {
|
|
1429
|
+
return asset.location;
|
|
1430
|
+
}
|
|
1431
|
+
assertHasId(asset);
|
|
1432
|
+
var useBigInt = BIGINT_ID_CHAINS.some(function (prefix) {
|
|
1433
|
+
return chain.startsWith(prefix);
|
|
1434
|
+
});
|
|
1435
|
+
return useBigInt ? BigInt(asset.assetId) : Number(asset.assetId);
|
|
1436
|
+
};
|
|
1423
1437
|
var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
1424
1438
|
function AssetsPallet() {
|
|
1425
1439
|
_classCallCheck(this, AssetsPallet);
|
|
@@ -1429,15 +1443,9 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1429
1443
|
return _createClass(AssetsPallet, [{
|
|
1430
1444
|
key: "mint",
|
|
1431
1445
|
value: function mint(api, address, asset, _balance, chain) {
|
|
1432
|
-
|
|
1433
|
-
var
|
|
1434
|
-
amount = asset.amount;
|
|
1435
|
-
var bigintIdChains = ['Astar', 'Shiden', 'Moonbeam', 'NeuroWeb', 'Darwinia'];
|
|
1446
|
+
var amount = asset.amount;
|
|
1447
|
+
var id = resolveAssetId(asset, chain);
|
|
1436
1448
|
var notUseAddressIdChains = ['NeuroWeb', 'Darwinia'];
|
|
1437
|
-
var useBigInt = bigintIdChains.some(function (prefix) {
|
|
1438
|
-
return chain.startsWith(prefix);
|
|
1439
|
-
});
|
|
1440
|
-
var id = useBigInt ? BigInt(assetId) : Number(assetId);
|
|
1441
1449
|
var notUseId = notUseAddressIdChains.some(function (prefix) {
|
|
1442
1450
|
return chain.startsWith(prefix);
|
|
1443
1451
|
}) || api.isChainEvm(chain);
|
|
@@ -3629,11 +3637,11 @@ var reverseTransformLocation = function reverseTransformLocation(location) {
|
|
|
3629
3637
|
});
|
|
3630
3638
|
};
|
|
3631
3639
|
|
|
3632
|
-
var resolveParaId = function resolveParaId(paraId, destination) {
|
|
3640
|
+
var resolveParaId = function resolveParaId(paraId, destination, api) {
|
|
3633
3641
|
if (isTLocation(destination)) {
|
|
3634
3642
|
return undefined;
|
|
3635
3643
|
}
|
|
3636
|
-
return paraId !== undefined ? paraId :
|
|
3644
|
+
return paraId !== undefined ? paraId : getParaIdImpl(destination, api._customCtx);
|
|
3637
3645
|
};
|
|
3638
3646
|
|
|
3639
3647
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
@@ -3681,7 +3689,7 @@ var Chain = /*#__PURE__*/function () {
|
|
|
3681
3689
|
case 0:
|
|
3682
3690
|
api = transferOptions.api, asset = transferOptions.assetInfo, currency = transferOptions.currency, feeAsset = transferOptions.feeAsset, feeCurrency = transferOptions.feeCurrency, recipient = transferOptions.recipient, destination = transferOptions.to, paraIdTo = transferOptions.paraIdTo, overriddenAsset = transferOptions.overriddenAsset, version = transferOptions.version, sender = transferOptions.sender, ahAddress = transferOptions.ahAddress, pallet = transferOptions.pallet, method = transferOptions.method, keepAlive = transferOptions.keepAlive, transactOptions = transferOptions.transactOptions;
|
|
3683
3691
|
scenario = resolveScenario(this.chain, destination);
|
|
3684
|
-
paraId = resolveParaId(paraIdTo, destination);
|
|
3692
|
+
paraId = resolveParaId(paraIdTo, destination, api);
|
|
3685
3693
|
destChain = resolveDestChain(api, this.chain, paraId);
|
|
3686
3694
|
isLocalTransfer = this.chain === destination;
|
|
3687
3695
|
if (!isLocalTransfer) {
|
|
@@ -3910,7 +3918,7 @@ var Chain = /*#__PURE__*/function () {
|
|
|
3910
3918
|
var isSomeChainNativeAsset = nativeSymbols.some(function (symbol) {
|
|
3911
3919
|
return isSymbolMatch(asset.symbol, symbol);
|
|
3912
3920
|
});
|
|
3913
|
-
var isNativeAsset = !isTLocation(to) && (isAHPOrigin && !asset.isNative && isSymbolMatch(asset.symbol,
|
|
3921
|
+
var isNativeAsset = !isTLocation(to) && (isAHPOrigin && !asset.isNative && isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(to, api._customCtx)) || isAHPDest && isSomeChainNativeAsset);
|
|
3914
3922
|
var assetHubChain = "AssetHub".concat(this.ecosystem);
|
|
3915
3923
|
var isRegisteredOnAh = api.findAssetInfo(assetHubChain, {
|
|
3916
3924
|
location: asset.location
|
|
@@ -4369,14 +4377,12 @@ var validateDestination = function validateDestination(origin, destination, api)
|
|
|
4369
4377
|
if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
4370
4378
|
throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
4371
4379
|
}
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
4380
|
+
if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
|
|
4381
|
+
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
|
|
4375
4382
|
}
|
|
4376
4383
|
var isLocationDestination = _typeof(destination) === 'object';
|
|
4377
4384
|
var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
|
|
4378
|
-
|
|
4379
|
-
if (!isRelayDestination && !isLocationDestination) {
|
|
4385
|
+
if (!isLocationDestination) {
|
|
4380
4386
|
var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
|
|
4381
4387
|
var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
|
|
4382
4388
|
if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
@@ -4486,7 +4492,7 @@ var createTransfer = /*#__PURE__*/function () {
|
|
|
4486
4492
|
api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, recipient = options.recipient, destination = options.to, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
4487
4493
|
validateCurrency(currency, feeAsset);
|
|
4488
4494
|
_context.n = 1;
|
|
4489
|
-
return api.init(origin, TX_CLIENT_TIMEOUT_MS);
|
|
4495
|
+
return api.init(origin, TX_CLIENT_TIMEOUT_MS, destination);
|
|
4490
4496
|
case 1:
|
|
4491
4497
|
_resolveTransferParam = resolveTransferParams(options), resolvedFeeAsset = _resolveTransferParam.resolvedFeeAsset, resolvedVersion = _resolveTransferParam.resolvedVersion, overriddenAsset = _resolveTransferParam.overriddenAsset, normalizedAsset = _resolveTransferParam.normalizedAsset;
|
|
4492
4498
|
customCtx = api === null || api === void 0 ? void 0 : api._customCtx;
|
|
@@ -6488,7 +6494,7 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6488
6494
|
}
|
|
6489
6495
|
return _context.a(2, undefined);
|
|
6490
6496
|
case 1:
|
|
6491
|
-
edNative =
|
|
6497
|
+
edNative = getExistentialDepositOrThrowImpl(origin, undefined, api._customCtx);
|
|
6492
6498
|
_context.n = 2;
|
|
6493
6499
|
return getBalanceInternal({
|
|
6494
6500
|
api: api,
|
|
@@ -6497,8 +6503,8 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6497
6503
|
});
|
|
6498
6504
|
case 2:
|
|
6499
6505
|
balanceNative = _context.v;
|
|
6500
|
-
isNativeAssetToOrigin = isSymbolMatch(asset.symbol,
|
|
6501
|
-
isNativeAssetToDest = isSymbolMatch(asset.symbol,
|
|
6506
|
+
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(origin, api._customCtx));
|
|
6507
|
+
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(destination, api._customCtx));
|
|
6502
6508
|
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
6503
6509
|
_context.n = 3;
|
|
6504
6510
|
break;
|
|
@@ -6539,14 +6545,14 @@ var isSufficientDestination = /*#__PURE__*/function () {
|
|
|
6539
6545
|
return _regenerator().w(function (_context2) {
|
|
6540
6546
|
while (1) switch (_context2.n) {
|
|
6541
6547
|
case 0:
|
|
6542
|
-
isNativeAsset = isSymbolMatch(asset.symbol,
|
|
6548
|
+
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(destination, api._customCtx));
|
|
6543
6549
|
if (isNativeAsset) {
|
|
6544
6550
|
_context2.n = 1;
|
|
6545
6551
|
break;
|
|
6546
6552
|
}
|
|
6547
6553
|
return _context2.a(2, undefined);
|
|
6548
6554
|
case 1:
|
|
6549
|
-
existentialDeposit =
|
|
6555
|
+
existentialDeposit = getExistentialDepositOrThrowImpl(destination, undefined, api._customCtx);
|
|
6550
6556
|
_context2.n = 2;
|
|
6551
6557
|
return getBalanceInternal({
|
|
6552
6558
|
api: api,
|
|
@@ -9622,7 +9628,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
9622
9628
|
overriddenAsset = _context$options.overriddenAsset;
|
|
9623
9629
|
var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
|
|
9624
9630
|
var finalDest = bridgeHopChain !== null && bridgeHopChain !== void 0 ? bridgeHopChain : origin.chain === reserve.chain ? dest.chain : reserve.chain;
|
|
9625
|
-
var destLocation = createDestination(origin.api, version, origin.chain, finalDest,
|
|
9631
|
+
var destLocation = createDestination(origin.api, version, origin.chain, finalDest, getParaIdImpl(finalDest, origin.api._customCtx));
|
|
9626
9632
|
var transferType = bridgeHopChain ? 'DestinationReserve' : resolveTransferType(context);
|
|
9627
9633
|
var feeAsset = Array.isArray(overriddenAsset) ? overriddenAsset.find(function (a) {
|
|
9628
9634
|
return a.isFeeAsset;
|
|
@@ -12587,7 +12593,7 @@ var EnergyWebX = /*#__PURE__*/function (_Chain) {
|
|
|
12587
12593
|
var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'EnergyWebX';
|
|
12588
12594
|
var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ewx';
|
|
12589
12595
|
var ecosystem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Polkadot';
|
|
12590
|
-
var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.
|
|
12596
|
+
var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.V5;
|
|
12591
12597
|
_classCallCheck(this, EnergyWebX);
|
|
12592
12598
|
return _callSuper(this, EnergyWebX, [chain, info, ecosystem, version]);
|
|
12593
12599
|
}
|
|
@@ -12641,7 +12647,7 @@ var EnergyWebX = /*#__PURE__*/function (_Chain) {
|
|
|
12641
12647
|
var EnergyWebXPaseo = /*#__PURE__*/function (_EnergyWebX) {
|
|
12642
12648
|
function EnergyWebXPaseo() {
|
|
12643
12649
|
_classCallCheck(this, EnergyWebXPaseo);
|
|
12644
|
-
return _callSuper(this, EnergyWebXPaseo, ['EnergyWebXPaseo', 'paseoEwx', 'Paseo', Version.
|
|
12650
|
+
return _callSuper(this, EnergyWebXPaseo, ['EnergyWebXPaseo', 'paseoEwx', 'Paseo', Version.V5]);
|
|
12645
12651
|
}
|
|
12646
12652
|
_inherits(EnergyWebXPaseo, _EnergyWebX);
|
|
12647
12653
|
return _createClass(EnergyWebXPaseo);
|
|
@@ -14296,17 +14302,29 @@ var buildAutoNativeAsset = function buildAutoNativeAsset(entry) {
|
|
|
14296
14302
|
var _requireNativeAssetFi = requireNativeAssetFields(entry),
|
|
14297
14303
|
symbol = _requireNativeAssetFi.symbol,
|
|
14298
14304
|
decimals = _requireNativeAssetFi.decimals;
|
|
14299
|
-
return {
|
|
14305
|
+
return _objectSpread2({
|
|
14300
14306
|
symbol: symbol,
|
|
14301
14307
|
decimals: decimals,
|
|
14302
14308
|
location: buildNativeLocation(entry.paraId),
|
|
14303
14309
|
isNative: true
|
|
14304
|
-
}
|
|
14310
|
+
}, entry.nativeExistentialDeposit !== undefined && {
|
|
14311
|
+
existentialDeposit: entry.nativeExistentialDeposit
|
|
14312
|
+
});
|
|
14305
14313
|
};
|
|
14306
14314
|
var resolveAssets = function resolveAssets(entry) {
|
|
14307
|
-
|
|
14315
|
+
var declaredNativeAsset = entry.assets.find(function (asset) {
|
|
14308
14316
|
return asset.isNative;
|
|
14309
|
-
})
|
|
14317
|
+
});
|
|
14318
|
+
if (declaredNativeAsset) {
|
|
14319
|
+
if (declaredNativeAsset.existentialDeposit === undefined && entry.nativeExistentialDeposit) {
|
|
14320
|
+
return entry.assets.map(function (asset) {
|
|
14321
|
+
return asset === declaredNativeAsset ? _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
14322
|
+
existentialDeposit: entry.nativeExistentialDeposit
|
|
14323
|
+
}) : asset;
|
|
14324
|
+
});
|
|
14325
|
+
}
|
|
14326
|
+
return entry.assets;
|
|
14327
|
+
}
|
|
14310
14328
|
return [buildAutoNativeAsset(entry)].concat(_toConsumableArray(entry.assets));
|
|
14311
14329
|
};
|
|
14312
14330
|
var buildCustomChainAssetsInfo = function buildCustomChainAssetsInfo(entry) {
|
|
@@ -14487,11 +14505,13 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14487
14505
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain) {
|
|
14488
14506
|
var _this = this;
|
|
14489
14507
|
var clientTtlMs,
|
|
14508
|
+
destination,
|
|
14490
14509
|
_args = arguments;
|
|
14491
14510
|
return _regenerator().w(function (_context) {
|
|
14492
14511
|
while (1) switch (_context.n) {
|
|
14493
14512
|
case 0:
|
|
14494
14513
|
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
14514
|
+
destination = _args.length > 2 ? _args[2] : undefined;
|
|
14495
14515
|
if (!(this._chain !== undefined || isExternalChain(chain))) {
|
|
14496
14516
|
_context.n = 1;
|
|
14497
14517
|
break;
|
|
@@ -14509,6 +14529,13 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14509
14529
|
_context.n = 3;
|
|
14510
14530
|
return this.maybeHydrateCustomChain(chain);
|
|
14511
14531
|
case 3:
|
|
14532
|
+
if (!(typeof destination === 'string' && isCustomChain(destination))) {
|
|
14533
|
+
_context.n = 4;
|
|
14534
|
+
break;
|
|
14535
|
+
}
|
|
14536
|
+
_context.n = 4;
|
|
14537
|
+
return this.hydrateCustomChain(destination);
|
|
14538
|
+
case 4:
|
|
14512
14539
|
return _context.a(2);
|
|
14513
14540
|
}
|
|
14514
14541
|
}, _callee, this);
|
|
@@ -14519,30 +14546,87 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14519
14546
|
return init;
|
|
14520
14547
|
}()
|
|
14521
14548
|
}, {
|
|
14522
|
-
key: "
|
|
14549
|
+
key: "setCustomCtx",
|
|
14550
|
+
value: function setCustomCtx(ctx) {
|
|
14551
|
+
this._customCtx = ctx;
|
|
14552
|
+
}
|
|
14553
|
+
}, {
|
|
14554
|
+
key: "hydrateCustomChain",
|
|
14523
14555
|
value: function () {
|
|
14524
|
-
var
|
|
14525
|
-
var _this$_customCtx$cust;
|
|
14526
|
-
var
|
|
14556
|
+
var _hydrateCustomChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain) {
|
|
14557
|
+
var _this$_customCtx$cust, _this$_customCtx$cust2;
|
|
14558
|
+
var childApi;
|
|
14527
14559
|
return _regenerator().w(function (_context2) {
|
|
14528
14560
|
while (1) switch (_context2.n) {
|
|
14529
14561
|
case 0:
|
|
14530
|
-
|
|
14531
|
-
if (entry) {
|
|
14562
|
+
if (!(!((_this$_customCtx$cust = this._customCtx.customChains) !== null && _this$_customCtx$cust !== void 0 && _this$_customCtx$cust[chain]) || (_this$_customCtx$cust2 = this._customCtx.customChainAssets) !== null && _this$_customCtx$cust2 !== void 0 && _this$_customCtx$cust2[chain])) {
|
|
14532
14563
|
_context2.n = 1;
|
|
14533
14564
|
break;
|
|
14534
14565
|
}
|
|
14535
14566
|
return _context2.a(2);
|
|
14567
|
+
case 1:
|
|
14568
|
+
childApi = this.clone();
|
|
14569
|
+
childApi.setCustomCtx(this._customCtx);
|
|
14570
|
+
_context2.n = 2;
|
|
14571
|
+
return childApi.init(chain, this._ttlMs);
|
|
14572
|
+
case 2:
|
|
14573
|
+
this.setCustomCtx(childApi._customCtx);
|
|
14574
|
+
case 3:
|
|
14575
|
+
return _context2.a(2);
|
|
14576
|
+
}
|
|
14577
|
+
}, _callee2, this);
|
|
14578
|
+
}));
|
|
14579
|
+
function hydrateCustomChain(_x2) {
|
|
14580
|
+
return _hydrateCustomChain.apply(this, arguments);
|
|
14581
|
+
}
|
|
14582
|
+
return hydrateCustomChain;
|
|
14583
|
+
}()
|
|
14584
|
+
}, {
|
|
14585
|
+
key: "getNativeExistentialDeposit",
|
|
14586
|
+
value: function () {
|
|
14587
|
+
var _getNativeExistentialDeposit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
14588
|
+
var ed;
|
|
14589
|
+
return _regenerator().w(function (_context3) {
|
|
14590
|
+
while (1) switch (_context3.n) {
|
|
14591
|
+
case 0:
|
|
14592
|
+
_context3.n = 1;
|
|
14593
|
+
return this.getConstant('Balances', 'ExistentialDeposit');
|
|
14594
|
+
case 1:
|
|
14595
|
+
ed = _context3.v;
|
|
14596
|
+
return _context3.a(2, ed !== undefined ? BigInt(ed) : undefined);
|
|
14597
|
+
}
|
|
14598
|
+
}, _callee3, this);
|
|
14599
|
+
}));
|
|
14600
|
+
function getNativeExistentialDeposit() {
|
|
14601
|
+
return _getNativeExistentialDeposit.apply(this, arguments);
|
|
14602
|
+
}
|
|
14603
|
+
return getNativeExistentialDeposit;
|
|
14604
|
+
}()
|
|
14605
|
+
}, {
|
|
14606
|
+
key: "maybeHydrateCustomChain",
|
|
14607
|
+
value: function () {
|
|
14608
|
+
var _maybeHydrateCustomChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(chain) {
|
|
14609
|
+
var _this$_customCtx$cust3;
|
|
14610
|
+
var entry, needsProps, props, declaredNativeAsset, _yield$Promise$all, _yield$Promise$all2, supportsDryRunApi, supportsXcmPaymentApi, isEVM, hasPolkadotXcm, hasXcmPallet, palletList, nativeExistentialDeposit, xcmPallet, pallets, hydrated;
|
|
14611
|
+
return _regenerator().w(function (_context4) {
|
|
14612
|
+
while (1) switch (_context4.n) {
|
|
14613
|
+
case 0:
|
|
14614
|
+
entry = (_this$_customCtx$cust3 = this._customCtx.customChains) === null || _this$_customCtx$cust3 === void 0 ? void 0 : _this$_customCtx$cust3[chain];
|
|
14615
|
+
if (entry) {
|
|
14616
|
+
_context4.n = 1;
|
|
14617
|
+
break;
|
|
14618
|
+
}
|
|
14619
|
+
return _context4.a(2);
|
|
14536
14620
|
case 1:
|
|
14537
14621
|
needsProps = entry.ss58Prefix === undefined || entry.nativeAssetSymbol === undefined || entry.nativeAssetDecimals === undefined;
|
|
14538
14622
|
if (!needsProps) {
|
|
14539
|
-
|
|
14623
|
+
_context4.n = 3;
|
|
14540
14624
|
break;
|
|
14541
14625
|
}
|
|
14542
|
-
|
|
14626
|
+
_context4.n = 2;
|
|
14543
14627
|
return this.getSystemProperties();
|
|
14544
14628
|
case 2:
|
|
14545
|
-
props =
|
|
14629
|
+
props = _context4.v;
|
|
14546
14630
|
if (entry.ss58Prefix === undefined && typeof props.ss58Format === 'number') {
|
|
14547
14631
|
entry.ss58Prefix = props.ss58Format;
|
|
14548
14632
|
}
|
|
@@ -14552,20 +14636,29 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14552
14636
|
if (entry.nativeAssetDecimals === undefined && typeof props.tokenDecimals === 'number') {
|
|
14553
14637
|
entry.nativeAssetDecimals = props.tokenDecimals;
|
|
14554
14638
|
}
|
|
14639
|
+
declaredNativeAsset = entry.assets.find(function (asset) {
|
|
14640
|
+
return asset.isNative;
|
|
14641
|
+
});
|
|
14642
|
+
if (!(declaredNativeAsset && props.tokenSymbol && !isSymbolMatch(declaredNativeAsset.symbol, props.tokenSymbol))) {
|
|
14643
|
+
_context4.n = 3;
|
|
14644
|
+
break;
|
|
14645
|
+
}
|
|
14646
|
+
throw new CustomChainInvalidError("Custom chain '".concat(entry.name, "' declares '").concat(declaredNativeAsset.symbol, "' as its native asset, ") + "but the chain's native asset is '".concat(props.tokenSymbol, "'."));
|
|
14555
14647
|
case 3:
|
|
14556
|
-
|
|
14557
|
-
return Promise.all([this.hasRuntimeApi('DryRunApi'), this.hasRuntimeApi('XcmPaymentApi'), this.isEvmChain(), this.hasMethod('PolkadotXcm', 'send'), this.hasMethod('XcmPallet', 'send'), this.fetchPalletList()]);
|
|
14648
|
+
_context4.n = 4;
|
|
14649
|
+
return Promise.all([this.hasRuntimeApi('DryRunApi'), this.hasRuntimeApi('XcmPaymentApi'), this.isEvmChain(), this.hasMethod('PolkadotXcm', 'send'), this.hasMethod('XcmPallet', 'send'), this.fetchPalletList(), this.getNativeExistentialDeposit()]);
|
|
14558
14650
|
case 4:
|
|
14559
|
-
_yield$Promise$all =
|
|
14560
|
-
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all,
|
|
14651
|
+
_yield$Promise$all = _context4.v;
|
|
14652
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 7);
|
|
14561
14653
|
supportsDryRunApi = _yield$Promise$all2[0];
|
|
14562
14654
|
supportsXcmPaymentApi = _yield$Promise$all2[1];
|
|
14563
14655
|
isEVM = _yield$Promise$all2[2];
|
|
14564
14656
|
hasPolkadotXcm = _yield$Promise$all2[3];
|
|
14565
14657
|
hasXcmPallet = _yield$Promise$all2[4];
|
|
14566
14658
|
palletList = _yield$Promise$all2[5];
|
|
14659
|
+
nativeExistentialDeposit = _yield$Promise$all2[6];
|
|
14567
14660
|
if (!(!hasPolkadotXcm && !hasXcmPallet)) {
|
|
14568
|
-
|
|
14661
|
+
_context4.n = 5;
|
|
14569
14662
|
break;
|
|
14570
14663
|
}
|
|
14571
14664
|
throw new UnsupportedOperationError("Custom chain '".concat(entry.name, "' does not expose a 'PolkadotXcm' or 'XcmPallet' pallet."));
|
|
@@ -14577,6 +14670,7 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14577
14670
|
isEVM: isEVM,
|
|
14578
14671
|
supportsDryRunApi: supportsDryRunApi,
|
|
14579
14672
|
supportsXcmPaymentApi: supportsXcmPaymentApi,
|
|
14673
|
+
nativeExistentialDeposit: nativeExistentialDeposit !== undefined ? nativeExistentialDeposit.toString() : undefined,
|
|
14580
14674
|
pallets: pallets
|
|
14581
14675
|
});
|
|
14582
14676
|
if (this._customCtx.customChainAssets) {
|
|
@@ -14586,11 +14680,11 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14586
14680
|
this._customCtx.customChainPallets[chain] = pallets;
|
|
14587
14681
|
}
|
|
14588
14682
|
case 6:
|
|
14589
|
-
return
|
|
14683
|
+
return _context4.a(2);
|
|
14590
14684
|
}
|
|
14591
|
-
},
|
|
14685
|
+
}, _callee4, this);
|
|
14592
14686
|
}));
|
|
14593
|
-
function maybeHydrateCustomChain(
|
|
14687
|
+
function maybeHydrateCustomChain(_x3) {
|
|
14594
14688
|
return _maybeHydrateCustomChain.apply(this, arguments);
|
|
14595
14689
|
}
|
|
14596
14690
|
return maybeHydrateCustomChain;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.7.1",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@noble/hashes": "^2.2.0",
|
|
26
26
|
"@scure/base": "^2.2.0",
|
|
27
27
|
"viem": "^2.51.3",
|
|
28
|
-
"@paraspell/
|
|
29
|
-
"@paraspell/sdk-common": "13.
|
|
30
|
-
"@paraspell/
|
|
28
|
+
"@paraspell/assets": "13.7.1",
|
|
29
|
+
"@paraspell/sdk-common": "13.7.1",
|
|
30
|
+
"@paraspell/pallets": "13.7.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|