@paraspell/sdk 8.0.3 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,32 +78,38 @@ NOTES:
78
78
  - ParaSpell now offers advanced asset symbol selection {symbol: "symbol"} for non duplicate assets, {symbol: Native("symbol")} or {symbol: Foreign("symbol")} if the duplicates are between native and foreign assets and {symbol: ForeignAbstract("symbol")} if the duplicates are in foreign assets only. You will get an error that will guide you further if you simply start with {symbol: "symbol"}.
79
79
  - You can now select assets by multilocation by simply using { multilocation: string | JSON }. The custom multilocation selection remains supported, but in order to use it you now have to use override - {multilocation: Override('Custom Multilocation')}.
80
80
  - The balance queries also support multilocation asset selection
81
+ - PAPI version of SDK is now fully PJS-less (We removed apps/config as dependency entirely).
82
+ - You can now query foreign asset minimal deposits also.
81
83
  ```
82
84
 
83
85
  ```
84
86
  Latest news:
85
- - PAPI version of SDK is now fully PJS-less (We removed apps/config as dependency entirely).
86
- - You can now query foreign asset minimal deposits also.
87
87
  - Since v8, amount moved closer to currency selection and specifying from and to parameters is no longer optional to save code.
88
88
  - More information on v8 major breaking change: https://github.com/paraspell/xcm-tools/pull/554
89
89
  - XCM SDK Now supports API Failsafe - If one endpoint doesn't work it automatically switches to the next one.
90
+ - Builder now allows you to directly disconnect API.
90
91
  ```
91
92
 
92
93
  ### Builder pattern:
93
94
 
94
95
  ##### Transfer assets from Parachain to Parachain
95
96
  ```ts
96
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
97
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
97
98
  .from(NODE)
98
99
  .to(NODE /*,customParaId - optional*/ | Multilocation object /*Only works for PolkadotXCM pallet*/)
99
100
  .currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
100
101
  .address(address | Multilocation object /*If you are sending through xTokens, you need to pass the destination and address multilocation in one object (x2)*/)
101
102
  /*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
102
103
  .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
103
- .build()
104
+
105
+ const tx = await builder.build()
106
+
107
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
108
+ await builder.disconnect()
109
+
104
110
  /*
105
111
  EXAMPLE:
106
- const tx = await Builder()
112
+ const builder = Builder()
107
113
  .from('Acala')
108
114
  .to('Astar')
109
115
  .currency({
@@ -111,22 +117,31 @@ const tx = await Builder()
111
117
  amount: '1000000000'
112
118
  })
113
119
  .address(address)
114
- .build();
120
+
121
+ const tx = await builder.build()
122
+
123
+ //Disconnect API after TX
124
+ await builder.disconnect()
115
125
  */
116
126
  ```
117
127
  ##### Transfer assets from the Relay chain to Parachain
118
128
  ```ts
119
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
129
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
120
130
  .from(RELAY_NODE) //Kusama or Polkadot
121
131
  .to(NODE/*,customParaId - optional*/ | Multilocation object)
122
132
  .currency({symbol: 'DOT', amount: amount})
123
133
  .address(address | Multilocation object)
124
134
  /*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
125
135
  .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
126
- .build()
136
+
137
+ const tx = await builder.build()
138
+
139
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
140
+ await builder.disconnect()
141
+
127
142
  /*
128
143
  EXAMPLE:
129
- const tx = await Builder()
144
+ const builder = await Builder()
130
145
  .from('Polkadot')
131
146
  .to('Astar')
132
147
  .currency({
@@ -134,22 +149,31 @@ const tx = await Builder()
134
149
  amount: '1000000000'
135
150
  })
136
151
  .address(address)
137
- .build();
152
+
153
+ const tx = await builder.build()
154
+
155
+ //Disconnect API after TX
156
+ await builder.disconnect()
138
157
  */
139
158
  ```
140
159
  ##### Transfer assets from Parachain to Relay chain
141
160
  ```ts
142
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
161
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
143
162
  .from(NODE)
144
163
  .to(RELAY_NODE) //Kusama or Polkadot
145
164
  .currency({symbol: 'DOT', amount: amount})
146
165
  .address(address | Multilocation object)
