@paraspell/sdk 1.1.13 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +75 -16
- package/dist/index.d.ts +13 -10
- package/dist/index.mjs +75 -17
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,12 +5,6 @@ var ethers = require('ethers');
|
|
|
5
5
|
var endpoints = require('@polkadot/apps-config/endpoints');
|
|
6
6
|
|
|
7
7
|
// derrived from https://github.com/kodadot/packages/blob/main/minimark/src/common/types.ts
|
|
8
|
-
exports.TType = void 0;
|
|
9
|
-
(function (TType) {
|
|
10
|
-
TType["CONSTS"] = "consts";
|
|
11
|
-
TType["QUERY"] = "query";
|
|
12
|
-
TType["TX"] = "tx";
|
|
13
|
-
})(exports.TType || (exports.TType = {}));
|
|
14
8
|
exports.Version = void 0;
|
|
15
9
|
(function (Version) {
|
|
16
10
|
Version[Version["V1"] = 0] = "V1";
|
|
@@ -3771,7 +3765,6 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
3771
3765
|
var module = lowercaseFirstLetter(pallet.toString());
|
|
3772
3766
|
if (serializedApiCallEnabled) {
|
|
3773
3767
|
return {
|
|
3774
|
-
type: exports.TType.TX,
|
|
3775
3768
|
module: module,
|
|
3776
3769
|
section: 'transfer',
|
|
3777
3770
|
parameters: [currencySelection, amount, addressSelection, fees]
|
|
@@ -4509,6 +4502,7 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
4509
4502
|
return Karura;
|
|
4510
4503
|
}(ParachainNode);
|
|
4511
4504
|
|
|
4505
|
+
// Contains basic structure of polkadotXCM call
|
|
4512
4506
|
var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
|
|
4513
4507
|
function PolkadotXCMTransferImpl() {
|
|
4514
4508
|
_classCallCheck(this, PolkadotXCMTransferImpl);
|
|
@@ -4524,7 +4518,6 @@ var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
|
|
|
4524
4518
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
4525
4519
|
if (serializedApiCallEnabled) {
|
|
4526
4520
|
return {
|
|
4527
|
-
type: exports.TType.TX,
|
|
4528
4521
|
module: 'polkadotXcm',
|
|
4529
4522
|
section: method,
|
|
4530
4523
|
parameters: [header, addressSelection, currencySelection, 0].concat(_toConsumableArray(fees ? [fees] : []))
|
|
@@ -5226,6 +5219,13 @@ function getNodeEndpointOption(node) {
|
|
|
5226
5219
|
var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
|
|
5227
5220
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5228
5221
|
};
|
|
5222
|
+
var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref2) {
|
|
5223
|
+
var _api$tx$module;
|
|
5224
|
+
var module = _ref2.module,
|
|
5225
|
+
section = _ref2.section,
|
|
5226
|
+
parameters = _ref2.parameters;
|
|
5227
|
+
return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
|
|
5228
|
+
};
|
|
5229
5229
|
|
|
5230
5230
|
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
5231
5231
|
var _getAssetsObject = getAssetsObject(node),
|
|
@@ -5265,10 +5265,30 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
|
|
|
5265
5265
|
return _createClass(NodeNotSupportedError);
|
|
5266
5266
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
5267
5267
|
|
|
5268
|
+
var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
|
|
5269
|
+
_inherits(IncompatibleNodesError, _Error);
|
|
5270
|
+
var _super = _createSuper(IncompatibleNodesError);
|
|
5271
|
+
function IncompatibleNodesError() {
|
|
5272
|
+
var _this;
|
|
5273
|
+
_classCallCheck(this, IncompatibleNodesError);
|
|
5274
|
+
_this = _super.call(this, 'Transactions between nodes on different relaychains are not yet possible.');
|
|
5275
|
+
_this.name = 'IncompatibleNodes';
|
|
5276
|
+
return _this;
|
|
5277
|
+
}
|
|
5278
|
+
return _createClass(IncompatibleNodesError);
|
|
5279
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
5280
|
+
|
|
5268
5281
|
// Contains basic call formatting for different XCM Palletss
|
|
5269
5282
|
var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5270
5283
|
var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
5271
5284
|
var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
|
|
5285
|
+
if (destination) {
|
|
5286
|
+
var originRelayChainSymbol = getRelayChainSymbol(origin);
|
|
5287
|
+
var destinationRelayChainSymbol = getRelayChainSymbol(destination);
|
|
5288
|
+
if (originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
5289
|
+
throw new IncompatibleNodesError();
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5272
5292
|
if (!asset) {
|
|
5273
5293
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
|
|
5274
5294
|
}
|
|
@@ -5285,25 +5305,59 @@ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currency
|
|
|
5285
5305
|
function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5286
5306
|
return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
|
|
5287
5307
|
}
|
|
5288
|
-
|
|
5308
|
+
// TODO: Refactor this function
|
|
5309
|
+
var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, to) {
|
|
5310
|
+
var serializedApiCallEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5289
5311
|
var paraId = getParaId(destination);
|
|
5290
5312
|
if (destination === 'Statemint' || destination === 'Statemine') {
|
|
5291
5313
|
// Same for Statemint, Statemine and Encoiter
|
|
5292
|
-
|
|
5314
|
+
var _serializedApiCall = {
|
|
5315
|
+
module: 'xcmPallet',
|
|
5316
|
+
section: 'limitedTeleportAssets',
|
|
5317
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', exports.Version.V3, paraId), handleAddress('RelayToPara', '', api, to, exports.Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', exports.Version.V3, destination), 0, 'Unlimited']
|
|
5318
|
+
};
|
|
5319
|
+
if (serializedApiCallEnabled) {
|
|
5320
|
+
return _serializedApiCall;
|
|
5321
|
+
}
|
|
5322
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall);
|
|
5293
5323
|
} else if (destination === 'Encointer') {
|
|
5294
|
-
|
|
5324
|
+
var _serializedApiCall2 = {
|
|
5325
|
+
module: 'xcmPallet',
|
|
5326
|
+
section: 'limitedTeleportAssets',
|
|
5327
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', exports.Version.V1, paraId), handleAddress('RelayToPara', '', api, to, exports.Version.V1, paraId), createCurrencySpecification(amount, 'RelayToPara', exports.Version.V1, destination), 0, 'Unlimited']
|
|
5328
|
+
};
|
|
5329
|
+
if (serializedApiCallEnabled) {
|
|
5330
|
+
return _serializedApiCall2;
|
|
5331
|
+
}
|
|
5332
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall2);
|
|
5295
5333
|
} else if (destination === 'Darwinia' || destination === 'Crab') {
|
|
5296
5334
|
// Do not do anything because Darwinia and Crab does not have DOT and KSM registered
|
|
5297
5335
|
throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
|
|
5298
5336
|
}
|
|
5299
|
-
|
|
5337
|
+
var serializedApiCall = {
|
|
5338
|
+
module: 'xcmPallet',
|
|
5339
|
+
section: 'reserveTransferAssets',
|
|
5340
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', exports.Version.V3, paraId), handleAddress('RelayToPara', '', api, to, exports.Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', exports.Version.V3, destination), 0]
|
|
5341
|
+
};
|
|
5342
|
+
if (serializedApiCallEnabled) {
|
|
5343
|
+
return serializedApiCall;
|
|
5344
|
+
}
|
|
5345
|
+
return callPolkadotJsTxFunction(api, serializedApiCall);
|
|
5346
|
+
};
|
|
5347
|
+
function transferRelayToPara(api, destination, amount, to) {
|
|
5348
|
+
return transferRelayToParaCommon(api, destination, amount, to);
|
|
5300
5349
|
}
|
|
5350
|
+
var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to) {
|
|
5351
|
+
return transferRelayToParaCommon(api, destination, amount, to, true);
|
|
5352
|
+
};
|
|
5301
5353
|
|
|
5302
5354
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
5303
5355
|
__proto__: null,
|
|
5304
5356
|
send: send,
|
|
5305
5357
|
sendSerializedApiCall: sendSerializedApiCall,
|
|
5306
|
-
transferRelayToPara: transferRelayToPara
|
|
5358
|
+
transferRelayToPara: transferRelayToPara,
|
|
5359
|
+
transferRelayToParaCommon: transferRelayToParaCommon,
|
|
5360
|
+
transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
|
|
5307
5361
|
});
|
|
5308
5362
|
|
|
5309
5363
|
//Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
|
|
@@ -5575,6 +5629,11 @@ var RelayToParaBuilder = /*#__PURE__*/function () {
|
|
|
5575
5629
|
value: function build() {
|
|
5576
5630
|
return transferRelayToPara(this.api, this.to, this._amount, this._address);
|
|
5577
5631
|
}
|
|
5632
|
+
}, {
|
|
5633
|
+
key: "buildSerializedApiCall",
|
|
5634
|
+
value: function buildSerializedApiCall() {
|
|
5635
|
+
return transferRelayToParaSerializedApiCall(this.api, this.to, this._amount, this._address);
|
|
5636
|
+
}
|
|
5578
5637
|
}], [{
|
|
5579
5638
|
key: "create",
|
|
5580
5639
|
value: function create(api, to) {
|
|
@@ -5735,11 +5794,10 @@ var ToGeneralBuilder = /*#__PURE__*/function () {
|
|
|
5735
5794
|
return ToGeneralBuilder;
|
|
5736
5795
|
}();
|
|
5737
5796
|
var FromGeneralBuilder = /*#__PURE__*/function () {
|
|
5738
|
-
function FromGeneralBuilder(api, from
|
|
5797
|
+
function FromGeneralBuilder(api, from) {
|
|
5739
5798
|
_classCallCheck(this, FromGeneralBuilder);
|
|
5740
5799
|
this.api = api;
|
|
5741
5800
|
this.from = from;
|
|
5742
|
-
this.version = version;
|
|
5743
5801
|
}
|
|
5744
5802
|
_createClass(FromGeneralBuilder, [{
|
|
5745
5803
|
key: "to",
|
|
@@ -5767,7 +5825,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5767
5825
|
_createClass(GeneralBuilder, [{
|
|
5768
5826
|
key: "from",
|
|
5769
5827
|
value: function from(node) {
|
|
5770
|
-
return new FromGeneralBuilder(this.api, node
|
|
5828
|
+
return new FromGeneralBuilder(this.api, node);
|
|
5771
5829
|
}
|
|
5772
5830
|
}, {
|
|
5773
5831
|
key: "to",
|
|
@@ -6244,6 +6302,7 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
6244
6302
|
};
|
|
6245
6303
|
|
|
6246
6304
|
exports.Builder = Builder;
|
|
6305
|
+
exports.IncompatibleNodesError = IncompatibleNodesError;
|
|
6247
6306
|
exports.InvalidCurrencyError = InvalidCurrencyError;
|
|
6248
6307
|
exports.NODE_NAMES = NODE_NAMES;
|
|
6249
6308
|
exports.NoXCMSupportImplementedError = NoXCMSupportImplementedError;
|
package/dist/index.d.ts
CHANGED
|
@@ -35,13 +35,7 @@ type TPalletMap = {
|
|
|
35
35
|
supportedPallets: TPallet[];
|
|
36
36
|
};
|
|
37
37
|
type TPalletJsonMap = Record<TNode, TPalletMap>;
|
|
38
|
-
declare enum TType {
|
|
39
|
-
CONSTS = "consts",
|
|
40
|
-
QUERY = "query",
|
|
41
|
-
TX = "tx"
|
|
42
|
-
}
|
|
43
38
|
type TSerializedApiCall = {
|
|
44
|
-
type: TType;
|
|
45
39
|
module: string;
|
|
46
40
|
section: string;
|
|
47
41
|
parameters: any[];
|
|
@@ -76,16 +70,22 @@ declare enum Version {
|
|
|
76
70
|
|
|
77
71
|
declare const sendSerializedApiCall: (api: ApiPromise, origin: TNode, currencySymbolOrId: string | number | bigint, amount: any, to: string, destination?: TNode) => TSerializedApiCall;
|
|
78
72
|
declare function send(api: ApiPromise, origin: TNode, currencySymbolOrId: string | number | bigint, amount: any, to: string, destination?: TNode): Extrinsic;
|
|
73
|
+
declare const transferRelayToParaCommon: (api: ApiPromise, destination: TNode, amount: any, to: string, serializedApiCallEnabled?: boolean) => Extrinsic | TSerializedApiCall | never;
|
|
79
74
|
declare function transferRelayToPara(api: ApiPromise, destination: TNode, amount: any, to: string): Extrinsic | never;
|
|
75
|
+
declare const transferRelayToParaSerializedApiCall: (api: ApiPromise, destination: TNode, amount: any, to: string) => TSerializedApiCall;
|
|
80
76
|
|
|
81
77
|
declare const index$4_send: typeof send;
|
|
82
78
|
declare const index$4_sendSerializedApiCall: typeof sendSerializedApiCall;
|
|
83
79
|
declare const index$4_transferRelayToPara: typeof transferRelayToPara;
|
|
80
|
+
declare const index$4_transferRelayToParaCommon: typeof transferRelayToParaCommon;
|
|
81
|
+
declare const index$4_transferRelayToParaSerializedApiCall: typeof transferRelayToParaSerializedApiCall;
|
|
84
82
|
declare namespace index$4 {
|
|
85
83
|
export {
|
|
86
84
|
index$4_send as send,
|
|
87
85
|
index$4_sendSerializedApiCall as sendSerializedApiCall,
|
|
88
86
|
index$4_transferRelayToPara as transferRelayToPara,
|
|
87
|
+
index$4_transferRelayToParaCommon as transferRelayToParaCommon,
|
|
88
|
+
index$4_transferRelayToParaSerializedApiCall as transferRelayToParaSerializedApiCall,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -249,6 +249,7 @@ interface AssetAAddLiquidityBuilder {
|
|
|
249
249
|
|
|
250
250
|
interface FinalRelayToParaBuilder$1 {
|
|
251
251
|
build(): Extrinsic | never;
|
|
252
|
+
buildSerializedApiCall(): TSerializedApiCall;
|
|
252
253
|
}
|
|
253
254
|
interface AddressRelayToParaBuilder {
|
|
254
255
|
address(address: string): FinalRelayToParaBuilder$1;
|
|
@@ -299,15 +300,13 @@ declare class ToGeneralBuilder {
|
|
|
299
300
|
declare class FromGeneralBuilder {
|
|
300
301
|
private api;
|
|
301
302
|
private from;
|
|
302
|
-
|
|
303
|
-
constructor(api: ApiPromise, from: TNode, version: number);
|
|
303
|
+
constructor(api: ApiPromise, from: TNode);
|
|
304
304
|
to(node: TNode): ToGeneralBuilder;
|
|
305
305
|
currency(currency: string | number | bigint): AmountSendBuilder;
|
|
306
306
|
closeChannel(): InboundCloseChannelBuilder;
|
|
307
307
|
}
|
|
308
308
|
declare class GeneralBuilder {
|
|
309
309
|
private api;
|
|
310
|
-
private version;
|
|
311
310
|
constructor(api: ApiPromise);
|
|
312
311
|
from(node: TNode): FromGeneralBuilder;
|
|
313
312
|
to(node: TNode): AmountRelayToParaBuilder;
|
|
@@ -340,4 +339,8 @@ declare class ScenarioNotSupportedError extends Error {
|
|
|
340
339
|
constructor(node: TNode, scenario: TScenario);
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
|
|
342
|
+
declare class IncompatibleNodesError extends Error {
|
|
343
|
+
constructor();
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export { Bool, Builder, Extrinsic, ExtrinsicFunction, IPolkadotXCMTransfer, IXTokensTransfer, IncompatibleNodesError, InvalidCurrencyError, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXCMTransferInput, SUPPORTED_PALLETS, ScenarioNotSupportedError, TAssetDetails, TAssetJsonMap, TNativeAssetDetails, TNode, TNodeAssets, TPallet, TPalletJsonMap, TPalletMap, TRelayChainType, TScenario, TSerializedApiCall, UpdateFunction, Version, XTokensTransferInput, index as assets, index$1 as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getNodeEndpointOption, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$2 as openChannels, index$4 as xcmPallet, index$3 as xyk };
|
package/dist/index.mjs
CHANGED
|
@@ -3,12 +3,6 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
import { prodRelayPolkadot, prodRelayKusama } from '@polkadot/apps-config/endpoints';
|
|
4
4
|
|
|
5
5
|
// derrived from https://github.com/kodadot/packages/blob/main/minimark/src/common/types.ts
|
|
6
|
-
var TType;
|
|
7
|
-
(function (TType) {
|
|
8
|
-
TType["CONSTS"] = "consts";
|
|
9
|
-
TType["QUERY"] = "query";
|
|
10
|
-
TType["TX"] = "tx";
|
|
11
|
-
})(TType || (TType = {}));
|
|
12
6
|
var Version;
|
|
13
7
|
(function (Version) {
|
|
14
8
|
Version[Version["V1"] = 0] = "V1";
|
|
@@ -3769,7 +3763,6 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
3769
3763
|
var module = lowercaseFirstLetter(pallet.toString());
|
|
3770
3764
|
if (serializedApiCallEnabled) {
|
|
3771
3765
|
return {
|
|
3772
|
-
type: TType.TX,
|
|
3773
3766
|
module: module,
|
|
3774
3767
|
section: 'transfer',
|
|
3775
3768
|
parameters: [currencySelection, amount, addressSelection, fees]
|
|
@@ -4507,6 +4500,7 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
4507
4500
|
return Karura;
|
|
4508
4501
|
}(ParachainNode);
|
|
4509
4502
|
|
|
4503
|
+
// Contains basic structure of polkadotXCM call
|
|
4510
4504
|
var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
|
|
4511
4505
|
function PolkadotXCMTransferImpl() {
|
|
4512
4506
|
_classCallCheck(this, PolkadotXCMTransferImpl);
|
|
@@ -4522,7 +4516,6 @@ var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
|
|
|
4522
4516
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
4523
4517
|
if (serializedApiCallEnabled) {
|
|
4524
4518
|
return {
|
|
4525
|
-
type: TType.TX,
|
|
4526
4519
|
module: 'polkadotXcm',
|
|
4527
4520
|
section: method,
|
|
4528
4521
|
parameters: [header, addressSelection, currencySelection, 0].concat(_toConsumableArray(fees ? [fees] : []))
|
|
@@ -5224,6 +5217,13 @@ function getNodeEndpointOption(node) {
|
|
|
5224
5217
|
var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
|
|
5225
5218
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5226
5219
|
};
|
|
5220
|
+
var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref2) {
|
|
5221
|
+
var _api$tx$module;
|
|
5222
|
+
var module = _ref2.module,
|
|
5223
|
+
section = _ref2.section,
|
|
5224
|
+
parameters = _ref2.parameters;
|
|
5225
|
+
return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
|
|
5226
|
+
};
|
|
5227
5227
|
|
|
5228
5228
|
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
5229
5229
|
var _getAssetsObject = getAssetsObject(node),
|
|
@@ -5263,10 +5263,30 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
|
|
|
5263
5263
|
return _createClass(NodeNotSupportedError);
|
|
5264
5264
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
5265
5265
|
|
|
5266
|
+
var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
|
|
5267
|
+
_inherits(IncompatibleNodesError, _Error);
|
|
5268
|
+
var _super = _createSuper(IncompatibleNodesError);
|
|
5269
|
+
function IncompatibleNodesError() {
|
|
5270
|
+
var _this;
|
|
5271
|
+
_classCallCheck(this, IncompatibleNodesError);
|
|
5272
|
+
_this = _super.call(this, 'Transactions between nodes on different relaychains are not yet possible.');
|
|
5273
|
+
_this.name = 'IncompatibleNodes';
|
|
5274
|
+
return _this;
|
|
5275
|
+
}
|
|
5276
|
+
return _createClass(IncompatibleNodesError);
|
|
5277
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
5278
|
+
|
|
5266
5279
|
// Contains basic call formatting for different XCM Palletss
|
|
5267
5280
|
var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5268
5281
|
var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
5269
5282
|
var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
|
|
5283
|
+
if (destination) {
|
|
5284
|
+
var originRelayChainSymbol = getRelayChainSymbol(origin);
|
|
5285
|
+
var destinationRelayChainSymbol = getRelayChainSymbol(destination);
|
|
5286
|
+
if (originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
5287
|
+
throw new IncompatibleNodesError();
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5270
5290
|
if (!asset) {
|
|
5271
5291
|
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
|
|
5272
5292
|
}
|
|
@@ -5283,25 +5303,59 @@ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currency
|
|
|
5283
5303
|
function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5284
5304
|
return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
|
|
5285
5305
|
}
|
|
5286
|
-
|
|
5306
|
+
// TODO: Refactor this function
|
|
5307
|
+
var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, to) {
|
|
5308
|
+
var serializedApiCallEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5287
5309
|
var paraId = getParaId(destination);
|
|
5288
5310
|
if (destination === 'Statemint' || destination === 'Statemine') {
|
|
5289
5311
|
// Same for Statemint, Statemine and Encoiter
|
|
5290
|
-
|
|
5312
|
+
var _serializedApiCall = {
|
|
5313
|
+
module: 'xcmPallet',
|
|
5314
|
+
section: 'limitedTeleportAssets',
|
|
5315
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId), handleAddress('RelayToPara', '', api, to, Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination), 0, 'Unlimited']
|
|
5316
|
+
};
|
|
5317
|
+
if (serializedApiCallEnabled) {
|
|
5318
|
+
return _serializedApiCall;
|
|
5319
|
+
}
|
|
5320
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall);
|
|
5291
5321
|
} else if (destination === 'Encointer') {
|
|
5292
|
-
|
|
5322
|
+
var _serializedApiCall2 = {
|
|
5323
|
+
module: 'xcmPallet',
|
|
5324
|
+
section: 'limitedTeleportAssets',
|
|
5325
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V1, paraId), handleAddress('RelayToPara', '', api, to, Version.V1, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V1, destination), 0, 'Unlimited']
|
|
5326
|
+
};
|
|
5327
|
+
if (serializedApiCallEnabled) {
|
|
5328
|
+
return _serializedApiCall2;
|
|
5329
|
+
}
|
|
5330
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall2);
|
|
5293
5331
|
} else if (destination === 'Darwinia' || destination === 'Crab') {
|
|
5294
5332
|
// Do not do anything because Darwinia and Crab does not have DOT and KSM registered
|
|
5295
5333
|
throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
|
|
5296
5334
|
}
|
|
5297
|
-
|
|
5335
|
+
var serializedApiCall = {
|
|
5336
|
+
module: 'xcmPallet',
|
|
5337
|
+
section: 'reserveTransferAssets',
|
|
5338
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId), handleAddress('RelayToPara', '', api, to, Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination), 0]
|
|
5339
|
+
};
|
|
5340
|
+
if (serializedApiCallEnabled) {
|
|
5341
|
+
return serializedApiCall;
|
|
5342
|
+
}
|
|
5343
|
+
return callPolkadotJsTxFunction(api, serializedApiCall);
|
|
5344
|
+
};
|
|
5345
|
+
function transferRelayToPara(api, destination, amount, to) {
|
|
5346
|
+
return transferRelayToParaCommon(api, destination, amount, to);
|
|
5298
5347
|
}
|
|
5348
|
+
var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to) {
|
|
5349
|
+
return transferRelayToParaCommon(api, destination, amount, to, true);
|
|
5350
|
+
};
|
|
5299
5351
|
|
|
5300
5352
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
5301
5353
|
__proto__: null,
|
|
5302
5354
|
send: send,
|
|
5303
5355
|
sendSerializedApiCall: sendSerializedApiCall,
|
|
5304
|
-
transferRelayToPara: transferRelayToPara
|
|
5356
|
+
transferRelayToPara: transferRelayToPara,
|
|
5357
|
+
transferRelayToParaCommon: transferRelayToParaCommon,
|
|
5358
|
+
transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
|
|
5305
5359
|
});
|
|
5306
5360
|
|
|
5307
5361
|
//Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
|
|
@@ -5573,6 +5627,11 @@ var RelayToParaBuilder = /*#__PURE__*/function () {
|
|
|
5573
5627
|
value: function build() {
|
|
5574
5628
|
return transferRelayToPara(this.api, this.to, this._amount, this._address);
|
|
5575
5629
|
}
|
|
5630
|
+
}, {
|
|
5631
|
+
key: "buildSerializedApiCall",
|
|
5632
|
+
value: function buildSerializedApiCall() {
|
|
5633
|
+
return transferRelayToParaSerializedApiCall(this.api, this.to, this._amount, this._address);
|
|
5634
|
+
}
|
|
5576
5635
|
}], [{
|
|
5577
5636
|
key: "create",
|
|
5578
5637
|
value: function create(api, to) {
|
|
@@ -5733,11 +5792,10 @@ var ToGeneralBuilder = /*#__PURE__*/function () {
|
|
|
5733
5792
|
return ToGeneralBuilder;
|
|
5734
5793
|
}();
|
|
5735
5794
|
var FromGeneralBuilder = /*#__PURE__*/function () {
|
|
5736
|
-
function FromGeneralBuilder(api, from
|
|
5795
|
+
function FromGeneralBuilder(api, from) {
|
|
5737
5796
|
_classCallCheck(this, FromGeneralBuilder);
|
|
5738
5797
|
this.api = api;
|
|
5739
5798
|
this.from = from;
|
|
5740
|
-
this.version = version;
|
|
5741
5799
|
}
|
|
5742
5800
|
_createClass(FromGeneralBuilder, [{
|
|
5743
5801
|
key: "to",
|
|
@@ -5765,7 +5823,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5765
5823
|
_createClass(GeneralBuilder, [{
|
|
5766
5824
|
key: "from",
|
|
5767
5825
|
value: function from(node) {
|
|
5768
|
-
return new FromGeneralBuilder(this.api, node
|
|
5826
|
+
return new FromGeneralBuilder(this.api, node);
|
|
5769
5827
|
}
|
|
5770
5828
|
}, {
|
|
5771
5829
|
key: "to",
|
|
@@ -6241,4 +6299,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
6241
6299
|
return palletsMap[node].supportedPallets;
|
|
6242
6300
|
};
|
|
6243
6301
|
|
|
6244
|
-
export { Builder, InvalidCurrencyError, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, SUPPORTED_PALLETS, ScenarioNotSupportedError,
|
|
6302
|
+
export { Builder, IncompatibleNodesError, InvalidCurrencyError, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$4 as assets, index as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getNodeEndpointOption, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$1 as openChannels, index$3 as xcmPallet, index$2 as xyk };
|