@paraspell/sdk 1.1.11 → 1.1.12

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 CHANGED
@@ -5,6 +5,12 @@ var ethers = require('ethers');
5
5
  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 = {}));
8
14
  exports.Version = void 0;
9
15
  (function (Version) {
10
16
  Version[Version["V1"] = 0] = "V1";
@@ -3719,6 +3725,7 @@ var ParachainNode = /*#__PURE__*/function () {
3719
3725
  }, {
3720
3726
  key: "transfer",
3721
3727
  value: function transfer(api, currencySymbol, currencyId, amount, to, destination) {
3728
+ var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
3722
3729
  var scenario = destination ? 'ParaToPara' : 'ParaToRelay';
3723
3730
  var paraId = destination ? getParaId(destination) : undefined;
3724
3731
  if (supportsXTokens(this)) {
@@ -3728,7 +3735,8 @@ var ParachainNode = /*#__PURE__*/function () {
3728
3735
  currencyID: currencyId,
3729
3736
  amount: amount,
3730
3737
  addressSelection: handleAddress(scenario, 'xTokens', api, to, this.version, paraId),
3731
- fees: getFees(scenario)
3738
+ fees: getFees(scenario),
3739
+ serializedApiCallEnabled: serializedApiCallEnabled
3732
3740
  });
3733
3741
  } else if (supportsPolkadotXCM(this)) {
3734
3742
  return this.transferPolkadotXCM({
@@ -3736,7 +3744,8 @@ var ParachainNode = /*#__PURE__*/function () {
3736
3744
  header: createHeaderPolkadotXCM(scenario, this.version, paraId),
3737
3745
  addressSelection: handleAddress(scenario, 'polkadotXCM', api, to, this.version, paraId),
3738
3746
  currencySelection: createCurrencySpecification(amount, scenario, this.version, this._node, currencyId),
3739
- scenario: scenario
3747
+ scenario: scenario,
3748
+ serializedApiCallEnabled: serializedApiCallEnabled
3740
3749
  });
3741
3750
  } else {
3742
3751
  throw new NoXCMSupportImplementedError(this._node);
@@ -3755,10 +3764,20 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
3755
3764
  value: function transferXTokens(_ref, currencySelection) {
3756
3765
  var api = _ref.api,
3757
3766
  amount = _ref.amount,
3758
- addressSelection = _ref.addressSelection;
3767
+ addressSelection = _ref.addressSelection,
3768
+ serializedApiCallEnabled = _ref.serializedApiCallEnabled;
3759
3769
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
3760
3770
  var pallet = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'XTokens';
3761
- return api.tx[lowercaseFirstLetter(pallet.toString())].transfer(currencySelection, amount, addressSelection, fees);
3771
+ var module = lowercaseFirstLetter(pallet.toString());
3772
+ if (serializedApiCallEnabled) {
3773
+ return {
3774
+ type: exports.TType.TX,
3775
+ module: module,
3776
+ section: 'transfer',
3777
+ parameters: [currencySelection, amount, addressSelection, fees]
3778
+ };
3779
+ }
3780
+ return api.tx[module].transfer(currencySelection, amount, addressSelection, fees);
3762
3781
  }
3763
3782
  }]);
3764
3783
  return XTokensTransferImpl;
@@ -4140,7 +4159,6 @@ var Basilisk$1 = /*#__PURE__*/function (_ParachainNode) {
4140
4159
  key: "transferXTokens",
4141
4160
  value: function transferXTokens(input) {
4142
4161
  var currencyID = input.currencyID;
4143
- input.fees;
4144
4162
  return XTokensTransferImpl.transferXTokens(input, currencyID);
4145
4163
  }
4146
4164
  }]);
@@ -4491,7 +4509,6 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
4491
4509
  return Karura;
4492
4510
  }(ParachainNode);
4493
4511
 
4494
- // Contains basic structure of polkadotXCM call
4495
4512
  var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
