@paraspell/sdk 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 +75 -15
- package/dist/index.cjs +358 -302
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +358 -302
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -70,26 +70,19 @@ import { Native, Foreign, ForeignAbstract } from '@paraspell/sdk'; //Only needed
|
|
|
70
70
|
|
|
71
71
|
```
|
|
72
72
|
NOTES:
|
|
73
|
-
- 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.
|
|
74
|
-
- You can now use custom ParachainIDs if you wish to test in TestNet. Just add parachainID as an additional parameter eg: .to('Basilisk', 2948).
|
|
75
|
-
- 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.
|
|
76
|
-
- You can now customize XCM Version! Try using .xcmVersion parameter after address in builder.
|
|
77
|
-
- 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.
|
|
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
|
-
- 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
|
-
- The balance queries also support multilocation asset selection
|
|
81
73
|
- PAPI version of SDK is now fully PJS-less (We removed apps/config as dependency entirely).
|
|
82
74
|
- You can now query foreign asset minimal deposits also.
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
Latest news:
|
|
87
75
|
- Since v8, amount moved closer to currency selection and specifying from and to parameters is no longer optional to save code.
|
|
88
76
|
- More information on v8 major breaking change: https://github.com/paraspell/xcm-tools/pull/554
|
|
89
77
|
- XCM SDK Now supports API Failsafe - If one endpoint doesn't work it automatically switches to the next one.
|
|
90
78
|
- Builder now allows you to directly disconnect API.
|
|
91
79
|
```
|
|
92
80
|
|
|
81
|
+
```
|
|
82
|
+
Latest news:
|
|
83
|
+
- Local transfers are now available for every currency and every chain. To try them, simply use same origin and destination parameters.
|
|
84
|
+
```
|
|
85
|
+
|
|
93
86
|
### Builder pattern:
|
|
94
87
|
|
|
95
88
|
##### Transfer assets from Parachain to Parachain
|
|
@@ -99,7 +92,8 @@ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
99
92
|
.to(NODE /*,customParaId - optional*/ | Multilocation object /*Only works for PolkadotXCM pallet*/)
|
|
100
93
|
.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}})
|
|
101
94
|
.address(address | Multilocation object /*If you are sending through xTokens, you need to pass the destination and address multilocation in one object (x2)*/, /*senderAddress - OPTIONAL - used when origin is AssetHub and feeAsset parameter is provided*/)
|
|
102
|
-
/*.
|
|
95
|
+
/*.feeAsset({symbol: 'symbol'} || {id: 'id'} || {multilocation: 'multilocation'}) // Optional parameter used when multiasset is provided or when origin is AssetHub - so user can pay in fees different than DOT
|
|
96
|
+
.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
|
|
103
97
|
.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.*/
|
|
104
98
|
|
|
105
99
|
const tx = await builder.build()
|
|
@@ -131,8 +125,7 @@ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
131
125
|
.to(NODE/*,customParaId - optional*/ | Multilocation object)
|
|
132
126
|
.currency({symbol: 'DOT', amount: amount})
|
|
133
127
|
.address(address | Multilocation object)
|
|
134
|
-
|
|
135
|
-
.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
|
|
128
|
+
/*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
|
|
136
129
|
.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.*/
|
|
137
130
|
|
|
138
131
|
const tx = await builder.build()
|
|
@@ -234,6 +227,42 @@ import { hasDryRunSupport } from "@paraspell/sdk-pjs";
|
|
|
234
227
|
const result = hasDryRunSupport(node)
|
|
235
228
|
```
|
|
236
229
|
|
|
230
|
+
### XCM Fee (Origin and Dest.)
|
|
231
|
+
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).
|
|
232
|
+
|
|
233
|
+
#### More accurate query using DryRun
|
|
234
|
+
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).
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
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.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
242
|
+
.from(ORIGIN_CHAIN)
|
|
243
|
+
.to(DESTINATION_CHAIN)
|
|
244
|
+
.currency(CURRENCY)
|
|
245
|
+
.address(RECIPIENT_ADDRESS, SENDER_ADDRESS) // Both sender and recipient addresses are required!
|
|
246
|
+
.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.
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Less accurate query using Payment info
|
|
250
|
+
This query is designed to retrieve you approximate fee and doesn't require any token balance.
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
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.
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
const fee = await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
258
|
+
.from(ORIGIN_CHAIN)
|
|
259
|
+
.to(DESTINATION_CHAIN)
|
|
260
|
+
.currency(CURRENCY)
|
|
261
|
+
.address(RECIPIENT_ADDRESS, SENDER_ADDRESS) // Both sender and recipient addresses are required!
|
|
262
|
+
.getXcmFeeEstimate()
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
|
|
237
266
|
### Asset claim:
|
|
238
267
|
```ts
|
|
239
268
|
//Claim XCM trapped assets from the selected chain
|
|
@@ -249,6 +278,37 @@ const tx = await builder.build()
|
|
|
249
278
|
await builder.disconnect()
|
|
250
279
|
```
|
|
251
280
|
|
|
281
|
+
### Local transfers
|
|
282
|
+
```ts
|
|
283
|
+
const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
284
|
+
.from(NODE)
|
|
285
|
+
.to(NODE) //Has to be same as origin (from)
|
|
286
|
+
.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}})
|
|
287
|
+
.address(address)
|
|
288
|
+
|
|
289
|
+
const tx = await builder.build()
|
|
290
|
+
|
|
291
|
+
//Make sure to disconnect API after it is no longer used (eg. after transaction)
|
|
292
|
+
await builder.disconnect()
|
|
293
|
+
|
|
294
|
+
/*
|
|
295
|
+
EXAMPLE:
|
|
296
|
+
const builder = Builder()
|
|
297
|
+
.from('Hydration')
|
|
298
|
+
.to('Hydration')
|
|
299
|
+
.currency({
|
|
300
|
+
symbol: 'DOT',
|
|
301
|
+
amount: '1000000000'
|
|
302
|
+
})
|
|
303
|
+
.address(address)
|
|
304
|
+
|
|
305
|
+
const tx = await builder.build()
|
|
306
|
+
|
|
307
|
+
//Disconnect API after TX
|
|
308
|
+
await builder.disconnect()
|
|
309
|
+
*/
|
|
310
|
+
```
|
|
311
|
+
|
|
252
312
|
### Asset queries:
|
|
253
313
|
|
|
254
314
|
```ts
|