@paraspell/sdk 1.1.14 → 2.0.1

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 CHANGED
@@ -112,7 +112,7 @@ Builder(api).from(NODE).to(NODE).currency(CurrencyString||CurrencyID).amount(amo
112
112
  Builder(api).to(NODE).amount(amount).address(address).build()
113
113
 
114
114
  //Transfer tokens from Parachain to Relay chain
115
- Builder(api).from(NODE).currency(CurrencyString||CurrencyID).amount(amount).address(address).build()
115
+ Builder(api).from(NODE).amount(amount).address(address).build()
116
116
 
117
117
  //Close HRMP channels
118
118
  Builder(api).from(NODE).closeChannel().inbound(inbound).outbound(outbound).build()
@@ -130,7 +130,7 @@ Function pattern XCM & HRMP construction
130
130
  paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency: CurrencyString||CurrencyID, amount: any, to: destination address string, destination: destination Parachain ID)
131
131
 
132
132
  //Transfer tokens from Parachain to Relay chain
133
- paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency: CurrencyString||CurrencyID, amount: any, to: destination address string)
133
+ paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, amount: any, to: destination address string)
134
134
 
135
135
  //Transfer tokens from Relay chain to Parachain
136
136
  paraspell.xcmPallet.transferRelayToPara(api: ApiPromise, destination: destination Parachain ID, amount: any, to: destination address string)