4496
4513
  function PolkadotXCMTransferImpl() {
4497
4514
  _classCallCheck(this, PolkadotXCMTransferImpl);
@@ -4502,8 +4519,17 @@ var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
4502
4519
  var api = _ref.api,
4503
4520
  header = _ref.header,
4504
4521
  addressSelection = _ref.addressSelection,
4505
- currencySelection = _ref.currencySelection;
4522
+ currencySelection = _ref.currencySelection,
4523
+ serializedApiCallEnabled = _ref.serializedApiCallEnabled;
4506
4524
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
4525
+ if (serializedApiCallEnabled) {
4526
+ return {
4527
+ type: exports.TType.TX,
4528
+ module: 'polkadotXcm',
4529
+ section: method,
4530
+ parameters: [header, addressSelection, currencySelection, 0].concat(_toConsumableArray(fees ? [fees] : []))
4531
+ };
4532
+ }
4507
4533
  return fees ? api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0, fees) : api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0);
4508
4534
  }
4509
4535
  }]);
@@ -5230,7 +5256,8 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
5230
5256
  }( /*#__PURE__*/_wrapNativeSuper(Error));
5231
5257
 
5232
5258
  // Contains basic call formatting for different XCM Palletss
5233
- function send(api, origin, currencySymbolOrId, amount, to, destination) {
5259
+ var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to, destination) {
5260
+ var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
5234
5261
  var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
5235
5262
  if (!asset) {
5236
5263
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
@@ -5240,7 +5267,13 @@ function send(api, origin, currencySymbolOrId, amount, to, destination) {
5240
5267
  }
5241
5268
  var currencySymbol = asset.symbol,
5242
5269
  currencyId = asset.assetId;
5243
- return getNode(origin).transfer(api, currencySymbol, currencyId, amount, to, destination);
5270
+ return getNode(origin).transfer(api, currencySymbol, currencyId, amount, to, destination, serializedApiCallEnabled);
5271
+ };
5272
+ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currencySymbolOrId, amount, to, destination) {
5273
+ return sendCommon(api, origin, currencySymbolOrId, amount, to, destination, true);
5274
+ };
5275
+ function send(api, origin, currencySymbolOrId, amount, to, destination) {
5276
+ return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
5244
5277
  }
