@paraspell/sdk 8.0.3 → 8.1.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
@@ -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
  };
@@ -1140,9 +1143,11 @@ var PapiApi = /*#__PURE__*/function () {
1140
1143
  }, {
1141
1144
  key: "disconnect",
1142
1145
  value: function disconnect() {
1143
- if (!this.disconnectAllowed) return Promise.resolve();
1146
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1147
+ if (!this.initialized) return Promise.resolve();
1148
+ if (!force && !this.disconnectAllowed) return Promise.resolve();
1144
1149
  // Disconnect api only if it was created automatically
1145
- if (typeof this._api === 'string' || this._api === undefined) {
1150
+ if (force || typeof this._api === 'string' || this._api === undefined) {
1146
1151
  this.api.destroy();
1147
1152
  }
1148
1153
  return Promise.resolve();
package/dist/index.mjs CHANGED
@@ -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
  };
@@ -1139,9 +1142,11 @@ var PapiApi = /*#__PURE__*/function () {
1139
1142
  }, {
1140
1143
  key: "disconnect",
1141
1144
  value: function disconnect() {
1142
- if (!this.disconnectAllowed) return Promise.resolve();
1145
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1146
+ if (!this.initialized) return Promise.resolve();
1147
+ if (!force && !this.disconnectAllowed) return Promise.resolve();
1143
1148
  // Disconnect api only if it was created automatically
1144
- if (typeof this._api === 'string' || this._api === undefined) {
1149
+ if (force || typeof this._api === 'string' || this._api === undefined) {
1145
1150
  this.api.destroy();
1146
1151
  }
1147
1152
  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.1.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "ethers": "^6.13.4",
27
27
  "viem": "^2.21.58",
28
- "@paraspell/sdk-core": "8.0.3"
28
+ "@paraspell/sdk-core": "8.1.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "polkadot-api": ">= 1.8.1 < 2"