@paraspell/sdk 2.0.6 → 3.0.2
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 +28 -109
- package/dist/index.cjs +875 -698
- package/dist/index.d.ts +47 -13
- package/dist/index.mjs +875 -699
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,53 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
# @paraspell/sdk
|
|
5
2
|
|
|
6
3
|

|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
5
|
[![npm version][npm-version-src]][npm-version-href]
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|
|
16
7
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
9
|
[](https://snyk.io/test/github/paraspell/sdk)
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
SDK For XCM & XCMP handling made with ❤️ by ParaSpell✨. It is no longer necessary to construct calls manually. @paraspell/sdk handles this for you. Feel free to become magician and try your paraSPELLS 🧙✨.
|
|
11
|
+
SDK For XCM & XCMP handling made with ❤️ by ParaSpell✨. It is no longer necessary to construct calls manually. @paraspell/sdk handles this for you. Feel free to become a magician and try your paraSPELLS 🧙✨.
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
##### Currently supporting 44 Polkadot & Kusama nodes list [here](https://github.com/paraspell/sdk/blob/main/docs/supportedNodes.md).
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
##### Currently supporting 48 Polkadot & Kusama nodes list [here](https://github.com/paraspell/sdk/blob/main/docs/supportedNodes.md).
|
|
31
14
|
|
|
32
15
|
### Check out our brand new Wiki documentation! [Wiki docs](https://paraspell.github.io/docs/)
|
|
33
16
|
|
|
34
|
-
|
|
35
|
-
|
|
36
17
|
## Usage
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
19
|
**Install package:**
|
|
43
20
|
|
|
44
|
-
|
|
45
|
-
|
|
46
21
|
#### Since version 1.0.0
|
|
47
22
|
|
|
48
|
-
Our SDK introduced all Polkadot libraries as peer dependencies.
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
Our SDK introduced all Polkadot libraries as peer dependencies. The reason for this is, that most of the projects use these libraries in some way already and it fixes issues with unmet dependency warnings. Make sure your project has them. You can install them by following the command:
|
|
51
24
|
|
|
52
25
|
##### Install DEPS via npm||yarn||pnpm
|
|
53
26
|
|
|
@@ -70,45 +43,38 @@ yarn install @paraspell/sdk
|
|
|
70
43
|
//pnpm
|
|
71
44
|
pnpm install @paraspell/sdk
|
|
72
45
|
```
|
|
73
|
-
##### Importing package to your project:
|
|
74
46
|
|
|
75
|
-
|
|
47
|
+
##### Importing package to your project:
|
|
76
48
|
|
|
77
|
-
If you wish to use XCM, HRMP
|
|
49
|
+
If you wish to use XCM, HRMP and XYK Pallets only you can import Builder like this:
|
|
78
50
|
|
|
79
51
|
```js
|
|
80
|
-
import { Builder } from
|
|
52
|
+
import { Builder } from '@paraspell/sdk'
|
|
81
53
|
```
|
|
82
54
|
|
|
83
|
-
|
|
84
|
-
|
|
85
55
|
Old function like import (With assets):
|
|
86
56
|
|
|
87
57
|
```js
|
|
88
58
|
// ESM
|
|
89
|
-
import
|
|
59
|
+
import * as paraspell from '@paraspell/sdk'
|
|
90
60
|
|
|
91
61
|
// CommonJS
|
|
92
|
-
const
|
|
62
|
+
const paraspell = require('@paraspell/sdk')
|
|
93
63
|
```
|
|
94
64
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
65
|
## Currently implemented pallets
|
|
100
66
|
|
|
101
67
|
XCM pallet (Combined xTokens, polkadotXCM, ormlXTokens, XcmPallet & relayerXCM):
|
|
102
68
|
|
|
103
|
-
|
|
104
|
-
|
|
105
69
|
Builder pattern XCM & HRMP construction
|
|
106
70
|
|
|
107
71
|
```ts
|
|
108
72
|
//Transfer tokens from Parachain to Parachain
|
|
73
|
+
//**NOTE** If you wish to transfer from Parachain that uses long IDs for example Moonbeam you have to add character 'n' the end of currencyID. Eg: .currency(42259045809535163221576417993425387648n) will mean you transfer xcDOT.
|
|
74
|
+
|
|
109
75
|
Builder(api).from(NODE).to(NODE).currency(CurrencyString||CurrencyID).amount(amount).address(address).build()
|
|
110
76
|
|
|
111
|
-
//Transfer tokens from Relay chain to Parachain
|
|
77
|
+
//Transfer tokens from the Relay chain to Parachain
|
|
112
78
|
Builder(api).to(NODE).amount(amount).address(address).build()
|
|
113
79
|
|
|
114
80
|
//Transfer tokens from Parachain to Relay chain
|
|
@@ -121,12 +87,11 @@ Builder(api).from(NODE).closeChannel().inbound(inbound).outbound(outbound).build
|
|
|
121
87
|
Builder(api).from(NODE).to(NODE).openChannel().maxSize(maxSize).maxMessageSize(maxMsgSize).build()'
|
|
122
88
|
```
|
|
123
89
|
|
|
124
|
-
|
|
125
|
-
|
|
126
90
|
Function pattern XCM & HRMP construction
|
|
127
91
|
|
|
128
92
|
```ts
|
|
129
93
|
//Transfer tokens from Parachain to Parachain
|
|
94
|
+
//**NOTE** If you wish to transfer from Parachain that uses long IDs for example Moonbeam you have to add character 'n' the end of currencyID. Eg: currency = 42259045809535163221576417993425387648n will mean you transfer xcDOT.
|
|
130
95
|
paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency: CurrencyString||CurrencyID, amount: any, to: destination address string, destination: destination Parachain ID)
|
|
131
96
|
|
|
132
97
|
//Transfer tokens from Parachain to Relay chain
|
|
@@ -144,30 +109,28 @@ paraspell.closeChannels.closeChannel(api: ApiPromise, origin: origin Parachain
|
|
|
144
109
|
paraspell.openChannels.openChannel(api: ApiPromise, origin: origin Parachain ID, destination: destination Parachain ID, maxSize: number, maxMessageSize: number)
|
|
145
110
|
```
|
|
146
111
|
|
|
147
|
-
Asset pallet
|
|
148
|
-
|
|
149
|
-
|
|
112
|
+
Asset pallet construction:
|
|
150
113
|
|
|
151
114
|
```ts
|
|
152
115
|
//Returns assets object from assets.json for particular node including information about native and foreign assets
|
|
153
116
|
paraspell.assets.getAssetsObject(node: TNode)
|
|
154
117
|
|
|
155
|
-
//Returns foreign assetId for particular node and asset symbol
|
|
118
|
+
//Returns foreign assetId for a particular node and asset symbol
|
|
156
119
|
paraspell.assets.getAssetId(node: TNode, symbol: string)
|
|
157
120
|
|
|
158
|
-
//Returns symbol of the relay chain for particular node. Either "DOT" or "KSM"
|
|
121
|
+
//Returns the symbol of the relay chain for a particular node. Either "DOT" or "KSM"
|
|
159
122
|
paraspell.assets.getRelayChainSymbol(node: TNode)
|
|
160
123
|
|
|
161
124
|
//Returns string array of native assets symbols for particular node
|
|
162
125
|
paraspell.assets.getNativeAssets(node: TNode)
|
|
163
126
|
|
|
164
|
-
//Returns object array of foreign assets for particular node. Each object has symbol and assetId property
|
|
127
|
+
//Returns object array of foreign assets for a particular node. Each object has a symbol and assetId property
|
|
165
128
|
paraspell.assets.getOtherAssets(node: TNode)
|
|
166
129
|
|
|
167
|
-
//Returns string array of all assets symbols. (native and foreign assets are merged
|
|
130
|
+
//Returns string array of all assets symbols. (native and foreign assets are merged into a single array)
|
|
168
131
|
paraspell.assets.getAllAssetsSymbols(node: TNode)
|
|
169
132
|
|
|
170
|
-
//Checks if node supports particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
133
|
+
//Checks if a node supports a particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
171
134
|
paraspell.assets.hasSupportForAsset(node: TNode, symbol: string)
|
|
172
135
|
|
|
173
136
|
//Get decimals for specific asset
|
|
@@ -183,30 +146,28 @@ paraspell.assets.getTNode(nodeID: number)
|
|
|
183
146
|
paraspell.NODE_NAMES
|
|
184
147
|
```
|
|
185
148
|
|
|
186
|
-
Basilisk XYK pallet
|
|
187
|
-
|
|
188
|
-
|
|
149
|
+
Basilisk XYK pallet construction
|
|
189
150
|
|
|
190
|
-
Builder
|
|
151
|
+
Builder pattern XYK construction
|
|
191
152
|
|
|
192
153
|
```ts
|
|
193
|
-
//Add liquidity to specific pool
|
|
154
|
+
//Add liquidity to a specific pool
|
|
194
155
|
Builder(api).addLiquidity().assetA(assetA).assetB(assetB).amountA(amountA).amountBMaxLimit(maxLimit).build()
|
|
195
156
|
|
|
196
|
-
//Remove liquidity from specific pool
|
|
157
|
+
//Remove liquidity from a specific pool
|
|
197
158
|
Builder(api).removeLiquidity().assetA(assetA).assetB(assetB).liquidityAmount(liquidity).build()
|
|
198
159
|
|
|
199
160
|
//Create pool
|
|
200
161
|
Builder(api).createPool().assetA(assetA).amountA(amountA).assetB(assetB).amountB(amountB).build()
|
|
201
162
|
|
|
202
|
-
//Buy specific asset from pool
|
|
163
|
+
//Buy specific asset from the pool
|
|
203
164
|
Builder(api).buy().assetOut(out).assetIn(in).amount(amount).maxLimit(maxLimit).discount(discount).build()
|
|
204
165
|
|
|
205
|
-
//Sell specific asset from pool
|
|
166
|
+
//Sell specific asset from the pool
|
|
206
167
|
Builder(api).sell().assetIn(in).assetOut(out).amount(amount).maxLimit(maxLimit).discount(discount).build()
|
|
207
168
|
```
|
|
208
169
|
|
|
209
|
-
Function pattern XYK
|
|
170
|
+
Function pattern XYK construction
|
|
210
171
|
|
|
211
172
|
```ts
|
|
212
173
|
//Add liquidity to specific pool
|
|
@@ -233,7 +194,7 @@ import { getDefaultPallet, getSupportedPallets, SUPPORTED_PALLETS } from '@para
|
|
|
233
194
|
//Returns default pallet for specific parachain node
|
|
234
195
|
getDefaultPallet(node: TNode)
|
|
235
196
|
|
|
236
|
-
//Returns an array of supported pallets for specific parachain node.
|
|
197
|
+
//Returns an array of supported pallets for a specific parachain node.
|
|
237
198
|
getSupportedPallets(node: TNode)
|
|
238
199
|
|
|
239
200
|
//Prints all pallets that are currently supported
|
|
@@ -242,7 +203,7 @@ console.log(SUPPORTED_PALLETS)
|
|
|
242
203
|
|
|
243
204
|
##### Example of usage can be found in the UI repository [here](https://github.com/paraspell/ui) or in the Astarot repository [here](https://github.com/paraspell/astarot)
|
|
244
205
|
|
|
245
|
-
#####
|
|
206
|
+
##### A list of currently compatible nodes can be found [here](https://github.com/paraspell/sdk/blob/beta-pre-release/docs/supportedNodes.md)
|
|
246
207
|
|
|
247
208
|
## 💻 Development
|
|
248
209
|
|
|
@@ -262,7 +223,7 @@ console.log(SUPPORTED_PALLETS)
|
|
|
262
223
|
|
|
263
224
|
- Run updatePallets script using `pnpm updatePallets`
|
|
264
225
|
|
|
265
|
-
- Run coverage tests
|
|
226
|
+
- Run coverage tests using `pnpm test`
|
|
266
227
|
|
|
267
228
|
- Run all tests using `pnpm runAll`
|
|
268
229
|
|
|
@@ -276,61 +237,19 @@ console.log(SUPPORTED_PALLETS)
|
|
|
276
237
|
|
|
277
238
|
[](https://bsx.fi/)
|
|
278
239
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
240
|
## License
|
|
283
241
|
|
|
284
|
-
|
|
285
|
-
|
|
286
242
|
Made with 💛 by [ParaSpell✨](https://github.com/paraspell)
|
|
287
243
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
244
|
Published under [MIT License](https://github.com/paraspell/sdk/blob/main/LICENSE).
|
|
293
245
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
246
|
<!-- Badges -->
|
|
299
247
|
|
|
300
|
-
|
|
301
|
-
|
|
302
248
|
[npm-version-src]: https://img.shields.io/npm/v/@paraspell/sdk?style=flat-square
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
249
|
[npm-version-href]: https://npmjs.com/package/@paraspell/sdk
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
250
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@paraspell/sdk?style=flat-square
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
251
|
[npm-downloads-href]: https://npmjs.com/package/@paraspell/sdk
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
252
|
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/@paraspell/sdk/ci/main?style=flat-square
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
253
|
[github-actions-href]: https://github.com/unjs/@paraspell/sdk/actions?query=workflow%3Aci
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
254
|
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/@paraspell/sdk/main?style=flat-square
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
255
|
[codecov-href]: https://codecov.io/gh/unjs/@paraspell/sdk
|