@paraspell/sdk 12.9.7 → 12.10.0-rc.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
@@ -47,7 +47,7 @@ npm install | pnpm add | yarn add @paraspell/sdk
47
47
 
48
48
  ### Install Swap extension
49
49
 
50
- 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. Only available in PAPI version of SDK.
50
+ 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.
51
51
 
52
52
  > [!IMPORTANT]
53
53
  > - ⚠️ **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.
@@ -87,11 +87,14 @@ import * as paraspell from '@paraspell/sdk'
87
87
  ## Implementation
88
88
 
89
89
  > [!NOTE]
90
+ > - You can now pass signer directly into sender parameter
90
91
  > - The local transfers now have additional builder parameter called keepAlive
91
92
  > - Transact is here! Find out more: https://paraspell.github.io/docs/sdk/xcmPallet.html#transact
92
93
  >
93
94
  > **Latest news:**
94
- > - Swap is here! Find out more: https://paraspell.github.io/docs/sdk/getting-started.html#install-swap-extension
95
+ > - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
96
+ > - Swap package is now available on every XCM SDK version: https://paraspell.github.io/docs/sdk/getting-started.html#install-swap-extension
97
+ > - abstractDecimals is now turned on by default!
95
98
 
96
99
  ### Sending XCM
97
100
  For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html).
@@ -103,15 +106,15 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
103
106
  .from(TSubstrateChain)
104
107
  .to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/)
105
108
  .currency({id: currencyID, amount: amount} | {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}, ..])
106
- .address(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
107
- .senderAddress(address | PAPI_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.
109
+ .recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
110
+ .sender(address | PAPI_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.
108
111
  /*.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)
109
112
  .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
110
113
  .xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
111
114
  .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.*/
112
115
 
113
116
  const tx = await builder.build()
114
- // Or if you use signers in senderAddress:
117
+ // Or if you use signers in sender:
115
118
  // await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
116
119
 
117
120
  //Make sure to disconnect the API after it is no longer used (eg, after a transaction)
@@ -124,9 +127,9 @@ const builder = Builder()
124
127
  .to('Polkadot')
125
128
  .currency({
126
129
  symbol: 'DOT',
127
- amount: '1000000000'
130
+ amount: '1'
128
131
  })
129
- .address(address)
132
+ .recipient(address)
130
133
 
131
134
  const tx = await builder.build()
132
135
 
@@ -142,7 +145,7 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
142
145
  .from(TSubstrateChain)
143
146
  .to(TChain) //Has to be the same as the origin (from)
144
147
  .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}, ..])
145
- .address(address)
148
+ .recipient(address)
146
149
  /* .keepAlive(bool) - Optional: Allows draining the account below the existential deposit. */
147
150
 
148
151
  const tx = await builder.build()
@@ -157,9 +160,9 @@ const builder = Builder()
157
160
  .to('Hydration')
158
161
  .currency({
159
162
  symbol: 'DOT',
160
- amount: '1000000000'
163
+ amount: '1'
161
164
  })
162
- .address(address)
165
+ .recipient(address)
163
166
 
164
167
  const tx = await builder.build()
165
168
 
@@ -175,12 +178,12 @@ const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..]
175
178
  .from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
176
179
  .to(TChain) // Has to be same as origin (from)
177
180
  .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*/})
178
- .senderAddress(senderAddress | PAPI SIGNER)
179
- .address(address)
181
+ .sender(sender | PAPI SIGNER)
182
+ .recipient(address)
180
183
  .transact(hex, /* originType, TWeight - Optional */)
181
184
 
182
185
  const tx = await builder.build()
183
- // Or if you use signers in senderAddress:
186
+ // Or if you use signers in sender:
184
187
  // await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
185
188
 
186
189
  //Disconnect API after TX
@@ -194,20 +197,21 @@ const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..]
194
197
  .from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
195
198
  .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
196
199
  .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*/})
197
- .address(address | Location object /*If you are sending through xTokens, you need to pass the destination and address location in one object (x2)*/)
198
- .senderAddress(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.
200
+ .recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address location in one object (x2)*/)
201
+ .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.
199
202
  .swap({
200
203
  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*/}
201
204
  // exchange: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
202
205
  // slippage: 1, - Optional - 1 by default
203
- // evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
206
+ // evmsender: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
204
207
  // evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
205
208
  // onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
206
209
  })
207
210
 
208
211
  const tx = await builder.buildAll()
209
- // Or if you use signers in senderAddress:
210
- // await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
212
+ // Or if you use signers in sender:
213
+ // await builder.signAndSubmit() - Signs and submits the transaction (only working in 1click scenarios); returns TX hash for tracking
214
+ // await builder.signAndSubmitAll() - Signs and submits transactions (required in 2click scenarios); returns array of TX hashes for tracking
211
215
 
