@paraspell/sdk 1.1.12 → 1.1.14
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 +70 -17
- package/dist/index.d.ts +28 -10
- package/dist/index.mjs +66 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require('@polkadot/api');
|
|
4
4
|
var ethers = require('ethers');
|
|
5
|
-
require('@polkadot/apps-config/endpoints');
|
|
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] : []))
|
|
@@ -5213,9 +5206,26 @@ function createHeaderPolkadotXCM(scenario, version, nodeId) {
|
|
|
5213
5206
|
function getNode(node) {
|
|
5214
5207
|
return nodes[node];
|
|
5215
5208
|
}
|
|
5209
|
+
function getNodeEndpointOption(node) {
|
|
5210
|
+
var _getNode = getNode(node),
|
|
5211
|
+
type = _getNode.type,
|
|
5212
|
+
name = _getNode.name;
|
|
5213
|
+
var _ref = type === 'polkadot' ? endpoints.prodRelayPolkadot : endpoints.prodRelayKusama,
|
|
5214
|
+
linked = _ref.linked;
|
|
5215
|
+
return linked ? linked.find(function (o) {
|
|
5216
|
+
return o.info === name;
|
|
5217
|
+
}) : undefined;
|
|
5218
|
+
}
|
|
5216
5219
|
var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
|
|
5217
5220
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5218
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
|
+
};
|
|
5219
5229
|
|
|
5220
5230
|
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
5221
5231
|
var _getAssetsObject = getAssetsObject(node),
|
|
@@ -5275,25 +5285,59 @@ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currency
|
|
|
5275
5285
|
function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5276
5286
|
return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
|
|
5277
5287
|
}
|
|
5278
|
-
|
|
5288
|
+
// TODO: Refactor this function
|
|
5289
|
+
var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, to) {
|
|
5290
|
+
var serializedApiCallEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5279
5291
|
var paraId = getParaId(destination);
|
|
5280
5292
|
if (destination === 'Statemint' || destination === 'Statemine') {
|
|
5281
5293
|
// Same for Statemint, Statemine and Encoiter
|
|
5282
|
-
|
|
5294
|
+
var _serializedApiCall = {
|
|
5295
|
+
module: 'xcmPallet',
|
|
5296
|
+
section: 'limitedTeleportAssets',
|
|
5297
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', exports.Version.V3, paraId), handleAddress('RelayToPara', '', api, to, exports.Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', exports.Version.V3, destination), 0, 'Unlimited']
|
|
5298
|
+
};
|
|
5299
|
+
if (serializedApiCallEnabled) {
|
|
5300
|
+
return _serializedApiCall;
|
|
5301
|
+
}
|
|
5302
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall);
|
|
5283
5303
|
} else if (destination === 'Encointer') {
|
|
5284
|
-
|
|
5304
|
+
var _serializedApiCall2 = {
|
|
5305
|
+
module: 'xcmPallet',
|
|
5306
|
+
section: 'limitedTeleportAssets',
|
|
5307
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', exports.Version.V1, paraId), handleAddress('RelayToPara', '', api, to, exports.Version.V1, paraId), createCurrencySpecification(amount, 'RelayToPara', exports.Version.V1, destination), 0, 'Unlimited']
|
|
5308
|
+
};
|
|
5309
|
+
if (serializedApiCallEnabled) {
|
|
5310
|
+
return _serializedApiCall2;
|
|
5311
|
+
}
|
|
5312
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall2);
|
|
5285
5313
|
} else if (destination === 'Darwinia' || destination === 'Crab') {
|
|
5286
5314
|
// Do not do anything because Darwinia and Crab does not have DOT and KSM registered
|
|
5287
5315
|
throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
|
|
5288
5316
|
}
|
|
5289
|
-
|
|
5317
|
+
var serializedApiCall = {
|
|
5318
|
+
module: 'xcmPallet',
|
|
5319
|
+
section: 'reserveTransferAssets',
|
|
5320
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', exports.Version.V3, paraId), handleAddress('RelayToPara', '', api, to, exports.Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', exports.Version.V3, destination), 0]
|
|
5321
|
+
};
|
|
5322
|
+
if (serializedApiCallEnabled) {
|
|
5323
|
+
return serializedApiCall;
|
|
5324
|
+
}
|
|
5325
|
+
return callPolkadotJsTxFunction(api, serializedApiCall);
|
|
5326
|
+
};
|
|
5327
|
+
function transferRelayToPara(api, destination, amount, to) {
|
|
5328
|
+
return transferRelayToParaCommon(api, destination, amount, to);
|
|
5290
5329
|
}
|
|
5330
|
+
var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to) {
|
|
5331
|
+
return transferRelayToParaCommon(api, destination, amount, to, true);
|
|
5332
|
+
};
|
|
5291
5333
|
|
|
5292
5334
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
5293
5335
|
__proto__: null,
|
|
5294
5336
|
send: send,
|
|
5295
5337
|
sendSerializedApiCall: sendSerializedApiCall,
|
|
5296
|
-
transferRelayToPara: transferRelayToPara
|
|
5338
|
+
transferRelayToPara: transferRelayToPara,
|
|
5339
|
+
transferRelayToParaCommon: transferRelayToParaCommon,
|
|
5340
|
+
transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
|
|
5297
5341
|
});
|
|
5298
5342
|
|
|
5299
5343
|
//Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
|
|
@@ -5565,6 +5609,11 @@ var RelayToParaBuilder = /*#__PURE__*/function () {
|
|
|
5565
5609
|
value: function build() {
|
|
5566
5610
|
return transferRelayToPara(this.api, this.to, this._amount, this._address);
|
|
5567
5611
|
}
|
|
5612
|
+
}, {
|
|
5613
|
+
key: "buildSerializedApiCall",
|
|
5614
|
+
value: function buildSerializedApiCall() {
|
|
5615
|
+
return transferRelayToParaSerializedApiCall(this.api, this.to, this._amount, this._address);
|
|
5616
|
+
}
|
|
5568
5617
|
}], [{
|
|
5569
5618
|
key: "create",
|
|
5570
5619
|
value: function create(api, to) {
|
|
@@ -5725,11 +5774,10 @@ var ToGeneralBuilder = /*#__PURE__*/function () {
|
|
|
5725
5774
|
return ToGeneralBuilder;
|
|
5726
5775
|
}();
|
|
5727
5776
|
var FromGeneralBuilder = /*#__PURE__*/function () {
|
|
5728
|
-
function FromGeneralBuilder(api, from
|
|
5777
|
+
function FromGeneralBuilder(api, from) {
|
|
5729
5778
|
_classCallCheck(this, FromGeneralBuilder);
|
|
5730
5779
|
this.api = api;
|
|
5731
5780
|
this.from = from;
|
|
5732
|
-
this.version = version;
|
|
5733
5781
|
}
|
|
5734
5782
|
_createClass(FromGeneralBuilder, [{
|
|
5735
5783
|
key: "to",
|
|
@@ -5757,7 +5805,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5757
5805
|
_createClass(GeneralBuilder, [{
|
|
5758
5806
|
key: "from",
|
|
5759
5807
|
value: function from(node) {
|
|
5760
|
-
return new FromGeneralBuilder(this.api, node
|
|
5808
|
+
return new FromGeneralBuilder(this.api, node);
|
|
5761
5809
|
}
|
|
5762
5810
|
}, {
|
|
5763
5811
|
key: "to",
|
|
@@ -6234,8 +6282,12 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
6234
6282
|
};
|
|
6235
6283
|
|
|
6236
6284
|
exports.Builder = Builder;
|
|
6285
|
+
exports.InvalidCurrencyError = InvalidCurrencyError;
|
|
6237
6286
|
exports.NODE_NAMES = NODE_NAMES;
|
|
6287
|
+
exports.NoXCMSupportImplementedError = NoXCMSupportImplementedError;
|
|
6288
|
+
exports.NodeNotSupportedError = NodeNotSupportedError;
|
|
6238
6289
|
exports.SUPPORTED_PALLETS = SUPPORTED_PALLETS;
|
|
6290
|
+
exports.ScenarioNotSupportedError = ScenarioNotSupportedError;
|
|
6239
6291
|
exports.assets = index$4;
|
|
6240
6292
|
exports.closeChannels = index;
|
|
6241
6293
|
exports.getAllAssetsSymbols = getAllAssetsSymbols;
|
|
@@ -6244,6 +6296,7 @@ exports.getAssetId = getAssetId;
|
|
|
6244
6296
|
exports.getAssetsObject = getAssetsObject;
|
|
6245
6297
|
exports.getDefaultPallet = getDefaultPallet;
|
|
6246
6298
|
exports.getNativeAssets = getNativeAssets;
|
|
6299
|
+
exports.getNodeEndpointOption = getNodeEndpointOption;
|
|
6247
6300
|
exports.getOtherAssets = getOtherAssets;
|
|
6248
6301
|
exports.getParaId = getParaId;
|
|
6249
6302
|
exports.getRelayChainSymbol = getRelayChainSymbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ApiPromise } from '@polkadot/api';
|
|
2
2
|
import { SubmittableExtrinsic } from '@polkadot/api-base/types';
|
|
3
|
+
import * as _polkadot_apps_config_endpoints_types from '@polkadot/apps-config/endpoints/types';
|
|
3
4
|
|
|
4
5
|
declare const NODE_NAMES: readonly ["Statemint", "Acala", "Astar", "BifrostPolkadot", "Bitgreen", "Centrifuge", "Clover", "ComposableFinance", "Darwinia", "HydraDX", "Interlay", "Kylin", "Litentry", "Moonbeam", "Parallel", "Statemine", "Encointer", "Altair", "Amplitude", "Bajun", "Basilisk", "BifrostKusama", "Pioneer", "Calamari", "CrustShadow", "Crab", "Dorafactory", "Imbue", "Integritee", "InvArchTinker", "Karura", "Kico", "Kintsugi", "Litmus", "Mangata", "Moonriver", "ParallelHeiko", "Picasso", "Pichiu", "Quartz", "Robonomics", "Shiden", "Turing", "Equilibrium", "Unique", "Crust", "Efinity", "Ipci"];
|
|
5
6
|
declare const SUPPORTED_PALLETS: readonly ["XTokens", "OrmlXTokens", "PolkadotXcm", "RelayerXcm"];
|
|
@@ -34,13 +35,7 @@ type TPalletMap = {
|
|
|
34
35
|
supportedPallets: TPallet[];
|
|
35
36
|
};
|
|
36
37
|
type TPalletJsonMap = Record<TNode, TPalletMap>;
|
|
37
|
-
declare enum TType {
|
|
38
|
-
CONSTS = "consts",
|
|
39
|
-
QUERY = "query",
|
|
40
|
-
TX = "tx"
|
|
41
|
-
}
|
|
42
38
|
type TSerializedApiCall = {
|
|
43
|
-
type: TType;
|
|
44
39
|
module: string;
|
|
45
40
|
section: string;
|
|
46
41
|
parameters: any[];
|
|
@@ -75,16 +70,22 @@ declare enum Version {
|
|
|
75
70
|
|
|
76
71
|
declare const sendSerializedApiCall: (api: ApiPromise, origin: TNode, currencySymbolOrId: string | number | bigint, amount: any, to: string, destination?: TNode) => TSerializedApiCall;
|
|
77
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;
|
|
78
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;
|
|
79
76
|
|
|
80
77
|
declare const index$4_send: typeof send;
|
|
81
78
|
declare const index$4_sendSerializedApiCall: typeof sendSerializedApiCall;
|
|
82
79
|
declare const index$4_transferRelayToPara: typeof transferRelayToPara;
|
|
80
|
+
declare const index$4_transferRelayToParaCommon: typeof transferRelayToParaCommon;
|
|
81
|
+
declare const index$4_transferRelayToParaSerializedApiCall: typeof transferRelayToParaSerializedApiCall;
|
|
83
82
|
declare namespace index$4 {
|
|
84
83
|
export {
|
|
85
84
|
index$4_send as send,
|
|
86
85
|
index$4_sendSerializedApiCall as sendSerializedApiCall,
|
|
87
86
|
index$4_transferRelayToPara as transferRelayToPara,
|
|
87
|
+
index$4_transferRelayToParaCommon as transferRelayToParaCommon,
|
|
88
|
+
index$4_transferRelayToParaSerializedApiCall as transferRelayToParaSerializedApiCall,
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -248,6 +249,7 @@ interface AssetAAddLiquidityBuilder {
|
|
|
248
249
|
|
|
249
250
|
interface FinalRelayToParaBuilder$1 {
|
|
250
251
|
build(): Extrinsic | never;
|
|
252
|
+
buildSerializedApiCall(): TSerializedApiCall;
|
|
251
253
|
}
|
|
252
254
|
interface AddressRelayToParaBuilder {
|
|
253
255
|
address(address: string): FinalRelayToParaBuilder$1;
|
|
@@ -298,15 +300,13 @@ declare class ToGeneralBuilder {
|
|
|
298
300
|
declare class FromGeneralBuilder {
|
|
299
301
|
private api;
|
|
300
302
|
private from;
|
|
301
|
-
|
|
302
|
-
constructor(api: ApiPromise, from: TNode, version: number);
|
|
303
|
+
constructor(api: ApiPromise, from: TNode);
|
|
303
304
|
to(node: TNode): ToGeneralBuilder;
|
|
304
305
|
currency(currency: string | number | bigint): AmountSendBuilder;
|
|
305
306
|
closeChannel(): InboundCloseChannelBuilder;
|
|
306
307
|
}
|
|
307
308
|
declare class GeneralBuilder {
|
|
308
309
|
private api;
|
|
309
|
-
private version;
|
|
310
310
|
constructor(api: ApiPromise);
|
|
311
311
|
from(node: TNode): FromGeneralBuilder;
|
|
312
312
|
to(node: TNode): AmountRelayToParaBuilder;
|
|
@@ -321,4 +321,22 @@ declare function Builder(api: ApiPromise): GeneralBuilder;
|
|
|
321
321
|
declare const getDefaultPallet: (node: TNode) => TPallet;
|
|
322
322
|
declare const getSupportedPallets: (node: TNode) => TPallet[];
|
|
323
323
|
|
|
324
|
-
|
|
324
|
+
declare function getNodeEndpointOption(node: TNode): _polkadot_apps_config_endpoints_types.EndpointOption | undefined;
|
|
325
|
+
|
|
326
|
+
declare class InvalidCurrencyError extends Error {
|
|
327
|
+
constructor(message: string);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
declare class NodeNotSupportedError extends Error {
|
|
331
|
+
constructor(message: string);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
declare class NoXCMSupportImplementedError extends Error {
|
|
335
|
+
constructor(node: TNode);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare class ScenarioNotSupportedError extends Error {
|
|
339
|
+
constructor(node: TNode, scenario: TScenario);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export { Bool, Builder, Extrinsic, ExtrinsicFunction, IPolkadotXCMTransfer, IXTokensTransfer, 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
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import '@polkadot/api';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import '@polkadot/apps-config/endpoints';
|
|
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] : []))
|
|
@@ -5211,9 +5204,26 @@ function createHeaderPolkadotXCM(scenario, version, nodeId) {
|
|
|
5211
5204
|
function getNode(node) {
|
|
5212
5205
|
return nodes[node];
|
|
5213
5206
|
}
|
|
5207
|
+
function getNodeEndpointOption(node) {
|
|
5208
|
+
var _getNode = getNode(node),
|
|
5209
|
+
type = _getNode.type,
|
|
5210
|
+
name = _getNode.name;
|
|
5211
|
+
var _ref = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
|
|
5212
|
+
linked = _ref.linked;
|
|
5213
|
+
return linked ? linked.find(function (o) {
|
|
5214
|
+
return o.info === name;
|
|
5215
|
+
}) : undefined;
|
|
5216
|
+
}
|
|
5214
5217
|
var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
|
|
5215
5218
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5216
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
|
+
};
|
|
5217
5227
|
|
|
5218
5228
|
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
|
|
5219
5229
|
var _getAssetsObject = getAssetsObject(node),
|
|
@@ -5273,25 +5283,59 @@ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currency
|
|
|
5273
5283
|
function send(api, origin, currencySymbolOrId, amount, to, destination) {
|
|
5274
5284
|
return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
|
|
5275
5285
|
}
|
|
5276
|
-
|
|
5286
|
+
// TODO: Refactor this function
|
|
5287
|
+
var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, to) {
|
|
5288
|
+
var serializedApiCallEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5277
5289
|
var paraId = getParaId(destination);
|
|
5278
5290
|
if (destination === 'Statemint' || destination === 'Statemine') {
|
|
5279
5291
|
// Same for Statemint, Statemine and Encoiter
|
|
5280
|
-
|
|
5292
|
+
var _serializedApiCall = {
|
|
5293
|
+
module: 'xcmPallet',
|
|
5294
|
+
section: 'limitedTeleportAssets',
|
|
5295
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId), handleAddress('RelayToPara', '', api, to, Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination), 0, 'Unlimited']
|
|
5296
|
+
};
|
|
5297
|
+
if (serializedApiCallEnabled) {
|
|
5298
|
+
return _serializedApiCall;
|
|
5299
|
+
}
|
|
5300
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall);
|
|
5281
5301
|
} else if (destination === 'Encointer') {
|
|
5282
|
-
|
|
5302
|
+
var _serializedApiCall2 = {
|
|
5303
|
+
module: 'xcmPallet',
|
|
5304
|
+
section: 'limitedTeleportAssets',
|
|
5305
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V1, paraId), handleAddress('RelayToPara', '', api, to, Version.V1, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V1, destination), 0, 'Unlimited']
|
|
5306
|
+
};
|
|
5307
|
+
if (serializedApiCallEnabled) {
|
|
5308
|
+
return _serializedApiCall2;
|
|
5309
|
+
}
|
|
5310
|
+
return callPolkadotJsTxFunction(api, _serializedApiCall2);
|
|
5283
5311
|
} else if (destination === 'Darwinia' || destination === 'Crab') {
|
|
5284
5312
|
// Do not do anything because Darwinia and Crab does not have DOT and KSM registered
|
|
5285
5313
|
throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
|
|
5286
5314
|
}
|
|
5287
|
-
|
|
5315
|
+
var serializedApiCall = {
|
|
5316
|
+
module: 'xcmPallet',
|
|
5317
|
+
section: 'reserveTransferAssets',
|
|
5318
|
+
parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId), handleAddress('RelayToPara', '', api, to, Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination), 0]
|
|
5319
|
+
};
|
|
5320
|
+
if (serializedApiCallEnabled) {
|
|
5321
|
+
return serializedApiCall;
|
|
5322
|
+
}
|
|
5323
|
+
return callPolkadotJsTxFunction(api, serializedApiCall);
|
|
5324
|
+
};
|
|
5325
|
+
function transferRelayToPara(api, destination, amount, to) {
|
|
5326
|
+
return transferRelayToParaCommon(api, destination, amount, to);
|
|
5288
5327
|
}
|
|
5328
|
+
var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to) {
|
|
5329
|
+
return transferRelayToParaCommon(api, destination, amount, to, true);
|
|
5330
|
+
};
|
|
5289
5331
|
|
|
5290
5332
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
5291
5333
|
__proto__: null,
|
|
5292
5334
|
send: send,
|
|
5293
5335
|
sendSerializedApiCall: sendSerializedApiCall,
|
|
5294
|
-
transferRelayToPara: transferRelayToPara
|
|
5336
|
+
transferRelayToPara: transferRelayToPara,
|
|
5337
|
+
transferRelayToParaCommon: transferRelayToParaCommon,
|
|
5338
|
+
transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
|
|
5295
5339
|
});
|
|
5296
5340
|
|
|
5297
5341
|
//Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
|
|
@@ -5563,6 +5607,11 @@ var RelayToParaBuilder = /*#__PURE__*/function () {
|
|
|
5563
5607
|
value: function build() {
|
|
5564
5608
|
return transferRelayToPara(this.api, this.to, this._amount, this._address);
|
|
5565
5609
|
}
|
|
5610
|
+
}, {
|
|
5611
|
+
key: "buildSerializedApiCall",
|
|
5612
|
+
value: function buildSerializedApiCall() {
|
|
5613
|
+
return transferRelayToParaSerializedApiCall(this.api, this.to, this._amount, this._address);
|
|
5614
|
+
}
|
|
5566
5615
|
}], [{
|
|
5567
5616
|
key: "create",
|
|
5568
5617
|
value: function create(api, to) {
|
|
@@ -5723,11 +5772,10 @@ var ToGeneralBuilder = /*#__PURE__*/function () {
|
|
|
5723
5772
|
return ToGeneralBuilder;
|
|
5724
5773
|
}();
|
|
5725
5774
|
var FromGeneralBuilder = /*#__PURE__*/function () {
|
|
5726
|
-
function FromGeneralBuilder(api, from
|
|
5775
|
+
function FromGeneralBuilder(api, from) {
|
|
5727
5776
|
_classCallCheck(this, FromGeneralBuilder);
|
|
5728
5777
|
this.api = api;
|
|
5729
5778
|
this.from = from;
|
|
5730
|
-
this.version = version;
|
|
5731
5779
|
}
|
|
5732
5780
|
_createClass(FromGeneralBuilder, [{
|
|
5733
5781
|
key: "to",
|
|
@@ -5755,7 +5803,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
5755
5803
|
_createClass(GeneralBuilder, [{
|
|
5756
5804
|
key: "from",
|
|
5757
5805
|
value: function from(node) {
|
|
5758
|
-
return new FromGeneralBuilder(this.api, node
|
|
5806
|
+
return new FromGeneralBuilder(this.api, node);
|
|
5759
5807
|
}
|
|
5760
5808
|
}, {
|
|
5761
5809
|
key: "to",
|
|
@@ -6231,4 +6279,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
|
|
|
6231
6279
|
return palletsMap[node].supportedPallets;
|
|
6232
6280
|
};
|
|
6233
6281
|
|
|
6234
|
-
export { Builder, NODE_NAMES, SUPPORTED_PALLETS,
|
|
6282
|
+
export { Builder, 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 };
|