147
166
  /*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
148
167
  .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
149
- .build()
168
+
169
+ const tx = await builder.build()
170
+
171
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
172
+ await builder.disconnect()
173
+
150
174
  /*
151
175
  EXAMPLE:
152
- const tx = await Builder()
176
+ const builder = await Builder()
153
177
  .from('Astar')
154
178
  .to('Polkadot')
155
179
  .currency({
@@ -157,14 +181,18 @@ const tx = await Builder()
157
181
  amount: '1000000000'
158
182
  })
159
183
  .address(address)
160
- .build();
184
+
185
+ const tx = await builder.build()
186
+
187
+ //Disconnect API after TX
188
+ await builder.disconnect()
161
189
  */
162
190
  ```
163
191
 
164
192
  ##### Batch calls
165
193
  You can batch XCM calls and execute multiple XCM calls within one call. All three scenarios (Para->Para, Para->Relay, Relay->Para) can be used and combined.
166
194
  ```js
167
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
195
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
168
196
  .from(NODE) //Ensure, that origin node is the same in all batched XCM Calls.
169
197
  .to(NODE_2) //Any compatible Parachain
170
198
  .currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
@@ -176,10 +204,14 @@ await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
176
204
  .currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
177
205
  .address(address | Multilocation object)
178
206
  .addToBatch()