212
216
  // Make sure to disconnect API after it is no longer used (eg. after transaction)
213
217
  await builder.disconnect()
@@ -226,12 +230,12 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
226
230
  currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
227
231
  // exchange: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
228
232
  // slippage: 1, - Optional - 1 by default
229
- // evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
233
+ // evmsender: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
230
234
  // evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
231
235
  // onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
232
236
  })*/
233
- .address(ADDRESS)
234
- .senderAddress(address | PAPI_SIGNER)
237
+ .recipient(ADDRESS)
238
+ .sender(address | PAPI_SIGNER)
235
239
  .dryRun()
236
240
 
237
241
  //Check Parachain for DryRun support - returns true/false
@@ -249,8 +253,8 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
249
253
  .to(TChain)
250
254
  .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*/}]})
251
255
  /*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
252
- .address(ADDRESS)
253
- .senderAddress(address | PAPI_SIGNER)
256
+ .recipient(ADDRESS)
257
+ .sender(address | PAPI_SIGNER)
254
258
  .dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
255
259
  ```
256
260
 
@@ -261,13 +265,13 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
261
265
  .from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
262
266
  .to(TChain2) //Any compatible Parachain
263
267
  .currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
264
- .address(address | Location object)
268
+ .recipient(address | Location object)
265
269
  .addToBatch()
266
270
 
267
271
  .from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
268
272
  .to(TChain3) //Any compatible Parachain
269
273
  .currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
270
- .address(address | Location object)
274
+ .recipient(address | Location object)
271
275
  .addToBatch()
272
276
 
273
277
  const tx = await builder.buildBatch({
@@ -287,7 +291,7 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
287
291
  .claimfrom(TSubstrateChain)
288
292
  .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}, ..]
289
293
  )
290
- .address(address | Location object)
294
+ .recipient(address | Location object)
291
295
  /*.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.*/
292
296
 
293
297
  const tx = await builder.build()
@@ -312,11 +316,11 @@ const builder = await Builder({
312
316
  .from(TSubstrateChain)
313
317
  .to(TChain)
314
318
  .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*/}])
315
- .address(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
316
- .senderAddress(address | PAPI_SIGNER) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
319
+ .recipient(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
320
+ .sender(address | PAPI_SIGNER) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
317
321
 
318
322
  const tx = await builder.build()
319
- //Or if you use prederived account as senderAddress:
323
+ //Or if you use prederived account as sender:
320
324
  //await builder.signAndSubmit()
321
325
 
322
326
  //Disconnect API after TX
@@ -338,12 +342,12 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
338
342
  currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
339
343
  // exchange: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
340
344
  // slippage: 1, - Optional - 1 by default
341
- // evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
345
+ // evmsender: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
342
346
  // evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
343
347
  // onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
344
348
  })*/
345
- .address(RECIPIENT_ADDRESS)
346
- .senderAddress(address | PAPI_SIGNER)
349
+ .recipient(RECIPIENT_ADDRESS)
350
+ .sender(address | PAPI_SIGNER)
347
351
  .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.
348
352
  ```
349
353
 
@@ -355,8 +359,8 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
355
359
  .to(TChain)
356
360
  .currency(CURRENCY_SPEC)
357
361
  /*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
358
- .address(RECIPIENT_ADDRESS)
359
- .senderAddress(address | PAPI_SIGNER)
362
+ .recipient(RECIPIENT_ADDRESS)
363
+ .sender(address | PAPI_SIGNER)
360
364
  .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.
361
365
  ```
362
366
 
@@ -367,8 +371,8 @@ const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
367
371
  .to(TChain)
368
372
  .currency(CURRENCY_SPEC)
369
373
  /*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
370
- .address(RECIPIENT_ADDRESS)
371
- .senderAddress(address | PAPI_SIGNER)
374
+ .recipient(RECIPIENT_ADDRESS)
375
+ .sender(address | PAPI_SIGNER)
372
376
  .getTransferInfo()
373
377
  ```
374
378
 
@@ -383,12 +387,12 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
383
387
  currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
384
388
  // exchange: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
385
389
  // slippage: 1, - Optional - 1 by default
386
- // evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
390
+ // evmsender: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
387
391
  // evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
388
392
  // onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
389
393
  })*/
390
- .address(RECIPIENT_ADDRESS)
391
- .senderAddress(address | PAPI_SIGNER)
394
+ .recipient(RECIPIENT_ADDRESS)
395
+ .sender(address | PAPI_SIGNER)
392
396
  .getTransferableAmount()
