@paraspell/sdk 0.0.20 → 0.0.22
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 +65 -19
- package/dist/index.cjs +881 -193
- package/dist/index.d.ts +133 -17
- package/dist/index.mjs +878 -192
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
# @paraspell/sdk
|
|
3
|
+

|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ SDK For XCM & XCMP handling made with ❤️ by ParaSpell✨. It is no longer ne
|
|
|
14
15
|
|
|
15
16
|
##### Currently supporting 42 Polkadot & Kusama nodes list [here](https://github.com/paraspell/sdk/blob/beta-pre-release/docs/supportedNodes.md).
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
### Check out our brand new Wiki documentation! [Wiki docs](https://paraspell.github.io/docs/)
|
|
18
19
|
|
|
19
20
|
## Usage
|
|
20
21
|
|
|
@@ -41,32 +42,27 @@ pnpm install @paraspell/sdk
|
|
|
41
42
|
|
|
42
43
|
##### Importing package to your project:
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
If you wish to use XCM, HRMP, XYK Pallets only you can import Builder like this:
|
|
45
46
|
```js
|
|
46
|
-
/////////NEW BUILDER STYLE IMPORT///////////
|
|
47
|
-
|
|
48
47
|
import { Builder } from '@paraspell/sdk'
|
|
48
|
+
```
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
Old function like import (With assets):
|
|
51
|
+
```js
|
|
52
52
|
// ESM
|
|
53
53
|
import * as paraspell from '@paraspell/sdk'
|
|
54
54
|
|
|
55
55
|
// CommonJS
|
|
56
56
|
const paraspell = require('@paraspell/sdk')
|
|
57
|
-
|
|
58
57
|
```
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
|
|
62
61
|
## Currently implemented pallets
|
|
62
|
+
XCM pallet (Combined xTokens, polkadotXCM, ormlXTokens, XcmPallet & relayerXCM):
|
|
63
63
|
|
|
64
|
+
Builder pattern XCM & HRMP construction
|
|
64
65
|
```ts
|
|
65
|
-
|
|
66
|
-
//XCM pallet (Combined xTokens, polkadotXCM, ormlXTokens, XcmPallet & relayerXCM):
|
|
67
|
-
|
|
68
|
-
//////////NEW BUILDER PATTERN XCM & HRMP CONSTRUCTION//////////
|
|
69
|
-
|
|
70
66
|
//Transfer tokens from Parachain to Parachain
|
|
71
67
|
Builder(api).from(NODE).to(NODE).currency(CurrencyString).currencyId(currencyId).amount(amount).address(address).build()
|
|
72
68
|
|
|
@@ -80,10 +76,11 @@ Builder(api).from(NODE).currency(CurrencyString).currencyId(currencyId).amount(a
|
|
|
80
76
|
Builder(api).from(NODE).closeChannel().inbound(inbound).outbound(outbound).build()
|
|
81
77
|
|
|
82
78
|
//Open HRMP channels
|
|
83
|
-
Builder(api).from(NODE).to(NODE).openChannel().maxSize(maxSize).maxMessageSize(maxMsgSize).build()
|
|
84
|
-
|
|
85
|
-
///////////OLD STYLE XCM & HRMP CONSTRUCTION//////////////
|
|
79
|
+
Builder(api).from(NODE).to(NODE).openChannel().maxSize(maxSize).maxMessageSize(maxMsgSize).build()'
|
|
80
|
+
```
|
|
86
81
|
|
|
82
|
+
Function pattern XCM & HRMP construction
|
|
83
|
+
```ts
|
|
87
84
|
//Transfer tokens from Parachain to Parachain
|
|
88
85
|
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)
|
|
89
86
|
|
|
@@ -100,11 +97,10 @@ paraspell.closeChannels.closeChannel(api: ApiPromise, origin: origin Parachain
|
|
|
100
97
|
//parasSudoWrapper pallet:
|
|
101
98
|
//Open HRMP channels
|
|
102
99
|
paraspell.openChannels.openChannel(api: ApiPromise, origin: origin Parachain ID, destination: destination Parachain ID, maxSize: number, maxMessageSize: number)
|
|
100
|
+
```
|
|
101
|
+
Asset pallet contruction:
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
//Asset pallet
|
|
107
|
-
|
|
103
|
+
```ts
|
|
108
104
|
//Returns assets object from assets.json for particular node including information about native and foreign assets
|
|
109
105
|
paraspell.assets.getAssetsObject(node: TNode)
|
|
110
106
|
|
|
@@ -134,7 +130,56 @@ paraspell.assets.getParaId(node: TNode)
|
|
|
134
130
|
|
|
135
131
|
//Import all compatible nodes as constant:
|
|
136
132
|
paraspell.NODE_NAMES
|
|
133
|
+
```
|
|
134
|
+
Basilisk XYK pallet contruction
|
|
135
|
+
|
|
136
|
+
Builder patternn XYK construction
|
|
137
|
+
```ts
|
|
138
|
+
//Add liquidity to specific pool
|
|
139
|
+
Builder(api).addLiquidity().assetA(assetA).assetB(assetB).amountA(amountA).amountBMaxLimit(maxLimit).build()
|
|
140
|
+
|
|
141
|
+
//Remove liquidity from specific pool
|
|
142
|
+
Builder(api).removeLiquidity().assetA(assetA).assetB(assetB).liquidityAmount(liquidity).build()
|
|
143
|
+
|
|
144
|
+
//Create pool
|
|
145
|
+
Builder(api).createPool().assetA(assetA).amountA(amountA).assetB(assetB).amountB(amountB).build()
|
|
146
|
+
|
|
147
|
+
//Buy specific asset from pool
|
|
148
|
+
Builder(api).buy().assetOut(out).assetIn(in).amount(amount).maxLimit(maxLimit).discount(discount).build()
|
|
149
|
+
|
|
150
|
+
//Sell specific asset from pool
|
|
151
|
+
Builder(api).sell().assetIn(in).assetOut(out).amount(amount).maxLimit(maxLimit).discount(discount).build()
|
|
152
|
+
```
|
|
153
|
+
Function pattern XYK contruction
|
|
154
|
+
```ts
|
|
155
|
+
//Add liquidity to specific pool
|
|
156
|
+
paraspell.xyk.addLiquidity(api: ApiPromise, assetA: number, assetB: number, amountA: any, amountBMaxLimit: any)
|
|
157
|
+
|
|
158
|
+
//Remove liquidity from specific pool
|
|
159
|
+
paraspell.xyk.removeLiquidity(api: ApiPromise, assetA: number, assetB: number, liquidityAmount: any)
|
|
160
|
+
|
|
161
|
+
//Create pool
|
|
162
|
+
paraspell.xyk.createPool(api: ApiPromise, assetA: number, amountA: any, assetB: number, amountB: any)
|
|
163
|
+
|
|
164
|
+
//Buy specific asset from pool
|
|
165
|
+
paraspell.xyk.buy(api: ApiPromise, assetOut: number, assetIn: number, amount: any, maxLimit: any, discount: Bool)
|
|
166
|
+
|
|
167
|
+
//Sell specific asset from pool
|
|
168
|
+
paraspell.xyk.sell(api: ApiPromise, assetIn: number, assetOut: number, amount: any, maxLimit: any, discount: Bool)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Node pallet operations
|
|
172
|
+
```js
|
|
173
|
+
import { getDefaultPallet, getSupportedPallets, SUPPORTED_PALLETS } from '@paraspell/sdk'
|
|
174
|
+
|
|
175
|
+
//Returns default pallet for specific parachain node
|
|
176
|
+
getDefaultPallet(node: TNode)
|
|
177
|
+
|
|
178
|
+
//Returns an array of supported pallets for specific parachain node.
|
|
179
|
+
getSupportedPallets(node: TNode)
|
|
137
180
|
|
|
181
|
+
//Prints all pallets that are currently supported
|
|
182
|
+
console.log(SUPPORTED_PALLETS)
|
|
138
183
|
```
|
|
139
184
|
|
|
140
185
|
##### 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)
|
|
@@ -156,6 +201,7 @@ paraspell.NODE_NAMES
|
|
|
156
201
|
- Run compilation test using `pnpm compile`
|
|
157
202
|
- Run linting test using `pnpm lint`
|
|
158
203
|
- Run updateAssets script using `pnpm updateAssets`
|
|
204
|
+
- Run updatePallets script using `pnpm updatePallets`
|
|
159
205
|
- Run coverage tests usign `pnpm test`
|
|
160
206
|
- Run all tests using `pnpm runAll`
|
|
161
207
|
|