179
- .buildBatch({
207
+
208
+ const tx = await builder.buildBatch({
180
209
  // This settings object is optional and batch all is the default option
181
210
  mode: BatchMode.BATCH_ALL //or BatchMode.BATCH
182
211
  })
212
+
213
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
214
+ await builder.disconnect()
183
215
  ```
184
216
 
185
217
  ### Dry run your XCM Calls:
@@ -199,12 +231,16 @@ getDryRun({api /*optional*/, node, address, tx /* Extrinsic object */})
199
231
  ### Asset claim:
200
232
  ```ts
201
233
  //Claim XCM trapped assets from the selected chain
202
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
234
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
203
235
  .claimFrom(NODE)
204
236
  .fungible(MultilocationArray (Only one multilocation allowed) [{Multilocation}])
205
237
  .account(address | Multilocation object)
206
238
  /*.xcmVersion(Version.V3) Optional parameter, by default V3. XCM Version ENUM if a different XCM version is needed (Supported V2 & V3). Requires importing Version enum.*/
207
- .build()
239
+
240
+ const tx = await builder.build()
241
+
242
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
243
+ await builder.disconnect()
208
244
  ```
209
245
 
210
246
  ### Asset queries:
package/dist/index.cjs CHANGED
@@ -33,7 +33,7 @@ function _asyncToGenerator(n) {
33
33
  function _throw(n) {
34
34
  asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
35
35
  }
36
- _next(void 0);
36
+ _next(undefined);
37
37
  });
38
38
  };
39
39
  }
@@ -43,12 +43,12 @@ function _classCallCheck(a, n) {
43
43
  function _defineProperties(e, r) {
44
44
  for (var t = 0; t < r.length; t++) {
45
45
  var o = r[t];
46
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
46
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
47
47
  }
48
48
  }
49
49
  function _createClass(e, r, t) {
50
50
  return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
51
- writable: !1
51
+ writable: false
52
52
  }), e;
53
53
  }
54
54
  function _createForOfIteratorHelper(r, e) {
@@ -62,9 +62,9 @@ function _createForOfIteratorHelper(r, e) {
62
62
  s: F,
63
63
  n: function () {
64
64
  return n >= r.length ? {
65
- done: !0
65
+ done: true
66
66
  } : {
67
- done: !1,
67
+ done: false,
68
68
  value: r[n++]
69
69
  };
70
70
  },
@@ -77,8 +77,8 @@ function _createForOfIteratorHelper(r, e) {
77
77
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
78
78
  }
79
79
  var o,
80
- a = !0,
81
- u = !1;
80
+ a = true,
81
+ u = false;
82
82
  return {
83
83
  s: function () {
84
84
  t = t.call(r);
@@ -88,7 +88,7 @@ function _createForOfIteratorHelper(r, e) {
88
88
  return a = r.done, r;
89
89
  },
90
90
  e: function (r) {
91
- u = !0, o = r;
91
+ u = true, o = r;
92
92
  },
93
93
  f: function () {
94
94
  try {
@@ -102,9 +102,9 @@ function _createForOfIteratorHelper(r, e) {
102
102
  function _defineProperty(e, r, t) {
103
103
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
104
104
  value: t,
105
- enumerable: !0,
106
- configurable: !0,
107
- writable: !0
105
+ enumerable: true,
106
+ configurable: true,
107
+ writable: true
108
108
  }) : e[r] = t, e;
109
109
  }
110
110
  function _iterableToArrayLimit(r, l) {
@@ -115,12 +115,12 @@ function _iterableToArrayLimit(r, l) {
115
115
  i,
116
116
  u,
117
117
  a = [],
118
- f = !0,
119
- o = !1;
118
+ f = true,
119
+ o = false;
120
120
  try {
121
121
  if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
122
122
  } catch (r) {
123
- o = !0, n = r;
123
+ o = true, n = r;
124
124
  } finally {
125
125
  try {
126
126
  if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
@@ -147,7 +147,7 @@ function ownKeys(e, r) {
147
147
  function _objectSpread2(e) {
148
148
  for (var r = 1; r < arguments.length; r++) {
149
149
  var t = null != arguments[r] ? arguments[r] : {};
150
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
150
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
151
151
  _defineProperty(e, r, t[r]);
152
152
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
153
153
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -173,9 +173,9 @@ function _regeneratorRuntime() {
173
173
  function define(t, e, r) {
174
174
  return Object.defineProperty(t, e, {
175
175
  value: r,
176
- enumerable: !0,
177
- configurable: !0,
178
- writable: !0
176
+ enumerable: true,
177
+ configurable: true,
178
+ writable: true
179
179
  }), t[e];
180
180
  }
181
181
  try {
@@ -268,7 +268,7 @@ function _regeneratorRuntime() {
268
268
  if ("throw" === i) throw a;
269
269
  return {
270
270
  value: t,
271
- done: !0
271
+ done: true
272
272
  };
273
273
  }
274
274
  for (n.method = i, n.arg = a;;) {
@@ -319,7 +319,7 @@ function _regeneratorRuntime() {
319
319
  function Context(t) {
320
320
  this.tryEntries = [{
321
321
  tryLoc: "root"
322
- }], t.forEach(pushTryEntry, this), this.reset(!0);
322
+ }], t.forEach(pushTryEntry, this), this.reset(true);
323
323
  }
324
324
  function values(e) {
325
325
  if (e || "" === e) {
@@ -329,8 +329,8 @@ function _regeneratorRuntime() {
329
329
  if (!isNaN(e.length)) {
330
330
  var o = -1,
331
331
  i = function next() {
332
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
333
- return next.value = t, next.done = !0, next;
332
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
333
+ return next.value = t, next.done = true, next;
334
334
  };
335
335
  return i.next = i;
336
336
  }
@@ -339,10 +339,10 @@ function _regeneratorRuntime() {
339
339
  }
340
340
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
341
341
  value: GeneratorFunctionPrototype,
342
- configurable: !0
342
+ configurable: true
343
343
  }), o(GeneratorFunctionPrototype, "constructor", {
344
344
  value: GeneratorFunction,
345
- configurable: !0
345
+ configurable: true
346
346
  }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
347
347
  var e = "function" == typeof t && t.constructor;
348
348
  return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
@@ -355,7 +355,7 @@ function _regeneratorRuntime() {
355
355
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
356
356
  return this;
357
357
  }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
358
- void 0 === i && (i = Promise);
358
+ undefined === i && (i = Promise);
359
359
  var a = new AsyncIterator(wrap(t, r, n, o), i);
360
360
  return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
361
361
  return t.done ? t.value : a.next();
@@ -371,17 +371,17 @@ function _regeneratorRuntime() {
371
371
  return r.reverse(), function next() {
372
372
  for (; r.length;) {
373
373
  var t = r.pop();
374
- if (t in e) return next.value = t, next.done = !1, next;
374
+ if (t in e) return next.value = t, next.done = false, next;
375
375
  }
376
- return next.done = !0, next;
376
+ return next.done = true, next;
377
377
  };
378
378
  }, e.values = values, Context.prototype = {
379
379
  constructor: Context,
380
380
  reset: function (e) {
381
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
381
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
382
382
  },
383
383
  stop: function () {
384
- this.done = !0;
384
+ this.done = true;
385
385
  var t = this.tryEntries[0].completion;
386
386
  if ("throw" === t.type) throw t.arg;
387
387
  return this.rval;
@@ -400,10 +400,10 @@ function _regeneratorRuntime() {
400
400
  var c = n.call(i, "catchLoc"),
401
401
  u = n.call(i, "finallyLoc");
402
402
  if (c && u) {
403
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
403
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
404
404
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
405
405
  } else if (c) {
406
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
406
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
407
407
  } else {
408
408
  if (!u) throw Error("try statement without catch or finally");
409
409
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
@@ -462,7 +462,7 @@ function _slicedToArray(r, e) {
462
462
  function _toPrimitive(t, r) {
463
463
  if ("object" != typeof t || !t) return t;
464
464
  var e = t[Symbol.toPrimitive];
465
- if (void 0 !== e) {
465
+ if (undefined !== e) {
466
466
  var i = e.call(t, r);
467
467
  if ("object" != typeof i) return i;
468
468
  throw new TypeError("@@toPrimitive must return a primitive value.");
@@ -486,7 +486,7 @@ function _unsupportedIterableToArray(r, a) {
486
486
  if (r) {
487
487
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
488
488
  var t = {}.toString.call(r).slice(8, -1);
489
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
489
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
490
490
  }
491
491
  }
492
492
 
@@ -539,6 +539,9 @@ var _transform = function transform(obj) {
539
539
  return {
540
540
  type: key,
541
541
  value: {
542
+ network: value.network === 'any' ? {
543
+ type: 'Any'
544
+ } : undefined,
542
545
  key: polkadotApi.FixedSizeBinary.fromHex(value.key)
543
546
  }
544
547
  };
@@ -681,7 +684,7 @@ var PapiApi = /*#__PURE__*/function () {
681
684
  _context.next = 18;
682
685
  break;
683
686
  case 10:
684
- if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
687
+ if (!((_this$_api = this._api) !== null && _this$_api !== undefined)) {
685
688
  _context.next = 14;
686
689
  break;
687
690
  }
@@ -767,6 +770,16 @@ var PapiApi = /*#__PURE__*/function () {
767
770
  var transformedParameters = _transform(parameters);
768
771
  return this.api.getUnsafeApi().tx[module][section](transformedParameters);
769
772
  }
773
+ }, {
774
+ key: "callBatchMethod",
775
+ value: function callBatchMethod(calls, mode) {
776
+ var section = mode === sdkCore.BatchMode.BATCH_ALL ? 'batch_all' : 'batch';
777
+ return this.api.getUnsafeApi().tx.Utility[section]({
778
+ calls: calls.map(function (call) {
779
+ return call.decodedCall;
780
+ })
781
+ });
782
+ }
770
783
  }, {
771
784
  key: "calculateTransactionFee",
772
785
  value: function () {
@@ -984,9 +997,9 @@ var PapiApi = /*#__PURE__*/function () {
984
997
  var _keyArgs = _slicedToArray(keyArgs, 2);
985
998
  _keyArgs[0];
986
999
  var assetItem = _keyArgs[1];
987
- return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && sdkCore.isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
1000
+ return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === undefined ? undefined : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === undefined ? undefined : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === undefined ? undefined : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && sdkCore.isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === undefined ? undefined : _asset$assetId2.toLowerCase());
988
1001
  });
989
- return _context11.abrupt("return", entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1002
+ return _context11.abrupt("return", entry !== null && entry !== undefined && entry.value ? BigInt(entry.value.free.toString()) : 0n);
990
1003
  case 7:
991
1004
  case "end":
992
1005
  return _context11.stop();
@@ -1140,9 +1153,11 @@ var PapiApi = /*#__PURE__*/function () {
1140
1153
  }, {
1141
1154
  key: "disconnect",
1142
1155
  value: function disconnect() {
1143
- if (!this.disconnectAllowed) return Promise.resolve();
1156
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1157
+ if (!this.initialized) return Promise.resolve();
1158
+ if (!force && !this.disconnectAllowed) return Promise.resolve();
1144
1159
  // Disconnect api only if it was created automatically
1145
- if (typeof this._api === 'string' || this._api === undefined) {
1160
+ if (force || typeof this._api === 'string' || this._api === undefined) {
1146
1161
  this.api.destroy();
1147
1162
  }
1148
1163
  return Promise.resolve();
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
1
+ import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
4
4
  import { FixedSizeBinary, createClient } from 'polkadot-api';
@@ -32,7 +32,7 @@ function _asyncToGenerator(n) {
32
32
  function _throw(n) {
33
33
  asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
34
34
  }
35
- _next(void 0);
35
+ _next(undefined);
36
36
  });
37
37
  };
38
38
  }
@@ -42,12 +42,12 @@ function _classCallCheck(a, n) {
42
42
  function _defineProperties(e, r) {
43
43
  for (var t = 0; t < r.length; t++) {
44
44
  var o = r[t];
45
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
45
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
46
46
  }
47
47
  }
48
48
  function _createClass(e, r, t) {
49
49
  return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
50
- writable: !1
50
+ writable: false
51
51
  }), e;
52
52
  }
53
53
  function _createForOfIteratorHelper(r, e) {
@@ -61,9 +61,9 @@ function _createForOfIteratorHelper(r, e) {
61
61
  s: F,
62
62
  n: function () {
63
63
  return n >= r.length ? {
64
- done: !0
64
+ done: true
65
65
  } : {
66
- done: !1,
66
+ done: false,
67
67
  value: r[n++]
68
68
  };
69
69
  },
@@ -76,8 +76,8 @@ function _createForOfIteratorHelper(r, e) {
76
76
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
77
  }
78
78
  var o,
79
- a = !0,
80
- u = !1;
79
+ a = true,
80
+ u = false;
81
81
  return {
82
82
  s: function () {
83
83
  t = t.call(r);
@@ -87,7 +87,7 @@ function _createForOfIteratorHelper(r, e) {
87
87
  return a = r.done, r;
88
88
  },
89
89
  e: function (r) {
90
- u = !0, o = r;
90
+ u = true, o = r;
91
91
  },
92
92
  f: function () {
93
93
  try {
@@ -101,9 +101,9 @@ function _createForOfIteratorHelper(r, e) {
101
101
  function _defineProperty(e, r, t) {
102
102
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
103
103
  value: t,
104
- enumerable: !0,
105
- configurable: !0,
106
- writable: !0
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true
107
107
  }) : e[r] = t, e;
108
108
  }
109
109
  function _iterableToArrayLimit(r, l) {
@@ -114,12 +114,12 @@ function _iterableToArrayLimit(r, l) {
114
114
  i,
115
115
  u,
116
116
  a = [],
117
- f = !0,
118
- o = !1;
117
+ f = true,
118
+ o = false;
119
119
  try {
120
120
  if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
121
121
  } catch (r) {
122
- o = !0, n = r;
122
+ o = true, n = r;
123
123
  } finally {
124
124
  try {
125
125
  if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
@@ -146,7 +146,7 @@ function ownKeys(e, r) {
146
146
  function _objectSpread2(e) {
147
147
  for (var r = 1; r < arguments.length; r++) {
148
148
  var t = null != arguments[r] ? arguments[r] : {};
149
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
149
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
150
150
  _defineProperty(e, r, t[r]);
151
151
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
152
152
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -172,9 +172,9 @@ function _regeneratorRuntime() {
172
172
  function define(t, e, r) {
173
173
  return Object.defineProperty(t, e, {
174
174
  value: r,
175
- enumerable: !0,
176
- configurable: !0,
177
- writable: !0
175
+ enumerable: true,
176
+ configurable: true,
177
+ writable: true
178
178
  }), t[e];
179
179
  }
180
180
  try {
@@ -267,7 +267,7 @@ function _regeneratorRuntime() {
267
267
  if ("throw" === i) throw a;
268
268
  return {
269
269
  value: t,
270
- done: !0
270
+ done: true
271
271
  };
272
272
  }
273
273
  for (n.method = i, n.arg = a;;) {
@@ -318,7 +318,7 @@ function _regeneratorRuntime() {
318
318
  function Context(t) {
319
319
  this.tryEntries = [{
320
320
  tryLoc: "root"
321
- }], t.forEach(pushTryEntry, this), this.reset(!0);
321
+ }], t.forEach(pushTryEntry, this), this.reset(true);
322
322
  }
323
323
  function values(e) {
324
324
  if (e || "" === e) {
@@ -328,8 +328,8 @@ function _regeneratorRuntime() {
328
328
  if (!isNaN(e.length)) {
329
329
  var o = -1,
330
330
  i = function next() {
331
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
332
- return next.value = t, next.done = !0, next;
331
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
332
+ return next.value = t, next.done = true, next;
333
333
  };
334
334
  return i.next = i;
335
335
  }
@@ -338,10 +338,10 @@ function _regeneratorRuntime() {
338
338
  }
339
339
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
340
340
  value: GeneratorFunctionPrototype,
341
- configurable: !0
341
+ configurable: true
342
342
  }), o(GeneratorFunctionPrototype, "constructor", {
343
343
  value: GeneratorFunction,
344
- configurable: !0
344
+ configurable: true
345
345
  }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
346
346
  var e = "function" == typeof t && t.constructor;
347
347
  return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
@@ -354,7 +354,7 @@ function _regeneratorRuntime() {
354
354
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
355
355
  return this;
356
356
  }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
357
- void 0 === i && (i = Promise);
357
+ undefined === i && (i = Promise);
358
358
  var a = new AsyncIterator(wrap(t, r, n, o), i);
359
359
  return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
360
360
  return t.done ? t.value : a.next();
@@ -370,17 +370,17 @@ function _regeneratorRuntime() {
370
370
  return r.reverse(), function next() {
371
371
  for (; r.length;) {
372
372
  var t = r.pop();
373
- if (t in e) return next.value = t, next.done = !1, next;
373
+ if (t in e) return next.value = t, next.done = false, next;
374
374
  }
375
- return next.done = !0, next;
375
+ return next.done = true, next;
376
376
  };
377
377
  }, e.values = values, Context.prototype = {
378
378
  constructor: Context,
379
379
  reset: function (e) {
380
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
380
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
381
381
  },
382
382
  stop: function () {
383
- this.done = !0;
383
+ this.done = true;
384
384
  var t = this.tryEntries[0].completion;
385
385
  if ("throw" === t.type) throw t.arg;
386
386
  return this.rval;
@@ -399,10 +399,10 @@ function _regeneratorRuntime() {
399
399
  var c = n.call(i, "catchLoc"),
400
400
  u = n.call(i, "finallyLoc");
401
401
  if (c && u) {
402
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
402
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
403
403
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
404
404
  } else if (c) {
405
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
405
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
406
406
  } else {
407
407
  if (!u) throw Error("try statement without catch or finally");
408
408
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
@@ -461,7 +461,7 @@ function _slicedToArray(r, e) {
461
461
  function _toPrimitive(t, r) {
462
462
  if ("object" != typeof t || !t) return t;
463
463
  var e = t[Symbol.toPrimitive];
464
- if (void 0 !== e) {
464
+ if (undefined !== e) {
465
465
  var i = e.call(t, r);
466
466
  if ("object" != typeof i) return i;
467
467
  throw new TypeError("@@toPrimitive must return a primitive value.");
@@ -485,7 +485,7 @@ function _unsupportedIterableToArray(r, a) {
485
485
  if (r) {
486
486
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
487
487
  var t = {}.toString.call(r).slice(8, -1);
488
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
488
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
489
489
  }
490
490
  }
491
491
 
@@ -538,6 +538,9 @@ var _transform = function transform(obj) {
538
538
  return {
539
539
  type: key,
540
540
  value: {
541
+ network: value.network === 'any' ? {
542
+ type: 'Any'
543
+ } : undefined,
541
544
  key: FixedSizeBinary.fromHex(value.key)
542
545
  }
543
546
  };
@@ -680,7 +683,7 @@ var PapiApi = /*#__PURE__*/function () {
680
683
  _context.next = 18;
681
684
  break;
682
685
  case 10:
683
- if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
686
+ if (!((_this$_api = this._api) !== null && _this$_api !== undefined)) {
684
687
  _context.next = 14;
685
688
  break;
686
689
  }
@@ -766,6 +769,16 @@ var PapiApi = /*#__PURE__*/function () {
766
769
  var transformedParameters = _transform(parameters);
767
770
  return this.api.getUnsafeApi().tx[module][section](transformedParameters);
768
771
  }
772
+ }, {
773
+ key: "callBatchMethod",
774
+ value: function callBatchMethod(calls, mode) {
775
+ var section = mode === BatchMode.BATCH_ALL ? 'batch_all' : 'batch';
776
+ return this.api.getUnsafeApi().tx.Utility[section]({
777
+ calls: calls.map(function (call) {
778
+ return call.decodedCall;
779
+ })
780
+ });
781
+ }
769
782
  }, {
770
783
  key: "calculateTransactionFee",
771
784
  value: function () {
@@ -983,9 +996,9 @@ var PapiApi = /*#__PURE__*/function () {
983
996
  var _keyArgs = _slicedToArray(keyArgs, 2);
984
997
  _keyArgs[0];
985
998
  var assetItem = _keyArgs[1];
986
- return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
999
+ return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === undefined ? undefined : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === undefined ? undefined : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === undefined ? undefined : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === undefined ? undefined : _asset$assetId2.toLowerCase());
987
1000
  });
988
- return _context11.abrupt("return", entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1001
+ return _context11.abrupt("return", entry !== null && entry !== undefined && entry.value ? BigInt(entry.value.free.toString()) : 0n);
989
1002
  case 7:
990
1003
  case "end":
991
1004
  return _context11.stop();
@@ -1139,9 +1152,11 @@ var PapiApi = /*#__PURE__*/function () {
1139
1152
  }, {
1140
1153
  key: "disconnect",
1141
1154
  value: function disconnect() {
1142
- if (!this.disconnectAllowed) return Promise.resolve();
1155
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1156
+ if (!this.initialized) return Promise.resolve();
1157
+ if (!force && !this.disconnectAllowed) return Promise.resolve();
1143
1158
  // Disconnect api only if it was created automatically
1144
- if (typeof this._api === 'string' || this._api === undefined) {
1159
+ if (force || typeof this._api === 'string' || this._api === undefined) {
1145
1160
  this.api.destroy();
1146
1161
  }
1147
1162
  return Promise.resolve();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "8.0.3",
3
+ "version": "8.2.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,31 +23,31 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "ethers": "^6.13.4",
27
- "viem": "^2.21.58",
28
- "@paraspell/sdk-core": "8.0.3"
26
+ "ethers": "^6.13.5",
27
+ "viem": "^2.22.13",
28
+ "@paraspell/sdk-core": "8.2.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "polkadot-api": ">= 1.8.1 < 2"
31
+ "polkadot-api": ">= 1.8.4 < 2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.26.0",
35
- "@babel/preset-env": "^7.26.0",
36
- "@codecov/rollup-plugin": "^1.7.0",
37
- "@noble/curves": "^1.7.0",
38
- "@noble/hashes": "^1.6.1",
35
+ "@babel/preset-env": "^7.26.7",
36
+ "@codecov/rollup-plugin": "^1.8.0",
37
+ "@noble/curves": "^1.8.1",
38
+ "@noble/hashes": "^1.7.1",
39
39
  "@polkadot-labs/hdkd": "^0.0.10",
40
40
  "@polkadot-labs/hdkd-helpers": "^0.0.10",
41
41
  "@rollup/plugin-babel": "^6.0.4",
42
42
  "@rollup/plugin-json": "^6.1.0",
43
43
  "@rollup/plugin-typescript": "^12.1.2",
44
- "@scure/bip32": "^1.6.0",
45
- "@scure/bip39": "^1.5.0",
46
- "@vitest/coverage-v8": "^2.1.8",
44
+ "@scure/bip32": "^1.6.2",
45
+ "@scure/bip39": "^1.5.4",
46
+ "@vitest/coverage-v8": "^3.0.4",
47
47
  "axios": "^1.7.9",
48
48
  "dotenv": "^16.4.7",
49
49
  "prettier": "^3.4.2",
50
- "rollup": "^4.29.1",
50
+ "rollup": "^4.32.0",
51
51
  "rollup-plugin-dts": "^6.1.1",
52
52
  "tslib": "^2.8.1"
53
53
  },