393
397
  ```
394
398
 
@@ -403,12 +407,12 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
403
407
  currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
404
408
  // exchange: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
405
409
  // slippage: 1, - Optional - 1 by default
406
- // evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
410
+ // evmsender: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
407
411
  // evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
408
412
  // onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
409
413
  })*/
410
- .address(RECIPIENT_ADDRESS)
411
- .senderAddress(address | PAPI_SIGNER)
414
+ .recipient(RECIPIENT_ADDRESS)
415
+ .sender(address | PAPI_SIGNER)
412
416
  .getMinTransferableAmount()
413
417
  ```
414
418
 
@@ -419,8 +423,8 @@ const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url
419
423
  .to(TChain)
420
424
  .currency(CURRENCY_SPEC)
421
425
  /*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
422
- .address(RECIPIENT_ADDRESS)
423
- .senderAddress(address | PAPI_SIGNER)
426
+ .recipient(RECIPIENT_ADDRESS)
427
+ .sender(address | PAPI_SIGNER)
424
428
  .getReceivableAmount()
425
429
  ```
426
430
 
@@ -431,8 +435,8 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
431
435
  .to(TChain)
432
436
  .currency(CURRENCY_SPEC)
433
437
  /*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
434
- .address(RECIPIENT_ADDRESS)
435
- .senderAddress(address | PAPI_SIGNER)
438
+ .recipient(RECIPIENT_ADDRESS)
439
+ .sender(address | PAPI_SIGNER)
436
440
  .verifyEdOnDestination()
437
441
  ```
438
442
 
@@ -443,13 +447,13 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
443
447
  .from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
444
448
  .to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
445
449
  .currency(CURRENCY_SPEC)
446
- .address(RECIPIENT_ADDRESS)
447
- .senderAddress(SENDER_ADDRESS)
450
+ .recipient(RECIPIENT_ADDRESS)
451
+ .sender(SENDER_ADDRESS)
448
452
  .swap({
449
453
  currencyTo: CURRENCY_SPEC,
450
454
  // exchange: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
451
455
  // slippage: 1, - Optional - 1 by default
452
- // evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
456
+ // evmsender: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
453
457
  // evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
454
458
  // onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
455
459
  })
@@ -487,11 +491,12 @@ import { convertSs58 } from "@paraspell/sdk";
487
491
  let result = convertSs58(ADDRESS, TChain) // returns converted address in string
488
492
  ```
489
493
 
490
- ### Asset queries
494
+ ### Asset queries:
495
+
491
496
  For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
492
497
 
493
498
  ```ts
494
- import { getSupportedDestinations, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk'
499
+ import { getSupportedDestinations, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk'
495
500
 
496
501
  //Get chains that support the specific asset related to origin
497
502
  getSupportedDestinations(TChain, CURRENCY)
@@ -514,9 +519,6 @@ getAssetLocation(TChain, { symbol: symbol } | { id: assetId })
514
519
  // Retrieve assets object from assets.json for a particular chain, including information about native and foreign assets
515
520
  getAssetsObject(TChain)
516
521
 
517
- // Retrieve foreign assetId for a particular chain and asset symbol
518
- getAssetId(TChain, ASSET_SYMBOL)
519
-
520
522
  // Retrieve the symbol of the relay chain for a particular chain. Either "DOT" or "KSM"
521
523
  getRelayChainSymbol(TChain)
522
524
 
@@ -529,12 +531,6 @@ getOtherAssets(TChain)
529
531
  // Retrieve string array of all asset symbols. (native and foreign assets are merged into a single array)
530
532
  getAllAssetsSymbols(TChain)
531
533
 
532
- // Check if a chain supports a particular asset. (Both native and foreign assets are searched). Returns boolean
533
- hasSupportForAsset(TChain, ASSET_SYMBOL)
534
-
535
- // Get decimals for specific asset
536
- getAssetDecimals(TChain, ASSET_SYMBOL)
537
-
538
534
  // Get specific chain id
539
535
  getParaId(TChain)
540
536
 
@@ -579,6 +575,8 @@ console.log(SUPPORTED_PALLETS)
579
575
 
580
576
  - Run end-to-end tests using `pnpm test:e2e`
581
577
 
578
+ - Run swap end-to-end tests using `pnpm test:e2e:swap`
579
+
582
580
  - Run full end-to-end tests using `pnpm test:e2e:chopsticks`
583
581
 
584
582
  - Run all core tests and checks using `pnpm runAll`
package/dist/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import * as _paraspell_sdk_core from '@paraspell/sdk-core';
2
- import { TApiOrUrl, TEvmChainFrom, TSwapEvent as TSwapEvent$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TEvmBuilderOptions, TChain, TCurrencyInputWithAmount, TBuilderOptions, GeneralBuilder as GeneralBuilder$1, TSendBaseOptions, TGetXcmFeeBaseOptions, TCreateBaseSwapXcmOptions } from '@paraspell/sdk-core';
2
+ import { TEvmChainFrom, TSwapEvent as TSwapEvent$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TEvmBuilderOptions, TChain, TCurrencyInputWithAmount, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions, TGetXcmFeeBaseOptions, TCreateBaseSwapXcmOptions } from '@paraspell/sdk-core';
3
3
  export * from '@paraspell/sdk-core';
4
4
  import * as polkadot_api from 'polkadot-api';
5
5
  import { PolkadotClient, UnsafeTransaction, PolkadotSigner } from 'polkadot-api';
6
6
  import { WalletClient } from 'viem';
7
7
 
8
8
  type TPapiApi = PolkadotClient;
9
- type TPapiApiOrUrl = TApiOrUrl<PolkadotClient>;
10
9
  type TPapiSigner = PolkadotSigner;
11
10
  type TPapiTransaction = UnsafeTransaction<any, string, string, any>;
12
11
  type TEvmChainFromPapi = Extract<TEvmChainFrom, 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
@@ -20,22 +19,13 @@ type TSwapEvent = TSwapEvent$1<TPapiApi, TPapiTransaction>;
20
19
  declare const getBalance: (options: _paraspell_sdk_core.TGetBalanceCommonOptions & {
21
20
  currency?: _paraspell_sdk_core.TCurrencyCore;
22
21
  } & {
23
- api?: TPapiApiOrUrl;
22
+ api?: _paraspell_sdk_core.TApiOrUrl<TPapiApi>;
24
23
  }) => Promise<bigint>;
25
- /**
26
- * Claims assets from a parachain.
27
- *
28
- * @returns An extrinsic representing the claim transaction.
29
- */
30
- declare const claimAssets: (options: _paraspell_sdk_core.TAssetClaimOptionsBase & {
31
- api?: TPapiApiOrUrl;
32
- }) => Promise<TPapiTransaction>;
33
24
 
