@paraspell/sdk 0.0.27 → 1.1.1
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 +114 -29
- package/dist/index.cjs +347 -52
- package/dist/index.d.ts +9 -8
- package/dist/index.mjs +347 -52
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,76 +1,118 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
3
|
+
|
|
2
4
|
# @paraspell/sdk
|
|
5
|
+
|
|
3
6
|

|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
|
|
10
|
+
|
|
11
|
+
|
|
7
12
|
[![npm version][npm-version-src]][npm-version-href]
|
|
8
13
|
|
|
14
|
+
|
|
15
|
+
|
|
9
16
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
10
17
|
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
[](https://snyk.io/test/github/paraspell/sdk)
|
|
21
|
+
|
|
12
22
|
|
|
13
23
|
|
|
14
|
-
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 🧙✨.
|
|
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 🧙✨.
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
##### Currently supporting 46 Polkadot & Kusama nodes list [here](https://github.com/paraspell/sdk/blob/main/docs/supportedNodes.md).
|
|
29
|
+
|
|
30
|
+
|
|
17
31
|
|
|
18
32
|
### Check out our brand new Wiki documentation! [Wiki docs](https://paraspell.github.io/docs/)
|
|
19
33
|
|
|
34
|
+
|
|
35
|
+
|
|
20
36
|
## Usage
|
|
21
37
|
|
|
22
38
|
|
|
23
39
|
|
|
24
|
-
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
**Install package:**
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
#### Since version 1.0.0
|
|
47
|
+
|
|
48
|
+
Our SDK introduced all Polkadot libraries as peer dependencies. 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 have them. You can install them by following command:
|
|
25
49
|
|
|
26
50
|
|
|
27
51
|
|
|
28
|
-
##### Install via npm
|
|
52
|
+
##### Install DEPS via npm||yarn||pnpm
|
|
53
|
+
|
|
29
54
|
```
|
|
30
|
-
npm
|
|
55
|
+
//npm
|
|
56
|
+
npm install @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config
|
|
57
|
+
//yarn
|
|
58
|
+
yarn install @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config
|
|
59
|
+
//pnpm
|
|
60
|
+
pnpm install @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config
|
|
31
61
|
```
|
|
32
|
-
|
|
62
|
+
|
|
63
|
+
##### Install SDK via npm||yarn||pnpm
|
|
64
|
+
|
|
33
65
|
```
|
|
66
|
+
//npm
|
|
67
|
+
npm install @paraspell/sdk
|
|
68
|
+
//yarn
|
|
34
69
|
yarn install @paraspell/sdk
|
|
35
|
-
|
|
36
|
-
##### Install via pnpm
|
|
37
|
-
```
|
|
70
|
+
//pnpm
|
|
38
71
|
pnpm install @paraspell/sdk
|
|
39
72
|
```
|
|
73
|
+
##### Importing package to your project:
|
|
40
74
|
|
|
41
75
|
|
|
42
76
|
|
|
43
|
-
##### Importing package to your project:
|
|
44
|
-
|
|
45
77
|
If you wish to use XCM, HRMP, XYK Pallets only you can import Builder like this:
|
|
78
|
+
|
|
46
79
|
```js
|
|
47
|
-
import { Builder } from
|
|
80
|
+
import { Builder } from '@paraspell/sdk'
|
|
48
81
|
```
|
|
49
82
|
|
|
83
|
+
|
|
84
|
+
|
|
50
85
|
Old function like import (With assets):
|
|
86
|
+
|
|
51
87
|
```js
|
|
52
88
|
// ESM
|
|
53
89
|
import * as paraspell from '@paraspell/sdk'
|
|
54
90
|
|
|
55
91
|
// CommonJS
|
|
56
|
-
const
|
|
92
|
+
const paraspell = require('@paraspell/sdk')
|
|
57
93
|
```
|
|
58
94
|
|
|
59
95
|
|
|
60
96
|
|
|
97
|
+
|
|
98
|
+
|
|
61
99
|
## Currently implemented pallets
|
|
100
|
+
|
|
62
101
|
XCM pallet (Combined xTokens, polkadotXCM, ormlXTokens, XcmPallet & relayerXCM):
|
|
63
102
|
|
|
103
|
+
|
|
104
|
+
|
|
64
105
|
Builder pattern XCM & HRMP construction
|
|
106
|
+
|
|
65
107
|
```ts
|
|
66
108
|
//Transfer tokens from Parachain to Parachain
|
|
67
|
-
Builder(api).from(NODE).to(NODE).currency(CurrencyString).
|
|
109
|
+
Builder(api).from(NODE).to(NODE).currency(CurrencyString||CurrencyID).amount(amount).address(address).build()
|
|
68
110
|
|
|
69
111
|
//Transfer tokens from Relay chain to Parachain
|
|
70
112
|
Builder(api).to(NODE).amount(amount).address(address).build()
|
|
71
|
-
|
|
113
|
+
|
|
72
114
|
//Transfer tokens from Parachain to Relay chain
|
|
73
|
-
Builder(api).from(NODE).currency(CurrencyString).
|
|
115
|
+
Builder(api).from(NODE).currency(CurrencyString||CurrencyID).amount(amount).address(address).build()
|
|
74
116
|
|
|
75
117
|
//Close HRMP channels
|
|
76
118
|
Builder(api).from(NODE).closeChannel().inbound(inbound).outbound(outbound).build()
|
|
@@ -79,13 +121,16 @@ Builder(api).from(NODE).closeChannel().inbound(inbound).outbound(outbound).build
|
|
|
79
121
|
Builder(api).from(NODE).to(NODE).openChannel().maxSize(maxSize).maxMessageSize(maxMsgSize).build()'
|
|
80
122
|
```
|
|
81
123
|
|
|
124
|
+
|
|
125
|
+
|
|
82
126
|
Function pattern XCM & HRMP construction
|
|
127
|
+
|
|
83
128
|
```ts
|
|
84
129
|
//Transfer tokens from Parachain to Parachain
|
|
85
|
-
paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency:
|
|
130
|
+
paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency: CurrencyString||CurrencyID, amount: any, to: destination address string, destination: destination Parachain ID)
|
|
86
131
|
|
|
87
132
|
//Transfer tokens from Parachain to Relay chain
|
|
88
|
-
paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency:
|
|
133
|
+
paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency: CurrencyString||CurrencyID, amount: any, to: destination address string)
|
|
89
134
|
|
|
90
135
|
//Transfer tokens from Relay chain to Parachain
|
|
91
136
|
paraspell.xcmPallet.transferRelayToPara(api: ApiPromise, destination: destination Parachain ID, amount: any, to: destination address string)
|
|
@@ -98,8 +143,11 @@ paraspell.closeChannels.closeChannel(api: ApiPromise, origin: origin Parachain
|
|
|
98
143
|
//Open HRMP channels
|
|
99
144
|
paraspell.openChannels.openChannel(api: ApiPromise, origin: origin Parachain ID, destination: destination Parachain ID, maxSize: number, maxMessageSize: number)
|
|
100
145
|
```
|
|
146
|
+
|
|
101
147
|
Asset pallet contruction:
|
|
102
148
|
|
|
149
|
+
|
|
150
|
+
|
|
103
151
|
```ts
|
|
104
152
|
//Returns assets object from assets.json for particular node including information about native and foreign assets
|
|
105
153
|
paraspell.assets.getAssetsObject(node: TNode)
|
|
@@ -131,9 +179,13 @@ paraspell.assets.getParaId(node: TNode)
|
|
|
131
179
|
//Import all compatible nodes as constant:
|
|
132
180
|
paraspell.NODE_NAMES
|
|
133
181
|
```
|
|
182
|
+
|
|
134
183
|
Basilisk XYK pallet contruction
|
|
135
184
|
|
|
185
|
+
|
|
186
|
+
|
|
136
187
|
Builder patternn XYK construction
|
|
188
|
+
|
|
137
189
|
```ts
|
|
138
190
|
//Add liquidity to specific pool
|
|
139
191
|
Builder(api).addLiquidity().assetA(assetA).assetB(assetB).amountA(amountA).amountBMaxLimit(maxLimit).build()
|
|
@@ -150,7 +202,9 @@ Builder(api).buy().assetOut(out).assetIn(in).amount(amount).maxLimit(maxLimit).d
|
|
|
150
202
|
//Sell specific asset from pool
|
|
151
203
|
Builder(api).sell().assetIn(in).assetOut(out).amount(amount).maxLimit(maxLimit).discount(discount).build()
|
|
152
204
|
```
|
|
205
|
+
|
|
153
206
|
Function pattern XYK contruction
|
|
207
|
+
|
|
154
208
|
```ts
|
|
155
209
|
//Add liquidity to specific pool
|
|
156
210
|
paraspell.xyk.addLiquidity(api: ApiPromise, assetA: number, assetB: number, amountA: any, amountBMaxLimit: any)
|
|
@@ -169,8 +223,9 @@ paraspell.xyk.sell(api: ApiPromise, assetIn: number, assetOut: number, amount: a
|
|
|
169
223
|
```
|
|
170
224
|
|
|
171
225
|
Node pallet operations
|
|
226
|
+
|
|
172
227
|
```js
|
|
173
|
-
import { getDefaultPallet, getSupportedPallets, SUPPORTED_PALLETS } from
|
|
228
|
+
import { getDefaultPallet, getSupportedPallets, SUPPORTED_PALLETS } from '@paraspell/sdk'
|
|
174
229
|
|
|
175
230
|
//Returns default pallet for specific parachain node
|
|
176
231
|
getDefaultPallet(node: TNode)
|
|
@@ -182,15 +237,12 @@ getSupportedPallets(node: TNode)
|
|
|
182
237
|
console.log(SUPPORTED_PALLETS)
|
|
183
238
|
```
|
|
184
239
|
|
|
185
|
-
|
|
186
|
-
##### List of currently compatible nodes can be found [here](https://github.com/paraspell/sdk/blob/beta-pre-release/docs/supportedNodes.md)
|
|
240
|
+
##### 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)
|
|
187
241
|
|
|
188
|
-
|
|
242
|
+
##### List of currently compatible nodes can be found [here](https://github.com/paraspell/sdk/blob/beta-pre-release/docs/supportedNodes.md)
|
|
189
243
|
|
|
190
244
|
## 💻 Development
|
|
191
245
|
|
|
192
|
-
|
|
193
|
-
|
|
194
246
|
- Clone this repository
|
|
195
247
|
|
|
196
248
|
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
|
|
@@ -198,52 +250,85 @@ console.log(SUPPORTED_PALLETS)
|
|
|
198
250
|
- Install dependencies using `pnpm install`
|
|
199
251
|
|
|
200
252
|
- Run interactive tests using `pnpm dev`
|
|
253
|
+
|
|
201
254
|
- Run compilation test using `pnpm compile`
|
|
255
|
+
|
|
202
256
|
- Run linting test using `pnpm lint`
|
|
257
|
+
|
|
203
258
|
- Run updateAssets script using `pnpm updateAssets`
|
|
259
|
+
|
|
204
260
|
- Run updatePallets script using `pnpm updatePallets`
|
|
261
|
+
|
|
205
262
|
- Run coverage tests usign `pnpm test`
|
|
206
|
-
- Run all tests using `pnpm runAll`
|
|
207
263
|
|
|
264
|
+
- Run all tests using `pnpm runAll`
|
|
208
265
|
|
|
209
266
|
## Founded by
|
|
267
|
+
|
|
210
268
|
[<img width="245" alt="web3 foundation_grants_badge_black" src="https://user-images.githubusercontent.com/55763425/211145923-f7ee2a57-3e63-4b7d-9674-2da9db46b2ee.png">](https://github.com/w3f/Grants-Program/pull/1245)
|
|
269
|
+
|
|
211
270
|
[<img width="245" alt="web3 foundation_grants_badge_white (1)" src="https://user-images.githubusercontent.com/55763425/211069914-bbec9e28-7a0d-417b-8149-087b7f04e57e.png">](https://github.com/w3f/Grants-Program/pull/1245)
|
|
212
271
|
|
|
213
|
-
|
|
272
|
+
|
|
214
273
|
|
|
274
|
+
[](https://bsx.fi/)
|
|
215
275
|
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
216
279
|
|
|
217
280
|
## License
|
|
218
281
|
|
|
282
|
+
|
|
283
|
+
|
|
219
284
|
Made with 💛 by [ParaSpell✨](https://github.com/paraspell)
|
|
220
285
|
|
|
221
286
|
|
|
222
287
|
|
|
288
|
+
|
|
289
|
+
|
|
223
290
|
Published under [MIT License](https://github.com/paraspell/sdk/blob/main/LICENSE).
|
|
224
291
|
|
|
225
292
|
|
|
226
293
|
|
|
294
|
+
|
|
295
|
+
|
|
227
296
|
<!-- Badges -->
|
|
228
297
|
|
|
298
|
+
|
|
299
|
+
|
|
229
300
|
[npm-version-src]: https://img.shields.io/npm/v/@paraspell/sdk?style=flat-square
|
|
230
301
|
|
|
302
|
+
|
|
303
|
+
|
|
231
304
|
[npm-version-href]: https://npmjs.com/package/@paraspell/sdk
|
|
232
305
|
|
|
233
306
|
|
|
234
307
|
|
|
308
|
+
|
|
309
|
+
|
|
235
310
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@paraspell/sdk?style=flat-square
|
|
236
311
|
|
|
237
|
-
|
|
312
|
+
|
|
238
313
|
|
|
314
|
+
[npm-downloads-href]: https://npmjs.com/package/@paraspell/sdk
|
|
239
315
|
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
240
319
|
|
|
241
320
|
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/@paraspell/sdk/ci/main?style=flat-square
|
|
242
321
|
|
|
243
|
-
|
|
322
|
+
|
|
244
323
|
|
|
324
|
+
[github-actions-href]: https://github.com/unjs/@paraspell/sdk/actions?query=workflow%3Aci
|
|
245
325
|
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
246
329
|
|
|
247
330
|
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/@paraspell/sdk/main?style=flat-square
|
|
248
331
|
|
|
249
|
-
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
[codecov-href]: https://codecov.io/gh/unjs/@paraspell/sdk
|