@paraspell/sdk-dedot 13.0.0-rc.1 → 13.0.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 +196 -66
- package/dist/index.d.ts +9 -10
- package/dist/index.mjs +231 -277
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -44,7 +44,33 @@ npm install | pnpm add | yarn add dedot @polkadot/keyring
|
|
|
44
44
|
npm install | pnpm add | yarn add @paraspell/sdk-dedot
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
###
|
|
47
|
+
### Install Swap extension
|
|
48
|
+
|
|
49
|
+
If you plan to [do Swap XCMs](https://paraspell.github.io/docs/sdk/xcmPallet.html#swap) you can install Swap package which allows you to do cross-chain swaps on popular Polkadot, Kusama, Paseo, Westend exchanges. Now available in all JS client versions of SDK.
|
|
50
|
+
|
|
51
|
+
> [!IMPORTANT]
|
|
52
|
+
> - ⚠️ **WebAssembly (Wasm) must be enabled in your project** because of the Hydration SDK (One of the exchanges implemented in XCM Router). Wasm can be enabled either through the web application configuration or through the appropriate plugin.
|
|
53
|
+
>
|
|
54
|
+
> - ⚠️ Additionally, Hydration requires the use of the **augment package** (see: https://github.com/galacticcouncil/sdk/issues/114).
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install | pnpm add | yarn add @paraspell/swap @galacticcouncil/api-augment
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Setup Swap extension
|
|
61
|
+
|
|
62
|
+
Add the `@paraspell/swap` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// Import swap extension here
|
|
66
|
+
import '@paraspell/swap';
|
|
67
|
+
|
|
68
|
+
export default function App() {
|
|
69
|
+
return {/* Your app here */};
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Importing SDK Functionality
|
|
48
74
|
|
|
49
75
|
Named import:
|
|
50
76
|
```ts
|
|
@@ -59,6 +85,11 @@ import * as paraspell from '@paraspell/sdk-dedot'
|
|
|
59
85
|
|
|
60
86
|
|
|
61
87
|
## Implementation
|
|
88
|
+
|
|
89
|
+
> **Latest news:**
|
|
90
|
+
> - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
|
|
91
|
+
> - Swap package is now available on every XCM SDK version: https://paraspell.github.io/docs/sdk/getting-started.html#install-swap-extension
|
|
92
|
+
> - abstractDecimals is now turned on by default!
|
|
62
93
|
|
|
63
94
|
### Sending XCM
|
|
64
95
|
For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html).
|
|
@@ -70,15 +101,15 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
70
101
|
.from(TSubstrateChain)
|
|
71
102
|
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/)
|
|
72
103
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..])
|
|
73
|
-
.
|
|
74
|
-
.
|
|
104
|
+
.recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
|
|
105
|
+
.sender(address | {address, DEDOT_Signer}) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
75
106
|
/*.ahAddress(ahAddress) - OPTIONAL - used when origin is EVM chain and XCM goes through AssetHub (Multihop transfer where we are unable to convert Key20 to ID32 address eg. origin: Moonbeam & destination: Ethereum (Multihop goes from Moonbeam > AssetHub > BridgeHub > Ethereum)
|
|
76
107
|
.feeAsset({symbol: 'symbol'} || {id: 'id'} || {location: 'location'}) // Optional parameter used when multiasset is provided or when origin is AssetHub - so user can pay in fees different than DOT
|
|
77
108
|
.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
|
|
78
109
|
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
|
|
79
110
|
|
|
80
111
|
const tx = await builder.build()
|
|
81
|
-
// Or if you use signers in
|
|
112
|
+
// Or if you use signers in sender:
|
|
82
113
|
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
83
114
|
|
|
84
115
|
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
@@ -91,9 +122,9 @@ const builder = Builder()
|
|
|
91
122
|
.to('Polkadot')
|
|
92
123
|
.currency({
|
|
93
124
|
symbol: 'DOT',
|
|
94
|
-
amount: '
|
|
125
|
+
amount: '1'
|
|
95
126
|
})
|
|
96
|
-
.
|
|
127
|
+
.recipient(address)
|
|
97
128
|
|
|
98
129
|
const tx = await builder.build()
|
|
99
130
|
|
|
@@ -109,7 +140,7 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
109
140
|
.from(TSubstrateChain)
|
|
110
141
|
.to(TChain) //Has to be the same as the origin (from)
|
|
111
142
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..])
|
|
112
|
-
.
|
|
143
|
+
.recipient(address)
|
|
113
144
|
/* .keepAlive(bool) - Optional: Allows draining the account below the existential deposit. */
|
|
114
145
|
|
|
115
146
|
|
|
@@ -125,9 +156,9 @@ const builder = Builder()
|
|
|
125
156
|
.to('Hydration')
|
|
126
157
|
.currency({
|
|
127
158
|
symbol: 'DOT',
|
|
128
|
-
amount: '
|
|
159
|
+
amount: '1'
|
|
129
160
|
})
|
|
130
|
-
.
|
|
161
|
+
.recipient(address)
|
|
131
162
|
|
|
132
163
|
const tx = await builder.build()
|
|
133
164
|
|
|
@@ -143,18 +174,45 @@ const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..]
|
|
|
143
174
|
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
144
175
|
.to(TChain) // Has to be same as origin (from)
|
|
145
176
|
.currency(CURRENCY_SPEC) // Refer to currency spec options below
|
|
146
|
-
.
|
|
147
|
-
.
|
|
177
|
+
.sender(sender | PAPI SIGNER)
|
|
178
|
+
.recipient(address)
|
|
148
179
|
.transact(hex, /* originType, TWeight - Optional */)
|
|
149
180
|
|
|
150
181
|
const tx = await builder.build()
|
|
151
|
-
// Or if you use signers in
|
|
182
|
+
// Or if you use signers in sender:
|
|
152
183
|
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
153
184
|
|
|
154
185
|
//Disconnect API after TX
|
|
155
186
|
await builder.disconnect()
|
|
156
187
|
```
|
|
157
188
|
|
|
189
|
+
#### Swap
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
193
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
194
|
+
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
195
|
+
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/})
|
|
196
|
+
.recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address location in one object (x2)*/)
|
|
197
|
+
.sender(address | PAPI_SIGNER /*Only in PAPI SDK*/ | {address, PJS_SIGNER} /*Only in PJS SDK*/) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub/Hydration with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
198
|
+
.swap({
|
|
199
|
+
currencyTo: {id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/}
|
|
200
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
201
|
+
// slippage: 1, - Optional - 1 by default
|
|
202
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
203
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
204
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
const tx = await builder.buildAll()
|
|
208
|
+
// Or if you use signers in sender:
|
|
209
|
+
// await builder.signAndSubmit() - Signs and submits the transaction (only working in 1click scenarios); returns TX hash for tracking
|
|
210
|
+
// await builder.signAndSubmitAll() - Signs and submits transactions (required in 2click scenarios); returns array of TX hashes for tracking
|
|
211
|
+
|
|
212
|
+
// Make sure to disconnect API after it is no longer used (eg. after transaction)
|
|
213
|
+
await builder.disconnect()
|
|
214
|
+
```
|
|
215
|
+
|
|
158
216
|
#### Dry run your XCM Calls:
|
|
159
217
|
```ts
|
|
160
218
|
//Builder pattern
|
|
@@ -162,9 +220,17 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
162
220
|
.from(TSubstrateChain)
|
|
163
221
|
.to(TChain)
|
|
164
222
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
165
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency
|
|
166
|
-
|
|
167
|
-
|
|
223
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.
|
|
224
|
+
.swap({
|
|
225
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
226
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
227
|
+
// slippage: 1, - Optional - 1 by default
|
|
228
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
229
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
230
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
231
|
+
})*/
|
|
232
|
+
.recipient(ADDRESS)
|
|
233
|
+
.sender(address | {address, DEDOT_Signer})
|
|
168
234
|
.dryRun()
|
|
169
235
|
|
|
170
236
|
//Check Parachain for DryRun support - returns true/false
|
|
@@ -181,8 +247,8 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
181
247
|
.to(TChain)
|
|
182
248
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
183
249
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
184
|
-
.
|
|
185
|
-
.
|
|
250
|
+
.recipient(ADDRESS)
|
|
251
|
+
.sender(address | {address, DEDOT_Signer})
|
|
186
252
|
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
187
253
|
```
|
|
188
254
|
|
|
@@ -193,13 +259,13 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
193
259
|
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
194
260
|
.to(TChain2) //Any compatible Parachain
|
|
195
261
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
196
|
-
.
|
|
262
|
+
.recipient(address | Location object)
|
|
197
263
|
.addToBatch()
|
|
198
264
|
|
|
199
265
|
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
200
266
|
.to(TChain3) //Any compatible Parachain
|
|
201
267
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
202
|
-
.
|
|
268
|
+
.recipient(address | Location object)
|
|
203
269
|
.addToBatch()
|
|
204
270
|
|
|
205
271
|
const tx = await builder.buildBatch({
|
|
@@ -211,23 +277,6 @@ const tx = await builder.buildBatch({
|
|
|
211
277
|
await builder.disconnect()
|
|
212
278
|
```
|
|
213
279
|
|
|
214
|
-
#### Asset claim:
|
|
215
|
-
|
|
216
|
-
```ts
|
|
217
|
-
//Claim XCM trapped assets from the selected chain
|
|
218
|
-
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
219
|
-
.claimfrom(TSubstrateChain)
|
|
220
|
-
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..]
|
|
221
|
-
)
|
|
222
|
-
.address(address | Location object)
|
|
223
|
-
/*.xcmVersion(Version.V3) Optional parameter, by default chain specific version. XCM Version ENUM if a different XCM version is needed (Supported V3 & V4 & V5). Requires importing Version enum.*/
|
|
224
|
-
|
|
225
|
-
const tx = await builder.build()
|
|
226
|
-
|
|
227
|
-
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
228
|
-
await builder.disconnect()
|
|
229
|
-
```
|
|
230
|
-
|
|
231
280
|
### Localhost test setup
|
|
232
281
|
|
|
233
282
|
```ts
|
|
@@ -243,11 +292,11 @@ const builder = await Builder({
|
|
|
243
292
|
.from(TSubstrateChain)
|
|
244
293
|
.to(TChain)
|
|
245
294
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}])
|
|
246
|
-
.
|
|
247
|
-
.
|
|
295
|
+
.recipient(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
|
|
296
|
+
.sender(address | {address, DEDOT_Signer}) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
248
297
|
|
|
249
298
|
const tx = await builder.build()
|
|
250
|
-
//Or if you use prederived account as
|
|
299
|
+
//Or if you use prederived account as sender:
|
|
251
300
|
//await builder.signAndSubmit()
|
|
252
301
|
|
|
253
302
|
//Disconnect API after TX
|
|
@@ -265,9 +314,17 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
265
314
|
.from(TSubstrateChain)
|
|
266
315
|
.to(TChain)
|
|
267
316
|
.currency(CURRENCY_SPEC)
|
|
268
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
269
|
-
|
|
270
|
-
|
|
317
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
318
|
+
.swap({
|
|
319
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
320
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
321
|
+
// slippage: 1, - Optional - 1 by default
|
|
322
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
323
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
324
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
325
|
+
})*/
|
|
326
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
327
|
+
.sender(address | {address, DEDOT_Signer})
|
|
271
328
|
.getXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of a DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin or Destination chain do not support DryRun out of the box.
|
|
272
329
|
```
|
|
273
330
|
|
|
@@ -279,8 +336,8 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
279
336
|
.to(TChain)
|
|
280
337
|
.currency(CURRENCY_SPEC)
|
|
281
338
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
282
|
-
.
|
|
283
|
-
.
|
|
339
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
340
|
+
.sender(address | {address, DEDOT_Signer})
|
|
284
341
|
.getOriginXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of a DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin do not support DryRun out of the box.
|
|
285
342
|
```
|
|
286
343
|
|
|
@@ -291,8 +348,8 @@ const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
291
348
|
.to(TChain)
|
|
292
349
|
.currency(CURRENCY_SPEC)
|
|
293
350
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
294
|
-
.
|
|
295
|
-
.
|
|
351
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
352
|
+
.sender(address | {address, DEDOT_Signer})
|
|
296
353
|
.getTransferInfo()
|
|
297
354
|
```
|
|
298
355
|
|
|
@@ -302,9 +359,17 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
302
359
|
.from(TSubstrateChain)
|
|
303
360
|
.to(TChain)
|
|
304
361
|
.currency(CURRENCY_SPEC)
|
|
305
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
306
|
-
|
|
307
|
-
|
|
362
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
363
|
+
.swap({
|
|
364
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
365
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
366
|
+
// slippage: 1, - Optional - 1 by default
|
|
367
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
368
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
369
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
370
|
+
})*/
|
|
371
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
372
|
+
.sender(address | {address, DEDOT_Signer})
|
|
308
373
|
.getTransferableAmount()
|
|
309
374
|
```
|
|
310
375
|
|
|
@@ -314,9 +379,17 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
314
379
|
.from(TSubstrateChain)
|
|
315
380
|
.to(TChain)
|
|
316
381
|
.currency(CURRENCY_SPEC)
|
|
317
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
318
|
-
|
|
319
|
-
|
|
382
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
383
|
+
.swap({
|
|
384
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
385
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
386
|
+
// slippage: 1, - Optional - 1 by default
|
|
387
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
388
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
389
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
390
|
+
})*/
|
|
391
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
392
|
+
.sender(address | {address, DEDOT_Signer})
|
|
320
393
|
.getMinTransferableAmount()
|
|
321
394
|
```
|
|
322
395
|
|
|
@@ -327,8 +400,8 @@ const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url
|
|
|
327
400
|
.to(TChain)
|
|
328
401
|
.currency(CURRENCY_SPEC)
|
|
329
402
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
330
|
-
.
|
|
331
|
-
.
|
|
403
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
404
|
+
.sender(address | {address, DEDOT_Signer})
|
|
332
405
|
.getReceivableAmount()
|
|
333
406
|
```
|
|
334
407
|
|
|
@@ -339,11 +412,31 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
339
412
|
.to(TChain)
|
|
340
413
|
.currency(CURRENCY_SPEC)
|
|
341
414
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
342
|
-
.
|
|
343
|
-
.
|
|
415
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
416
|
+
.sender(address | {address, DEDOT_Signer})
|
|
344
417
|
.verifyEdOnDestination()
|
|
345
418
|
```
|
|
346
419
|
|
|
420
|
+
#### Get best amount out
|
|
421
|
+
|
|
422
|
+
```ts
|
|
423
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
424
|
+
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
425
|
+
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
426
|
+
.currency(CURRENCY_SPEC)
|
|
427
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
428
|
+
.sender(SENDER_ADDRESS)
|
|
429
|
+
.swap({
|
|
430
|
+
currencyTo: CURRENCY_SPEC,
|
|
431
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
432
|
+
// slippage: 1, - Optional - 1 by default
|
|
433
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
434
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
435
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
436
|
+
})
|
|
437
|
+
.getBestAmountOut();
|
|
438
|
+
```
|
|
439
|
+
|
|
347
440
|
#### Asset balance
|
|
348
441
|
```ts
|
|
349
442
|
import { getBalance } from "@paraspell/sdk-dedot";
|
|
@@ -380,7 +473,7 @@ let result = convertSs58(ADDRESS, TChain) // returns converted address in string
|
|
|
380
473
|
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
|
|
381
474
|
|
|
382
475
|
```ts
|
|
383
|
-
import { getSupportedDestinations, getFeeAssets, getAssetsObject,
|
|
476
|
+
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk-dedot'
|
|
384
477
|
|
|
385
478
|
//Get chains that support the specific asset related to origin
|
|
386
479
|
getSupportedDestinations(TChain, CURRENCY)
|
|
@@ -403,9 +496,6 @@ getAssetLocation(TChain, { symbol: symbol } | { id: assetId })
|
|
|
403
496
|
// Retrieve assets object from assets.json for a particular chain, including information about native and foreign assets
|
|
404
497
|
getAssetsObject(TChain)
|
|
405
498
|
|
|
406
|
-
// Retrieve foreign assetId for a particular chain and asset symbol
|
|
407
|
-
getAssetId(TChain, ASSET_SYMBOL)
|
|
408
|
-
|
|
409
499
|
// Retrieve the symbol of the relay chain for a particular chain. Either "DOT" or "KSM"
|
|
410
500
|
getRelayChainSymbol(TChain)
|
|
411
501
|
|
|
@@ -418,12 +508,6 @@ getOtherAssets(TChain)
|
|
|
418
508
|
// Retrieve string array of all asset symbols. (native and foreign assets are merged into a single array)
|
|
419
509
|
getAllAssetsSymbols(TChain)
|
|
420
510
|
|
|
421
|
-
// Check if a chain supports a particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
422
|
-
hasSupportForAsset(TChain, ASSET_SYMBOL)
|
|
423
|
-
|
|
424
|
-
// Get decimals for specific asset
|
|
425
|
-
getAssetDecimals(TChain, ASSET_SYMBOL)
|
|
426
|
-
|
|
427
511
|
// Get specific chain id
|
|
428
512
|
getParaId(TChain)
|
|
429
513
|
|
|
@@ -460,6 +544,52 @@ getOtherAssetsPallets(chain: TChain)
|
|
|
460
544
|
console.log(SUPPORTED_PALLETS)
|
|
461
545
|
```
|
|
462
546
|
|
|
547
|
+
### Import chains as types
|
|
548
|
+
There are 6 options for types you can choose based on your prefference
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
// Import all exchange chains (Swap)
|
|
552
|
+
import type { TExchangeChain } from "@paraspell/sdk-dedot"
|
|
553
|
+
|
|
554
|
+
// Import all Parachains
|
|
555
|
+
import type { TParachain } from "@paraspell/sdk-dedot"
|
|
556
|
+
|
|
557
|
+
// Import all Relay chains
|
|
558
|
+
import type { TRelaychain } from "@paraspell/sdk-dedot"
|
|
559
|
+
|
|
560
|
+
// Import all Substrate chains (Parachains + Relays)
|
|
561
|
+
import type { TSubstrateChain } from "@paraspell/sdk-dedot"
|
|
562
|
+
|
|
563
|
+
// Import chains outside Polkadot ecosystem (Ethereum)
|
|
564
|
+
import type { TExternalChain } from "@paraspell/sdk-dedot"
|
|
565
|
+
|
|
566
|
+
// Import all chains implemented in ParaSpell
|
|
567
|
+
import type { TChain } from "@paraspell/sdk-dedot"
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Import chains as constant
|
|
571
|
+
There are 6 options for constants you can choose based on your prefference
|
|
572
|
+
|
|
573
|
+
```ts
|
|
574
|
+
// Print all exchange chains (Swap)
|
|
575
|
+
console.log(EXCHANGE_CHAINS)
|
|
576
|
+
|
|
577
|
+
// Print all Parachains
|
|
578
|
+
console.log(PARACHAINS)
|
|
579
|
+
|
|
580
|
+
// Print all Relay chains
|
|
581
|
+
console.log(RELAYCHAINS)
|
|
582
|
+
|
|
583
|
+
// Print all Substrate chains (Parachains + Relays)
|
|
584
|
+
console.log(SUBSTRATE_CHAINS)
|
|
585
|
+
|
|
586
|
+
// Print chains outside Polkadot ecosystem (Ethereum)
|
|
587
|
+
console.log(EXTERNAL_CHAINS)
|
|
588
|
+
|
|
589
|
+
// Print all chains implemented in ParaSpell
|
|
590
|
+
console.log(CHAINS)
|
|
591
|
+
```
|
|
592
|
+
|
|
463
593
|
## 💻 Tests
|
|
464
594
|
- Run compilation using `pnpm compile`
|
|
465
595
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions } from '@paraspell/sdk-core';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import { DedotClient as DedotClient$1 } from 'dedot';
|
|
5
5
|
import { GenericSubstrateApi as GenericSubstrateApi$1, ChainSubmittableExtrinsic as ChainSubmittableExtrinsic$1, IKeyringPair as IKeyringPair$1 } from 'dedot/types';
|
|
6
6
|
|
|
7
7
|
type TDedotApi = DedotClient$1<GenericSubstrateApi$1>;
|
|
8
|
-
type TDedotApiOrUrl = TApiOrUrl<TDedotApi>;
|
|
9
8
|
type TDedotExtrinsic = ChainSubmittableExtrinsic$1;
|
|
10
9
|
type TDedotSigner = IKeyringPair$1;
|
|
11
10
|
|
|
@@ -17,7 +16,7 @@ type TDedotSigner = IKeyringPair$1;
|
|
|
17
16
|
declare const getBalance: (options: _paraspell_sdk_core.TGetBalanceCommonOptions & {
|
|
18
17
|
currency?: _paraspell_sdk_core.TCurrencyCore;
|
|
19
18
|
} & {
|
|
20
|
-
api?:
|
|
19
|
+
api?: _paraspell_sdk_core.TApiOrUrl<TDedotApi>;
|
|
21
20
|
}) => Promise<bigint>;
|
|
22
21
|
|
|
23
22
|
declare const assets_Foreign: typeof Foreign;
|
|
@@ -73,20 +72,20 @@ declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
|
73
72
|
* @param api - The API instance or options to use for building transactions.
|
|
74
73
|
* @returns A new Builder instance.
|
|
75
74
|
*/
|
|
76
|
-
declare const Builder: (api?: TBuilderOptions<
|
|
75
|
+
declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TDedotApi>>) => GeneralBuilder$1<DedotClient<GenericSubstrateApi>, ChainSubmittableExtrinsic, IKeyringPair, object>;
|
|
77
76
|
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TDedotApi, TDedotExtrinsic, TDedotSigner>> = object> = GeneralBuilder$1<TDedotApi, TDedotExtrinsic, TDedotSigner, T>;
|
|
78
77
|
|
|
79
78
|
declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<ChainSubmittableExtrinsic> & {
|
|
80
|
-
api?:
|
|
79
|
+
api?: TApiOrUrl<TDedotApi>;
|
|
81
80
|
}) => Promise<_paraspell_sdk_core.TDryRunResult>;
|
|
82
81
|
declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<ChainSubmittableExtrinsic> & {
|
|
83
|
-
api?:
|
|
82
|
+
api?: TApiOrUrl<TDedotApi>;
|
|
84
83
|
}) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
|
|
85
|
-
declare const getParaEthTransferFees: (api?:
|
|
84
|
+
declare const getParaEthTransferFees: (api?: TApiOrUrl<TDedotApi>) => Promise<[bigint, bigint]>;
|
|
86
85
|
/**
|
|
87
86
|
* Gets the Ethereum bridge status.
|
|
88
87
|
*/
|
|
89
|
-
declare const getBridgeStatus: (api?:
|
|
88
|
+
declare const getBridgeStatus: (api?: TApiOrUrl<TDedotApi>) => Promise<_paraspell_sdk_core.TBridgeStatus>;
|
|
90
89
|
|
|
91
90
|
declare const transfer_dryRun: typeof dryRun;
|
|
92
91
|
declare const transfer_dryRunOrigin: typeof dryRunOrigin;
|
|
@@ -101,7 +100,7 @@ declare namespace transfer {
|
|
|
101
100
|
};
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<
|
|
103
|
+
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TApiOrUrl<TDedotApi>>) => Promise<DedotClient<GenericSubstrateApi>>;
|
|
105
104
|
|
|
106
105
|
export { Builder, assets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
|
|
107
|
-
export type { GeneralBuilder, TDedotApi,
|
|
106
|
+
export type { GeneralBuilder, TDedotApi, TDedotExtrinsic, TDedotSigner };
|