@paraspell/sdk-pjs 8.11.0 → 8.12.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
@@ -68,25 +68,17 @@ import { Native, Foreign, ForeignAbstract } from '@paraspell/sdk-pjs'; //Only ne
68
68
 
69
69
  ```
70
70
  NOTES:
71
- - If you wish to transfer from Parachain that uses long IDs for example Moonbeam you have to add the character 'n' to the end of currencyID. Eg: .currency({id: 42259045809535163221576417993425387648n}) will mean you transfer xcDOT.
72
- - You can now use custom ParachainIDs if you wish to test in TestNet. Just add parachainID as an additional parameter eg: .to('Basilisk', 2948).
73
- - POLKADOT <> KUSAMA Bridge is now available! Try sending DOT or KSM between AssetHubs - More information here: https://paraspell.github.io/docs/sdk/xcmPallet.html#ecosystem-bridges.
74
- - You can now customize XCM Version! Try using .xcmVersion parameter after address in builder.
75
- - POLKADOT <> ETHEREUM Bridge is now available! Try sending WETH between the ecosystems - More information here: https://paraspell.github.io/docs/sdk/xcmPallet.html#ecosystem-bridges.
76
- - 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"}.
77
- - 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')}.
78
- - The balance queries also support multilocation asset selection
79
- - You can now query foreign asset minimal deposits also.
80
- ```
81
-
82
- ```
83
- Latest news:
84
71
  - Since v8, amount moved closer to currency selection and specifying from and to parameters is no longer optional to save code.
85
72
  - More information on v8 major breaking change: https://github.com/paraspell/xcm-tools/pull/554
86
73
  - XCM SDK Now supports API Failsafe - If one endpoint doesn't work it automatically switches to the next one.
87
74
  - Builder now allows you to directly disconnect API.
88
75
  ```
89
76
 
77
+ ```
78
+ Latest news:
79
+ - Local transfers are now available for every currency and every chain. To try them, simply use same origin and destination parameters.
80
+ ```
81
+
90
82
  ### Builder pattern:
91
83
 
92
84
  ##### Transfer assets from Parachain to Parachain
@@ -231,6 +223,42 @@ import { hasDryRunSupport } from "@paraspell/sdk-pjs";
231
223
  const result = hasDryRunSupport(node)
232
224
  ```
233
225
 
226
+ ### XCM Fee (Origin and Dest.)
227
+ Following queries allow you to query fee from both Origin and Destination of the XCM Message. You can get accurate result from DryRun query(Requires token balance) or less accurate from Payment info query (Doesn't require token balance).
228
+
229
+ #### More accurate query using DryRun
230
+ The query is designed to retrieve you XCM fee at any cost, but fallbacking to Payment info if DryRun query fails or is not supported by either origin or destination. This query requires user to have token balance (Token that they are sending and origin native asset to pay for execution fees on origin).
231
+
232
+ ```
233
+ NOTICE: When Payment info query is performed, it retrieves fees for destination in destination's native currency, however, they are paid in currency that is being sent. To solve this, you have to convert token(native) to token(transferred) based on price. DryRun returns fees in currency that is being transferred, so no additional calculations necessary in that case.
234
+ ```
235
+
236
+ ```ts
237
+ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
238
+ .from(ORIGIN_CHAIN)
239
+ .to(DESTINATION_CHAIN)
240
+ .currency(CURRENCY)
241
+ .address(RECIPIENT_ADDRESS, SENDER_ADDRESS) // Both sender and recipient addresses are required!
242
+ .getXcmFee({disableFallback: true / false}) //When fallback is disabled, you only get notified of DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin or Destination chain do not support DryRun out of the box.
243
+ ```
244
+
245
+ #### Less accurate query using Payment info
246
+ This query is designed to retrieve you approximate fee and doesn't require any token balance.
247
+
248
+ ```
249
+ NOTICE: When Payment info query is performed, it retrieves fees for destination in destination's native currency, however, they are paid in currency that is being sent. To solve this, you have to convert token(native) to token(transferred) based on price.
250
+ ```
251
+
252
+ ```ts
253
+ const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
254
+ .from(ORIGIN_CHAIN)
255
+ .to(DESTINATION_CHAIN)
256
+ .currency(CURRENCY)
257
+ .address(RECIPIENT_ADDRESS, SENDER_ADDRESS) // Both sender and recipient addresses are required!
258
+ .getXcmFeeEstimate()
259
+ ```
260
+
261
+
234
262
  ### Asset claim:
235
263
  ```ts
236
264
  //Claim XCM trapped assets from the selected chain
@@ -246,6 +274,38 @@ const tx = await builder.build()
246
274
  await builder.disconnect()
247
275
  ```
248
276
 
277
+ ### Local transfers
278
+ ```ts
279
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
280
+ .from(NODE)
281
+ .to(NODE) //Has to be same as origin (from)
282
+ .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}})
283
+ .address(address)
284
+
285
+ const tx = await builder.build()
286
+
287
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
288
+ await builder.disconnect()
289
+
290
+ /*
291
+ EXAMPLE:
292
+ const builder = Builder()
293
+ .from('Hydration')
294
+ .to('Hydration')
295
+ .currency({
296
+ symbol: 'DOT',
297
+ amount: '1000000000'
298
+ })
299
+ .address(address)
300
+
301
+ const tx = await builder.build()
302
+
303
+ //Disconnect API after TX
304
+ await builder.disconnect()
305
+ */
306
+ ```
307
+
308
+
249
309
  ### Asset queries:
250
310
 
251
311
  ```ts