package/dist/index.cjs CHANGED
@@ -3781,7 +3781,7 @@ var Acala$1 = /*#__PURE__*/function (_ParachainNode) {
3781
3781
  var _super = _createSuper(Acala);
3782
3782
  function Acala() {
3783
3783
  _classCallCheck(this, Acala);
3784
- return _super.call(this, 'Acala', 'acala', 'polkadot', exports.Version.V1);
3784
+ return _super.call(this, 'Acala', 'acala', 'polkadot', exports.Version.V3);
3785
3785
  }
3786
3786
  _createClass(Acala, [{
3787
3787
  key: "transferXTokens",
@@ -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
  }
@@ -5709,15 +5729,15 @@ var SellBuilder = /*#__PURE__*/function () {
5709
5729
  return SellBuilder;
5710
5730
  }();
5711
5731
 
5712
- var SendBuilder = /*#__PURE__*/function () {
5713
- function SendBuilder(api, from, to, currency) {
5714
- _classCallCheck(this, SendBuilder);
5732
+ var ParaToParaBuilder = /*#__PURE__*/function () {
5733
+ function ParaToParaBuilder(api, from, to, currency) {
5734
+ _classCallCheck(this, ParaToParaBuilder);
5715
5735
  this.api = api;
5716
5736
  this.from = from;
5717
5737
  this.to = to;
5718
5738
  this.currency = currency;
5719
5739
  }
5720
- _createClass(SendBuilder, [{
5740
+ _createClass(ParaToParaBuilder, [{
5721
5741
  key: "amount",
5722
5742
  value: function amount(_amount) {
5723
5743
  this._amount = _amount;
@@ -5740,17 +5760,46 @@ var SendBuilder = /*#__PURE__*/function () {
5740
5760
  return sendSerializedApiCall(this.api, this.from, this.currency, this._amount, this._address, this.to);
5741
5761
  }
5742
5762
  }], [{
5743
- key: "createParaToRelay",
5744
- value: function createParaToRelay(api, from, currency) {
5745
- return new SendBuilder(api, from, undefined, currency);
5746
- }
5747
- }, {
5748
5763
  key: "createParaToPara",
5749
5764
  value: function createParaToPara(api, from, to, currency) {
5750
- return new SendBuilder(api, from, to, currency);
5765
+ return new ParaToParaBuilder(api, from, to, currency);
5766
+ }
5767
+ }]);
5768
+ return ParaToParaBuilder;
5769
+ }();
5770
+
5771
+ var ParaToRelayBuilder = /*#__PURE__*/function () {
5772
+ function ParaToRelayBuilder(api, from, amount) {
5773
+ _classCallCheck(this, ParaToRelayBuilder);
5774
+ this.api = api;
5775
+ this.from = from;
5776
+ this.amount = amount;
5777
+ }
5778
+ _createClass(ParaToRelayBuilder, [{
5779
+ key: "address",
5780
+ value: function address(_address) {
5781
+ this._address = _address;
5782
+ return this;
5783
+ }
5784
+ }, {
5785
+ key: "build",
5786
+ value: function build() {
5787
+ var currency = getRelayChainSymbol(this.from);
5788
+ return send(this.api, this.from, currency, this.amount, this._address);
5789
+ }
5790
+ }, {
5791
+ key: "buildSerializedApiCall",
5792
+ value: function buildSerializedApiCall() {
5793
+ var currency = getRelayChainSymbol(this.from);
5794
+ return sendSerializedApiCall(this.api, this.from, currency, this.amount, this._address);
5795
+ }
5796
+ }], [{
5797
+ key: "create",
5798
+ value: function create(api, from, amount) {
5799
+ return new ParaToRelayBuilder(api, from, amount);
5751
5800
  }
5752
5801
  }]);
5753
- return SendBuilder;
5802
+ return ParaToRelayBuilder;
5754
5803
  }();
5755
5804
 
5756
5805
  var ToGeneralBuilder = /*#__PURE__*/function () {
@@ -5763,7 +5812,7 @@ var ToGeneralBuilder = /*#__PURE__*/function () {
5763
5812
  _createClass(ToGeneralBuilder, [{
5764
5813
  key: "currency",
5765
5814
  value: function currency(_currency) {
5766
- return SendBuilder.createParaToPara(this.api, this.from, this.to, _currency);
5815
+ return ParaToParaBuilder.createParaToPara(this.api, this.from, this.to, _currency);
5767
5816
  }
5768
5817
  }, {
5769
5818
  key: "openChannel",
@@ -5785,9 +5834,9 @@ var FromGeneralBuilder = /*#__PURE__*/function () {
5785
5834
  return new ToGeneralBuilder(this.api, this.from, node);
5786
5835
  }
5787
5836
  }, {
5788
- key: "currency",
5789
- value: function currency(_currency2) {
5790
- return SendBuilder.createParaToRelay(this.api, this.from, _currency2);
5837
+ key: "amount",
5838
+ value: function amount(_amount) {
5839
+ return ParaToRelayBuilder.create(this.api, this.from, _amount);
5791
5840
  }
5792
5841
  }, {
5793
5842
  key: "closeChannel",
@@ -6282,6 +6331,7 @@ var getSupportedPallets = function getSupportedPallets(node) {
6282
6331
  };
6283
6332
 
6284
6333
  exports.Builder = Builder;
6334
+ exports.IncompatibleNodesError = IncompatibleNodesError;
6285
6335
  exports.InvalidCurrencyError = InvalidCurrencyError;
6286
6336
  exports.NODE_NAMES = NODE_NAMES;
6287
6337
  exports.NoXCMSupportImplementedError = NoXCMSupportImplementedError;
package/dist/index.d.ts CHANGED
@@ -247,17 +247,6 @@ interface AssetAAddLiquidityBuilder {
247
247
  assetA(assetA: number): AssetBAddLiquidityBuilder;
248
248
  }
249
249
 
250
- interface FinalRelayToParaBuilder$1 {
251
- build(): Extrinsic | never;
252
- buildSerializedApiCall(): TSerializedApiCall;
253
- }
254
- interface AddressRelayToParaBuilder {
255
- address(address: string): FinalRelayToParaBuilder$1;
256
- }
257
- interface AmountRelayToParaBuilder {
258
- amount(amount: number): AddressRelayToParaBuilder;
259
- }
260
-
261
250
  interface FinalCloseChannelBuilder {
262
251
  build(): Extrinsic;
263
252
  }
@@ -278,23 +267,12 @@ interface MaxSizeOpenChannelBuilder {
278
267
  maxSize(size: number): MaxMessageSizeOpenChannelBuilder;
279
268
  }
280
269
 
281
- interface FinalRelayToParaBuilder {
282
- build(): Extrinsic | never;
283
- buildSerializedApiCall(): TSerializedApiCall;
284
- }
285
- interface AddressSendBuilder {
286
- address(address: string): FinalRelayToParaBuilder;
287
- }
288
- interface AmountSendBuilder {
289
- amount(amount: any): AddressSendBuilder;
290
- }
291
-
292
270
  declare class ToGeneralBuilder {
293
271
  private api;
294
272
  private from;
295
273
  private to;
296
274
  constructor(api: ApiPromise, from: TNode, to: TNode);
297
- currency(currency: string | number | bigint): AmountSendBuilder;
275
+ currency(currency: string | number | bigint): AmountBuilder;
298
276
  openChannel(): MaxSizeOpenChannelBuilder;
299
277
  }
300
278
  declare class FromGeneralBuilder {
@@ -302,14 +280,14 @@ declare class FromGeneralBuilder {
302
280
  private from;
303
281
  constructor(api: ApiPromise, from: TNode);
304
282
  to(node: TNode): ToGeneralBuilder;
305
- currency(currency: string | number | bigint): AmountSendBuilder;
283
+ amount(amount: any): AddressBuilder;
306
284
  closeChannel(): InboundCloseChannelBuilder;
307
285
  }
308
286
  declare class GeneralBuilder {
309
287
  private api;
310
288
  constructor(api: ApiPromise);
311
289
  from(node: TNode): FromGeneralBuilder;
312
- to(node: TNode): AmountRelayToParaBuilder;
290
+ to(node: TNode): AmountBuilder;
313
291
  addLiquidity(): AssetAAddLiquidityBuilder;
314
292
  removeLiquidity(): AssetARemoveLiquidityBuilder;
315
293
  buy(): AssetOutBuyBuilder;
@@ -317,6 +295,16 @@ declare class GeneralBuilder {
317
295
  createPool(): AssetACreatePoolBuilder;
318
296
  }
319
297
  declare function Builder(api: ApiPromise): GeneralBuilder;
298
+ interface FinalBuilder {
299
+ build(): Extrinsic | never;
300
+ buildSerializedApiCall(): TSerializedApiCall;
301
+ }
302
+ interface AddressBuilder {
303
+ address(address: string): FinalBuilder;
304
+ }
305
+ interface AmountBuilder {
306
+ amount(amount: any): AddressBuilder;
307
+ }
320
308
 
321
309
  declare const getDefaultPallet: (node: TNode) => TPallet;
322
310
  declare const getSupportedPallets: (node: TNode) => TPallet[];
@@ -339,4 +327,8 @@ declare class ScenarioNotSupportedError extends Error {
339
327
  constructor(node: TNode, scenario: TScenario);
340
328
  }
341
329
 
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 };
330
+ declare class IncompatibleNodesError extends Error {
331
+ constructor();
332
+ }
333
+
334
+ 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
@@ -3779,7 +3779,7 @@ var Acala$1 = /*#__PURE__*/function (_ParachainNode) {
3779
3779
  var _super = _createSuper(Acala);
3780
3780
  function Acala() {
3781
3781
  _classCallCheck(this, Acala);
3782
- return _super.call(this, 'Acala', 'acala', 'polkadot', Version.V1);
3782
+ return _super.call(this, 'Acala', 'acala', 'polkadot', Version.V3);
3783
3783
  }
3784
3784
  _createClass(Acala, [{
3785
3785
  key: "transferXTokens",
@@ -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
  }
@@ -5707,15 +5727,15 @@ var SellBuilder = /*#__PURE__*/function () {
5707
5727
  return SellBuilder;
5708
5728
  }();
5709
5729
 
5710
- var SendBuilder = /*#__PURE__*/function () {
5711
- function SendBuilder(api, from, to, currency) {
5712
- _classCallCheck(this, SendBuilder);
5730
+ var ParaToParaBuilder = /*#__PURE__*/function () {
5731
+ function ParaToParaBuilder(api, from, to, currency) {
5732
+ _classCallCheck(this, ParaToParaBuilder);
5713
5733
  this.api = api;
5714
5734
  this.from = from;
5715
5735
  this.to = to;
5716
5736
  this.currency = currency;
5717
5737
  }
5718
- _createClass(SendBuilder, [{
5738
+ _createClass(ParaToParaBuilder, [{
5719
5739
  key: "amount",
5720
5740
  value: function amount(_amount) {
5721
5741
  this._amount = _amount;
@@ -5738,17 +5758,46 @@ var SendBuilder = /*#__PURE__*/function () {
5738
5758
  return sendSerializedApiCall(this.api, this.from, this.currency, this._amount, this._address, this.to);
5739
5759
  }
5740
5760
  }], [{
5741
- key: "createParaToRelay",
5742
- value: function createParaToRelay(api, from, currency) {
5743
- return new SendBuilder(api, from, undefined, currency);
5744
- }
5745
- }, {
5746
5761
  key: "createParaToPara",
5747
5762
  value: function createParaToPara(api, from, to, currency) {
5748
- return new SendBuilder(api, from, to, currency);
5763
+ return new ParaToParaBuilder(api, from, to, currency);
5764
+ }
5765
+ }]);
5766
+ return ParaToParaBuilder;
5767
+ }();
5768
+
5769
+ var ParaToRelayBuilder = /*#__PURE__*/function () {
5770
+ function ParaToRelayBuilder(api, from, amount) {
5771
+ _classCallCheck(this, ParaToRelayBuilder);
5772
+ this.api = api;
5773
+ this.from = from;
5774
+ this.amount = amount;
5775
+ }
5776
+ _createClass(ParaToRelayBuilder, [{
5777
+ key: "address",
5778
+ value: function address(_address) {
5779
+ this._address = _address;
5780
+ return this;
5781
+ }
5782
+ }, {
5783
+ key: "build",
5784
+ value: function build() {
5785
+ var currency = getRelayChainSymbol(this.from);
5786
+ return send(this.api, this.from, currency, this.amount, this._address);
5787
+ }
5788
+ }, {
5789
+ key: "buildSerializedApiCall",
5790
+ value: function buildSerializedApiCall() {
5791
+ var currency = getRelayChainSymbol(this.from);
5792
+ return sendSerializedApiCall(this.api, this.from, currency, this.amount, this._address);
5793
+ }
5794
+ }], [{
5795
+ key: "create",
5796
+ value: function create(api, from, amount) {
5797
+ return new ParaToRelayBuilder(api, from, amount);
5749
5798
  }
5750
5799
  }]);
5751
- return SendBuilder;
5800
+ return ParaToRelayBuilder;
5752
5801
  }();
5753
5802
 
5754
5803
  var ToGeneralBuilder = /*#__PURE__*/function () {
@@ -5761,7 +5810,7 @@ var ToGeneralBuilder = /*#__PURE__*/function () {
5761
5810
  _createClass(ToGeneralBuilder, [{
5762
5811
  key: "currency",
5763
5812
  value: function currency(_currency) {
5764
- return SendBuilder.createParaToPara(this.api, this.from, this.to, _currency);
5813
+ return ParaToParaBuilder.createParaToPara(this.api, this.from, this.to, _currency);
5765
5814
  }
5766
5815
  }, {
5767
5816
  key: "openChannel",
@@ -5783,9 +5832,9 @@ var FromGeneralBuilder = /*#__PURE__*/function () {
5783
5832
  return new ToGeneralBuilder(this.api, this.from, node);
5784
5833
  }
5785
5834
  }, {
5786
- key: "currency",
5787
- value: function currency(_currency2) {
5788
- return SendBuilder.createParaToRelay(this.api, this.from, _currency2);
5835
+ key: "amount",
5836
+ value: function amount(_amount) {
5837
+ return ParaToRelayBuilder.create(this.api, this.from, _amount);
5789
5838
  }
5790
5839
  }, {
5791
5840
  key: "closeChannel",
@@ -6279,4 +6328,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
6279
6328
  return palletsMap[node].supportedPallets;
6280
6329
  };
6281
6330
 
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 };
6331
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "1.1.14",
3
+ "version": "2.0.1",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",