34
25
  declare const assets_Foreign: typeof Foreign;
35
26
  declare const assets_ForeignAbstract: typeof ForeignAbstract;
36
27
  declare const assets_Native: typeof Native;
37
28
  declare const assets_Override: typeof Override;
38
- declare const assets_claimAssets: typeof claimAssets;
39
29
  declare const assets_findAssetInfo: typeof findAssetInfo;
40
30
  declare const assets_getAllAssetsSymbols: typeof getAllAssetsSymbols;
41
31
  declare const assets_getAssetDecimals: typeof getAssetDecimals;
@@ -58,7 +48,6 @@ declare namespace assets {
58
48
  assets_ForeignAbstract as ForeignAbstract,
59
49
  assets_Native as Native,
60
50
  assets_Override as Override,
61
- assets_claimAssets as claimAssets,
62
51
  assets_findAssetInfo as findAssetInfo,
63
52
  assets_getAllAssetsSymbols as getAllAssetsSymbols,
64
53
  assets_getAssetDecimals as getAssetDecimals,
@@ -113,8 +102,8 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmBuilderO
113
102
  * @param address - The Polkadot address to receive the transfer.
114
103
  * @returns An instance of EvmBuilder
115
104
  */
116
- address(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
117
- address: string;
105
+ recipient(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
106
+ recipient: string;
118
107
  }>;
119
108
  /**
120
109
  * Sets the asset hub address. This is used for transfers that go through the Asset Hub.
@@ -148,31 +137,31 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmBuilderO
148
137
  * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
149
138
  * @returns A new Builder instance.
150
139
  */
151
- declare const Builder: (api?: TBuilderOptions<TPapiApiOrUrl>) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, object>;
152
- type GeneralBuilder<T extends Partial<TSendBaseOptions<TPapiApi, TPapiTransaction, TPapiSigner>> = object> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T>;
153
- declare const EvmBuilder: (api?: TBuilderOptions<TPapiApiOrUrl>) => EvmBuilderCore<unknown, unknown, unknown, {
154
- api: _paraspell_sdk_core.IPolkadotApi<PolkadotClient, TPapiTransaction, PolkadotSigner>;
140
+ declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, object>;
141
+ type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPapiApi, TPapiTransaction, TPapiSigner>> = object> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T>;
142
+ declare const EvmBuilder: (api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
143
+ api: _paraspell_sdk_core.PolkadotApi<PolkadotClient, TPapiTransaction, PolkadotSigner>;
155
144
  }>;
156
145
 
157
146
  declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<TPapiTransaction> & {
158
- api?: TPapiApiOrUrl;
147
+ api?: TApiOrUrl<TPapiApi>;
159
148
  }) => Promise<_paraspell_sdk_core.TDryRunResult>;
160
149
  declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<TPapiTransaction> & {
161
- api?: TPapiApiOrUrl;
150
+ api?: TApiOrUrl<TPapiApi>;
162
151
  }) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
163
- declare const getParaEthTransferFees: (ahApi?: TPapiApiOrUrl) => Promise<[bigint, bigint]>;
152
+ declare const getParaEthTransferFees: (ahApi?: TApiOrUrl<TPapiApi>) => Promise<[bigint, bigint]>;
164
153
  /**
165
154
  * Gets the Ethereum bridge status.
166
155
  */
167
- declare const getBridgeStatus: (ahApi?: TPapiApiOrUrl) => Promise<_paraspell_sdk_core.TBridgeStatus>;
156
+ declare const getBridgeStatus: (ahApi?: TApiOrUrl<TPapiApi>) => Promise<_paraspell_sdk_core.TBridgeStatus>;
168
157
  declare const getOriginXcmFee: (options: _paraspell_sdk_core.TGetOriginXcmFeeBaseOptions<TPapiTransaction> & {
169
- api?: TPapiApiOrUrl;
158
+ api?: TApiOrUrl<TPapiApi>;
170
159
  }) => Promise<_paraspell_sdk_core.TXcmFeeDetail & {
171
160
  forwardedXcms?: unknown;
172
161
  destParaId?: number;
173
162
  }>;
174
- declare const getXcmFee: <TDisableFallback extends boolean>(options: TGetXcmFeeBaseOptions<TPapiTransaction, TDisableFallback>, builderOptions?: TBuilderOptions<TPapiApiOrUrl>) => Promise<_paraspell_sdk_core.TGetXcmFeeResult<TDisableFallback>>;
175
- declare const handleSwapExecuteTransfer: (options: TCreateBaseSwapXcmOptions, builderOptions?: TBuilderOptions<TPapiApiOrUrl>) => Promise<TPapiTransaction>;
163
+ declare const getXcmFee: <TDisableFallback extends boolean>(options: TGetXcmFeeBaseOptions<TPapiTransaction, TDisableFallback>, builderOptions?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<_paraspell_sdk_core.TGetXcmFeeResult<TDisableFallback>>;
164
+ declare const handleSwapExecuteTransfer: (options: TCreateBaseSwapXcmOptions, builderOptions?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<TPapiTransaction>;
176
165
 
177
166
  declare const transfer_dryRun: typeof dryRun;
178
167
  declare const transfer_dryRunOrigin: typeof dryRunOrigin;
@@ -193,10 +182,10 @@ declare namespace transfer {
193
182
  };
194
183
  }
195
184
 
196
- declare const createChainClient: (chain: TSubstrateChain, api?: TBuilderOptions<TPapiApiOrUrl>) => Promise<polkadot_api.PolkadotClient>;
185
+ declare const createChainClient: (chain: TSubstrateChain, api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<polkadot_api.PolkadotClient>;
197
186
 
198
187
  declare const checkAndConvertToNumberOrBigInt: (input: string) => number | bigint;
199
188
  declare const transform: (obj: any) => any;
200
189
 
201
- export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, transform, transfer as xcmPallet };
202
- export type { GeneralBuilder, TEvmChainFromPapi, TPapiApi, TPapiApiOrUrl, TPapiSigner, TPapiTransaction, TSwapEvent };
190
+ export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, transform, transfer as xcmPallet };
191
+ export type { GeneralBuilder, TEvmChainFromPapi, TPapiApi, TPapiSigner, TPapiTransaction, TSwapEvent };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, DEFAULT_TTL_MS, resolveChainApi, isExternalChain, Parents, findAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, isRelayChain, padValueBy, isAssetEqual, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
1
+ import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, Parents, findAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, isRelayChain, padValueBy, isAssetEqual, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { secp256k1 } from '@noble/curves/secp256k1.js';
4
4
  import { keccak_256 } from '@noble/hashes/sha3.js';
@@ -21,6 +21,10 @@ function _arrayLikeToArray(r, a) {
21
21
  function _arrayWithoutHoles(r) {
22
22
  if (Array.isArray(r)) return _arrayLikeToArray(r);
23
23
  }
24
+ function _assertThisInitialized(e) {
25
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
26
+ return e;
27
+ }
24
28
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
25
29
  try {
26
30
  var i = n[a](c),
@@ -46,6 +50,9 @@ function _asyncToGenerator(n) {
46
50
  });
47
51
  };
48
52
  }
