@paraspell/sdk 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -13
- package/dist/index.cjs +437 -181
- package/dist/index.d.ts +71 -57
- package/dist/index.mjs +437 -181
- package/dist/papi/index.cjs +435 -181
- package/dist/papi/index.d.ts +60 -46
- package/dist/papi/index.mjs +435 -181
- package/package.json +1 -1
package/dist/papi/index.cjs
CHANGED
|
@@ -506,11 +506,11 @@ function _toPrimitive(t, r) {
|
|
|
506
506
|
if ("object" != typeof t || !t) return t;
|
|
507
507
|
var e = t[Symbol.toPrimitive];
|
|
508
508
|
if (void 0 !== e) {
|
|
509
|
-
var i = e.call(t, r);
|
|
509
|
+
var i = e.call(t, r || "default");
|
|
510
510
|
if ("object" != typeof i) return i;
|
|
511
511
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
512
512
|
}
|
|
513
|
-
return (String )(t);
|
|
513
|
+
return ("string" === r ? String : Number)(t);
|
|
514
514
|
}
|
|
515
515
|
function _toPropertyKey(t) {
|
|
516
516
|
var i = _toPrimitive(t, "string");
|
|
@@ -8617,6 +8617,14 @@ var findParachainJunction = function findParachainJunction(multilocation) {
|
|
|
8617
8617
|
};
|
|
8618
8618
|
|
|
8619
8619
|
var DEFAULT_FEE_ASSET = 0;
|
|
8620
|
+
var ETH_CHAIN_ID = BigInt(1);
|
|
8621
|
+
var ETHEREUM_JUNCTION = {
|
|
8622
|
+
GlobalConsensus: {
|
|
8623
|
+
Ethereum: {
|
|
8624
|
+
chain_id: ETH_CHAIN_ID
|
|
8625
|
+
}
|
|
8626
|
+
}
|
|
8627
|
+
};
|
|
8620
8628
|
|
|
8621
8629
|
var constructRelayToParaParameters = function constructRelayToParaParameters(_ref, version) {
|
|
8622
8630
|
var api = _ref.api,
|
|
@@ -8774,82 +8782,103 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
8774
8782
|
}, {
|
|
8775
8783
|
key: "transfer",
|
|
8776
8784
|
value: function transfer(options) {
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8785
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8786
|
+
var api, currencySymbol, currencyId, amount, address, destination, paraIdTo, overridedCurrencyMultiLocation, feeAsset, version, ahAddress, _options$serializedAp, serializedApiCallEnabled, scenario, paraId, versionOrDefault;
|
|
8787
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8788
|
+
while (1) switch (_context.prev = _context.next) {
|
|
8789
|
+
case 0:
|
|
8790
|
+
api = options.api, currencySymbol = options.currencySymbol, currencyId = options.currencyId, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation, feeAsset = options.feeAsset, version = options.version, ahAddress = options.ahAddress, _options$serializedAp = options.serializedApiCallEnabled, serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
|
|
8791
|
+
scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
|
|
8792
|
+
paraId = destination !== undefined && _typeof(destination) !== 'object' && destination !== 'Ethereum' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
8793
|
+
if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot')) {
|
|
8794
|
+
_context.next = 5;
|
|
8795
|
+
break;
|
|
8796
|
+
}
|
|
8797
|
+
throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
|
|
8798
|
+
case 5:
|
|
8799
|
+
versionOrDefault = version !== null && version !== void 0 ? version : this.version;
|
|
8800
|
+
if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
|
|
8801
|
+
_context.next = 10;
|
|
8802
|
+
break;
|
|
8803
|
+
}
|
|
8804
|
+
return _context.abrupt("return", this.transferXTokens({
|
|
8805
|
+
api: api,
|
|
8806
|
+
currency: currencySymbol,
|
|
8807
|
+
currencyID: currencyId,
|
|
8808
|
+
amount: amount,
|
|
8809
|
+
addressSelection: generateAddressPayload(api, scenario, 'XTokens', address, versionOrDefault, paraId),
|
|
8810
|
+
fees: getFees(scenario),
|
|
8811
|
+
origin: this.node,
|
|
8812
|
+
scenario: scenario,
|
|
8813
|
+
paraIdTo: paraId,
|
|
8814
|
+
destination: destination,
|
|
8815
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
8816
|
+
feeAsset: feeAsset,
|
|
8817
|
+
serializedApiCallEnabled: serializedApiCallEnabled
|
|
8818
|
+
}));
|
|
8819
|
+
case 10:
|
|
8820
|
+
if (!supportsXTransfer(this)) {
|
|
8821
|
+
_context.next = 14;
|
|
8822
|
+
break;
|
|
8823
|
+
}
|
|
8824
|
+
return _context.abrupt("return", this.transferXTransfer({
|
|
8825
|
+
api: api,
|
|
8826
|
+
currency: currencySymbol,
|
|
8827
|
+
currencyID: currencyId,
|
|
8828
|
+
amount: amount,
|
|
8829
|
+
recipientAddress: address,
|
|
8830
|
+
paraId: paraId,
|
|
8831
|
+
origin: this.node,
|
|
8832
|
+
destination: destination,
|
|
8833
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
8834
|
+
serializedApiCallEnabled: serializedApiCallEnabled
|
|
8835
|
+
}));
|
|
8836
|
+
case 14:
|
|
8837
|
+
if (!supportsPolkadotXCM(this)) {
|
|
8838
|
+
_context.next = 22;
|
|
8839
|
+
break;
|
|
8840
|
+
}
|
|
8841
|
+
if (!(isTMultiLocation(overridedCurrencyMultiLocation) && !verifyMultiLocation(this.node, overridedCurrencyMultiLocation))) {
|
|
8842
|
+
_context.next = 17;
|
|
8843
|
+
break;
|
|
8844
|
+
}
|
|
8845
|
+
throw new InvalidCurrencyError('Provided Multi-location is not a valid currency.');
|
|
8846
|
+
case 17:
|
|
8847
|
+
_context.next = 19;
|
|
8848
|
+
return this.transferPolkadotXCM({
|
|
8849
|
+
api: api,
|
|
8850
|
+
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraId),
|
|
8851
|
+
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraId),
|
|
8852
|
+
address: address,
|
|
8853
|
+
amount: amount,
|
|
8854
|
+
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrencyMultiLocation),
|
|
8855
|
+
currencyId: currencyId,
|
|
8856
|
+
scenario: scenario,
|
|
8857
|
+
currencySymbol: currencySymbol,
|
|
8858
|
+
feeAsset: feeAsset,
|
|
8859
|
+
destination: destination,
|
|
8860
|
+
paraIdTo: paraId,
|
|
8861
|
+
overridedCurrency: overridedCurrencyMultiLocation,
|
|
8862
|
+
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
8863
|
+
version: version,
|
|
8864
|
+
ahAddress: ahAddress
|
|
8865
|
+
});
|
|
8866
|
+
case 19:
|
|
8867
|
+
return _context.abrupt("return", _context.sent);
|
|
8868
|
+
case 22:
|
|
8869
|
+
throw new NoXCMSupportImplementedError(this._node);
|
|
8870
|
+
case 23:
|
|
8871
|
+
case "end":
|
|
8872
|
+
return _context.stop();
|
|
8873
|
+
}
|
|
8874
|
+
}, _callee, this);
|
|
8875
|
+
}));
|
|
8847
8876
|
}
|
|
8848
8877
|
}, {
|
|
8849
8878
|
key: "transferRelayToPara",
|
|
8850
8879
|
value: function transferRelayToPara(options) {
|
|
8851
|
-
var _options$
|
|
8852
|
-
version = _options$
|
|
8880
|
+
var _options$version = options.version,
|
|
8881
|
+
version = _options$version === void 0 ? exports.Version.V3 : _options$version;
|
|
8853
8882
|
return {
|
|
8854
8883
|
module: 'XcmPallet',
|
|
8855
8884
|
section: 'reserve_transfer_assets',
|
|
@@ -8864,21 +8893,21 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
8864
8893
|
}, {
|
|
8865
8894
|
key: "createApiInstance",
|
|
8866
8895
|
value: function createApiInstance(api) {
|
|
8867
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8868
|
-
return _regeneratorRuntime().wrap(function
|
|
8869
|
-
while (1) switch (
|
|
8896
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
8897
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
8898
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
8870
8899
|
case 0:
|
|
8871
|
-
return
|
|
8900
|
+
return _context2.abrupt("return", api.createApiInstance(this.getProvider()));
|
|
8872
8901
|
case 1:
|
|
8873
8902
|
case "end":
|
|
8874
|
-
return
|
|
8903
|
+
return _context2.stop();
|
|
8875
8904
|
}
|
|
8876
|
-
},
|
|
8905
|
+
}, _callee2, this);
|
|
8877
8906
|
}));
|
|
8878
8907
|
}
|
|
8879
8908
|
}, {
|
|
8880
8909
|
key: "createCurrencySpec",
|
|
8881
|
-
value: function createCurrencySpec$1(amount, scenario, version,
|
|
8910
|
+
value: function createCurrencySpec$1(amount, scenario, version, _currencyId, overridedMultiLocation) {
|
|
8882
8911
|
return createCurrencySpec(amount, version, scenario === 'ParaToRelay' ? exports.Parents.ONE : exports.Parents.ZERO, overridedMultiLocation);
|
|
8883
8912
|
}
|
|
8884
8913
|
}, {
|
|
@@ -8962,6 +8991,7 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
8962
8991
|
value: function transferXTokens(input, currencySelection) {
|
|
8963
8992
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
|
|
8964
8993
|
var api = input.api,
|
|
8994
|
+
origin = input.origin,
|
|
8965
8995
|
amount = input.amount,
|
|
8966
8996
|
addressSelection = input.addressSelection,
|
|
8967
8997
|
destination = input.destination,
|
|
@@ -8971,10 +9001,12 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
8971
9001
|
if (isMultiLocationDestination) {
|
|
8972
9002
|
throw new Error('Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.');
|
|
8973
9003
|
}
|
|
8974
|
-
var
|
|
8975
|
-
var
|
|
8976
|
-
var
|
|
8977
|
-
var
|
|
9004
|
+
var isBifrostOrigin = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
9005
|
+
var isAssetHubDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
9006
|
+
var shouldUseMultiasset = isAssetHubDest && !isBifrostOrigin;
|
|
9007
|
+
var modifiedCurrencySelection = getCurrencySelection(input, shouldUseMultiasset, currencySelection);
|
|
9008
|
+
var section = shouldUseMultiasset ? feeAsset ? 'transfer_multiassets' : 'transfer_multiasset' : 'transfer';
|
|
9009
|
+
var parameters = getXTokensParameters(shouldUseMultiasset, modifiedCurrencySelection, addressSelection, amount, fees, feeAsset);
|
|
8978
9010
|
var call = {
|
|
8979
9011
|
module: 'XTokens',
|
|
8980
9012
|
section: section,
|
|
@@ -9158,23 +9190,15 @@ var BifrostPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9158
9190
|
var amount = input.amount,
|
|
9159
9191
|
overridedCurrency = input.overridedCurrency,
|
|
9160
9192
|
currencySymbol = input.currencySymbol;
|
|
9161
|
-
|
|
9162
|
-
var ethJunction = {
|
|
9163
|
-
GlobalConsensus: {
|
|
9164
|
-
Ethereum: {
|
|
9165
|
-
chain_id: ETH_CHAIN_ID
|
|
9166
|
-
}
|
|
9167
|
-
}
|
|
9168
|
-
};
|
|
9169
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(Object.assign(Object.assign({}, input), {
|
|
9193
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(Object.assign(Object.assign({}, input), {
|
|
9170
9194
|
currencySelection: createCurrencySpec(amount, this.version, currencySymbol === 'DOT' ? exports.Parents.ONE : exports.Parents.TWO, overridedCurrency, currencySymbol === 'WETH' ? {
|
|
9171
|
-
X2: [
|
|
9195
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9172
9196
|
AccountKey20: {
|
|
9173
9197
|
key: (_a = getAssetId('Ethereum', 'WETH')) !== null && _a !== void 0 ? _a : ''
|
|
9174
9198
|
}
|
|
9175
9199
|
}]
|
|
9176
9200
|
} : undefined)
|
|
9177
|
-
}), 'transfer_assets', 'Unlimited');
|
|
9201
|
+
}), 'transfer_assets', 'Unlimited'));
|
|
9178
9202
|
}
|
|
9179
9203
|
}, {
|
|
9180
9204
|
key: "canUseXTokens",
|
|
@@ -9229,18 +9253,195 @@ var ComposableFinance$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9229
9253
|
}]);
|
|
9230
9254
|
}(ParachainNode);
|
|
9231
9255
|
|
|
9256
|
+
var calculateFee = function calculateFee(api) {
|
|
9257
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9258
|
+
var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
9259
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9260
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9261
|
+
case 0:
|
|
9262
|
+
DEFAULT_FEE = BigInt(2750872500000);
|
|
9263
|
+
_context.next = 3;
|
|
9264
|
+
return api.createApiForNode('AssetHubPolkadot');
|
|
9265
|
+
case 3:
|
|
9266
|
+
ahApi = _context.sent;
|
|
9267
|
+
_context.next = 6;
|
|
9268
|
+
return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
9269
|
+
case 6:
|
|
9270
|
+
feeStorageItem = _context.sent;
|
|
9271
|
+
leFeeHex = feeStorageItem.replace('0x', '');
|
|
9272
|
+
leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
|
|
9273
|
+
transfer_bridge_fee = leFee === BigInt(0) ? DEFAULT_FEE : BigInt(leFee.toString());
|
|
9274
|
+
transfer_assethub_execution_fee = BigInt(2200000000);
|
|
9275
|
+
return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
|
|
9276
|
+
case 12:
|
|
9277
|
+
case "end":
|
|
9278
|
+
return _context.stop();
|
|
9279
|
+
}
|
|
9280
|
+
}, _callee);
|
|
9281
|
+
}));
|
|
9282
|
+
};
|
|
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
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, versionOrDefault) {
|
|
9296
|
+
var api = _ref.api,
|
|
9297
|
+
address = _ref.address,
|
|
9298
|
+
currencyId = _ref.currencyId,
|
|
9299
|
+
scenario = _ref.scenario,
|
|
9300
|
+
ahAddress = _ref.ahAddress;
|
|
9301
|
+
return _defineProperty({}, versionOrDefault, [{
|
|
9302
|
+
SetAppendix: [{
|
|
9303
|
+
DepositAsset: {
|
|
9304
|
+
assets: {
|
|
9305
|
+
Wild: 'All'
|
|
9306
|
+
},
|
|
9307
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', versionOrDefault, undefined))[0]
|
|
9308
|
+
}
|
|
9309
|
+
}]
|
|
9310
|
+
}, {
|
|
9311
|
+
InitiateReserveWithdraw: {
|
|
9312
|
+
assets: {
|
|
9313
|
+
Wild: {
|
|
9314
|
+
AllOf: {
|
|
9315
|
+
id: createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : ''),
|
|
9316
|
+
fun: 'Fungible'
|
|
9317
|
+
}
|
|
9318
|
+
}
|
|
9319
|
+
},
|
|
9320
|
+
reserve: {
|
|
9321
|
+
parents: exports.Parents.TWO,
|
|
9322
|
+
interior: {
|
|
9323
|
+
X1: [ETHEREUM_JUNCTION]
|
|
9324
|
+
}
|
|
9325
|
+
},
|
|
9326
|
+
xcm: [{
|
|
9327
|
+
BuyExecution: {
|
|
9328
|
+
fees: {
|
|
9329
|
+
id: {
|
|
9330
|
+
parents: exports.Parents.ZERO,
|
|
9331
|
+
interior: {
|
|
9332
|
+
X1: [{
|
|
9333
|
+
AccountKey20: {
|
|
9334
|
+
network: null,
|
|
9335
|
+
key: currencyId
|
|
9336
|
+
}
|
|
9337
|
+
}]
|
|
9338
|
+
}
|
|
9339
|
+
},
|
|
9340
|
+
fun: {
|
|
9341
|
+
Fungible: BigInt(1)
|
|
9342
|
+
}
|
|
9343
|
+
},
|
|
9344
|
+
weight_limit: 'Unlimited'
|
|
9345
|
+
}
|
|
9346
|
+
}, {
|
|
9347
|
+
DepositAsset: {
|
|
9348
|
+
assets: {
|
|
9349
|
+
Wild: {
|
|
9350
|
+
AllCounted: 1
|
|
9351
|
+
}
|
|
9352
|
+
},
|
|
9353
|
+
beneficiary: {
|
|
9354
|
+
parents: exports.Parents.ZERO,
|
|
9355
|
+
interior: {
|
|
9356
|
+
X1: [{
|
|
9357
|
+
AccountKey20: {
|
|
9358
|
+
network: null,
|
|
9359
|
+
key: address
|
|
9360
|
+
}
|
|
9361
|
+
}]
|
|
9362
|
+
}
|
|
9363
|
+
}
|
|
9364
|
+
}
|
|
9365
|
+
}]
|
|
9366
|
+
}
|
|
9367
|
+
}]);
|
|
9368
|
+
};
|
|
9232
9369
|
var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
9233
9370
|
function Hydration() {
|
|
9234
9371
|
_classCallCheck(this, Hydration);
|
|
9235
9372
|
return _callSuper(this, Hydration, ['Hydration', 'hydradx', 'polkadot', exports.Version.V3]);
|
|
9236
9373
|
}
|
|
9374
|
+
// Handles WETH Ethereum transfers
|
|
9237
9375
|
_inherits(Hydration, _ParachainNode);
|
|
9238
9376
|
return _createClass(Hydration, [{
|
|
9377
|
+
key: "transferPolkadotXCM",
|
|
9378
|
+
value: function transferPolkadotXCM(input) {
|
|
9379
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
9380
|
+
var api, address, currencySymbol, scenario, version, destination, amount, currencyId, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
|
|
9381
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
9382
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
9383
|
+
case 0:
|
|
9384
|
+
api = input.api, address = input.address, currencySymbol = input.currencySymbol, scenario = input.scenario, version = input.version, destination = input.destination, amount = input.amount, currencyId = input.currencyId, ahAddress = input.ahAddress;
|
|
9385
|
+
if (ethers.ethers.isAddress(address)) {
|
|
9386
|
+
_context2.next = 3;
|
|
9387
|
+
break;
|
|
9388
|
+
}
|
|
9389
|
+
throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
|
|
9390
|
+
case 3:
|
|
9391
|
+
if (!((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) !== 'WETH')) {
|
|
9392
|
+
_context2.next = 5;
|
|
9393
|
+
break;
|
|
9394
|
+
}
|
|
9395
|
+
throw new InvalidCurrencyError("Currency ".concat(currencySymbol, " is not supported for Ethereum transfers from Hydration"));
|
|
9396
|
+
case 5:
|
|
9397
|
+
if (!(ahAddress === undefined)) {
|
|
9398
|
+
_context2.next = 7;
|
|
9399
|
+
break;
|
|
9400
|
+
}
|
|
9401
|
+
throw new Error('AssetHub address is required for Ethereum transfers');
|
|
9402
|
+
case 7:
|
|
9403
|
+
versionOrDefault = version !== null && version !== void 0 ? version : exports.Version.V4;
|
|
9404
|
+
ethMultiAsset = Object.values(createCurrencySpec(amount, versionOrDefault, exports.Parents.TWO, createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')))[0][0];
|
|
9405
|
+
_context2.next = 11;
|
|
9406
|
+
return calculateFee(api);
|
|
9407
|
+
case 11:
|
|
9408
|
+
fee = _context2.sent;
|
|
9409
|
+
call = {
|
|
9410
|
+
module: 'PolkadotXcm',
|
|
9411
|
+
section: 'transfer_assets_using_type_and_then',
|
|
9412
|
+
parameters: {
|
|
9413
|
+
dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
|
|
9414
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
|
|
9415
|
+
assets_transfer_type: 'DestinationReserve',
|
|
9416
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
9417
|
+
parents: exports.Parents.ONE,
|
|
9418
|
+
interior: 'Here'
|
|
9419
|
+
}),
|
|
9420
|
+
fees_transfer_type: 'DestinationReserve',
|
|
9421
|
+
custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
|
|
9422
|
+
weight_limit: 'Unlimited'
|
|
9423
|
+
}
|
|
9424
|
+
};
|
|
9425
|
+
return _context2.abrupt("return", api.callTxMethod(call));
|
|
9426
|
+
case 14:
|
|
9427
|
+
case "end":
|
|
9428
|
+
return _context2.stop();
|
|
9429
|
+
}
|
|
9430
|
+
}, _callee2, this);
|
|
9431
|
+
}));
|
|
9432
|
+
}
|
|
9433
|
+
}, {
|
|
9239
9434
|
key: "transferXTokens",
|
|
9240
9435
|
value: function transferXTokens(input) {
|
|
9241
9436
|
var currencyID = input.currencyID;
|
|
9242
9437
|
return XTokensTransferImpl.transferXTokens(input, currencyID);
|
|
9243
9438
|
}
|
|
9439
|
+
}, {
|
|
9440
|
+
key: "canUseXTokens",
|
|
9441
|
+
value: function canUseXTokens(_ref3) {
|
|
9442
|
+
var destination = _ref3.destination;
|
|
9443
|
+
return destination !== 'Ethereum';
|
|
9444
|
+
}
|
|
9244
9445
|
}]);
|
|
9245
9446
|
}(ParachainNode);
|
|
9246
9447
|
|
|
@@ -9711,21 +9912,13 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9711
9912
|
if (!ethAsset) {
|
|
9712
9913
|
throw new InvalidCurrencyError("Currency ".concat(currencySymbol, " is not supported for Ethereum transfers"));
|
|
9713
9914
|
}
|
|
9714
|
-
var ETH_CHAIN_ID = BigInt(1);
|
|
9715
|
-
var ethJunction = {
|
|
9716
|
-
GlobalConsensus: {
|
|
9717
|
-
Ethereum: {
|
|
9718
|
-
chain_id: ETH_CHAIN_ID
|
|
9719
|
-
}
|
|
9720
|
-
}
|
|
9721
|
-
};
|
|
9722
9915
|
var modifiedInput = Object.assign(Object.assign({}, input), {
|
|
9723
|
-
header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo,
|
|
9916
|
+
header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, exports.Parents.TWO),
|
|
9724
9917
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraIdTo),
|
|
9725
9918
|
currencySelection: createCurrencySpec(input.amount, exports.Version.V3, exports.Parents.TWO, {
|
|
9726
9919
|
parents: exports.Parents.TWO,
|
|
9727
9920
|
interior: {
|
|
9728
|
-
X2: [
|
|
9921
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9729
9922
|
AccountKey20: {
|
|
9730
9923
|
key: ethAsset.assetId
|
|
9731
9924
|
}
|
|
@@ -9766,17 +9959,18 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9766
9959
|
}, {
|
|
9767
9960
|
key: "transferPolkadotXCM",
|
|
9768
9961
|
value: function transferPolkadotXCM(input) {
|
|
9962
|
+
var _a;
|
|
9769
9963
|
var scenario = input.scenario,
|
|
9770
9964
|
currencySymbol = input.currencySymbol,
|
|
9771
9965
|
currencyId = input.currencyId;
|
|
9772
9966
|
if (input.destination === 'AssetHubKusama') {
|
|
9773
|
-
return this.handleBridgeTransfer(input, 'Kusama');
|
|
9967
|
+
return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
|
|
9774
9968
|
}
|
|
9775
9969
|
if (input.destination === 'Ethereum') {
|
|
9776
|
-
return this.handleEthBridgeTransfer(input);
|
|
9970
|
+
return Promise.resolve(this.handleEthBridgeTransfer(input));
|
|
9777
9971
|
}
|
|
9778
9972
|
if (input.destination === 'Mythos') {
|
|
9779
|
-
return this.handleMythosTransfer(input);
|
|
9973
|
+
return Promise.resolve(this.handleMythosTransfer(input));
|
|
9780
9974
|
}
|
|
9781
9975
|
if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined) {
|
|
9782
9976
|
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.');
|
|
@@ -9785,7 +9979,19 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9785
9979
|
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>}.');
|
|
9786
9980
|
}
|
|
9787
9981
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9788
|
-
|
|
9982
|
+
var api = input.api,
|
|
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;
|
|
9994
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
|
|
9789
9995
|
}
|
|
9790
9996
|
}, {
|
|
9791
9997
|
key: "transferRelayToPara",
|
|
@@ -9834,7 +10040,7 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9834
10040
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
|
|
9835
10041
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
|
|
9836
10042
|
if (destination === 'AssetHubPolkadot') {
|
|
9837
|
-
return getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
|
|
10043
|
+
return Promise.resolve(getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot'));
|
|
9838
10044
|
}
|
|
9839
10045
|
if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
|
|
9840
10046
|
throw new ScenarioNotSupportedError(this.node, scenario, 'Para to Para scenarios for KSM transfer from AssetHub are not supported, you have to transfer KSM to Relay chain and transfer to destination chain from Relay chain.');
|
|
@@ -9843,7 +10049,7 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9843
10049
|
throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
|
|
9844
10050
|
}
|
|
9845
10051
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9846
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10052
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
9847
10053
|
}
|
|
9848
10054
|
}, {
|
|
9849
10055
|
key: "transferRelayToPara",
|
|
@@ -9879,7 +10085,7 @@ var CoretimeKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9879
10085
|
// TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
|
|
9880
10086
|
var scenario = input.scenario;
|
|
9881
10087
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9882
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10088
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
9883
10089
|
}
|
|
9884
10090
|
}, {
|
|
9885
10091
|
key: "transferRelayToPara",
|
|
@@ -9911,7 +10117,7 @@ var CoretimePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9911
10117
|
value: function transferPolkadotXCM(input) {
|
|
9912
10118
|
var scenario = input.scenario;
|
|
9913
10119
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9914
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10120
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
9915
10121
|
}
|
|
9916
10122
|
}, {
|
|
9917
10123
|
key: "transferRelayToPara",
|
|
@@ -9939,7 +10145,7 @@ var Encointer$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9939
10145
|
// NO PARA TO PARA SCENARIOS ON SUBSCAN
|
|
9940
10146
|
// TESTED https://encointer.subscan.io/xcm_message/kusama-418501e86e947b16c4e4e9040694017e64f9b162
|
|
9941
10147
|
if (input.scenario === 'ParaToRelay') {
|
|
9942
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited');
|
|
10148
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
|
|
9943
10149
|
}
|
|
9944
10150
|
throw new ScenarioNotSupportedError(this.node, input.scenario);
|
|
9945
10151
|
}
|
|
@@ -9966,7 +10172,7 @@ var RobonomicsKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9966
10172
|
return _createClass(RobonomicsKusama, [{
|
|
9967
10173
|
key: "transferPolkadotXCM",
|
|
9968
10174
|
value: function transferPolkadotXCM(input) {
|
|
9969
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10175
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
9970
10176
|
}
|
|
9971
10177
|
}]);
|
|
9972
10178
|
}(ParachainNode);
|
|
@@ -9980,7 +10186,7 @@ var RobonomicsPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9980
10186
|
return _createClass(RobonomicsPolkadot, [{
|
|
9981
10187
|
key: "transferPolkadotXCM",
|
|
9982
10188
|
value: function transferPolkadotXCM(input) {
|
|
9983
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10189
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
9984
10190
|
}
|
|
9985
10191
|
}]);
|
|
9986
10192
|
}(ParachainNode);
|
|
@@ -9999,7 +10205,7 @@ var PeoplePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9999
10205
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
10000
10206
|
}
|
|
10001
10207
|
var section = 'limited_teleport_assets';
|
|
10002
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10208
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10003
10209
|
}
|
|
10004
10210
|
}, {
|
|
10005
10211
|
key: "transferRelayToPara",
|
|
@@ -10029,7 +10235,7 @@ var PeopleKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10029
10235
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
10030
10236
|
}
|
|
10031
10237
|
var section = 'limited_teleport_assets';
|
|
10032
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10238
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10033
10239
|
}
|
|
10034
10240
|
}, {
|
|
10035
10241
|
key: "transferRelayToPara",
|
|
@@ -10056,7 +10262,7 @@ var Astar$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10056
10262
|
value: function transferPolkadotXCM(input) {
|
|
10057
10263
|
// TESTED https://polkadot.subscan.io/xcm_message/polkadot-f2b697df74ebe4b62853fe81b8b7d0522464972d
|
|
10058
10264
|
var section = input.scenario === 'ParaToPara' ? 'reserve_transfer_assets' : 'reserve_withdraw_assets';
|
|
10059
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section);
|
|
10265
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section));
|
|
10060
10266
|
}
|
|
10061
10267
|
}, {
|
|
10062
10268
|
key: "transferXTokens",
|
|
@@ -10128,7 +10334,7 @@ var Crab$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10128
10334
|
value: function transferPolkadotXCM(input) {
|
|
10129
10335
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-ce7396ec470ba0c6516a50075046ee65464572dc
|
|
10130
10336
|
if (input.scenario === 'ParaToPara') {
|
|
10131
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets');
|
|
10337
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
|
|
10132
10338
|
}
|
|
10133
10339
|
throw new ScenarioNotSupportedError(this.node, input.scenario);
|
|
10134
10340
|
}
|
|
@@ -10243,7 +10449,7 @@ var NeuroWeb$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10243
10449
|
return _createClass(NeuroWeb, [{
|
|
10244
10450
|
key: "transferPolkadotXCM",
|
|
10245
10451
|
value: function transferPolkadotXCM(input) {
|
|
10246
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10452
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
10247
10453
|
}
|
|
10248
10454
|
}]);
|
|
10249
10455
|
}(ParachainNode);
|
|
@@ -10321,7 +10527,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10321
10527
|
if (scenario === 'ParaToPara') {
|
|
10322
10528
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
10323
10529
|
}
|
|
10324
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited');
|
|
10530
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
|
|
10325
10531
|
}
|
|
10326
10532
|
}, {
|
|
10327
10533
|
key: "transferRelayToPara",
|
|
@@ -10483,7 +10689,7 @@ var Subsocial$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10483
10689
|
if (currencySymbol !== this.getNativeAssetSymbol()) {
|
|
10484
10690
|
throw new InvalidCurrencyError("Asset ".concat(currencySymbol, " is not supported by node ").concat(this.node, "."));
|
|
10485
10691
|
}
|
|
10486
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10692
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
10487
10693
|
}
|
|
10488
10694
|
}]);
|
|
10489
10695
|
}(ParachainNode);
|
|
@@ -10500,7 +10706,7 @@ var KiltSpiritnet$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10500
10706
|
if (input.scenario !== 'ParaToPara') {
|
|
10501
10707
|
throw new ScenarioNotSupportedError(this.node, input.scenario);
|
|
10502
10708
|
}
|
|
10503
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets');
|
|
10709
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
|
|
10504
10710
|
}
|
|
10505
10711
|
}, {
|
|
10506
10712
|
key: "transferRelayToPara",
|
|
@@ -10554,7 +10760,7 @@ var BridgeHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10554
10760
|
throw new ScenarioNotSupportedError(this.node, scenario, 'Unable to use bridge hub for transfers to other Parachains. Please move your currency to AssetHub to transfer to other Parachains.');
|
|
10555
10761
|
}
|
|
10556
10762
|
var section = 'limited_teleport_assets';
|
|
10557
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10763
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10558
10764
|
}
|
|
10559
10765
|
}, {
|
|
10560
10766
|
key: "transferRelayToPara",
|
|
@@ -10587,7 +10793,7 @@ var BridgeHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10587
10793
|
throw new ScenarioNotSupportedError(this.node, scenario, 'Unable to use bridge hub for transfers to other Parachains. Please move your currency to AssetHub to transfer to other Parachains.');
|
|
10588
10794
|
}
|
|
10589
10795
|
var section = 'limited_teleport_assets';
|
|
10590
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10796
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10591
10797
|
}
|
|
10592
10798
|
}, {
|
|
10593
10799
|
key: "transferRelayToPara",
|
|
@@ -10631,7 +10837,7 @@ var Mythos$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10631
10837
|
if (currencySymbol !== nativeSymbol) {
|
|
10632
10838
|
throw new InvalidCurrencyError("Node ".concat(this.node, " does not support currency ").concat(currencySymbol));
|
|
10633
10839
|
}
|
|
10634
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10840
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
10635
10841
|
}
|
|
10636
10842
|
}, {
|
|
10637
10843
|
key: "transferRelayToPara",
|
|
@@ -12283,8 +12489,9 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
|
|
|
12283
12489
|
*/
|
|
12284
12490
|
}, {
|
|
12285
12491
|
key: "address",
|
|
12286
|
-
value: function address(_address) {
|
|
12492
|
+
value: function address(_address, ahAddress) {
|
|
12287
12493
|
this._address = _address;
|
|
12494
|
+
this._ahAddress = ahAddress;
|
|
12288
12495
|
return this;
|
|
12289
12496
|
}
|
|
12290
12497
|
/**
|
|
@@ -12324,7 +12531,8 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
|
|
|
12324
12531
|
paraIdTo: this.paraIdTo,
|
|
12325
12532
|
feeAsset: this._feeAsset,
|
|
12326
12533
|
destApiForKeepAlive: this._destApi,
|
|
12327
|
-
version: this._version
|
|
12534
|
+
version: this._version,
|
|
12535
|
+
ahAddress: this._ahAddress
|
|
12328
12536
|
};
|
|
12329
12537
|
}
|
|
12330
12538
|
/**
|
|
@@ -13399,7 +13607,8 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
13399
13607
|
});
|
|
13400
13608
|
return [].concat(_toConsumableArray(polkadotAsset ? [polkadotAsset] : []), _toConsumableArray(kusamaAsset ? [kusamaAsset] : []));
|
|
13401
13609
|
}
|
|
13402
|
-
|
|
13610
|
+
var isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
13611
|
+
if (!isRelayChain(origin) && getDefaultPallet(origin) === 'XTokens' && (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama') && !isBifrost) {
|
|
13403
13612
|
return getOtherAssets(destination).filter(function (asset) {
|
|
13404
13613
|
return originAssets.some(function (a) {
|
|
13405
13614
|
return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
|
|
@@ -13556,11 +13765,11 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13556
13765
|
return __awaiter(void 0, [options_1].concat(args_1), void 0, function (options) {
|
|
13557
13766
|
var serializedApiCallEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
13558
13767
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13559
|
-
var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet,
|
|
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;
|
|
13560
13769
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13561
13770
|
while (1) switch (_context.prev = _context.next) {
|
|
13562
13771
|
case 0:
|
|
13563
|
-
api = options.api, origin = options.origin, currency = options.currency, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, feeAsset = options.feeAsset, version = options.version;
|
|
13772
|
+
api = options.api, origin = options.origin, currency = options.currency, amount = options.amount, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, destApiForKeepAlive = options.destApiForKeepAlive, feeAsset = options.feeAsset, version = options.version, ahAddress = options.ahAddress;
|
|
13564
13773
|
if (!((!('multiasset' in currency) || 'multilocation' in currency) && amount === null)) {
|
|
13565
13774
|
_context.next = 3;
|
|
13566
13775
|
break;
|
|
@@ -13610,11 +13819,11 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13610
13819
|
}
|
|
13611
13820
|
throw new InvalidCurrencyError('Fee asset index is out of bounds. Please provide a valid index.');
|
|
13612
13821
|
case 17:
|
|
13613
|
-
if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot')) {
|
|
13822
|
+
if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration')) {
|
|
13614
13823
|
_context.next = 19;
|
|
13615
13824
|
break;
|
|
13616
13825
|
}
|
|
13617
|
-
throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot.');
|
|
13826
|
+
throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
|
|
13618
13827
|
case 19:
|
|
13619
13828
|
isMultiLocationDestination = _typeof(destination) === 'object';
|
|
13620
13829
|
isBridge = origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
|
|
@@ -13635,90 +13844,85 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13635
13844
|
assetCheckEnabled = 'multilocation' in currency || 'multiasset' in currency || isBridge ? false : originNode.assetCheckEnabled;
|
|
13636
13845
|
isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
13637
13846
|
pallet = getDefaultPallet(origin);
|
|
13638
|
-
|
|
13639
|
-
|
|
13847
|
+
isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
13848
|
+
if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
|
|
13849
|
+
_context.next = 42;
|
|
13640
13850
|
break;
|
|
13641
13851
|
}
|
|
13642
13852
|
asset = getAssetBySymbolOrId(destination, currency, false, destination);
|
|
13643
|
-
|
|
13644
|
-
if (origin === 'BifrostPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
|
|
13645
|
-
nativeAssets = nativeAssets.filter(function (nativeAsset) {
|
|
13646
|
-
return nativeAsset.symbol !== 'DOT';
|
|
13647
|
-
});
|
|
13648
|
-
}
|
|
13649
|
-
if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
|
|
13853
|
+
if (!('symbol' in currency && getNativeAssets(destination).some(function (nativeAsset) {
|
|
13650
13854
|
return nativeAsset.symbol.toLowerCase() === currency.symbol.toLowerCase();
|
|
13651
13855
|
}))) {
|
|
13652
|
-
_context.next =
|
|
13856
|
+
_context.next = 36;
|
|
13653
13857
|
break;
|
|
13654
13858
|
}
|
|
13655
13859
|
throw new InvalidCurrencyError("".concat(currency.symbol, " is not supported for transfers to ").concat(destination, "."));
|
|
13656
|
-
case
|
|
13860
|
+
case 36:
|
|
13657
13861
|
if (!(assetCheckEnabled && asset === null)) {
|
|
13658
|
-
_context.next =
|
|
13862
|
+
_context.next = 38;
|
|
13659
13863
|
break;
|
|
13660
13864
|
}
|
|
13661
13865
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13662
|
-
case
|
|
13866
|
+
case 38:
|
|
13663
13867
|
if (!((asset === null || asset === void 0 ? void 0 : asset.symbol) && !hasSupportForAsset(origin, asset.symbol))) {
|
|
13664
|
-
_context.next =
|
|
13868
|
+
_context.next = 40;
|
|
13665
13869
|
break;
|
|
13666
13870
|
}
|
|
13667
13871
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(asset.symbol, "."));
|
|
13668
|
-
case
|
|
13669
|
-
_context.next =
|
|
13872
|
+
case 40:
|
|
13873
|
+
_context.next = 47;
|
|
13670
13874
|
break;
|
|
13671
|
-
case
|
|
13875
|
+
case 42:
|
|
13672
13876
|
asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination, isTMultiLocation(destination) ? undefined : destination) : null;
|
|
13673
13877
|
if (!(!isBridge && asset === null && assetCheckEnabled)) {
|
|
13674
|
-
_context.next =
|
|
13878
|
+
_context.next = 45;
|
|
13675
13879
|
break;
|
|
13676
13880
|
}
|
|
13677
13881
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13678
|
-
case
|
|
13882
|
+
case 45:
|
|
13679
13883
|
if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
|
|
13680
|
-
_context.next =
|
|
13884
|
+
_context.next = 47;
|
|
13681
13885
|
break;
|
|
13682
13886
|
}
|
|
13683
13887
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13684
|
-
case
|
|
13685
|
-
_context.next =
|
|
13888
|
+
case 47:
|
|
13889
|
+
_context.next = 49;
|
|
13686
13890
|
return api.init(origin);
|
|
13687
|
-
case
|
|
13891
|
+
case 49:
|
|
13688
13892
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
13689
13893
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
13690
|
-
_context.next =
|
|
13894
|
+
_context.next = 54;
|
|
13691
13895
|
break;
|
|
13692
13896
|
}
|
|
13693
13897
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
13694
|
-
_context.next =
|
|
13898
|
+
_context.next = 68;
|
|
13695
13899
|
break;
|
|
13696
|
-
case
|
|
13900
|
+
case 54:
|
|
13697
13901
|
if (!(_typeof(address) === 'object')) {
|
|
13698
|
-
_context.next =
|
|
13902
|
+
_context.next = 58;
|
|
13699
13903
|
break;
|
|
13700
13904
|
}
|
|
13701
13905
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
13702
|
-
_context.next =
|
|
13906
|
+
_context.next = 68;
|
|
13703
13907
|
break;
|
|
13704
|
-
case
|
|
13908
|
+
case 58:
|
|
13705
13909
|
if (!(_typeof(destination) === 'object')) {
|
|
13706
|
-
_context.next =
|
|
13910
|
+
_context.next = 62;
|
|
13707
13911
|
break;
|
|
13708
13912
|
}
|
|
13709
13913
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
13710
|
-
_context.next =
|
|
13914
|
+
_context.next = 68;
|
|
13711
13915
|
break;
|
|
13712
|
-
case
|
|
13916
|
+
case 62:
|
|
13713
13917
|
if (!(origin === 'Ethereum' || destination === 'Ethereum')) {
|
|
13714
|
-
_context.next =
|
|
13918
|
+
_context.next = 66;
|
|
13715
13919
|
break;
|
|
13716
13920
|
}
|
|
13717
13921
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
13718
|
-
_context.next =
|
|
13922
|
+
_context.next = 68;
|
|
13719
13923
|
break;
|
|
13720
|
-
case
|
|
13721
|
-
_context.next =
|
|
13924
|
+
case 66:
|
|
13925
|
+
_context.next = 68;
|
|
13722
13926
|
return checkKeepAlive({
|
|
13723
13927
|
originApi: api,
|
|
13724
13928
|
address: address,
|
|
@@ -13728,7 +13932,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13728
13932
|
currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : 'symbol' in currency ? currency.symbol : undefined,
|
|
13729
13933
|
destNode: destination
|
|
13730
13934
|
});
|
|
13731
|
-
case
|
|
13935
|
+
case 68:
|
|
13732
13936
|
currencyStr = 'symbol' in currency ? currency.symbol : 'id' in currency ? currency.id.toString() : undefined;
|
|
13733
13937
|
return _context.abrupt("return", originNode.transfer({
|
|
13734
13938
|
api: api,
|
|
@@ -13742,9 +13946,10 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13742
13946
|
feeAsset: feeAsset,
|
|
13743
13947
|
version: version,
|
|
13744
13948
|
destApiForKeepAlive: destApiForKeepAlive,
|
|
13745
|
-
serializedApiCallEnabled: serializedApiCallEnabled
|
|
13949
|
+
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
13950
|
+
ahAddress: ahAddress
|
|
13746
13951
|
}));
|
|
13747
|
-
case
|
|
13952
|
+
case 70:
|
|
13748
13953
|
case "end":
|
|
13749
13954
|
return _context.stop();
|
|
13750
13955
|
}
|
|
@@ -14118,21 +14323,32 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
14118
14323
|
}
|
|
14119
14324
|
throw new NodeNotSupportedError("The node ".concat(node, " is not yet supported by the Polkadot API."));
|
|
14120
14325
|
case 2:
|
|
14326
|
+
if (!(typeof this._api === 'string')) {
|
|
14327
|
+
_context.next = 8;
|
|
14328
|
+
break;
|
|
14329
|
+
}
|
|
14330
|
+
_context.next = 5;
|
|
14331
|
+
return this.createApiInstance(this._api);
|
|
14332
|
+
case 5:
|
|
14333
|
+
this.api = _context.sent;
|
|
14334
|
+
_context.next = 16;
|
|
14335
|
+
break;
|
|
14336
|
+
case 8:
|
|
14121
14337
|
if (!((_a = this._api) !== null && _a !== void 0)) {
|
|
14122
|
-
_context.next =
|
|
14338
|
+
_context.next = 12;
|
|
14123
14339
|
break;
|
|
14124
14340
|
}
|
|
14125
14341
|
_context.t0 = _a;
|
|
14126
|
-
_context.next =
|
|
14342
|
+
_context.next = 15;
|
|
14127
14343
|
break;
|
|
14128
|
-
case
|
|
14129
|
-
_context.next =
|
|
14344
|
+
case 12:
|
|
14345
|
+
_context.next = 14;
|
|
14130
14346
|
return createApiInstanceForNode$1(this, node);
|
|
14131
|
-
case
|
|
14347
|
+
case 14:
|
|
14132
14348
|
_context.t0 = _context.sent;
|
|
14133
|
-
case
|
|
14349
|
+
case 15:
|
|
14134
14350
|
this.api = _context.t0;
|
|
14135
|
-
case
|
|
14351
|
+
case 16:
|
|
14136
14352
|
case "end":
|
|
14137
14353
|
return _context.stop();
|
|
14138
14354
|
}
|
|
@@ -14343,11 +14559,49 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
14343
14559
|
}, _callee9, this);
|
|
14344
14560
|
}));
|
|
14345
14561
|
}
|
|
14562
|
+
}, {
|
|
14563
|
+
key: "getFromStorage",
|
|
14564
|
+
value: function getFromStorage(key) {
|
|
14565
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
14566
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
14567
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
14568
|
+
case 0:
|
|
14569
|
+
_context10.next = 2;
|
|
14570
|
+
return this.api._request('state_getStorage', [key]);
|
|
14571
|
+
case 2:
|
|
14572
|
+
return _context10.abrupt("return", _context10.sent);
|
|
14573
|
+
case 3:
|
|
14574
|
+
case "end":
|
|
14575
|
+
return _context10.stop();
|
|
14576
|
+
}
|
|
14577
|
+
}, _callee10, this);
|
|
14578
|
+
}));
|
|
14579
|
+
}
|
|
14346
14580
|
}, {
|
|
14347
14581
|
key: "clone",
|
|
14348
14582
|
value: function clone() {
|
|
14349
14583
|
return new PapiApi();
|
|
14350
14584
|
}
|
|
14585
|
+
}, {
|
|
14586
|
+
key: "createApiForNode",
|
|
14587
|
+
value: function createApiForNode(node) {
|
|
14588
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
14589
|
+
var api;
|
|
14590
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
14591
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
14592
|
+
case 0:
|
|
14593
|
+
api = new PapiApi();
|
|
14594
|
+
_context11.next = 3;
|
|
14595
|
+
return api.init(node);
|
|
14596
|
+
case 3:
|
|
14597
|
+
return _context11.abrupt("return", api);
|
|
14598
|
+
case 4:
|
|
14599
|
+
case "end":
|
|
14600
|
+
return _context11.stop();
|
|
14601
|
+
}
|
|
14602
|
+
}, _callee11);
|
|
14603
|
+
}));
|
|
14604
|
+
}
|
|
14351
14605
|
}]);
|
|
14352
14606
|
}();
|
|
14353
14607
|
|