@paraspell/sdk 7.1.0 → 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 +386 -171
- package/dist/index.d.ts +12 -2
- package/dist/index.mjs +386 -171
- package/dist/papi/index.cjs +386 -171
- package/dist/papi/index.d.ts +12 -2
- package/dist/papi/index.mjs +386 -171
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -492,8 +492,8 @@ function _superPropBase(t, o) {
|
|
|
492
492
|
return t;
|
|
493
493
|
}
|
|
494
494
|
function _superPropGet(t, o, e, r) {
|
|
495
|
-
var p = _get(_getPrototypeOf(t.prototype ), o, e);
|
|
496
|
-
return "function" == typeof p ? function (t) {
|
|
495
|
+
var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e);
|
|
496
|
+
return 2 & r && "function" == typeof p ? function (t) {
|
|
497
497
|
return p.apply(e, t);
|
|
498
498
|
} : p;
|
|
499
499
|
}
|
|
@@ -2503,14 +2503,16 @@ var AssetHubPolkadot$3 = {
|
|
|
2503
2503
|
},
|
|
2504
2504
|
{
|
|
2505
2505
|
symbol: "KSM",
|
|
2506
|
-
decimals: 12
|
|
2506
|
+
decimals: 12,
|
|
2507
|
+
manuallyAdded: true
|
|
2507
2508
|
}
|
|
2508
2509
|
],
|
|
2509
2510
|
otherAssets: [
|
|
2510
2511
|
{
|
|
2511
2512
|
assetId: "",
|
|
2512
2513
|
symbol: "MYTH",
|
|
2513
|
-
decimals: 18
|
|
2514
|
+
decimals: 18,
|
|
2515
|
+
manuallyAdded: true
|
|
2514
2516
|
},
|
|
2515
2517
|
{
|
|
2516
2518
|
assetId: "22222005",
|
|
@@ -6343,7 +6345,8 @@ var AssetHubKusama$3 = {
|
|
|
6343
6345
|
nativeAssets: [
|
|
6344
6346
|
{
|
|
6345
6347
|
symbol: "KSM",
|
|
6346
|
-
decimals: 12
|
|
6348
|
+
decimals: 12,
|
|
6349
|
+
manuallyAdded: true
|
|
6347
6350
|
},
|
|
6348
6351
|
{
|
|
6349
6352
|
symbol: "DOT",
|
|
@@ -9251,6 +9254,19 @@ var ComposableFinance$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9251
9254
|
}]);
|
|
9252
9255
|
}(ParachainNode);
|
|
9253
9256
|
|
|
9257
|
+
var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
|
|
9258
|
+
return {
|
|
9259
|
+
parents: Parents.TWO,
|
|
9260
|
+
interior: {
|
|
9261
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9262
|
+
AccountKey20: {
|
|
9263
|
+
key: currencyId
|
|
9264
|
+
}
|
|
9265
|
+
}]
|
|
9266
|
+
}
|
|
9267
|
+
};
|
|
9268
|
+
};
|
|
9269
|
+
|
|
9254
9270
|
var calculateFee = function calculateFee(api) {
|
|
9255
9271
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9256
9272
|
var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
@@ -9278,31 +9294,34 @@ var calculateFee = function calculateFee(api) {
|
|
|
9278
9294
|
}, _callee);
|
|
9279
9295
|
}));
|
|
9280
9296
|
};
|
|
9281
|
-
var
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9297
|
+
var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
|
|
9298
|
+
var api = _ref.api,
|
|
9299
|
+
scenario = _ref.scenario,
|
|
9300
|
+
address = _ref.address;
|
|
9301
|
+
return _defineProperty({}, version, [{
|
|
9302
|
+
DepositAsset: {
|
|
9303
|
+
assets: {
|
|
9304
|
+
Wild: {
|
|
9305
|
+
AllCounted: 1
|
|
9288
9306
|
}
|
|
9289
|
-
}
|
|
9307
|
+
},
|
|
9308
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
|
|
9290
9309
|
}
|
|
9291
|
-
};
|
|
9310
|
+
}]);
|
|
9292
9311
|
};
|
|
9293
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(
|
|
9294
|
-
var api =
|
|
9295
|
-
address =
|
|
9296
|
-
currencyId =
|
|
9297
|
-
scenario =
|
|
9298
|
-
ahAddress =
|
|
9299
|
-
return _defineProperty({},
|
|
9312
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref3, version) {
|
|
9313
|
+
var api = _ref3.api,
|
|
9314
|
+
address = _ref3.address,
|
|
9315
|
+
currencyId = _ref3.currencyId,
|
|
9316
|
+
scenario = _ref3.scenario,
|
|
9317
|
+
ahAddress = _ref3.ahAddress;
|
|
9318
|
+
return _defineProperty({}, version, [{
|
|
9300
9319
|
SetAppendix: [{
|
|
9301
9320
|
DepositAsset: {
|
|
9302
9321
|
assets: {
|
|
9303
9322
|
Wild: 'All'
|
|
9304
9323
|
},
|
|
9305
|
-
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '',
|
|
9324
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', version, undefined))[0]
|
|
9306
9325
|
}
|
|
9307
9326
|
}]
|
|
9308
9327
|
}, {
|
|
@@ -9369,11 +9388,10 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9369
9388
|
_classCallCheck(this, Hydration);
|
|
9370
9389
|
return _callSuper(this, Hydration, ['Hydration', 'hydradx', 'polkadot', Version.V3]);
|
|
9371
9390
|
}
|
|
9372
|
-
// Handles WETH Ethereum transfers
|
|
9373
9391
|
_inherits(Hydration, _ParachainNode);
|
|
9374
9392
|
return _createClass(Hydration, [{
|
|
9375
|
-
key: "
|
|
9376
|
-
value: function
|
|
9393
|
+
key: "transferToEthereum",
|
|
9394
|
+
value: function transferToEthereum(input) {
|
|
9377
9395
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
9378
9396
|
var api, address, currencySymbol, scenario, version, destination, amount, currencyId, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
|
|
9379
9397
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -9428,6 +9446,59 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9428
9446
|
}, _callee2, this);
|
|
9429
9447
|
}));
|
|
9430
9448
|
}
|
|
9449
|
+
}, {
|
|
9450
|
+
key: "transferToAssetHub",
|
|
9451
|
+
value: function transferToAssetHub(input) {
|
|
9452
|
+
var api = input.api,
|
|
9453
|
+
scenario = input.scenario,
|
|
9454
|
+
version = input.version,
|
|
9455
|
+
destination = input.destination,
|
|
9456
|
+
amount = input.amount;
|
|
9457
|
+
var versionOrDefault = version !== null && version !== void 0 ? version : Version.V3;
|
|
9458
|
+
var call = {
|
|
9459
|
+
module: 'PolkadotXcm',
|
|
9460
|
+
section: 'transfer_assets_using_type_and_then',
|
|
9461
|
+
parameters: {
|
|
9462
|
+
dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
|
|
9463
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(amount, 'ParaToRelay', versionOrDefault))[0][0]]),
|
|
9464
|
+
assets_transfer_type: 'DestinationReserve',
|
|
9465
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
9466
|
+
Concrete: {
|
|
9467
|
+
parents: Parents.ONE,
|
|
9468
|
+
interior: 'Here'
|
|
9469
|
+
}
|
|
9470
|
+
}),
|
|
9471
|
+
fees_transfer_type: 'DestinationReserve',
|
|
9472
|
+
custom_xcm_on_dest: createCustomXcmAh(input, versionOrDefault),
|
|
9473
|
+
weight_limit: 'Unlimited'
|
|
9474
|
+
}
|
|
9475
|
+
};
|
|
9476
|
+
return api.callTxMethod(call);
|
|
9477
|
+
}
|
|
9478
|
+
// Handles WETH Ethereum transfers
|
|
9479
|
+
}, {
|
|
9480
|
+
key: "transferPolkadotXCM",
|
|
9481
|
+
value: function transferPolkadotXCM(input) {
|
|
9482
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
9483
|
+
var destination;
|
|
9484
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
9485
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
9486
|
+
case 0:
|
|
9487
|
+
destination = input.destination;
|
|
9488
|
+
if (!(destination === 'Ethereum')) {
|
|
9489
|
+
_context3.next = 3;
|
|
9490
|
+
break;
|
|
9491
|
+
}
|
|
9492
|
+
return _context3.abrupt("return", this.transferToEthereum(input));
|
|
9493
|
+
case 3:
|
|
9494
|
+
return _context3.abrupt("return", this.transferToAssetHub(input));
|
|
9495
|
+
case 4:
|
|
9496
|
+
case "end":
|
|
9497
|
+
return _context3.stop();
|
|
9498
|
+
}
|
|
9499
|
+
}, _callee3, this);
|
|
9500
|
+
}));
|
|
9501
|
+
}
|
|
9431
9502
|
}, {
|
|
9432
9503
|
key: "transferXTokens",
|
|
9433
9504
|
value: function transferXTokens(input) {
|
|
@@ -9436,9 +9507,15 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9436
9507
|
}
|
|
9437
9508
|
}, {
|
|
9438
9509
|
key: "canUseXTokens",
|
|
9439
|
-
value: function canUseXTokens(
|
|
9440
|
-
var destination =
|
|
9441
|
-
|
|
9510
|
+
value: function canUseXTokens(_ref5) {
|
|
9511
|
+
var destination = _ref5.destination,
|
|
9512
|
+
currencySymbol = _ref5.currencySymbol,
|
|
9513
|
+
currencyId = _ref5.currencyId;
|
|
9514
|
+
var dotAsset = getOtherAssets(this.node).find(function (_ref6) {
|
|
9515
|
+
var symbol = _ref6.symbol;
|
|
9516
|
+
return symbol === 'DOT';
|
|
9517
|
+
});
|
|
9518
|
+
return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && (currencySymbol === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.symbol) || currencyId === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.assetId)));
|
|
9442
9519
|
}
|
|
9443
9520
|
}]);
|
|
9444
9521
|
}(ParachainNode);
|
|
@@ -9865,10 +9942,50 @@ var Karura$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9865
9942
|
}]);
|
|
9866
9943
|
}(ParachainNode);
|
|
9867
9944
|
|
|
9945
|
+
var createCustomXcmToBifrost = function createCustomXcmToBifrost(_ref, version) {
|
|
9946
|
+
var api = _ref.api,
|
|
9947
|
+
address = _ref.address,
|
|
9948
|
+
scenario = _ref.scenario;
|
|
9949
|
+
return _defineProperty({}, version, [{
|
|
9950
|
+
DepositAsset: {
|
|
9951
|
+
assets: {
|
|
9952
|
+
Wild: 'All'
|
|
9953
|
+
},
|
|
9954
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
|
|
9955
|
+
}
|
|
9956
|
+
}]);
|
|
9957
|
+
};
|
|
9868
9958
|
var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
9869
9959
|
function AssetHubPolkadot() {
|
|
9960
|
+
var _this;
|
|
9870
9961
|
_classCallCheck(this, AssetHubPolkadot);
|
|
9871
|
-
|
|
9962
|
+
_this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', Version.V3]);
|
|
9963
|
+
_this.handleBifrostEthTransfer = function (input) {
|
|
9964
|
+
var api = input.api,
|
|
9965
|
+
amount = input.amount,
|
|
9966
|
+
scenario = input.scenario,
|
|
9967
|
+
version = input.version,
|
|
9968
|
+
destination = input.destination,
|
|
9969
|
+
currencyId = input.currencyId;
|
|
9970
|
+
var versionOrDefault = version !== null && version !== void 0 ? version : _this.version;
|
|
9971
|
+
var call = {
|
|
9972
|
+
module: 'PolkadotXcm',
|
|
9973
|
+
section: 'transfer_assets_using_type_and_then',
|
|
9974
|
+
parameters: {
|
|
9975
|
+
dest: _this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('BifrostPolkadot')),
|
|
9976
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(createCurrencySpec(amount, versionOrDefault, Parents.TWO, createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')))[0][0]]),
|
|
9977
|
+
assets_transfer_type: 'LocalReserve',
|
|
9978
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
9979
|
+
Concrete: createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')
|
|
9980
|
+
}),
|
|
9981
|
+
fees_transfer_type: 'LocalReserve',
|
|
9982
|
+
custom_xcm_on_dest: createCustomXcmToBifrost(input, versionOrDefault),
|
|
9983
|
+
weight_limit: 'Unlimited'
|
|
9984
|
+
}
|
|
9985
|
+
};
|
|
9986
|
+
return api.callTxMethod(call);
|
|
9987
|
+
};
|
|
9988
|
+
return _this;
|
|
9872
9989
|
}
|
|
9873
9990
|
_inherits(AssetHubPolkadot, _ParachainNode);
|
|
9874
9991
|
return _createClass(AssetHubPolkadot, [{
|
|
@@ -9954,41 +10071,71 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9954
10071
|
});
|
|
9955
10072
|
return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'limited_teleport_assets', 'Unlimited');
|
|
9956
10073
|
}
|
|
10074
|
+
}, {
|
|
10075
|
+
key: "patchInput",
|
|
10076
|
+
value: function patchInput(input) {
|
|
10077
|
+
var _a;
|
|
10078
|
+
var currencySymbol = input.currencySymbol,
|
|
10079
|
+
currencyId = input.currencyId,
|
|
10080
|
+
destination = input.destination,
|
|
10081
|
+
paraIdTo = input.paraIdTo,
|
|
10082
|
+
amount = input.amount,
|
|
10083
|
+
overridedCurrency = input.overridedCurrency,
|
|
10084
|
+
scenario = input.scenario,
|
|
10085
|
+
api = input.api,
|
|
10086
|
+
version = input.version,
|
|
10087
|
+
address = input.address;
|
|
10088
|
+
if (((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDT' || (currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot') {
|
|
10089
|
+
var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : Version.V2;
|
|
10090
|
+
return Object.assign(Object.assign({}, input), {
|
|
10091
|
+
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
|
|
10092
|
+
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
|
|
10093
|
+
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
|
|
10094
|
+
});
|
|
10095
|
+
}
|
|
10096
|
+
var dotAsset = getOtherAssets(this.node).find(function (_ref3) {
|
|
10097
|
+
var symbol = _ref3.symbol;
|
|
10098
|
+
return symbol === 'DOT';
|
|
10099
|
+
});
|
|
10100
|
+
if (destination === 'Hydration' && (currencySymbol === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.symbol) || currencyId === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.assetId))) {
|
|
10101
|
+
var _versionOrDefault = version !== null && version !== void 0 ? version : this.version;
|
|
10102
|
+
return Object.assign(Object.assign({}, input), {
|
|
10103
|
+
currencySelection: _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, 'ParaToRelay', _versionOrDefault, currencyId, overridedCurrency])
|
|
10104
|
+
});
|
|
10105
|
+
}
|
|
10106
|
+
return input;
|
|
10107
|
+
}
|
|
9957
10108
|
}, {
|
|
9958
10109
|
key: "transferPolkadotXCM",
|
|
9959
10110
|
value: function transferPolkadotXCM(input) {
|
|
9960
|
-
var _a;
|
|
9961
10111
|
var scenario = input.scenario,
|
|
9962
10112
|
currencySymbol = input.currencySymbol,
|
|
9963
|
-
currencyId = input.currencyId
|
|
9964
|
-
|
|
10113
|
+
currencyId = input.currencyId,
|
|
10114
|
+
destination = input.destination;
|
|
10115
|
+
if (destination === 'AssetHubKusama') {
|
|
9965
10116
|
return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
|
|
9966
10117
|
}
|
|
9967
|
-
if (
|
|
10118
|
+
if (destination === 'Ethereum') {
|
|
9968
10119
|
return Promise.resolve(this.handleEthBridgeTransfer(input));
|
|
9969
10120
|
}
|
|
9970
|
-
if (
|
|
10121
|
+
if (destination === 'Mythos') {
|
|
9971
10122
|
return Promise.resolve(this.handleMythosTransfer(input));
|
|
9972
10123
|
}
|
|
9973
|
-
|
|
10124
|
+
var wethAsset = getOtherAssets('Ethereum').find(function (_ref4) {
|
|
10125
|
+
var symbol = _ref4.symbol;
|
|
10126
|
+
return symbol === 'WETH';
|
|
10127
|
+
});
|
|
10128
|
+
if (destination === 'BifrostPolkadot' && (currencySymbol === (wethAsset === null || wethAsset === void 0 ? void 0 : wethAsset.symbol) || currencyId === (wethAsset === null || wethAsset === void 0 ? void 0 : wethAsset.assetId))) {
|
|
10129
|
+
return Promise.resolve(this.handleBifrostEthTransfer(input));
|
|
10130
|
+
}
|
|
10131
|
+
if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined && destination !== 'Hydration') {
|
|
9974
10132
|
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.');
|
|
9975
10133
|
}
|
|
9976
10134
|
if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
|
|
9977
10135
|
throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
|
|
9978
10136
|
}
|
|
9979
10137
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9980
|
-
var
|
|
9981
|
-
destination = input.destination,
|
|
9982
|
-
paraIdTo = input.paraIdTo,
|
|
9983
|
-
address = input.address,
|
|
9984
|
-
amount = input.amount,
|
|
9985
|
-
overridedCurrency = input.overridedCurrency;
|
|
9986
|
-
var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : Version.V2;
|
|
9987
|
-
var modifiedInput = ((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDT' || (currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot' ? Object.assign(Object.assign({}, input), {
|
|
9988
|
-
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
|
|
9989
|
-
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
|
|
9990
|
-
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
|
|
9991
|
-
}) : input;
|
|
10138
|
+
var modifiedInput = this.patchInput(input);
|
|
9992
10139
|
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
|
|
9993
10140
|
}
|
|
9994
10141
|
}, {
|
|
@@ -10016,7 +10163,7 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10016
10163
|
};
|
|
10017
10164
|
return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
|
|
10018
10165
|
} else {
|
|
10019
|
-
return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
|
|
10166
|
+
return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
|
|
10020
10167
|
}
|
|
10021
10168
|
}
|
|
10022
10169
|
}]);
|
|
@@ -10309,7 +10456,7 @@ var Darwinia$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10309
10456
|
};
|
|
10310
10457
|
return createCurrencySpec(amount, version, Parents.ZERO, overridedMultiLocation, interior);
|
|
10311
10458
|
} else {
|
|
10312
|
-
return _superPropGet(Darwinia, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
|
|
10459
|
+
return _superPropGet(Darwinia, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId, overridedMultiLocation]);
|
|
10313
10460
|
}
|
|
10314
10461
|
}
|
|
10315
10462
|
}, {
|
|
@@ -10544,7 +10691,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10544
10691
|
if (scenario === 'ParaToPara') {
|
|
10545
10692
|
return {};
|
|
10546
10693
|
} else {
|
|
10547
|
-
return _superPropGet(Collectives, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
|
|
10694
|
+
return _superPropGet(Collectives, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
|
|
10548
10695
|
}
|
|
10549
10696
|
}
|
|
10550
10697
|
}]);
|
|
@@ -11522,82 +11669,138 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
11522
11669
|
};
|
|
11523
11670
|
|
|
11524
11671
|
// Contains function for getting Asset ID or Symbol used in XCM call creation
|
|
11525
|
-
var
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
return
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11672
|
+
var findBestMatches = function findBestMatches(assets, symbol) {
|
|
11673
|
+
// First, exact match
|
|
11674
|
+
var matches = assets.filter(function (asset) {
|
|
11675
|
+
return asset.symbol === symbol;
|
|
11676
|
+
});
|
|
11677
|
+
if (matches.length > 0) {
|
|
11678
|
+
return matches;
|
|
11532
11679
|
}
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11680
|
+
// Uppercase match
|
|
11681
|
+
var upperSymbol = symbol.toUpperCase();
|
|
11682
|
+
matches = assets.filter(function (asset) {
|
|
11683
|
+
return asset.symbol === upperSymbol;
|
|
11536
11684
|
});
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11685
|
+
if (matches.length > 0) {
|
|
11686
|
+
return matches;
|
|
11687
|
+
}
|
|
11688
|
+
// Lowercase match
|
|
11689
|
+
var lowerSymbol = symbol.toLowerCase();
|
|
11690
|
+
matches = assets.filter(function (asset) {
|
|
11691
|
+
return asset.symbol === lowerSymbol;
|
|
11692
|
+
});
|
|
11693
|
+
if (matches.length > 0) {
|
|
11694
|
+
return matches;
|
|
11695
|
+
}
|
|
11696
|
+
// Case-insensitive match
|
|
11697
|
+
matches = assets.filter(function (asset) {
|
|
11698
|
+
var _a;
|
|
11699
|
+
return ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === lowerSymbol;
|
|
11540
11700
|
});
|
|
11701
|
+
return matches;
|
|
11702
|
+
};
|
|
11703
|
+
var findAssetBySymbol = function findAssetBySymbol(node, destination, otherAssets, nativeAssets, symbol, isRelayDestination) {
|
|
11704
|
+
var lowerSymbol = symbol.toLowerCase();
|
|
11541
11705
|
var isPolkadotXcm = !isRelayChain(node) && node !== 'Ethereum' && getDefaultPallet(node) === 'PolkadotXcm';
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11706
|
+
var otherAssetsMatches = [];
|
|
11707
|
+
var nativeAssetsMatches = [];
|
|
11708
|
+
if (destination === 'Ethereum') {
|
|
11709
|
+
var ethereumAssets = getOtherAssets('Ethereum');
|
|
11710
|
+
var assetsMatches = findBestMatches(ethereumAssets, symbol);
|
|
11711
|
+
if (assetsMatches.length === 0) {
|
|
11712
|
+
if (lowerSymbol.endsWith('.e')) {
|
|
11713
|
+
// Symbol ends with '.e', strip it and search again
|
|
11714
|
+
var strippedSymbol = symbol.slice(0, -2).toLowerCase();
|
|
11715
|
+
assetsMatches = findBestMatches(ethereumAssets, strippedSymbol);
|
|
11716
|
+
} else {
|
|
11717
|
+
// Symbol does not end with '.e', add '.e' suffix and search
|
|
11718
|
+
var suffixedSymbol = "".concat(symbol, ".e").toLowerCase();
|
|
11719
|
+
assetsMatches = findBestMatches(ethereumAssets, suffixedSymbol);
|
|
11557
11720
|
}
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11721
|
+
}
|
|
11722
|
+
return assetsMatches[0];
|
|
11723
|
+
}
|
|
11724
|
+
var supportsESuffix = node === 'AssetHubPolkadot' || node === 'AssetHubKusama' || destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama' || node === 'Ethereum';
|
|
11725
|
+
if (lowerSymbol.endsWith('.e') && supportsESuffix) {
|
|
11726
|
+
// Symbol ends with '.e', indicating a Snowbridge asset
|
|
11727
|
+
var _strippedSymbol = symbol.slice(0, -2);
|
|
11728
|
+
// Search in Ethereum assets without the '.e' suffix
|
|
11729
|
+
var _ethereumAssets = getOtherAssets('Ethereum');
|
|
11730
|
+
var ethereumMatches = findBestMatches(_ethereumAssets, _strippedSymbol);
|
|
11731
|
+
if (ethereumMatches.length > 0) {
|
|
11732
|
+
return ethereumMatches[0];
|
|
11733
|
+
}
|
|
11734
|
+
// If not found, search normal assets with '.e' suffix
|
|
11735
|
+
otherAssetsMatches = findBestMatches(otherAssets, symbol);
|
|
11736
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, symbol);
|
|
11737
|
+
if (nativeAssetsMatches.length > 0 || otherAssetsMatches.length > 0) {
|
|
11738
|
+
if (isPolkadotXcm) {
|
|
11739
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0];
|
|
11561
11740
|
}
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
nativeAssetsMatches = nativeAssets.filter(function (_ref7) {
|
|
11571
|
-
var assetSymbol = _ref7.symbol;
|
|
11572
|
-
return (assetSymbol === null || assetSymbol === void 0 ? void 0 : assetSymbol.toLowerCase()) === prefixedLowerSymbol;
|
|
11573
|
-
});
|
|
11574
|
-
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11575
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11741
|
+
return otherAssetsMatches[0] || nativeAssetsMatches[0];
|
|
11742
|
+
}
|
|
11743
|
+
// If still not found, search normal assets without suffix
|
|
11744
|
+
otherAssetsMatches = findBestMatches(otherAssets, _strippedSymbol);
|
|
11745
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, _strippedSymbol);
|
|
11746
|
+
if (nativeAssetsMatches.length > 0 || otherAssetsMatches.length > 0) {
|
|
11747
|
+
if (isPolkadotXcm) {
|
|
11748
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0];
|
|
11576
11749
|
}
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11750
|
+
return otherAssetsMatches[0] || nativeAssetsMatches[0];
|
|
11751
|
+
}
|
|
11752
|
+
// No matches found
|
|
11753
|
+
return undefined;
|
|
11754
|
+
} else {
|
|
11755
|
+
// Symbol does not end with '.e', proceed with existing logic
|
|
11756
|
+
otherAssetsMatches = findBestMatches(otherAssets, symbol);
|
|
11757
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, symbol);
|
|
11758
|
+
if (otherAssetsMatches.length === 0 && nativeAssetsMatches.length === 0) {
|
|
11759
|
+
if (lowerSymbol.startsWith('xc')) {
|
|
11760
|
+
// Symbol starts with 'xc', try stripping 'xc' prefix
|
|
11761
|
+
var _strippedSymbol2 = symbol.substring(2);
|
|
11762
|
+
otherAssetsMatches = findBestMatches(otherAssets, _strippedSymbol2);
|
|
11763
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, _strippedSymbol2);
|
|
11764
|
+
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11765
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0] || undefined;
|
|
11766
|
+
}
|
|
11767
|
+
var totalMatches = otherAssetsMatches.length + nativeAssetsMatches.length;
|
|
11768
|
+
if (totalMatches > 1) {
|
|
11769
|
+
throw new InvalidCurrencyError("Multiple assets found for symbol ".concat(symbol, " after stripping 'xc' prefix. Please specify by ID."));
|
|
11770
|
+
}
|
|
11771
|
+
} else {
|
|
11772
|
+
// Try adding 'xc' prefix
|
|
11773
|
+
var prefixedSymbol = "xc".concat(symbol);
|
|
11774
|
+
otherAssetsMatches = findBestMatches(otherAssets, prefixedSymbol);
|
|
11775
|
+
nativeAssetsMatches = findBestMatches(nativeAssets, prefixedSymbol);
|
|
11776
|
+
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11777
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0] || undefined;
|
|
11778
|
+
}
|
|
11779
|
+
var _totalMatches = otherAssetsMatches.length + nativeAssetsMatches.length;
|
|
11780
|
+
if (_totalMatches > 1) {
|
|
11781
|
+
throw new InvalidCurrencyError("Multiple assets found for symbol ".concat(symbol, " after adding 'xc' prefix. Please specify by ID."));
|
|
11782
|
+
}
|
|
11580
11783
|
}
|
|
11581
11784
|
}
|
|
11785
|
+
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11786
|
+
return nativeAssetsMatches[0] || otherAssetsMatches[0] || undefined;
|
|
11787
|
+
}
|
|
11788
|
+
if (otherAssetsMatches.length > 1 && !isRelayDestination) {
|
|
11789
|
+
throw new DuplicateAssetError(symbol);
|
|
11790
|
+
}
|
|
11791
|
+
return otherAssetsMatches[0] || nativeAssetsMatches[0] || undefined;
|
|
11582
11792
|
}
|
|
11583
|
-
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11584
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11585
|
-
}
|
|
11586
|
-
if (otherAssetsMatches.length > 1 && !isRelayDestination) {
|
|
11587
|
-
throw new DuplicateAssetError(symbol);
|
|
11588
|
-
}
|
|
11589
|
-
return otherAssetsMatches[0] || nativeAssetsMatches[0] || null;
|
|
11590
11793
|
};
|
|
11591
11794
|
var findAssetById = function findAssetById(assets, assetId) {
|
|
11592
|
-
var otherAssetsMatches = assets.filter(function (
|
|
11593
|
-
var currentAssetId =
|
|
11795
|
+
var otherAssetsMatches = assets.filter(function (_ref) {
|
|
11796
|
+
var currentAssetId = _ref.assetId;
|
|
11594
11797
|
return currentAssetId === assetId.toString();
|
|
11595
11798
|
});
|
|
11596
11799
|
if (otherAssetsMatches.length > 1) {
|
|
11597
11800
|
throw new DuplicateAssetIdError(assetId.toString());
|
|
11598
11801
|
}
|
|
11599
|
-
return assets.find(function (
|
|
11600
|
-
var currentAssetId =
|
|
11802
|
+
return assets.find(function (_ref2) {
|
|
11803
|
+
var currentAssetId = _ref2.assetId;
|
|
11601
11804
|
return currentAssetId === assetId.toString();
|
|
11602
11805
|
});
|
|
11603
11806
|
};
|
|
@@ -11615,7 +11818,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency) {
|
|
|
11615
11818
|
var combinedAssets = destination === 'Ethereum' ? _toConsumableArray(getOtherAssets('Ethereum')) : [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets));
|
|
11616
11819
|
var asset;
|
|
11617
11820
|
if ('symbol' in currency) {
|
|
11618
|
-
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets,
|
|
11821
|
+
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets, currency.symbol, isRelayDestination);
|
|
11619
11822
|
} else {
|
|
11620
11823
|
asset = findAssetById(combinedAssets, currency.id);
|
|
11621
11824
|
}
|
|
@@ -11750,6 +11953,11 @@ var hasSupportForAsset = function hasSupportForAsset(node, symbol) {
|
|
|
11750
11953
|
} else {
|
|
11751
11954
|
symbolsToCheck.add("xc".concat(lowerSymbol));
|
|
11752
11955
|
}
|
|
11956
|
+
if (lowerSymbol.endsWith('.e')) {
|
|
11957
|
+
symbolsToCheck.add(lowerSymbol.substring(0, lowerSymbol.length - 2));
|
|
11958
|
+
} else {
|
|
11959
|
+
symbolsToCheck.add("".concat(lowerSymbol, ".e"));
|
|
11960
|
+
}
|
|
11753
11961
|
var nodeSymbols = getAllAssetsSymbols(node).map(function (s) {
|
|
11754
11962
|
return s.toLowerCase();
|
|
11755
11963
|
});
|
|
@@ -12093,8 +12301,8 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
|
|
|
12093
12301
|
_context.next = 13;
|
|
12094
12302
|
break;
|
|
12095
12303
|
}
|
|
12096
|
-
multiLocation = getAssetHubMultiLocation(asset.symbol);
|
|
12097
|
-
if (!multiLocation) {
|
|
12304
|
+
multiLocation = getAssetHubMultiLocation(asset.symbol); // Ethereum address ID indicates that it is an Ethereum asset
|
|
12305
|
+
if (!(multiLocation && ethers.isAddress(asset.assetId))) {
|
|
12098
12306
|
_context.next = 10;
|
|
12099
12307
|
break;
|
|
12100
12308
|
}
|
|
@@ -13399,6 +13607,7 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
13399
13607
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
13400
13608
|
var api = _ref.api,
|
|
13401
13609
|
account = _ref.account,
|
|
13610
|
+
accountDestination = _ref.accountDestination,
|
|
13402
13611
|
amount = _ref.amount,
|
|
13403
13612
|
currency = _ref.currency,
|
|
13404
13613
|
origin = _ref.origin,
|
|
@@ -13420,7 +13629,7 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
13420
13629
|
nativeBalance = _context2.sent;
|
|
13421
13630
|
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
13422
13631
|
_context2.next = 6;
|
|
13423
|
-
return createTx$1(api,
|
|
13632
|
+
return createTx$1(api, accountDestination, amount, currency, origin, destination);
|
|
13424
13633
|
case 6:
|
|
13425
13634
|
tx = _context2.sent;
|
|
13426
13635
|
_context2.next = 9;
|
|
@@ -13452,7 +13661,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13452
13661
|
amount = _ref.amount,
|
|
13453
13662
|
originApi = _ref.api;
|
|
13454
13663
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13455
|
-
var _b, _c, _d, originBalance,
|
|
13664
|
+
var _b, _c, _d, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
13456
13665
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13457
13666
|
while (1) switch (_context.prev = _context.next) {
|
|
13458
13667
|
case 0:
|
|
@@ -13474,64 +13683,54 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13474
13683
|
currency: currency,
|
|
13475
13684
|
amount: amount,
|
|
13476
13685
|
account: accountOrigin,
|
|
13686
|
+
accountDestination: accountDestination,
|
|
13477
13687
|
api: originApi
|
|
13478
13688
|
});
|
|
13479
13689
|
case 7:
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
|
|
13690
|
+
xcmFeeDetails = _context.sent;
|
|
13691
|
+
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
13483
13692
|
asset = (_b = getAssetBySymbolOrId(origin, currency)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency) : null;
|
|
13484
13693
|
if (asset) {
|
|
13485
|
-
_context.next =
|
|
13694
|
+
_context.next = 12;
|
|
13486
13695
|
break;
|
|
13487
13696
|
}
|
|
13488
13697
|
throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
|
|
13489
|
-
case
|
|
13698
|
+
case 12:
|
|
13490
13699
|
_context.t0 = {
|
|
13491
13700
|
origin: origin,
|
|
13492
13701
|
destination: destination,
|
|
13493
13702
|
ecosystem: determineRelayChainSymbol(origin)
|
|
13494
13703
|
};
|
|
13495
|
-
_context.next =
|
|
13704
|
+
_context.next = 15;
|
|
13496
13705
|
return getAssetBalance$1({
|
|
13497
13706
|
api: originApi,
|
|
13498
13707
|
address: accountOrigin,
|
|
13499
13708
|
node: origin,
|
|
13500
13709
|
currency: currency
|
|
13501
13710
|
});
|
|
13502
|
-
case
|
|
13711
|
+
case 15:
|
|
13503
13712
|
_context.t1 = _context.sent;
|
|
13504
13713
|
_context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
|
|
13505
13714
|
_context.t3 = {
|
|
13506
13715
|
balance: _context.t1,
|
|
13507
13716
|
currency: _context.t2
|
|
13508
13717
|
};
|
|
13509
|
-
_context.next =
|
|
13718
|
+
_context.next = 20;
|
|
13510
13719
|
return getBalanceNative$1({
|
|
13511
13720
|
address: accountOrigin,
|
|
13512
13721
|
node: origin,
|
|
13513
13722
|
api: originApi
|
|
13514
13723
|
});
|
|
13515
|
-
case
|
|
13724
|
+
case 20:
|
|
13516
13725
|
_context.t4 = _context.sent;
|
|
13517
13726
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
13518
|
-
_context.
|
|
13519
|
-
return getOriginFeeDetails$1({
|
|
13520
|
-
origin: origin,
|
|
13521
|
-
destination: destination,
|
|
13522
|
-
currency: currency,
|
|
13523
|
-
amount: amount,
|
|
13524
|
-
account: accountOrigin,
|
|
13525
|
-
api: originApi
|
|
13526
|
-
});
|
|
13527
|
-
case 25:
|
|
13528
|
-
_context.t6 = _context.sent;
|
|
13727
|
+
_context.t6 = xcmFeeDetails;
|
|
13529
13728
|
_context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
|
|
13530
13729
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
13531
13730
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
13532
|
-
_context.next =
|
|
13731
|
+
_context.next = 28;
|
|
13533
13732
|
return getMaxNativeTransferableAmount(originApi, accountOrigin, origin);
|
|
13534
|
-
case
|
|
13733
|
+
case 28:
|
|
13535
13734
|
_context.t10 = _context.sent;
|
|
13536
13735
|
_context.t11 = {
|
|
13537
13736
|
balance: _context.t4,
|
|
@@ -13542,13 +13741,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13542
13741
|
minNativeTransferableAmount: _context.t9,
|
|
13543
13742
|
maxNativeTransferableAmount: _context.t10
|
|
13544
13743
|
};
|
|
13545
|
-
_context.next =
|
|
13744
|
+
_context.next = 32;
|
|
13546
13745
|
return getBalanceNative$1({
|
|
13547
13746
|
address: accountDestination,
|
|
13548
13747
|
node: destination,
|
|
13549
13748
|
api: originApi
|
|
13550
13749
|
});
|
|
13551
|
-
case
|
|
13750
|
+
case 32:
|
|
13552
13751
|
_context.t12 = _context.sent;
|
|
13553
13752
|
_context.t13 = getNativeAssetSymbol(destination);
|
|
13554
13753
|
_context.t14 = getExistentialDeposit(destination);
|
|
@@ -13563,7 +13762,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13563
13762
|
originFeeBalance: _context.t11,
|
|
13564
13763
|
destinationFeeBalance: _context.t15
|
|
13565
13764
|
});
|
|
13566
|
-
case
|
|
13765
|
+
case 37:
|
|
13567
13766
|
case "end":
|
|
13568
13767
|
return _context.stop();
|
|
13569
13768
|
}
|
|
@@ -13618,6 +13817,16 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
13618
13817
|
return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
|
|
13619
13818
|
});
|
|
13620
13819
|
});
|
|
13820
|
+
if (origin === 'AssetHubPolkadot' && destination === 'BifrostPolkadot') {
|
|
13821
|
+
var wethAsset = getOtherAssets('Ethereum').find(function (_ref) {
|
|
13822
|
+
var symbol = _ref.symbol;
|
|
13823
|
+
return symbol === 'WETH';
|
|
13824
|
+
});
|
|
13825
|
+
if (wethAsset) supportedAssets.push({
|
|
13826
|
+
assetId: wethAsset.assetId,
|
|
13827
|
+
symbol: "".concat(wethAsset.symbol, ".e")
|
|
13828
|
+
});
|
|
13829
|
+
}
|
|
13621
13830
|
return supportedAssets;
|
|
13622
13831
|
};
|
|
13623
13832
|
|
|
@@ -13763,7 +13972,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13763
13972
|
return __awaiter(void 0, [options_1].concat(args_1), void 0, function (options) {
|
|
13764
13973
|
var serializedApiCallEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
13765
13974
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13766
|
-
var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, ahAddress, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet, isBifrost, asset, amountStr, currencyStr;
|
|
13975
|
+
var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, ahAddress, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet, isBifrost, asset, nativeAssets, amountStr, currencyStr;
|
|
13767
13976
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13768
13977
|
while (1) switch (_context.prev = _context.next) {
|
|
13769
13978
|
case 0:
|
|
@@ -13844,83 +14053,89 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13844
14053
|
pallet = getDefaultPallet(origin);
|
|
13845
14054
|
isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
13846
14055
|
if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
|
|
13847
|
-
_context.next =
|
|
14056
|
+
_context.next = 44;
|
|
13848
14057
|
break;
|
|
13849
14058
|
}
|
|
13850
14059
|
asset = getAssetBySymbolOrId(destination, currency, false, destination);
|
|
13851
|
-
|
|
14060
|
+
nativeAssets = getNativeAssets(destination);
|
|
14061
|
+
if (origin === 'Hydration') {
|
|
14062
|
+
nativeAssets = nativeAssets.filter(function (nativeAsset) {
|
|
14063
|
+
return nativeAsset.symbol !== 'DOT';
|
|
14064
|
+
});
|
|
14065
|
+
}
|
|
14066
|
+
if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
|
|
13852
14067
|
return nativeAsset.symbol.toLowerCase() === currency.symbol.toLowerCase();
|
|
13853
14068
|
}))) {
|
|
13854
|
-
_context.next =
|
|
14069
|
+
_context.next = 38;
|
|
13855
14070
|
break;
|
|
13856
14071
|
}
|
|
13857
14072
|
throw new InvalidCurrencyError("".concat(currency.symbol, " is not supported for transfers to ").concat(destination, "."));
|
|
13858
|
-
case
|
|
14073
|
+
case 38:
|
|
13859
14074
|
if (!(assetCheckEnabled && asset === null)) {
|
|
13860
|
-
_context.next =
|
|
14075
|
+
_context.next = 40;
|
|
13861
14076
|
break;
|
|
13862
14077
|
}
|
|
13863
14078
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13864
|
-
case
|
|
14079
|
+
case 40:
|
|
13865
14080
|
if (!((asset === null || asset === void 0 ? void 0 : asset.symbol) && !hasSupportForAsset(origin, asset.symbol))) {
|
|
13866
|
-
_context.next =
|
|
14081
|
+
_context.next = 42;
|
|
13867
14082
|
break;
|
|
13868
14083
|
}
|
|
13869
14084
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(asset.symbol, "."));
|
|
13870
|
-
case 40:
|
|
13871
|
-
_context.next = 47;
|
|
13872
|
-
break;
|
|
13873
14085
|
case 42:
|
|
14086
|
+
_context.next = 49;
|
|
14087
|
+
break;
|
|
14088
|
+
case 44:
|
|
13874
14089
|
asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination, isTMultiLocation(destination) ? undefined : destination) : null;
|
|
13875
14090
|
if (!(!isBridge && asset === null && assetCheckEnabled)) {
|
|
13876
|
-
_context.next =
|
|
14091
|
+
_context.next = 47;
|
|
13877
14092
|
break;
|
|
13878
14093
|
}
|
|
13879
14094
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13880
|
-
case
|
|
14095
|
+
case 47:
|
|
13881
14096
|
if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
|
|
13882
|
-
_context.next =
|
|
14097
|
+
_context.next = 49;
|
|
13883
14098
|
break;
|
|
13884
14099
|
}
|
|
13885
14100
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13886
|
-
case 47:
|
|
13887
|
-
_context.next = 49;
|
|
13888
|
-
return api.init(origin);
|
|
13889
14101
|
case 49:
|
|
14102
|
+
_context.next = 51;
|
|
14103
|
+
return api.init(origin);
|
|
14104
|
+
case 51:
|
|
13890
14105
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
13891
14106
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
13892
|
-
_context.next =
|
|
14107
|
+
_context.next = 56;
|
|
13893
14108
|
break;
|
|
13894
14109
|
}
|
|
13895
14110
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
13896
|
-
_context.next =
|
|
14111
|
+
_context.next = 70;
|
|
13897
14112
|
break;
|
|
13898
|
-
case
|
|
14113
|
+
case 56:
|
|
13899
14114
|
if (!(_typeof(address) === 'object')) {
|
|
13900
|
-
_context.next =
|
|
14115
|
+
_context.next = 60;
|
|
13901
14116
|
break;
|
|
13902
14117
|
}
|
|
13903
14118
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
13904
|
-
_context.next =
|
|
14119
|
+
_context.next = 70;
|
|
13905
14120
|
break;
|
|
13906
|
-
case
|
|
14121
|
+
case 60:
|
|
13907
14122
|
if (!(_typeof(destination) === 'object')) {
|
|
13908
|
-
_context.next =
|
|
14123
|
+
_context.next = 64;
|
|
13909
14124
|
break;
|
|
13910
14125
|
}
|
|
13911
14126
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
13912
|
-
_context.next =
|
|
14127
|
+
_context.next = 70;
|
|
13913
14128
|
break;
|
|
13914
|
-
case
|
|
14129
|
+
case 64:
|
|
13915
14130
|
if (!(origin === 'Ethereum' || destination === 'Ethereum')) {
|
|
13916
|
-
_context.next =
|
|
14131
|
+
_context.next = 68;
|
|
13917
14132
|
break;
|
|
13918
14133
|
}
|
|
13919
14134
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
13920
|
-
_context.next =
|
|
14135
|
+
_context.next = 70;
|
|
13921
14136
|
break;
|
|
13922
|
-
case
|
|
13923
|
-
_context.next =
|
|
14137
|
+
case 68:
|
|
14138
|
+
_context.next = 70;
|
|
13924
14139
|
return checkKeepAlive({
|
|
13925
14140
|
originApi: api,
|
|
13926
14141
|
address: address,
|
|
@@ -13930,7 +14145,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13930
14145
|
currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : 'symbol' in currency ? currency.symbol : undefined,
|
|
13931
14146
|
destNode: destination
|
|
13932
14147
|
});
|
|
13933
|
-
case
|
|
14148
|
+
case 70:
|
|
13934
14149
|
currencyStr = 'symbol' in currency ? currency.symbol : 'id' in currency ? currency.id.toString() : undefined;
|
|
13935
14150
|
return _context.abrupt("return", originNode.transfer({
|
|
13936
14151
|
api: api,
|
|
@@ -13947,7 +14162,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13947
14162
|
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
13948
14163
|
ahAddress: ahAddress
|
|
13949
14164
|
}));
|
|
13950
|
-
case
|
|
14165
|
+
case 72:
|
|
13951
14166
|
case "end":
|
|
13952
14167
|
return _context.stop();
|
|
13953
14168
|
}
|