@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.cjs
CHANGED
|
@@ -494,8 +494,8 @@ function _superPropBase(t, o) {
|
|
|
494
494
|
return t;
|
|
495
495
|
}
|
|
496
496
|
function _superPropGet(t, o, e, r) {
|
|
497
|
-
var p = _get(_getPrototypeOf(t.prototype ), o, e);
|
|
498
|
-
return "function" == typeof p ? function (t) {
|
|
497
|
+
var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e);
|
|
498
|
+
return 2 & r && "function" == typeof p ? function (t) {
|
|
499
499
|
return p.apply(e, t);
|
|
500
500
|
} : p;
|
|
501
501
|
}
|
|
@@ -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,31 +9296,34 @@ var calculateFee = function calculateFee(api) {
|
|
|
9280
9296
|
}, _callee);
|
|
9281
9297
|
}));
|
|
9282
9298
|
};
|
|
9283
|
-
var
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9299
|
+
var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
|
|
9300
|
+
var api = _ref.api,
|
|
9301
|
+
scenario = _ref.scenario,
|
|
9302
|
+
address = _ref.address;
|
|
9303
|
+
return _defineProperty({}, version, [{
|
|
9304
|
+
DepositAsset: {
|
|
9305
|
+
assets: {
|
|
9306
|
+
Wild: {
|
|
9307
|
+
AllCounted: 1
|
|
9290
9308
|
}
|
|
9291
|
-
}
|
|
9309
|
+
},
|
|
9310
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
|
|
9292
9311
|
}
|
|
9293
|
-
};
|
|
9312
|
+
}]);
|
|
9294
9313
|
};
|
|
9295
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(
|
|
9296
|
-
var api =
|
|
9297
|
-
address =
|
|
9298
|
-
currencyId =
|
|
9299
|
-
scenario =
|
|
9300
|
-
ahAddress =
|
|
9301
|
-
return _defineProperty({},
|
|
9314
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref3, version) {
|
|
9315
|
+
var api = _ref3.api,
|
|
9316
|
+
address = _ref3.address,
|
|
9317
|
+
currencyId = _ref3.currencyId,
|
|
9318
|
+
scenario = _ref3.scenario,
|
|
9319
|
+
ahAddress = _ref3.ahAddress;
|
|
9320
|
+
return _defineProperty({}, version, [{
|
|
9302
9321
|
SetAppendix: [{
|
|
9303
9322
|
DepositAsset: {
|
|
9304
9323
|
assets: {
|
|
9305
9324
|
Wild: 'All'
|
|
9306
9325
|
},
|
|
9307
|
-
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '',
|
|
9326
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', version, undefined))[0]
|
|
9308
9327
|
}
|
|
9309
9328
|
}]
|
|
9310
9329
|
}, {
|
|
@@ -9371,11 +9390,10 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9371
9390
|
_classCallCheck(this, Hydration);
|
|
9372
9391
|
return _callSuper(this, Hydration, ['Hydration', 'hydradx', 'polkadot', exports.Version.V3]);
|
|
9373
9392
|
}
|
|
9374
|
-
// Handles WETH Ethereum transfers
|
|
9375
9393
|
_inherits(Hydration, _ParachainNode);
|
|
9376
9394
|
return _createClass(Hydration, [{
|
|
9377
|
-
key: "
|
|
9378
|
-
value: function
|
|
9395
|
+
key: "transferToEthereum",
|
|
9396
|
+
value: function transferToEthereum(input) {
|
|
9379
9397
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
9380
9398
|
var api, address, currencySymbol, scenario, version, destination, amount, currencyId, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
|
|
9381
9399
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -9430,6 +9448,59 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9430
9448
|
}, _callee2, this);
|
|
9431
9449
|
}));
|
|
9432
9450
|
}
|
|
9451
|
+
}, {
|
|
9452
|
+
key: "transferToAssetHub",
|
|
9453
|
+
value: function transferToAssetHub(input) {
|
|
9454
|
+
var api = input.api,
|
|
9455
|
+
scenario = input.scenario,
|
|
9456
|
+
version = input.version,
|
|
9457
|
+
destination = input.destination,
|
|
9458
|
+
amount = input.amount;
|
|
9459
|
+
var versionOrDefault = version !== null && version !== void 0 ? version : exports.Version.V3;
|
|
9460
|
+
var call = {
|
|
9461
|
+
module: 'PolkadotXcm',
|
|
9462
|
+
section: 'transfer_assets_using_type_and_then',
|
|
9463
|
+
parameters: {
|
|
9464
|
+
dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
|
|
9465
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(amount, 'ParaToRelay', versionOrDefault))[0][0]]),
|
|
9466
|
+
assets_transfer_type: 'DestinationReserve',
|
|
9467
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
9468
|
+
Concrete: {
|
|
9469
|
+
parents: exports.Parents.ONE,
|
|
9470
|
+
interior: 'Here'
|
|
9471
|
+
}
|
|
9472
|
+
}),
|
|
9473
|
+
fees_transfer_type: 'DestinationReserve',
|
|
9474
|
+
custom_xcm_on_dest: createCustomXcmAh(input, versionOrDefault),
|
|
9475
|
+
weight_limit: 'Unlimited'
|
|
9476
|
+
}
|
|
9477
|
+
};
|
|
9478
|
+
return api.callTxMethod(call);
|
|
9479
|
+
}
|
|
9480
|
+
// Handles WETH Ethereum transfers
|
|
9481
|
+
}, {
|
|
9482
|
+
key: "transferPolkadotXCM",
|
|
9483
|
+
value: function transferPolkadotXCM(input) {
|
|
9484
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
9485
|
+
var destination;
|
|
9486
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
9487
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
9488
|
+
case 0:
|
|
9489
|
+
destination = input.destination;
|
|
9490
|
+
if (!(destination === 'Ethereum')) {
|
|
9491
|
+
_context3.next = 3;
|
|
9492
|
+
break;
|
|
9493
|
+
}
|
|
9494
|
+
return _context3.abrupt("return", this.transferToEthereum(input));
|
|
9495
|
+
case 3:
|
|
9496
|
+
return _context3.abrupt("return", this.transferToAssetHub(input));
|
|
9497
|
+
case 4:
|
|
9498
|
+
case "end":
|
|
9499
|
+
return _context3.stop();
|
|
9500
|
+
}
|
|
9501
|
+
}, _callee3, this);
|
|
9502
|
+
}));
|
|
9503
|
+
}
|
|
9433
9504
|
}, {
|
|
9434
9505
|
key: "transferXTokens",
|
|
9435
9506
|
value: function transferXTokens(input) {
|
|
@@ -9438,9 +9509,15 @@ var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9438
9509
|
}
|
|
9439
9510
|
}, {
|
|
9440
9511
|
key: "canUseXTokens",
|
|
9441
|
-
value: function canUseXTokens(
|
|
9442
|
-
var destination =
|
|
9443
|
-
|
|
9512
|
+
value: function canUseXTokens(_ref5) {
|
|
9513
|
+
var destination = _ref5.destination,
|
|
9514
|
+
currencySymbol = _ref5.currencySymbol,
|
|
9515
|
+
currencyId = _ref5.currencyId;
|
|
9516
|
+
var dotAsset = getOtherAssets(this.node).find(function (_ref6) {
|
|
9517
|
+
var symbol = _ref6.symbol;
|
|
9518
|
+
return symbol === 'DOT';
|
|
9519
|
+
});
|
|
9520
|
+
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)));
|
|
9444
9521
|
}
|
|
9445
9522
|
}]);
|
|
9446
9523
|
}(ParachainNode);
|
|
@@ -9867,10 +9944,50 @@ var Karura$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9867
9944
|
}]);
|
|
9868
9945
|
}(ParachainNode);
|
|
9869
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
|
+
};
|
|
9870
9960
|
var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
9871
9961
|
function AssetHubPolkadot() {
|
|
9962
|
+
var _this;
|
|
9872
9963
|
_classCallCheck(this, AssetHubPolkadot);
|
|
9873
|
-
|
|
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;
|
|
9874
9991
|
}
|
|
9875
9992
|
_inherits(AssetHubPolkadot, _ParachainNode);
|
|
9876
9993
|
return _createClass(AssetHubPolkadot, [{
|
|
@@ -9956,41 +10073,71 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9956
10073
|
});
|
|
9957
10074
|
return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'limited_teleport_assets', 'Unlimited');
|
|
9958
10075
|
}
|
|
10076
|
+
}, {
|
|
10077
|
+
key: "patchInput",
|
|
10078
|
+
value: function patchInput(input) {
|
|
10079
|
+
var _a;
|
|
10080
|
+
var currencySymbol = input.currencySymbol,
|
|
10081
|
+
currencyId = input.currencyId,
|
|
10082
|
+
destination = input.destination,
|
|
10083
|
+
paraIdTo = input.paraIdTo,
|
|
10084
|
+
amount = input.amount,
|
|
10085
|
+
overridedCurrency = input.overridedCurrency,
|
|
10086
|
+
scenario = input.scenario,
|
|
10087
|
+
api = input.api,
|
|
10088
|
+
version = input.version,
|
|
10089
|
+
address = input.address;
|
|
10090
|
+
if (((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDT' || (currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot') {
|
|
10091
|
+
var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : exports.Version.V2;
|
|
10092
|
+
return Object.assign(Object.assign({}, input), {
|
|
10093
|
+
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
|
|
10094
|
+
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
|
|
10095
|
+
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
|
|
10096
|
+
});
|
|
10097
|
+
}
|
|
10098
|
+
var dotAsset = getOtherAssets(this.node).find(function (_ref3) {
|
|
10099
|
+
var symbol = _ref3.symbol;
|
|
10100
|
+
return symbol === 'DOT';
|
|
10101
|
+
});
|
|
10102
|
+
if (destination === 'Hydration' && (currencySymbol === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.symbol) || currencyId === (dotAsset === null || dotAsset === void 0 ? void 0 : dotAsset.assetId))) {
|
|
10103
|
+
var _versionOrDefault = version !== null && version !== void 0 ? version : this.version;
|
|
10104
|
+
return Object.assign(Object.assign({}, input), {
|
|
10105
|
+
currencySelection: _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, 'ParaToRelay', _versionOrDefault, currencyId, overridedCurrency])
|
|
10106
|
+
});
|
|
10107
|
+
}
|
|
10108
|
+
return input;
|
|
10109
|
+
}
|
|
9959
10110
|
}, {
|
|
9960
10111
|
key: "transferPolkadotXCM",
|
|
9961
10112
|
value: function transferPolkadotXCM(input) {
|
|
9962
|
-
var _a;
|
|
9963
10113
|
var scenario = input.scenario,
|
|
9964
10114
|
currencySymbol = input.currencySymbol,
|
|
9965
|
-
currencyId = input.currencyId
|
|
9966
|
-
|
|
10115
|
+
currencyId = input.currencyId,
|
|
10116
|
+
destination = input.destination;
|
|
10117
|
+
if (destination === 'AssetHubKusama') {
|
|
9967
10118
|
return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
|
|
9968
10119
|
}
|
|
9969
|
-
if (
|
|
10120
|
+
if (destination === 'Ethereum') {
|
|
9970
10121
|
return Promise.resolve(this.handleEthBridgeTransfer(input));
|
|
9971
10122
|
}
|
|
9972
|
-
if (
|
|
10123
|
+
if (destination === 'Mythos') {
|
|
9973
10124
|
return Promise.resolve(this.handleMythosTransfer(input));
|
|
9974
10125
|
}
|
|
9975
|
-
|
|
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
|
+
}
|
|
10133
|
+
if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined && destination !== 'Hydration') {
|
|
9976
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.');
|
|
9977
10135
|
}
|
|
9978
10136
|
if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
|
|
9979
10137
|
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>}.');
|
|
9980
10138
|
}
|
|
9981
10139
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9982
|
-
var
|
|
9983
|
-
destination = input.destination,
|
|
9984
|
-
paraIdTo = input.paraIdTo,
|
|
9985
|
-
address = input.address,
|
|
9986
|
-
amount = input.amount,
|
|
9987
|
-
overridedCurrency = input.overridedCurrency;
|
|
9988
|
-
var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : exports.Version.V2;
|
|
9989
|
-
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), {
|
|
9990
|
-
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
|
|
9991
|
-
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
|
|
9992
|
-
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
|
|
9993
|
-
}) : input;
|
|
10140
|
+
var modifiedInput = this.patchInput(input);
|
|
9994
10141
|
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
|
|
9995
10142
|
}
|
|
9996
10143
|
}, {
|
|
@@ -10018,7 +10165,7 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10018
10165
|
};
|
|
10019
10166
|
return createCurrencySpec(amount, version, exports.Parents.ZERO, overridedMultiLocation, interior);
|
|
10020
10167
|
} else {
|
|
10021
|
-
return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
|
|
10168
|
+
return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
|
|
10022
10169
|
}
|
|
10023
10170
|
}
|
|
10024
10171
|
}]);
|
|
@@ -10311,7 +10458,7 @@ var Darwinia$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10311
10458
|
};
|
|
10312
10459
|
return createCurrencySpec(amount, version, exports.Parents.ZERO, overridedMultiLocation, interior);
|
|
10313
10460
|
} else {
|
|
10314
|
-
return _superPropGet(Darwinia, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
|
|
10461
|
+
return _superPropGet(Darwinia, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId, overridedMultiLocation]);
|
|
10315
10462
|
}
|
|
10316
10463
|
}
|
|
10317
10464
|
}, {
|
|
@@ -10546,7 +10693,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10546
10693
|
if (scenario === 'ParaToPara') {
|
|
10547
10694
|
return {};
|
|
10548
10695
|
} else {
|
|
10549
|
-
return _superPropGet(Collectives, "createCurrencySpec", this)([amount, scenario, version, currencyId]);
|
|
10696
|
+
return _superPropGet(Collectives, "createCurrencySpec", this, 3)([amount, scenario, version, currencyId]);
|
|
10550
10697
|
}
|
|
10551
10698
|
}
|
|
10552
10699
|
}]);
|
|
@@ -11524,82 +11671,138 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
11524
11671
|
};
|
|
11525
11672
|
|
|
11526
11673
|
// Contains function for getting Asset ID or Symbol used in XCM call creation
|
|
11527
|
-
var
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
return
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
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;
|
|
11534
11681
|
}
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11682
|
+
// Uppercase match
|
|
11683
|
+
var upperSymbol = symbol.toUpperCase();
|
|
11684
|
+
matches = assets.filter(function (asset) {
|
|
11685
|
+
return asset.symbol === upperSymbol;
|
|
11538
11686
|
});
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
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;
|
|
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;
|
|
11542
11702
|
});
|
|
11703
|
+
return matches;
|
|
11704
|
+
};
|
|
11705
|
+
var findAssetBySymbol = function findAssetBySymbol(node, destination, otherAssets, nativeAssets, symbol, isRelayDestination) {
|
|
11706
|
+
var lowerSymbol = symbol.toLowerCase();
|
|
11543
11707
|
var isPolkadotXcm = !isRelayChain(node) && node !== 'Ethereum' && getDefaultPallet(node) === 'PolkadotXcm';
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
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);
|
|
11559
11722
|
}
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
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];
|
|
11563
11742
|
}
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
nativeAssetsMatches = nativeAssets.filter(function (_ref7) {
|
|
11573
|
-
var assetSymbol = _ref7.symbol;
|
|
11574
|
-
return (assetSymbol === null || assetSymbol === void 0 ? void 0 : assetSymbol.toLowerCase()) === prefixedLowerSymbol;
|
|
11575
|
-
});
|
|
11576
|
-
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11577
|
-
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];
|
|
11578
11751
|
}
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
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
|
+
}
|
|
11582
11785
|
}
|
|
11583
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;
|
|
11584
11794
|
}
|
|
11585
|
-
if (node === 'Astar' || node === 'Shiden' || isPolkadotXcm) {
|
|
11586
|
-
return nativeAssetsMatches[0] || otherAssetsMatches[0] || null;
|
|
11587
|
-
}
|
|
11588
|
-
if (otherAssetsMatches.length > 1 && !isRelayDestination) {
|
|
11589
|
-
throw new DuplicateAssetError(symbol);
|
|
11590
|
-
}
|
|
11591
|
-
return otherAssetsMatches[0] || nativeAssetsMatches[0] || null;
|
|
11592
11795
|
};
|
|
11593
11796
|
var findAssetById = function findAssetById(assets, assetId) {
|
|
11594
|
-
var otherAssetsMatches = assets.filter(function (
|
|
11595
|
-
var currentAssetId =
|
|
11797
|
+
var otherAssetsMatches = assets.filter(function (_ref) {
|
|
11798
|
+
var currentAssetId = _ref.assetId;
|
|
11596
11799
|
return currentAssetId === assetId.toString();
|
|
11597
11800
|
});
|
|
11598
11801
|
if (otherAssetsMatches.length > 1) {
|
|
11599
11802
|
throw new DuplicateAssetIdError(assetId.toString());
|
|
11600
11803
|
}
|
|
11601
|
-
return assets.find(function (
|
|
11602
|
-
var currentAssetId =
|
|
11804
|
+
return assets.find(function (_ref2) {
|
|
11805
|
+
var currentAssetId = _ref2.assetId;
|
|
11603
11806
|
return currentAssetId === assetId.toString();
|
|
11604
11807
|
});
|
|
11605
11808
|
};
|
|
@@ -11617,7 +11820,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency) {
|
|
|
11617
11820
|
var combinedAssets = destination === 'Ethereum' ? _toConsumableArray(getOtherAssets('Ethereum')) : [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets));
|
|
11618
11821
|
var asset;
|
|
11619
11822
|
if ('symbol' in currency) {
|
|
11620
|
-
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets,
|
|
11823
|
+
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets, currency.symbol, isRelayDestination);
|
|
11621
11824
|
} else {
|
|
11622
11825
|
asset = findAssetById(combinedAssets, currency.id);
|
|
11623
11826
|
}
|
|
@@ -11752,6 +11955,11 @@ var hasSupportForAsset = function hasSupportForAsset(node, symbol) {
|
|
|
11752
11955
|
} else {
|
|
11753
11956
|
symbolsToCheck.add("xc".concat(lowerSymbol));
|
|
11754
11957
|
}
|
|
11958
|
+
if (lowerSymbol.endsWith('.e')) {
|
|
11959
|
+
symbolsToCheck.add(lowerSymbol.substring(0, lowerSymbol.length - 2));
|
|
11960
|
+
} else {
|
|
11961
|
+
symbolsToCheck.add("".concat(lowerSymbol, ".e"));
|
|
11962
|
+
}
|
|
11755
11963
|
var nodeSymbols = getAllAssetsSymbols(node).map(function (s) {
|
|
11756
11964
|
return s.toLowerCase();
|
|
11757
11965
|
});
|
|
@@ -12095,8 +12303,8 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
|
|
|
12095
12303
|
_context.next = 13;
|
|
12096
12304
|
break;
|
|
12097
12305
|
}
|
|
12098
|
-
multiLocation = getAssetHubMultiLocation(asset.symbol);
|
|
12099
|
-
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))) {
|
|
12100
12308
|
_context.next = 10;
|
|
12101
12309
|
break;
|
|
12102
12310
|
}
|
|
@@ -13401,6 +13609,7 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
13401
13609
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
13402
13610
|
var api = _ref.api,
|
|
13403
13611
|
account = _ref.account,
|
|
13612
|
+
accountDestination = _ref.accountDestination,
|
|
13404
13613
|
amount = _ref.amount,
|
|
13405
13614
|
currency = _ref.currency,
|
|
13406
13615
|
origin = _ref.origin,
|
|
@@ -13422,7 +13631,7 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
13422
13631
|
nativeBalance = _context2.sent;
|
|
13423
13632
|
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
13424
13633
|
_context2.next = 6;
|
|
13425
|
-
return createTx$1(api,
|
|
13634
|
+
return createTx$1(api, accountDestination, amount, currency, origin, destination);
|
|
13426
13635
|
case 6:
|
|
13427
13636
|
tx = _context2.sent;
|
|
13428
13637
|
_context2.next = 9;
|
|
@@ -13454,7 +13663,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13454
13663
|
amount = _ref.amount,
|
|
13455
13664
|
originApi = _ref.api;
|
|
13456
13665
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13457
|
-
var _b, _c, _d, originBalance,
|
|
13666
|
+
var _b, _c, _d, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
13458
13667
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13459
13668
|
while (1) switch (_context.prev = _context.next) {
|
|
13460
13669
|
case 0:
|
|
@@ -13476,64 +13685,54 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13476
13685
|
currency: currency,
|
|
13477
13686
|
amount: amount,
|
|
13478
13687
|
account: accountOrigin,
|
|
13688
|
+
accountDestination: accountDestination,
|
|
13479
13689
|
api: originApi
|
|
13480
13690
|
});
|
|
13481
13691
|
case 7:
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
|
|
13692
|
+
xcmFeeDetails = _context.sent;
|
|
13693
|
+
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
13485
13694
|
asset = (_b = getAssetBySymbolOrId(origin, currency)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency) : null;
|
|
13486
13695
|
if (asset) {
|
|
13487
|
-
_context.next =
|
|
13696
|
+
_context.next = 12;
|
|
13488
13697
|
break;
|
|
13489
13698
|
}
|
|
13490
13699
|
throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
|
|
13491
|
-
case
|
|
13700
|
+
case 12:
|
|
13492
13701
|
_context.t0 = {
|
|
13493
13702
|
origin: origin,
|
|
13494
13703
|
destination: destination,
|
|
13495
13704
|
ecosystem: determineRelayChainSymbol(origin)
|
|
13496
13705
|
};
|
|
13497
|
-
_context.next =
|
|
13706
|
+
_context.next = 15;
|
|
13498
13707
|
return getAssetBalance$1({
|
|
13499
13708
|
api: originApi,
|
|
13500
13709
|
address: accountOrigin,
|
|
13501
13710
|
node: origin,
|
|
13502
13711
|
currency: currency
|
|
13503
13712
|
});
|
|
13504
|
-
case
|
|
13713
|
+
case 15:
|
|
13505
13714
|
_context.t1 = _context.sent;
|
|
13506
13715
|
_context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
|
|
13507
13716
|
_context.t3 = {
|
|
13508
13717
|
balance: _context.t1,
|
|
13509
13718
|
currency: _context.t2
|
|
13510
13719
|
};
|
|
13511
|
-
_context.next =
|
|
13720
|
+
_context.next = 20;
|
|
13512
13721
|
return getBalanceNative$1({
|
|
13513
13722
|
address: accountOrigin,
|
|
13514
13723
|
node: origin,
|
|
13515
13724
|
api: originApi
|
|
13516
13725
|
});
|
|
13517
|
-
case
|
|
13726
|
+
case 20:
|
|
13518
13727
|
_context.t4 = _context.sent;
|
|
13519
13728
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
13520
|
-
_context.
|
|
13521
|
-
return getOriginFeeDetails$1({
|
|
13522
|
-
origin: origin,
|
|
13523
|
-
destination: destination,
|
|
13524
|
-
currency: currency,
|
|
13525
|
-
amount: amount,
|
|
13526
|
-
account: accountOrigin,
|
|
13527
|
-
api: originApi
|
|
13528
|
-
});
|
|
13529
|
-
case 25:
|
|
13530
|
-
_context.t6 = _context.sent;
|
|
13729
|
+
_context.t6 = xcmFeeDetails;
|
|
13531
13730
|
_context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
|
|
13532
13731
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
13533
13732
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
13534
|
-
_context.next =
|
|
13733
|
+
_context.next = 28;
|
|
13535
13734
|
return getMaxNativeTransferableAmount(originApi, accountOrigin, origin);
|
|
13536
|
-
case
|
|
13735
|
+
case 28:
|
|
13537
13736
|
_context.t10 = _context.sent;
|
|
13538
13737
|
_context.t11 = {
|
|
13539
13738
|
balance: _context.t4,
|
|
@@ -13544,13 +13743,13 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13544
13743
|
minNativeTransferableAmount: _context.t9,
|
|
13545
13744
|
maxNativeTransferableAmount: _context.t10
|
|
13546
13745
|
};
|
|
13547
|
-
_context.next =
|
|
13746
|
+
_context.next = 32;
|
|
13548
13747
|
return getBalanceNative$1({
|
|
13549
13748
|
address: accountDestination,
|
|
13550
13749
|
node: destination,
|
|
13551
13750
|
api: originApi
|
|
13552
13751
|
});
|
|
13553
|
-
case
|
|
13752
|
+
case 32:
|
|
13554
13753
|
_context.t12 = _context.sent;
|
|
13555
13754
|
_context.t13 = getNativeAssetSymbol(destination);
|
|
13556
13755
|
_context.t14 = getExistentialDeposit(destination);
|
|
@@ -13565,7 +13764,7 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
13565
13764
|
originFeeBalance: _context.t11,
|
|
13566
13765
|
destinationFeeBalance: _context.t15
|
|
13567
13766
|
});
|
|
13568
|
-
case
|
|
13767
|
+
case 37:
|
|
13569
13768
|
case "end":
|
|
13570
13769
|
return _context.stop();
|
|
13571
13770
|
}
|
|
@@ -13620,6 +13819,16 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
13620
13819
|
return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
|
|
13621
13820
|
});
|
|
13622
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
|
+
}
|
|
13623
13832
|
return supportedAssets;
|
|
13624
13833
|
};
|
|
13625
13834
|
|
|
@@ -13765,7 +13974,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13765
13974
|
return __awaiter(void 0, [options_1].concat(args_1), void 0, function (options) {
|
|
13766
13975
|
var serializedApiCallEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
13767
13976
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13768
|
-
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;
|
|
13977
|
+
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;
|
|
13769
13978
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13770
13979
|
while (1) switch (_context.prev = _context.next) {
|
|
13771
13980
|
case 0:
|
|
@@ -13846,83 +14055,89 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13846
14055
|
pallet = getDefaultPallet(origin);
|
|
13847
14056
|
isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
13848
14057
|
if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
|
|
13849
|
-
_context.next =
|
|
14058
|
+
_context.next = 44;
|
|
13850
14059
|
break;
|
|
13851
14060
|
}
|
|
13852
14061
|
asset = getAssetBySymbolOrId(destination, currency, false, destination);
|
|
13853
|
-
|
|
14062
|
+
nativeAssets = getNativeAssets(destination);
|
|
14063
|
+
if (origin === 'Hydration') {
|
|
14064
|
+
nativeAssets = nativeAssets.filter(function (nativeAsset) {
|
|
14065
|
+
return nativeAsset.symbol !== 'DOT';
|
|
14066
|
+
});
|
|
14067
|
+
}
|
|
14068
|
+
if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
|
|
13854
14069
|
return nativeAsset.symbol.toLowerCase() === currency.symbol.toLowerCase();
|
|
13855
14070
|
}))) {
|
|
13856
|
-
_context.next =
|
|
14071
|
+
_context.next = 38;
|
|
13857
14072
|
break;
|
|
13858
14073
|
}
|
|
13859
14074
|
throw new InvalidCurrencyError("".concat(currency.symbol, " is not supported for transfers to ").concat(destination, "."));
|
|
13860
|
-
case
|
|
14075
|
+
case 38:
|
|
13861
14076
|
if (!(assetCheckEnabled && asset === null)) {
|
|
13862
|
-
_context.next =
|
|
14077
|
+
_context.next = 40;
|
|
13863
14078
|
break;
|
|
13864
14079
|
}
|
|
13865
14080
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13866
|
-
case
|
|
14081
|
+
case 40:
|
|
13867
14082
|
if (!((asset === null || asset === void 0 ? void 0 : asset.symbol) && !hasSupportForAsset(origin, asset.symbol))) {
|
|
13868
|
-
_context.next =
|
|
14083
|
+
_context.next = 42;
|
|
13869
14084
|
break;
|
|
13870
14085
|
}
|
|
13871
14086
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(asset.symbol, "."));
|
|
13872
|
-
case 40:
|
|
13873
|
-
_context.next = 47;
|
|
13874
|
-
break;
|
|
13875
14087
|
case 42:
|
|
14088
|
+
_context.next = 49;
|
|
14089
|
+
break;
|
|
14090
|
+
case 44:
|
|
13876
14091
|
asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination, isTMultiLocation(destination) ? undefined : destination) : null;
|
|
13877
14092
|
if (!(!isBridge && asset === null && assetCheckEnabled)) {
|
|
13878
|
-
_context.next =
|
|
14093
|
+
_context.next = 47;
|
|
13879
14094
|
break;
|
|
13880
14095
|
}
|
|
13881
14096
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13882
|
-
case
|
|
14097
|
+
case 47:
|
|
13883
14098
|
if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
|
|
13884
|
-
_context.next =
|
|
14099
|
+
_context.next = 49;
|
|
13885
14100
|
break;
|
|
13886
14101
|
}
|
|
13887
14102
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13888
|
-
case 47:
|
|
13889
|
-
_context.next = 49;
|
|
13890
|
-
return api.init(origin);
|
|
13891
14103
|
case 49:
|
|
14104
|
+
_context.next = 51;
|
|
14105
|
+
return api.init(origin);
|
|
14106
|
+
case 51:
|
|
13892
14107
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
13893
14108
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
13894
|
-
_context.next =
|
|
14109
|
+
_context.next = 56;
|
|
13895
14110
|
break;
|
|
13896
14111
|
}
|
|
13897
14112
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
13898
|
-
_context.next =
|
|
14113
|
+
_context.next = 70;
|
|
13899
14114
|
break;
|
|
13900
|
-
case
|
|
14115
|
+
case 56:
|
|
13901
14116
|
if (!(_typeof(address) === 'object')) {
|
|
13902
|
-
_context.next =
|
|
14117
|
+
_context.next = 60;
|
|
13903
14118
|
break;
|
|
13904
14119
|
}
|
|
13905
14120
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
13906
|
-
_context.next =
|
|
14121
|
+
_context.next = 70;
|
|
13907
14122
|
break;
|
|
13908
|
-
case
|
|
14123
|
+
case 60:
|
|
13909
14124
|
if (!(_typeof(destination) === 'object')) {
|
|
13910
|
-
_context.next =
|
|
14125
|
+
_context.next = 64;
|
|
13911
14126
|
break;
|
|
13912
14127
|
}
|
|
13913
14128
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
13914
|
-
_context.next =
|
|
14129
|
+
_context.next = 70;
|
|
13915
14130
|
break;
|
|
13916
|
-
case
|
|
14131
|
+
case 64:
|
|
13917
14132
|
if (!(origin === 'Ethereum' || destination === 'Ethereum')) {
|
|
13918
|
-
_context.next =
|
|
14133
|
+
_context.next = 68;
|
|
13919
14134
|
break;
|
|
13920
14135
|
}
|
|
13921
14136
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
13922
|
-
_context.next =
|
|
14137
|
+
_context.next = 70;
|
|
13923
14138
|
break;
|
|
13924
|
-
case
|
|
13925
|
-
_context.next =
|
|
14139
|
+
case 68:
|
|
14140
|
+
_context.next = 70;
|
|
13926
14141
|
return checkKeepAlive({
|
|
13927
14142
|
originApi: api,
|
|
13928
14143
|
address: address,
|
|
@@ -13932,7 +14147,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13932
14147
|
currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : 'symbol' in currency ? currency.symbol : undefined,
|
|
13933
14148
|
destNode: destination
|
|
13934
14149
|
});
|
|
13935
|
-
case
|
|
14150
|
+
case 70:
|
|
13936
14151
|
currencyStr = 'symbol' in currency ? currency.symbol : 'id' in currency ? currency.id.toString() : undefined;
|
|
13937
14152
|
return _context.abrupt("return", originNode.transfer({
|
|
13938
14153
|
api: api,
|
|
@@ -13949,7 +14164,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13949
14164
|
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
13950
14165
|
ahAddress: ahAddress
|
|
13951
14166
|
}));
|
|
13952
|
-
case
|
|
14167
|
+
case 72:
|
|
13953
14168
|
case "end":
|
|
13954
14169
|
return _context.stop();
|
|
13955
14170
|
}
|