@paraspell/sdk-core 14.1.1 → 14.2.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 +21 -1
- package/dist/index.mjs +166 -48
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -159,6 +159,7 @@ declare abstract class SubstrateChain<TApi, TRes, TSigner, TCustomChain extends
|
|
|
159
159
|
transferLocal(options: TTransferInternalOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
160
160
|
transferLocalNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
161
161
|
transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
|
|
162
|
+
protected getLocalCurrencyId(_api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): unknown;
|
|
162
163
|
getBalanceNative(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, address: string, asset: TAssetInfo): Promise<bigint>;
|
|
163
164
|
getCustomCurrencyId(_api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, _asset: TAssetInfo): unknown;
|
|
164
165
|
getBalanceForeign(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, address: string, asset: TAssetInfo): Promise<bigint>;
|
|
@@ -355,6 +356,14 @@ declare class CrustShadow<TApi, TRes, TSigner, TCustomChain extends string = nev
|
|
|
355
356
|
transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
|
|
356
357
|
}
|
|
357
358
|
|
|
359
|
+
declare class Curio<TApi, TRes, TSigner, TCustomChain extends string = never> extends SubstrateChain<TApi, TRes, TSigner, TCustomChain> implements IPolkadotXCMTransfer<TApi, TRes, TSigner, TCustomChain> {
|
|
360
|
+
constructor();
|
|
361
|
+
getCustomCurrencyId(_api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): TForeignOrTokenAsset;
|
|
362
|
+
protected getLocalCurrencyId(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): TForeignOrTokenAsset;
|
|
363
|
+
protected getMintConfig(): TMintConfig;
|
|
364
|
+
transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
365
|
+
}
|
|
366
|
+
|
|
358
367
|
declare class Darwinia<TApi, TRes, TSigner, TCustomChain extends string = never> extends SubstrateChain<TApi, TRes, TSigner, TCustomChain> implements IPolkadotXCMTransfer<TApi, TRes, TSigner, TCustomChain> {
|
|
359
368
|
constructor();
|
|
360
369
|
protected getMintConfig(): TMintConfig;
|
|
@@ -411,6 +420,14 @@ declare class Jamton<TApi, TRes, TSigner, TCustomChain extends string = never> e
|
|
|
411
420
|
ForeignAsset: number;
|
|
412
421
|
Native?: undefined;
|
|
413
422
|
};
|
|
423
|
+
protected getLocalCurrencyId(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, asset: TAssetInfo): {
|
|
424
|
+
Native: number;
|
|
425
|
+
ForeignAsset?: undefined;
|
|
426
|
+
} | {
|
|
427
|
+
ForeignAsset: number;
|
|
428
|
+
Native?: undefined;
|
|
429
|
+
};
|
|
430
|
+
protected getMintConfig(): TMintConfig;
|
|
414
431
|
transferPolkadotXCM(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
|
|
415
432
|
}
|
|
416
433
|
|
|
@@ -550,6 +567,7 @@ declare const chains: <TApi, TRes, TSigner>() => {
|
|
|
550
567
|
Encointer: Encointer<TApi, TRes, TSigner, never>;
|
|
551
568
|
Basilisk: Basilisk<TApi, TRes, TSigner, never>;
|
|
552
569
|
BifrostKusama: BifrostKusama<TApi, TRes, TSigner, never>;
|
|
570
|
+
Curio: Curio<TApi, TRes, TSigner, never>;
|
|
553
571
|
CrustShadow: CrustShadow<TApi, TRes, TSigner, never>;
|
|
554
572
|
Crab: Crab<TApi, TRes, TSigner, never>;
|
|
555
573
|
Karura: Karura<TApi, TRes, TSigner, never>;
|
|
@@ -1020,6 +1038,7 @@ type TDryRunBaseOptions<TRes, TCustomChain extends string = never> = {
|
|
|
1020
1038
|
swapConfig?: TSwapConfig;
|
|
1021
1039
|
useRootOrigin?: boolean;
|
|
1022
1040
|
bypassOptions?: TBypassOptions;
|
|
1041
|
+
keepAlive?: boolean;
|
|
1023
1042
|
};
|
|
1024
1043
|
type TDryRunOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TDryRunBaseOptions<TRes, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
|
|
1025
1044
|
type TDryRunCallBaseOptions<TRes, TCustomChain extends string = never> = {
|
|
@@ -1051,6 +1070,7 @@ type TDryRunCallBaseOptions<TRes, TCustomChain extends string = never> = {
|
|
|
1051
1070
|
assets?: WithAmount<TAssetInfo>[];
|
|
1052
1071
|
bypassOptions?: TBypassOptions;
|
|
1053
1072
|
feeAsset?: TAssetInfo;
|
|
1073
|
+
keepAlive?: boolean;
|
|
1054
1074
|
};
|
|
1055
1075
|
type TDryRunBypassOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<Omit<TDryRunCallBaseOptions<TRes, TCustomChain>, 'useRootOrigin' | 'destination'>, TApi, TRes, TSigner, TCustomChain>;
|
|
1056
1076
|
type TDryRunCallOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = WithApi<TDryRunCallBaseOptions<TRes, TCustomChain>, TApi, TRes, TSigner, TCustomChain>;
|
|
@@ -2506,7 +2526,7 @@ declare const reverseTransformLocation: (location: TLocation) => TLocation;
|
|
|
2506
2526
|
|
|
2507
2527
|
declare const normalizeAmount: (amount: bigint) => bigint;
|
|
2508
2528
|
|
|
2509
|
-
declare const resolveDestChain: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, originChain: TSubstrateChain | TCustomChain, paraId: number | undefined) => "AssetHubPolkadot" | "Acala" | "Ajuna" | "Astar" | "BifrostPolkadot" | "BridgeHubPolkadot" | "Centrifuge" | "Darwinia" | "EnergyWebX" | "Hydration" | "Heima" | "Jamton" | "CoretimePolkadot" | "Collectives" | "Crust" | "NeuroWeb" | "Pendulum" | "Mythos" | "Peaq" | "PeoplePolkadot" | "Unique" | "Xode" | "AssetHubKusama" | "BridgeHubKusama" | "Karura" | "CoretimeKusama" | "Encointer" | "Basilisk" | "BifrostKusama" | "CrustShadow" | "Crab" | "RobonomicsPolkadot" | "PeopleKusama" | "Shiden" | "AssetHubWestend" | "BridgeHubWestend" | "CollectivesWestend" | "CoretimeWestend" | "Penpal" | "PeopleWestend" | "AssetHubPaseo" | "EnergyWebXPaseo" | "HeimaPaseo" | "HydrationPaseo" | "NeuroWebPaseo" | "PeoplePaseo" | undefined;
|
|
2529
|
+
declare const resolveDestChain: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, originChain: TSubstrateChain | TCustomChain, paraId: number | undefined) => "AssetHubPolkadot" | "Acala" | "Ajuna" | "Astar" | "BifrostPolkadot" | "BridgeHubPolkadot" | "Centrifuge" | "Darwinia" | "EnergyWebX" | "Hydration" | "Heima" | "Jamton" | "CoretimePolkadot" | "Collectives" | "Crust" | "NeuroWeb" | "Pendulum" | "Mythos" | "Peaq" | "PeoplePolkadot" | "Unique" | "Xode" | "AssetHubKusama" | "BridgeHubKusama" | "Karura" | "CoretimeKusama" | "Encointer" | "Basilisk" | "BifrostKusama" | "Curio" | "CrustShadow" | "Crab" | "RobonomicsPolkadot" | "PeopleKusama" | "Shiden" | "AssetHubWestend" | "BridgeHubWestend" | "CollectivesWestend" | "CoretimeWestend" | "Penpal" | "PeopleWestend" | "AssetHubPaseo" | "EnergyWebXPaseo" | "HeimaPaseo" | "HydrationPaseo" | "NeuroWebPaseo" | "PeoplePaseo" | undefined;
|
|
2510
2530
|
|
|
2511
2531
|
declare const resolveParaId: <TApi, TRes, TSigner, TCustomChain extends string = never>(paraId: number | undefined, destination: TDestination, api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>) => number | undefined;
|
|
2512
2532
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
2
|
-
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isSymbolMatch, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositOrThrowImpl, normalizeCustomAssets } from '@paraspell/assets';
|
|
2
|
+
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isSymbolMatch, isAssetEqual, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositOrThrowImpl, 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, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
|
|
@@ -819,18 +819,13 @@ var keyFromWs = function keyFromWs(ws) {
|
|
|
819
819
|
return Array.isArray(ws) ? JSON.stringify(ws) : ws;
|
|
820
820
|
};
|
|
821
821
|
var createClientPoolHelpers = function createClientPoolHelpers(clientPool, createClient) {
|
|
822
|
-
var
|
|
823
|
-
|
|
824
|
-
|
|
822
|
+
var pendingClients = new Map();
|
|
823
|
+
var createEntry = /*#__PURE__*/function () {
|
|
824
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(key, ws, ttlMs) {
|
|
825
|
+
var client, entry;
|
|
825
826
|
return _regenerator().w(function (_context) {
|
|
826
827
|
while (1) switch (_context.n) {
|
|
827
828
|
case 0:
|
|
828
|
-
key = keyFromWs(ws);
|
|
829
|
-
entry = clientPool.peek(key);
|
|
830
|
-
if (entry) {
|
|
831
|
-
_context.n = 2;
|
|
832
|
-
break;
|
|
833
|
-
}
|
|
834
829
|
_context.n = 1;
|
|
835
830
|
return createClient(ws);
|
|
836
831
|
case 1:
|
|
@@ -841,16 +836,51 @@ var createClientPoolHelpers = function createClientPoolHelpers(clientPool, creat
|
|
|
841
836
|
destroyWanted: false
|
|
842
837
|
};
|
|
843
838
|
clientPool.set(key, entry, ttlMs);
|
|
839
|
+
return _context.a(2, entry);
|
|
840
|
+
}
|
|
841
|
+
}, _callee);
|
|
842
|
+
}));
|
|
843
|
+
return function createEntry(_x, _x2, _x3) {
|
|
844
|
+
return _ref.apply(this, arguments);
|
|
845
|
+
};
|
|
846
|
+
}();
|
|
847
|
+
var getOrCreateEntry = function getOrCreateEntry(key, ws, ttlMs) {
|
|
848
|
+
var pending = pendingClients.get(key);
|
|
849
|
+
if (pending) return pending;
|
|
850
|
+
var creation = Promise.resolve().then(function () {
|
|
851
|
+
return createEntry(key, ws, ttlMs);
|
|
852
|
+
})["finally"](function () {
|
|
853
|
+
pendingClients["delete"](key);
|
|
854
|
+
});
|
|
855
|
+
pendingClients.set(key, creation);
|
|
856
|
+
return creation;
|
|
857
|
+
};
|
|
858
|
+
var leaseClient = /*#__PURE__*/function () {
|
|
859
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(ws, ttlMs) {
|
|
860
|
+
var key, entry;
|
|
861
|
+
return _regenerator().w(function (_context2) {
|
|
862
|
+
while (1) switch (_context2.n) {
|
|
863
|
+
case 0:
|
|
864
|
+
key = keyFromWs(ws);
|
|
865
|
+
entry = clientPool.peek(key);
|
|
866
|
+
if (entry) {
|
|
867
|
+
_context2.n = 2;
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
_context2.n = 1;
|
|
871
|
+
return getOrCreateEntry(key, ws, ttlMs);
|
|
872
|
+
case 1:
|
|
873
|
+
entry = _context2.v;
|
|
844
874
|
case 2:
|
|
845
875
|
entry.refs += 1;
|
|
846
|
-
clientPool.revive(key, ttlMs);
|
|
847
876
|
entry.destroyWanted = false;
|
|
848
|
-
|
|
877
|
+
clientPool.revive(key, ttlMs);
|
|
878
|
+
return _context2.a(2, entry.client);
|
|
849
879
|
}
|
|
850
|
-
},
|
|
880
|
+
}, _callee2);
|
|
851
881
|
}));
|
|
852
|
-
return function leaseClient(
|
|
853
|
-
return
|
|
882
|
+
return function leaseClient(_x4, _x5) {
|
|
883
|
+
return _ref2.apply(this, arguments);
|
|
854
884
|
};
|
|
855
885
|
}();
|
|
856
886
|
var releaseClient = function releaseClient(ws) {
|
|
@@ -1449,6 +1479,17 @@ var BifrostKusama$1 = {
|
|
|
1449
1479
|
}
|
|
1450
1480
|
]
|
|
1451
1481
|
};
|
|
1482
|
+
var Curio$1 = {
|
|
1483
|
+
name: "Curio",
|
|
1484
|
+
info: "curio",
|
|
1485
|
+
paraId: 3339,
|
|
1486
|
+
providers: [
|
|
1487
|
+
{
|
|
1488
|
+
name: "Curio",
|
|
1489
|
+
endpoint: "wss://parachain.curioinvest.com/"
|
|
1490
|
+
}
|
|
1491
|
+
]
|
|
1492
|
+
};
|
|
1452
1493
|
var CrustShadow$1 = {
|
|
1453
1494
|
name: "Crust Shadow",
|
|
1454
1495
|
info: "shadow",
|
|
@@ -1854,6 +1895,7 @@ var configs = {
|
|
|
1854
1895
|
Encointer: Encointer$1,
|
|
1855
1896
|
Basilisk: Basilisk$1,
|
|
1856
1897
|
BifrostKusama: BifrostKusama$1,
|
|
1898
|
+
Curio: Curio$1,
|
|
1857
1899
|
CrustShadow: CrustShadow$1,
|
|
1858
1900
|
Crab: Crab$1,
|
|
1859
1901
|
RobonomicsPolkadot: RobonomicsPolkadot$1,
|
|
@@ -3096,11 +3138,10 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
3096
3138
|
recipient = options.recipient,
|
|
3097
3139
|
isAmountAll = options.isAmountAll,
|
|
3098
3140
|
keepAlive = options.keepAlive;
|
|
3099
|
-
assertHasId(asset);
|
|
3100
3141
|
var dest = {
|
|
3101
3142
|
Id: recipient
|
|
3102
3143
|
};
|
|
3103
|
-
var currencyId =
|
|
3144
|
+
var currencyId = this.getLocalCurrencyId(api, asset);
|
|
3104
3145
|
if (isAmountAll) {
|
|
3105
3146
|
return api.deserializeExtrinsics({
|
|
3106
3147
|
module: 'Tokens',
|
|
@@ -3122,6 +3163,12 @@ var SubstrateChain = /*#__PURE__*/function (_Chain) {
|
|
|
3122
3163
|
}
|
|
3123
3164
|
});
|
|
3124
3165
|
}
|
|
3166
|
+
}, {
|
|
3167
|
+
key: "getLocalCurrencyId",
|
|
3168
|
+
value: function getLocalCurrencyId(_api, asset) {
|
|
3169
|
+
assertHasId(asset);
|
|
3170
|
+
return BigInt(asset.assetId);
|
|
3171
|
+
}
|
|
3125
3172
|
}, {
|
|
3126
3173
|
key: "getBalanceNative",
|
|
3127
3174
|
value: function getBalanceNative(api, address, asset) {
|
|
@@ -3376,7 +3423,8 @@ var validateBridgeAsset = function validateBridgeAsset(origin, destination, asse
|
|
|
3376
3423
|
var nativeAsset = api.findNativeAssetInfoOrThrow(origin);
|
|
3377
3424
|
var isNativeAsset = isAssetEqual(asset, nativeAsset);
|
|
3378
3425
|
var isBridgedStablecoin = isStableCoinAsset(asset);
|
|
3379
|
-
|
|
3426
|
+
var isAdditionalBridgedAsset = isAdditionalSubstrateBridgeAsset(asset);
|
|
3427
|
+
if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin || isAdditionalBridgedAsset)) {
|
|
3380
3428
|
throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
3381
3429
|
}
|
|
3382
3430
|
};
|
|
@@ -4027,7 +4075,8 @@ var buildDryRun = function buildDryRun(api, tx, options, bypassOptions) {
|
|
|
4027
4075
|
feeAsset = options.feeAsset,
|
|
4028
4076
|
from = options.from,
|
|
4029
4077
|
currency = options.currency,
|
|
4030
|
-
version = options.version
|
|
4078
|
+
version = options.version,
|
|
4079
|
+
keepAlive = options.keepAlive;
|
|
4031
4080
|
if (isTLocation(to)) {
|
|
4032
4081
|
throw new InvalidAddressError('Location destination is not supported for XCM fee calculation.');
|
|
4033
4082
|
}
|
|
@@ -4040,7 +4089,8 @@ var buildDryRun = function buildDryRun(api, tx, options, bypassOptions) {
|
|
|
4040
4089
|
currency: currency,
|
|
4041
4090
|
feeAsset: feeAsset,
|
|
4042
4091
|
version: version,
|
|
4043
|
-
bypassOptions: bypassOptions
|
|
4092
|
+
bypassOptions: bypassOptions,
|
|
4093
|
+
keepAlive: from === to ? keepAlive !== null && keepAlive !== void 0 ? keepAlive : true : false
|
|
4044
4094
|
});
|
|
4045
4095
|
};
|
|
4046
4096
|
|
|
@@ -5819,11 +5869,11 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
5819
5869
|
|
|
5820
5870
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5821
5871
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5822
|
-
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, dryRunError, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
5872
|
+
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, keepAlive, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, dryRunError, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
5823
5873
|
return _regenerator().w(function (_context2) {
|
|
5824
5874
|
while (1) switch (_context2.n) {
|
|
5825
5875
|
case 0:
|
|
5826
|
-
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
5876
|
+
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, keepAlive = options.keepAlive, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
5827
5877
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
5828
5878
|
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
5829
5879
|
amount = asset.amount;
|
|
@@ -5841,6 +5891,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5841
5891
|
feeAsset: resolvedFeeAsset,
|
|
5842
5892
|
version: resolvedVersion,
|
|
5843
5893
|
bypassOptions: bypassOptions,
|
|
5894
|
+
keepAlive: keepAlive,
|
|
5844
5895
|
useRootOrigin: useRootOrigin || !!bypassOptions
|
|
5845
5896
|
});
|
|
5846
5897
|
case 1:
|
|
@@ -6176,6 +6227,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6176
6227
|
mintFeeAssetRes,
|
|
6177
6228
|
amount,
|
|
6178
6229
|
mintSentAsset,
|
|
6230
|
+
sentAssets,
|
|
6179
6231
|
mintAssetResults,
|
|
6180
6232
|
_args2 = arguments,
|
|
6181
6233
|
_t,
|
|
@@ -6243,7 +6295,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6243
6295
|
case 8:
|
|
6244
6296
|
mintSentAsset = /*#__PURE__*/function () {
|
|
6245
6297
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sentAsset) {
|
|
6246
|
-
var balance, bonus, mintAmount, _calcPreviewMintAmoun, missing, total;
|
|
6298
|
+
var balance, bonus, mintAmount, _calcPreviewMintAmoun, keepAliveBuffer, desiredBalance, missing, total;
|
|
6247
6299
|
return _regenerator().w(function (_context) {
|
|
6248
6300
|
while (1) switch (_context.n) {
|
|
6249
6301
|
case 0:
|
|
@@ -6260,7 +6312,9 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6260
6312
|
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
6261
6313
|
mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount;
|
|
6262
6314
|
} else {
|
|
6263
|
-
|
|
6315
|
+
keepAliveBuffer = dryRunOptions.keepAlive ? getEdFromAssetOrThrow(sentAsset) : 0n;
|
|
6316
|
+
desiredBalance = sentAsset.amount + keepAliveBuffer;
|
|
6317
|
+
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, desiredBalance)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
6264
6318
|
total = missing + bonus;
|
|
6265
6319
|
mintAmount = total > 0n ? total : null;
|
|
6266
6320
|
}
|
|
@@ -6274,8 +6328,9 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
6274
6328
|
return _ref3.apply(this, arguments);
|
|
6275
6329
|
};
|
|
6276
6330
|
}(); // mint assets that are being sent
|
|
6331
|
+
sentAssets = (_dryRunOptions$assets = dryRunOptions.assets) !== null && _dryRunOptions$assets !== void 0 ? _dryRunOptions$assets : [asset];
|
|
6277
6332
|
_context2.n = 9;
|
|
6278
|
-
return Promise.all(
|
|
6333
|
+
return Promise.all(sentAssets.map(mintSentAsset));
|
|
6279
6334
|
case 9:
|
|
6280
6335
|
mintAssetResults = _context2.v;
|
|
6281
6336
|
return _context2.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes].concat(_toConsumableArray(mintAssetResults)).flatMap(function (tx) {
|
|
@@ -8044,8 +8099,8 @@ var createDestination = function createDestination(api, version, origin, destina
|
|
|
8044
8099
|
}
|
|
8045
8100
|
};
|
|
8046
8101
|
}
|
|
8047
|
-
var
|
|
8048
|
-
if (
|
|
8102
|
+
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
8103
|
+
if (isExternalDestination) {
|
|
8049
8104
|
return {
|
|
8050
8105
|
parents: Parents.TWO,
|
|
8051
8106
|
interior: {
|
|
@@ -8271,6 +8326,26 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8271
8326
|
};
|
|
8272
8327
|
};
|
|
8273
8328
|
|
|
8329
|
+
var PINK_LOCATION = {
|
|
8330
|
+
parents: 1,
|
|
8331
|
+
interior: {
|
|
8332
|
+
X3: [{
|
|
8333
|
+
Parachain: 1000
|
|
8334
|
+
}, {
|
|
8335
|
+
PalletInstance: 50
|
|
8336
|
+
}, {
|
|
8337
|
+
GeneralIndex: 23
|
|
8338
|
+
}]
|
|
8339
|
+
}
|
|
8340
|
+
};
|
|
8341
|
+
var requiresSystemAssetByLocation = function requiresSystemAssetByLocation(api, assetLocation) {
|
|
8342
|
+
var wudLocation = api.findAssetInfoOrThrow('Jamton', {
|
|
8343
|
+
symbol: 'WUD'
|
|
8344
|
+
}).location;
|
|
8345
|
+
return [wudLocation, PINK_LOCATION].some(function (location) {
|
|
8346
|
+
return deepEqual(assetLocation, location);
|
|
8347
|
+
});
|
|
8348
|
+
};
|
|
8274
8349
|
var getBridgeReserve = function getBridgeReserve(api, chain, destination, location) {
|
|
8275
8350
|
var expectedConsensus = isExternalChain(destination) ? getEthereumJunction(api, chain, false).GlobalConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
|
|
8276
8351
|
var isDestReserve = deepEqual(getJunctionValue(location, 'GlobalConsensus'), expectedConsensus);
|
|
@@ -8283,12 +8358,12 @@ var resolveReserveChain = function resolveReserveChain(api, chain, destination,
|
|
|
8283
8358
|
if (overrideReserve !== undefined) {
|
|
8284
8359
|
return overrideReserve;
|
|
8285
8360
|
}
|
|
8286
|
-
return api.getAssetReserveChain(chain, assetLocation,
|
|
8361
|
+
return api.getAssetReserveChain(chain, assetLocation, isExternalChain(destination));
|
|
8287
8362
|
};
|
|
8288
8363
|
var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
8289
8364
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, overrides) {
|
|
8290
8365
|
var _overrides$noFeeAsset;
|
|
8291
|
-
var api, chain, destination, assetInfo, isSubBridge, isSb, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, bridgeHopChain, destApi, reserveApi;
|
|
8366
|
+
var api, chain, destination, assetInfo, isSubBridge, isSb, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isExternalDestination, isSnowbridgeAsset, requiresSystemAsset, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, assetHubChain, bridgeHopChain, destApi, reserveApi;
|
|
8292
8367
|
return _regenerator().w(function (_context) {
|
|
8293
8368
|
while (1) switch (_context.n) {
|
|
8294
8369
|
case 0:
|
|
@@ -8326,14 +8401,18 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
8326
8401
|
systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(chain));
|
|
8327
8402
|
assetGlobalConsensus = getJunctionValue(assetInfo.location, 'GlobalConsensus');
|
|
8328
8403
|
originRelayChain = api.getRelayChainOf(chain);
|
|
8329
|
-
|
|
8330
|
-
|
|
8404
|
+
isExternalDestination = isExternalChain(destination);
|
|
8405
|
+
isSnowbridgeAsset = deepEqual(assetGlobalConsensus, getEthereumJunction(api, chain, false).GlobalConsensus);
|
|
8406
|
+
requiresSystemAsset = !isExternalDestination && (isSnowbridgeAsset || !isRelayChain(destination) && requiresSystemAssetByLocation(api, assetInfo.location));
|
|
8407
|
+
isAssetHubToExternal = chain.startsWith('AssetHub') && isExternalDestination;
|
|
8408
|
+
isForeignRelayToExternal = isExternalDestination && !chain.startsWith('AssetHub') && assetInfo.location.parents === 2 && RELAYCHAINS.some(function (relay) {
|
|
8331
8409
|
return relay !== originRelayChain && deepEqual(assetGlobalConsensus, _defineProperty({}, relay.toLowerCase(), null));
|
|
8332
8410
|
});
|
|
8333
|
-
isRelayAsset = !isForeignRelayToExternal && (isAssetHubToExternal || NO_FEE_ASSET_LOCS.some(function (loc) {
|
|
8411
|
+
isRelayAsset = !requiresSystemAsset && !isForeignRelayToExternal && (isAssetHubToExternal || NO_FEE_ASSET_LOCS.some(function (loc) {
|
|
8334
8412
|
return deepEqual(assetInfo.location, loc);
|
|
8335
8413
|
}) || isSubBridge || ((_overrides$noFeeAsset = overrides.noFeeAsset) !== null && _overrides$noFeeAsset !== void 0 ? _overrides$noFeeAsset : false));
|
|
8336
|
-
|
|
8414
|
+
assetHubChain = "AssetHub".concat(originRelayChain);
|
|
8415
|
+
bridgeHopChain = !chain.startsWith('AssetHub') && destination !== assetHubChain && assetGlobalConsensus !== undefined ? assetHubChain : undefined;
|
|
8337
8416
|
destApi = api.clone();
|
|
8338
8417
|
_context.n = 1;
|
|
8339
8418
|
return destApi.init(destination);
|
|
@@ -9165,7 +9244,9 @@ var isNativeAssetTeleport = function isNativeAssetTeleport(api, origin, dest, as
|
|
|
9165
9244
|
var isOriginAh = origin.includes('AssetHub');
|
|
9166
9245
|
var isDestAh = dest.includes('AssetHub');
|
|
9167
9246
|
if (isOriginAh === isDestAh) return false;
|
|
9247
|
+
if (api.getRelayChainOf(origin) !== api.getRelayChainOf(dest)) return false;
|
|
9168
9248
|
var para = isDestAh ? origin : dest;
|
|
9249
|
+
if (para === 'Curio') return false;
|
|
9169
9250
|
return isAssetEqual(api.findNativeAssetInfoOrThrow(para), asset);
|
|
9170
9251
|
};
|
|
9171
9252
|
|
|
@@ -11445,6 +11526,43 @@ var CrustShadow = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11445
11526
|
}]);
|
|
11446
11527
|
}(SubstrateChain);
|
|
11447
11528
|
|
|
11529
|
+
var Curio = /*#__PURE__*/function (_SubstrateChain) {
|
|
11530
|
+
function Curio() {
|
|
11531
|
+
_classCallCheck(this, Curio);
|
|
11532
|
+
return _callSuper(this, Curio, ['Curio', 'curio', 'Kusama', Version.V4]);
|
|
11533
|
+
}
|
|
11534
|
+
_inherits(Curio, _SubstrateChain);
|
|
11535
|
+
return _createClass(Curio, [{
|
|
11536
|
+
key: "getCustomCurrencyId",
|
|
11537
|
+
value: function getCustomCurrencyId(_api, asset) {
|
|
11538
|
+
if (asset.isNative) return {
|
|
11539
|
+
Token: asset.symbol
|
|
11540
|
+
};
|
|
11541
|
+
assertHasId(asset);
|
|
11542
|
+
return {
|
|
11543
|
+
ForeignAsset: Number(asset.assetId)
|
|
11544
|
+
};
|
|
11545
|
+
}
|
|
11546
|
+
}, {
|
|
11547
|
+
key: "getLocalCurrencyId",
|
|
11548
|
+
value: function getLocalCurrencyId(api, asset) {
|
|
11549
|
+
return this.getCustomCurrencyId(api, asset);
|
|
11550
|
+
}
|
|
11551
|
+
}, {
|
|
11552
|
+
key: "getMintConfig",
|
|
11553
|
+
value: function getMintConfig() {
|
|
11554
|
+
return {
|
|
11555
|
+
useCustomCurrencyId: true
|
|
11556
|
+
};
|
|
11557
|
+
}
|
|
11558
|
+
}, {
|
|
11559
|
+
key: "transferPolkadotXCM",
|
|
11560
|
+
value: function transferPolkadotXCM(input) {
|
|
11561
|
+
return transferPolkadotXcm(input);
|
|
11562
|
+
}
|
|
11563
|
+
}]);
|
|
11564
|
+
}(SubstrateChain);
|
|
11565
|
+
|
|
11448
11566
|
var Darwinia = /*#__PURE__*/function (_SubstrateChain) {
|
|
11449
11567
|
function Darwinia() {
|
|
11450
11568
|
_classCallCheck(this, Darwinia);
|
|
@@ -11694,29 +11812,28 @@ var Jamton = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
11694
11812
|
ForeignAsset: assetId
|
|
11695
11813
|
};
|
|
11696
11814
|
}
|
|
11815
|
+
}, {
|
|
11816
|
+
key: "getLocalCurrencyId",
|
|
11817
|
+
value: function getLocalCurrencyId(api, asset) {
|
|
11818
|
+
return this.getCustomCurrencyId(api, asset);
|
|
11819
|
+
}
|
|
11820
|
+
}, {
|
|
11821
|
+
key: "getMintConfig",
|
|
11822
|
+
value: function getMintConfig() {
|
|
11823
|
+
return {
|
|
11824
|
+
useCustomCurrencyId: true
|
|
11825
|
+
};
|
|
11826
|
+
}
|
|
11697
11827
|
}, {
|
|
11698
11828
|
key: "transferPolkadotXCM",
|
|
11699
11829
|
value: function transferPolkadotXCM(input) {
|
|
11700
|
-
var
|
|
11701
|
-
assetInfo = input.assetInfo,
|
|
11830
|
+
var assetInfo = input.assetInfo,
|
|
11702
11831
|
scenario = input.scenario,
|
|
11703
|
-
destination = input.destination
|
|
11704
|
-
version = input.version;
|
|
11832
|
+
destination = input.destination;
|
|
11705
11833
|
if (assetInfo.isNative) return transferPolkadotXcm(input);
|
|
11706
11834
|
if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot') {
|
|
11707
11835
|
throw new ScenarioNotSupportedError("Transfer from ".concat(this.chain, " to ").concat(JSON.stringify(destination), " is not yet supported"));
|
|
11708
11836
|
}
|
|
11709
|
-
if (isSymbolMatch(assetInfo.symbol, 'WUD')) {
|
|
11710
|
-
var usdt = api.findAssetInfoOrThrow(this.chain, {
|
|
11711
|
-
symbol: 'USDt'
|
|
11712
|
-
});
|
|
11713
|
-
var MIN_USDT_AMOUNT = 180000n; // 0.18 USDt
|
|
11714
|
-
return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
|
|
11715
|
-
overriddenAsset: [_objectSpread2(_objectSpread2({}, createAsset(version, MIN_USDT_AMOUNT, usdt.location)), {}, {
|
|
11716
|
-
isFeeAsset: true
|
|
11717
|
-
}), createAsset(version, assetInfo.amount, assetInfo.location)]
|
|
11718
|
-
}));
|
|
11719
|
-
}
|
|
11720
11837
|
return transferPolkadotXcm(input);
|
|
11721
11838
|
}
|
|
11722
11839
|
}]);
|
|
@@ -12356,6 +12473,7 @@ var chains = function chains() {
|
|
|
12356
12473
|
Encointer: new Encointer(),
|
|
12357
12474
|
Basilisk: new Basilisk(),
|
|
12358
12475
|
BifrostKusama: new BifrostKusama(),
|
|
12476
|
+
Curio: new Curio(),
|
|
12359
12477
|
CrustShadow: new CrustShadow(),
|
|
12360
12478
|
Crab: new Crab(),
|
|
12361
12479
|
Karura: new Karura(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.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.55.10",
|
|
28
|
-
"@paraspell/
|
|
29
|
-
"@paraspell/
|
|
30
|
-
"@paraspell/
|
|
28
|
+
"@paraspell/pallets": "14.2.0",
|
|
29
|
+
"@paraspell/sdk-common": "14.2.0",
|
|
30
|
+
"@paraspell/assets": "14.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|