@paraspell/sdk 12.5.0 → 12.6.0
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 +91 -70
- package/dist/index.d.ts +16 -15
- package/dist/index.mjs +171 -145
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -66,14 +66,13 @@ import { Native, Foreign, ForeignAbstract } from '@paraspell/sdk'; //Only needed
|
|
|
66
66
|
## Implementation
|
|
67
67
|
|
|
68
68
|
> [!NOTE]
|
|
69
|
-
> - Local transfers are now available for every currency and every chain. To try them, simply use the same origin and destination parameters.
|
|
70
|
-
> - Transfer info queries are now all in the Builder pattern and don't require any imports other than the builder.
|
|
71
|
-
> - You can now query Ethereum asset balances on Ethereum via balance query
|
|
72
|
-
> - The Builder() now accepts an optional configuration object (To enhance localhost experience and testing). This object can contain apiOverrides and a development flag. More information in the "Localhost test setup" section.
|
|
73
69
|
> - Brand new asset decimal abstraction introduced. It can be turned on in Builder config. Will be turned on by default in next major release.
|
|
70
|
+
> - V11 > V12 Migration guide https://paraspell.github.io/docs/migration/v11-to-v12.html
|
|
74
71
|
>
|
|
75
72
|
> **Latest news:**
|
|
76
|
-
> -
|
|
73
|
+
> - You can now pass signer directly into senderAddress parameter
|
|
74
|
+
> - The local transfers now have additional builder parameter called keepAlive
|
|
75
|
+
> - Transact is here! Find out more: https://paraspell.github.io/docs/sdk/xcmPallet.html#transact
|
|
77
76
|
|
|
78
77
|
### Sending XCM
|
|
79
78
|
For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html).
|
|
@@ -86,13 +85,15 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
86
85
|
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/)
|
|
87
86
|
.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}, ..])
|
|
88
87
|
.address(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
|
|
89
|
-
.senderAddress(address) // - 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.
|
|
88
|
+
.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.
|
|
90
89
|
/*.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)
|
|
91
90
|
.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
|
|
92
91
|
.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
|
|
93
92
|
.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.*/
|
|
94
93
|
|
|
95
94
|
const tx = await builder.build()
|
|
95
|
+
// Or if you use signers in senderAddress:
|
|
96
|
+
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
96
97
|
|
|
97
98
|
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
98
99
|
await builder.disconnect()
|
|
@@ -123,6 +124,7 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
123
124
|
.to(TChain) //Has to be the same as the origin (from)
|
|
124
125
|
.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}, ..])
|
|
125
126
|
.address(address)
|
|
127
|
+
/* .keepAlive(bool) - Optional: Allows draining the account below the existential deposit. */
|
|
126
128
|
|
|
127
129
|
const tx = await builder.build()
|
|
128
130
|
|
|
@@ -147,6 +149,58 @@ await builder.disconnect()
|
|
|
147
149
|
*/
|
|
148
150
|
```
|
|
149
151
|
|
|
152
|
+
#### Transact
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
156
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
157
|
+
.to(TChain) // Has to be same as origin (from)
|
|
158
|
+
.currency(CURRENCY_SPEC) // Refer to currency spec options below
|
|
159
|
+
.senderAddress(senderAddress | PAPI SIGNER)
|
|
160
|
+
.address(address)
|
|
161
|
+
.transact(hex, /* originType, TWeight - Optional */)
|
|
162
|
+
|
|
163
|
+
const tx = await builder.build()
|
|
164
|
+
// Or if you use signers in senderAddress:
|
|
165
|
+
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
166
|
+
|
|
167
|
+
//Disconnect API after TX
|
|
168
|
+
await builder.disconnect()
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Dry run your XCM Calls:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
//Builder pattern
|
|
175
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
176
|
+
.from(TSubstrateChain)
|
|
177
|
+
.to(TChain)
|
|
178
|
+
.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*/}]})
|
|
179
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
180
|
+
.address(ADDRESS)
|
|
181
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
182
|
+
.dryRun()
|
|
183
|
+
|
|
184
|
+
//Check Parachain for DryRun support - returns true/false
|
|
185
|
+
import { hasDryRunSupport } from "@paraspell/sdk";
|
|
186
|
+
|
|
187
|
+
const result = hasDryRunSupport(TChain)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Dry run preview:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
//Builder pattern
|
|
194
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
195
|
+
.from(TSubstrateChain)
|
|
196
|
+
.to(TChain)
|
|
197
|
+
.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*/}]})
|
|
198
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
199
|
+
.address(ADDRESS)
|
|
200
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
201
|
+
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
202
|
+
```
|
|
203
|
+
|
|
150
204
|
#### Batch calls
|
|
151
205
|
|
|
152
206
|
```ts
|
|
@@ -189,39 +243,6 @@ const tx = await builder.build()
|
|
|
189
243
|
await builder.disconnect()
|
|
190
244
|
```
|
|
191
245
|
|
|
192
|
-
#### Dry run your XCM Calls:
|
|
193
|
-
|
|
194
|
-
```ts
|
|
195
|
-
//Builder pattern
|
|
196
|
-
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
197
|
-
.from(TSubstrateChain)
|
|
198
|
-
.to(TChain)
|
|
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*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
200
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
201
|
-
.address(ADDRESS)
|
|
202
|
-
.senderAddress(SENDER_ADDRESS)
|
|
203
|
-
.dryRun()
|
|
204
|
-
|
|
205
|
-
//Check Parachain for DryRun support - returns true/false
|
|
206
|
-
import { hasDryRunSupport } from "@paraspell/sdk";
|
|
207
|
-
|
|
208
|
-
const result = hasDryRunSupport(TChain)
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
#### Dry run preview:
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
//Builder pattern
|
|
215
|
-
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
216
|
-
.from(TSubstrateChain)
|
|
217
|
-
.to(TChain)
|
|
218
|
-
.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*/}]})
|
|
219
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
220
|
-
.address(ADDRESS)
|
|
221
|
-
.senderAddress(SENDER_ADDRESS)
|
|
222
|
-
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
223
|
-
```
|
|
224
|
-
|
|
225
246
|
### Localhost test setup
|
|
226
247
|
|
|
227
248
|
```ts
|
|
@@ -239,7 +260,7 @@ const builder = await Builder({
|
|
|
239
260
|
.to(TChain)
|
|
240
261
|
.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*/}])
|
|
241
262
|
.address(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
|
|
242
|
-
.senderAddress(address) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
263
|
+
.senderAddress(address | PAPI_SIGNER) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
243
264
|
|
|
244
265
|
const tx = await builder.build()
|
|
245
266
|
//Or if you use prederived account as senderAddress:
|
|
@@ -252,90 +273,90 @@ await builder.disconnect()
|
|
|
252
273
|
### XCM Fee queries
|
|
253
274
|
For full documentation with output examples of XCM Fee queries, head to [official documentation](https://paraspell.github.io/docs/sdk/xcmUtils.html).
|
|
254
275
|
|
|
255
|
-
#### XCM
|
|
276
|
+
#### XCM Fee (Origin and Dest.)
|
|
277
|
+
|
|
256
278
|
```ts
|
|
257
|
-
const
|
|
279
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
258
280
|
.from(TSubstrateChain)
|
|
259
281
|
.to(TChain)
|
|
260
282
|
.currency(CURRENCY_SPEC)
|
|
261
283
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
262
284
|
.address(RECIPIENT_ADDRESS)
|
|
263
|
-
.senderAddress(
|
|
264
|
-
.
|
|
285
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
286
|
+
.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.
|
|
265
287
|
```
|
|
266
288
|
|
|
267
|
-
####
|
|
289
|
+
#### XCM Fee (Origin only)
|
|
290
|
+
|
|
268
291
|
```ts
|
|
269
|
-
const
|
|
292
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
270
293
|
.from(TSubstrateChain)
|
|
271
294
|
.to(TChain)
|
|
272
295
|
.currency(CURRENCY_SPEC)
|
|
273
296
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
274
297
|
.address(RECIPIENT_ADDRESS)
|
|
275
|
-
.senderAddress(
|
|
276
|
-
.
|
|
298
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
299
|
+
.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.
|
|
277
300
|
```
|
|
278
301
|
|
|
279
|
-
####
|
|
302
|
+
#### XCM Transfer info
|
|
280
303
|
```ts
|
|
281
|
-
const
|
|
304
|
+
const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
282
305
|
.from(TSubstrateChain)
|
|
283
306
|
.to(TChain)
|
|
284
307
|
.currency(CURRENCY_SPEC)
|
|
285
308
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
286
309
|
.address(RECIPIENT_ADDRESS)
|
|
287
|
-
.senderAddress(
|
|
288
|
-
.
|
|
310
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
311
|
+
.getTransferInfo()
|
|
289
312
|
```
|
|
290
313
|
|
|
291
|
-
####
|
|
314
|
+
#### Transferable amount
|
|
292
315
|
```ts
|
|
293
|
-
const
|
|
316
|
+
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
294
317
|
.from(TSubstrateChain)
|
|
295
318
|
.to(TChain)
|
|
296
319
|
.currency(CURRENCY_SPEC)
|
|
297
320
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
298
321
|
.address(RECIPIENT_ADDRESS)
|
|
299
|
-
.senderAddress(
|
|
300
|
-
.
|
|
322
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
323
|
+
.getTransferableAmount()
|
|
301
324
|
```
|
|
302
325
|
|
|
303
|
-
####
|
|
326
|
+
#### Minimal transferable amount
|
|
304
327
|
```ts
|
|
305
|
-
const
|
|
328
|
+
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
306
329
|
.from(TSubstrateChain)
|
|
307
330
|
.to(TChain)
|
|
308
331
|
.currency(CURRENCY_SPEC)
|
|
309
332
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
310
333
|
.address(RECIPIENT_ADDRESS)
|
|
311
|
-
.senderAddress(
|
|
312
|
-
.
|
|
334
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
335
|
+
.getMinTransferableAmount()
|
|
313
336
|
```
|
|
314
337
|
|
|
315
|
-
####
|
|
316
|
-
|
|
338
|
+
#### Receivable amount
|
|
317
339
|
```ts
|
|
318
|
-
const
|
|
340
|
+
const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
319
341
|
.from(TSubstrateChain)
|
|
320
342
|
.to(TChain)
|
|
321
343
|
.currency(CURRENCY_SPEC)
|
|
322
344
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
323
345
|
.address(RECIPIENT_ADDRESS)
|
|
324
|
-
.senderAddress(
|
|
325
|
-
.
|
|
346
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
347
|
+
.getReceivableAmount()
|
|
326
348
|
```
|
|
327
349
|
|
|
328
|
-
####
|
|
329
|
-
|
|
350
|
+
#### Verify ED on destination
|
|
330
351
|
```ts
|
|
331
|
-
const
|
|
352
|
+
const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
332
353
|
.from(TSubstrateChain)
|
|
333
354
|
.to(TChain)
|
|
334
355
|
.currency(CURRENCY_SPEC)
|
|
335
356
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
336
357
|
.address(RECIPIENT_ADDRESS)
|
|
337
|
-
.senderAddress(
|
|
338
|
-
.
|
|
358
|
+
.senderAddress(address | PAPI_SIGNER)
|
|
359
|
+
.verifyEdOnDestination()
|
|
339
360
|
```
|
|
340
361
|
|
|
341
362
|
#### Asset balance
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
|
2
2
|
import { TApiOrUrl, TEvmChainFrom, 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';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import * as polkadot_api from 'polkadot-api';
|
|
5
|
-
import { PolkadotClient, UnsafeTransaction } from 'polkadot-api';
|
|
5
|
+
import { PolkadotClient, UnsafeTransaction, PolkadotSigner } from 'polkadot-api';
|
|
6
6
|
import { WalletClient } from 'viem';
|
|
7
7
|
|
|
8
8
|
type TPapiApi = PolkadotClient;
|
|
9
9
|
type TPapiApiOrUrl = TApiOrUrl<PolkadotClient>;
|
|
10
|
+
type TPapiSigner = PolkadotSigner;
|
|
10
11
|
type TPapiTransaction = UnsafeTransaction<any, string, string, any>;
|
|
11
12
|
type TEvmChainFromPapi = Extract<TEvmChainFrom, 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
|
|
12
13
|
|
|
@@ -81,10 +82,10 @@ declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
|
81
82
|
/**
|
|
82
83
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
83
84
|
*/
|
|
84
|
-
declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TApi, TRes>> = object> {
|
|
85
|
+
declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmBuilderOptions<TApi, TRes, TSigner>> = object> {
|
|
85
86
|
protected readonly _options: T;
|
|
86
87
|
constructor(options: T);
|
|
87
|
-
from(chain: TEvmChainFromPapi): EvmBuilderCore<TApi, TRes, T & {
|
|
88
|
+
from(chain: TEvmChainFromPapi): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
88
89
|
from: TEvmChainFromPapi;
|
|
89
90
|
}>;
|
|
90
91
|
/**
|
|
@@ -93,7 +94,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
93
94
|
* @param chain - The Polkadot chain to which the transfer will be made.
|
|
94
95
|
* @returns An instance of EvmBuilder
|
|
95
96
|
*/
|
|
96
|
-
to(chain: TChain): EvmBuilderCore<TApi, TRes, T & {
|
|
97
|
+
to(chain: TChain): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
97
98
|
to: TChain;
|
|
98
99
|
}>;
|
|
99
100
|
/**
|
|
@@ -102,7 +103,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
102
103
|
* @param currency - The currency to be transferred.
|
|
103
104
|
* @returns An instance of EvmBuilder
|
|
104
105
|
*/
|
|
105
|
-
currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, T & {
|
|
106
|
+
currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
106
107
|
currency: TCurrencyInputWithAmount;
|
|
107
108
|
}>;
|
|
108
109
|
/**
|
|
@@ -111,7 +112,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
111
112
|
* @param address - The Polkadot address to receive the transfer.
|
|
112
113
|
* @returns An instance of EvmBuilder
|
|
113
114
|
*/
|
|
114
|
-
address(address: string): EvmBuilderCore<TApi, TRes, T & {
|
|
115
|
+
address(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
115
116
|
address: string;
|
|
116
117
|
}>;
|
|
117
118
|
/**
|
|
@@ -120,7 +121,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
120
121
|
* @param address - The address to be used.
|
|
121
122
|
* @returns An instance of EvmBuilder
|
|
122
123
|
*/
|
|
123
|
-
ahAddress(address: string | undefined): EvmBuilderCore<unknown, unknown, T & {
|
|
124
|
+
ahAddress(address: string | undefined): EvmBuilderCore<unknown, unknown, unknown, T & {
|
|
124
125
|
ahAddress: string | undefined;
|
|
125
126
|
}>;
|
|
126
127
|
/**
|
|
@@ -129,7 +130,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
129
130
|
* @param signer - The Ethereum signer to authorize the transfer.
|
|
130
131
|
* @returns An instance of EvmBuilder
|
|
131
132
|
*/
|
|
132
|
-
signer(signer: WalletClient): EvmBuilderCore<TApi, TRes, T & {
|
|
133
|
+
signer(signer: WalletClient): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
133
134
|
signer: WalletClient;
|
|
134
135
|
}>;
|
|
135
136
|
/**
|
|
@@ -137,7 +138,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
137
138
|
*
|
|
138
139
|
* @throws Error if any required parameters are missing.
|
|
139
140
|
*/
|
|
140
|
-
build(this: EvmBuilderCore<TApi, TRes, TEvmBuilderOptions<TApi, TRes>>): Promise<string>;
|
|
141
|
+
build(this: EvmBuilderCore<TApi, TRes, TSigner, TEvmBuilderOptions<TApi, TRes, TSigner>>): Promise<string>;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -146,10 +147,10 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TEvmBuilderOptions<TA
|
|
|
146
147
|
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
147
148
|
* @returns A new Builder instance.
|
|
148
149
|
*/
|
|
149
|
-
declare const Builder: (api?: TBuilderOptions<TPapiApiOrUrl>) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, object>;
|
|
150
|
-
type GeneralBuilder<T extends Partial<TSendBaseOptions
|
|
151
|
-
declare const EvmBuilder: (api?: TBuilderOptions<TPapiApiOrUrl>) => EvmBuilderCore<unknown, unknown, {
|
|
152
|
-
api: _paraspell_sdk_core.IPolkadotApi<PolkadotClient, TPapiTransaction>;
|
|
150
|
+
declare const Builder: (api?: TBuilderOptions<TPapiApiOrUrl>) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, object>;
|
|
151
|
+
type GeneralBuilder<T extends Partial<TSendBaseOptions<TPapiTransaction>> = object> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T>;
|
|
152
|
+
declare const EvmBuilder: (api?: TBuilderOptions<TPapiApiOrUrl>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
153
|
+
api: _paraspell_sdk_core.IPolkadotApi<PolkadotClient, TPapiTransaction, PolkadotSigner>;
|
|
153
154
|
}>;
|
|
154
155
|
|
|
155
156
|
/**
|
|
@@ -157,7 +158,7 @@ declare const EvmBuilder: (api?: TBuilderOptions<TPapiApiOrUrl>) => EvmBuilderCo
|
|
|
157
158
|
* @param options - The transfer options.
|
|
158
159
|
* @returns An extrinsic to be signed and sent.
|
|
159
160
|
*/
|
|
160
|
-
declare const send: (options: _paraspell_sdk_core.TSendBaseOptions & {
|
|
161
|
+
declare const send: (options: _paraspell_sdk_core.TSendBaseOptions<TPapiTransaction> & {
|
|
161
162
|
isAmountAll: boolean;
|
|
162
163
|
} & {
|
|
163
164
|
api?: TPapiApiOrUrl;
|
|
@@ -209,4 +210,4 @@ declare const checkAndConvertToNumberOrBigInt: (input: string) => number | bigin
|
|
|
209
210
|
declare const transform: (obj: any) => any;
|
|
210
211
|
|
|
211
212
|
export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, claimAssets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, send, transform, transfer as xcmPallet };
|
|
212
|
-
export type { GeneralBuilder, TEvmChainFromPapi, TPapiApi, TPapiApiOrUrl, TPapiTransaction };
|
|
213
|
+
export type { GeneralBuilder, TEvmChainFromPapi, TPapiApi, TPapiApiOrUrl, TPapiSigner, TPapiTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEvmPrivateKeyHex, NumberFormatError, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, isExternalChain, Parents,
|
|
1
|
+
import { isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, isExternalChain, Parents, findAssetInfoOrThrow, computeFeeFromDryRun, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, 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, getNativeAssetSymbol, getNativeAssets, getOtherAssets, 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, send as send$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';
|
|
@@ -320,13 +320,14 @@ var createDevSigner = function createDevSigner(path) {
|
|
|
320
320
|
if (evmPrivateKey) return createEcdsaSigner(evmPrivateKey);
|
|
321
321
|
return createSr25519Signer(path);
|
|
322
322
|
};
|
|
323
|
-
var deriveAddress = function deriveAddress(
|
|
324
|
-
|
|
323
|
+
var deriveAddress = function deriveAddress(sender) {
|
|
324
|
+
if (isSenderSigner(sender)) return AccountId().dec(sender.publicKey);
|
|
325
|
+
var evmPrivateKey = getEvmPrivateKey(sender);
|
|
325
326
|
if (evmPrivateKey) {
|
|
326
327
|
var address = resolveEcdsaAddress(evmPrivateKey);
|
|
327
328
|
return "0x".concat(bytesToHex(address));
|
|
328
329
|
}
|
|
329
|
-
var keyPair = createSr25519Keypair(
|
|
330
|
+
var keyPair = createSr25519Keypair(sender);
|
|
330
331
|
return AccountId().dec(keyPair.publicKey);
|
|
331
332
|
};
|
|
332
333
|
|
|
@@ -476,6 +477,13 @@ var _transform = function transform(obj) {
|
|
|
476
477
|
jit_withdraw: (_value$jit_withdraw = value.jit_withdraw) !== null && _value$jit_withdraw !== void 0 ? _value$jit_withdraw : false
|
|
477
478
|
}
|
|
478
479
|
};
|
|
480
|
+
} else if (key === 'PayFees') {
|
|
481
|
+
return {
|
|
482
|
+
type: key,
|
|
483
|
+
value: {
|
|
484
|
+
asset: _transform(value.asset)
|
|
485
|
+
}
|
|
486
|
+
};
|
|
479
487
|
} else if (key === 'X1' && Array.isArray(value)) {
|
|
480
488
|
return {
|
|
481
489
|
type: key,
|
|
@@ -727,6 +735,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
727
735
|
var transformedParams = _transform(params);
|
|
728
736
|
return this.api.getUnsafeApi().tx[module][method](transformedParams);
|
|
729
737
|
}
|
|
738
|
+
}, {
|
|
739
|
+
key: "txFromHex",
|
|
740
|
+
value: function () {
|
|
741
|
+
var _txFromHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(hex) {
|
|
742
|
+
var callData;
|
|
743
|
+
return _regenerator().w(function (_context3) {
|
|
744
|
+
while (1) switch (_context3.n) {
|
|
745
|
+
case 0:
|
|
746
|
+
callData = Binary.fromHex(hex);
|
|
747
|
+
return _context3.a(2, this.api.getUnsafeApi().txFromCallData(callData));
|
|
748
|
+
}
|
|
749
|
+
}, _callee3, this);
|
|
750
|
+
}));
|
|
751
|
+
function txFromHex(_x3) {
|
|
752
|
+
return _txFromHex.apply(this, arguments);
|
|
753
|
+
}
|
|
754
|
+
return txFromHex;
|
|
755
|
+
}()
|
|
730
756
|
}, {
|
|
731
757
|
key: "queryState",
|
|
732
758
|
value: function queryState(_ref7) {
|
|
@@ -773,15 +799,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
773
799
|
}, {
|
|
774
800
|
key: "objectToHex",
|
|
775
801
|
value: function () {
|
|
776
|
-
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
802
|
+
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(obj, _typeName, version) {
|
|
777
803
|
var transformedObj, tx, removeFirst5Bytes, encodedData;
|
|
778
|
-
return _regenerator().w(function (
|
|
779
|
-
while (1) switch (
|
|
804
|
+
return _regenerator().w(function (_context4) {
|
|
805
|
+
while (1) switch (_context4.n) {
|
|
780
806
|
case 0:
|
|
781
807
|
transformedObj = _transform(obj);
|
|
782
808
|
tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
|
|
783
809
|
dest: {
|
|
784
|
-
type:
|
|
810
|
+
type: version,
|
|
785
811
|
value: {
|
|
786
812
|
parents: Parents.ZERO,
|
|
787
813
|
interior: {
|
|
@@ -794,15 +820,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
794
820
|
removeFirst5Bytes = function removeFirst5Bytes(hexString) {
|
|
795
821
|
return '0x' + hexString.slice(12);
|
|
796
822
|
};
|
|
797
|
-
|
|
823
|
+
_context4.n = 1;
|
|
798
824
|
return tx.getEncodedData();
|
|
799
825
|
case 1:
|
|
800
|
-
encodedData =
|
|
801
|
-
return
|
|
826
|
+
encodedData = _context4.v;
|
|
827
|
+
return _context4.a(2, removeFirst5Bytes(encodedData.asHex()));
|
|
802
828
|
}
|
|
803
|
-
},
|
|
829
|
+
}, _callee4, this);
|
|
804
830
|
}));
|
|
805
|
-
function objectToHex(
|
|
831
|
+
function objectToHex(_x4, _x5, _x6) {
|
|
806
832
|
return _objectToHex.apply(this, arguments);
|
|
807
833
|
}
|
|
808
834
|
return objectToHex;
|
|
@@ -827,30 +853,30 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
827
853
|
}, {
|
|
828
854
|
key: "hasMethod",
|
|
829
855
|
value: function () {
|
|
830
|
-
var _hasMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
856
|
+
var _hasMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(pallet, method) {
|
|
831
857
|
var _t;
|
|
832
|
-
return _regenerator().w(function (
|
|
833
|
-
while (1) switch (
|
|
858
|
+
return _regenerator().w(function (_context5) {
|
|
859
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
834
860
|
case 0:
|
|
835
|
-
|
|
836
|
-
|
|
861
|
+
_context5.p = 0;
|
|
862
|
+
_context5.n = 1;
|
|
837
863
|
return this.api.getUnsafeApi().tx[pallet][method]().getEncodedData();
|
|
838
864
|
case 1:
|
|
839
|
-
return
|
|
865
|
+
return _context5.a(2, true);
|
|
840
866
|
case 2:
|
|
841
|
-
|
|
842
|
-
_t =
|
|
867
|
+
_context5.p = 2;
|
|
868
|
+
_t = _context5.v;
|
|
843
869
|
if (!(_t instanceof Error && _t.message.includes("Runtime entry Tx(".concat(pallet, ".").concat(method, ") not found")))) {
|
|
844
|
-
|
|
870
|
+
_context5.n = 3;
|
|
845
871
|
break;
|
|
846
872
|
}
|
|
847
|
-
return
|
|
873
|
+
return _context5.a(2, false);
|
|
848
874
|
case 3:
|
|
849
|
-
return
|
|
875
|
+
return _context5.a(2, true);
|
|
850
876
|
}
|
|
851
|
-
},
|
|
877
|
+
}, _callee5, this, [[0, 2]]);
|
|
852
878
|
}));
|
|
853
|
-
function hasMethod(
|
|
879
|
+
function hasMethod(_x7, _x8) {
|
|
854
880
|
return _hasMethod.apply(this, arguments);
|
|
855
881
|
}
|
|
856
882
|
return hasMethod;
|
|
@@ -867,45 +893,60 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
867
893
|
return tx.decodedCall.value.value.assets.value.length;
|
|
868
894
|
}
|
|
869
895
|
}, {
|
|
870
|
-
key: "
|
|
896
|
+
key: "getPaymentInfo",
|
|
871
897
|
value: function () {
|
|
872
|
-
var
|
|
873
|
-
|
|
874
|
-
|
|
898
|
+
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(tx, address) {
|
|
899
|
+
var _yield$tx$getPaymentI, partial_fee, _yield$tx$getPaymentI2, proof_size, ref_time;
|
|
900
|
+
return _regenerator().w(function (_context6) {
|
|
901
|
+
while (1) switch (_context6.n) {
|
|
875
902
|
case 0:
|
|
876
|
-
|
|
903
|
+
_context6.n = 1;
|
|
904
|
+
return tx.getPaymentInfo(address);
|
|
905
|
+
case 1:
|
|
906
|
+
_yield$tx$getPaymentI = _context6.v;
|
|
907
|
+
partial_fee = _yield$tx$getPaymentI.partial_fee;
|
|
908
|
+
_yield$tx$getPaymentI2 = _yield$tx$getPaymentI.weight;
|
|
909
|
+
proof_size = _yield$tx$getPaymentI2.proof_size;
|
|
910
|
+
ref_time = _yield$tx$getPaymentI2.ref_time;
|
|
911
|
+
return _context6.a(2, {
|
|
912
|
+
partialFee: partial_fee,
|
|
913
|
+
weight: {
|
|
914
|
+
proofSize: proof_size,
|
|
915
|
+
refTime: ref_time
|
|
916
|
+
}
|
|
917
|
+
});
|
|
877
918
|
}
|
|
878
|
-
},
|
|
919
|
+
}, _callee6);
|
|
879
920
|
}));
|
|
880
|
-
function
|
|
881
|
-
return
|
|
921
|
+
function getPaymentInfo(_x9, _x0) {
|
|
922
|
+
return _getPaymentInfo.apply(this, arguments);
|
|
882
923
|
}
|
|
883
|
-
return
|
|
924
|
+
return getPaymentInfo;
|
|
884
925
|
}()
|
|
885
926
|
}, {
|
|
886
927
|
key: "quoteAhPrice",
|
|
887
928
|
value: function () {
|
|
888
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
929
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(fromMl, toMl, amountIn) {
|
|
889
930
|
var includeFee,
|
|
890
931
|
transformedFromMl,
|
|
891
932
|
transformedToMl,
|
|
892
933
|
response,
|
|
893
|
-
|
|
894
|
-
return _regenerator().w(function (
|
|
895
|
-
while (1) switch (
|
|
934
|
+
_args6 = arguments;
|
|
935
|
+
return _regenerator().w(function (_context7) {
|
|
936
|
+
while (1) switch (_context7.n) {
|
|
896
937
|
case 0:
|
|
897
|
-
includeFee =
|
|
938
|
+
includeFee = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : true;
|
|
898
939
|
transformedFromMl = _transform(fromMl);
|
|
899
940
|
transformedToMl = _transform(toMl);
|
|
900
|
-
|
|
941
|
+
_context7.n = 1;
|
|
901
942
|
return this.api.getUnsafeApi().apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
|
|
902
943
|
case 1:
|
|
903
|
-
response =
|
|
904
|
-
return
|
|
944
|
+
response = _context7.v;
|
|
945
|
+
return _context7.a(2, response ? BigInt(response) : undefined);
|
|
905
946
|
}
|
|
906
|
-
},
|
|
947
|
+
}, _callee7, this);
|
|
907
948
|
}));
|
|
908
|
-
function quoteAhPrice(
|
|
949
|
+
function quoteAhPrice(_x1, _x10, _x11) {
|
|
909
950
|
return _quoteAhPrice.apply(this, arguments);
|
|
910
951
|
}
|
|
911
952
|
return quoteAhPrice;
|
|
@@ -918,20 +959,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
918
959
|
}, {
|
|
919
960
|
key: "getFromRpc",
|
|
920
961
|
value: function () {
|
|
921
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
962
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(module, method, key) {
|
|
922
963
|
var value;
|
|
923
|
-
return _regenerator().w(function (
|
|
924
|
-
while (1) switch (
|
|
964
|
+
return _regenerator().w(function (_context8) {
|
|
965
|
+
while (1) switch (_context8.n) {
|
|
925
966
|
case 0:
|
|
926
|
-
|
|
967
|
+
_context8.n = 1;
|
|
927
968
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? AccountId().dec(key) : key]);
|
|
928
969
|
case 1:
|
|
929
|
-
value =
|
|
930
|
-
return
|
|
970
|
+
value = _context8.v;
|
|
971
|
+
return _context8.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
931
972
|
}
|
|
932
|
-
},
|
|
973
|
+
}, _callee8, this);
|
|
933
974
|
}));
|
|
934
|
-
function getFromRpc(
|
|
975
|
+
function getFromRpc(_x12, _x13, _x14) {
|
|
935
976
|
return _getFromRpc.apply(this, arguments);
|
|
936
977
|
}
|
|
937
978
|
return getFromRpc;
|
|
@@ -944,20 +985,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
944
985
|
}, {
|
|
945
986
|
key: "createApiForChain",
|
|
946
987
|
value: function () {
|
|
947
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
988
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(chain) {
|
|
948
989
|
var api;
|
|
949
|
-
return _regenerator().w(function (
|
|
950
|
-
while (1) switch (
|
|
990
|
+
return _regenerator().w(function (_context9) {
|
|
991
|
+
while (1) switch (_context9.n) {
|
|
951
992
|
case 0:
|
|
952
993
|
api = new PapiApi();
|
|
953
|
-
|
|
994
|
+
_context9.n = 1;
|
|
954
995
|
return api.init(chain);
|
|
955
996
|
case 1:
|
|
956
|
-
return
|
|
997
|
+
return _context9.a(2, api);
|
|
957
998
|
}
|
|
958
|
-
},
|
|
999
|
+
}, _callee9);
|
|
959
1000
|
}));
|
|
960
|
-
function createApiForChain(
|
|
1001
|
+
function createApiForChain(_x15) {
|
|
961
1002
|
return _createApiForChain.apply(this, arguments);
|
|
962
1003
|
}
|
|
963
1004
|
return createApiForChain;
|
|
@@ -972,44 +1013,44 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
972
1013
|
}, {
|
|
973
1014
|
key: "resolveFeeAsset",
|
|
974
1015
|
value: function () {
|
|
975
|
-
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1016
|
+
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
|
|
976
1017
|
var chain, address, assetId;
|
|
977
|
-
return _regenerator().w(function (
|
|
978
|
-
while (1) switch (
|
|
1018
|
+
return _regenerator().w(function (_context0) {
|
|
1019
|
+
while (1) switch (_context0.n) {
|
|
979
1020
|
case 0:
|
|
980
1021
|
chain = options.chain, address = options.address;
|
|
981
1022
|
if (chain.startsWith('Hydration')) {
|
|
982
|
-
|
|
1023
|
+
_context0.n = 1;
|
|
983
1024
|
break;
|
|
984
1025
|
}
|
|
985
|
-
return
|
|
1026
|
+
return _context0.a(2, {
|
|
986
1027
|
isCustomAsset: false,
|
|
987
1028
|
asset: this.resolveDefaultFeeAsset(options)
|
|
988
1029
|
});
|
|
989
1030
|
case 1:
|
|
990
|
-
|
|
1031
|
+
_context0.n = 2;
|
|
991
1032
|
return this.api.getUnsafeApi().query.MultiTransactionPayment.AccountCurrencyMap.getValue(address);
|
|
992
1033
|
case 2:
|
|
993
|
-
assetId =
|
|
1034
|
+
assetId = _context0.v;
|
|
994
1035
|
if (!(assetId === undefined)) {
|
|
995
|
-
|
|
1036
|
+
_context0.n = 3;
|
|
996
1037
|
break;
|
|
997
1038
|
}
|
|
998
|
-
return
|
|
1039
|
+
return _context0.a(2, {
|
|
999
1040
|
isCustomAsset: false,
|
|
1000
1041
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1001
1042
|
});
|
|
1002
1043
|
case 3:
|
|
1003
|
-
return
|
|
1044
|
+
return _context0.a(2, {
|
|
1004
1045
|
isCustomAsset: true,
|
|
1005
1046
|
asset: findAssetInfoOrThrow(chain, {
|
|
1006
1047
|
id: assetId
|
|
1007
1048
|
}, null)
|
|
1008
1049
|
});
|
|
1009
1050
|
}
|
|
1010
|
-
},
|
|
1051
|
+
}, _callee0, this);
|
|
1011
1052
|
}));
|
|
1012
|
-
function resolveFeeAsset(
|
|
1053
|
+
function resolveFeeAsset(_x16) {
|
|
1013
1054
|
return _resolveFeeAsset.apply(this, arguments);
|
|
1014
1055
|
}
|
|
1015
1056
|
return resolveFeeAsset;
|
|
@@ -1019,11 +1060,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1019
1060
|
value: function () {
|
|
1020
1061
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
|
|
1021
1062
|
var _this = this;
|
|
1022
|
-
var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi,
|
|
1063
|
+
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, resolvedFeeAsset, actualWeight, weight, forwardedXcms, destParaId, hasLocation, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t2, _t3;
|
|
1023
1064
|
return _regenerator().w(function (_context10) {
|
|
1024
1065
|
while (1) switch (_context10.n) {
|
|
1025
1066
|
case 0:
|
|
1026
|
-
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1067
|
+
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1027
1068
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1028
1069
|
if (supportsDryRunApi) {
|
|
1029
1070
|
_context10.n = 1;
|
|
@@ -1031,7 +1072,6 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1031
1072
|
}
|
|
1032
1073
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1033
1074
|
case 1:
|
|
1034
|
-
DEFAULT_XCM_VERSION = 3;
|
|
1035
1075
|
basePayload = {
|
|
1036
1076
|
type: 'system',
|
|
1037
1077
|
value: useRootOrigin ? {
|
|
@@ -1058,21 +1098,22 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1058
1098
|
case 4:
|
|
1059
1099
|
resolvedTx = _t2;
|
|
1060
1100
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1061
|
-
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1101
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(includeVersion) {
|
|
1062
1102
|
var _this$api$getUnsafeAp3;
|
|
1063
|
-
var callArgs;
|
|
1064
|
-
return _regenerator().w(function (
|
|
1065
|
-
while (1) switch (
|
|
1103
|
+
var callArgs, versionNum;
|
|
1104
|
+
return _regenerator().w(function (_context1) {
|
|
1105
|
+
while (1) switch (_context1.n) {
|
|
1066
1106
|
case 0:
|
|
1067
1107
|
callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1068
1108
|
if (includeVersion) {
|
|
1069
|
-
|
|
1109
|
+
versionNum = Number(version.charAt(1));
|
|
1110
|
+
callArgs.push(versionNum);
|
|
1070
1111
|
}
|
|
1071
|
-
return
|
|
1112
|
+
return _context1.a(2, (_this$api$getUnsafeAp3 = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp3, callArgs));
|
|
1072
1113
|
}
|
|
1073
|
-
},
|
|
1114
|
+
}, _callee1);
|
|
1074
1115
|
}));
|
|
1075
|
-
return function performDryRunCall(
|
|
1116
|
+
return function performDryRunCall(_x18) {
|
|
1076
1117
|
return _ref0.apply(this, arguments);
|
|
1077
1118
|
};
|
|
1078
1119
|
}();
|
|
@@ -1182,33 +1223,14 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1182
1223
|
_context10.n = 15;
|
|
1183
1224
|
break;
|
|
1184
1225
|
}
|
|
1185
|
-
getPaymentInfoWeight = /*#__PURE__*/function () {
|
|
1186
|
-
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
1187
|
-
var _yield$tx$getPaymentI, weight;
|
|
1188
|
-
return _regenerator().w(function (_context1) {
|
|
1189
|
-
while (1) switch (_context1.n) {
|
|
1190
|
-
case 0:
|
|
1191
|
-
_context1.n = 1;
|
|
1192
|
-
return tx.getPaymentInfo(address);
|
|
1193
|
-
case 1:
|
|
1194
|
-
_yield$tx$getPaymentI = _context1.v;
|
|
1195
|
-
weight = _yield$tx$getPaymentI.weight;
|
|
1196
|
-
return _context1.a(2, weight);
|
|
1197
|
-
}
|
|
1198
|
-
}, _callee1);
|
|
1199
|
-
}));
|
|
1200
|
-
return function getPaymentInfoWeight() {
|
|
1201
|
-
return _ref10.apply(this, arguments);
|
|
1202
|
-
};
|
|
1203
|
-
}();
|
|
1204
1226
|
if (result.value.local_xcm) {
|
|
1205
1227
|
_context10.n = 11;
|
|
1206
1228
|
break;
|
|
1207
1229
|
}
|
|
1208
1230
|
_context10.n = 10;
|
|
1209
|
-
return
|
|
1231
|
+
return this.getPaymentInfo(tx, address);
|
|
1210
1232
|
case 10:
|
|
1211
|
-
_t3 = _context10.v;
|
|
1233
|
+
_t3 = _context10.v.weight;
|
|
1212
1234
|
_context10.n = 12;
|
|
1213
1235
|
break;
|
|
1214
1236
|
case 11:
|
|
@@ -1216,7 +1238,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1216
1238
|
case 12:
|
|
1217
1239
|
overriddenWeight = _t3;
|
|
1218
1240
|
_context10.n = 13;
|
|
1219
|
-
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, false, overriddenWeight);
|
|
1241
|
+
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
1220
1242
|
case 13:
|
|
1221
1243
|
xcmFee = _context10.v;
|
|
1222
1244
|
if (!(typeof xcmFee === 'bigint')) {
|
|
@@ -1238,9 +1260,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1238
1260
|
};
|
|
1239
1261
|
case 15:
|
|
1240
1262
|
_context10.n = 16;
|
|
1241
|
-
return this.
|
|
1263
|
+
return this.getPaymentInfo(tx, address);
|
|
1242
1264
|
case 16:
|
|
1243
|
-
|
|
1265
|
+
_yield$this$getPaymen = _context10.v;
|
|
1266
|
+
executionFee = _yield$this$getPaymen.partialFee;
|
|
1244
1267
|
fee = computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
|
|
1245
1268
|
return _context10.a(2, Promise.resolve({
|
|
1246
1269
|
success: true,
|
|
@@ -1253,7 +1276,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1253
1276
|
}
|
|
1254
1277
|
}, _callee10, this);
|
|
1255
1278
|
}));
|
|
1256
|
-
function getDryRunCall(
|
|
1279
|
+
function getDryRunCall(_x17) {
|
|
1257
1280
|
return _getDryRunCall.apply(this, arguments);
|
|
1258
1281
|
}
|
|
1259
1282
|
return getDryRunCall;
|
|
@@ -1278,7 +1301,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1278
1301
|
}
|
|
1279
1302
|
}, _callee11, this);
|
|
1280
1303
|
}));
|
|
1281
|
-
function getXcmWeight(
|
|
1304
|
+
function getXcmWeight(_x19) {
|
|
1282
1305
|
return _getXcmWeight.apply(this, arguments);
|
|
1283
1306
|
}
|
|
1284
1307
|
return getXcmWeight;
|
|
@@ -1286,7 +1309,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1286
1309
|
}, {
|
|
1287
1310
|
key: "getDeliveryFee",
|
|
1288
1311
|
value: function () {
|
|
1289
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, forwardedXcm, asset, assetLocalizedLoc) {
|
|
1312
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
1290
1313
|
var _deliveryFeeRes, _deliveryFeeRes2;
|
|
1291
1314
|
var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res, _t4, _t5;
|
|
1292
1315
|
return _regenerator().w(function (_context12) {
|
|
@@ -1316,7 +1339,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1316
1339
|
break;
|
|
1317
1340
|
}
|
|
1318
1341
|
usedThirdParam = true;
|
|
1319
|
-
transformedAssetLoc = _transform(addXcmVersionHeader(assetLocalizedLoc,
|
|
1342
|
+
transformedAssetLoc = _transform(addXcmVersionHeader(assetLocalizedLoc, version));
|
|
1320
1343
|
_context12.n = 4;
|
|
1321
1344
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs.concat([transformedAssetLoc]));
|
|
1322
1345
|
case 4:
|
|
@@ -1356,7 +1379,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1356
1379
|
}
|
|
1357
1380
|
}, _callee12, this, [[7, 9], [1, 3]]);
|
|
1358
1381
|
}));
|
|
1359
|
-
function getDeliveryFee(
|
|
1382
|
+
function getDeliveryFee(_x20, _x21, _x22, _x23, _x24) {
|
|
1360
1383
|
return _getDeliveryFee.apply(this, arguments);
|
|
1361
1384
|
}
|
|
1362
1385
|
return getDeliveryFee;
|
|
@@ -1364,7 +1387,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1364
1387
|
}, {
|
|
1365
1388
|
key: "getXcmPaymentApiFee",
|
|
1366
1389
|
value: function () {
|
|
1367
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset) {
|
|
1390
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset, version) {
|
|
1368
1391
|
var _this2 = this,
|
|
1369
1392
|
_execFeeRes$value;
|
|
1370
1393
|
var transformXcm,
|
|
@@ -1383,11 +1406,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1383
1406
|
return _regenerator().w(function (_context14) {
|
|
1384
1407
|
while (1) switch (_context14.n) {
|
|
1385
1408
|
case 0:
|
|
1386
|
-
transformXcm = _args13.length >
|
|
1387
|
-
overridenWeight = _args13.length >
|
|
1409
|
+
transformXcm = _args13.length > 5 && _args13[5] !== undefined ? _args13[5] : false;
|
|
1410
|
+
overridenWeight = _args13.length > 6 ? _args13[6] : undefined;
|
|
1388
1411
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1389
1412
|
queryWeight = /*#__PURE__*/function () {
|
|
1390
|
-
var
|
|
1413
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1391
1414
|
var weightRes;
|
|
1392
1415
|
return _regenerator().w(function (_context13) {
|
|
1393
1416
|
while (1) switch (_context13.n) {
|
|
@@ -1401,14 +1424,17 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1401
1424
|
}, _callee13);
|
|
1402
1425
|
}));
|
|
1403
1426
|
return function queryWeight() {
|
|
1404
|
-
return
|
|
1427
|
+
return _ref10.apply(this, arguments);
|
|
1405
1428
|
};
|
|
1406
1429
|
}();
|
|
1407
|
-
if (!
|
|
1430
|
+
if (!overridenWeight) {
|
|
1408
1431
|
_context14.n = 1;
|
|
1409
1432
|
break;
|
|
1410
1433
|
}
|
|
1411
|
-
_t6 =
|
|
1434
|
+
_t6 = {
|
|
1435
|
+
proof_size: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.proofSize,
|
|
1436
|
+
ref_time: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.refTime
|
|
1437
|
+
};
|
|
1412
1438
|
_context14.n = 3;
|
|
1413
1439
|
break;
|
|
1414
1440
|
case 1:
|
|
@@ -1423,7 +1449,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1423
1449
|
transformedAssetLoc = _transform(assetLocalizedLoc);
|
|
1424
1450
|
_context14.n = 4;
|
|
1425
1451
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight, {
|
|
1426
|
-
type:
|
|
1452
|
+
type: version,
|
|
1427
1453
|
value: transformedAssetLoc
|
|
1428
1454
|
});
|
|
1429
1455
|
case 4:
|
|
@@ -1434,7 +1460,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1434
1460
|
break;
|
|
1435
1461
|
}
|
|
1436
1462
|
_context14.n = 5;
|
|
1437
|
-
return this.getBridgeHubFallbackExecFee(chain, weight, asset);
|
|
1463
|
+
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
1438
1464
|
case 5:
|
|
1439
1465
|
bridgeHubExecFee = _context14.v;
|
|
1440
1466
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
@@ -1442,14 +1468,14 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1442
1468
|
}
|
|
1443
1469
|
case 6:
|
|
1444
1470
|
_context14.n = 7;
|
|
1445
|
-
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc);
|
|
1471
|
+
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
1446
1472
|
case 7:
|
|
1447
1473
|
deliveryFee = _context14.v;
|
|
1448
1474
|
return _context14.a(2, execFee + deliveryFee);
|
|
1449
1475
|
}
|
|
1450
1476
|
}, _callee14, this);
|
|
1451
1477
|
}));
|
|
1452
|
-
function getXcmPaymentApiFee(
|
|
1478
|
+
function getXcmPaymentApiFee(_x25, _x26, _x27, _x28, _x29) {
|
|
1453
1479
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1454
1480
|
}
|
|
1455
1481
|
return getXcmPaymentApiFee;
|
|
@@ -1457,14 +1483,14 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1457
1483
|
}, {
|
|
1458
1484
|
key: "getBridgeHubFallbackExecFee",
|
|
1459
1485
|
value: function () {
|
|
1460
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(chain, weightValue, asset) {
|
|
1486
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(chain, weightValue, asset, version) {
|
|
1461
1487
|
var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1462
1488
|
return _regenerator().w(function (_context15) {
|
|
1463
1489
|
while (1) switch (_context15.n) {
|
|
1464
1490
|
case 0:
|
|
1465
1491
|
_context15.n = 1;
|
|
1466
1492
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
|
|
1467
|
-
type:
|
|
1493
|
+
type: version,
|
|
1468
1494
|
value: _transform(RELAY_LOCATION)
|
|
1469
1495
|
});
|
|
1470
1496
|
case 1:
|
|
@@ -1496,7 +1522,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1496
1522
|
}
|
|
1497
1523
|
}, _callee15, this);
|
|
1498
1524
|
}));
|
|
1499
|
-
function getBridgeHubFallbackExecFee(
|
|
1525
|
+
function getBridgeHubFallbackExecFee(_x30, _x31, _x32, _x33) {
|
|
1500
1526
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1501
1527
|
}
|
|
1502
1528
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1504,13 +1530,13 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1504
1530
|
}, {
|
|
1505
1531
|
key: "getDryRunXcm",
|
|
1506
1532
|
value: function () {
|
|
1507
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(
|
|
1508
|
-
var
|
|
1509
|
-
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1533
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref11) {
|
|
1534
|
+
var _ref12, _processAssetsDeposit, _ref13, _ref14, _ref15, _ref16, _ref17;
|
|
1535
|
+
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1510
1536
|
return _regenerator().w(function (_context16) {
|
|
1511
1537
|
while (1) switch (_context16.n) {
|
|
1512
1538
|
case 0:
|
|
1513
|
-
originLocation =
|
|
1539
|
+
originLocation = _ref11.originLocation, xcm = _ref11.xcm, chain = _ref11.chain, origin = _ref11.origin, asset = _ref11.asset, feeAsset = _ref11.feeAsset, originFee = _ref11.originFee, amount = _ref11.amount, version = _ref11.version;
|
|
1514
1540
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1515
1541
|
if (supportsDryRunApi) {
|
|
1516
1542
|
_context16.n = 1;
|
|
@@ -1547,7 +1573,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1547
1573
|
break;
|
|
1548
1574
|
}
|
|
1549
1575
|
_context16.n = 4;
|
|
1550
|
-
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1576
|
+
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1551
1577
|
case 4:
|
|
1552
1578
|
_fee = _context16.v;
|
|
1553
1579
|
if (!(typeof _fee === 'bigint')) {
|
|
@@ -1567,15 +1593,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1567
1593
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1568
1594
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1569
1595
|
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
|
|
1570
|
-
feeAssetFeeEvent = (
|
|
1596
|
+
feeAssetFeeEvent = (_ref12 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1571
1597
|
return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
|
|
1572
|
-
}) : undefined) !== null &&
|
|
1598
|
+
}) : undefined) !== null && _ref12 !== void 0 ? _ref12 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1573
1599
|
return event.type === 'Tokens' && event.value.type === 'Deposited';
|
|
1574
1600
|
}) : undefined;
|
|
1575
1601
|
processedAssetsAmount = chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount, 'Assets', 'Deposited', true) : (_processAssetsDeposit = processAssetsDepositedEvents(emitted, amount, 'Balances', 'Minted', false)) !== null && _processAssetsDeposit !== void 0 ? _processAssetsDeposit : processAssetsDepositedEvents(emitted, amount, 'Balances', 'Issued', false);
|
|
1576
|
-
feeEvent = (_ref14 = (_ref15 = (_ref16 = (_ref17 =
|
|
1602
|
+
feeEvent = (_ref13 = (_ref14 = (_ref15 = (_ref16 = (_ref17 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent : chain === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1577
1603
|
return event.type === 'Balances' && event.value.type === 'Issued';
|
|
1578
|
-
}) : undefined) !== null &&
|
|
1604
|
+
}) : undefined) !== null && _ref17 !== void 0 ? _ref17 : processedAssetsAmount !== undefined ? {
|
|
1579
1605
|
type: 'Assets',
|
|
1580
1606
|
value: {
|
|
1581
1607
|
type: 'Deposited',
|
|
@@ -1583,17 +1609,17 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1583
1609
|
amount: processedAssetsAmount
|
|
1584
1610
|
}
|
|
1585
1611
|
}
|
|
1586
|
-
} : undefined) !== null &&
|
|
1612
|
+
} : undefined) !== null && _ref16 !== void 0 ? _ref16 : origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
|
|
1587
1613
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1588
|
-
}) : undefined) !== null &&
|
|
1614
|
+
}) : undefined) !== null && _ref15 !== void 0 ? _ref15 :
|
|
1589
1615
|
// Prefer to Minted event
|
|
1590
1616
|
reversedEvents.find(function (event) {
|
|
1591
1617
|
return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
|
|
1592
|
-
})) !== null &&
|
|
1618
|
+
})) !== null && _ref14 !== void 0 ? _ref14 :
|
|
1593
1619
|
// Fallback an Issued event
|
|
1594
1620
|
reversedEvents.find(function (event) {
|
|
1595
1621
|
return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
|
|
1596
|
-
})) !== null &&
|
|
1622
|
+
})) !== null && _ref13 !== void 0 ? _ref13 : reversedEvents.find(function (event) {
|
|
1597
1623
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1598
1624
|
});
|
|
1599
1625
|
if (feeEvent) {
|
|
@@ -1622,7 +1648,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1622
1648
|
}
|
|
1623
1649
|
}, _callee16, this);
|
|
1624
1650
|
}));
|
|
1625
|
-
function getDryRunXcm(
|
|
1651
|
+
function getDryRunXcm(_x34) {
|
|
1626
1652
|
return _getDryRunXcm.apply(this, arguments);
|
|
1627
1653
|
}
|
|
1628
1654
|
return getDryRunXcm;
|
|
@@ -1683,18 +1709,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1683
1709
|
}
|
|
1684
1710
|
}, {
|
|
1685
1711
|
key: "deriveAddress",
|
|
1686
|
-
value: function deriveAddress$1(
|
|
1687
|
-
return deriveAddress(
|
|
1712
|
+
value: function deriveAddress$1(sender) {
|
|
1713
|
+
return deriveAddress(sender);
|
|
1688
1714
|
}
|
|
1689
1715
|
}, {
|
|
1690
1716
|
key: "signAndSubmit",
|
|
1691
1717
|
value: function () {
|
|
1692
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(tx,
|
|
1718
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(tx, sender) {
|
|
1693
1719
|
var signer, _yield$tx$signAndSubm, txHash;
|
|
1694
1720
|
return _regenerator().w(function (_context18) {
|
|
1695
1721
|
while (1) switch (_context18.n) {
|
|
1696
1722
|
case 0:
|
|
1697
|
-
signer = createDevSigner(
|
|
1723
|
+
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1698
1724
|
_context18.n = 1;
|
|
1699
1725
|
return tx.signAndSubmit(signer);
|
|
1700
1726
|
case 1:
|
|
@@ -1704,7 +1730,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1704
1730
|
}
|
|
1705
1731
|
}, _callee18);
|
|
1706
1732
|
}));
|
|
1707
|
-
function signAndSubmit(
|
|
1733
|
+
function signAndSubmit(_x35, _x36) {
|
|
1708
1734
|
return _signAndSubmit.apply(this, arguments);
|
|
1709
1735
|
}
|
|
1710
1736
|
return signAndSubmit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.6.0",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@noble/hashes": "^2.0.1",
|
|
27
|
-
"@polkadot-api/legacy-provider": "^0.3.
|
|
27
|
+
"@polkadot-api/legacy-provider": "^0.3.8",
|
|
28
28
|
"@polkadot-labs/hdkd": "^0.0.26",
|
|
29
29
|
"@polkadot-labs/hdkd-helpers": "^0.0.27",
|
|
30
30
|
"viem": "2.45.0",
|
|
31
|
-
"@paraspell/sdk-core": "12.
|
|
31
|
+
"@paraspell/sdk-core": "12.6.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"polkadot-api": ">= 1.23.
|
|
34
|
+
"polkadot-api": ">= 1.23.3 < 2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@acala-network/chopsticks": "^1.2.5",
|
|
38
|
-
"@babel/plugin-syntax-import-attributes": "^7.
|
|
39
|
-
"@babel/preset-env": "^7.28.
|
|
38
|
+
"@babel/plugin-syntax-import-attributes": "^7.28.6",
|
|
39
|
+
"@babel/preset-env": "^7.28.6",
|
|
40
40
|
"@codecov/rollup-plugin": "^1.9.1",
|
|
41
41
|
"@noble/curves": "^2.0.1",
|
|
42
42
|
"@rollup/plugin-babel": "^6.1.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
45
45
|
"@scure/bip32": "^2.0.1",
|
|
46
46
|
"@scure/bip39": "^2.0.1",
|
|
47
|
-
"@vitest/coverage-v8": "^4.0.
|
|
48
|
-
"axios": "^1.13.
|
|
47
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
48
|
+
"axios": "^1.13.4",
|
|
49
49
|
"dotenv": "^17.2.3",
|
|
50
|
-
"rollup": "^4.
|
|
50
|
+
"rollup": "^4.57.0",
|
|
51
51
|
"rollup-plugin-dts": "^6.3.0",
|
|
52
52
|
"tslib": "^2.8.1"
|
|
53
53
|
},
|