@paraspell/sdk-core 13.6.0 → 13.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.d.ts +8 -3
- package/dist/index.mjs +142 -47
- 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,9 +4377,8 @@ 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);
|
|
@@ -4486,7 +4493,7 @@ var createTransfer = /*#__PURE__*/function () {
|
|
|
4486
4493
|
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
4494
|
validateCurrency(currency, feeAsset);
|
|
4488
4495
|
_context.n = 1;
|
|
4489
|
-
return api.init(origin, TX_CLIENT_TIMEOUT_MS);
|
|
4496
|
+
return api.init(origin, TX_CLIENT_TIMEOUT_MS, destination);
|
|
4490
4497
|
case 1:
|
|
4491
4498
|
_resolveTransferParam = resolveTransferParams(options), resolvedFeeAsset = _resolveTransferParam.resolvedFeeAsset, resolvedVersion = _resolveTransferParam.resolvedVersion, overriddenAsset = _resolveTransferParam.overriddenAsset, normalizedAsset = _resolveTransferParam.normalizedAsset;
|
|
4492
4499
|
customCtx = api === null || api === void 0 ? void 0 : api._customCtx;
|
|
@@ -6488,7 +6495,7 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6488
6495
|
}
|
|
6489
6496
|
return _context.a(2, undefined);
|
|
6490
6497
|
case 1:
|
|
6491
|
-
edNative =
|
|
6498
|
+
edNative = getExistentialDepositOrThrowImpl(origin, undefined, api._customCtx);
|
|
6492
6499
|
_context.n = 2;
|
|
6493
6500
|
return getBalanceInternal({
|
|
6494
6501
|
api: api,
|
|
@@ -6497,8 +6504,8 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6497
6504
|
});
|
|
6498
6505
|
case 2:
|
|
6499
6506
|
balanceNative = _context.v;
|
|
6500
|
-
isNativeAssetToOrigin = isSymbolMatch(asset.symbol,
|
|
6501
|
-
isNativeAssetToDest = isSymbolMatch(asset.symbol,
|
|
6507
|
+
isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(origin, api._customCtx));
|
|
6508
|
+
isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(destination, api._customCtx));
|
|
6502
6509
|
if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
|
|
6503
6510
|
_context.n = 3;
|
|
6504
6511
|
break;
|
|
@@ -6539,14 +6546,14 @@ var isSufficientDestination = /*#__PURE__*/function () {
|
|
|
6539
6546
|
return _regenerator().w(function (_context2) {
|
|
6540
6547
|
while (1) switch (_context2.n) {
|
|
6541
6548
|
case 0:
|
|
6542
|
-
isNativeAsset = isSymbolMatch(asset.symbol,
|
|
6549
|
+
isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(destination, api._customCtx));
|
|
6543
6550
|
if (isNativeAsset) {
|
|
6544
6551
|
_context2.n = 1;
|
|
6545
6552
|
break;
|
|
6546
6553
|
}
|
|
6547
6554
|
return _context2.a(2, undefined);
|
|
6548
6555
|
case 1:
|
|
6549
|
-
existentialDeposit =
|
|
6556
|
+
existentialDeposit = getExistentialDepositOrThrowImpl(destination, undefined, api._customCtx);
|
|
6550
6557
|
_context2.n = 2;
|
|
6551
6558
|
return getBalanceInternal({
|
|
6552
6559
|
api: api,
|
|
@@ -9622,7 +9629,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
9622
9629
|
overriddenAsset = _context$options.overriddenAsset;
|
|
9623
9630
|
var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
|
|
9624
9631
|
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,
|
|
9632
|
+
var destLocation = createDestination(origin.api, version, origin.chain, finalDest, getParaIdImpl(finalDest, origin.api._customCtx));
|
|
9626
9633
|
var transferType = bridgeHopChain ? 'DestinationReserve' : resolveTransferType(context);
|
|
9627
9634
|
var feeAsset = Array.isArray(overriddenAsset) ? overriddenAsset.find(function (a) {
|
|
9628
9635
|
return a.isFeeAsset;
|
|
@@ -12587,7 +12594,7 @@ var EnergyWebX = /*#__PURE__*/function (_Chain) {
|
|
|
12587
12594
|
var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'EnergyWebX';
|
|
12588
12595
|
var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ewx';
|
|
12589
12596
|
var ecosystem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Polkadot';
|
|
12590
|
-
var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.
|
|
12597
|
+
var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Version.V5;
|
|
12591
12598
|
_classCallCheck(this, EnergyWebX);
|
|
12592
12599
|
return _callSuper(this, EnergyWebX, [chain, info, ecosystem, version]);
|
|
12593
12600
|
}
|
|
@@ -12641,7 +12648,7 @@ var EnergyWebX = /*#__PURE__*/function (_Chain) {
|
|
|
12641
12648
|
var EnergyWebXPaseo = /*#__PURE__*/function (_EnergyWebX) {
|
|
12642
12649
|
function EnergyWebXPaseo() {
|
|
12643
12650
|
_classCallCheck(this, EnergyWebXPaseo);
|
|
12644
|
-
return _callSuper(this, EnergyWebXPaseo, ['EnergyWebXPaseo', 'paseoEwx', 'Paseo', Version.
|
|
12651
|
+
return _callSuper(this, EnergyWebXPaseo, ['EnergyWebXPaseo', 'paseoEwx', 'Paseo', Version.V5]);
|
|
12645
12652
|
}
|
|
12646
12653
|
_inherits(EnergyWebXPaseo, _EnergyWebX);
|
|
12647
12654
|
return _createClass(EnergyWebXPaseo);
|
|
@@ -14296,17 +14303,29 @@ var buildAutoNativeAsset = function buildAutoNativeAsset(entry) {
|
|
|
14296
14303
|
var _requireNativeAssetFi = requireNativeAssetFields(entry),
|
|
14297
14304
|
symbol = _requireNativeAssetFi.symbol,
|
|
14298
14305
|
decimals = _requireNativeAssetFi.decimals;
|
|
14299
|
-
return {
|
|
14306
|
+
return _objectSpread2({
|
|
14300
14307
|
symbol: symbol,
|
|
14301
14308
|
decimals: decimals,
|
|
14302
14309
|
location: buildNativeLocation(entry.paraId),
|
|
14303
14310
|
isNative: true
|
|
14304
|
-
}
|
|
14311
|
+
}, entry.nativeExistentialDeposit !== undefined && {
|
|
14312
|
+
existentialDeposit: entry.nativeExistentialDeposit
|
|
14313
|
+
});
|
|
14305
14314
|
};
|
|
14306
14315
|
var resolveAssets = function resolveAssets(entry) {
|
|
14307
|
-
|
|
14316
|
+
var declaredNativeAsset = entry.assets.find(function (asset) {
|
|
14308
14317
|
return asset.isNative;
|
|
14309
|
-
})
|
|
14318
|
+
});
|
|
14319
|
+
if (declaredNativeAsset) {
|
|
14320
|
+
if (declaredNativeAsset.existentialDeposit === undefined && entry.nativeExistentialDeposit) {
|
|
14321
|
+
return entry.assets.map(function (asset) {
|
|
14322
|
+
return asset === declaredNativeAsset ? _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
14323
|
+
existentialDeposit: entry.nativeExistentialDeposit
|
|
14324
|
+
}) : asset;
|
|
14325
|
+
});
|
|
14326
|
+
}
|
|
14327
|
+
return entry.assets;
|
|
14328
|
+
}
|
|
14310
14329
|
return [buildAutoNativeAsset(entry)].concat(_toConsumableArray(entry.assets));
|
|
14311
14330
|
};
|
|
14312
14331
|
var buildCustomChainAssetsInfo = function buildCustomChainAssetsInfo(entry) {
|
|
@@ -14487,11 +14506,13 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14487
14506
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain) {
|
|
14488
14507
|
var _this = this;
|
|
14489
14508
|
var clientTtlMs,
|
|
14509
|
+
destination,
|
|
14490
14510
|
_args = arguments;
|
|
14491
14511
|
return _regenerator().w(function (_context) {
|
|
14492
14512
|
while (1) switch (_context.n) {
|
|
14493
14513
|
case 0:
|
|
14494
14514
|
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
14515
|
+
destination = _args.length > 2 ? _args[2] : undefined;
|
|
14495
14516
|
if (!(this._chain !== undefined || isExternalChain(chain))) {
|
|
14496
14517
|
_context.n = 1;
|
|
14497
14518
|
break;
|
|
@@ -14509,6 +14530,13 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14509
14530
|
_context.n = 3;
|
|
14510
14531
|
return this.maybeHydrateCustomChain(chain);
|
|
14511
14532
|
case 3:
|
|
14533
|
+
if (!(typeof destination === 'string' && isCustomChain(destination))) {
|
|
14534
|
+
_context.n = 4;
|
|
14535
|
+
break;
|
|
14536
|
+
}
|
|
14537
|
+
_context.n = 4;
|
|
14538
|
+
return this.hydrateCustomChain(destination);
|
|
14539
|
+
case 4:
|
|
14512
14540
|
return _context.a(2);
|
|
14513
14541
|
}
|
|
14514
14542
|
}, _callee, this);
|
|
@@ -14519,30 +14547,87 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14519
14547
|
return init;
|
|
14520
14548
|
}()
|
|
14521
14549
|
}, {
|
|
14522
|
-
key: "
|
|
14550
|
+
key: "setCustomCtx",
|
|
14551
|
+
value: function setCustomCtx(ctx) {
|
|
14552
|
+
this._customCtx = ctx;
|
|
14553
|
+
}
|
|
14554
|
+
}, {
|
|
14555
|
+
key: "hydrateCustomChain",
|
|
14523
14556
|
value: function () {
|
|
14524
|
-
var
|
|
14525
|
-
var _this$_customCtx$cust;
|
|
14526
|
-
var
|
|
14557
|
+
var _hydrateCustomChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain) {
|
|
14558
|
+
var _this$_customCtx$cust, _this$_customCtx$cust2;
|
|
14559
|
+
var childApi;
|
|
14527
14560
|
return _regenerator().w(function (_context2) {
|
|
14528
14561
|
while (1) switch (_context2.n) {
|
|
14529
14562
|
case 0:
|
|
14530
|
-
|
|
14531
|
-
if (entry) {
|
|
14563
|
+
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
14564
|
_context2.n = 1;
|
|
14533
14565
|
break;
|
|
14534
14566
|
}
|
|
14535
14567
|
return _context2.a(2);
|
|
14568
|
+
case 1:
|
|
14569
|
+
childApi = this.clone();
|
|
14570
|
+
childApi.setCustomCtx(this._customCtx);
|
|
14571
|
+
_context2.n = 2;
|
|
14572
|
+
return childApi.init(chain, this._ttlMs);
|
|
14573
|
+
case 2:
|
|
14574
|
+
this.setCustomCtx(childApi._customCtx);
|
|
14575
|
+
case 3:
|
|
14576
|
+
return _context2.a(2);
|
|
14577
|
+
}
|
|
14578
|
+
}, _callee2, this);
|
|
14579
|
+
}));
|
|
14580
|
+
function hydrateCustomChain(_x2) {
|
|
14581
|
+
return _hydrateCustomChain.apply(this, arguments);
|
|
14582
|
+
}
|
|
14583
|
+
return hydrateCustomChain;
|
|
14584
|
+
}()
|
|
14585
|
+
}, {
|
|
14586
|
+
key: "getNativeExistentialDeposit",
|
|
14587
|
+
value: function () {
|
|
14588
|
+
var _getNativeExistentialDeposit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
14589
|
+
var ed;
|
|
14590
|
+
return _regenerator().w(function (_context3) {
|
|
14591
|
+
while (1) switch (_context3.n) {
|
|
14592
|
+
case 0:
|
|
14593
|
+
_context3.n = 1;
|
|
14594
|
+
return this.getConstant('Balances', 'ExistentialDeposit');
|
|
14595
|
+
case 1:
|
|
14596
|
+
ed = _context3.v;
|
|
14597
|
+
return _context3.a(2, ed !== undefined ? BigInt(ed) : undefined);
|
|
14598
|
+
}
|
|
14599
|
+
}, _callee3, this);
|
|
14600
|
+
}));
|
|
14601
|
+
function getNativeExistentialDeposit() {
|
|
14602
|
+
return _getNativeExistentialDeposit.apply(this, arguments);
|
|
14603
|
+
}
|
|
14604
|
+
return getNativeExistentialDeposit;
|
|
14605
|
+
}()
|
|
14606
|
+
}, {
|
|
14607
|
+
key: "maybeHydrateCustomChain",
|
|
14608
|
+
value: function () {
|
|
14609
|
+
var _maybeHydrateCustomChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(chain) {
|
|
14610
|
+
var _this$_customCtx$cust3;
|
|
14611
|
+
var entry, needsProps, props, declaredNativeAsset, _yield$Promise$all, _yield$Promise$all2, supportsDryRunApi, supportsXcmPaymentApi, isEVM, hasPolkadotXcm, hasXcmPallet, palletList, nativeExistentialDeposit, xcmPallet, pallets, hydrated;
|
|
14612
|
+
return _regenerator().w(function (_context4) {
|
|
14613
|
+
while (1) switch (_context4.n) {
|
|
14614
|
+
case 0:
|
|
14615
|
+
entry = (_this$_customCtx$cust3 = this._customCtx.customChains) === null || _this$_customCtx$cust3 === void 0 ? void 0 : _this$_customCtx$cust3[chain];
|
|
14616
|
+
if (entry) {
|
|
14617
|
+
_context4.n = 1;
|
|
14618
|
+
break;
|
|
14619
|
+
}
|
|
14620
|
+
return _context4.a(2);
|
|
14536
14621
|
case 1:
|
|
14537
14622
|
needsProps = entry.ss58Prefix === undefined || entry.nativeAssetSymbol === undefined || entry.nativeAssetDecimals === undefined;
|
|
14538
14623
|
if (!needsProps) {
|
|
14539
|
-
|
|
14624
|
+
_context4.n = 3;
|
|
14540
14625
|
break;
|
|
14541
14626
|
}
|
|
14542
|
-
|
|
14627
|
+
_context4.n = 2;
|
|
14543
14628
|
return this.getSystemProperties();
|
|
14544
14629
|
case 2:
|
|
14545
|
-
props =
|
|
14630
|
+
props = _context4.v;
|
|
14546
14631
|
if (entry.ss58Prefix === undefined && typeof props.ss58Format === 'number') {
|
|
14547
14632
|
entry.ss58Prefix = props.ss58Format;
|
|
14548
14633
|
}
|
|
@@ -14552,20 +14637,29 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14552
14637
|
if (entry.nativeAssetDecimals === undefined && typeof props.tokenDecimals === 'number') {
|
|
14553
14638
|
entry.nativeAssetDecimals = props.tokenDecimals;
|
|
14554
14639
|
}
|
|
14640
|
+
declaredNativeAsset = entry.assets.find(function (asset) {
|
|
14641
|
+
return asset.isNative;
|
|
14642
|
+
});
|
|
14643
|
+
if (!(declaredNativeAsset && props.tokenSymbol && !isSymbolMatch(declaredNativeAsset.symbol, props.tokenSymbol))) {
|
|
14644
|
+
_context4.n = 3;
|
|
14645
|
+
break;
|
|
14646
|
+
}
|
|
14647
|
+
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
14648
|
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()]);
|
|
14649
|
+
_context4.n = 4;
|
|
14650
|
+
return Promise.all([this.hasRuntimeApi('DryRunApi'), this.hasRuntimeApi('XcmPaymentApi'), this.isEvmChain(), this.hasMethod('PolkadotXcm', 'send'), this.hasMethod('XcmPallet', 'send'), this.fetchPalletList(), this.getNativeExistentialDeposit()]);
|
|
14558
14651
|
case 4:
|
|
14559
|
-
_yield$Promise$all =
|
|
14560
|
-
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all,
|
|
14652
|
+
_yield$Promise$all = _context4.v;
|
|
14653
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 7);
|
|
14561
14654
|
supportsDryRunApi = _yield$Promise$all2[0];
|
|
14562
14655
|
supportsXcmPaymentApi = _yield$Promise$all2[1];
|
|
14563
14656
|
isEVM = _yield$Promise$all2[2];
|
|
14564
14657
|
hasPolkadotXcm = _yield$Promise$all2[3];
|
|
14565
14658
|
hasXcmPallet = _yield$Promise$all2[4];
|
|
14566
14659
|
palletList = _yield$Promise$all2[5];
|
|
14660
|
+
nativeExistentialDeposit = _yield$Promise$all2[6];
|
|
14567
14661
|
if (!(!hasPolkadotXcm && !hasXcmPallet)) {
|
|
14568
|
-
|
|
14662
|
+
_context4.n = 5;
|
|
14569
14663
|
break;
|
|
14570
14664
|
}
|
|
14571
14665
|
throw new UnsupportedOperationError("Custom chain '".concat(entry.name, "' does not expose a 'PolkadotXcm' or 'XcmPallet' pallet."));
|
|
@@ -14577,6 +14671,7 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14577
14671
|
isEVM: isEVM,
|
|
14578
14672
|
supportsDryRunApi: supportsDryRunApi,
|
|
14579
14673
|
supportsXcmPaymentApi: supportsXcmPaymentApi,
|
|
14674
|
+
nativeExistentialDeposit: nativeExistentialDeposit !== undefined ? nativeExistentialDeposit.toString() : undefined,
|
|
14580
14675
|
pallets: pallets
|
|
14581
14676
|
});
|
|
14582
14677
|
if (this._customCtx.customChainAssets) {
|
|
@@ -14586,11 +14681,11 @@ var PolkadotApi = /*#__PURE__*/function () {
|
|
|
14586
14681
|
this._customCtx.customChainPallets[chain] = pallets;
|
|
14587
14682
|
}
|
|
14588
14683
|
case 6:
|
|
14589
|
-
return
|
|
14684
|
+
return _context4.a(2);
|
|
14590
14685
|
}
|
|
14591
|
-
},
|
|
14686
|
+
}, _callee4, this);
|
|
14592
14687
|
}));
|
|
14593
|
-
function maybeHydrateCustomChain(
|
|
14688
|
+
function maybeHydrateCustomChain(_x3) {
|
|
14594
14689
|
return _maybeHydrateCustomChain.apply(this, arguments);
|
|
14595
14690
|
}
|
|
14596
14691
|
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.0",
|
|
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/
|
|
30
|
-
"@paraspell/
|
|
28
|
+
"@paraspell/assets": "13.7.0",
|
|
29
|
+
"@paraspell/pallets": "13.7.0",
|
|
30
|
+
"@paraspell/sdk-common": "13.7.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|