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