@paraspell/sdk 7.1.1 → 7.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +220 -107
- package/dist/index.d.ts +8 -1
- package/dist/index.mjs +220 -107
- package/dist/papi/index.cjs +220 -107
- package/dist/papi/index.d.ts +8 -1
- package/dist/papi/index.mjs +220 -107
- package/package.json +3 -1
package/dist/papi/index.cjs
CHANGED
|
@@ -2505,14 +2505,16 @@ var AssetHubPolkadot$3 = {
|
|
|
2505
2505
|
},
|
|
2506
2506
|
{
|
|
2507
2507
|
symbol: "KSM",
|
|
2508
|
-
decimals: 12
|
|
2508
|
+
decimals: 12,
|
|
2509
|
+
manuallyAdded: true
|
|
2509
2510
|
}
|
|
2510
2511
|
],
|
|
2511
2512
|
otherAssets: [
|
|
2512
2513
|
{
|
|
2513
2514
|
assetId: "",
|
|
2514
2515
|
symbol: "MYTH",
|
|
2515
|
-
decimals: 18
|
|
2516
|
+
decimals: 18,
|
|
2517
|
+
manuallyAdded: true
|
|
2516
2518
|
},
|
|
2517
2519
|
{
|
|
2518
2520
|
assetId: "22222005",
|
|
@@ -6345,7 +6347,8 @@ var AssetHubKusama$3 = {
|
|
|
6345
6347
|
nativeAssets: [
|
|
6346
6348
|
{
|
|
6347
6349
|
symbol: "KSM",
|
|
6348
|
-
decimals: 12
|
|
6350
|
+
decimals: 12,
|
|
6351
|
+
manuallyAdded: true
|
|
6349
6352
|
},
|
|
6350
6353
|
{
|
|
6351
6354
|
symbol: "DOT",
|
|
@@ -9253,6 +9256,19 @@ var ComposableFinance$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9253
9256
|
}]);
|
|
9254
9257
|
}(ParachainNode);
|
|
9255
9258
|
|
|
9259
|
+
var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
|
|
9260
|
+
return {
|
|
9261
|
+
parents: exports.Parents.TWO,
|
|
9262
|
+
interior: {
|
|
9263
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9264
|
+
AccountKey20: {
|
|
9265
|
+
key: currencyId
|
|
9266
|
+
}
|
|
9267
|
+
}]
|
|
9268
|
+
}
|
|
9269
|
+
};
|
|
9270
|
+
};
|
|
9271
|
+
|
|
9256
9272
|
var calculateFee = function calculateFee(api) {
|
|
9257
9273
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9258
9274
|
var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
@@ -9280,18 +9296,6 @@ var calculateFee = function calculateFee(api) {
|
|
|
9280
9296
|
}, _callee);
|
|
9281
9297
|
}));
|
|
9282
9298
|
};
|
|
9283
|
-
var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
|
|
9284
|
-
return {
|
|
9285
|
-
parents: exports.Parents.TWO,
|
|
9286
|
-
interior: {
|
|
9287
|
-
X2: [ETHEREUM_JUNCTION, {
|
|
9288
|
-
AccountKey20: {
|
|
9289
|
-
key: currencyId
|
|
9290
|
-
}
|
|
9291
|
-
}]
|
|
9292
|
-
}
|
|
9293
|
-
};
|
|
9294
|
-
};
|
|
9295
9299
|
var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
|
|
9296
9300
|
var api = _ref.api,
|
|
9297
9301
|
scenario = _ref.scenario,
|
|
@@ -9940,10 +9944,50 @@ var Karura$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9940
9944
|
}]);
|
|
9941
9945
|
}(ParachainNode);
|
|
9942
9946
|
|
|
9947
|
+
var createCustomXcmToBifrost = function createCustomXcmToBifrost(_ref, version) {
|
|
9948
|
+
var api = _ref.api,
|
|
9949
|
+
address = _ref.address,
|
|
9950
|
+
scenario = _ref.scenario;
|
|
9951
|
+
return _defineProperty({}, version, [{
|
|
9952
|
+
DepositAsset: {
|
|
9953
|
+
assets: {
|
|
9954
|
+
Wild: 'All'
|
|
9955
|
+
},
|
|
9956
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
|
|
9957
|
+
}
|
|
9958
|
+
}]);
|
|
9959
|
+
};
|
|
9943
9960
|
var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
9944
9961
|
function AssetHubPolkadot() {
|
|
9962
|
+
var _this;
|
|
9945
9963
|
_classCallCheck(this, AssetHubPolkadot);
|
|
9946
|
-
|
|
9964
|
+
_this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', exports.Version.V3]);
|
|
9965
|
+
_this.handleBifrostEthTransfer = function (input) {
|
|
9966
|
+
var api = input.api,
|
|
9967
|
+
amount = input.amount,
|
|
9968
|
+
scenario = input.scenario,
|
|
9969
|
+
version = input.version,
|
|
9970
|
+
destination = input.destination,
|
|
9971
|
+
currencyId = input.currencyId;
|
|
9972
|
+
var versionOrDefault = version !== null && version !== void 0 ? version : _this.version;
|
|
9973
|
+
var call = {
|
|
9974
|
+
module: 'PolkadotXcm',
|
|
9975
|
+
section: 'transfer_assets_using_type_and_then',
|
|
9976
|
+
parameters: {
|
|
9977
|
+
dest: _this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('BifrostPolkadot')),
|
|
9978
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(createCurrencySpec(amount, versionOrDefault, exports.Parents.TWO, createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')))[0][0]]),
|
|
9979
|
+
assets_transfer_type: 'LocalReserve',
|
|
9980
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
9981
|
+
Concrete: createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')
|
|
9982
|
+
}),
|
|
9983
|
+
fees_transfer_type: 'LocalReserve',
|
|
9984
|
+
custom_xcm_on_dest: createCustomXcmToBifrost(input, versionOrDefault),
|
|
9985
|
+
weight_limit: 'Unlimited'
|
|
9986
|
+
}
|
|
9987
|
+
};
|
|
9988
|
+
return api.callTxMethod(call);
|
|
9989
|
+
};
|
|
9990
|
+
return _this;
|
|
9947
9991
|
}
|
|
9948
9992
|
_inherits(AssetHubPolkadot, _ParachainNode);
|
|
9949
9993
|
return _createClass(AssetHubPolkadot, [{
|
|
@@ -10051,8 +10095,8 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10051
10095
|
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
|
|
10052
10096
|
});
|
|
10053
10097
|
}
|
|
10054
|
-
var dotAsset = getOtherAssets(this.node).find(function (
|
|
10055
|
-
var symbol =
|
|
10098
|
+
var dotAsset = getOtherAssets(this.node).find(function (_ref3) {
|
|
10099
|
+
var symbol = _ref3.symbol;
|
|
10056
10100
|
return symbol === 'DOT';
|
|
10057
10101
|
});
|
|
10058
10102
|
if (destination === 'Hydration' && (currencySymbol === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.symbol) || currencyId === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.assetId))) {
|
|
@@ -10079,6 +10123,13 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10079
10123
|
if (destination === 'Mythos') {
|
|
10080
10124
|
return Promise.resolve(this.handleMythosTransfer(input));
|
|
10081
10125
|
}
|
|
10126
|
+
var wethAsset = getOtherAssets('Ethereum').find(function (_ref4) {
|
|
10127
|
+
var symbol = _ref4.symbol;
|
|
10128
|
+
return symbol === 'WETH';
|
|
10129
|
+
});
|
|
10130
|
+
if (destination === 'BifrostPolkadot' && (currencySymbol === (wethAsset === null || wethAsset === void 0 ? void 0 : wethAsset.symbol) || currencyId === (wethAsset === null || wethAsset === void 0 ? void 0 : wethAsset.assetId))) {
|
|
10131
|
+
return Promise.resolve(this.handleBifrostEthTransfer(input));
|
|
10132
|
+
}
|
|
10082
10133
|
if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined && destination !== 'Hydration') {
|
|
10083
10134
|
throw new ScenarioNotSupportedError(this.node, scenario, 'Para to Para scenarios for DOT transfer from AssetHub are not supported, you have to transfer DOT to Relay chain and transfer to destination chain from Relay chain.');
|
|
10084
10135
|
}
|
|
@@ -11620,82 +11671,138 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
11620
11671
|
};
|
|
11621
11672
|
|
|
11622
11673
|
// Contains function for getting Asset ID or Symbol used in XCM call creation
|
|
11623
|
-
var
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
return
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11674
|
+
var findBestMatches = function findBestMatches(assets, symbol) {
|
|
11675
|
+
// First, exact match
|
|
11676
|
+
var matches = assets.filter(function (asset) {
|
|
11677
|
+
return asset.symbol === symbol;
|
|
11678
|
+
});
|
|
11679
|
+
if (matches.length > 0) {
|
|
11680
|
+
return matches;
|
|
11630
11681
|
}
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11682
|
+
// Uppercase match
|
|
11683
|
+
var upperSymbol = symbol.toUpperCase();
|
|
11684
|
+
matches = assets.filter(function (asset) {
|
|
11685
|
+
return asset.symbol === upperSymbol;
|
|
11634
11686
|
});
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11687
|
+
if (matches.length > 0) {
|
|
11688
|
+
return matches;
|
|
11689
|
+
}
|
|
11690
|
+
// Lowercase match
|
|
11691
|
+
var lowerSymbol = symbol.toLowerCase();
|
|
11692
|
+
matches = assets.filter(function (asset) {
|
|
11693
|
+
return asset.symbol === lowerSymbol;
|
|
11638
11694
|
});
|
|
11695
|
+
if (matches.length > 0) {
|
|
11696
|
+
return matches;
|
|
11697
|
+
}
|
|
11698
|
+
// Case-insensitive match
|
|
11699
|
+
matches = assets.filter(function (asset) {
|
|
11700
|
+
var _a;
|
|
11701
|
+
return ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === lowerSymbol;
|
|
11702
|
+
});
|
|
11703
|
+
return matches;
|
|
11704
|
+
};
|
|
11705
|
+
var findAssetBySymbol = function findAssetBySymbol(node, destination, otherAssets, nativeAssets, symbol, isRelayDestination) {
|
|
11706
|
+
var lowerSymbol = symbol.toLowerCase();
|
|
11639
11707
|
var isPolkadotXcm = !isRelayChain(node) && node !== 'Ethereum' && getDefaultPallet(node) === 'PolkadotXcm';
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11708
|
+
var otherAssetsMatches = [];
|
|
11709
|
+
var nativeAssetsMatches = [];
|
|
11710
|
+
if (destination === 'Ethereum') {
|
|
11711
|
+
var ethereumAssets = getOtherAssets('Ethereum');
|
|
11712
|
+
var assetsMatches = findBestMatches(ethereumAssets, symbol);
|
|
11713
|
+
if (assetsMatches.length === 0) {
|
|
11714
|
+
if (lowerSymbol.endsWith('.e')) {
|
|
11715
|
+
// Symbol ends with '.e', strip it and search again
|
|
11716
|
+
var strippedSymbol = symbol.slice(0, -2).toLowerCase();
|
|
11717
|
+
assetsMatches = findBestMatches(ethereumAssets, strippedSymbol);
|
|
11718
|
+
} else {
|
|
11719
|
+
// Symbol does not end with '.e', add '.e' suffix and search
|
|
11720
|
+
var suffixedSymbol = "".concat(symbol, ".e").toLowerCase();
|
|
11721
|
+
assetsMatches = findBestMatches(ethereumAssets, suffixedSymbol);
|
|
11655
11722
|
}
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11723
|
+
}
|
|
11724
|
+
return assetsMatches[0];
|
|
11725
|
+
}
|
|
11726
|
+
var supportsESuffix = node === 'AssetHubPolkadot' || node === 'AssetHubKusama' || destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama' || node === 'Ethereum';
|
|
11727
|
+
if (lowerSymbol.endsWith('.e') && supportsESuffix) {
|
|
11728
|
+
// Symbol ends with '.e', indicating a Snowbridge asset
|
|
11729
|
+
var _strippedSymbol = symbol.slice(0, -2);
|
|
11730
|
+
// Search in Ethereum assets without the '.e' suffix
|
|
11731
|
+
var _ethereumAssets = getOtherAssets('Ethereum');
|
|
11732
|
+
var ethereumMatches = findBestMatches(_ethereumAssets, _strippedSymbol);
|
|
11733
|
+
if (ethereumMatches.length > 0) {
|
|
11734
|
+
return ethereumMatches[0];
|
|
11735
|
+
}
|
|
11736
|
+
// If not found, search normal assets with '.e' suffix
|
|
11737
|
+
otherAssetsMatches = findBestMatches(otherAssets, symbol);
|
|
11738
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, symbol);
|
|
11739
|
+
if (nativeAssetsMatches.length > 0 || otherAssetsMatches.length > 0) {
|
|
11740
|
+
if (isPolkadotXcm) {
|
|
11741
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0];
|
|
11659
11742
|
}
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
nativeAssetsMatches = nativeAssets.filter(function (_ref7) {
|
|
11669
|
-
var assetSymbol = _ref7.symbol;
|
|
11670
|
-
return (assetSymbol === null || assetSymbol === void 0 ? void 0 : assetSymbol.toLowerCase()) === prefixedLowerSymbol;
|
|
11671
|
-
});
|
|
11672
|
-
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11673
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11743
|
+
return otherAssetsMatches[0] || nativeAssetsMatches[0];
|
|
11744
|
+
}
|
|
11745
|
+
// If still not found, search normal assets without suffix
|
|
11746
|
+
otherAssetsMatches = findBestMatches(otherAssets, _strippedSymbol);
|
|
11747
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, _strippedSymbol);
|
|
11748
|
+
if (nativeAssetsMatches.length > 0 || otherAssetsMatches.length > 0) {
|
|
11749
|
+
if (isPolkadotXcm) {
|
|
11750
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0];
|
|
11674
11751
|
}
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11752
|
+
return otherAssetsMatches[0] || nativeAssetsMatches[0];
|
|
11753
|
+
}
|
|
11754
|
+
// No matches found
|
|
11755
|
+
return undefined;
|
|
11756
|
+
} else {
|
|
11757
|
+
// Symbol does not end with '.e', proceed with existing logic
|
|
11758
|
+
otherAssetsMatches = findBestMatches(otherAssets, symbol);
|
|
11759
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, symbol);
|
|
11760
|
+
if (otherAssetsMatches.length === 0 && nativeAssetsMatches.length === 0) {
|
|
11761
|
+
if (lowerSymbol.startsWith('xc')) {
|
|
11762
|
+
// Symbol starts with 'xc', try stripping 'xc' prefix
|
|
11763
|
+
var _strippedSymbol2 = symbol.substring(2);
|
|
11764
|
+
otherAssetsMatches = findBestMatches(otherAssets, _strippedSymbol2);
|
|
11765
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, _strippedSymbol2);
|
|
11766
|
+
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11767
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0] || undefined;
|
|
11768
|
+
}
|
|
11769
|
+
var totalMatches = otherAssetsMatches.length + nativeAssetsMatches.length;
|
|
11770
|
+
if (totalMatches > 1) {
|
|
11771
|
+
throw new InvalidCurrencyError("Multiple assets found for symbol ".concat(symbol, " after stripping 'xc' prefix. Please specify by ID."));
|
|
11772
|
+
}
|
|
11773
|
+
} else {
|
|
11774
|
+
// Try adding 'xc' prefix
|
|
11775
|
+
var prefixedSymbol = "xc".concat(symbol);
|
|
11776
|
+
otherAssetsMatches = findBestMatches(otherAssets, prefixedSymbol);
|
|
11777
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, prefixedSymbol);
|
|
11778
|
+
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11779
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0] || undefined;
|
|
11780
|
+
}
|
|
11781
|
+
var _totalMatches = otherAssetsMatches.length + nativeAssetsMatches.length;
|
|
11782
|
+
if (_totalMatches > 1) {
|
|
11783
|
+
throw new InvalidCurrencyError("Multiple assets found for symbol ".concat(symbol, " after adding 'xc' prefix. Please specify by ID."));
|
|
11784
|
+
}
|
|
11678
11785
|
}
|
|
11679
11786
|
}
|
|
11787
|
+
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11788
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0] || undefined;
|
|
11789
|
+
}
|
|
11790
|
+
if (otherAssetsMatches.length > 1 && !isRelayDestination) {
|
|
11791
|
+
throw new DuplicateAssetError(symbol);
|
|
11792
|
+
}
|
|
11793
|
+
return otherAssetsMatches[0] || nativeAssetsMatches[0] || undefined;
|
|
11680
11794
|
}
|
|
11681
|
-
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11682
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11683
|
-
}
|
|
11684
|
-
if (otherAssetsMatches.length > 1 && !isRelayDestination) {
|
|
11685
|
-
throw new DuplicateAssetError(symbol);
|
|
11686
|
-
}
|
|
11687
|
-
return otherAssetsMatches[0] || nativeAssetsMatches[0] || null;
|
|
11688
11795
|
};
|
|
11689
11796
|
var findAssetById = function findAssetById(assets, assetId) {
|
|
11690
|
-
var otherAssetsMatches = assets.filter(function (
|
|
11691
|
-
var currentAssetId =
|
|
11797
|
+
var otherAssetsMatches = assets.filter(function (_ref) {
|
|
11798
|
+
var currentAssetId = _ref.assetId;
|
|
11692
11799
|
return currentAssetId === assetId.toString();
|
|
11693
11800
|
});
|
|
11694
11801
|
if (otherAssetsMatches.length > 1) {
|
|
11695
11802
|
throw new DuplicateAssetIdError(assetId.toString());
|
|
11696
11803
|
}
|
|
11697
|
-
return assets.find(function (
|
|
11698
|
-
var currentAssetId =
|
|
11804
|
+
return assets.find(function (_ref2) {
|
|
11805
|
+
var currentAssetId = _ref2.assetId;
|
|
11699
11806
|
return currentAssetId === assetId.toString();
|
|
11700
11807
|
});
|
|
11701
11808
|
};
|
|
@@ -11713,7 +11820,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency) {
|
|
|
11713
11820
|
var combinedAssets = destination === 'Ethereum' ? _toConsumableArray(getOtherAssets('Ethereum')) : [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets));
|
|
11714
11821
|
var asset;
|
|
11715
11822
|
if ('symbol' in currency) {
|
|
11716
|
-
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets,
|
|
11823
|
+
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets, currency.symbol, isRelayDestination);
|
|
11717
11824
|
} else {
|
|
11718
11825
|
asset = findAssetById(combinedAssets, currency.id);
|
|
11719
11826
|
}
|
|
@@ -11848,6 +11955,11 @@ var hasSupportForAsset = function hasSupportForAsset(node, symbol) {
|
|
|
11848
11955
|
} else {
|
|
11849
11956
|
symbolsToCheck.add("xc".concat(lowerSymbol));
|
|
11850
11957
|
}
|
|
11958
|
+
if (lowerSymbol.endsWith('.e')) {
|
|
11959
|
+
symbolsToCheck.add(lowerSymbol.substring(0, lowerSymbol.length - 2));
|
|
11960
|
+
} else {
|
|
11961
|
+
symbolsToCheck.add("".concat(lowerSymbol, ".e"));
|
|
11962
|
+
}
|
|
11851
11963
|
var nodeSymbols = getAllAssetsSymbols(node).map(function (s) {
|
|
11852
11964
|
return s.toLowerCase();
|
|
11853
11965
|
});
|
|
@@ -12191,8 +12303,8 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
|
|
|
12191
12303
|
_context.next = 13;
|
|
12192
12304
|
break;
|
|
12193
12305
|
}
|
|
12194
|
-
multiLocation = getAssetHubMultiLocation(asset.symbol);
|
|
12195
|
-
if (!multiLocation) {
|
|
12306
|
+
multiLocation = getAssetHubMultiLocation(asset.symbol); // Ethereum address ID indicates that it is an Ethereum asset
|
|
12307
|
+
if (!(multiLocation && ethers.ethers.isAddress(asset.assetId))) {
|
|
12196
12308
|
_context.next = 10;
|
|
12197
12309
|
break;
|
|
12198
12310
|
}
|
|
@@ -13497,6 +13609,7 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
13497
13609
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
13498
13610
|
var api = _ref.api,
|
|
13499
13611
|
account = _ref.account,
|
|
13612
|
+
accountDestination = _ref.accountDestination,
|
|
13500
13613
|
amount = _ref.amount,
|
|
13501
13614
|
currency = _ref.currency,
|
|
13502
13615
|
origin = _ref.origin,
|
|
@@ -13518,7 +13631,7 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
13518
13631
|
nativeBalance = _context2.sent;
|
|
13519
13632
|
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
13520
13633
|
_context2.next = 6;
|
|
13521
|
-
return createTx$1(api,
|
|
13634
|
+
return createTx$1(api, accountDestination, amount, currency, origin, destination);
|
|
13522
13635
|
case 6:
|
|
13523
13636
|
tx = _context2.sent;
|
|
13524
13637
|
_context2.next = 9;
|
|
@@ -13550,7 +13663,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13550
13663
|
amount = _ref.amount,
|
|
13551
13664
|
originApi = _ref.api;
|
|
13552
13665
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13553
|
-
var _b, _c, _d, originBalance,
|
|
13666
|
+
var _b, _c, _d, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
13554
13667
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13555
13668
|
while (1) switch (_context.prev = _context.next) {
|
|
13556
13669
|
case 0:
|
|
@@ -13572,64 +13685,54 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13572
13685
|
currency: currency,
|
|
13573
13686
|
amount: amount,
|
|
13574
13687
|
account: accountOrigin,
|
|
13688
|
+
accountDestination: accountDestination,
|
|
13575
13689
|
api: originApi
|
|
13576
13690
|
});
|
|
13577
13691
|
case 7:
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
|
|
13692
|
+
xcmFeeDetails = _context.sent;
|
|
13693
|
+
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
13581
13694
|
asset = (_b = getAssetBySymbolOrId(origin, currency)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency) : null;
|
|
13582
13695
|
if (asset) {
|
|
13583
|
-
_context.next =
|
|
13696
|
+
_context.next = 12;
|
|
13584
13697
|
break;
|
|
13585
13698
|
}
|
|
13586
13699
|
throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
|
|
13587
|
-
case
|
|
13700
|
+
case 12:
|
|
13588
13701
|
_context.t0 = {
|
|
13589
13702
|
origin: origin,
|
|
13590
13703
|
destination: destination,
|
|
13591
13704
|
ecosystem: determineRelayChainSymbol(origin)
|
|
13592
13705
|
};
|
|
13593
|
-
_context.next =
|
|
13706
|
+
_context.next = 15;
|
|
13594
13707
|
return getAssetBalance$1({
|
|
13595
13708
|
api: originApi,
|
|
13596
13709
|
address: accountOrigin,
|
|
13597
13710
|
node: origin,
|
|
13598
13711
|
currency: currency
|
|
13599
13712
|
});
|
|
13600
|
-
case
|
|
13713
|
+
case 15:
|
|
13601
13714
|
_context.t1 = _context.sent;
|
|
13602
13715
|
_context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
|
|
13603
13716
|
_context.t3 = {
|
|
13604
13717
|
balance: _context.t1,
|
|
13605
13718
|
currency: _context.t2
|
|
13606
13719
|
};
|
|
13607
|
-
_context.next =
|
|
13720
|
+
_context.next = 20;
|
|
13608
13721
|
return getBalanceNative$1({
|
|
13609
13722
|
address: accountOrigin,
|
|
13610
13723
|
node: origin,
|
|
13611
13724
|
api: originApi
|
|
13612
13725
|
});
|
|
13613
|
-
case
|
|
13726
|
+
case 20:
|
|
13614
13727
|
_context.t4 = _context.sent;
|
|
13615
13728
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
13616
|
-
_context.
|
|
13617
|
-
return getOriginFeeDetails$1({
|
|
13618
|
-
origin: origin,
|
|
13619
|
-
destination: destination,
|
|
13620
|
-
currency: currency,
|
|
13621
|
-
amount: amount,
|
|
13622
|
-
account: accountOrigin,
|
|
13623
|
-
api: originApi
|
|
13624
|
-
});
|
|
13625
|
-
case 25:
|
|
13626
|
-
_context.t6 = _context.sent;
|
|
13729
|
+
_context.t6 = xcmFeeDetails;
|
|
13627
13730
|
_context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
|
|
13628
13731
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
13629
13732
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
13630
|
-
_context.next =
|
|
13733
|
+
_context.next = 28;
|
|
13631
13734
|
return getMaxNativeTransferableAmount(originApi, accountOrigin, origin);
|
|
13632
|
-
case
|
|
13735
|
+
case 28:
|
|
13633
13736
|
_context.t10 = _context.sent;
|
|
13634
13737
|
_context.t11 = {
|
|
13635
13738
|
balance: _context.t4,
|
|
@@ -13640,13 +13743,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13640
13743
|
minNativeTransferableAmount: _context.t9,
|
|
13641
13744
|
maxNativeTransferableAmount: _context.t10
|
|
13642
13745
|
};
|
|
13643
|
-
_context.next =
|
|
13746
|
+
_context.next = 32;
|
|
13644
13747
|
return getBalanceNative$1({
|
|
13645
13748
|
address: accountDestination,
|
|
13646
13749
|
node: destination,
|
|
13647
13750
|
api: originApi
|
|
13648
13751
|
});
|
|
13649
|
-
case
|
|
13752
|
+
case 32:
|
|
13650
13753
|
_context.t12 = _context.sent;
|
|
13651
13754
|
_context.t13 = getNativeAssetSymbol(destination);
|
|
13652
13755
|
_context.t14 = getExistentialDeposit(destination);
|
|
@@ -13661,7 +13764,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13661
13764
|
originFeeBalance: _context.t11,
|
|
13662
13765
|
destinationFeeBalance: _context.t15
|
|
13663
13766
|
});
|
|
13664
|
-
case
|
|
13767
|
+
case 37:
|
|
13665
13768
|
case "end":
|
|
13666
13769
|
return _context.stop();
|
|
13667
13770
|
}
|
|
@@ -13716,6 +13819,16 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
13716
13819
|
return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
|
|
13717
13820
|
});
|
|
13718
13821
|
});
|
|
13822
|
+
if (origin === 'AssetHubPolkadot' && destination === 'BifrostPolkadot') {
|
|
13823
|
+
var wethAsset = getOtherAssets('Ethereum').find(function (_ref) {
|
|
13824
|
+
var symbol = _ref.symbol;
|
|
13825
|
+
return symbol === 'WETH';
|
|
13826
|
+
});
|
|
13827
|
+
if (wethAsset) supportedAssets.push({
|
|
13828
|
+
assetId: wethAsset.assetId,
|
|
13829
|
+
symbol: "".concat(wethAsset.symbol, ".e")
|
|
13830
|
+
});
|
|
13831
|
+
}
|
|
13719
13832
|
return supportedAssets;
|
|
13720
13833
|
};
|
|
13721
13834
|
|
package/dist/papi/index.d.ts
CHANGED
|
@@ -216,6 +216,7 @@ declare class AssetHubPolkadot<TApi, TRes> extends ParachainNode<TApi, TRes> imp
|
|
|
216
216
|
handleBridgeTransfer<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>, targetChain: 'Polkadot' | 'Kusama'): TTransferReturn<TRes>;
|
|
217
217
|
handleEthBridgeTransfer<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>): TTransferReturn<TRes>;
|
|
218
218
|
handleMythosTransfer<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>): TTransferReturn<TRes>;
|
|
219
|
+
handleBifrostEthTransfer: <TApi_1, TRes_1>(input: PolkadotXCMTransferInput<TApi_1, TRes_1>) => TTransferReturn<TRes_1>;
|
|
219
220
|
patchInput<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>): PolkadotXCMTransferInput<TApi, TRes>;
|
|
220
221
|
transferPolkadotXCM<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>): Promise<TTransferReturn<TRes>>;
|
|
221
222
|
transferRelayToPara(options: TRelayToParaOptions<TApi, TRes>): TSerializedApiCallV2;
|
|
@@ -883,11 +884,13 @@ type TAssetDetails = {
|
|
|
883
884
|
assetId: string;
|
|
884
885
|
symbol?: string;
|
|
885
886
|
decimals?: number;
|
|
887
|
+
manuallyAdded?: boolean;
|
|
886
888
|
};
|
|
887
889
|
type TNativeAssetDetails = {
|
|
888
890
|
assetId?: string;
|
|
889
891
|
symbol: string;
|
|
890
892
|
decimals: number;
|
|
893
|
+
manuallyAdded?: boolean;
|
|
891
894
|
};
|
|
892
895
|
type TNodeAssets = {
|
|
893
896
|
paraId?: number;
|
|
@@ -1099,9 +1102,13 @@ type TGetOriginFeeDetailsOptionsBase = {
|
|
|
1099
1102
|
*/
|
|
1100
1103
|
amount: string;
|
|
1101
1104
|
/**
|
|
1102
|
-
* The account
|
|
1105
|
+
* The origin account.
|
|
1103
1106
|
*/
|
|
1104
1107
|
account: string;
|
|
1108
|
+
/**
|
|
1109
|
+
* The destination account.
|
|
1110
|
+
*/
|
|
1111
|
+
accountDestination: string;
|
|
1105
1112
|
/**
|
|
1106
1113
|
* The fee margin percentage.
|
|
1107
1114
|
*/
|