@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.mjs
CHANGED
|
@@ -504,11 +504,11 @@ function _toPrimitive(t, r) {
|
|
|
504
504
|
if ("object" != typeof t || !t) return t;
|
|
505
505
|
var e = t[Symbol.toPrimitive];
|
|
506
506
|
if (void 0 !== e) {
|
|
507
|
-
var i = e.call(t, r);
|
|
507
|
+
var i = e.call(t, r || "default");
|
|
508
508
|
if ("object" != typeof i) return i;
|
|
509
509
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
510
510
|
}
|
|
511
|
-
return (String )(t);
|
|
511
|
+
return ("string" === r ? String : Number)(t);
|
|
512
512
|
}
|
|
513
513
|
function _toPropertyKey(t) {
|
|
514
514
|
var i = _toPrimitive(t, "string");
|
|
@@ -8615,6 +8615,14 @@ var findParachainJunction = function findParachainJunction(multilocation) {
|
|
|
8615
8615
|
};
|
|
8616
8616
|
|
|
8617
8617
|
var DEFAULT_FEE_ASSET = 0;
|
|
8618
|
+
var ETH_CHAIN_ID = BigInt(1);
|
|
8619
|
+
var ETHEREUM_JUNCTION = {
|
|
8620
|
+
GlobalConsensus: {
|
|
8621
|
+
Ethereum: {
|
|
8622
|
+
chain_id: ETH_CHAIN_ID
|
|
8623
|
+
}
|
|
8624
|
+
}
|
|
8625
|
+
};
|
|
8618
8626
|
|
|
8619
8627
|
var constructRelayToParaParameters = function constructRelayToParaParameters(_ref, version) {
|
|
8620
8628
|
var api = _ref.api,
|
|
@@ -8772,82 +8780,103 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
8772
8780
|
}, {
|
|
8773
8781
|
key: "transfer",
|
|
8774
8782
|
value: function transfer(options) {
|
|
8775
|
-
|
|
8776
|
-
|
|
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
|
-
|
|
8783
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8784
|
+
var api, currencySymbol, currencyId, amount, address, destination, paraIdTo, overridedCurrencyMultiLocation, feeAsset, version, ahAddress, _options$serializedAp, serializedApiCallEnabled, scenario, paraId, versionOrDefault;
|
|
8785
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8786
|
+
while (1) switch (_context.prev = _context.next) {
|
|
8787
|
+
case 0:
|
|
8788
|
+
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;
|
|
8789
|
+
scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
|
|
8790
|
+
paraId = destination !== undefined && _typeof(destination) !== 'object' && destination !== 'Ethereum' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
8791
|
+
if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot')) {
|
|
8792
|
+
_context.next = 5;
|
|
8793
|
+
break;
|
|
8794
|
+
}
|
|
8795
|
+
throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
|
|
8796
|
+
case 5:
|
|
8797
|
+
versionOrDefault = version !== null && version !== void 0 ? version : this.version;
|
|
8798
|
+
if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
|
|
8799
|
+
_context.next = 10;
|
|
8800
|
+
break;
|
|
8801
|
+
}
|
|
8802
|
+
return _context.abrupt("return", this.transferXTokens({
|
|
8803
|
+
api: api,
|
|
8804
|
+
currency: currencySymbol,
|
|
8805
|
+
currencyID: currencyId,
|
|
8806
|
+
amount: amount,
|
|
8807
|
+
addressSelection: generateAddressPayload(api, scenario, 'XTokens', address, versionOrDefault, paraId),
|
|
8808
|
+
fees: getFees(scenario),
|
|
8809
|
+
origin: this.node,
|
|
8810
|
+
scenario: scenario,
|
|
8811
|
+
paraIdTo: paraId,
|
|
8812
|
+
destination: destination,
|
|
8813
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
8814
|
+
feeAsset: feeAsset,
|
|
8815
|
+
serializedApiCallEnabled: serializedApiCallEnabled
|
|
8816
|
+
}));
|
|
8817
|
+
case 10:
|
|
8818
|
+
if (!supportsXTransfer(this)) {
|
|
8819
|
+
_context.next = 14;
|
|
8820
|
+
break;
|
|
8821
|
+
}
|
|
8822
|
+
return _context.abrupt("return", this.transferXTransfer({
|
|
8823
|
+
api: api,
|
|
8824
|
+
currency: currencySymbol,
|
|
8825
|
+
currencyID: currencyId,
|
|
8826
|
+
amount: amount,
|
|
8827
|
+
recipientAddress: address,
|
|
8828
|
+
paraId: paraId,
|
|
8829
|
+
origin: this.node,
|
|
8830
|
+
destination: destination,
|
|
8831
|
+
overridedCurrencyMultiLocation: overridedCurrencyMultiLocation,
|
|
8832
|
+
serializedApiCallEnabled: serializedApiCallEnabled
|
|
8833
|
+
}));
|
|
8834
|
+
case 14:
|
|
8835
|
+
if (!supportsPolkadotXCM(this)) {
|
|
8836
|
+
_context.next = 22;
|
|
8837
|
+
break;
|
|
8838
|
+
}
|
|
8839
|
+
if (!(isTMultiLocation(overridedCurrencyMultiLocation) && !verifyMultiLocation(this.node, overridedCurrencyMultiLocation))) {
|
|
8840
|
+
_context.next = 17;
|
|
8841
|
+
break;
|
|
8842
|
+
}
|
|
8843
|
+
throw new InvalidCurrencyError('Provided Multi-location is not a valid currency.');
|
|
8844
|
+
case 17:
|
|
8845
|
+
_context.next = 19;
|
|
8846
|
+
return this.transferPolkadotXCM({
|
|
8847
|
+
api: api,
|
|
8848
|
+
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraId),
|
|
8849
|
+
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraId),
|
|
8850
|
+
address: address,
|
|
8851
|
+
amount: amount,
|
|
8852
|
+
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrencyMultiLocation),
|
|
8853
|
+
currencyId: currencyId,
|
|
8854
|
+
scenario: scenario,
|
|
8855
|
+
currencySymbol: currencySymbol,
|
|
8856
|
+
feeAsset: feeAsset,
|
|
8857
|
+
destination: destination,
|
|
8858
|
+
paraIdTo: paraId,
|
|
8859
|
+
overridedCurrency: overridedCurrencyMultiLocation,
|
|
8860
|
+
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
8861
|
+
version: version,
|
|
8862
|
+
ahAddress: ahAddress
|
|
8863
|
+
});
|
|
8864
|
+
case 19:
|
|
8865
|
+
return _context.abrupt("return", _context.sent);
|
|
8866
|
+
case 22:
|
|
8867
|
+
throw new NoXCMSupportImplementedError(this._node);
|
|
8868
|
+
case 23:
|
|
8869
|
+
case "end":
|
|
8870
|
+
return _context.stop();
|
|
8871
|
+
}
|
|
8872
|
+
}, _callee, this);
|
|
8873
|
+
}));
|
|
8845
8874
|
}
|
|
8846
8875
|
}, {
|
|
8847
8876
|
key: "transferRelayToPara",
|
|
8848
8877
|
value: function transferRelayToPara(options) {
|
|
8849
|
-
var _options$
|
|
8850
|
-
version = _options$
|
|
8878
|
+
var _options$version = options.version,
|
|
8879
|
+
version = _options$version === void 0 ? Version.V3 : _options$version;
|
|
8851
8880
|
return {
|
|
8852
8881
|
module: 'XcmPallet',
|
|
8853
8882
|
section: 'reserve_transfer_assets',
|
|
@@ -8862,21 +8891,21 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
8862
8891
|
}, {
|
|
8863
8892
|
key: "createApiInstance",
|
|
8864
8893
|
value: function createApiInstance(api) {
|
|
8865
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8866
|
-
return _regeneratorRuntime().wrap(function
|
|
8867
|
-
while (1) switch (
|
|
8894
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
8895
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
8896
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
8868
8897
|
case 0:
|
|
8869
|
-
return
|
|
8898
|
+
return _context2.abrupt("return", api.createApiInstance(this.getProvider()));
|
|
8870
8899
|
case 1:
|
|
8871
8900
|
case "end":
|
|
8872
|
-
return
|
|
8901
|
+
return _context2.stop();
|
|
8873
8902
|
}
|
|
8874
|
-
},
|
|
8903
|
+
}, _callee2, this);
|
|
8875
8904
|
}));
|
|
8876
8905
|
}
|
|
8877
8906
|
}, {
|
|
8878
8907
|
key: "createCurrencySpec",
|
|
8879
|
-
value: function createCurrencySpec$1(amount, scenario, version,
|
|
8908
|
+
value: function createCurrencySpec$1(amount, scenario, version, _currencyId, overridedMultiLocation) {
|
|
8880
8909
|
return createCurrencySpec(amount, version, scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO, overridedMultiLocation);
|
|
8881
8910
|
}
|
|
8882
8911
|
}, {
|
|
@@ -8960,6 +8989,7 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
8960
8989
|
value: function transferXTokens(input, currencySelection) {
|
|
8961
8990
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
|
|
8962
8991
|
var api = input.api,
|
|
8992
|
+
origin = input.origin,
|
|
8963
8993
|
amount = input.amount,
|
|
8964
8994
|
addressSelection = input.addressSelection,
|
|
8965
8995
|
destination = input.destination,
|
|
@@ -8969,10 +8999,12 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
8969
8999
|
if (isMultiLocationDestination) {
|
|
8970
9000
|
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.');
|
|
8971
9001
|
}
|
|
8972
|
-
var
|
|
8973
|
-
var
|
|
8974
|
-
var
|
|
8975
|
-
var
|
|
9002
|
+
var isBifrostOrigin = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
9003
|
+
var isAssetHubDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
9004
|
+
var shouldUseMultiasset = isAssetHubDest && !isBifrostOrigin;
|
|
9005
|
+
var modifiedCurrencySelection = getCurrencySelection(input, shouldUseMultiasset, currencySelection);
|
|
9006
|
+
var section = shouldUseMultiasset ? feeAsset ? 'transfer_multiassets' : 'transfer_multiasset' : 'transfer';
|
|
9007
|
+
var parameters = getXTokensParameters(shouldUseMultiasset, modifiedCurrencySelection, addressSelection, amount, fees, feeAsset);
|
|
8976
9008
|
var call = {
|
|
8977
9009
|
module: 'XTokens',
|
|
8978
9010
|
section: section,
|
|
@@ -9156,23 +9188,15 @@ var BifrostPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9156
9188
|
var amount = input.amount,
|
|
9157
9189
|
overridedCurrency = input.overridedCurrency,
|
|
9158
9190
|
currencySymbol = input.currencySymbol;
|
|
9159
|
-
|
|
9160
|
-
var ethJunction = {
|
|
9161
|
-
GlobalConsensus: {
|
|
9162
|
-
Ethereum: {
|
|
9163
|
-
chain_id: ETH_CHAIN_ID
|
|
9164
|
-
}
|
|
9165
|
-
}
|
|
9166
|
-
};
|
|
9167
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(Object.assign(Object.assign({}, input), {
|
|
9191
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(Object.assign(Object.assign({}, input), {
|
|
9168
9192
|
currencySelection: createCurrencySpec(amount, this.version, currencySymbol === 'DOT' ? Parents.ONE : Parents.TWO, overridedCurrency, currencySymbol === 'WETH' ? {
|
|
9169
|
-
X2: [
|
|
9193
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9170
9194
|
AccountKey20: {
|
|
9171
9195
|
key: (_a = getAssetId('Ethereum', 'WETH')) !== null && _a !== void 0 ? _a : ''
|
|
9172
9196
|
}
|
|
9173
9197
|
}]
|
|
9174
9198
|
} : undefined)
|
|
9175
|
-
}), 'transfer_assets', 'Unlimited');
|
|
9199
|
+
}), 'transfer_assets', 'Unlimited'));
|
|
9176
9200
|
}
|
|
9177
9201
|
}, {
|
|
9178
9202
|
key: "canUseXTokens",
|
|
@@ -9227,18 +9251,195 @@ var ComposableFinance$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9227
9251
|
}]);
|
|
9228
9252
|
}(ParachainNode);
|
|
9229
9253
|
|
|
9254
|
+
var calculateFee = function calculateFee(api) {
|
|
9255
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9256
|
+
var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
9257
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9258
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9259
|
+
case 0:
|
|
9260
|
+
DEFAULT_FEE = BigInt(2750872500000);
|
|
9261
|
+
_context.next = 3;
|
|
9262
|
+
return api.createApiForNode('AssetHubPolkadot');
|
|
9263
|
+
case 3:
|
|
9264
|
+
ahApi = _context.sent;
|
|
9265
|
+
_context.next = 6;
|
|
9266
|
+
return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
9267
|
+
case 6:
|
|
9268
|
+
feeStorageItem = _context.sent;
|
|
9269
|
+
leFeeHex = feeStorageItem.replace('0x', '');
|
|
9270
|
+
leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
|
|
9271
|
+
transfer_bridge_fee = leFee === BigInt(0) ? DEFAULT_FEE : BigInt(leFee.toString());
|
|
9272
|
+
transfer_assethub_execution_fee = BigInt(2200000000);
|
|
9273
|
+
return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
|
|
9274
|
+
case 12:
|
|
9275
|
+
case "end":
|
|
9276
|
+
return _context.stop();
|
|
9277
|
+
}
|
|
9278
|
+
}, _callee);
|
|
9279
|
+
}));
|
|
9280
|
+
};
|
|
9281
|
+
var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
|
|
9282
|
+
return {
|
|
9283
|
+
parents: Parents.TWO,
|
|
9284
|
+
interior: {
|
|
9285
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9286
|
+
AccountKey20: {
|
|
9287
|
+
key: currencyId
|
|
9288
|
+
}
|
|
9289
|
+
}]
|
|
9290
|
+
}
|
|
9291
|
+
};
|
|
9292
|
+
};
|
|
9293
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, versionOrDefault) {
|
|
9294
|
+
var api = _ref.api,
|
|
9295
|
+
address = _ref.address,
|
|
9296
|
+
currencyId = _ref.currencyId,
|
|
9297
|
+
scenario = _ref.scenario,
|
|
9298
|
+
ahAddress = _ref.ahAddress;
|
|
9299
|
+
return _defineProperty({}, versionOrDefault, [{
|
|
9300
|
+
SetAppendix: [{
|
|
9301
|
+
DepositAsset: {
|
|
9302
|
+
assets: {
|
|
9303
|
+
Wild: 'All'
|
|
9304
|
+
},
|
|
9305
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== void 0 ? ahAddress : '', versionOrDefault, undefined))[0]
|
|
9306
|
+
}
|
|
9307
|
+
}]
|
|
9308
|
+
}, {
|
|
9309
|
+
InitiateReserveWithdraw: {
|
|
9310
|
+
assets: {
|
|
9311
|
+
Wild: {
|
|
9312
|
+
AllOf: {
|
|
9313
|
+
id: createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : ''),
|
|
9314
|
+
fun: 'Fungible'
|
|
9315
|
+
}
|
|
9316
|
+
}
|
|
9317
|
+
},
|
|
9318
|
+
reserve: {
|
|
9319
|
+
parents: Parents.TWO,
|
|
9320
|
+
interior: {
|
|
9321
|
+
X1: [ETHEREUM_JUNCTION]
|
|
9322
|
+
}
|
|
9323
|
+
},
|
|
9324
|
+
xcm: [{
|
|
9325
|
+
BuyExecution: {
|
|
9326
|
+
fees: {
|
|
9327
|
+
id: {
|
|
9328
|
+
parents: Parents.ZERO,
|
|
9329
|
+
interior: {
|
|
9330
|
+
X1: [{
|
|
9331
|
+
AccountKey20: {
|
|
9332
|
+
network: null,
|
|
9333
|
+
key: currencyId
|
|
9334
|
+
}
|
|
9335
|
+
}]
|
|
9336
|
+
}
|
|
9337
|
+
},
|
|
9338
|
+
fun: {
|
|
9339
|
+
Fungible: BigInt(1)
|
|
9340
|
+
}
|
|
9341
|
+
},
|
|
9342
|
+
weight_limit: 'Unlimited'
|
|
9343
|
+
}
|
|
9344
|
+
}, {
|
|
9345
|
+
DepositAsset: {
|
|
9346
|
+
assets: {
|
|
9347
|
+
Wild: {
|
|
9348
|
+
AllCounted: 1
|
|
9349
|
+
}
|
|
9350
|
+
},
|
|
9351
|
+
beneficiary: {
|
|
9352
|
+
parents: Parents.ZERO,
|
|
9353
|
+
interior: {
|
|
9354
|
+
X1: [{
|
|
9355
|
+
AccountKey20: {
|
|
9356
|
+
network: null,
|
|
9357
|
+
key: address
|
|
9358
|
+
}
|
|
9359
|
+
}]
|
|
9360
|
+
}
|
|
9361
|
+
}
|
|
9362
|
+
}
|
|
9363
|
+
}]
|
|
9364
|
+
}
|
|
9365
|
+
}]);
|
|
9366
|
+
};
|
|
9230
9367
|
var Hydration$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
9231
9368
|
function Hydration() {
|
|
9232
9369
|
_classCallCheck(this, Hydration);
|
|
9233
9370
|
return _callSuper(this, Hydration, ['Hydration', 'hydradx', 'polkadot', Version.V3]);
|
|
9234
9371
|
}
|
|
9372
|
+
// Handles WETH Ethereum transfers
|
|
9235
9373
|
_inherits(Hydration, _ParachainNode);
|
|
9236
9374
|
return _createClass(Hydration, [{
|
|
9375
|
+
key: "transferPolkadotXCM",
|
|
9376
|
+
value: function transferPolkadotXCM(input) {
|
|
9377
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
9378
|
+
var api, address, currencySymbol, scenario, version, destination, amount, currencyId, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
|
|
9379
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
9380
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
9381
|
+
case 0:
|
|
9382
|
+
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;
|
|
9383
|
+
if (ethers.isAddress(address)) {
|
|
9384
|
+
_context2.next = 3;
|
|
9385
|
+
break;
|
|
9386
|
+
}
|
|
9387
|
+
throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
|
|
9388
|
+
case 3:
|
|
9389
|
+
if (!((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) !== 'WETH')) {
|
|
9390
|
+
_context2.next = 5;
|
|
9391
|
+
break;
|
|
9392
|
+
}
|
|
9393
|
+
throw new InvalidCurrencyError("Currency ".concat(currencySymbol, " is not supported for Ethereum transfers from Hydration"));
|
|
9394
|
+
case 5:
|
|
9395
|
+
if (!(ahAddress === undefined)) {
|
|
9396
|
+
_context2.next = 7;
|
|
9397
|
+
break;
|
|
9398
|
+
}
|
|
9399
|
+
throw new Error('AssetHub address is required for Ethereum transfers');
|
|
9400
|
+
case 7:
|
|
9401
|
+
versionOrDefault = version !== null && version !== void 0 ? version : Version.V4;
|
|
9402
|
+
ethMultiAsset = Object.values(createCurrencySpec(amount, versionOrDefault, Parents.TWO, createEthereumTokenLocation(currencyId !== null && currencyId !== void 0 ? currencyId : '')))[0][0];
|
|
9403
|
+
_context2.next = 11;
|
|
9404
|
+
return calculateFee(api);
|
|
9405
|
+
case 11:
|
|
9406
|
+
fee = _context2.sent;
|
|
9407
|
+
call = {
|
|
9408
|
+
module: 'PolkadotXcm',
|
|
9409
|
+
section: 'transfer_assets_using_type_and_then',
|
|
9410
|
+
parameters: {
|
|
9411
|
+
dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
|
|
9412
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
|
|
9413
|
+
assets_transfer_type: 'DestinationReserve',
|
|
9414
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
9415
|
+
parents: Parents.ONE,
|
|
9416
|
+
interior: 'Here'
|
|
9417
|
+
}),
|
|
9418
|
+
fees_transfer_type: 'DestinationReserve',
|
|
9419
|
+
custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
|
|
9420
|
+
weight_limit: 'Unlimited'
|
|
9421
|
+
}
|
|
9422
|
+
};
|
|
9423
|
+
return _context2.abrupt("return", api.callTxMethod(call));
|
|
9424
|
+
case 14:
|
|
9425
|
+
case "end":
|
|
9426
|
+
return _context2.stop();
|
|
9427
|
+
}
|
|
9428
|
+
}, _callee2, this);
|
|
9429
|
+
}));
|
|
9430
|
+
}
|
|
9431
|
+
}, {
|
|
9237
9432
|
key: "transferXTokens",
|
|
9238
9433
|
value: function transferXTokens(input) {
|
|
9239
9434
|
var currencyID = input.currencyID;
|
|
9240
9435
|
return XTokensTransferImpl.transferXTokens(input, currencyID);
|
|
9241
9436
|
}
|
|
9437
|
+
}, {
|
|
9438
|
+
key: "canUseXTokens",
|
|
9439
|
+
value: function canUseXTokens(_ref3) {
|
|
9440
|
+
var destination = _ref3.destination;
|
|
9441
|
+
return destination !== 'Ethereum';
|
|
9442
|
+
}
|
|
9242
9443
|
}]);
|
|
9243
9444
|
}(ParachainNode);
|
|
9244
9445
|
|
|
@@ -9709,21 +9910,13 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9709
9910
|
if (!ethAsset) {
|
|
9710
9911
|
throw new InvalidCurrencyError("Currency ".concat(currencySymbol, " is not supported for Ethereum transfers"));
|
|
9711
9912
|
}
|
|
9712
|
-
var ETH_CHAIN_ID = BigInt(1);
|
|
9713
|
-
var ethJunction = {
|
|
9714
|
-
GlobalConsensus: {
|
|
9715
|
-
Ethereum: {
|
|
9716
|
-
chain_id: ETH_CHAIN_ID
|
|
9717
|
-
}
|
|
9718
|
-
}
|
|
9719
|
-
};
|
|
9720
9913
|
var modifiedInput = Object.assign(Object.assign({}, input), {
|
|
9721
|
-
header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo,
|
|
9914
|
+
header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
|
|
9722
9915
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraIdTo),
|
|
9723
9916
|
currencySelection: createCurrencySpec(input.amount, Version.V3, Parents.TWO, {
|
|
9724
9917
|
parents: Parents.TWO,
|
|
9725
9918
|
interior: {
|
|
9726
|
-
X2: [
|
|
9919
|
+
X2: [ETHEREUM_JUNCTION, {
|
|
9727
9920
|
AccountKey20: {
|
|
9728
9921
|
key: ethAsset.assetId
|
|
9729
9922
|
}
|
|
@@ -9764,17 +9957,18 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9764
9957
|
}, {
|
|
9765
9958
|
key: "transferPolkadotXCM",
|
|
9766
9959
|
value: function transferPolkadotXCM(input) {
|
|
9960
|
+
var _a;
|
|
9767
9961
|
var scenario = input.scenario,
|
|
9768
9962
|
currencySymbol = input.currencySymbol,
|
|
9769
9963
|
currencyId = input.currencyId;
|
|
9770
9964
|
if (input.destination === 'AssetHubKusama') {
|
|
9771
|
-
return this.handleBridgeTransfer(input, 'Kusama');
|
|
9965
|
+
return Promise.resolve(this.handleBridgeTransfer(input, 'Kusama'));
|
|
9772
9966
|
}
|
|
9773
9967
|
if (input.destination === 'Ethereum') {
|
|
9774
|
-
return this.handleEthBridgeTransfer(input);
|
|
9968
|
+
return Promise.resolve(this.handleEthBridgeTransfer(input));
|
|
9775
9969
|
}
|
|
9776
9970
|
if (input.destination === 'Mythos') {
|
|
9777
|
-
return this.handleMythosTransfer(input);
|
|
9971
|
+
return Promise.resolve(this.handleMythosTransfer(input));
|
|
9778
9972
|
}
|
|
9779
9973
|
if (scenario === 'ParaToPara' && currencySymbol === 'DOT' && currencyId === undefined) {
|
|
9780
9974
|
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.');
|
|
@@ -9783,7 +9977,19 @@ var AssetHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9783
9977
|
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>}.');
|
|
9784
9978
|
}
|
|
9785
9979
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9786
|
-
|
|
9980
|
+
var api = input.api,
|
|
9981
|
+
destination = input.destination,
|
|
9982
|
+
paraIdTo = input.paraIdTo,
|
|
9983
|
+
address = input.address,
|
|
9984
|
+
amount = input.amount,
|
|
9985
|
+
overridedCurrency = input.overridedCurrency;
|
|
9986
|
+
var versionOrDefault = (_a = input.version) !== null && _a !== void 0 ? _a : Version.V2;
|
|
9987
|
+
var modifiedInput = ((currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDT' || (currencySymbol === null || currencySymbol === void 0 ? void 0 : currencySymbol.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot' ? Object.assign(Object.assign({}, input), {
|
|
9988
|
+
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
|
|
9989
|
+
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
|
|
9990
|
+
currencySelection: this.createCurrencySpec(amount, scenario, versionOrDefault, currencyId, overridedCurrency)
|
|
9991
|
+
}) : input;
|
|
9992
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, section, 'Unlimited'));
|
|
9787
9993
|
}
|
|
9788
9994
|
}, {
|
|
9789
9995
|
key: "transferRelayToPara",
|
|
@@ -9832,7 +10038,7 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9832
10038
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
|
|
9833
10039
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
|
|
9834
10040
|
if (destination === 'AssetHubPolkadot') {
|
|
9835
|
-
return getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
|
|
10041
|
+
return Promise.resolve(getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot'));
|
|
9836
10042
|
}
|
|
9837
10043
|
if (scenario === 'ParaToPara' && currencySymbol === 'KSM' && currencyId === undefined) {
|
|
9838
10044
|
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.');
|
|
@@ -9841,7 +10047,7 @@ var AssetHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9841
10047
|
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>}.');
|
|
9842
10048
|
}
|
|
9843
10049
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9844
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10050
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
9845
10051
|
}
|
|
9846
10052
|
}, {
|
|
9847
10053
|
key: "transferRelayToPara",
|
|
@@ -9877,7 +10083,7 @@ var CoretimeKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9877
10083
|
// TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
|
|
9878
10084
|
var scenario = input.scenario;
|
|
9879
10085
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9880
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10086
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
9881
10087
|
}
|
|
9882
10088
|
}, {
|
|
9883
10089
|
key: "transferRelayToPara",
|
|
@@ -9909,7 +10115,7 @@ var CoretimePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9909
10115
|
value: function transferPolkadotXCM(input) {
|
|
9910
10116
|
var scenario = input.scenario;
|
|
9911
10117
|
var section = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
|
|
9912
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10118
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
9913
10119
|
}
|
|
9914
10120
|
}, {
|
|
9915
10121
|
key: "transferRelayToPara",
|
|
@@ -9937,7 +10143,7 @@ var Encointer$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9937
10143
|
// NO PARA TO PARA SCENARIOS ON SUBSCAN
|
|
9938
10144
|
// TESTED https://encointer.subscan.io/xcm_message/kusama-418501e86e947b16c4e4e9040694017e64f9b162
|
|
9939
10145
|
if (input.scenario === 'ParaToRelay') {
|
|
9940
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited');
|
|
10146
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
|
|
9941
10147
|
}
|
|
9942
10148
|
throw new ScenarioNotSupportedError(this.node, input.scenario);
|
|
9943
10149
|
}
|
|
@@ -9964,7 +10170,7 @@ var RobonomicsKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9964
10170
|
return _createClass(RobonomicsKusama, [{
|
|
9965
10171
|
key: "transferPolkadotXCM",
|
|
9966
10172
|
value: function transferPolkadotXCM(input) {
|
|
9967
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10173
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
9968
10174
|
}
|
|
9969
10175
|
}]);
|
|
9970
10176
|
}(ParachainNode);
|
|
@@ -9978,7 +10184,7 @@ var RobonomicsPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9978
10184
|
return _createClass(RobonomicsPolkadot, [{
|
|
9979
10185
|
key: "transferPolkadotXCM",
|
|
9980
10186
|
value: function transferPolkadotXCM(input) {
|
|
9981
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10187
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
9982
10188
|
}
|
|
9983
10189
|
}]);
|
|
9984
10190
|
}(ParachainNode);
|
|
@@ -9997,7 +10203,7 @@ var PeoplePolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
9997
10203
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
9998
10204
|
}
|
|
9999
10205
|
var section = 'limited_teleport_assets';
|
|
10000
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10206
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10001
10207
|
}
|
|
10002
10208
|
}, {
|
|
10003
10209
|
key: "transferRelayToPara",
|
|
@@ -10027,7 +10233,7 @@ var PeopleKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10027
10233
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
10028
10234
|
}
|
|
10029
10235
|
var section = 'limited_teleport_assets';
|
|
10030
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10236
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10031
10237
|
}
|
|
10032
10238
|
}, {
|
|
10033
10239
|
key: "transferRelayToPara",
|
|
@@ -10054,7 +10260,7 @@ var Astar$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10054
10260
|
value: function transferPolkadotXCM(input) {
|
|
10055
10261
|
// TESTED https://polkadot.subscan.io/xcm_message/polkadot-f2b697df74ebe4b62853fe81b8b7d0522464972d
|
|
10056
10262
|
var section = input.scenario === 'ParaToPara' ? 'reserve_transfer_assets' : 'reserve_withdraw_assets';
|
|
10057
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section);
|
|
10263
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section));
|
|
10058
10264
|
}
|
|
10059
10265
|
}, {
|
|
10060
10266
|
key: "transferXTokens",
|
|
@@ -10126,7 +10332,7 @@ var Crab$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10126
10332
|
value: function transferPolkadotXCM(input) {
|
|
10127
10333
|
// TESTED https://kusama.subscan.io/xcm_message/kusama-ce7396ec470ba0c6516a50075046ee65464572dc
|
|
10128
10334
|
if (input.scenario === 'ParaToPara') {
|
|
10129
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets');
|
|
10335
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
|
|
10130
10336
|
}
|
|
10131
10337
|
throw new ScenarioNotSupportedError(this.node, input.scenario);
|
|
10132
10338
|
}
|
|
@@ -10241,7 +10447,7 @@ var NeuroWeb$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10241
10447
|
return _createClass(NeuroWeb, [{
|
|
10242
10448
|
key: "transferPolkadotXCM",
|
|
10243
10449
|
value: function transferPolkadotXCM(input) {
|
|
10244
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10450
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
10245
10451
|
}
|
|
10246
10452
|
}]);
|
|
10247
10453
|
}(ParachainNode);
|
|
@@ -10319,7 +10525,7 @@ var Collectives$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10319
10525
|
if (scenario === 'ParaToPara') {
|
|
10320
10526
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
10321
10527
|
}
|
|
10322
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited');
|
|
10528
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
|
|
10323
10529
|
}
|
|
10324
10530
|
}, {
|
|
10325
10531
|
key: "transferRelayToPara",
|
|
@@ -10481,7 +10687,7 @@ var Subsocial$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10481
10687
|
if (currencySymbol !== this.getNativeAssetSymbol()) {
|
|
10482
10688
|
throw new InvalidCurrencyError("Asset ".concat(currencySymbol, " is not supported by node ").concat(this.node, "."));
|
|
10483
10689
|
}
|
|
10484
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10690
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
10485
10691
|
}
|
|
10486
10692
|
}]);
|
|
10487
10693
|
}(ParachainNode);
|
|
@@ -10498,7 +10704,7 @@ var KiltSpiritnet$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10498
10704
|
if (input.scenario !== 'ParaToPara') {
|
|
10499
10705
|
throw new ScenarioNotSupportedError(this.node, input.scenario);
|
|
10500
10706
|
}
|
|
10501
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets');
|
|
10707
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
|
|
10502
10708
|
}
|
|
10503
10709
|
}, {
|
|
10504
10710
|
key: "transferRelayToPara",
|
|
@@ -10552,7 +10758,7 @@ var BridgeHubPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10552
10758
|
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.');
|
|
10553
10759
|
}
|
|
10554
10760
|
var section = 'limited_teleport_assets';
|
|
10555
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10761
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10556
10762
|
}
|
|
10557
10763
|
}, {
|
|
10558
10764
|
key: "transferRelayToPara",
|
|
@@ -10585,7 +10791,7 @@ var BridgeHubKusama$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10585
10791
|
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.');
|
|
10586
10792
|
}
|
|
10587
10793
|
var section = 'limited_teleport_assets';
|
|
10588
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited');
|
|
10794
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'));
|
|
10589
10795
|
}
|
|
10590
10796
|
}, {
|
|
10591
10797
|
key: "transferRelayToPara",
|
|
@@ -10629,7 +10835,7 @@ var Mythos$2 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
10629
10835
|
if (currencySymbol !== nativeSymbol) {
|
|
10630
10836
|
throw new InvalidCurrencyError("Node ".concat(this.node, " does not support currency ").concat(currencySymbol));
|
|
10631
10837
|
}
|
|
10632
|
-
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited');
|
|
10838
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited'));
|
|
10633
10839
|
}
|
|
10634
10840
|
}, {
|
|
10635
10841
|
key: "transferRelayToPara",
|
|
@@ -12281,8 +12487,9 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
|
|
|
12281
12487
|
*/
|
|
12282
12488
|
}, {
|
|
12283
12489
|
key: "address",
|
|
12284
|
-
value: function address(_address) {
|
|
12490
|
+
value: function address(_address, ahAddress) {
|
|
12285
12491
|
this._address = _address;
|
|
12492
|
+
this._ahAddress = ahAddress;
|
|
12286
12493
|
return this;
|
|
12287
12494
|
}
|
|
12288
12495
|
/**
|
|
@@ -12322,7 +12529,8 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
|
|
|
12322
12529
|
paraIdTo: this.paraIdTo,
|
|
12323
12530
|
feeAsset: this._feeAsset,
|
|
12324
12531
|
destApiForKeepAlive: this._destApi,
|
|
12325
|
-
version: this._version
|
|
12532
|
+
version: this._version,
|
|
12533
|
+
ahAddress: this._ahAddress
|
|
12326
12534
|
};
|
|
12327
12535
|
}
|
|
12328
12536
|
/**
|
|
@@ -13397,7 +13605,8 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
13397
13605
|
});
|
|
13398
13606
|
return [].concat(_toConsumableArray(polkadotAsset ? [polkadotAsset] : []), _toConsumableArray(kusamaAsset ? [kusamaAsset] : []));
|
|
13399
13607
|
}
|
|
13400
|
-
|
|
13608
|
+
var isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
13609
|
+
if (!isRelayChain(origin) && getDefaultPallet(origin) === 'XTokens' && (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama') && !isBifrost) {
|
|
13401
13610
|
return getOtherAssets(destination).filter(function (asset) {
|
|
13402
13611
|
return originAssets.some(function (a) {
|
|
13403
13612
|
return normalizeSymbol(a.symbol) === normalizeSymbol(asset.symbol);
|
|
@@ -13554,11 +13763,11 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13554
13763
|
return __awaiter(void 0, [options_1].concat(args_1), void 0, function (options) {
|
|
13555
13764
|
var serializedApiCallEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
13556
13765
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13557
|
-
var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet,
|
|
13766
|
+
var _a, _b, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, version, ahAddress, isMultiLocationDestination, isBridge, isRelayDestination, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, isDestAssetHub, pallet, isBifrost, asset, amountStr, currencyStr;
|
|
13558
13767
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13559
13768
|
while (1) switch (_context.prev = _context.next) {
|
|
13560
13769
|
case 0:
|
|
13561
|
-
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;
|
|
13770
|
+
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;
|
|
13562
13771
|
if (!((!('multiasset' in currency) || 'multilocation' in currency) && amount === null)) {
|
|
13563
13772
|
_context.next = 3;
|
|
13564
13773
|
break;
|
|
@@ -13608,11 +13817,11 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13608
13817
|
}
|
|
13609
13818
|
throw new InvalidCurrencyError('Fee asset index is out of bounds. Please provide a valid index.');
|
|
13610
13819
|
case 17:
|
|
13611
|
-
if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot')) {
|
|
13820
|
+
if (!(destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration')) {
|
|
13612
13821
|
_context.next = 19;
|
|
13613
13822
|
break;
|
|
13614
13823
|
}
|
|
13615
|
-
throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot.');
|
|
13824
|
+
throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
|
|
13616
13825
|
case 19:
|
|
13617
13826
|
isMultiLocationDestination = _typeof(destination) === 'object';
|
|
13618
13827
|
isBridge = origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
|
|
@@ -13633,90 +13842,85 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13633
13842
|
assetCheckEnabled = 'multilocation' in currency || 'multiasset' in currency || isBridge ? false : originNode.assetCheckEnabled;
|
|
13634
13843
|
isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
13635
13844
|
pallet = getDefaultPallet(origin);
|
|
13636
|
-
|
|
13637
|
-
|
|
13845
|
+
isBifrost = origin === 'BifrostPolkadot' || origin === 'BifrostKusama';
|
|
13846
|
+
if (!(!isBridge && isDestAssetHub && pallet === 'XTokens' && !isBifrost)) {
|
|
13847
|
+
_context.next = 42;
|
|
13638
13848
|
break;
|
|
13639
13849
|
}
|
|
13640
13850
|
asset = getAssetBySymbolOrId(destination, currency, false, destination);
|
|
13641
|
-
|
|
13642
|
-
if (origin === 'BifrostPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
|
|
13643
|
-
nativeAssets = nativeAssets.filter(function (nativeAsset) {
|
|
13644
|
-
return nativeAsset.symbol !== 'DOT';
|
|
13645
|
-
});
|
|
13646
|
-
}
|
|
13647
|
-
if (!('symbol' in currency && nativeAssets.some(function (nativeAsset) {
|
|
13851
|
+
if (!('symbol' in currency && getNativeAssets(destination).some(function (nativeAsset) {
|
|
13648
13852
|
return nativeAsset.symbol.toLowerCase() === currency.symbol.toLowerCase();
|
|
13649
13853
|
}))) {
|
|
13650
|
-
_context.next =
|
|
13854
|
+
_context.next = 36;
|
|
13651
13855
|
break;
|
|
13652
13856
|
}
|
|
13653
13857
|
throw new InvalidCurrencyError("".concat(currency.symbol, " is not supported for transfers to ").concat(destination, "."));
|
|
13654
|
-
case
|
|
13858
|
+
case 36:
|
|
13655
13859
|
if (!(assetCheckEnabled && asset === null)) {
|
|
13656
|
-
_context.next =
|
|
13860
|
+
_context.next = 38;
|
|
13657
13861
|
break;
|
|
13658
13862
|
}
|
|
13659
13863
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13660
|
-
case
|
|
13864
|
+
case 38:
|
|
13661
13865
|
if (!((asset === null || asset === void 0 ? void 0 : asset.symbol) && !hasSupportForAsset(origin, asset.symbol))) {
|
|
13662
|
-
_context.next =
|
|
13866
|
+
_context.next = 40;
|
|
13663
13867
|
break;
|
|
13664
13868
|
}
|
|
13665
13869
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(asset.symbol, "."));
|
|
13666
|
-
case
|
|
13667
|
-
_context.next =
|
|
13870
|
+
case 40:
|
|
13871
|
+
_context.next = 47;
|
|
13668
13872
|
break;
|
|
13669
|
-
case
|
|
13873
|
+
case 42:
|
|
13670
13874
|
asset = assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, isRelayDestination, isTMultiLocation(destination) ? undefined : destination) : null;
|
|
13671
13875
|
if (!(!isBridge && asset === null && assetCheckEnabled)) {
|
|
13672
|
-
_context.next =
|
|
13876
|
+
_context.next = 45;
|
|
13673
13877
|
break;
|
|
13674
13878
|
}
|
|
13675
13879
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13676
|
-
case
|
|
13880
|
+
case 45:
|
|
13677
13881
|
if (!(!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol))) {
|
|
13678
|
-
_context.next =
|
|
13882
|
+
_context.next = 47;
|
|
13679
13883
|
break;
|
|
13680
13884
|
}
|
|
13681
13885
|
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
13682
|
-
case
|
|
13683
|
-
_context.next =
|
|
13886
|
+
case 47:
|
|
13887
|
+
_context.next = 49;
|
|
13684
13888
|
return api.init(origin);
|
|
13685
|
-
case
|
|
13889
|
+
case 49:
|
|
13686
13890
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
13687
13891
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
13688
|
-
_context.next =
|
|
13892
|
+
_context.next = 54;
|
|
13689
13893
|
break;
|
|
13690
13894
|
}
|
|
13691
13895
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
13692
|
-
_context.next =
|
|
13896
|
+
_context.next = 68;
|
|
13693
13897
|
break;
|
|
13694
|
-
case
|
|
13898
|
+
case 54:
|
|
13695
13899
|
if (!(_typeof(address) === 'object')) {
|
|
13696
|
-
_context.next =
|
|
13900
|
+
_context.next = 58;
|
|
13697
13901
|
break;
|
|
13698
13902
|
}
|
|
13699
13903
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
13700
|
-
_context.next =
|
|
13904
|
+
_context.next = 68;
|
|
13701
13905
|
break;
|
|
13702
|
-
case
|
|
13906
|
+
case 58:
|
|
13703
13907
|
if (!(_typeof(destination) === 'object')) {
|
|
13704
|
-
_context.next =
|
|
13908
|
+
_context.next = 62;
|
|
13705
13909
|
break;
|
|
13706
13910
|
}
|
|
13707
13911
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
13708
|
-
_context.next =
|
|
13912
|
+
_context.next = 68;
|
|
13709
13913
|
break;
|
|
13710
|
-
case
|
|
13914
|
+
case 62:
|
|
13711
13915
|
if (!(origin === 'Ethereum' || destination === 'Ethereum')) {
|
|
13712
|
-
_context.next =
|
|
13916
|
+
_context.next = 66;
|
|
13713
13917
|
break;
|
|
13714
13918
|
}
|
|
13715
13919
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
13716
|
-
_context.next =
|
|
13920
|
+
_context.next = 68;
|
|
13717
13921
|
break;
|
|
13718
|
-
case
|
|
13719
|
-
_context.next =
|
|
13922
|
+
case 66:
|
|
13923
|
+
_context.next = 68;
|
|
13720
13924
|
return checkKeepAlive({
|
|
13721
13925
|
originApi: api,
|
|
13722
13926
|
address: address,
|
|
@@ -13726,7 +13930,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13726
13930
|
currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : 'symbol' in currency ? currency.symbol : undefined,
|
|
13727
13931
|
destNode: destination
|
|
13728
13932
|
});
|
|
13729
|
-
case
|
|
13933
|
+
case 68:
|
|
13730
13934
|
currencyStr = 'symbol' in currency ? currency.symbol : 'id' in currency ? currency.id.toString() : undefined;
|
|
13731
13935
|
return _context.abrupt("return", originNode.transfer({
|
|
13732
13936
|
api: api,
|
|
@@ -13740,9 +13944,10 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
13740
13944
|
feeAsset: feeAsset,
|
|
13741
13945
|
version: version,
|
|
13742
13946
|
destApiForKeepAlive: destApiForKeepAlive,
|
|
13743
|
-
serializedApiCallEnabled: serializedApiCallEnabled
|
|
13947
|
+
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
13948
|
+
ahAddress: ahAddress
|
|
13744
13949
|
}));
|
|
13745
|
-
case
|
|
13950
|
+
case 70:
|
|
13746
13951
|
case "end":
|
|
13747
13952
|
return _context.stop();
|
|
13748
13953
|
}
|
|
@@ -14116,21 +14321,32 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
14116
14321
|
}
|
|
14117
14322
|
throw new NodeNotSupportedError("The node ".concat(node, " is not yet supported by the Polkadot API."));
|
|
14118
14323
|
case 2:
|
|
14324
|
+
if (!(typeof this._api === 'string')) {
|
|
14325
|
+
_context.next = 8;
|
|
14326
|
+
break;
|
|
14327
|
+
}
|
|
14328
|
+
_context.next = 5;
|
|
14329
|
+
return this.createApiInstance(this._api);
|
|
14330
|
+
case 5:
|
|
14331
|
+
this.api = _context.sent;
|
|
14332
|
+
_context.next = 16;
|
|
14333
|
+
break;
|
|
14334
|
+
case 8:
|
|
14119
14335
|
if (!((_a = this._api) !== null && _a !== void 0)) {
|
|
14120
|
-
_context.next =
|
|
14336
|
+
_context.next = 12;
|
|
14121
14337
|
break;
|
|
14122
14338
|
}
|
|
14123
14339
|
_context.t0 = _a;
|
|
14124
|
-
_context.next =
|
|
14340
|
+
_context.next = 15;
|
|
14125
14341
|
break;
|
|
14126
|
-
case
|
|
14127
|
-
_context.next =
|
|
14342
|
+
case 12:
|
|
14343
|
+
_context.next = 14;
|
|
14128
14344
|
return createApiInstanceForNode$1(this, node);
|
|
14129
|
-
case
|
|
14345
|
+
case 14:
|
|
14130
14346
|
_context.t0 = _context.sent;
|
|
14131
|
-
case
|
|
14347
|
+
case 15:
|
|
14132
14348
|
this.api = _context.t0;
|
|
14133
|
-
case
|
|
14349
|
+
case 16:
|
|
14134
14350
|
case "end":
|
|
14135
14351
|
return _context.stop();
|
|
14136
14352
|
}
|
|
@@ -14341,11 +14557,49 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
14341
14557
|
}, _callee9, this);
|
|
14342
14558
|
}));
|
|
14343
14559
|
}
|
|
14560
|
+
}, {
|
|
14561
|
+
key: "getFromStorage",
|
|
14562
|
+
value: function getFromStorage(key) {
|
|
14563
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
14564
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
14565
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
14566
|
+
case 0:
|
|
14567
|
+
_context10.next = 2;
|
|
14568
|
+
return this.api._request('state_getStorage', [key]);
|
|
14569
|
+
case 2:
|
|
14570
|
+
return _context10.abrupt("return", _context10.sent);
|
|
14571
|
+
case 3:
|
|
14572
|
+
case "end":
|
|
14573
|
+
return _context10.stop();
|
|
14574
|
+
}
|
|
14575
|
+
}, _callee10, this);
|
|
14576
|
+
}));
|
|
14577
|
+
}
|
|
14344
14578
|
}, {
|
|
14345
14579
|
key: "clone",
|
|
14346
14580
|
value: function clone() {
|
|
14347
14581
|
return new PapiApi();
|
|
14348
14582
|
}
|
|
14583
|
+
}, {
|
|
14584
|
+
key: "createApiForNode",
|
|
14585
|
+
value: function createApiForNode(node) {
|
|
14586
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
14587
|
+
var api;
|
|
14588
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
14589
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
14590
|
+
case 0:
|
|
14591
|
+
api = new PapiApi();
|
|
14592
|
+
_context11.next = 3;
|
|
14593
|
+
return api.init(node);
|
|
14594
|
+
case 3:
|
|
14595
|
+
return _context11.abrupt("return", api);
|
|
14596
|
+
case 4:
|
|
14597
|
+
case "end":
|
|
14598
|
+
return _context11.stop();
|
|
14599
|
+
}
|
|
14600
|
+
}, _callee11);
|
|
14601
|
+
}));
|
|
14602
|
+
}
|
|
14349
14603
|
}]);
|
|
14350
14604
|
}();
|
|
14351
14605
|
|