53
+ function _callSuper(t, o, e) {
54
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
55
+ }
49
56
  function _classCallCheck(a, n) {
50
57
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
51
58
  }
@@ -116,6 +123,31 @@ function _defineProperty(e, r, t) {
116
123
  writable: true
117
124
  }) : e[r] = t, e;
118
125
  }
126
+ function _getPrototypeOf(t) {
127
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
128
+ return t.__proto__ || Object.getPrototypeOf(t);
129
+ }, _getPrototypeOf(t);
130
+ }
131
+ function _inherits(t, e) {
132
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
133
+ t.prototype = Object.create(e && e.prototype, {
134
+ constructor: {
135
+ value: t,
136
+ writable: true,
137
+ configurable: true
138
+ }
139
+ }), Object.defineProperty(t, "prototype", {
140
+ writable: false
141
+ }), e && _setPrototypeOf(t, e);
142
+ }
143
+ function _isNativeReflectConstruct() {
144
+ try {
145
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
146
+ } catch (t) {}
147
+ return (_isNativeReflectConstruct = function () {
148
+ return !!t;
149
+ })();
150
+ }
119
151
  function _iterableToArray(r) {
120
152
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
121
153
  }
@@ -143,6 +175,11 @@ function _objectSpread2(e) {
143
175
  }