5245
5278
  function transferRelayToPara(api, destination, amount, to) {
5246
5279
  var paraId = getParaId(destination);
@@ -5259,6 +5292,7 @@ function transferRelayToPara(api, destination, amount, to) {
5259
5292
  var index$3 = /*#__PURE__*/Object.freeze({
5260
5293
  __proto__: null,
5261
5294
  send: send,
5295
+ sendSerializedApiCall: sendSerializedApiCall,
5262
5296
  transferRelayToPara: transferRelayToPara
5263
5297
  });
5264
5298
 
@@ -5651,6 +5685,11 @@ var SendBuilder = /*#__PURE__*/function () {
5651
5685
  value: function build() {
5652
5686
  return send(this.api, this.from, this.currency, this._amount, this._address, this.to);
5653
5687
  }
5688
+ }, {
5689
+ key: "buildSerializedApiCall",
5690
+ value: function buildSerializedApiCall() {
5691
+ return sendSerializedApiCall(this.api, this.from, this.currency, this._amount, this._address, this.to);
5692
+ }
5654
5693
  }], [{
5655
5694
  key: "createParaToRelay",
5656
5695
  value: function createParaToRelay(api, from, currency) {
package/dist/index.d.ts CHANGED
@@ -34,6 +34,17 @@ type TPalletMap = {
34
34
  supportedPallets: TPallet[];
35
35
  };
36
36
  type TPalletJsonMap = Record<TNode, TPalletMap>;
37
+ declare enum TType {
38
+ CONSTS = "consts",
39
+ QUERY = "query",
40
+ TX = "tx"
41
+ }
42
+ type TSerializedApiCall = {
43
+ type: TType;
44
+ module: string;
45
+ section: string;
46
+ parameters: any[];
47
+ };
37
48
  type XTokensTransferInput = {
38
49
  api: ApiPromise;
39
50
  currency: string;
@@ -41,9 +52,10 @@ type XTokensTransferInput = {
41
52
  amount: any;
42
53
  addressSelection: any;
43
54
  fees: number;
55
+ serializedApiCallEnabled?: boolean;
44
56
  };
45
57
  interface IXTokensTransfer {
46
- transferXTokens(input: XTokensTransferInput): Extrinsic;
58
+ transferXTokens(input: XTokensTransferInput): Extrinsic | TSerializedApiCall;
47
59
  }
48
60
  type PolkadotXCMTransferInput = {
49
61
  api: ApiPromise;
@@ -51,23 +63,27 @@ type PolkadotXCMTransferInput = {
51
63
  addressSelection: any;
52
64
  currencySelection: any;
53
65
  scenario: TScenario;
66
+ serializedApiCallEnabled?: boolean;
54
67
  };
55
68
  interface IPolkadotXCMTransfer {
56
- transferPolkadotXCM(input: PolkadotXCMTransferInput): Extrinsic;
69
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Extrinsic | TSerializedApiCall;
57
70
  }
58
71
  declare enum Version {
59
72
  V1 = 0,
60
73
  V3 = 1
61
74
  }
62
75
 
76
+ declare const sendSerializedApiCall: (api: ApiPromise, origin: TNode, currencySymbolOrId: string | number | bigint, amount: any, to: string, destination?: TNode) => TSerializedApiCall;
63
77
  declare function send(api: ApiPromise, origin: TNode, currencySymbolOrId: string | number | bigint, amount: any, to: string, destination?: TNode): Extrinsic;
64
78
  declare function transferRelayToPara(api: ApiPromise, destination: TNode, amount: any, to: string): Extrinsic | never;
65
79
 
66
80
  declare const index$4_send: typeof send;
81
+ declare const index$4_sendSerializedApiCall: typeof sendSerializedApiCall;
67
82
  declare const index$4_transferRelayToPara: typeof transferRelayToPara;
68
83
  declare namespace index$4 {
69
84
  export {
70
85
  index$4_send as send,
86
+ index$4_sendSerializedApiCall as sendSerializedApiCall,
71
87
  index$4_transferRelayToPara as transferRelayToPara,
72
88
  };
73
89
  }
@@ -262,6 +278,7 @@ interface MaxSizeOpenChannelBuilder {
262
278
 
263
279
  interface FinalRelayToParaBuilder {
264
280
  build(): Extrinsic | never;
281
+ buildSerializedApiCall(): TSerializedApiCall;
265
282
  }
266
283
  interface AddressSendBuilder {
267
284
  address(address: string): FinalRelayToParaBuilder;
@@ -304,4 +321,4 @@ declare function Builder(api: ApiPromise): GeneralBuilder;
304
321
  declare const getDefaultPallet: (node: TNode) => TPallet;
305
322
  declare const getSupportedPallets: (node: TNode) => TPallet[];
306
323
 
307
- export { Bool, Builder, Extrinsic, ExtrinsicFunction, IPolkadotXCMTransfer, IXTokensTransfer, NODE_NAMES, PolkadotXCMTransferInput, SUPPORTED_PALLETS, TAssetDetails, TAssetJsonMap, TNativeAssetDetails, TNode, TNodeAssets, TPallet, TPalletJsonMap, TPalletMap, TRelayChainType, TScenario, UpdateFunction, Version, XTokensTransferInput, index as assets, index$1 as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$2 as openChannels, index$4 as xcmPallet, index$3 as xyk };
324
+ export { Bool, Builder, Extrinsic, ExtrinsicFunction, IPolkadotXCMTransfer, IXTokensTransfer, NODE_NAMES, PolkadotXCMTransferInput, SUPPORTED_PALLETS, TAssetDetails, TAssetJsonMap, TNativeAssetDetails, TNode, TNodeAssets, TPallet, TPalletJsonMap, TPalletMap, TRelayChainType, TScenario, TSerializedApiCall, TType, UpdateFunction, Version, XTokensTransferInput, index as assets, index$1 as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$2 as openChannels, index$4 as xcmPallet, index$3 as xyk };
package/dist/index.mjs CHANGED
@@ -3,6 +3,12 @@ import { ethers } from 'ethers';
3
3
  import '@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 = {}));
6
12
  var Version;
7
13
  (function (Version) {
8
14
  Version[Version["V1"] = 0] = "V1";
@@ -3717,6 +3723,7 @@ var ParachainNode = /*#__PURE__*/function () {
3717
3723
  }, {
3718
3724
  key: "transfer",
3719
3725
  value: function transfer(api, currencySymbol, currencyId, amount, to, destination) {
3726
+ var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
3720
3727
  var scenario = destination ? 'ParaToPara' : 'ParaToRelay';
3721
3728
  var paraId = destination ? getParaId(destination) : undefined;
3722
3729
  if (supportsXTokens(this)) {
@@ -3726,7 +3733,8 @@ var ParachainNode = /*#__PURE__*/function () {
3726
3733
  currencyID: currencyId,
3727
3734
  amount: amount,
3728
3735
  addressSelection: handleAddress(scenario, 'xTokens', api, to, this.version, paraId),
3729
- fees: getFees(scenario)
3736
+ fees: getFees(scenario),
3737
+ serializedApiCallEnabled: serializedApiCallEnabled
3730
3738
  });
3731
3739
  } else if (supportsPolkadotXCM(this)) {
3732
3740
  return this.transferPolkadotXCM({
@@ -3734,7 +3742,8 @@ var ParachainNode = /*#__PURE__*/function () {
3734
3742
  header: createHeaderPolkadotXCM(scenario, this.version, paraId),
3735
3743
  addressSelection: handleAddress(scenario, 'polkadotXCM', api, to, this.version, paraId),
3736
3744
  currencySelection: createCurrencySpecification(amount, scenario, this.version, this._node, currencyId),
3737
- scenario: scenario
3745
+ scenario: scenario,
3746
+ serializedApiCallEnabled: serializedApiCallEnabled
3738
3747
  });
3739
3748
  } else {
3740
3749
  throw new NoXCMSupportImplementedError(this._node);
@@ -3753,10 +3762,20 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
3753
3762
  value: function transferXTokens(_ref, currencySelection) {
3754
3763
  var api = _ref.api,
3755
3764
  amount = _ref.amount,
3756
- addressSelection = _ref.addressSelection;
3765
+ addressSelection = _ref.addressSelection,
3766
+ serializedApiCallEnabled = _ref.serializedApiCallEnabled;
3757
3767
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
3758
3768
  var pallet = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'XTokens';
3759
- return api.tx[lowercaseFirstLetter(pallet.toString())].transfer(currencySelection, amount, addressSelection, fees);
3769
+ var module = lowercaseFirstLetter(pallet.toString());
3770
+ if (serializedApiCallEnabled) {
3771
+ return {
3772
+ type: TType.TX,
3773
+ module: module,
3774
+ section: 'transfer',
3775
+ parameters: [currencySelection, amount, addressSelection, fees]
3776
+ };
3777
+ }
3778
+ return api.tx[module].transfer(currencySelection, amount, addressSelection, fees);
3760
3779
  }
3761
3780
  }]);
3762
3781
  return XTokensTransferImpl;
@@ -4138,7 +4157,6 @@ var Basilisk$1 = /*#__PURE__*/function (_ParachainNode) {
4138
4157
  key: "transferXTokens",
4139
4158
  value: function transferXTokens(input) {
4140
4159
  var currencyID = input.currencyID;
4141
- input.fees;
4142
4160
  return XTokensTransferImpl.transferXTokens(input, currencyID);
4143
4161
  }
4144
4162
  }]);
@@ -4489,7 +4507,6 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
4489
4507
  return Karura;
4490
4508
  }(ParachainNode);
4491
4509
 
4492
- // Contains basic structure of polkadotXCM call
4493
4510
  var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
4494
4511
  function PolkadotXCMTransferImpl() {
4495
4512
  _classCallCheck(this, PolkadotXCMTransferImpl);
@@ -4500,8 +4517,17 @@ var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
4500
4517
  var api = _ref.api,
4501
4518
  header = _ref.header,
4502
4519
  addressSelection = _ref.addressSelection,
4503
- currencySelection = _ref.currencySelection;
4520
+ currencySelection = _ref.currencySelection,
4521
+ serializedApiCallEnabled = _ref.serializedApiCallEnabled;
4504
4522
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
4523
+ if (serializedApiCallEnabled) {
4524
+ return {
4525
+ type: TType.TX,
4526
+ module: 'polkadotXcm',
4527
+ section: method,
4528
+ parameters: [header, addressSelection, currencySelection, 0].concat(_toConsumableArray(fees ? [fees] : []))
4529
+ };
4530
+ }
4505
4531
  return fees ? api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0, fees) : api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0);
4506
4532
  }
4507
4533
  }]);
@@ -5228,7 +5254,8 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
5228
5254
  }( /*#__PURE__*/_wrapNativeSuper(Error));
5229
5255
 
5230
5256
  // Contains basic call formatting for different XCM Palletss
5231
- function send(api, origin, currencySymbolOrId, amount, to, destination) {
5257
+ var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to, destination) {
5258
+ var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
5232
5259
  var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
5233
5260
  if (!asset) {
5234
5261
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
@@ -5238,7 +5265,13 @@ function send(api, origin, currencySymbolOrId, amount, to, destination) {
5238
5265
  }
5239
5266
  var currencySymbol = asset.symbol,
5240
5267
  currencyId = asset.assetId;
5241
- return getNode(origin).transfer(api, currencySymbol, currencyId, amount, to, destination);
5268
+ return getNode(origin).transfer(api, currencySymbol, currencyId, amount, to, destination, serializedApiCallEnabled);
5269
+ };
5270
+ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currencySymbolOrId, amount, to, destination) {
5271
+ return sendCommon(api, origin, currencySymbolOrId, amount, to, destination, true);
5272
+ };
5273
+ function send(api, origin, currencySymbolOrId, amount, to, destination) {
5274
+ return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
5242
5275
  }
5243
5276
  function transferRelayToPara(api, destination, amount, to) {
5244
5277
  var paraId = getParaId(destination);
@@ -5257,6 +5290,7 @@ function transferRelayToPara(api, destination, amount, to) {
5257
5290
  var index$3 = /*#__PURE__*/Object.freeze({
5258
5291
  __proto__: null,
5259
5292
  send: send,
5293
+ sendSerializedApiCall: sendSerializedApiCall,
5260
5294
  transferRelayToPara: transferRelayToPara
5261
5295
  });
5262
5296
 
@@ -5649,6 +5683,11 @@ var SendBuilder = /*#__PURE__*/function () {
5649
5683
  value: function build() {
5650
5684
  return send(this.api, this.from, this.currency, this._amount, this._address, this.to);
5651
5685
  }
5686
+ }, {
5687
+ key: "buildSerializedApiCall",
5688
+ value: function buildSerializedApiCall() {
5689
+ return sendSerializedApiCall(this.api, this.from, this.currency, this._amount, this._address, this.to);
5690
+ }
5652
5691
  }], [{
5653
5692
  key: "createParaToRelay",
5654
5693
  value: function createParaToRelay(api, from, currency) {
@@ -6192,4 +6231,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
6192
6231
  return palletsMap[node].supportedPallets;
6193
6232
  };
6194
6233
 
6195
- export { Builder, NODE_NAMES, SUPPORTED_PALLETS, Version, index$4 as assets, index as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$1 as openChannels, index$3 as xcmPallet, index$2 as xyk };
6234
+ export { Builder, NODE_NAMES, SUPPORTED_PALLETS, TType, Version, index$4 as assets, index as closeChannels, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, 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.11",
3
+ "version": "1.1.12",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",