@paraspell/sdk-core 13.7.2 → 13.9.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 +238 -152
- package/dist/index.mjs +1009 -890
- package/package.json +6 -9
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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,
|
|
2
|
+
import { isChainEvm, getAssetsObject, isChainEvmImpl, InvalidCurrencyError, isOverrideLocationSpecifier, isTAsset, getOtherAssets, getNativeAssetSymbol, isSymbolMatch, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, isAssetXcEqual, isSymbolSpecifier, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, normalizeLocation, getEdFromAssetOrThrow, getExistentialDepositOrThrowImpl, extractAssetLocation, 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,
|
|
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
|
-
import { getXcmPallet, getSupportedPallets,
|
|
8
|
+
import { getXcmPallet, getSupportedPallets, getOtherAssetsPallets, getNativeAssetsPallet, hasPalletImpl, getXcmPalletImpl, getSupportedPalletsDetails, ASSETS_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
10
10
|
import { mainnet, sepolia, moonbeam, moonriver } from 'viem/chains';
|
|
11
11
|
|
|
@@ -1076,7 +1076,7 @@ var assertCurrencyCore = function assertCurrencyCore(value) {
|
|
|
1076
1076
|
throw new InvalidCurrencyError('A currency selector is required.');
|
|
1077
1077
|
}
|
|
1078
1078
|
if (Array.isArray(value)) {
|
|
1079
|
-
throw new InvalidCurrencyError('
|
|
1079
|
+
throw new InvalidCurrencyError('An array of currencies is not supported here. Provide a single currency selector ({ symbol }, { id }, or { location }).');
|
|
1080
1080
|
}
|
|
1081
1081
|
if (_typeof(value) === 'object' && 'location' in value && isOverrideLocationSpecifier(value.location)) {
|
|
1082
1082
|
throw new InvalidCurrencyError('Override location specifier is not supported here. Provide a regular location.');
|
|
@@ -1420,19 +1420,10 @@ var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1420
1420
|
}]);
|
|
1421
1421
|
}(BaseAssetsPallet);
|
|
1422
1422
|
|
|
1423
|
-
var
|
|
1424
|
-
|
|
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
|
-
}
|
|
1423
|
+
var resolveAssetId = function resolveAssetId(asset, config) {
|
|
1424
|
+
if (config.useLocationId) return asset.location;
|
|
1431
1425
|
assertHasId(asset);
|
|
1432
|
-
|
|
1433
|
-
return chain.startsWith(prefix);
|
|
1434
|
-
});
|
|
1435
|
-
return useBigInt ? BigInt(asset.assetId) : Number(asset.assetId);
|
|
1426
|
+
return config.useBigIntId ? BigInt(asset.assetId) : Number(asset.assetId);
|
|
1436
1427
|
};
|
|
1437
1428
|
var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
1438
1429
|
function AssetsPallet() {
|
|
@@ -1444,14 +1435,11 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1444
1435
|
key: "mint",
|
|
1445
1436
|
value: function mint(api, address, asset, _balance, chain) {
|
|
1446
1437
|
var amount = asset.amount;
|
|
1447
|
-
var
|
|
1448
|
-
var
|
|
1449
|
-
var
|
|
1450
|
-
return chain.startsWith(prefix);
|
|
1451
|
-
}) || api.isChainEvm(chain);
|
|
1452
|
-
var addr = notUseId ? address : {
|
|
1438
|
+
var config = chain.resolveMintConfig(api);
|
|
1439
|
+
var id = resolveAssetId(asset, config);
|
|
1440
|
+
var addr = config.useIdPrefix ? {
|
|
1453
1441
|
Id: address
|
|
1454
|
-
};
|
|
1442
|
+
} : address;
|
|
1455
1443
|
return Promise.resolve({
|
|
1456
1444
|
assetStatusTx: {
|
|
1457
1445
|
module: this.palletName,
|
|
@@ -1543,18 +1531,16 @@ var BalancesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1543
1531
|
key: "mint",
|
|
1544
1532
|
value: function mint(api, address, assetInfo, balance, chain) {
|
|
1545
1533
|
var amount = assetInfo.amount;
|
|
1546
|
-
var
|
|
1547
|
-
|
|
1548
|
-
return chain.startsWith(prefix);
|
|
1549
|
-
}) || api.isChainEvm(chain);
|
|
1534
|
+
var _chain$resolveMintCon = chain.resolveMintConfig(api),
|
|
1535
|
+
useIdPrefix = _chain$resolveMintCon.useIdPrefix;
|
|
1550
1536
|
return Promise.resolve({
|
|
1551
1537
|
balanceTx: {
|
|
1552
1538
|
module: this.palletName,
|
|
1553
1539
|
method: 'force_set_balance',
|
|
1554
1540
|
params: {
|
|
1555
|
-
who:
|
|
1541
|
+
who: useIdPrefix ? {
|
|
1556
1542
|
Id: address
|
|
1557
|
-
},
|
|
1543
|
+
} : address,
|
|
1558
1544
|
new_free: balance + amount
|
|
1559
1545
|
}
|
|
1560
1546
|
}
|
|
@@ -1589,6 +1575,11 @@ var BalancesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1589
1575
|
}]);
|
|
1590
1576
|
}(BaseAssetsPallet);
|
|
1591
1577
|
|
|
1578
|
+
var resolveCurrencyId$1 = function resolveCurrencyId(api, asset, chain, config) {
|
|
1579
|
+
if (config.useCustomCurrencyId) return chain.getCustomCurrencyId(api, asset);
|
|
1580
|
+
assertHasId(asset);
|
|
1581
|
+
return Number(asset.assetId);
|
|
1582
|
+
};
|
|
1592
1583
|
var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
1593
1584
|
function CurrenciesPallet() {
|
|
1594
1585
|
_classCallCheck(this, CurrenciesPallet);
|
|
@@ -1598,20 +1589,17 @@ var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1598
1589
|
return _createClass(CurrenciesPallet, [{
|
|
1599
1590
|
key: "mint",
|
|
1600
1591
|
value: function mint(api, address, asset, balance, chain) {
|
|
1601
|
-
var
|
|
1602
|
-
var isAcala = chain.startsWith('Acala');
|
|
1603
|
-
var isAcalaLike = isKarura || isAcala;
|
|
1604
|
-
var id = isAcalaLike ? getChain(isKarura ? 'Karura' : 'Acala').getCustomCurrencyId(api, asset) : (assertHasId(asset), Number(asset.assetId));
|
|
1592
|
+
var config = chain.resolveMintConfig(api);
|
|
1605
1593
|
var amount = asset.amount;
|
|
1606
1594
|
return Promise.resolve({
|
|
1607
1595
|
balanceTx: {
|
|
1608
1596
|
module: this.palletName,
|
|
1609
1597
|
method: 'update_balance',
|
|
1610
1598
|
params: {
|
|
1611
|
-
who:
|
|
1599
|
+
who: config.useCustomCurrencyId ? {
|
|
1612
1600
|
Id: address
|
|
1613
1601
|
} : address,
|
|
1614
|
-
currency_id:
|
|
1602
|
+
currency_id: resolveCurrencyId$1(api, asset, chain, config),
|
|
1615
1603
|
amount: balance + amount
|
|
1616
1604
|
}
|
|
1617
1605
|
}
|
|
@@ -1633,15 +1621,14 @@ var ForeignAssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1633
1621
|
_inherits(ForeignAssetsPallet, _BaseAssetsPallet);
|
|
1634
1622
|
return _createClass(ForeignAssetsPallet, [{
|
|
1635
1623
|
key: "mint",
|
|
1636
|
-
value: function mint(
|
|
1624
|
+
value: function mint(api, address, asset, _balance, chain) {
|
|
1637
1625
|
var location = asset.location,
|
|
1638
1626
|
amount = asset.amount;
|
|
1639
|
-
var
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
}) ? address : {
|
|
1627
|
+
var _chain$resolveMintCon = chain.resolveMintConfig(api),
|
|
1628
|
+
useIdPrefix = _chain$resolveMintCon.useIdPrefix;
|
|
1629
|
+
var addr = useIdPrefix ? {
|
|
1643
1630
|
Id: address
|
|
1644
|
-
};
|
|
1631
|
+
} : address;
|
|
1645
1632
|
return Promise.resolve({
|
|
1646
1633
|
assetStatusTx: {
|
|
1647
1634
|
module: this.palletName,
|
|
@@ -1756,7 +1743,7 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1756
1743
|
return _createClass(SystemPallet, [{
|
|
1757
1744
|
key: "mint",
|
|
1758
1745
|
value: function () {
|
|
1759
|
-
var _mint = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, assetInfo, balance
|
|
1746
|
+
var _mint = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, assetInfo, balance) {
|
|
1760
1747
|
var contractAddr, slot, amountEncoded, storageKey;
|
|
1761
1748
|
return _regenerator().w(function (_context) {
|
|
1762
1749
|
while (1) switch (_context.n) {
|
|
@@ -1783,7 +1770,7 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1783
1770
|
}
|
|
1784
1771
|
}, _callee, this);
|
|
1785
1772
|
}));
|
|
1786
|
-
function mint(_x, _x2, _x3, _x4
|
|
1773
|
+
function mint(_x, _x2, _x3, _x4) {
|
|
1787
1774
|
return _mint.apply(this, arguments);
|
|
1788
1775
|
}
|
|
1789
1776
|
return mint;
|
|
@@ -1822,7 +1809,7 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1822
1809
|
}
|
|
1823
1810
|
}, _callee2, this);
|
|
1824
1811
|
}));
|
|
1825
|
-
function getBalance(_x6, _x7
|
|
1812
|
+
function getBalance(_x5, _x6, _x7) {
|
|
1826
1813
|
return _getBalance.apply(this, arguments);
|
|
1827
1814
|
}
|
|
1828
1815
|
return getBalance;
|
|
@@ -1830,18 +1817,17 @@ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1830
1817
|
}]);
|
|
1831
1818
|
}(BaseAssetsPallet);
|
|
1832
1819
|
|
|
1833
|
-
var
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
var isEthAsset = !asset.isNative && ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.startsWith('0x'));
|
|
1837
|
-
var resolvedAsset = isEthAsset ? api.findAssetInfoOrThrow(chain, {
|
|
1838
|
-
location: asset.location
|
|
1839
|
-
}) : asset;
|
|
1840
|
-
return getChain(chain).getCustomCurrencyId(api, resolvedAsset);
|
|
1841
|
-
} else {
|
|
1820
|
+
var resolveCurrencyId = function resolveCurrencyId(api, asset, chain, config) {
|
|
1821
|
+
var _asset$assetId;
|
|
1822
|
+
if (!config.useCustomCurrencyId) {
|
|
1842
1823
|
assertHasId(asset);
|
|
1843
1824
|
return asset.assetId;
|
|
1844
1825
|
}
|
|
1826
|
+
var isEthAsset = !asset.isNative && ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.startsWith('0x'));
|
|
1827
|
+
var resolvedAsset = isEthAsset ? api.findAssetInfoOrThrow(chain.chain, {
|
|
1828
|
+
location: asset.location
|
|
1829
|
+
}) : asset;
|
|
1830
|
+
return chain.getCustomCurrencyId(api, resolvedAsset);
|
|
1845
1831
|
};
|
|
1846
1832
|
var TokensPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
1847
1833
|
function TokensPallet() {
|
|
@@ -1852,9 +1838,7 @@ var TokensPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
1852
1838
|
return _createClass(TokensPallet, [{
|
|
1853
1839
|
key: "mint",
|
|
1854
1840
|
value: function mint(api, address, asset, balance, chain) {
|
|
1855
|
-
var
|
|
1856
|
-
if (!isBifrost) assertHasId(asset);
|
|
1857
|
-
var id = resolveId(api, asset, chain);
|
|
1841
|
+
var id = resolveCurrencyId(api, asset, chain, chain.resolveMintConfig(api));
|
|
1858
1842
|
var amount = asset.amount;
|
|
1859
1843
|
return Promise.resolve({
|
|
1860
1844
|
balanceTx: {
|
|
@@ -2172,14 +2156,6 @@ var AssetHubPolkadot$1 = {
|
|
|
2172
2156
|
name: "Dwellir",
|
|
2173
2157
|
endpoint: "wss://asset-hub-polkadot-rpc.n.dwellir.com"
|
|
2174
2158
|
},
|
|
2175
|
-
{
|
|
2176
|
-
name: "IBP1",
|
|
2177
|
-
endpoint: "wss://asset-hub-polkadot.ibp.network"
|
|
2178
|
-
},
|
|
2179
|
-
{
|
|
2180
|
-
name: "IBP2",
|
|
2181
|
-
endpoint: "wss://asset-hub-polkadot.dotters.network"
|
|
2182
|
-
},
|
|
2183
2159
|
{
|
|
2184
2160
|
name: "LuckyFriday",
|
|
2185
2161
|
endpoint: "wss://rpc-asset-hub-polkadot.luckyfriday.io"
|
|
@@ -2191,10 +2167,6 @@ var AssetHubPolkadot$1 = {
|
|
|
2191
2167
|
{
|
|
2192
2168
|
name: "Parity",
|
|
2193
2169
|
endpoint: "wss://polkadot-asset-hub-rpc.polkadot.io"
|
|
2194
|
-
},
|
|
2195
|
-
{
|
|
2196
|
-
name: "RadiumBlock",
|
|
2197
|
-
endpoint: "wss://statemint.public.curie.radiumblock.co/ws"
|
|
2198
2170
|
}
|
|
2199
2171
|
]
|
|
2200
2172
|
};
|
|
@@ -2248,10 +2220,6 @@ var Astar$1 = {
|
|
|
2248
2220
|
{
|
|
2249
2221
|
name: "OnFinality",
|
|
2250
2222
|
endpoint: "wss://astar.api.onfinality.io/public-ws"
|
|
2251
|
-
},
|
|
2252
|
-
{
|
|
2253
|
-
name: "RadiumBlock",
|
|
2254
|
-
endpoint: "wss://astar.public.curie.radiumblock.co/ws"
|
|
2255
2223
|
}
|
|
2256
2224
|
]
|
|
2257
2225
|
};
|
|
@@ -2279,14 +2247,6 @@ var BridgeHubPolkadot$1 = {
|
|
|
2279
2247
|
name: "Dwellir",
|
|
2280
2248
|
endpoint: "wss://bridge-hub-polkadot-rpc.n.dwellir.com"
|
|
2281
2249
|
},
|
|
2282
|
-
{
|
|
2283
|
-
name: "IBP1",
|
|
2284
|
-
endpoint: "wss://bridge-hub-polkadot.ibp.network"
|
|
2285
|
-
},
|
|
2286
|
-
{
|
|
2287
|
-
name: "IBP2",
|
|
2288
|
-
endpoint: "wss://bridge-hub-polkadot.dotters.network"
|
|
2289
|
-
},
|
|
2290
2250
|
{
|
|
2291
2251
|
name: "LuckyFriday",
|
|
2292
2252
|
endpoint: "wss://rpc-bridge-hub-polkadot.luckyfriday.io"
|
|
@@ -2299,10 +2259,6 @@ var BridgeHubPolkadot$1 = {
|
|
|
2299
2259
|
name: "Parity",
|
|
2300
2260
|
endpoint: "wss://polkadot-bridge-hub-rpc.polkadot.io"
|
|
2301
2261
|
},
|
|
2302
|
-
{
|
|
2303
|
-
name: "RadiumBlock",
|
|
2304
|
-
endpoint: "wss://bridgehub-polkadot.public.curie.radiumblock.co/ws"
|
|
2305
|
-
},
|
|
2306
2262
|
{
|
|
2307
2263
|
name: "Spectrum",
|
|
2308
2264
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/mgX--uWlEtmNKw/polkadotbridgehub/mainnet/"
|
|
@@ -2356,16 +2312,12 @@ var Hydration$1 = {
|
|
|
2356
2312
|
paraId: 2034,
|
|
2357
2313
|
providers: [
|
|
2358
2314
|
{
|
|
2359
|
-
name: "
|
|
2360
|
-
endpoint: "wss://rpc.
|
|
2361
|
-
},
|
|
2362
|
-
{
|
|
2363
|
-
name: "IBP1",
|
|
2364
|
-
endpoint: "wss://hydration.ibp.network"
|
|
2315
|
+
name: "Dwellir",
|
|
2316
|
+
endpoint: "wss://hydration-rpc.n.dwellir.com"
|
|
2365
2317
|
},
|
|
2366
2318
|
{
|
|
2367
|
-
name: "
|
|
2368
|
-
endpoint: "wss://
|
|
2319
|
+
name: "Helikon",
|
|
2320
|
+
endpoint: "wss://rpc.helikon.io/hydradx"
|
|
2369
2321
|
}
|
|
2370
2322
|
]
|
|
2371
2323
|
};
|
|
@@ -2446,14 +2398,6 @@ var CoretimePolkadot$1 = {
|
|
|
2446
2398
|
name: "Dwellir",
|
|
2447
2399
|
endpoint: "wss://coretime-polkadot-rpc.n.dwellir.com"
|
|
2448
2400
|
},
|
|
2449
|
-
{
|
|
2450
|
-
name: "IBP1",
|
|
2451
|
-
endpoint: "wss://coretime-polkadot.ibp.network"
|
|
2452
|
-
},
|
|
2453
|
-
{
|
|
2454
|
-
name: "IBP2",
|
|
2455
|
-
endpoint: "wss://coretime-polkadot.dotters.network"
|
|
2456
|
-
},
|
|
2457
2401
|
{
|
|
2458
2402
|
name: "LuckyFriday",
|
|
2459
2403
|
endpoint: "wss://rpc-coretime-polkadot.luckyfriday.io"
|
|
@@ -2465,10 +2409,6 @@ var CoretimePolkadot$1 = {
|
|
|
2465
2409
|
{
|
|
2466
2410
|
name: "Parity",
|
|
2467
2411
|
endpoint: "wss://polkadot-coretime-rpc.polkadot.io"
|
|
2468
|
-
},
|
|
2469
|
-
{
|
|
2470
|
-
name: "RadiumBlock",
|
|
2471
|
-
endpoint: "wss://coretime-polkadot.public.curie.radiumblock.co/ws"
|
|
2472
2412
|
}
|
|
2473
2413
|
]
|
|
2474
2414
|
};
|
|
@@ -2481,14 +2421,6 @@ var Collectives$1 = {
|
|
|
2481
2421
|
name: "Dwellir",
|
|
2482
2422
|
endpoint: "wss://collectives-polkadot-rpc.n.dwellir.com"
|
|
2483
2423
|
},
|
|
2484
|
-
{
|
|
2485
|
-
name: "IBP1",
|
|
2486
|
-
endpoint: "wss://collectives-polkadot.ibp.network"
|
|
2487
|
-
},
|
|
2488
|
-
{
|
|
2489
|
-
name: "IBP2",
|
|
2490
|
-
endpoint: "wss://collectives-polkadot.dotters.network"
|
|
2491
|
-
},
|
|
2492
2424
|
{
|
|
2493
2425
|
name: "LuckyFriday",
|
|
2494
2426
|
endpoint: "wss://rpc-collectives-polkadot.luckyfriday.io"
|
|
@@ -2500,10 +2432,6 @@ var Collectives$1 = {
|
|
|
2500
2432
|
{
|
|
2501
2433
|
name: "Parity",
|
|
2502
2434
|
endpoint: "wss://polkadot-collectives-rpc.polkadot.io"
|
|
2503
|
-
},
|
|
2504
|
-
{
|
|
2505
|
-
name: "RadiumBlock",
|
|
2506
|
-
endpoint: "wss://collectives.public.curie.radiumblock.co/ws"
|
|
2507
2435
|
}
|
|
2508
2436
|
]
|
|
2509
2437
|
};
|
|
@@ -2583,14 +2511,6 @@ var PeoplePolkadot$1 = {
|
|
|
2583
2511
|
name: "Dwellir",
|
|
2584
2512
|
endpoint: "wss://people-polkadot-rpc.n.dwellir.com"
|
|
2585
2513
|
},
|
|
2586
|
-
{
|
|
2587
|
-
name: "IBP1",
|
|
2588
|
-
endpoint: "wss://people-polkadot.ibp.network"
|
|
2589
|
-
},
|
|
2590
|
-
{
|
|
2591
|
-
name: "IBP2",
|
|
2592
|
-
endpoint: "wss://people-polkadot.dotters.network"
|
|
2593
|
-
},
|
|
2594
2514
|
{
|
|
2595
2515
|
name: "LuckyFriday",
|
|
2596
2516
|
endpoint: "wss://rpc-people-polkadot.luckyfriday.io"
|
|
@@ -2602,10 +2522,6 @@ var PeoplePolkadot$1 = {
|
|
|
2602
2522
|
{
|
|
2603
2523
|
name: "Parity",
|
|
2604
2524
|
endpoint: "wss://polkadot-people-rpc.polkadot.io"
|
|
2605
|
-
},
|
|
2606
|
-
{
|
|
2607
|
-
name: "RadiumBlock",
|
|
2608
|
-
endpoint: "wss://people-polkadot.public.curie.radiumblock.co/ws"
|
|
2609
2525
|
}
|
|
2610
2526
|
]
|
|
2611
2527
|
};
|
|
@@ -2648,14 +2564,6 @@ var AssetHubKusama$1 = {
|
|
|
2648
2564
|
name: "Dwellir",
|
|
2649
2565
|
endpoint: "wss://asset-hub-kusama-rpc.n.dwellir.com"
|
|
2650
2566
|
},
|
|
2651
|
-
{
|
|
2652
|
-
name: "IBP1",
|
|
2653
|
-
endpoint: "wss://asset-hub-kusama.ibp.network"
|
|
2654
|
-
},
|
|
2655
|
-
{
|
|
2656
|
-
name: "IBP2",
|
|
2657
|
-
endpoint: "wss://asset-hub-kusama.dotters.network"
|
|
2658
|
-
},
|
|
2659
2567
|
{
|
|
2660
2568
|
name: "LuckyFriday",
|
|
2661
2569
|
endpoint: "wss://rpc-asset-hub-kusama.luckyfriday.io"
|
|
@@ -2667,10 +2575,6 @@ var AssetHubKusama$1 = {
|
|
|
2667
2575
|
{
|
|
2668
2576
|
name: "Parity",
|
|
2669
2577
|
endpoint: "wss://kusama-asset-hub-rpc.polkadot.io"
|
|
2670
|
-
},
|
|
2671
|
-
{
|
|
2672
|
-
name: "RadiumBlock",
|
|
2673
|
-
endpoint: "wss://statemine.public.curie.radiumblock.co/ws"
|
|
2674
2578
|
}
|
|
2675
2579
|
]
|
|
2676
2580
|
};
|
|
@@ -2683,14 +2587,6 @@ var BridgeHubKusama$1 = {
|
|
|
2683
2587
|
name: "Dwellir",
|
|
2684
2588
|
endpoint: "wss://bridge-hub-kusama-rpc.n.dwellir.com"
|
|
2685
2589
|
},
|
|
2686
|
-
{
|
|
2687
|
-
name: "IBP1",
|
|
2688
|
-
endpoint: "wss://bridge-hub-kusama.ibp.network"
|
|
2689
|
-
},
|
|
2690
|
-
{
|
|
2691
|
-
name: "IBP2",
|
|
2692
|
-
endpoint: "wss://bridge-hub-kusama.dotters.network"
|
|
2693
|
-
},
|
|
2694
2590
|
{
|
|
2695
2591
|
name: "LuckyFriday",
|
|
2696
2592
|
endpoint: "wss://rpc-bridge-hub-kusama.luckyfriday.io"
|
|
@@ -2703,10 +2599,6 @@ var BridgeHubKusama$1 = {
|
|
|
2703
2599
|
name: "Parity",
|
|
2704
2600
|
endpoint: "wss://kusama-bridge-hub-rpc.polkadot.io"
|
|
2705
2601
|
},
|
|
2706
|
-
{
|
|
2707
|
-
name: "RadiumBlock",
|
|
2708
|
-
endpoint: "wss://bridgehub-kusama.public.curie.radiumblock.co/ws"
|
|
2709
|
-
},
|
|
2710
2602
|
{
|
|
2711
2603
|
name: "Spectrum",
|
|
2712
2604
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/balkpUVauqyv8g/kusamabridgehub/mainnet/"
|
|
@@ -2791,14 +2683,6 @@ var CoretimeKusama$1 = {
|
|
|
2791
2683
|
name: "Dwellir",
|
|
2792
2684
|
endpoint: "wss://coretime-kusama-rpc.n.dwellir.com"
|
|
2793
2685
|
},
|
|
2794
|
-
{
|
|
2795
|
-
name: "IBP1",
|
|
2796
|
-
endpoint: "wss://coretime-kusama.ibp.network"
|
|
2797
|
-
},
|
|
2798
|
-
{
|
|
2799
|
-
name: "IBP2",
|
|
2800
|
-
endpoint: "wss://coretime-kusama.dotters.network"
|
|
2801
|
-
},
|
|
2802
2686
|
{
|
|
2803
2687
|
name: "LuckyFriday",
|
|
2804
2688
|
endpoint: "wss://rpc-coretime-kusama.luckyfriday.io"
|
|
@@ -2826,14 +2710,6 @@ var Encointer$1 = {
|
|
|
2826
2710
|
name: "Encointer Association",
|
|
2827
2711
|
endpoint: "wss://kusama.api.encointer.org"
|
|
2828
2712
|
},
|
|
2829
|
-
{
|
|
2830
|
-
name: "IBP1",
|
|
2831
|
-
endpoint: "wss://encointer-kusama.ibp.network"
|
|
2832
|
-
},
|
|
2833
|
-
{
|
|
2834
|
-
name: "IBP2",
|
|
2835
|
-
endpoint: "wss://encointer-kusama.dotters.network"
|
|
2836
|
-
},
|
|
2837
2713
|
{
|
|
2838
2714
|
name: "LuckyFriday",
|
|
2839
2715
|
endpoint: "wss://rpc-encointer-kusama.luckyfriday.io"
|
|
@@ -2939,14 +2815,6 @@ var PeopleKusama$1 = {
|
|
|
2939
2815
|
name: "Helixstreet",
|
|
2940
2816
|
endpoint: "wss://rpc-people-kusama.helixstreet.io"
|
|
2941
2817
|
},
|
|
2942
|
-
{
|
|
2943
|
-
name: "IBP1",
|
|
2944
|
-
endpoint: "wss://people-kusama.ibp.network"
|
|
2945
|
-
},
|
|
2946
|
-
{
|
|
2947
|
-
name: "IBP2",
|
|
2948
|
-
endpoint: "wss://people-kusama.dotters.network"
|
|
2949
|
-
},
|
|
2950
2818
|
{
|
|
2951
2819
|
name: "LuckyFriday",
|
|
2952
2820
|
endpoint: "wss://rpc-people-kusama.luckyfriday.io"
|
|
@@ -2958,10 +2826,6 @@ var PeopleKusama$1 = {
|
|
|
2958
2826
|
{
|
|
2959
2827
|
name: "Parity",
|
|
2960
2828
|
endpoint: "wss://kusama-people-rpc.polkadot.io"
|
|
2961
|
-
},
|
|
2962
|
-
{
|
|
2963
|
-
name: "RadiumBlock",
|
|
2964
|
-
endpoint: "wss://people-kusama.public.curie.radiumblock.co/ws"
|
|
2965
2829
|
}
|
|
2966
2830
|
]
|
|
2967
2831
|
};
|
|
@@ -2981,10 +2845,6 @@ var Shiden$1 = {
|
|
|
2981
2845
|
{
|
|
2982
2846
|
name: "OnFinality",
|
|
2983
2847
|
endpoint: "wss://shiden.api.onfinality.io/public-ws"
|
|
2984
|
-
},
|
|
2985
|
-
{
|
|
2986
|
-
name: "RadiumBlock",
|
|
2987
|
-
endpoint: "wss://shiden.public.curie.radiumblock.co/ws"
|
|
2988
2848
|
}
|
|
2989
2849
|
]
|
|
2990
2850
|
};
|
|
@@ -3105,17 +2965,13 @@ var AssetHubPaseo$1 = {
|
|
|
3105
2965
|
name: "Dwellir",
|
|
3106
2966
|
endpoint: "wss://asset-hub-paseo-rpc.n.dwellir.com"
|
|
3107
2967
|
},
|
|
3108
|
-
{
|
|
3109
|
-
name: "IBP1",
|
|
3110
|
-
endpoint: "wss://asset-hub-paseo.ibp.network"
|
|
3111
|
-
},
|
|
3112
|
-
{
|
|
3113
|
-
name: "IBP2",
|
|
3114
|
-
endpoint: "wss://asset-hub-paseo.dotters.network"
|
|
3115
|
-
},
|
|
3116
2968
|
{
|
|
3117
2969
|
name: "TurboFlakes",
|
|
3118
2970
|
endpoint: "wss://sys.turboflakes.io/asset-hub-paseo"
|
|
2971
|
+
},
|
|
2972
|
+
{
|
|
2973
|
+
name: "Zondax",
|
|
2974
|
+
endpoint: "wss://api2.zondax.ch/pas/assethub/node/rpc"
|
|
3119
2975
|
}
|
|
3120
2976
|
]
|
|
3121
2977
|
};
|
|
@@ -3140,12 +2996,8 @@ var BridgeHubPaseo$1 = {
|
|
|
3140
2996
|
paraId: 1002,
|
|
3141
2997
|
providers: [
|
|
3142
2998
|
{
|
|
3143
|
-
name: "
|
|
3144
|
-
endpoint: "wss://
|
|
3145
|
-
},
|
|
3146
|
-
{
|
|
3147
|
-
name: "IBP2",
|
|
3148
|
-
endpoint: "wss://bridge-hub-paseo.dotters.network"
|
|
2999
|
+
name: "Zondax",
|
|
3000
|
+
endpoint: "wss://api2.zondax.ch/pas/bridgehub/node/rpc"
|
|
3149
3001
|
}
|
|
3150
3002
|
]
|
|
3151
3003
|
};
|
|
@@ -3155,12 +3007,8 @@ var CoretimePaseo$1 = {
|
|
|
3155
3007
|
paraId: 1005,
|
|
3156
3008
|
providers: [
|
|
3157
3009
|
{
|
|
3158
|
-
name: "
|
|
3159
|
-
endpoint: "wss://
|
|
3160
|
-
},
|
|
3161
|
-
{
|
|
3162
|
-
name: "IBP2",
|
|
3163
|
-
endpoint: "wss://coretime-paseo.dotters.network"
|
|
3010
|
+
name: "Zondax",
|
|
3011
|
+
endpoint: "wss://api2.zondax.ch/pas/coretime/node/rpc"
|
|
3164
3012
|
}
|
|
3165
3013
|
]
|
|
3166
3014
|
};
|
|
@@ -3218,12 +3066,8 @@ var PeoplePaseo$1 = {
|
|
|
3218
3066
|
endpoint: "wss://people-paseo.rpc.amforc.com"
|
|
3219
3067
|
},
|
|
3220
3068
|
{
|
|
3221
|
-
name: "
|
|
3222
|
-
endpoint: "wss://
|
|
3223
|
-
},
|
|
3224
|
-
{
|
|
3225
|
-
name: "IBP2",
|
|
3226
|
-
endpoint: "wss://people-paseo.dotters.network"
|
|
3069
|
+
name: "Zondax",
|
|
3070
|
+
endpoint: "wss://api2.zondax.ch/pas/people/node/rpc"
|
|
3227
3071
|
}
|
|
3228
3072
|
]
|
|
3229
3073
|
};
|
|
@@ -3255,14 +3099,6 @@ var Polkadot$1 = {
|
|
|
3255
3099
|
name: "Helixstreet",
|
|
3256
3100
|
endpoint: "wss://rpc-polkadot.helixstreet.io"
|
|
3257
3101
|
},
|
|
3258
|
-
{
|
|
3259
|
-
name: "IBP1",
|
|
3260
|
-
endpoint: "wss://polkadot.ibp.network"
|
|
3261
|
-
},
|
|
3262
|
-
{
|
|
3263
|
-
name: "IBP2",
|
|
3264
|
-
endpoint: "wss://polkadot.dotters.network"
|
|
3265
|
-
},
|
|
3266
3102
|
{
|
|
3267
3103
|
name: "LuckyFriday",
|
|
3268
3104
|
endpoint: "wss://rpc-polkadot.luckyfriday.io"
|
|
@@ -3271,10 +3107,6 @@ var Polkadot$1 = {
|
|
|
3271
3107
|
name: "OnFinality",
|
|
3272
3108
|
endpoint: "wss://polkadot.api.onfinality.io/public-ws"
|
|
3273
3109
|
},
|
|
3274
|
-
{
|
|
3275
|
-
name: "RadiumBlock",
|
|
3276
|
-
endpoint: "wss://polkadot.public.curie.radiumblock.co/ws"
|
|
3277
|
-
},
|
|
3278
3110
|
{
|
|
3279
3111
|
name: "Spectrum",
|
|
3280
3112
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/LjwBJpV3dIKyWQ/polkadot/mainnet/"
|
|
@@ -3306,14 +3138,6 @@ var Kusama$1 = {
|
|
|
3306
3138
|
name: "Helixstreet",
|
|
3307
3139
|
endpoint: "wss://rpc-kusama.helixstreet.io"
|
|
3308
3140
|
},
|
|
3309
|
-
{
|
|
3310
|
-
name: "IBP1",
|
|
3311
|
-
endpoint: "wss://kusama.ibp.network"
|
|
3312
|
-
},
|
|
3313
|
-
{
|
|
3314
|
-
name: "IBP2",
|
|
3315
|
-
endpoint: "wss://kusama.dotters.network"
|
|
3316
|
-
},
|
|
3317
3141
|
{
|
|
3318
3142
|
name: "LuckyFriday",
|
|
3319
3143
|
endpoint: "wss://rpc-kusama.luckyfriday.io"
|
|
@@ -3322,10 +3146,6 @@ var Kusama$1 = {
|
|
|
3322
3146
|
name: "OnFinality",
|
|
3323
3147
|
endpoint: "wss://kusama.api.onfinality.io/public-ws"
|
|
3324
3148
|
},
|
|
3325
|
-
{
|
|
3326
|
-
name: "RadiumBlock",
|
|
3327
|
-
endpoint: "wss://kusama.public.curie.radiumblock.co/ws"
|
|
3328
|
-
},
|
|
3329
3149
|
{
|
|
3330
3150
|
name: "Spectrum",
|
|
3331
3151
|
endpoint: "wss://spectrum-03.simplystaking.xyz/cG9sa2Fkb3QtMDMtOTFkMmYwZGYtcG9sa2Fkb3Q/QXq7QZ6Q60NDzA/kusama/mainnet/"
|
|
@@ -3352,10 +3172,6 @@ var Westend$1 = {
|
|
|
3352
3172
|
{
|
|
3353
3173
|
name: "Parity",
|
|
3354
3174
|
endpoint: "wss://westend-rpc.polkadot.io"
|
|
3355
|
-
},
|
|
3356
|
-
{
|
|
3357
|
-
name: "RadiumBlock",
|
|
3358
|
-
endpoint: "wss://rpc.public.curie.radiumblock.xyz/ws-westend"
|
|
3359
3175
|
}
|
|
3360
3176
|
]
|
|
3361
3177
|
};
|
|
@@ -3373,12 +3189,8 @@ var Paseo$1 = {
|
|
|
3373
3189
|
endpoint: "wss://paseo-rpc.n.dwellir.com"
|
|
3374
3190
|
},
|
|
3375
3191
|
{
|
|
3376
|
-
name: "
|
|
3377
|
-
endpoint: "wss://
|
|
3378
|
-
},
|
|
3379
|
-
{
|
|
3380
|
-
name: "IBP2",
|
|
3381
|
-
endpoint: "wss://paseo.dotters.network"
|
|
3192
|
+
name: "Zondax",
|
|
3193
|
+
endpoint: "wss://api2.zondax.ch/pas/relay/node/rpc"
|
|
3382
3194
|
}
|
|
3383
3195
|
]
|
|
3384
3196
|
};
|
|
@@ -3952,11 +3764,11 @@ var Chain = /*#__PURE__*/function () {
|
|
|
3952
3764
|
key: "transferLocal",
|
|
3953
3765
|
value: function () {
|
|
3954
3766
|
var _transferLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
3955
|
-
var api, asset, feeAsset, recipient, sender, isAmountAll, validatedOptions, isNativeAsset, balance, localOptions;
|
|
3767
|
+
var api, asset, feeAsset, recipient, sender, isAmountAll, keepAlive, validatedOptions, isNativeAsset, balance, localOptions;
|
|
3956
3768
|
return _regenerator().w(function (_context2) {
|
|
3957
3769
|
while (1) switch (_context2.n) {
|
|
3958
3770
|
case 0:
|
|
3959
|
-
api = options.api, asset = options.assetInfo, feeAsset = options.feeAsset, recipient = options.recipient, sender = options.sender, isAmountAll = options.isAmountAll;
|
|
3771
|
+
api = options.api, asset = options.assetInfo, feeAsset = options.feeAsset, recipient = options.recipient, sender = options.sender, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
|
|
3960
3772
|
if (!isTLocation(recipient)) {
|
|
3961
3773
|
_context2.n = 1;
|
|
3962
3774
|
break;
|
|
@@ -3973,7 +3785,7 @@ var Chain = /*#__PURE__*/function () {
|
|
|
3973
3785
|
recipient: recipient
|
|
3974
3786
|
});
|
|
3975
3787
|
isNativeAsset = asset.symbol === this.getNativeAssetSymbol(api) && asset.isNative;
|
|
3976
|
-
if (!isAmountAll) {
|
|
3788
|
+
if (!(isAmountAll || keepAlive)) {
|
|
3977
3789
|
_context2.n = 4;
|
|
3978
3790
|
break;
|
|
3979
3791
|
}
|
|
@@ -4150,6 +3962,25 @@ var Chain = /*#__PURE__*/function () {
|
|
|
4150
3962
|
if (isNativeAsset) return this.getBalanceNative(api, address, asset);
|
|
4151
3963
|
return this.getBalanceForeign(api, address, asset);
|
|
4152
3964
|
}
|
|
3965
|
+
}, {
|
|
3966
|
+
key: "mint",
|
|
3967
|
+
value: function mint(api, address, assetInfo, balance) {
|
|
3968
|
+
var isMainNativeAsset = isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol(api));
|
|
3969
|
+
var pallet = !assetInfo.isNative && this.chain !== 'Mythos' || !isMainNativeAsset ? pickOtherMintPallet(assetInfo, getOtherAssetsPallets(this.chain, api._customCtx)) : getNativeAssetsPallet(this.chain, api._customCtx);
|
|
3970
|
+
return getPalletInstance(pallet).mint(api, address, assetInfo, balance, this);
|
|
3971
|
+
}
|
|
3972
|
+
}, {
|
|
3973
|
+
key: "resolveMintConfig",
|
|
3974
|
+
value: function resolveMintConfig(api) {
|
|
3975
|
+
return _objectSpread2({
|
|
3976
|
+
useIdPrefix: !api.isChainEvm(this.chain)
|
|
3977
|
+
}, this.getMintConfig());
|
|
3978
|
+
}
|
|
3979
|
+
}, {
|
|
3980
|
+
key: "getMintConfig",
|
|
3981
|
+
value: function getMintConfig() {
|
|
3982
|
+
return {};
|
|
3983
|
+
}
|
|
4153
3984
|
}]);
|
|
4154
3985
|
}();
|
|
4155
3986
|
|
|
@@ -4196,17 +4027,159 @@ var resolveAsset = function resolveAsset(currency, origin, destination, assetChe
|
|
|
4196
4027
|
return api.findAssetInfo(origin, currency, dest);
|
|
4197
4028
|
};
|
|
4198
4029
|
|
|
4030
|
+
var assertNotRawAssets = function assertNotRawAssets(currency) {
|
|
4031
|
+
if (Array.isArray(currency) && currency.length > 0 && currency.every(function (asset) {
|
|
4032
|
+
return isTAsset(asset);
|
|
4033
|
+
})) {
|
|
4034
|
+
throw new InvalidCurrencyError('Raw asset overrides are no longer supported. Please use custom assets instead.');
|
|
4035
|
+
}
|
|
4036
|
+
};
|
|
4037
|
+
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
4038
|
+
if (Array.isArray(currency)) {
|
|
4039
|
+
if (currency.length === 0) {
|
|
4040
|
+
throw new InvalidCurrencyError('Overridden assets cannot be empty');
|
|
4041
|
+
}
|
|
4042
|
+
if (currency.length === 1) {
|
|
4043
|
+
throw new InvalidCurrencyError('Please provide more than one asset');
|
|
4044
|
+
}
|
|
4045
|
+
assertNotRawAssets(currency);
|
|
4046
|
+
if (!feeAsset) {
|
|
4047
|
+
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
};
|
|
4051
|
+
var validateDestination = function validateDestination(origin, destination, api) {
|
|
4052
|
+
if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
4053
|
+
throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
4054
|
+
}
|
|
4055
|
+
if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
|
|
4056
|
+
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
|
|
4057
|
+
}
|
|
4058
|
+
var isLocationDestination = _typeof(destination) === 'object';
|
|
4059
|
+
var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
|
|
4060
|
+
if (!isLocationDestination) {
|
|
4061
|
+
var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
|
|
4062
|
+
var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
|
|
4063
|
+
if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
4064
|
+
throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
|
|
4068
|
+
var chain = getChain(destination);
|
|
4069
|
+
if (!chain.isRelayToParaEnabled()) {
|
|
4070
|
+
throw new ScenarioNotSupportedError({
|
|
4071
|
+
chain: destination,
|
|
4072
|
+
scenario: 'RelayToPara'
|
|
4073
|
+
});
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
};
|
|
4077
|
+
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
4078
|
+
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
4079
|
+
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
4080
|
+
}
|
|
4081
|
+
if (!assetCheckEnabled && 'id' in currency) {
|
|
4082
|
+
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
4083
|
+
}
|
|
4084
|
+
};
|
|
4085
|
+
var validateTransact = function validateTransact(_ref) {
|
|
4086
|
+
var api = _ref.api,
|
|
4087
|
+
from = _ref.from,
|
|
4088
|
+
to = _ref.to,
|
|
4089
|
+
sender = _ref.sender,
|
|
4090
|
+
address = _ref.recipient,
|
|
4091
|
+
currency = _ref.currency,
|
|
4092
|
+
transactOptions = _ref.transactOptions;
|
|
4093
|
+
var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
|
|
4094
|
+
if (!call) return;
|
|
4095
|
+
if (from === to) {
|
|
4096
|
+
throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
|
|
4097
|
+
}
|
|
4098
|
+
if (Array.isArray(currency)) {
|
|
4099
|
+
throw new UnsupportedOperationError('Cannot use transact options with multiple currencies.');
|
|
4100
|
+
}
|
|
4101
|
+
if (typeof call === 'string' && !isHex(call)) {
|
|
4102
|
+
throw new ValidationError('Transact call hex must be a valid hex string.');
|
|
4103
|
+
}
|
|
4104
|
+
if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
|
|
4105
|
+
throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
|
|
4106
|
+
}
|
|
4107
|
+
if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
|
|
4108
|
+
return new ValidationError('Sender address must match the destination address for transact to work.');
|
|
4109
|
+
}
|
|
4110
|
+
};
|
|
4111
|
+
|
|
4112
|
+
var resolveCurrency = function resolveCurrency(api, currency, resolvedFeeAsset, origin, destination, onAsset) {
|
|
4113
|
+
var dest = !isTLocation(destination) ? destination : null;
|
|
4114
|
+
if (Array.isArray(currency)) {
|
|
4115
|
+
var _resolvedFeeAsset$amo;
|
|
4116
|
+
if (!resolvedFeeAsset) {
|
|
4117
|
+
throw new InvalidCurrencyError('Fee asset is required when providing more than one asset');
|
|
4118
|
+
}
|
|
4119
|
+
assertNotRawAssets(currency);
|
|
4120
|
+
var assets = currency.map(function (item) {
|
|
4121
|
+
if (item.amount === AMOUNT_ALL) {
|
|
4122
|
+
throw new InvalidCurrencyError('Provided assets cannot use amount all. Please specify amount.');
|
|
4123
|
+
}
|
|
4124
|
+
var asset = api.findAssetInfo(origin, item, dest);
|
|
4125
|
+
if (!asset) {
|
|
4126
|
+
throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(item, replaceBigInt)));
|
|
4127
|
+
}
|
|
4128
|
+
onAsset === null || onAsset === void 0 || onAsset(asset);
|
|
4129
|
+
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4130
|
+
amount: abstractDecimals(item.amount, asset.decimals, api),
|
|
4131
|
+
isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
|
|
4132
|
+
});
|
|
4133
|
+
});
|
|
4134
|
+
var feeAssetCount = assets.filter(function (asset) {
|
|
4135
|
+
return asset.isFeeAsset;
|
|
4136
|
+
}).length;
|
|
4137
|
+
if (feeAssetCount > 1) {
|
|
4138
|
+
throw new InvalidCurrencyError("Fee asset matches more than one of the provided assets");
|
|
4139
|
+
}
|
|
4140
|
+
if (feeAssetCount === 0) {
|
|
4141
|
+
throw new InvalidCurrencyError("Fee asset must be one of the provided assets");
|
|
4142
|
+
}
|
|
4143
|
+
return {
|
|
4144
|
+
assets: assets,
|
|
4145
|
+
asset: _objectSpread2(_objectSpread2({}, resolvedFeeAsset), {}, {
|
|
4146
|
+
amount: (_resolvedFeeAsset$amo = resolvedFeeAsset.amount) !== null && _resolvedFeeAsset$amo !== void 0 ? _resolvedFeeAsset$amo : 0n
|
|
4147
|
+
})
|
|
4148
|
+
};
|
|
4149
|
+
}
|
|
4150
|
+
var asset = api.findAssetInfoOrThrow(origin, currency, dest);
|
|
4151
|
+
var resolved = _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4152
|
+
amount: abstractDecimals(currency.amount, asset.decimals, api)
|
|
4153
|
+
});
|
|
4154
|
+
return {
|
|
4155
|
+
assets: [resolved],
|
|
4156
|
+
asset: resolved
|
|
4157
|
+
};
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4199
4160
|
var resolveFeeAsset = function resolveFeeAsset(api, feeAsset, origin, destination, currency) {
|
|
4200
|
-
if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
4161
|
+
if (!Array.isArray(currency) && !origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
4201
4162
|
throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
|
|
4202
4163
|
}
|
|
4164
|
+
assertNotRawAssets(currency);
|
|
4203
4165
|
var dest = !isTLocation(destination) ? destination : null;
|
|
4204
4166
|
var asset = api.findAssetInfo(origin, feeAsset, dest);
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4167
|
+
if (!asset) {
|
|
4168
|
+
return throwUnsupportedCurrency(feeAsset, origin);
|
|
4169
|
+
}
|
|
4170
|
+
if (!Array.isArray(currency)) {
|
|
4171
|
+
return asset;
|
|
4208
4172
|
}
|
|
4209
|
-
|
|
4173
|
+
var feeElement = currency.find(function (item) {
|
|
4174
|
+
var resolved = api.findAssetInfo(origin, item, dest);
|
|
4175
|
+
return resolved !== null && isAssetEqual(resolved, asset);
|
|
4176
|
+
});
|
|
4177
|
+
if (!feeElement) {
|
|
4178
|
+
throw new InvalidCurrencyError('Fee asset must be one of the provided assets');
|
|
4179
|
+
}
|
|
4180
|
+
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4181
|
+
amount: abstractDecimals(feeElement.amount, asset.decimals, api)
|
|
4182
|
+
});
|
|
4210
4183
|
};
|
|
4211
4184
|
|
|
4212
4185
|
var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
@@ -4218,9 +4191,10 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
|
4218
4191
|
destination = _ref.destination,
|
|
4219
4192
|
swapConfig = _ref.swapConfig,
|
|
4220
4193
|
asset = _ref.asset,
|
|
4194
|
+
currentAsset = _ref.currentAsset,
|
|
4221
4195
|
hasPassedExchange = _ref.hasPassedExchange,
|
|
4222
4196
|
currency = _ref.currency;
|
|
4223
|
-
var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
|
|
4197
|
+
var isRelayAssetIncluded = !Array.isArray(currency) && api.getTypeThenAssetCount(tx) === 2;
|
|
4224
4198
|
var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
|
|
4225
4199
|
if (useRelayAssetAsFee) {
|
|
4226
4200
|
return api.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
@@ -4228,7 +4202,7 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
|
|
|
4228
4202
|
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
4229
4203
|
return api.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
4230
4204
|
}
|
|
4231
|
-
return (_api$findAssetInfoOnD = api.findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD :
|
|
4205
|
+
return (_api$findAssetInfoOnD = api.findAssetInfoOnDest(originChain, currentChain, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : currentAsset;
|
|
4232
4206
|
};
|
|
4233
4207
|
|
|
4234
4208
|
var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge, api) {
|
|
@@ -4304,60 +4278,22 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
|
|
|
4304
4278
|
}
|
|
4305
4279
|
if (Array.isArray(currency)) {
|
|
4306
4280
|
if (!feeAsset) {
|
|
4307
|
-
throw new InvalidCurrencyError('Overridden
|
|
4281
|
+
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4308
4282
|
}
|
|
4309
4283
|
if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
|
|
4310
4284
|
throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
|
|
4311
4285
|
}
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
throw new InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
|
|
4320
|
-
}
|
|
4321
|
-
return currency.map(function (asset) {
|
|
4322
|
-
var ml = extractAssetLocation(asset);
|
|
4323
|
-
return _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
4324
|
-
fun: {
|
|
4325
|
-
Fungible: BigInt(asset.fun.Fungible)
|
|
4326
|
-
},
|
|
4327
|
-
isFeeAsset: deepEqual(ml, feeAsset.location)
|
|
4328
|
-
});
|
|
4329
|
-
});
|
|
4330
|
-
}
|
|
4331
|
-
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
4332
|
-
var assets = currency.map(function (currency) {
|
|
4333
|
-
if (currency.amount === AMOUNT_ALL) {
|
|
4334
|
-
throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
|
|
4335
|
-
}
|
|
4336
|
-
var asset = api.findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
|
|
4337
|
-
if (!asset) {
|
|
4338
|
-
throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
4339
|
-
}
|
|
4340
|
-
if (!resolvedFeeAsset) {
|
|
4341
|
-
throw new InvalidCurrencyError('Fee asset not found');
|
|
4342
|
-
}
|
|
4343
|
-
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
4344
|
-
var version = getChainVersion(api, origin);
|
|
4345
|
-
var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
4286
|
+
assertNotRawAssets(currency);
|
|
4287
|
+
var version = getChainVersion(api, origin);
|
|
4288
|
+
var _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination, function (asset) {
|
|
4289
|
+
return validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
4290
|
+
}),
|
|
4291
|
+
assets = _resolveCurrency.assets;
|
|
4292
|
+
return sortAssets(assets.map(function (asset) {
|
|
4346
4293
|
return _objectSpread2({
|
|
4347
|
-
isFeeAsset:
|
|
4348
|
-
}, createAsset(version,
|
|
4349
|
-
});
|
|
4350
|
-
if (assets.filter(function (asset) {
|
|
4351
|
-
return asset.isFeeAsset;
|
|
4352
|
-
}).length > 1) {
|
|
4353
|
-
throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
4354
|
-
}
|
|
4355
|
-
if (assets.filter(function (asset) {
|
|
4356
|
-
return asset.isFeeAsset;
|
|
4357
|
-
}).length === 0) {
|
|
4358
|
-
throw new InvalidCurrencyError("Fee asset not found in multiassets");
|
|
4359
|
-
}
|
|
4360
|
-
return assets;
|
|
4294
|
+
isFeeAsset: asset.isFeeAsset
|
|
4295
|
+
}, createAsset(version, asset.amount, asset.location));
|
|
4296
|
+
}));
|
|
4361
4297
|
}
|
|
4362
4298
|
return undefined;
|
|
4363
4299
|
};
|
|
@@ -4369,79 +4305,8 @@ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency)
|
|
|
4369
4305
|
return !(isMultipleAssets || hasOverriddenLocation);
|
|
4370
4306
|
};
|
|
4371
4307
|
|
|
4372
|
-
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
4373
|
-
if (Array.isArray(currency)) {
|
|
4374
|
-
if (currency.length === 0) {
|
|
4375
|
-
throw new InvalidCurrencyError('Overridden assets cannot be empty');
|
|
4376
|
-
}
|
|
4377
|
-
if (currency.length === 1) {
|
|
4378
|
-
throw new InvalidCurrencyError('Please provide more than one asset');
|
|
4379
|
-
}
|
|
4380
|
-
if (currency.length > 1 && !currency.every(function (asset) {
|
|
4381
|
-
return isTAsset(asset);
|
|
4382
|
-
}) && !feeAsset) {
|
|
4383
|
-
throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
|
|
4384
|
-
}
|
|
4385
|
-
}
|
|
4386
|
-
};
|
|
4387
|
-
var validateDestination = function validateDestination(origin, destination, api) {
|
|
4388
|
-
if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
4389
|
-
throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
4390
|
-
}
|
|
4391
|
-
if (typeof destination === 'string' && isExternalChain(destination) && !ETHEREUM_BRIDGE_ORIGINS.includes(origin)) {
|
|
4392
|
-
throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(ETHEREUM_BRIDGE_ORIGINS.join(', ')));
|
|
4393
|
-
}
|
|
4394
|
-
var isLocationDestination = _typeof(destination) === 'object';
|
|
4395
|
-
var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
|
|
4396
|
-
if (!isLocationDestination) {
|
|
4397
|
-
var originRelayChainSymbol = getRelayChainSymbolImpl(origin, api._customCtx);
|
|
4398
|
-
var destinationRelayChainSymbol = getRelayChainSymbolImpl(destination, api._customCtx);
|
|
4399
|
-
if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
4400
|
-
throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
|
|
4401
|
-
}
|
|
4402
|
-
}
|
|
4403
|
-
if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
|
|
4404
|
-
var chain = getChain(destination);
|
|
4405
|
-
if (!chain.isRelayToParaEnabled()) {
|
|
4406
|
-
throw new ScenarioNotSupportedError({
|
|
4407
|
-
chain: destination,
|
|
4408
|
-
scenario: 'RelayToPara'
|
|
4409
|
-
});
|
|
4410
|
-
}
|
|
4411
|
-
}
|
|
4412
|
-
};
|
|
4413
|
-
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
4414
|
-
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
4415
|
-
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
4416
|
-
}
|
|
4417
|
-
if (!assetCheckEnabled && 'id' in currency) {
|
|
4418
|
-
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
4419
|
-
}
|
|
4420
|
-
};
|
|
4421
|
-
var validateTransact = function validateTransact(_ref) {
|
|
4422
|
-
var api = _ref.api,
|
|
4423
|
-
from = _ref.from,
|
|
4424
|
-
to = _ref.to,
|
|
4425
|
-
sender = _ref.sender,
|
|
4426
|
-
address = _ref.recipient,
|
|
4427
|
-
transactOptions = _ref.transactOptions;
|
|
4428
|
-
var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
|
|
4429
|
-
if (!call) return;
|
|
4430
|
-
if (from === to) {
|
|
4431
|
-
throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
|
|
4432
|
-
}
|
|
4433
|
-
if (typeof call === 'string' && !isHex(call)) {
|
|
4434
|
-
throw new ValidationError('Transact call hex must be a valid hex string.');
|
|
4435
|
-
}
|
|
4436
|
-
if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
|
|
4437
|
-
throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
|
|
4438
|
-
}
|
|
4439
|
-
if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
|
|
4440
|
-
return new ValidationError('Sender address must match the destination address for transact to work.');
|
|
4441
|
-
}
|
|
4442
|
-
};
|
|
4443
|
-
|
|
4444
4308
|
var resolveTransferParams = function resolveTransferParams(options) {
|
|
4309
|
+
var _resolvedFeeAsset$amo;
|
|
4445
4310
|
var api = options.api,
|
|
4446
4311
|
origin = options.from,
|
|
4447
4312
|
currency = options.currency,
|
|
@@ -4469,18 +4334,8 @@ var resolveTransferParams = function resolveTransferParams(options) {
|
|
|
4469
4334
|
var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
4470
4335
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
4471
4336
|
};
|
|
4472
|
-
var finalAsset = Array.isArray(currency) ?
|
|
4473
|
-
|
|
4474
|
-
// since these values won't be used but need to pass checks
|
|
4475
|
-
_objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
4476
|
-
amount: 0n,
|
|
4477
|
-
assetId: '1',
|
|
4478
|
-
location: {
|
|
4479
|
-
parents: Parents.ZERO,
|
|
4480
|
-
interior: {
|
|
4481
|
-
Here: null
|
|
4482
|
-
}
|
|
4483
|
-
}
|
|
4337
|
+
var finalAsset = Array.isArray(currency) && resolvedFeeAsset ? _objectSpread2(_objectSpread2({}, resolvedFeeAsset), {}, {
|
|
4338
|
+
amount: (_resolvedFeeAsset$amo = resolvedFeeAsset.amount) !== null && _resolvedFeeAsset$amo !== void 0 ? _resolvedFeeAsset$amo : 0n
|
|
4484
4339
|
}) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
4485
4340
|
amount: finalAmount
|
|
4486
4341
|
});
|
|
@@ -5816,16 +5671,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5816
5671
|
return _getOriginXcmFee2.apply(this, arguments);
|
|
5817
5672
|
}
|
|
5818
5673
|
return getOriginXcmFee$1;
|
|
5819
|
-
}()
|
|
5820
|
-
/**
|
|
5821
|
-
* Returns the max transferable amount for the transfer
|
|
5822
|
-
*
|
|
5823
|
-
* @returns The max transferable amount.
|
|
5824
|
-
*/
|
|
5825
|
-
)
|
|
5674
|
+
}())
|
|
5826
5675
|
}, {
|
|
5827
5676
|
key: "getTransferableAmount",
|
|
5828
|
-
value:
|
|
5677
|
+
value: function () {
|
|
5829
5678
|
var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
5830
5679
|
var senderSource, _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
|
|
5831
5680
|
return _regenerator().w(function (_context11) {
|
|
@@ -5870,15 +5719,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5870
5719
|
}
|
|
5871
5720
|
return getTransferableAmount$1;
|
|
5872
5721
|
}()
|
|
5873
|
-
/**
|
|
5874
|
-
* Returns the min transferable amount for the transfer
|
|
5875
|
-
*
|
|
5876
|
-
* @returns The min transferable amount.
|
|
5877
|
-
*/
|
|
5878
|
-
)
|
|
5879
5722
|
}, {
|
|
5880
5723
|
key: "getMinTransferableAmount",
|
|
5881
|
-
value:
|
|
5724
|
+
value: function () {
|
|
5882
5725
|
var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
5883
5726
|
var senderSource, _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
|
|
5884
5727
|
return _regenerator().w(function (_context12) {
|
|
@@ -5931,7 +5774,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5931
5774
|
*
|
|
5932
5775
|
* @returns The max transferable amount.
|
|
5933
5776
|
*/
|
|
5934
|
-
)
|
|
5935
5777
|
}, {
|
|
5936
5778
|
key: "verifyEdOnDestination",
|
|
5937
5779
|
value: (function () {
|
|
@@ -5970,16 +5812,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5970
5812
|
return _verifyEdOnDestination2.apply(this, arguments);
|
|
5971
5813
|
}
|
|
5972
5814
|
return verifyEdOnDestination$1;
|
|
5973
|
-
}()
|
|
5974
|
-
/**
|
|
5975
|
-
* Returns the transfer info for the transfer
|
|
5976
|
-
*
|
|
5977
|
-
* @returns The transfer info.
|
|
5978
|
-
*/
|
|
5979
|
-
)
|
|
5815
|
+
}())
|
|
5980
5816
|
}, {
|
|
5981
5817
|
key: "getTransferInfo",
|
|
5982
|
-
value:
|
|
5818
|
+
value: function () {
|
|
5983
5819
|
var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
5984
5820
|
var senderSource, _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, recipient, currency, ahAddress, sender, feeAsset, version, swapOptions;
|
|
5985
5821
|
return _regenerator().w(function (_context14) {
|
|
@@ -6028,18 +5864,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
6028
5864
|
}
|
|
6029
5865
|
return getTransferInfo$1;
|
|
6030
5866
|
}()
|
|
6031
|
-
/**
|
|
6032
|
-
* Returns the receivable amount on the destination after the transfer
|
|
6033
|
-
*
|
|
6034
|
-
* @returns The computed receivable amount.
|
|
6035
|
-
* @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
|
|
6036
|
-
*/
|
|
6037
|
-
)
|
|
6038
5867
|
}, {
|
|
6039
5868
|
key: "getReceivableAmount",
|
|
6040
|
-
value:
|
|
5869
|
+
value: function () {
|
|
6041
5870
|
var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
6042
|
-
var _yield$this$getTransf,
|
|
5871
|
+
var _yield$this$getTransf, receivedCurrency, getAmountOrThrow;
|
|
6043
5872
|
return _regenerator().w(function (_context15) {
|
|
6044
5873
|
while (1) switch (_context15.n) {
|
|
6045
5874
|
case 0:
|
|
@@ -6047,14 +5876,15 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
6047
5876
|
return this.getTransferInfo();
|
|
6048
5877
|
case 1:
|
|
6049
5878
|
_yield$this$getTransf = _context15.v;
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
5879
|
+
receivedCurrency = _yield$this$getTransf.destination.receivedCurrency;
|
|
5880
|
+
getAmountOrThrow = function getAmountOrThrow(_ref) {
|
|
5881
|
+
var receivedAmount = _ref.receivedAmount;
|
|
5882
|
+
if (receivedAmount instanceof UnableToComputeError) {
|
|
5883
|
+
throw receivedAmount;
|
|
5884
|
+
}
|
|
5885
|
+
return receivedAmount;
|
|
5886
|
+
};
|
|
5887
|
+
return _context15.a(2, Array.isArray(receivedCurrency) ? receivedCurrency.map(getAmountOrThrow) : getAmountOrThrow(receivedCurrency));
|
|
6058
5888
|
}
|
|
6059
5889
|
}, _callee15, this);
|
|
6060
5890
|
}));
|
|
@@ -6062,7 +5892,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
6062
5892
|
return _getReceivableAmount.apply(this, arguments);
|
|
6063
5893
|
}
|
|
6064
5894
|
return getReceivableAmount;
|
|
6065
|
-
}()
|
|
5895
|
+
}()
|
|
6066
5896
|
}, {
|
|
6067
5897
|
key: "getBestAmountOut",
|
|
6068
5898
|
value: function () {
|
|
@@ -6494,7 +6324,7 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
|
|
|
6494
6324
|
}();
|
|
6495
6325
|
|
|
6496
6326
|
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
6497
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative,
|
|
6327
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative, asset, feeAsset) {
|
|
6498
6328
|
var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
|
|
6499
6329
|
return _regenerator().w(function (_context) {
|
|
6500
6330
|
while (1) switch (_context.n) {
|
|
@@ -6520,7 +6350,7 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6520
6350
|
_context.n = 3;
|
|
6521
6351
|
break;
|
|
6522
6352
|
}
|
|
6523
|
-
return _context.a(2, balanceNative - edNative - feeNative -
|
|
6353
|
+
return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
|
|
6524
6354
|
case 3:
|
|
6525
6355
|
if (isNativeAssetToOrigin) {
|
|
6526
6356
|
_context.n = 5;
|
|
@@ -6540,18 +6370,18 @@ var isSufficientOrigin = /*#__PURE__*/function () {
|
|
|
6540
6370
|
isSufficientAsset = balanceAsset - edAsset > 0n;
|
|
6541
6371
|
return _context.a(2, isSufficientNative && isSufficientAsset);
|
|
6542
6372
|
case 5:
|
|
6543
|
-
return _context.a(2, balanceNative - edNative - feeNative -
|
|
6373
|
+
return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
|
|
6544
6374
|
case 6:
|
|
6545
6375
|
return _context.a(2);
|
|
6546
6376
|
}
|
|
6547
6377
|
}, _callee);
|
|
6548
6378
|
}));
|
|
6549
|
-
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7
|
|
6379
|
+
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
|
6550
6380
|
return _ref.apply(this, arguments);
|
|
6551
6381
|
};
|
|
6552
6382
|
}();
|
|
6553
6383
|
var isSufficientDestination = /*#__PURE__*/function () {
|
|
6554
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address,
|
|
6384
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, asset, feeNative) {
|
|
6555
6385
|
var isNativeAsset, existentialDeposit, nativeBalance;
|
|
6556
6386
|
return _regenerator().w(function (_context2) {
|
|
6557
6387
|
while (1) switch (_context2.n) {
|
|
@@ -6572,11 +6402,11 @@ var isSufficientDestination = /*#__PURE__*/function () {
|
|
|
6572
6402
|
});
|
|
6573
6403
|
case 2:
|
|
6574
6404
|
nativeBalance = _context2.v;
|
|
6575
|
-
return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
|
|
6405
|
+
return _context2.a(2, nativeBalance + asset.amount - existentialDeposit - feeNative > 0n);
|
|
6576
6406
|
}
|
|
6577
6407
|
}, _callee2);
|
|
6578
6408
|
}));
|
|
6579
|
-
return function isSufficientDestination(_x9, _x0, _x1, _x10
|
|
6409
|
+
return function isSufficientDestination(_x8, _x9, _x0, _x1, _x10) {
|
|
6580
6410
|
return _ref2.apply(this, arguments);
|
|
6581
6411
|
};
|
|
6582
6412
|
}();
|
|
@@ -6592,15 +6422,15 @@ var createOriginLocation = function createOriginLocation(origin, destination, ve
|
|
|
6592
6422
|
};
|
|
6593
6423
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
6594
6424
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
6595
|
-
var api, origin, hopChain, destination, currency,
|
|
6425
|
+
var api, origin, hopChain, destination, currency, asset, currentAsset, forwardedXcms, recipient, feeAsset, originFee, tx, version, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
6596
6426
|
return _regenerator().w(function (_context3) {
|
|
6597
6427
|
while (1) switch (_context3.n) {
|
|
6598
6428
|
case 0:
|
|
6599
|
-
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency,
|
|
6429
|
+
api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, asset = options.asset, currentAsset = options.currentAsset, forwardedXcms = options.forwardedXcms, recipient = options.recipient, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, version = options.version, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
|
|
6600
6430
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
6601
6431
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
6602
6432
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
6603
|
-
var
|
|
6433
|
+
var reverseFeeFor, swapAsset, _t2;
|
|
6604
6434
|
return _regenerator().w(function (_context2) {
|
|
6605
6435
|
while (1) switch (_context2.p = _context2.n) {
|
|
6606
6436
|
case 0:
|
|
@@ -6610,53 +6440,52 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6610
6440
|
}
|
|
6611
6441
|
return _context2.a(2, 0n);
|
|
6612
6442
|
case 1:
|
|
6613
|
-
|
|
6614
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(
|
|
6615
|
-
var
|
|
6443
|
+
reverseFeeFor = /*#__PURE__*/function () {
|
|
6444
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(assetInfo, amount) {
|
|
6445
|
+
var _t;
|
|
6616
6446
|
return _regenerator().w(function (_context) {
|
|
6617
6447
|
while (1) switch (_context.p = _context.n) {
|
|
6618
6448
|
case 0:
|
|
6619
|
-
|
|
6620
|
-
_context.
|
|
6621
|
-
_context.n = 2;
|
|
6449
|
+
_context.p = 0;
|
|
6450
|
+
_context.n = 1;
|
|
6622
6451
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
6623
6452
|
destination: destination
|
|
6624
6453
|
}), {
|
|
6625
6454
|
location: assetInfo.location,
|
|
6626
|
-
amount:
|
|
6455
|
+
amount: amount
|
|
6627
6456
|
});
|
|
6628
|
-
case
|
|
6457
|
+
case 1:
|
|
6629
6458
|
return _context.a(2, _context.v);
|
|
6630
|
-
case
|
|
6631
|
-
_context.p =
|
|
6459
|
+
case 2:
|
|
6460
|
+
_context.p = 2;
|
|
6632
6461
|
_t = _context.v;
|
|
6633
6462
|
if (!(_t instanceof InvalidCurrencyError)) {
|
|
6634
|
-
_context.n =
|
|
6463
|
+
_context.n = 4;
|
|
6635
6464
|
break;
|
|
6636
6465
|
}
|
|
6637
|
-
_context.n =
|
|
6466
|
+
_context.n = 3;
|
|
6638
6467
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
6639
6468
|
destination: destination
|
|
6640
6469
|
}), {
|
|
6641
6470
|
symbol: assetInfo.symbol,
|
|
6642
|
-
amount:
|
|
6471
|
+
amount: amount
|
|
6643
6472
|
});
|
|
6644
|
-
case
|
|
6473
|
+
case 3:
|
|
6645
6474
|
return _context.a(2, _context.v);
|
|
6646
|
-
case
|
|
6475
|
+
case 4:
|
|
6647
6476
|
throw _t;
|
|
6648
|
-
case
|
|
6477
|
+
case 5:
|
|
6649
6478
|
return _context.a(2);
|
|
6650
6479
|
}
|
|
6651
|
-
}, _callee, null, [[
|
|
6480
|
+
}, _callee, null, [[0, 2]]);
|
|
6652
6481
|
}));
|
|
6653
|
-
return function
|
|
6482
|
+
return function reverseFeeFor(_x2, _x3) {
|
|
6654
6483
|
return _ref3.apply(this, arguments);
|
|
6655
6484
|
};
|
|
6656
6485
|
}();
|
|
6657
6486
|
_context2.p = 2;
|
|
6658
6487
|
_context2.n = 3;
|
|
6659
|
-
return
|
|
6488
|
+
return reverseFeeFor(asset, asset.amount);
|
|
6660
6489
|
case 3:
|
|
6661
6490
|
return _context2.a(2, _context2.v);
|
|
6662
6491
|
case 4:
|
|
@@ -6668,8 +6497,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6668
6497
|
}
|
|
6669
6498
|
return _context2.a(2, 0n);
|
|
6670
6499
|
case 5:
|
|
6500
|
+
swapAsset = api.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo, destination);
|
|
6671
6501
|
_context2.n = 6;
|
|
6672
|
-
return
|
|
6502
|
+
return reverseFeeFor(swapAsset, swapConfig.amountOut);
|
|
6673
6503
|
case 6:
|
|
6674
6504
|
return _context2.a(2, _context2.v);
|
|
6675
6505
|
}
|
|
@@ -6688,14 +6518,14 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6688
6518
|
case 1:
|
|
6689
6519
|
_fee = _context3.v;
|
|
6690
6520
|
_context3.n = 2;
|
|
6691
|
-
return isSufficientDestination(api, destination, recipient,
|
|
6521
|
+
return isSufficientDestination(api, destination, recipient, currentAsset, _fee);
|
|
6692
6522
|
case 2:
|
|
6693
6523
|
sufficient = _context3.v;
|
|
6694
6524
|
return _context3.a(2, {
|
|
6695
6525
|
fee: _fee,
|
|
6696
6526
|
feeType: 'paymentInfo',
|
|
6697
6527
|
sufficient: sufficient,
|
|
6698
|
-
asset:
|
|
6528
|
+
asset: currentAsset
|
|
6699
6529
|
});
|
|
6700
6530
|
case 3:
|
|
6701
6531
|
_context3.n = 4;
|
|
@@ -6705,11 +6535,11 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6705
6535
|
xcm: forwardedXcms[1][0],
|
|
6706
6536
|
chain: destination,
|
|
6707
6537
|
origin: origin,
|
|
6708
|
-
asset:
|
|
6538
|
+
asset: currentAsset,
|
|
6709
6539
|
version: version,
|
|
6710
6540
|
originFee: originFee,
|
|
6711
6541
|
feeAsset: resolvedFeeAsset,
|
|
6712
|
-
amount: normalizeAmount(
|
|
6542
|
+
amount: normalizeAmount(currentAsset.amount)
|
|
6713
6543
|
});
|
|
6714
6544
|
case 4:
|
|
6715
6545
|
dryRunResult = _context3.v;
|
|
@@ -6736,7 +6566,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6736
6566
|
dryRunError: dryRunResult.failureReason,
|
|
6737
6567
|
dryRunSubError: dryRunResult.failureSubReason,
|
|
6738
6568
|
sufficient: false,
|
|
6739
|
-
asset:
|
|
6569
|
+
asset: currentAsset
|
|
6740
6570
|
});
|
|
6741
6571
|
case 7:
|
|
6742
6572
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
@@ -6746,7 +6576,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6746
6576
|
sufficient: true,
|
|
6747
6577
|
forwardedXcms: newForwardedXcms,
|
|
6748
6578
|
destParaId: destParaId,
|
|
6749
|
-
asset:
|
|
6579
|
+
asset: currentAsset
|
|
6750
6580
|
});
|
|
6751
6581
|
}
|
|
6752
6582
|
}, _callee3);
|
|
@@ -6756,6 +6586,17 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
6756
6586
|
};
|
|
6757
6587
|
}();
|
|
6758
6588
|
|
|
6589
|
+
var toFailureInfo = function toFailureInfo(failureChain, _ref) {
|
|
6590
|
+
var failureReason = _ref.failureReason,
|
|
6591
|
+
failureSubReason = _ref.failureSubReason,
|
|
6592
|
+
failureIndex = _ref.failureIndex;
|
|
6593
|
+
return {
|
|
6594
|
+
failureChain: failureChain,
|
|
6595
|
+
failureReason: failureReason,
|
|
6596
|
+
failureSubReason: failureSubReason,
|
|
6597
|
+
failureIndex: failureIndex
|
|
6598
|
+
};
|
|
6599
|
+
};
|
|
6759
6600
|
var getFailureInfo$1 = function getFailureInfo(result) {
|
|
6760
6601
|
var orderedChecks = [{
|
|
6761
6602
|
chain: 'origin',
|
|
@@ -6777,11 +6618,7 @@ var getFailureInfo$1 = function getFailureInfo(result) {
|
|
|
6777
6618
|
chain = _step$value.chain,
|
|
6778
6619
|
chainResult = _step$value.chainResult;
|
|
6779
6620
|
if (chainResult && chainResult.success === false && chainResult.failureReason) {
|
|
6780
|
-
return
|
|
6781
|
-
failureChain: chain,
|
|
6782
|
-
failureReason: chainResult.failureReason,
|
|
6783
|
-
failureSubReason: chainResult.failureSubReason
|
|
6784
|
-
};
|
|
6621
|
+
return toFailureInfo(chain, chainResult);
|
|
6785
6622
|
}
|
|
6786
6623
|
}
|
|
6787
6624
|
} catch (err) {
|
|
@@ -6789,11 +6626,7 @@ var getFailureInfo$1 = function getFailureInfo(result) {
|
|
|
6789
6626
|
} finally {
|
|
6790
6627
|
_iterator.f();
|
|
6791
6628
|
}
|
|
6792
|
-
return
|
|
6793
|
-
failureChain: result.failureChain,
|
|
6794
|
-
failureReason: result.failureReason,
|
|
6795
|
-
failureSubReason: result.failureSubReason
|
|
6796
|
-
};
|
|
6629
|
+
return toFailureInfo(result.failureChain, result);
|
|
6797
6630
|
};
|
|
6798
6631
|
|
|
6799
6632
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
@@ -7503,15 +7336,14 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
7503
7336
|
|
|
7504
7337
|
var traverseXcmHops = /*#__PURE__*/function () {
|
|
7505
7338
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
|
|
7506
|
-
var api, origin, destination,
|
|
7339
|
+
var api, origin, destination, asset, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, currentOrigin, forwardedXcms, nextParaId, currentAsset, hasPassedExchange, hops, destinationResult, nextChain, hopApi, isDestination, hopResult, _extractNextHopData, newXcms, destParaId;
|
|
7507
7340
|
return _regenerator().w(function (_context) {
|
|
7508
7341
|
while (1) switch (_context.p = _context.n) {
|
|
7509
7342
|
case 0:
|
|
7510
|
-
api = config.api, origin = config.origin, destination = config.destination,
|
|
7343
|
+
api = config.api, origin = config.origin, destination = config.destination, asset = config.asset, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
|
|
7511
7344
|
currentOrigin = origin;
|
|
7512
7345
|
forwardedXcms = initialForwardedXcms;
|
|
7513
7346
|
nextParaId = initialDestParaId;
|
|
7514
|
-
asset = api.findAssetInfoOrThrow(origin, currency, destination);
|
|
7515
7347
|
currentAsset = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain) ? api.findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo) : asset;
|
|
7516
7348
|
hasPassedExchange = origin === (swapConfig === null || swapConfig === void 0 ? void 0 : swapConfig.exchangeChain);
|
|
7517
7349
|
hops = [];
|
|
@@ -7631,15 +7463,14 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
7631
7463
|
|
|
7632
7464
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
7633
7465
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
7634
|
-
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin,
|
|
7466
|
+
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, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
7635
7467
|
return _regenerator().w(function (_context2) {
|
|
7636
7468
|
while (1) switch (_context2.n) {
|
|
7637
7469
|
case 0:
|
|
7638
7470
|
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;
|
|
7639
|
-
assertCurrencyCore(currency);
|
|
7640
|
-
asset = api.findAssetInfoOrThrow(origin, currency, destination);
|
|
7641
7471
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
7642
|
-
|
|
7472
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
7473
|
+
amount = asset.amount;
|
|
7643
7474
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
7644
7475
|
_context2.n = 1;
|
|
7645
7476
|
return api.getDryRunCall({
|
|
@@ -7650,6 +7481,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7650
7481
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
7651
7482
|
amount: amount
|
|
7652
7483
|
}),
|
|
7484
|
+
assets: assets,
|
|
7653
7485
|
feeAsset: resolvedFeeAsset,
|
|
7654
7486
|
version: resolvedVersion,
|
|
7655
7487
|
bypassOptions: bypassOptions,
|
|
@@ -7707,7 +7539,8 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7707
7539
|
originChain: origin,
|
|
7708
7540
|
currentChain: currentChain,
|
|
7709
7541
|
destination: destination,
|
|
7710
|
-
asset:
|
|
7542
|
+
asset: asset,
|
|
7543
|
+
currentAsset: currentAsset,
|
|
7711
7544
|
currency: currency,
|
|
7712
7545
|
swapConfig: swapConfig,
|
|
7713
7546
|
hasPassedExchange: hasPassedExchange
|
|
@@ -7753,7 +7586,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
7753
7586
|
api: api,
|
|
7754
7587
|
origin: origin,
|
|
7755
7588
|
destination: destination,
|
|
7756
|
-
|
|
7589
|
+
asset: asset,
|
|
7757
7590
|
initialForwardedXcms: initialForwardedXcms,
|
|
7758
7591
|
initialDestParaId: initialDestParaId,
|
|
7759
7592
|
swapConfig: swapConfig,
|
|
@@ -7897,23 +7730,8 @@ var resolveBypassMintAmount = function resolveBypassMintAmount(chain) {
|
|
|
7897
7730
|
return c === chain;
|
|
7898
7731
|
}) ? HIGH_BYPASS_MINT_AMOUNT : BYPASS_MINT_AMOUNT;
|
|
7899
7732
|
};
|
|
7900
|
-
var pickOtherPallet = function pickOtherPallet(asset, pallets) {
|
|
7901
|
-
if (!asset.isNative && (!asset.assetId || asset.assetId.startsWith('0x'))) {
|
|
7902
|
-
var _pallets$find;
|
|
7903
|
-
// No assetId means it's probably a ForeignAssets pallet asset
|
|
7904
|
-
return (_pallets$find = pallets.find(function (pallet) {
|
|
7905
|
-
return pallet.startsWith('Foreign');
|
|
7906
|
-
})) !== null && _pallets$find !== void 0 ? _pallets$find : pallets[0];
|
|
7907
|
-
}
|
|
7908
|
-
return pallets[0];
|
|
7909
|
-
};
|
|
7910
7733
|
var createMintTxs = function createMintTxs(chain, asset, balance, address, api) {
|
|
7911
|
-
|
|
7912
|
-
var otherPallets = getOtherAssetsPallets(chain, api._customCtx);
|
|
7913
|
-
var isMainNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbolImpl(chain, api._customCtx));
|
|
7914
|
-
var pallet = !asset.isNative && chain !== 'Mythos' || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
7915
|
-
var palletInstance = getPalletInstance(pallet);
|
|
7916
|
-
return palletInstance.mint(api, address, asset, balance, chain);
|
|
7734
|
+
return getChainImpl(chain, api._customCtx).mint(api, address, asset, balance);
|
|
7917
7735
|
};
|
|
7918
7736
|
var createRequiredMintTxs = function createRequiredMintTxs(chain, asset, amountHuman, balance, address, api) {
|
|
7919
7737
|
var amount = parseUnits(amountHuman, asset.decimals);
|
|
@@ -7965,7 +7783,8 @@ var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeA
|
|
|
7965
7783
|
}) ? parseUnits(resolveBypassMintAmount(chain), sent.decimals) : 0n;
|
|
7966
7784
|
};
|
|
7967
7785
|
var wrapTxBypass = /*#__PURE__*/function () {
|
|
7968
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
7786
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dryRunOptions) {
|
|
7787
|
+
var _dryRunOptions$assets;
|
|
7969
7788
|
var options,
|
|
7970
7789
|
api,
|
|
7971
7790
|
chain,
|
|
@@ -7983,21 +7802,15 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
7983
7802
|
mintRelayAssetRes,
|
|
7984
7803
|
mintFeeAssetRes,
|
|
7985
7804
|
amount,
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
_calcPreviewMintAmoun,
|
|
7990
|
-
missing,
|
|
7991
|
-
total,
|
|
7992
|
-
mintAssetRes,
|
|
7993
|
-
_args = arguments,
|
|
7805
|
+
mintSentAsset,
|
|
7806
|
+
mintAssetResults,
|
|
7807
|
+
_args2 = arguments,
|
|
7994
7808
|
_t,
|
|
7995
|
-
_t2
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
while (1) switch (_context.n) {
|
|
7809
|
+
_t2;
|
|
7810
|
+
return _regenerator().w(function (_context2) {
|
|
7811
|
+
while (1) switch (_context2.n) {
|
|
7999
7812
|
case 0:
|
|
8000
|
-
options =
|
|
7813
|
+
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {
|
|
8001
7814
|
mintFeeAssets: true,
|
|
8002
7815
|
sentAssetMintMode: 'bypass'
|
|
8003
7816
|
};
|
|
@@ -8016,84 +7829,87 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
8016
7829
|
relayInfo = mintFeeAssets ? api.findAssetInfo(chain, relayCurrency) : null;
|
|
8017
7830
|
sameNativeRelay = !!(nativeInfo && relayInfo && isAssetXcEqual(nativeInfo, relayInfo));
|
|
8018
7831
|
if (!mintFeeAssets) {
|
|
8019
|
-
|
|
7832
|
+
_context2.n = 2;
|
|
8020
7833
|
break;
|
|
8021
7834
|
}
|
|
8022
|
-
|
|
7835
|
+
_context2.n = 1;
|
|
8023
7836
|
return createRequiredMintTxs(chain, api.findNativeAssetInfoOrThrow(chain), bypassMintAmount, 0n, address, api);
|
|
8024
7837
|
case 1:
|
|
8025
|
-
_t =
|
|
8026
|
-
|
|
7838
|
+
_t = _context2.v;
|
|
7839
|
+
_context2.n = 3;
|
|
8027
7840
|
break;
|
|
8028
7841
|
case 2:
|
|
8029
7842
|
_t = null;
|
|
8030
7843
|
case 3:
|
|
8031
7844
|
mintNativeAssetRes = _t;
|
|
8032
7845
|
if (!(mintFeeAssets && !sameNativeRelay)) {
|
|
8033
|
-
|
|
7846
|
+
_context2.n = 5;
|
|
8034
7847
|
break;
|
|
8035
7848
|
}
|
|
8036
|
-
|
|
7849
|
+
_context2.n = 4;
|
|
8037
7850
|
return createOptionalMintTxs(chain, relayCurrency, bypassMintAmount, 0n, address, api);
|
|
8038
7851
|
case 4:
|
|
8039
|
-
_t2 =
|
|
8040
|
-
|
|
7852
|
+
_t2 = _context2.v;
|
|
7853
|
+
_context2.n = 6;
|
|
8041
7854
|
break;
|
|
8042
7855
|
case 5:
|
|
8043
7856
|
_t2 = null;
|
|
8044
7857
|
case 6:
|
|
8045
7858
|
mintRelayAssetRes = _t2;
|
|
8046
7859
|
if (!(feeAsset && mintFeeAssets)) {
|
|
8047
|
-
|
|
7860
|
+
_context2.n = 8;
|
|
8048
7861
|
break;
|
|
8049
7862
|
}
|
|
8050
7863
|
amount = parseUnits(bypassMintAmount, feeAsset.decimals);
|
|
8051
|
-
|
|
7864
|
+
_context2.n = 7;
|
|
8052
7865
|
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, feeAsset), {}, {
|
|
8053
7866
|
amount: amount
|
|
8054
7867
|
}), 0n, address, api);
|
|
8055
7868
|
case 7:
|
|
8056
|
-
mintFeeAssetRes =
|
|
7869
|
+
mintFeeAssetRes = _context2.v;
|
|
8057
7870
|
case 8:
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
7871
|
+
mintSentAsset = /*#__PURE__*/function () {
|
|
7872
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sentAsset) {
|
|
7873
|
+
var balance, bonus, mintAmount, _calcPreviewMintAmoun, missing, total;
|
|
7874
|
+
return _regenerator().w(function (_context) {
|
|
7875
|
+
while (1) switch (_context.n) {
|
|
7876
|
+
case 0:
|
|
7877
|
+
_context.n = 1;
|
|
7878
|
+
return getAssetBalanceInternal({
|
|
7879
|
+
api: api,
|
|
7880
|
+
chain: chain,
|
|
7881
|
+
address: address,
|
|
7882
|
+
asset: sentAsset
|
|
7883
|
+
});
|
|
7884
|
+
case 1:
|
|
7885
|
+
balance = _context.v;
|
|
7886
|
+
bonus = mintBonusForSent(chain, sentAsset, feeAsset, !!mintFeeAssets, api);
|
|
7887
|
+
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
7888
|
+
mintAmount = parseUnits(bypassMintAmount, sentAsset.decimals) + sentAsset.amount;
|
|
7889
|
+
} else {
|
|
7890
|
+
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, sentAsset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
7891
|
+
total = missing + bonus;
|
|
7892
|
+
mintAmount = total > 0n ? total : null;
|
|
7893
|
+
}
|
|
7894
|
+
return _context.a(2, mintAmount !== null ? createMintTxs(chain, _objectSpread2(_objectSpread2({}, sentAsset), {}, {
|
|
7895
|
+
amount: mintAmount
|
|
7896
|
+
}), balance, address, api) : null);
|
|
7897
|
+
}
|
|
7898
|
+
}, _callee);
|
|
7899
|
+
}));
|
|
7900
|
+
return function mintSentAsset(_x2) {
|
|
7901
|
+
return _ref3.apply(this, arguments);
|
|
7902
|
+
};
|
|
7903
|
+
}(); // mint assets that are being sent
|
|
7904
|
+
_context2.n = 9;
|
|
7905
|
+
return Promise.all(((_dryRunOptions$assets = dryRunOptions.assets) !== null && _dryRunOptions$assets !== void 0 ? _dryRunOptions$assets : [asset]).map(mintSentAsset));
|
|
8065
7906
|
case 9:
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
8069
|
-
mintAmount = parseUnits(bypassMintAmount, asset.decimals) + asset.amount;
|
|
8070
|
-
} else {
|
|
8071
|
-
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, asset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
8072
|
-
total = missing + bonus;
|
|
8073
|
-
mintAmount = total > 0n ? total : null;
|
|
8074
|
-
}
|
|
8075
|
-
// mint asset that is being sent
|
|
8076
|
-
if (!(mintAmount !== null)) {
|
|
8077
|
-
_context.n = 11;
|
|
8078
|
-
break;
|
|
8079
|
-
}
|
|
8080
|
-
_context.n = 10;
|
|
8081
|
-
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
8082
|
-
amount: mintAmount
|
|
8083
|
-
}), balance, address, api);
|
|
8084
|
-
case 10:
|
|
8085
|
-
_t3 = _context.v;
|
|
8086
|
-
_context.n = 12;
|
|
8087
|
-
break;
|
|
8088
|
-
case 11:
|
|
8089
|
-
_t3 = null;
|
|
8090
|
-
case 12:
|
|
8091
|
-
mintAssetRes = _t3;
|
|
8092
|
-
return _context.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes, mintAssetRes].flatMap(function (tx) {
|
|
7907
|
+
mintAssetResults = _context2.v;
|
|
7908
|
+
return _context2.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes].concat(_toConsumableArray(mintAssetResults)).flatMap(function (tx) {
|
|
8093
7909
|
return tx ? resultToExtrinsics(api, address, tx) : [];
|
|
8094
7910
|
})), [api.callDispatchAsMethod(tx, address)]), BatchMode.BATCH_ALL));
|
|
8095
7911
|
}
|
|
8096
|
-
},
|
|
7912
|
+
}, _callee2);
|
|
8097
7913
|
}));
|
|
8098
7914
|
return function wrapTxBypass(_x) {
|
|
8099
7915
|
return _ref2.apply(this, arguments);
|
|
@@ -8315,14 +8131,13 @@ var getBypassResultWithRetries = /*#__PURE__*/function () {
|
|
|
8315
8131
|
|
|
8316
8132
|
var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
8317
8133
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
8318
|
-
var api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, _ref$useRootOrigin, useRootOrigin,
|
|
8134
|
+
var api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, _ref$useRootOrigin, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, _yield$api$getPayment, rawFee, paddedFee, sufficient, resolvedVersion, dryRunResult, _yield$api$getPayment2, _rawFee, _paddedFee, fee, forwardedXcms, destParaId, weight;
|
|
8319
8135
|
return _regenerator().w(function (_context) {
|
|
8320
8136
|
while (1) switch (_context.n) {
|
|
8321
8137
|
case 0:
|
|
8322
8138
|
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency, version = _ref.version, _ref$useRootOrigin = _ref.useRootOrigin, useRootOrigin = _ref$useRootOrigin === void 0 ? false : _ref$useRootOrigin;
|
|
8323
|
-
asset = api.findAssetInfoOrThrow(origin, currency, destination);
|
|
8324
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
8325
8139
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
8140
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
8326
8141
|
_context.n = 1;
|
|
8327
8142
|
return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
8328
8143
|
case 1:
|
|
@@ -8337,9 +8152,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
8337
8152
|
rawFee = _yield$api$getPayment.partialFee;
|
|
8338
8153
|
paddedFee = padFee(rawFee, origin, destination, 'origin');
|
|
8339
8154
|
_context.n = 3;
|
|
8340
|
-
return isSufficientOrigin(api, origin, destination, sender, paddedFee,
|
|
8341
|
-
amount: amount
|
|
8342
|
-
}), asset, resolvedFeeAsset);
|
|
8155
|
+
return isSufficientOrigin(api, origin, destination, sender, paddedFee, asset, resolvedFeeAsset);
|
|
8343
8156
|
case 3:
|
|
8344
8157
|
sufficient = _context.v;
|
|
8345
8158
|
return _context.a(2, {
|
|
@@ -8356,9 +8169,8 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
8356
8169
|
chain: origin,
|
|
8357
8170
|
destination: destination,
|
|
8358
8171
|
address: sender,
|
|
8359
|
-
asset:
|
|
8360
|
-
|
|
8361
|
-
}),
|
|
8172
|
+
asset: asset,
|
|
8173
|
+
assets: assets,
|
|
8362
8174
|
version: resolvedVersion,
|
|
8363
8175
|
feeAsset: resolvedFeeAsset,
|
|
8364
8176
|
// Force dryRun pass
|
|
@@ -8499,13 +8311,13 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
|
|
|
8499
8311
|
};
|
|
8500
8312
|
var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
8501
8313
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
8502
|
-
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation,
|
|
8314
|
+
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, _failureSubReason, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _inferFeeAsset2, _destApi, destFallback, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, _bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, failureSubReason, _t, _t2, _t3, _t4;
|
|
8503
8315
|
return _regenerator().w(function (_context2) {
|
|
8504
8316
|
while (1) switch (_context2.p = _context2.n) {
|
|
8505
8317
|
case 0:
|
|
8506
8318
|
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
8507
|
-
|
|
8508
|
-
|
|
8319
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
8320
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), asset = _resolveCurrency.asset;
|
|
8509
8321
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
8510
8322
|
_context2.n = 1;
|
|
8511
8323
|
return getOriginXcmFeeInternal({
|
|
@@ -8566,12 +8378,11 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8566
8378
|
origin: origin,
|
|
8567
8379
|
prevChain: origin,
|
|
8568
8380
|
destination: destination,
|
|
8569
|
-
currency:
|
|
8570
|
-
|
|
8571
|
-
|
|
8381
|
+
currency: currency,
|
|
8382
|
+
asset: asset,
|
|
8383
|
+
currentAsset: asset,
|
|
8572
8384
|
sender: sender,
|
|
8573
8385
|
recipient: recipient,
|
|
8574
|
-
asset: asset,
|
|
8575
8386
|
version: resolvedVersion,
|
|
8576
8387
|
tx: tx,
|
|
8577
8388
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -8638,7 +8449,8 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8638
8449
|
originChain: origin,
|
|
8639
8450
|
currentChain: currentChain,
|
|
8640
8451
|
destination: destination,
|
|
8641
|
-
asset:
|
|
8452
|
+
asset: asset,
|
|
8453
|
+
currentAsset: currentAsset,
|
|
8642
8454
|
currency: currency,
|
|
8643
8455
|
swapConfig: swapConfig,
|
|
8644
8456
|
hasPassedExchange: hasPassedExchange
|
|
@@ -8651,12 +8463,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8651
8463
|
origin: origin,
|
|
8652
8464
|
prevChain: currentOrigin,
|
|
8653
8465
|
destination: currentChain,
|
|
8654
|
-
currency:
|
|
8655
|
-
|
|
8466
|
+
currency: currency,
|
|
8467
|
+
asset: asset,
|
|
8468
|
+
currentAsset: _objectSpread2(_objectSpread2({}, hopAsset), {}, {
|
|
8469
|
+
amount: asset.amount
|
|
8656
8470
|
}),
|
|
8657
8471
|
sender: sender,
|
|
8658
8472
|
recipient: recipient,
|
|
8659
|
-
asset: hopAsset,
|
|
8660
8473
|
version: resolvedVersion,
|
|
8661
8474
|
feeAsset: feeAsset,
|
|
8662
8475
|
tx: tx,
|
|
@@ -8681,7 +8494,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8681
8494
|
api: api,
|
|
8682
8495
|
origin: origin,
|
|
8683
8496
|
destination: destination,
|
|
8684
|
-
|
|
8497
|
+
asset: asset,
|
|
8685
8498
|
initialForwardedXcms: initialForwardedXcm,
|
|
8686
8499
|
initialDestParaId: initialDestParaId,
|
|
8687
8500
|
swapConfig: swapConfig,
|
|
@@ -8728,12 +8541,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
8728
8541
|
origin: origin,
|
|
8729
8542
|
prevChain: traversalResult.lastProcessedChain || origin,
|
|
8730
8543
|
destination: destination,
|
|
8731
|
-
currency:
|
|
8732
|
-
|
|
8544
|
+
currency: currency,
|
|
8545
|
+
asset: asset,
|
|
8546
|
+
currentAsset: _objectSpread2(_objectSpread2({}, (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset, api)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset), {}, {
|
|
8547
|
+
amount: asset.amount
|
|
8733
8548
|
}),
|
|
8734
8549
|
sender: sender,
|
|
8735
8550
|
recipient: recipient,
|
|
8736
|
-
asset: (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset, api)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset,
|
|
8737
8551
|
version: resolvedVersion,
|
|
8738
8552
|
tx: tx,
|
|
8739
8553
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -8961,11 +8775,11 @@ var aggregateHopFees = function aggregateHopFees(hops, matchAsset) {
|
|
|
8961
8775
|
|
|
8962
8776
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
8963
8777
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
8964
|
-
var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8778
|
+
var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, paysDestFee, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8965
8779
|
return _regenerator().w(function (_context) {
|
|
8966
8780
|
while (1) switch (_context.n) {
|
|
8967
8781
|
case 0:
|
|
8968
|
-
api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
|
|
8782
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, paysDestFee = _ref.paysDestFee, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
|
|
8969
8783
|
destApi = api.clone();
|
|
8970
8784
|
_context.n = 1;
|
|
8971
8785
|
return destApi.init(destination);
|
|
@@ -8983,14 +8797,14 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
8983
8797
|
destBalance = _context.v;
|
|
8984
8798
|
destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
|
|
8985
8799
|
destFeeAssetEqual = isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
|
|
8986
|
-
effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
|
|
8800
|
+
effectiveDestFee = paysDestFee && destFeeAssetEqual ? destFeeDetail.fee : 0n;
|
|
8987
8801
|
effectiveAmountForBalance = destAmount - totalHopFee;
|
|
8988
8802
|
destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
|
|
8989
8803
|
destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
|
|
8990
8804
|
createUnableToComputeError = function createUnableToComputeError() {
|
|
8991
8805
|
return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
|
|
8992
8806
|
};
|
|
8993
|
-
isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
|
|
8807
|
+
isUnableToCompute = paysDestFee && destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
|
|
8994
8808
|
destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
|
|
8995
8809
|
destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
|
|
8996
8810
|
isSubBridge = isSubstrateBridge(origin, destination);
|
|
@@ -9109,24 +8923,49 @@ var buildHopInfo = /*#__PURE__*/function () {
|
|
|
9109
8923
|
};
|
|
9110
8924
|
}();
|
|
9111
8925
|
|
|
8926
|
+
var _excluded$1 = ["amount"];
|
|
9112
8927
|
var buildOriginInfo = /*#__PURE__*/function () {
|
|
9113
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9114
|
-
var api, origin, sender,
|
|
9115
|
-
return _regenerator().w(function (
|
|
9116
|
-
while (1) switch (
|
|
8928
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
8929
|
+
var api, origin, sender, assets, amount, originFee, originFeeAsset, isFeeAssetAh, buildSelectedCurrency, selectedCurrency, originBalanceFee, originBalanceFeeAfter;
|
|
8930
|
+
return _regenerator().w(function (_context2) {
|
|
8931
|
+
while (1) switch (_context2.n) {
|
|
9117
8932
|
case 0:
|
|
9118
|
-
api = _ref.api, origin = _ref.origin, sender = _ref.sender,
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
8933
|
+
api = _ref.api, origin = _ref.origin, sender = _ref.sender, assets = _ref.assets, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isFeeAssetAh = _ref.isFeeAssetAh;
|
|
8934
|
+
buildSelectedCurrency = /*#__PURE__*/function () {
|
|
8935
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref3) {
|
|
8936
|
+
var assetAmount, asset, balance, balanceAfter;
|
|
8937
|
+
return _regenerator().w(function (_context) {
|
|
8938
|
+
while (1) switch (_context.n) {
|
|
8939
|
+
case 0:
|
|
8940
|
+
assetAmount = _ref3.amount, asset = _objectWithoutProperties(_ref3, _excluded$1);
|
|
8941
|
+
_context.n = 1;
|
|
8942
|
+
return getAssetBalanceInternal({
|
|
8943
|
+
api: api,
|
|
8944
|
+
address: sender,
|
|
8945
|
+
chain: origin,
|
|
8946
|
+
asset: asset
|
|
8947
|
+
});
|
|
8948
|
+
case 1:
|
|
8949
|
+
balance = _context.v;
|
|
8950
|
+
balanceAfter = balance - assetAmount;
|
|
8951
|
+
return _context.a(2, {
|
|
8952
|
+
sufficient: balanceAfter >= getEdFromAssetOrThrow(asset),
|
|
8953
|
+
balance: balance,
|
|
8954
|
+
balanceAfter: balanceAfter,
|
|
8955
|
+
asset: asset
|
|
8956
|
+
});
|
|
8957
|
+
}
|
|
8958
|
+
}, _callee);
|
|
8959
|
+
}));
|
|
8960
|
+
return function buildSelectedCurrency(_x2) {
|
|
8961
|
+
return _ref4.apply(this, arguments);
|
|
8962
|
+
};
|
|
8963
|
+
}();
|
|
8964
|
+
_context2.n = 1;
|
|
8965
|
+
return Promise.all(assets.map(buildSelectedCurrency));
|
|
9126
8966
|
case 1:
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
_context.n = 2;
|
|
8967
|
+
selectedCurrency = _context2.v;
|
|
8968
|
+
_context2.n = 2;
|
|
9130
8969
|
return getAssetBalanceInternal({
|
|
9131
8970
|
api: api,
|
|
9132
8971
|
address: sender,
|
|
@@ -9134,20 +8973,12 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
9134
8973
|
asset: originFeeAsset
|
|
9135
8974
|
});
|
|
9136
8975
|
case 2:
|
|
9137
|
-
originBalanceFee =
|
|
9138
|
-
originBalanceAfter = originBalance - amount;
|
|
8976
|
+
originBalanceFee = _context2.v;
|
|
9139
8977
|
originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
return _context.a(2, {
|
|
9143
|
-
selectedCurrency: {
|
|
9144
|
-
sufficient: originBalanceSufficient,
|
|
9145
|
-
balance: originBalance,
|
|
9146
|
-
balanceAfter: originBalanceAfter,
|
|
9147
|
-
asset: originAsset
|
|
9148
|
-
},
|
|
8978
|
+
return _context2.a(2, {
|
|
8979
|
+
selectedCurrency: selectedCurrency,
|
|
9149
8980
|
xcmFee: {
|
|
9150
|
-
sufficient:
|
|
8981
|
+
sufficient: originBalanceFee >= originFee,
|
|
9151
8982
|
fee: originFee,
|
|
9152
8983
|
balance: originBalanceFee,
|
|
9153
8984
|
balanceAfter: originBalanceFeeAfter,
|
|
@@ -9155,7 +8986,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
9155
8986
|
}
|
|
9156
8987
|
});
|
|
9157
8988
|
}
|
|
9158
|
-
},
|
|
8989
|
+
}, _callee2);
|
|
9159
8990
|
}));
|
|
9160
8991
|
return function buildOriginInfo(_x) {
|
|
9161
8992
|
return _ref2.apply(this, arguments);
|
|
@@ -9164,7 +8995,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
|
|
|
9164
8995
|
|
|
9165
8996
|
var getTransferInfo = /*#__PURE__*/function () {
|
|
9166
8997
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
9167
|
-
var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh,
|
|
8998
|
+
var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, _resolveCurrency, assets, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh, feeAssetIndex, feeCurrency, _yield$buildOriginInf, selectedCurrency, originXcmFee, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, buildDestInfoForAsset, destResults, feeResult, result, _t, _t2;
|
|
9168
8999
|
return _regenerator().w(function (_context2) {
|
|
9169
9000
|
while (1) switch (_context2.p = _context2.n) {
|
|
9170
9001
|
case 0:
|
|
@@ -9175,14 +9006,15 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9175
9006
|
}
|
|
9176
9007
|
throw new MissingParameterError('ahAddress', "ahAddress is required for EVM origin ".concat(origin, "."));
|
|
9177
9008
|
case 1:
|
|
9009
|
+
assertNotRawAssets(currency);
|
|
9178
9010
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
9179
9011
|
_context2.n = 2;
|
|
9180
9012
|
return api.init(origin);
|
|
9181
9013
|
case 2:
|
|
9182
9014
|
api.disconnectAllowed = false;
|
|
9183
9015
|
_context2.p = 3;
|
|
9184
|
-
|
|
9185
|
-
amount =
|
|
9016
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, originAsset = _resolveCurrency.asset;
|
|
9017
|
+
amount = originAsset.amount;
|
|
9186
9018
|
_context2.n = 4;
|
|
9187
9019
|
return getXcmFee({
|
|
9188
9020
|
api: api,
|
|
@@ -9204,20 +9036,25 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9204
9036
|
destFeeDetail = _yield$getXcmFeeInter.destination;
|
|
9205
9037
|
hops = _yield$getXcmFeeInter.hops;
|
|
9206
9038
|
isFeeAssetAh = origin === 'AssetHubPolkadot' && !!resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
|
|
9039
|
+
feeAssetIndex = assets.findIndex(function (asset) {
|
|
9040
|
+
return isAssetEqual(asset, originAsset);
|
|
9041
|
+
});
|
|
9042
|
+
feeCurrency = Array.isArray(currency) ? currency[feeAssetIndex] : currency;
|
|
9207
9043
|
_context2.n = 5;
|
|
9208
9044
|
return buildOriginInfo({
|
|
9209
9045
|
api: api,
|
|
9210
9046
|
origin: origin,
|
|
9211
9047
|
sender: sender,
|
|
9212
|
-
|
|
9213
|
-
originAsset: originAsset,
|
|
9048
|
+
assets: assets,
|
|
9214
9049
|
amount: amount,
|
|
9215
9050
|
originFee: originFee,
|
|
9216
9051
|
originFeeAsset: originFeeAsset,
|
|
9217
9052
|
isFeeAssetAh: isFeeAssetAh
|
|
9218
9053
|
});
|
|
9219
9054
|
case 5:
|
|
9220
|
-
|
|
9055
|
+
_yield$buildOriginInf = _context2.v;
|
|
9056
|
+
selectedCurrency = _yield$buildOriginInf.selectedCurrency;
|
|
9057
|
+
originXcmFee = _yield$buildOriginInf.xcmFee;
|
|
9221
9058
|
builtHops = [];
|
|
9222
9059
|
if (!(hops && hops.length > 0)) {
|
|
9223
9060
|
_context2.n = 7;
|
|
@@ -9236,7 +9073,7 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9236
9073
|
chain: hop.chain,
|
|
9237
9074
|
fee: hop.result.fee,
|
|
9238
9075
|
originChain: origin,
|
|
9239
|
-
currency:
|
|
9076
|
+
currency: feeCurrency,
|
|
9240
9077
|
asset: hop.result.asset,
|
|
9241
9078
|
sender: sender,
|
|
9242
9079
|
ahAddress: ahAddress
|
|
@@ -9258,44 +9095,76 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
9258
9095
|
builtHops = _context2.v;
|
|
9259
9096
|
case 7:
|
|
9260
9097
|
_aggregateHopFees = aggregateHopFees(hops, originAsset), totalHopFee = _aggregateHopFees.totalHopFee, bridgeFee = _aggregateHopFees.bridgeFee;
|
|
9098
|
+
buildDestInfoForAsset = function buildDestInfoForAsset(item, isFeeElement) {
|
|
9099
|
+
return buildDestInfo({
|
|
9100
|
+
api: api,
|
|
9101
|
+
origin: origin,
|
|
9102
|
+
destination: destination,
|
|
9103
|
+
recipient: recipient,
|
|
9104
|
+
currency: item,
|
|
9105
|
+
originFee: originFee,
|
|
9106
|
+
isFeeAssetAh: isFeeAssetAh && isFeeElement,
|
|
9107
|
+
paysDestFee: isFeeElement,
|
|
9108
|
+
destFeeDetail: destFeeDetail,
|
|
9109
|
+
totalHopFee: isFeeElement ? totalHopFee : 0n,
|
|
9110
|
+
bridgeFee: bridgeFee
|
|
9111
|
+
});
|
|
9112
|
+
};
|
|
9113
|
+
if (!Array.isArray(currency)) {
|
|
9114
|
+
_context2.n = 9;
|
|
9115
|
+
break;
|
|
9116
|
+
}
|
|
9261
9117
|
_context2.n = 8;
|
|
9262
|
-
return
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9268
|
-
amount: amount
|
|
9269
|
-
}),
|
|
9270
|
-
originFee: originFee,
|
|
9271
|
-
isFeeAssetAh: isFeeAssetAh,
|
|
9272
|
-
destFeeDetail: destFeeDetail,
|
|
9273
|
-
totalHopFee: totalHopFee,
|
|
9274
|
-
bridgeFee: bridgeFee
|
|
9275
|
-
});
|
|
9118
|
+
return Promise.all(currency.map(function (item, index) {
|
|
9119
|
+
return buildDestInfoForAsset(_objectSpread2(_objectSpread2({}, item), {}, {
|
|
9120
|
+
amount: assets[index].amount
|
|
9121
|
+
}), index === feeAssetIndex);
|
|
9122
|
+
}));
|
|
9276
9123
|
case 8:
|
|
9277
|
-
|
|
9278
|
-
|
|
9124
|
+
_t = _context2.v;
|
|
9125
|
+
_context2.n = 11;
|
|
9126
|
+
break;
|
|
9127
|
+
case 9:
|
|
9128
|
+
_context2.n = 10;
|
|
9129
|
+
return buildDestInfoForAsset(_objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9130
|
+
amount: amount
|
|
9131
|
+
}), true);
|
|
9132
|
+
case 10:
|
|
9133
|
+
_t2 = _context2.v;
|
|
9134
|
+
_t = [_t2];
|
|
9135
|
+
case 11:
|
|
9136
|
+
destResults = _t;
|
|
9137
|
+
feeResult = destResults[Array.isArray(currency) ? feeAssetIndex : 0];
|
|
9138
|
+
result = {
|
|
9279
9139
|
chain: {
|
|
9280
9140
|
origin: origin,
|
|
9281
9141
|
destination: destination,
|
|
9282
9142
|
ecosystem: api.getRelayChainSymbol(origin)
|
|
9283
9143
|
},
|
|
9284
|
-
origin:
|
|
9144
|
+
origin: {
|
|
9145
|
+
selectedCurrency: Array.isArray(currency) ? selectedCurrency : selectedCurrency[0],
|
|
9146
|
+
xcmFee: originXcmFee
|
|
9147
|
+
},
|
|
9285
9148
|
hops: builtHops,
|
|
9286
|
-
destination:
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9149
|
+
destination: {
|
|
9150
|
+
receivedCurrency: Array.isArray(currency) ? destResults.map(function (result) {
|
|
9151
|
+
return result.receivedCurrency;
|
|
9152
|
+
}) : destResults[0].receivedCurrency,
|
|
9153
|
+
xcmFee: feeResult.xcmFee
|
|
9154
|
+
}
|
|
9155
|
+
};
|
|
9156
|
+
return _context2.a(2, result);
|
|
9157
|
+
case 12:
|
|
9158
|
+
_context2.p = 12;
|
|
9290
9159
|
api.disconnectAllowed = true;
|
|
9291
|
-
_context2.n =
|
|
9160
|
+
_context2.n = 13;
|
|
9292
9161
|
return api.disconnect();
|
|
9293
|
-
case
|
|
9294
|
-
return _context2.f(
|
|
9295
|
-
case
|
|
9162
|
+
case 13:
|
|
9163
|
+
return _context2.f(12);
|
|
9164
|
+
case 14:
|
|
9296
9165
|
return _context2.a(2);
|
|
9297
9166
|
}
|
|
9298
|
-
}, _callee2, null, [[3,,
|
|
9167
|
+
}, _callee2, null, [[3,, 12, 14]]);
|
|
9299
9168
|
}));
|
|
9300
9169
|
return function getTransferInfo(_x) {
|
|
9301
9170
|
return _ref2.apply(this, arguments);
|
|
@@ -9358,35 +9227,26 @@ var computeAllFees = /*#__PURE__*/function () {
|
|
|
9358
9227
|
}();
|
|
9359
9228
|
|
|
9360
9229
|
var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
9361
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9362
|
-
var api, origin, sender, recipient,
|
|
9363
|
-
return _regenerator().w(function (
|
|
9364
|
-
while (1) switch (
|
|
9230
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref) {
|
|
9231
|
+
var api, origin, sender, recipient, destination, currency, feeAsset, buildTx, builder, version, resolvedFeeAsset, _resolveCurrency, assets, selectors, toResult, destApi, nativeAssetInfo, result, minAmounts, buildMinCurrency, createTx, amounts, tx, dryRunResult, _t;
|
|
9232
|
+
return _regenerator().w(function (_context3) {
|
|
9233
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
9365
9234
|
case 0:
|
|
9366
|
-
api = _ref.api, origin = _ref.origin, sender = _ref.sender, recipient = _ref.recipient,
|
|
9367
|
-
validateAddress(api, sender,
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9235
|
+
api = _ref.api, origin = _ref.origin, sender = _ref.sender, recipient = _ref.recipient, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder, version = _ref.version;
|
|
9236
|
+
validateAddress(api, sender, origin, false);
|
|
9237
|
+
assertNotRawAssets(currency);
|
|
9238
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
9239
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets;
|
|
9240
|
+
selectors = Array.isArray(currency) ? currency : [currency];
|
|
9241
|
+
toResult = function toResult(values) {
|
|
9242
|
+
return Array.isArray(currency) ? values : values[0];
|
|
9243
|
+
};
|
|
9371
9244
|
destApi = api.clone();
|
|
9372
|
-
|
|
9245
|
+
_context3.n = 1;
|
|
9373
9246
|
return destApi.init(destination);
|
|
9374
9247
|
case 1:
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
api: destApi,
|
|
9378
|
-
address: recipient,
|
|
9379
|
-
chain: destination,
|
|
9380
|
-
asset: destAsset
|
|
9381
|
-
});
|
|
9382
|
-
case 2:
|
|
9383
|
-
destBalance = _context2.v;
|
|
9384
|
-
destEd = getEdFromAssetOrThrow(destAsset);
|
|
9385
|
-
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
9386
|
-
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
9387
|
-
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9388
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
9389
|
-
_context2.n = 3;
|
|
9248
|
+
nativeAssetInfo = api.findNativeAssetInfoOrThrow(origin);
|
|
9249
|
+
_context3.n = 2;
|
|
9390
9250
|
return getXcmFee({
|
|
9391
9251
|
api: api,
|
|
9392
9252
|
origin: origin,
|
|
@@ -9394,146 +9254,214 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
9394
9254
|
buildTx: buildTx,
|
|
9395
9255
|
sender: sender,
|
|
9396
9256
|
recipient: recipient,
|
|
9397
|
-
currency: _objectSpread2(_objectSpread2({},
|
|
9398
|
-
amount: amount
|
|
9257
|
+
currency: Array.isArray(currency) ? currency : _objectSpread2(_objectSpread2({}, selectors[0]), {}, {
|
|
9258
|
+
amount: assets[0].amount
|
|
9399
9259
|
}),
|
|
9400
9260
|
feeAsset: feeAsset,
|
|
9401
9261
|
version: version,
|
|
9402
9262
|
disableFallback: false
|
|
9403
9263
|
});
|
|
9404
|
-
case
|
|
9405
|
-
result =
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
}, 0n);
|
|
9411
|
-
destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
|
|
9412
|
-
edComponent = destBalance === 0n ? destEd : 0n;
|
|
9413
|
-
minAmount = hopFeeTotal + destinationFee + originFee + edComponent + 1n;
|
|
9414
|
-
createTx = /*#__PURE__*/function () {
|
|
9415
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(amount) {
|
|
9416
|
-
var _yield$builder$curren, tx;
|
|
9264
|
+
case 2:
|
|
9265
|
+
result = _context3.v;
|
|
9266
|
+
_context3.n = 3;
|
|
9267
|
+
return Promise.all(assets.map(/*#__PURE__*/function () {
|
|
9268
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(asset, index) {
|
|
9269
|
+
var destAsset, destBalance, destEd, paysOriginInSendingAsset, originFee, hopFeeTotal, destinationFee, edComponent;
|
|
9417
9270
|
return _regenerator().w(function (_context) {
|
|
9418
9271
|
while (1) switch (_context.n) {
|
|
9419
9272
|
case 0:
|
|
9273
|
+
destAsset = api.findAssetOnDestOrThrow(origin, destination, selectors[index]);
|
|
9420
9274
|
_context.n = 1;
|
|
9421
|
-
return
|
|
9422
|
-
|
|
9423
|
-
|
|
9275
|
+
return getAssetBalanceInternal({
|
|
9276
|
+
api: destApi,
|
|
9277
|
+
address: recipient,
|
|
9278
|
+
chain: destination,
|
|
9279
|
+
asset: destAsset
|
|
9280
|
+
});
|
|
9424
9281
|
case 1:
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9282
|
+
destBalance = _context.v;
|
|
9283
|
+
destEd = getEdFromAssetOrThrow(destAsset);
|
|
9284
|
+
paysOriginInSendingAsset = !resolvedFeeAsset && isAssetEqual(nativeAssetInfo, asset) || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9285
|
+
originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
|
|
9286
|
+
hopFeeTotal = result.hops.reduce(function (acc, hop) {
|
|
9287
|
+
// only add if asset is equal
|
|
9288
|
+
return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
|
|
9289
|
+
}, 0n);
|
|
9290
|
+
destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
|
|
9291
|
+
edComponent = destBalance === 0n ? destEd : 0n;
|
|
9292
|
+
return _context.a(2, hopFeeTotal + destinationFee + originFee + edComponent + 1n);
|
|
9428
9293
|
}
|
|
9429
9294
|
}, _callee);
|
|
9430
9295
|
}));
|
|
9431
|
-
return function
|
|
9296
|
+
return function (_x2, _x3) {
|
|
9432
9297
|
return _ref3.apply(this, arguments);
|
|
9433
9298
|
};
|
|
9299
|
+
}()));
|
|
9300
|
+
case 3:
|
|
9301
|
+
minAmounts = _context3.v;
|
|
9302
|
+
buildMinCurrency = function buildMinCurrency(amounts) {
|
|
9303
|
+
assertNotRawAssets(currency);
|
|
9304
|
+
return Array.isArray(currency) ? currency.map(function (item, index) {
|
|
9305
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
9306
|
+
amount: amounts[index]
|
|
9307
|
+
});
|
|
9308
|
+
}) : _objectSpread2(_objectSpread2({}, selectors[0]), {}, {
|
|
9309
|
+
amount: amounts[0]
|
|
9310
|
+
});
|
|
9311
|
+
};
|
|
9312
|
+
createTx = /*#__PURE__*/function () {
|
|
9313
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(amounts) {
|
|
9314
|
+
var _yield$builder$curren, tx;
|
|
9315
|
+
return _regenerator().w(function (_context2) {
|
|
9316
|
+
while (1) switch (_context2.n) {
|
|
9317
|
+
case 0:
|
|
9318
|
+
_context2.n = 1;
|
|
9319
|
+
return builder.currency(buildMinCurrency(amounts))['buildInternal']();
|
|
9320
|
+
case 1:
|
|
9321
|
+
_yield$builder$curren = _context2.v;
|
|
9322
|
+
tx = _yield$builder$curren.tx;
|
|
9323
|
+
return _context2.a(2, tx);
|
|
9324
|
+
}
|
|
9325
|
+
}, _callee2);
|
|
9326
|
+
}));
|
|
9327
|
+
return function createTx(_x4) {
|
|
9328
|
+
return _ref4.apply(this, arguments);
|
|
9329
|
+
};
|
|
9434
9330
|
}();
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9331
|
+
amounts = minAmounts;
|
|
9332
|
+
_context3.p = 4;
|
|
9333
|
+
_context3.n = 5;
|
|
9334
|
+
return createTx(amounts);
|
|
9438
9335
|
case 5:
|
|
9439
|
-
tx =
|
|
9440
|
-
|
|
9336
|
+
tx = _context3.v;
|
|
9337
|
+
_context3.n = 10;
|
|
9441
9338
|
break;
|
|
9442
9339
|
case 6:
|
|
9443
|
-
|
|
9444
|
-
_t =
|
|
9340
|
+
_context3.p = 6;
|
|
9341
|
+
_t = _context3.v;
|
|
9445
9342
|
if (!(_t instanceof AmountTooLowError)) {
|
|
9446
|
-
|
|
9343
|
+
_context3.n = 10;
|
|
9447
9344
|
break;
|
|
9448
9345
|
}
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9346
|
+
amounts = amounts.map(function (amount) {
|
|
9347
|
+
return padValueBy(amount, FEE_PADDING);
|
|
9348
|
+
});
|
|
9349
|
+
_context3.p = 7;
|
|
9350
|
+
_context3.n = 8;
|
|
9351
|
+
return createTx(amounts);
|
|
9453
9352
|
case 8:
|
|
9454
|
-
tx =
|
|
9455
|
-
|
|
9353
|
+
tx = _context3.v;
|
|
9354
|
+
_context3.n = 10;
|
|
9456
9355
|
break;
|
|
9457
9356
|
case 9:
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
}
|
|
9464
|
-
return _context2.a(2, 0n);
|
|
9357
|
+
_context3.p = 9;
|
|
9358
|
+
_context3.v;
|
|
9359
|
+
return _context3.a(2, toResult(amounts.map(function () {
|
|
9360
|
+
return 0n;
|
|
9361
|
+
})));
|
|
9465
9362
|
case 10:
|
|
9466
|
-
|
|
9363
|
+
_context3.n = 11;
|
|
9467
9364
|
return dryRunInternal({
|
|
9468
9365
|
api: api,
|
|
9469
9366
|
tx: tx,
|
|
9470
|
-
origin:
|
|
9367
|
+
origin: origin,
|
|
9471
9368
|
destination: destination,
|
|
9472
9369
|
sender: sender,
|
|
9473
9370
|
version: version,
|
|
9474
|
-
currency:
|
|
9475
|
-
amount: minAmount
|
|
9476
|
-
}),
|
|
9371
|
+
currency: buildMinCurrency(amounts),
|
|
9477
9372
|
feeAsset: feeAsset
|
|
9478
9373
|
});
|
|
9479
9374
|
case 11:
|
|
9480
|
-
dryRunResult =
|
|
9375
|
+
dryRunResult = _context3.v;
|
|
9481
9376
|
if (!dryRunResult.failureReason) {
|
|
9482
|
-
|
|
9377
|
+
_context3.n = 12;
|
|
9483
9378
|
break;
|
|
9484
9379
|
}
|
|
9485
|
-
return
|
|
9380
|
+
return _context3.a(2, toResult(amounts.map(function () {
|
|
9381
|
+
return 0n;
|
|
9382
|
+
})));
|
|
9486
9383
|
case 12:
|
|
9487
|
-
return
|
|
9384
|
+
return _context3.a(2, toResult(amounts));
|
|
9488
9385
|
}
|
|
9489
|
-
},
|
|
9386
|
+
}, _callee3, null, [[7, 9], [4, 6]]);
|
|
9490
9387
|
}));
|
|
9491
9388
|
return function getMinTransferableAmountInternal(_x) {
|
|
9492
9389
|
return _ref2.apply(this, arguments);
|
|
9493
9390
|
};
|
|
9494
9391
|
}();
|
|
9495
9392
|
var getMinTransferableAmount = /*#__PURE__*/function () {
|
|
9496
|
-
var
|
|
9393
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
9497
9394
|
var api;
|
|
9498
|
-
return _regenerator().w(function (
|
|
9499
|
-
while (1) switch (
|
|
9395
|
+
return _regenerator().w(function (_context4) {
|
|
9396
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
9500
9397
|
case 0:
|
|
9501
9398
|
api = options.api;
|
|
9502
9399
|
api.disconnectAllowed = false;
|
|
9503
|
-
|
|
9504
|
-
|
|
9400
|
+
_context4.p = 1;
|
|
9401
|
+
_context4.n = 2;
|
|
9505
9402
|
return getMinTransferableAmountInternal(options);
|
|
9506
9403
|
case 2:
|
|
9507
|
-
return
|
|
9404
|
+
return _context4.a(2, _context4.v);
|
|
9508
9405
|
case 3:
|
|
9509
|
-
|
|
9406
|
+
_context4.p = 3;
|
|
9510
9407
|
api.disconnectAllowed = true;
|
|
9511
|
-
|
|
9408
|
+
_context4.n = 4;
|
|
9512
9409
|
return api.disconnect();
|
|
9513
9410
|
case 4:
|
|
9514
|
-
return
|
|
9411
|
+
return _context4.f(3);
|
|
9515
9412
|
case 5:
|
|
9516
|
-
return
|
|
9413
|
+
return _context4.a(2);
|
|
9517
9414
|
}
|
|
9518
|
-
},
|
|
9415
|
+
}, _callee4, null, [[1,, 3, 5]]);
|
|
9519
9416
|
}));
|
|
9520
|
-
return function getMinTransferableAmount(
|
|
9521
|
-
return
|
|
9417
|
+
return function getMinTransferableAmount(_x5) {
|
|
9418
|
+
return _ref5.apply(this, arguments);
|
|
9522
9419
|
};
|
|
9523
9420
|
}();
|
|
9524
9421
|
|
|
9525
|
-
var
|
|
9526
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
9527
|
-
var api,
|
|
9422
|
+
var getOriginFeeOrThrow = /*#__PURE__*/function () {
|
|
9423
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
|
|
9424
|
+
var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
|
|
9528
9425
|
return _regenerator().w(function (_context) {
|
|
9529
9426
|
while (1) switch (_context.n) {
|
|
9530
9427
|
case 0:
|
|
9531
|
-
api = _ref.api,
|
|
9532
|
-
validateAddress(api, sender, chain, false);
|
|
9533
|
-
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
9534
|
-
asset = api.findAssetInfoOrThrow(chain, currency);
|
|
9535
|
-
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
9428
|
+
api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
|
|
9536
9429
|
_context.n = 1;
|
|
9430
|
+
return getOriginXcmFee({
|
|
9431
|
+
api: api,
|
|
9432
|
+
buildTx: buildTx,
|
|
9433
|
+
origin: chain,
|
|
9434
|
+
destination: chain,
|
|
9435
|
+
sender: sender,
|
|
9436
|
+
feeAsset: feeAsset,
|
|
9437
|
+
version: version,
|
|
9438
|
+
currency: feeCurrency,
|
|
9439
|
+
disableFallback: false
|
|
9440
|
+
});
|
|
9441
|
+
case 1:
|
|
9442
|
+
_yield$getOriginXcmFe = _context.v;
|
|
9443
|
+
fee = _yield$getOriginXcmFe.fee;
|
|
9444
|
+
if (!(fee === undefined)) {
|
|
9445
|
+
_context.n = 2;
|
|
9446
|
+
break;
|
|
9447
|
+
}
|
|
9448
|
+
throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
|
|
9449
|
+
case 2:
|
|
9450
|
+
return _context.a(2, fee);
|
|
9451
|
+
}
|
|
9452
|
+
}, _callee);
|
|
9453
|
+
}));
|
|
9454
|
+
return function getOriginFeeOrThrow(_x, _x2) {
|
|
9455
|
+
return _ref2.apply(this, arguments);
|
|
9456
|
+
};
|
|
9457
|
+
}();
|
|
9458
|
+
var computeTransferableAmount = /*#__PURE__*/function () {
|
|
9459
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
|
|
9460
|
+
var balance, transferable;
|
|
9461
|
+
return _regenerator().w(function (_context2) {
|
|
9462
|
+
while (1) switch (_context2.n) {
|
|
9463
|
+
case 0:
|
|
9464
|
+
_context2.n = 1;
|
|
9537
9465
|
return getAssetBalanceInternal({
|
|
9538
9466
|
api: api,
|
|
9539
9467
|
address: sender,
|
|
@@ -9541,77 +9469,123 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
9541
9469
|
asset: asset
|
|
9542
9470
|
});
|
|
9543
9471
|
case 1:
|
|
9544
|
-
balance =
|
|
9545
|
-
|
|
9472
|
+
balance = _context2.v;
|
|
9473
|
+
transferable = balance - getEdFromAssetOrThrow(asset) - fee;
|
|
9474
|
+
return _context2.a(2, transferable > 0n ? transferable : 0n);
|
|
9475
|
+
}
|
|
9476
|
+
}, _callee2);
|
|
9477
|
+
}));
|
|
9478
|
+
return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
|
|
9479
|
+
return _ref3.apply(this, arguments);
|
|
9480
|
+
};
|
|
9481
|
+
}();
|
|
9482
|
+
var getTransferableAmountForAsset = /*#__PURE__*/function () {
|
|
9483
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
|
|
9484
|
+
var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
|
|
9485
|
+
return _regenerator().w(function (_context3) {
|
|
9486
|
+
while (1) switch (_context3.n) {
|
|
9487
|
+
case 0:
|
|
9488
|
+
api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
|
|
9489
|
+
asset = api.findAssetInfoOrThrow(chain, currency);
|
|
9490
|
+
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
9546
9491
|
nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
|
|
9547
9492
|
isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
|
|
9548
9493
|
paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
9549
|
-
feeToSubtract = 0n;
|
|
9550
9494
|
if (!paysOriginInSendingAsset) {
|
|
9551
|
-
|
|
9495
|
+
_context3.n = 2;
|
|
9552
9496
|
break;
|
|
9553
9497
|
}
|
|
9554
|
-
|
|
9555
|
-
return
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
version: version,
|
|
9563
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9564
|
-
amount: amount
|
|
9565
|
-
}),
|
|
9566
|
-
disableFallback: false
|
|
9567
|
-
});
|
|
9498
|
+
_context3.n = 1;
|
|
9499
|
+
return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
9500
|
+
amount: amount
|
|
9501
|
+
}));
|
|
9502
|
+
case 1:
|
|
9503
|
+
_t = _context3.v;
|
|
9504
|
+
_context3.n = 3;
|
|
9505
|
+
break;
|
|
9568
9506
|
case 2:
|
|
9569
|
-
|
|
9570
|
-
fee = _yield$getOriginXcmFe.fee;
|
|
9571
|
-
if (!(fee === undefined)) {
|
|
9572
|
-
_context.n = 3;
|
|
9573
|
-
break;
|
|
9574
|
-
}
|
|
9575
|
-
throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
|
|
9507
|
+
_t = 0n;
|
|
9576
9508
|
case 3:
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
transferable = balance - ed - feeToSubtract;
|
|
9580
|
-
return _context.a(2, transferable > 0n ? transferable : 0n);
|
|
9509
|
+
fee = _t;
|
|
9510
|
+
return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
|
|
9581
9511
|
}
|
|
9582
|
-
},
|
|
9512
|
+
}, _callee3);
|
|
9583
9513
|
}));
|
|
9584
|
-
return function
|
|
9585
|
-
return
|
|
9514
|
+
return function getTransferableAmountForAsset(_x8, _x9) {
|
|
9515
|
+
return _ref4.apply(this, arguments);
|
|
9516
|
+
};
|
|
9517
|
+
}();
|
|
9518
|
+
var getTransferableAmountForAssets = /*#__PURE__*/function () {
|
|
9519
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
|
|
9520
|
+
var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
|
|
9521
|
+
return _regenerator().w(function (_context4) {
|
|
9522
|
+
while (1) switch (_context4.n) {
|
|
9523
|
+
case 0:
|
|
9524
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
|
|
9525
|
+
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
|
|
9526
|
+
_context4.n = 1;
|
|
9527
|
+
return getOriginFeeOrThrow(options, currency);
|
|
9528
|
+
case 1:
|
|
9529
|
+
fee = _context4.v;
|
|
9530
|
+
return _context4.a(2, Promise.all(assets.map(function (asset) {
|
|
9531
|
+
return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
|
|
9532
|
+
})));
|
|
9533
|
+
}
|
|
9534
|
+
}, _callee4);
|
|
9535
|
+
}));
|
|
9536
|
+
return function getTransferableAmountForAssets(_x0, _x1) {
|
|
9537
|
+
return _ref5.apply(this, arguments);
|
|
9538
|
+
};
|
|
9539
|
+
}();
|
|
9540
|
+
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
9541
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
|
|
9542
|
+
var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
|
|
9543
|
+
return _regenerator().w(function (_context5) {
|
|
9544
|
+
while (1) switch (_context5.n) {
|
|
9545
|
+
case 0:
|
|
9546
|
+
api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
|
|
9547
|
+
validateAddress(api, sender, chain, false);
|
|
9548
|
+
assertNotRawAssets(currency);
|
|
9549
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
|
|
9550
|
+
return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
9551
|
+
currency: currency
|
|
9552
|
+
}), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
9553
|
+
currency: currency
|
|
9554
|
+
}), resolvedFeeAsset));
|
|
9555
|
+
}
|
|
9556
|
+
}, _callee5);
|
|
9557
|
+
}));
|
|
9558
|
+
return function getTransferableAmountInternal(_x10) {
|
|
9559
|
+
return _ref6.apply(this, arguments);
|
|
9586
9560
|
};
|
|
9587
9561
|
}();
|
|
9588
9562
|
var getTransferableAmount = /*#__PURE__*/function () {
|
|
9589
|
-
var
|
|
9563
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
|
|
9590
9564
|
var api;
|
|
9591
|
-
return _regenerator().w(function (
|
|
9592
|
-
while (1) switch (
|
|
9565
|
+
return _regenerator().w(function (_context6) {
|
|
9566
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
9593
9567
|
case 0:
|
|
9594
9568
|
api = options.api;
|
|
9595
9569
|
api.disconnectAllowed = false;
|
|
9596
|
-
|
|
9597
|
-
|
|
9570
|
+
_context6.p = 1;
|
|
9571
|
+
_context6.n = 2;
|
|
9598
9572
|
return getTransferableAmountInternal(options);
|
|
9599
9573
|
case 2:
|
|
9600
|
-
return
|
|
9574
|
+
return _context6.a(2, _context6.v);
|
|
9601
9575
|
case 3:
|
|
9602
|
-
|
|
9576
|
+
_context6.p = 3;
|
|
9603
9577
|
api.disconnectAllowed = true;
|
|
9604
|
-
|
|
9578
|
+
_context6.n = 4;
|
|
9605
9579
|
return api.disconnect();
|
|
9606
9580
|
case 4:
|
|
9607
|
-
return
|
|
9581
|
+
return _context6.f(3);
|
|
9608
9582
|
case 5:
|
|
9609
|
-
return
|
|
9583
|
+
return _context6.a(2);
|
|
9610
9584
|
}
|
|
9611
|
-
},
|
|
9585
|
+
}, _callee6, null, [[1,, 3, 5]]);
|
|
9612
9586
|
}));
|
|
9613
|
-
return function getTransferableAmount(
|
|
9614
|
-
return
|
|
9587
|
+
return function getTransferableAmount(_x11) {
|
|
9588
|
+
return _ref7.apply(this, arguments);
|
|
9615
9589
|
};
|
|
9616
9590
|
}();
|
|
9617
9591
|
|
|
@@ -9804,6 +9778,8 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9804
9778
|
paraIdTo,
|
|
9805
9779
|
sender,
|
|
9806
9780
|
ahAddress,
|
|
9781
|
+
overriddenAsset,
|
|
9782
|
+
overriddenAssets,
|
|
9807
9783
|
buildRefundInstruction,
|
|
9808
9784
|
hopFees,
|
|
9809
9785
|
destFee,
|
|
@@ -9815,6 +9791,7 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9815
9791
|
asset,
|
|
9816
9792
|
allOfSelector,
|
|
9817
9793
|
depositInstruction,
|
|
9794
|
+
localizeFilterAsset,
|
|
9818
9795
|
assetsFilter,
|
|
9819
9796
|
isAssetEthereumNative,
|
|
9820
9797
|
buyExecutionAmount,
|
|
@@ -9835,7 +9812,8 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9835
9812
|
destFee: 0n
|
|
9836
9813
|
};
|
|
9837
9814
|
origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, bridgeHopChain = context.bridgeHopChain, options = context.options;
|
|
9838
|
-
destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress;
|
|
9815
|
+
destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, overriddenAsset = options.overriddenAsset;
|
|
9816
|
+
overriddenAssets = Array.isArray(overriddenAsset) ? overriddenAsset : null;
|
|
9839
9817
|
buildRefundInstruction = function buildRefundInstruction() {
|
|
9840
9818
|
if (!sender || isSubBridge) return null;
|
|
9841
9819
|
var resolveRefundAddress = function resolveRefundAddress() {
|
|
@@ -9882,8 +9860,8 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9882
9860
|
depositInstruction = {
|
|
9883
9861
|
DepositAsset: {
|
|
9884
9862
|
assets: {
|
|
9885
|
-
Wild: assetCount > 1 ? allOfSelector : {
|
|
9886
|
-
AllCounted:
|
|
9863
|
+
Wild: assetCount > 1 && !overriddenAssets ? allOfSelector : {
|
|
9864
|
+
AllCounted: assetCount
|
|
9887
9865
|
}
|
|
9888
9866
|
},
|
|
9889
9867
|
beneficiary: createBeneficiaryLocation({
|
|
@@ -9893,9 +9871,18 @@ var createCustomXcm = /*#__PURE__*/function () {
|
|
|
9893
9871
|
})
|
|
9894
9872
|
}
|
|
9895
9873
|
};
|
|
9874
|
+
localizeFilterAsset = function localizeFilterAsset(amount, location) {
|
|
9875
|
+
return createAsset(version, amount, normalizeLocation(localizeLocationImpl(origin.api, reserve.chain, location), version));
|
|
9876
|
+
};
|
|
9896
9877
|
assetsFilter = [];
|
|
9897
|
-
if (
|
|
9898
|
-
|
|
9878
|
+
if (overriddenAssets) {
|
|
9879
|
+
assetsFilter.push.apply(assetsFilter, _toConsumableArray(overriddenAssets.map(function (asset) {
|
|
9880
|
+
return localizeFilterAsset(asset.fun.Fungible, extractAssetLocation(asset));
|
|
9881
|
+
})));
|
|
9882
|
+
} else {
|
|
9883
|
+
if (!isRelayAsset && !isExternalChain(dest.chain)) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocationImpl(origin.api, reserve.chain, RELAY_LOCATION)));
|
|
9884
|
+
assetsFilter.push(localizeFilterAsset(assetInfo.amount, assetInfo.location));
|
|
9885
|
+
}
|
|
9899
9886
|
isAssetEthereumNative = deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), getEthereumJunction(origin.api, origin.chain, false).GlobalConsensus);
|
|
9900
9887
|
if (!(isSubBridge || bridgeHopChain || origin.chain !== reserve.chain && dest.chain !== reserve.chain)) {
|
|
9901
9888
|
_context.n = 6;
|
|
@@ -10271,44 +10258,58 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
|
|
|
10271
10258
|
return totalHopFee + destFee;
|
|
10272
10259
|
};
|
|
10273
10260
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
10274
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
10275
|
-
var
|
|
10276
|
-
|
|
10277
|
-
|
|
10261
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
10262
|
+
var _destAssets$find;
|
|
10263
|
+
var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method, isTypeAndThenMethod, verifyAsset, results;
|
|
10264
|
+
return _regenerator().w(function (_context2) {
|
|
10265
|
+
while (1) switch (_context2.n) {
|
|
10278
10266
|
case 0:
|
|
10279
10267
|
api = options.api, buildTx = options.buildTx, origin = options.origin, destination = options.destination, currency = options.currency, sender = options.sender, recipient = options.recipient, feeAsset = options.feeAsset, version = options.version;
|
|
10280
10268
|
if (!isExternalChain(destination)) {
|
|
10281
|
-
|
|
10269
|
+
_context2.n = 1;
|
|
10282
10270
|
break;
|
|
10283
10271
|
}
|
|
10284
|
-
return
|
|
10272
|
+
return _context2.a(2, true);
|
|
10285
10273
|
case 1:
|
|
10286
10274
|
validateAddress(api, recipient, destination, true);
|
|
10287
10275
|
isSubBridge = isSubstrateBridge(origin, destination);
|
|
10288
10276
|
if (!isSubBridge) {
|
|
10289
|
-
|
|
10277
|
+
_context2.n = 2;
|
|
10290
10278
|
break;
|
|
10291
10279
|
}
|
|
10292
10280
|
throw new ScenarioNotSupportedError('Unable to verify the existential deposit for substrate bridge scenarios');
|
|
10293
10281
|
case 2:
|
|
10282
|
+
assertNotRawAssets(currency);
|
|
10283
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
10294
10284
|
destApi = api.clone();
|
|
10295
|
-
|
|
10285
|
+
_context2.n = 3;
|
|
10296
10286
|
return destApi.init(destination);
|
|
10297
10287
|
case 3:
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10288
|
+
resolvedAssets = Array.isArray(currency) ? resolveCurrency(api, currency, resolvedFeeAsset, origin, destination).assets.map(function (asset, index) {
|
|
10289
|
+
return {
|
|
10290
|
+
selector: currency[index],
|
|
10291
|
+
paysDestFee: !!asset.isFeeAsset
|
|
10292
|
+
};
|
|
10293
|
+
}) : [{
|
|
10294
|
+
selector: currency,
|
|
10295
|
+
paysDestFee: true
|
|
10296
|
+
}];
|
|
10297
|
+
destAssets = resolvedAssets.map(function (_ref2) {
|
|
10298
|
+
var selector = _ref2.selector,
|
|
10299
|
+
paysDestFee = _ref2.paysDestFee;
|
|
10300
|
+
var destAsset = api.findAssetOnDestOrThrow(origin, destination, selector);
|
|
10301
|
+
return {
|
|
10302
|
+
destAsset: destAsset,
|
|
10303
|
+
amount: abstractDecimals(selector.amount, destAsset.decimals, api),
|
|
10304
|
+
paysDestFee: paysDestFee
|
|
10305
|
+
};
|
|
10308
10306
|
});
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10307
|
+
_destAssets = _slicedToArray(destAssets, 1), firstAsset = _destAssets[0];
|
|
10308
|
+
feeElement = (_destAssets$find = destAssets.find(function (_ref3) {
|
|
10309
|
+
var paysDestFee = _ref3.paysDestFee;
|
|
10310
|
+
return paysDestFee;
|
|
10311
|
+
})) !== null && _destAssets$find !== void 0 ? _destAssets$find : firstAsset;
|
|
10312
|
+
_context2.n = 4;
|
|
10312
10313
|
return getXcmFeeInternal({
|
|
10313
10314
|
api: api,
|
|
10314
10315
|
buildTx: buildTx,
|
|
@@ -10316,59 +10317,84 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
10316
10317
|
destination: destination,
|
|
10317
10318
|
sender: sender,
|
|
10318
10319
|
recipient: recipient,
|
|
10319
|
-
currency: _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
10320
|
-
amount: amount
|
|
10320
|
+
currency: Array.isArray(currency) ? currency : _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
10321
|
+
amount: feeElement.amount
|
|
10321
10322
|
}),
|
|
10322
10323
|
version: version,
|
|
10323
10324
|
feeAsset: feeAsset,
|
|
10324
10325
|
disableFallback: false
|
|
10325
10326
|
});
|
|
10326
|
-
case
|
|
10327
|
-
xcmFeeResult =
|
|
10327
|
+
case 4:
|
|
10328
|
+
xcmFeeResult = _context2.v;
|
|
10328
10329
|
dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
10329
10330
|
if (!dryRunError) {
|
|
10330
|
-
|
|
10331
|
+
_context2.n = 5;
|
|
10331
10332
|
break;
|
|
10332
10333
|
}
|
|
10333
10334
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
10334
|
-
case
|
|
10335
|
+
case 5:
|
|
10335
10336
|
erroredHop = hops.find(function (hop) {
|
|
10336
10337
|
return hop.result.dryRunError;
|
|
10337
10338
|
});
|
|
10338
10339
|
hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
|
|
10339
10340
|
if (!hopError) {
|
|
10340
|
-
|
|
10341
|
+
_context2.n = 6;
|
|
10341
10342
|
break;
|
|
10342
10343
|
}
|
|
10343
10344
|
throw new DryRunFailedError(hopError, erroredHop.chain);
|
|
10344
|
-
case
|
|
10345
|
+
case 6:
|
|
10345
10346
|
if (!destDryRunError) {
|
|
10346
|
-
|
|
10347
|
+
_context2.n = 7;
|
|
10347
10348
|
break;
|
|
10348
10349
|
}
|
|
10349
10350
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
10350
|
-
case
|
|
10351
|
-
isUnableToCompute = !isSymbolMatch(normalizeSymbol(destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
|
|
10351
|
+
case 7:
|
|
10352
|
+
isUnableToCompute = !isSymbolMatch(normalizeSymbol(feeElement.destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
|
|
10352
10353
|
if (!isUnableToCompute) {
|
|
10353
|
-
|
|
10354
|
+
_context2.n = 8;
|
|
10354
10355
|
break;
|
|
10355
10356
|
}
|
|
10356
10357
|
throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
|
|
10357
|
-
case
|
|
10358
|
-
|
|
10358
|
+
case 8:
|
|
10359
|
+
_context2.n = 9;
|
|
10359
10360
|
return buildTx();
|
|
10360
|
-
case
|
|
10361
|
-
tx =
|
|
10362
|
-
totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
|
|
10361
|
+
case 9:
|
|
10362
|
+
tx = _context2.v;
|
|
10363
10363
|
method = api.getMethod(tx);
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10364
|
+
isTypeAndThenMethod = method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen';
|
|
10365
|
+
verifyAsset = /*#__PURE__*/function () {
|
|
10366
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
|
|
10367
|
+
var destAsset, amount, paysDestFee, ed, balance, feeToSubtract;
|
|
10368
|
+
return _regenerator().w(function (_context) {
|
|
10369
|
+
while (1) switch (_context.n) {
|
|
10370
|
+
case 0:
|
|
10371
|
+
destAsset = _ref4.destAsset, amount = _ref4.amount, paysDestFee = _ref4.paysDestFee;
|
|
10372
|
+
ed = getEdFromAssetOrThrow(destAsset);
|
|
10373
|
+
_context.n = 1;
|
|
10374
|
+
return getAssetBalanceInternal({
|
|
10375
|
+
address: recipient,
|
|
10376
|
+
chain: destination,
|
|
10377
|
+
api: destApi,
|
|
10378
|
+
asset: destAsset
|
|
10379
|
+
});
|
|
10380
|
+
case 1:
|
|
10381
|
+
balance = _context.v;
|
|
10382
|
+
feeToSubtract = isTypeAndThenMethod ? calculateTotalXcmFee(destAsset, xcmFeeResult) : paysDestFee ? destFee : 0n;
|
|
10383
|
+
return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
|
|
10384
|
+
}
|
|
10385
|
+
}, _callee);
|
|
10386
|
+
}));
|
|
10387
|
+
return function verifyAsset(_x2) {
|
|
10388
|
+
return _ref5.apply(this, arguments);
|
|
10389
|
+
};
|
|
10390
|
+
}();
|
|
10391
|
+
_context2.n = 10;
|
|
10392
|
+
return Promise.all(destAssets.map(verifyAsset));
|
|
10393
|
+
case 10:
|
|
10394
|
+
results = _context2.v;
|
|
10395
|
+
return _context2.a(2, results.every(Boolean));
|
|
10370
10396
|
}
|
|
10371
|
-
},
|
|
10397
|
+
}, _callee2);
|
|
10372
10398
|
}));
|
|
10373
10399
|
return function verifyEdOnDestinationInternal(_x) {
|
|
10374
10400
|
return _ref.apply(this, arguments);
|
|
@@ -11633,6 +11659,13 @@ var Acala = /*#__PURE__*/function (_Chain) {
|
|
|
11633
11659
|
ForeignAsset: Number(asset.assetId)
|
|
11634
11660
|
};
|
|
11635
11661
|
}
|
|
11662
|
+
}, {
|
|
11663
|
+
key: "getMintConfig",
|
|
11664
|
+
value: function getMintConfig() {
|
|
11665
|
+
return {
|
|
11666
|
+
useCustomCurrencyId: true
|
|
11667
|
+
};
|
|
11668
|
+
}
|
|
11636
11669
|
}, {
|
|
11637
11670
|
key: "getBalance",
|
|
11638
11671
|
value: function getBalance(api, address, asset) {
|
|
@@ -11758,34 +11791,28 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Chain) {
|
|
|
11758
11791
|
while (1) switch (_context.n) {
|
|
11759
11792
|
case 0:
|
|
11760
11793
|
api = options.api, assetInfo = options.assetInfo, feeAssetInfo = options.feeAssetInfo, overriddenAsset = options.overriddenAsset;
|
|
11761
|
-
if (!feeAssetInfo) {
|
|
11762
|
-
_context.n =
|
|
11763
|
-
break;
|
|
11764
|
-
}
|
|
11765
|
-
if (!overriddenAsset) {
|
|
11766
|
-
_context.n = 1;
|
|
11794
|
+
if (!(feeAssetInfo && !overriddenAsset)) {
|
|
11795
|
+
_context.n = 3;
|
|
11767
11796
|
break;
|
|
11768
11797
|
}
|
|
11769
|
-
throw new InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
|
|
11770
|
-
case 1:
|
|
11771
11798
|
if (!isSymbolMatch(assetInfo.symbol, 'KSM')) {
|
|
11772
|
-
_context.n =
|
|
11799
|
+
_context.n = 1;
|
|
11773
11800
|
break;
|
|
11774
11801
|
}
|
|
11775
11802
|
return _context.a(2, transferPolkadotXcm(options));
|
|
11776
|
-
case
|
|
11803
|
+
case 1:
|
|
11777
11804
|
isNativeAsset = isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol(api));
|
|
11778
11805
|
isNativeFeeAsset = isSymbolMatch(feeAssetInfo.symbol, this.getNativeAssetSymbol(api));
|
|
11779
11806
|
if (!(!isNativeAsset || !isNativeFeeAsset)) {
|
|
11780
|
-
_context.n =
|
|
11807
|
+
_context.n = 3;
|
|
11781
11808
|
break;
|
|
11782
11809
|
}
|
|
11783
11810
|
_t = api;
|
|
11784
|
-
_context.n =
|
|
11811
|
+
_context.n = 2;
|
|
11785
11812
|
return handleExecuteTransfer(options);
|
|
11786
|
-
case
|
|
11813
|
+
case 2:
|
|
11787
11814
|
return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
|
|
11788
|
-
case
|
|
11815
|
+
case 3:
|
|
11789
11816
|
return _context.a(2, transferPolkadotXcm(options));
|
|
11790
11817
|
}
|
|
11791
11818
|
}, _callee, this);
|
|
@@ -11896,6 +11923,13 @@ var Astar = /*#__PURE__*/function (_Chain) {
|
|
|
11896
11923
|
}
|
|
11897
11924
|
_inherits(Astar, _Chain);
|
|
11898
11925
|
return _createClass(Astar, [{
|
|
11926
|
+
key: "getMintConfig",
|
|
11927
|
+
value: function getMintConfig() {
|
|
11928
|
+
return {
|
|
11929
|
+
useBigIntId: true
|
|
11930
|
+
};
|
|
11931
|
+
}
|
|
11932
|
+
}, {
|
|
11899
11933
|
key: "transferPolkadotXCM",
|
|
11900
11934
|
value: function transferPolkadotXCM(input) {
|
|
11901
11935
|
return transferPolkadotXcm(input, 'transfer_assets_using_type_and_then');
|
|
@@ -11953,6 +11987,13 @@ var Hydration = /*#__PURE__*/function (_Chain) {
|
|
|
11953
11987
|
}
|
|
11954
11988
|
_inherits(Hydration, _Chain);
|
|
11955
11989
|
return _createClass(Hydration, [{
|
|
11990
|
+
key: "getMintConfig",
|
|
11991
|
+
value: function getMintConfig() {
|
|
11992
|
+
return {
|
|
11993
|
+
useIdPrefix: false
|
|
11994
|
+
};
|
|
11995
|
+
}
|
|
11996
|
+
}, {
|
|
11956
11997
|
key: "transferPolkadotXCM",
|
|
11957
11998
|
value: function () {
|
|
11958
11999
|
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
|
|
@@ -11961,34 +12002,28 @@ var Hydration = /*#__PURE__*/function (_Chain) {
|
|
|
11961
12002
|
while (1) switch (_context.n) {
|
|
11962
12003
|
case 0:
|
|
11963
12004
|
destination = input.destination, asset = input.assetInfo, feeAsset = input.feeAssetInfo, overriddenAsset = input.overriddenAsset, api = input.api;
|
|
11964
|
-
if (!feeAsset) {
|
|
11965
|
-
_context.n =
|
|
11966
|
-
break;
|
|
11967
|
-
}
|
|
11968
|
-
if (!overriddenAsset) {
|
|
11969
|
-
_context.n = 1;
|
|
12005
|
+
if (!(feeAsset && !overriddenAsset)) {
|
|
12006
|
+
_context.n = 2;
|
|
11970
12007
|
break;
|
|
11971
12008
|
}
|
|
11972
|
-
throw new InvalidCurrencyError('Cannot use overridden assets with XCM execute');
|
|
11973
|
-
case 1:
|
|
11974
12009
|
isNativeAsset = isSymbolMatch(asset.symbol, this.getNativeAssetSymbol(api));
|
|
11975
12010
|
isNativeFeeAsset = isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol(api));
|
|
11976
12011
|
if (!(!isNativeAsset || !isNativeFeeAsset)) {
|
|
11977
|
-
_context.n =
|
|
12012
|
+
_context.n = 2;
|
|
11978
12013
|
break;
|
|
11979
12014
|
}
|
|
11980
12015
|
_t = api;
|
|
11981
|
-
_context.n =
|
|
12016
|
+
_context.n = 1;
|
|
11982
12017
|
return handleExecuteTransfer(input);
|
|
11983
|
-
case
|
|
12018
|
+
case 1:
|
|
11984
12019
|
return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
|
|
11985
|
-
case
|
|
12020
|
+
case 2:
|
|
11986
12021
|
if (!(isMoonbeamWhAsset(asset.location) && destination === 'Moonbeam')) {
|
|
11987
|
-
_context.n =
|
|
12022
|
+
_context.n = 3;
|
|
11988
12023
|
break;
|
|
11989
12024
|
}
|
|
11990
12025
|
return _context.a(2, this.transferMoonbeamWhAsset(input));
|
|
11991
|
-
case
|
|
12026
|
+
case 3:
|
|
11992
12027
|
return _context.a(2, transferPolkadotXcm(input));
|
|
11993
12028
|
}
|
|
11994
12029
|
}, _callee, this);
|
|
@@ -12129,6 +12164,13 @@ var BifrostPolkadot = /*#__PURE__*/function (_Chain) {
|
|
|
12129
12164
|
Token2: id
|
|
12130
12165
|
};
|
|
12131
12166
|
}
|
|
12167
|
+
}, {
|
|
12168
|
+
key: "getMintConfig",
|
|
12169
|
+
value: function getMintConfig() {
|
|
12170
|
+
return {
|
|
12171
|
+
useCustomCurrencyId: true
|
|
12172
|
+
};
|
|
12173
|
+
}
|
|
12132
12174
|
}, {
|
|
12133
12175
|
key: "transferPolkadotXCM",
|
|
12134
12176
|
value: function transferPolkadotXCM(options) {
|
|
@@ -12534,6 +12576,13 @@ var Darwinia = /*#__PURE__*/function (_Chain) {
|
|
|
12534
12576
|
}
|
|
12535
12577
|
_inherits(Darwinia, _Chain);
|
|
12536
12578
|
return _createClass(Darwinia, [{
|
|
12579
|
+
key: "getMintConfig",
|
|
12580
|
+
value: function getMintConfig() {
|
|
12581
|
+
return {
|
|
12582
|
+
useBigIntId: true
|
|
12583
|
+
};
|
|
12584
|
+
}
|
|
12585
|
+
}, {
|
|
12537
12586
|
key: "transferPolkadotXCM",
|
|
12538
12587
|
value: function transferPolkadotXCM(input) {
|
|
12539
12588
|
var scenario = input.scenario,
|
|
@@ -12629,6 +12678,13 @@ var EnergyWebX = /*#__PURE__*/function (_Chain) {
|
|
|
12629
12678
|
value: function isRelayToParaEnabled() {
|
|
12630
12679
|
return false;
|
|
12631
12680
|
}
|
|
12681
|
+
}, {
|
|
12682
|
+
key: "getMintConfig",
|
|
12683
|
+
value: function getMintConfig() {
|
|
12684
|
+
return {
|
|
12685
|
+
useLocationId: true
|
|
12686
|
+
};
|
|
12687
|
+
}
|
|
12632
12688
|
}, {
|
|
12633
12689
|
key: "getBalanceForeign",
|
|
12634
12690
|
value: function () {
|
|
@@ -13095,6 +13151,14 @@ var NeuroWeb = /*#__PURE__*/function (_Chain) {
|
|
|
13095
13151
|
}
|
|
13096
13152
|
_inherits(NeuroWeb, _Chain);
|
|
13097
13153
|
return _createClass(NeuroWeb, [{
|
|
13154
|
+
key: "getMintConfig",
|
|
13155
|
+
value: function getMintConfig() {
|
|
13156
|
+
return {
|
|
13157
|
+
useIdPrefix: false,
|
|
13158
|
+
useBigIntId: true
|
|
13159
|
+
};
|
|
13160
|
+
}
|
|
13161
|
+
}, {
|
|
13098
13162
|
key: "transferPolkadotXCM",
|
|
13099
13163
|
value: function transferPolkadotXCM(input) {
|
|
13100
13164
|
return transferPolkadotXcm(input);
|
|
@@ -13367,6 +13431,16 @@ var Quartz = /*#__PURE__*/function (_Chain) {
|
|
|
13367
13431
|
value: function transferPolkadotXCM(input) {
|
|
13368
13432
|
return transferPolkadotXcm(input);
|
|
13369
13433
|
}
|
|
13434
|
+
}, {
|
|
13435
|
+
key: "transferLocalNonNativeAsset",
|
|
13436
|
+
value: function transferLocalNonNativeAsset(options) {
|
|
13437
|
+
return getChain('Unique').transferLocalNonNativeAsset(options);
|
|
13438
|
+
}
|
|
13439
|
+
}, {
|
|
13440
|
+
key: "getBalanceForeign",
|
|
13441
|
+
value: function getBalanceForeign(api, address, asset) {
|
|
13442
|
+
return getChain('Unique').getBalanceForeign(api, address, asset);
|
|
13443
|
+
}
|
|
13370
13444
|
}, {
|
|
13371
13445
|
key: "isSendingTempDisabled",
|
|
13372
13446
|
value: function isSendingTempDisabled() {
|
|
@@ -13432,6 +13506,7 @@ var Shiden = /*#__PURE__*/function (_Astar) {
|
|
|
13432
13506
|
return _createClass(Shiden);
|
|
13433
13507
|
}(Astar);
|
|
13434
13508
|
|
|
13509
|
+
var FUNGIBLE_ITEM_ID = 0;
|
|
13435
13510
|
var Unique = /*#__PURE__*/function (_Chain) {
|
|
13436
13511
|
function Unique() {
|
|
13437
13512
|
_classCallCheck(this, Unique);
|
|
@@ -13445,36 +13520,44 @@ var Unique = /*#__PURE__*/function (_Chain) {
|
|
|
13445
13520
|
}
|
|
13446
13521
|
}, {
|
|
13447
13522
|
key: "transferLocalNonNativeAsset",
|
|
13448
|
-
value: function transferLocalNonNativeAsset(
|
|
13449
|
-
|
|
13523
|
+
value: function transferLocalNonNativeAsset(options) {
|
|
13524
|
+
var api = options.api,
|
|
13525
|
+
asset = options.assetInfo,
|
|
13526
|
+
recipient = options.recipient;
|
|
13527
|
+
assertHasId(asset);
|
|
13528
|
+
var amount = getLocalTransferAmount(options);
|
|
13529
|
+
return api.deserializeExtrinsics({
|
|
13530
|
+
module: 'Unique',
|
|
13531
|
+
method: 'transfer',
|
|
13532
|
+
params: {
|
|
13533
|
+
recipient: {
|
|
13534
|
+
Substrate: recipient
|
|
13535
|
+
},
|
|
13536
|
+
collection_id: Number(asset.assetId),
|
|
13537
|
+
item_id: FUNGIBLE_ITEM_ID,
|
|
13538
|
+
value: amount
|
|
13539
|
+
}
|
|
13540
|
+
});
|
|
13450
13541
|
}
|
|
13451
13542
|
}, {
|
|
13452
13543
|
key: "getBalanceForeign",
|
|
13453
13544
|
value: function () {
|
|
13454
13545
|
var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
|
|
13455
13546
|
var _ref, _balance$value;
|
|
13456
|
-
var
|
|
13547
|
+
var balance;
|
|
13457
13548
|
return _regenerator().w(function (_context) {
|
|
13458
13549
|
while (1) switch (_context.n) {
|
|
13459
13550
|
case 0:
|
|
13460
13551
|
assertHasId(asset);
|
|
13461
13552
|
_context.n = 1;
|
|
13462
|
-
return api.queryState({
|
|
13463
|
-
module: 'ForeignAssets',
|
|
13464
|
-
method: 'ForeignAssetToCollection',
|
|
13465
|
-
params: [asset.location]
|
|
13466
|
-
});
|
|
13467
|
-
case 1:
|
|
13468
|
-
collectionId = _context.v;
|
|
13469
|
-
_context.n = 2;
|
|
13470
13553
|
return api.queryRuntimeApi({
|
|
13471
13554
|
module: 'UniqueApi',
|
|
13472
13555
|
method: 'balance',
|
|
13473
|
-
params: [
|
|
13556
|
+
params: [Number(asset.assetId), {
|
|
13474
13557
|
Substrate: address
|
|
13475
|
-
},
|
|
13558
|
+
}, FUNGIBLE_ITEM_ID]
|
|
13476
13559
|
});
|
|
13477
|
-
case
|
|
13560
|
+
case 1:
|
|
13478
13561
|
balance = _context.v;
|
|
13479
13562
|
return _context.a(2, (_ref = (_balance$value = balance === null || balance === void 0 ? void 0 : balance.value) !== null && _balance$value !== void 0 ? _balance$value : (balance === null || balance === void 0 ? void 0 : balance.ok) != undefined ? BigInt(balance.ok) : undefined) !== null && _ref !== void 0 ? _ref : 0n);
|
|
13480
13563
|
}
|
|
@@ -13878,6 +13961,17 @@ var maybeOverrideAsset = function maybeOverrideAsset(version, amount, asset, ove
|
|
|
13878
13961
|
return createAsset(version, amount, overriddenCurrency);
|
|
13879
13962
|
};
|
|
13880
13963
|
|
|
13964
|
+
var pickOtherMintPallet = function pickOtherMintPallet(asset, pallets) {
|
|
13965
|
+
if (!asset.isNative && (!asset.assetId || asset.assetId.startsWith('0x'))) {
|
|
13966
|
+
var _pallets$find;
|
|
13967
|
+
// No assetId means it's probably a ForeignAssets pallet asset
|
|
13968
|
+
return (_pallets$find = pallets.find(function (pallet) {
|
|
13969
|
+
return pallet.startsWith('Foreign');
|
|
13970
|
+
})) !== null && _pallets$find !== void 0 ? _pallets$find : pallets[0];
|
|
13971
|
+
}
|
|
13972
|
+
return pallets[0];
|
|
13973
|
+
};
|
|
13974
|
+
|
|
13881
13975
|
var isHere = function isHere(loc) {
|
|
13882
13976
|
var _loc$interior;
|
|
13883
13977
|
return loc.interior === 'Here' || ((_loc$interior = loc.interior) === null || _loc$interior === void 0 ? void 0 : _loc$interior.Here) !== undefined;
|
|
@@ -13916,6 +14010,17 @@ var _excluded = ["apiOverrides"];
|
|
|
13916
14010
|
var isUrl = function isUrl(value) {
|
|
13917
14011
|
return typeof value === 'string' || Array.isArray(value);
|
|
13918
14012
|
};
|
|
14013
|
+
/**
|
|
14014
|
+
* Checks if a given chain is a supported exchange chain.
|
|
14015
|
+
*
|
|
14016
|
+
* @param chain - The chain to check.
|
|
14017
|
+
* @returns True if the chain is a supported exchange chain; otherwise, false.
|
|
14018
|
+
*/
|
|
14019
|
+
var isExchange = function isExchange(chain) {
|
|
14020
|
+
return EXCHANGE_CHAINS.some(function (c) {
|
|
14021
|
+
return c === chain;
|
|
14022
|
+
});
|
|
14023
|
+
};
|
|
13919
14024
|
var convertBuilderConfig = function convertBuilderConfig(config) {
|
|
13920
14025
|
if (!config) return undefined;
|
|
13921
14026
|
if (isConfig(config)) {
|
|
@@ -14013,12 +14118,23 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
|
|
|
14013
14118
|
};
|
|
14014
14119
|
var overrideTxAmount = /*#__PURE__*/function () {
|
|
14015
14120
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder, amount, relative) {
|
|
14016
|
-
var modifiedBuilder, _yield$modifiedBuilde, tx;
|
|
14121
|
+
var currency, overrideAmount, modifiedBuilder, _yield$modifiedBuilde, tx;
|
|
14017
14122
|
return _regenerator().w(function (_context) {
|
|
14018
14123
|
while (1) switch (_context.n) {
|
|
14019
14124
|
case 0:
|
|
14020
|
-
|
|
14021
|
-
|
|
14125
|
+
currency = options.currency;
|
|
14126
|
+
assertNotRawAssets(currency);
|
|
14127
|
+
overrideAmount = function overrideAmount(item) {
|
|
14128
|
+
return computeOverridenAmount(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
14129
|
+
currency: item
|
|
14130
|
+
}), amount, relative);
|
|
14131
|
+
};
|
|
14132
|
+
modifiedBuilder = builder.currency(Array.isArray(currency) ? currency.map(function (item) {
|
|
14133
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
14134
|
+
amount: overrideAmount(item)
|
|
14135
|
+
});
|
|
14136
|
+
}) : _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
14137
|
+
amount: overrideAmount(currency)
|
|
14022
14138
|
}));
|
|
14023
14139
|
_context.n = 1;
|
|
14024
14140
|
return modifiedBuilder['buildInternal']();
|
|
@@ -14156,6 +14272,8 @@ var resolveModuleError = function resolveModuleError(chain, error) {
|
|
|
14156
14272
|
throw new RoutingResolutionError("Error index ".concat(errorIndex, " not found in ").concat(name, " pallet"));
|
|
14157
14273
|
}
|
|
14158
14274
|
if (failureReason === PolkadotXcmError.LocalExecutionIncompleteWithError) {
|
|
14275
|
+
// Byte layout: [pallet error variant][instruction index][xcm sub-error]
|
|
14276
|
+
var failureIndex = Number("0x".concat(error.error.slice(4, 6)));
|
|
14159
14277
|
var subErrorIndex = Number("0x".concat(error.error.slice(6, 8)));
|
|
14160
14278
|
var failureSubReason = Object.values(PolkadotXcmExecutionError)[subErrorIndex];
|
|
14161
14279
|
if (!failureSubReason) {
|
|
@@ -14163,7 +14281,8 @@ var resolveModuleError = function resolveModuleError(chain, error) {
|
|
|
14163
14281
|
}
|
|
14164
14282
|
return {
|
|
14165
14283
|
failureReason: failureReason,
|
|
14166
|
-
failureSubReason: failureSubReason
|
|
14284
|
+
failureSubReason: failureSubReason,
|
|
14285
|
+
failureIndex: failureIndex
|
|
14167
14286
|
};
|
|
14168
14287
|
}
|
|
14169
14288
|
return {
|
|
@@ -14879,4 +14998,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
|
|
|
14879
14998
|
};
|
|
14880
14999
|
};
|
|
14881
15000
|
|
|
14882
|
-
export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
|
|
15001
|
+
export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertNotRawAssets, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isExchange, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
|