144
176
  return e;
145
177
  }
178
+ function _possibleConstructorReturn(t, e) {
179
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
180
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
181
+ return _assertThisInitialized(t);
182
+ }
146
183
  function _regenerator() {
147
184
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
148
185
  var e,
@@ -251,6 +288,11 @@ function _regeneratorDefine(e, r, n, t) {
251
288
  }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
252
289
  }, _regeneratorDefine(e, r, n, t);
253
290
  }
291
+ function _setPrototypeOf(t, e) {
292
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
293
+ return t.__proto__ = e, t;
294
+ }, _setPrototypeOf(t, e);
295
+ }
254
296
  function _toConsumableArray(r) {
255
297
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
256
298
  }
@@ -690,41 +732,27 @@ var extractDryRunXcmFailureReason = function extractDryRunXcmFailureReason(resul
690
732
  }
691
733
  return JSON.stringify((_ref5 = (_result$value2 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value2 !== void 0 ? _result$value2 : result) !== null && _ref5 !== void 0 ? _ref5 : 'Unknown error structure', replaceBigInt);
692
734
  };
693
- var PapiApi = /*#__PURE__*/function () {
694
- function PapiApi(config) {
735
+ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
736
+ function PapiApi() {
737
+ var _this;
695
738
  _classCallCheck(this, PapiApi);
696
- this._ttlMs = DEFAULT_TTL_MS;
697
- this.initialized = false;
698
- this.disconnectAllowed = true;
699
- this._config = config;
739
+ _this = _callSuper(this, PapiApi, arguments);
740
+ _this.type = 'PAPI';
741
+ return _this;
700
742
  }
743
+ _inherits(PapiApi, _PolkadotApi);
701
744
  return _createClass(PapiApi, [{
702
- key: "getType",
703
- value: function getType() {
704
- return 'PAPI';
705
- }
706
- }, {
707
- key: "getConfig",
708
- value: function getConfig() {
709
- return this._config;
710
- }
711
- }, {
712
- key: "getApi",
713
- value: function getApi() {
714
- return this.api;
715
- }
716
- }, {
717
745
  key: "init",
718
746
  value: function () {
719
747
  var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain) {
720
- var _this = this;
748
+ var _this2 = this;
721
749
  var clientTtlMs,
722
750
  _args = arguments;
723
751
  return _regenerator().w(function (_context2) {
724
752
  while (1) switch (_context2.n) {
725
753
  case 0:
726
754
  clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
727
- if (!(this.initialized || isExternalChain(chain))) {
755
+ if (!(this._chain !== undefined || isExternalChain(chain))) {
728
756
  _context2.n = 1;
729
757
  break;
730
758
  }
@@ -734,11 +762,10 @@ var PapiApi = /*#__PURE__*/function () {
734
762
  this._chain = chain;
735
763
  _context2.n = 2;
736
764
  return resolveChainApi(this._config, chain, function (wsUrl, c) {
737
- return _this.createApiInstance(wsUrl, c);
765
+ return _this2.createApiInstance(wsUrl, c);
738
766
  });
739
767
  case 2:
740
- this.api = _context2.v;
741
- this.initialized = true;
768
+ this._api = _context2.v;
742
769
  case 3:
743
770
  return _context2.a(2);
744
771
  }
@@ -1044,13 +1071,13 @@ var PapiApi = /*#__PURE__*/function () {
1044
1071
  return _regenerator().w(function (_context9) {
1045
1072
  while (1) switch (_context9.n) {
1046
1073
  case 0:
1047
- api = new PapiApi();
1074
+ api = new PapiApi(isConfig(this._config) ? this._config : undefined);
1048
1075
  _context9.n = 1;
1049
1076
  return api.init(chain);
1050
1077
  case 1:
1051
1078
  return _context9.a(2, api);
1052
1079
  }
1053
- }, _callee9);
1080
+ }, _callee9, this);
1054
1081
  }));
1055
1082
  function createApiForChain(_x15) {
1056
1083
  return _createApiForChain.apply(this, arguments);
@@ -1099,7 +1126,7 @@ var PapiApi = /*#__PURE__*/function () {
1099
1126
  isCustomAsset: true,
1100
1127
  asset: findAssetInfoOrThrow(chain, {
1101
1128
  id: assetId
1102
- }, null)
1129
+ })
1103
1130
  });
1104
1131
  }
1105
1132
  }, _callee0, this);
@@ -1113,7 +1140,7 @@ var PapiApi = /*#__PURE__*/function () {
1113
1140
  key: "getDryRunCall",
1114
1141
  value: function () {
1115
1142
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
1116
- var _this2 = this;
1143
+ var _this3 = this;
1117
1144
  var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, resolvedFeeAsset, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t2, _t3;
1118
1145
  return _regenerator().w(function (_context10) {
1119
1146
  while (1) switch (_context10.n) {
@@ -1153,7 +1180,7 @@ var PapiApi = /*#__PURE__*/function () {
1153
1180
  resolvedTx = _t2;
1154
1181
  performDryRunCall = /*#__PURE__*/function () {
1155
1182
  var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(includeVersion) {
1156
- var _this2$api$getUnsafeA;
1183
+ var _this3$api$getUnsafeA;
1157
1184
  var callArgs, versionNum;
1158
1185
  return _regenerator().w(function (_context1) {
1159
1186
  while (1) switch (_context1.n) {
@@ -1163,7 +1190,7 @@ var PapiApi = /*#__PURE__*/function () {
1163
1190
  versionNum = Number(version.charAt(1));
1164
1191
  callArgs.push(versionNum);
1165
1192
  }
1166
- return _context1.a(2, (_this2$api$getUnsafeA = _this2.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this2$api$getUnsafeA, callArgs));
1193
+ return _context1.a(2, (_this3$api$getUnsafeA = _this3.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this3$api$getUnsafeA, callArgs));
1167
1194
  }
1168
1195
  }, _callee1);
1169
1196
  }));
@@ -1440,7 +1467,7 @@ var PapiApi = /*#__PURE__*/function () {
1440
1467
  key: "getXcmPaymentApiFee",
1441
1468
  value: function () {
1442
1469
  var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset, version) {
1443
- var _this3 = this,
1470
+ var _this4 = this,
1444
1471
  _execFeeRes$value;
1445
1472
  var transformXcm,
1446
1473
  overridenWeight,
@@ -1468,7 +1495,7 @@ var PapiApi = /*#__PURE__*/function () {
1468
1495
  while (1) switch (_context13.n) {
1469
1496
  case 0:
1470
1497
  _context13.n = 1;
1471
- return _this3.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
1498
+ return _this4.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
1472
1499
  case 1:
1473
1500
  weightRes = _context13.v;
1474
1501
  return _context13.a(2, weightRes.value);
@@ -1724,22 +1751,12 @@ var PapiApi = /*#__PURE__*/function () {
1724
1751
  }
1725
1752
  return getBridgeStatus;
1726
1753
  }()
1727
- }, {
1728
- key: "setDisconnectAllowed",
1729
- value: function setDisconnectAllowed(allowed) {
1730
- this.disconnectAllowed = allowed;
1731
- }
1732
- }, {
1733
- key: "getDisconnectAllowed",
1734
- value: function getDisconnectAllowed() {
1735
- return this.disconnectAllowed;
1736
- }
1737
1754
  }, {
1738
1755
  key: "disconnect",
1739
1756
  value: function disconnect() {
1740
1757
  var _this$_config$apiOver;
1741
1758
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1742
- if (!this.initialized) return Promise.resolve();
1759
+ if (!this._chain) return Promise.resolve();
1743
1760
  if (!force && !this.disconnectAllowed) return Promise.resolve();
1744
1761
  var api = isConfig(this._config) ? (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[this._chain] : this._config;
1745
1762
  // Own client provided, destroy only if force true
@@ -1785,8 +1802,41 @@ var PapiApi = /*#__PURE__*/function () {
1785
1802
  }
1786
1803
  return signAndSubmit;
1787
1804
  }()
1805
+ }, {
1806
+ key: "signAndSubmitFinalized",
1807
+ value: function () {
1808
+ var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(tx, sender) {
1809
+ var signer;
1810
+ return _regenerator().w(function (_context19) {
1811
+ while (1) switch (_context19.n) {
1812
+ case 0:
1813
+ signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
1814
+ return _context19.a(2, new Promise(function (resolve, reject) {
1815
+ tx.signSubmitAndWatch(signer).subscribe({
1816
+ next: function next(event) {
1817
+ if (event.type === 'finalized' || event.type === 'txBestBlocksState' && event.found) {
1818
+ if (!event.ok) {
1819
+ reject(new SubmitTransactionError(JSON.stringify(event.dispatchError.value)));
1820
+ } else {
1821
+ resolve(event.txHash);
1822
+ }
1823
+ }
1824
+ },
1825
+ error: function error(_error) {
1826
+ reject(_error instanceof Error ? _error : new SubmitTransactionError(String(_error)));
1827
+ }
1828
+ });
1829
+ }));
1830
+ }
1831
+ }, _callee19);
1832
+ }));
1833
+ function signAndSubmitFinalized(_x37, _x38) {
1834
+ return _signAndSubmitFinalized.apply(this, arguments);
1835
+ }
1836
+ return signAndSubmitFinalized;
1837
+ }()
1788
1838
  }]);
1789
- }();
1839
+ }(PolkadotApi);
1790
1840
 
1791
1841
  var createChainClient = function createChainClient(chain, api) {
1792
1842
  var papiApi = new PapiApi(api);
@@ -1825,12 +1875,6 @@ var findFailingEvent = function findFailingEvent(result) {
1825
1875
  * @returns The asset balance as a bigint.
1826
1876
  */
1827
1877
  var getBalance = createPapiApiCall(getBalance$1);
1828
- /**
1829
- * Claims assets from a parachain.
1830
- *
1831
- * @returns An extrinsic representing the claim transaction.
1832
- */
1833
- var claimAssets = createPapiApiCall(claimAssets$1);
1834
1878
 
1835
1879
  var assets = /*#__PURE__*/Object.freeze({
1836
1880
  __proto__: null,
@@ -1838,7 +1882,6 @@ var assets = /*#__PURE__*/Object.freeze({
1838
1882
  ForeignAbstract: ForeignAbstract,
1839
1883
  Native: Native,
1840
1884
  Override: Override,
1841
- claimAssets: claimAssets,
1842
1885
  findAssetInfo: findAssetInfo,
1843
1886
  getAllAssetsSymbols: getAllAssetsSymbols,
1844
1887
  getAssetDecimals: getAssetDecimals,
@@ -1910,10 +1953,10 @@ var EvmBuilderCore = /*#__PURE__*/function () {
1910
1953
  * @returns An instance of EvmBuilder
1911
1954
  */
1912
1955
  }, {
1913
- key: "address",
1914
- value: function address(_address) {
1956
+ key: "recipient",
1957
+ value: function recipient(address) {
1915
1958
  return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1916
- address: _address
1959
+ recipient: address
1917
1960
  }));
1918
1961
  }
1919
1962
  /**
@@ -1951,12 +1994,12 @@ var EvmBuilderCore = /*#__PURE__*/function () {
1951
1994
  key: "build",
1952
1995
  value: (function () {
1953
1996
  var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1954
- var _this$_options, from, to, address, api;
1997
+ var _this$_options, from, to, recipient, api;
1955
1998
  return _regenerator().w(function (_context) {
1956
1999
  while (1) switch (_context.n) {
1957
2000
  case 0:
1958
- _this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address, api = _this$_options.api;
1959
- validateAddress(api, address, to);
2001
+ _this$_options = this._options, from = _this$_options.from, to = _this$_options.to, recipient = _this$_options.recipient, api = _this$_options.api;
2002
+ validateAddress(api, recipient, to);
1960
2003
  if (!(from === 'Moonbeam' && to === 'Ethereum')) {
1961
2004
  _context.n = 1;
1962
2005
  break;
@@ -2075,4 +2118,4 @@ var transfer = /*#__PURE__*/Object.freeze({
2075
2118
  handleSwapExecuteTransfer: handleSwapExecuteTransfer
2076
2119
  });
2077
2120
 
2078
- export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, _transform as transform, transfer as xcmPallet };
2121
+ export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, _transform as transform, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "12.9.7",
3
+ "version": "12.10.0-rc.1",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "@polkadot-labs/hdkd": "^0.0.27",
29
29
  "@polkadot-labs/hdkd-helpers": "^0.0.28",
30
30
  "viem": "2.47.1",
31
- "@paraspell/sdk-core": "12.9.7"
31
+ "@paraspell/sdk-core": "12.10.0-rc.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "polkadot-api": ">= 1.23.3 < 2"
@@ -63,6 +63,7 @@
63
63
  "test:watch": "vitest",
64
64
  "runAll": "pnpm compile && pnpm format:write && pnpm lint && pnpm test",
65
65
  "test:e2e": "vitest run --config ./vitest.config.e2e.ts --sequence.concurrent",
66
- "test:e2e:chopsticks": "vitest run --config ./vitest.config.chopsticks.e2e.ts"
66
+ "test:e2e:chopsticks": "vitest run --config ./vitest.config.chopsticks.e2e.ts",
67
+ "test:e2e:swap": "vitest run --config ./vitest.config.swap.e2e.ts --sequence.concurrent"
67
68
  }
68
69
  }