@paraspell/sdk 1.0.1 → 1.1.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/LICENSE +2 -2
- package/README.md +106 -36
- package/dist/index.cjs +347 -52
- package/dist/index.d.ts +9 -8
- package/dist/index.mjs +347 -52
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023 ParaSpell
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,90 +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
|
+
|
|
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 🧙✨.
|
|
25
|
+
|
|
12
26
|
|
|
13
27
|
|
|
14
|
-
|
|
28
|
+
##### Currently supporting 46 Polkadot & Kusama nodes list [here](https://github.com/paraspell/sdk/blob/main/docs/supportedNodes.md).
|
|
15
29
|
|
|
16
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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).
|
|
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).
|
|
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:
|
|
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:
|
|
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
|
|
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
|
-
|
|
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,84 @@ 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
|
-
[
|
|
272
|
+
[<img width="245" alt="kusamacommunity" src="https://user-images.githubusercontent.com/55763425/227636288-e0aa6f2a-9eb6-4af2-bc6b-d572f145a2f0.png">](https://kusama.subsquare.io/referenda/referendum/123)
|
|
228
273
|
|
|
274
|
+
[](https://bsx.fi/)
|
|
229
275
|
|
|
276
|
+
|
|
277
|
+
|
|
230
278
|
|
|
231
279
|
## License
|
|
232
280
|
|
|
281
|
+
|
|
282
|
+
|
|
233
283
|
Made with 💛 by [ParaSpell✨](https://github.com/paraspell)
|
|
234
284
|
|
|
235
285
|
|
|
236
286
|
|
|
287
|
+
|
|
288
|
+
|
|
237
289
|
Published under [MIT License](https://github.com/paraspell/sdk/blob/main/LICENSE).
|
|
238
290
|
|
|
239
291
|
|
|
240
292
|
|
|
293
|
+
|
|
294
|
+
|
|
241
295
|
<!-- Badges -->
|
|
242
296
|
|
|
297
|
+
|
|
298
|
+
|
|
243
299
|
[npm-version-src]: https://img.shields.io/npm/v/@paraspell/sdk?style=flat-square
|
|
244
300
|
|
|
301
|
+
|
|
302
|
+
|
|
245
303
|
[npm-version-href]: https://npmjs.com/package/@paraspell/sdk
|
|
246
304
|
|
|
247
305
|
|
|
248
306
|
|
|
307
|
+
|
|
308
|
+
|
|
249
309
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@paraspell/sdk?style=flat-square
|
|
250
310
|
|
|
251
|
-
|
|
311
|
+
|
|
252
312
|
|
|
313
|
+
[npm-downloads-href]: https://npmjs.com/package/@paraspell/sdk
|
|
253
314
|
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
254
318
|
|
|
255
319
|
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/@paraspell/sdk/ci/main?style=flat-square
|
|
256
320
|
|
|
257
|
-
|
|
321
|
+
|
|
258
322
|
|
|
323
|
+
[github-actions-href]: https://github.com/unjs/@paraspell/sdk/actions?query=workflow%3Aci
|
|
259
324
|
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
260
328
|
|
|
261
329
|
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/@paraspell/sdk/main?style=flat-square
|
|
262
330
|
|
|
331
|
+
|
|
332
|
+
|
|
263
333
|
[codecov-href]: https://codecov.io/gh/unjs/@paraspell/sdk
|