@paraspell/sdk-pjs 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 +90 -69
- package/dist/index.d.ts +27 -23
- package/dist/index.mjs +210 -198
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -65,14 +65,13 @@ import { Native, Foreign, ForeignAbstract } from '@paraspell/sdk-pjs'; //Only ne
|
|
|
65
65
|
## Implementation
|
|
66
66
|
|
|
67
67
|
> [!NOTE]
|
|
68
|
-
> - Local transfers are now available for every currency and every chain. To try them, simply use the same origin and destination parameters.
|
|
69
|
-
> - Transfer info queries are now all in the Builder pattern and don't require any imports other than the builder.
|
|
70
|
-
> - You can now query Ethereum asset balances on Ethereum via balance query
|
|
71
|
-
> - 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.
|
|
72
68
|
> - Brand new asset decimal abstraction introduced. It can be turned on in Builder config. Will be turned on by default in next major release.
|
|
69
|
+
> - V11 > V12 Migration guide https://paraspell.github.io/docs/migration/v11-to-v12.html
|
|
73
70
|
>
|
|
74
71
|
> **Latest news:**
|
|
75
|
-
> -
|
|
72
|
+
> - You can now pass signer directly into senderAddress parameter
|
|
73
|
+
> - The local transfers now have additional builder parameter called keepAlive
|
|
74
|
+
> - Transact is here! Find out more: https://paraspell.github.io/docs/sdk/xcmPallet.html#transact
|
|
76
75
|
|
|
77
76
|
|
|
78
77
|
### Sending XCM
|
|
@@ -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 /*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}, ..])
|
|
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 | {address, PJS_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,8 @@ 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. */
|
|
128
|
+
|
|
126
129
|
|
|
127
130
|
const tx = await builder.build()
|
|
128
131
|
|
|
@@ -147,6 +150,56 @@ await builder.disconnect()
|
|
|
147
150
|
*/
|
|
148
151
|
```
|
|
149
152
|
|
|
153
|
+
#### Transact
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
157
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
158
|
+
.to(TChain) // Has to be same as origin (from)
|
|
159
|
+
.currency(CURRENCY_SPEC) // Refer to currency spec options below
|
|
160
|
+
.senderAddress(senderAddress | PAPI SIGNER)
|
|
161
|
+
.address(address)
|
|
162
|
+
.transact(hex, /* originType, TWeight - Optional */)
|
|
163
|
+
|
|
164
|
+
const tx = await builder.build()
|
|
165
|
+
// Or if you use signers in senderAddress:
|
|
166
|
+
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
167
|
+
|
|
168
|
+
//Disconnect API after TX
|
|
169
|
+
await builder.disconnect()
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Dry run your XCM Calls:
|
|
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 | {address, PJS_Signer})
|
|
182
|
+
.dryRun()
|
|
183
|
+
|
|
184
|
+
//Check Parachain for DryRun support - returns true/false
|
|
185
|
+
import { hasDryRunSupport } from "@paraspell/sdk";
|
|
186
|
+
|
|
187
|
+
const result = hasDryRunSupport(chain)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Dry run preview:
|
|
191
|
+
```ts
|
|
192
|
+
//Builder pattern
|
|
193
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
194
|
+
.from(TSubstrateChain)
|
|
195
|
+
.to(TChain)
|
|
196
|
+
.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*/}]})
|
|
197
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
198
|
+
.address(ADDRESS)
|
|
199
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
200
|
+
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
201
|
+
```
|
|
202
|
+
|
|
150
203
|
#### Batch calls
|
|
151
204
|
|
|
152
205
|
```ts
|
|
@@ -189,38 +242,6 @@ const tx = await builder.build()
|
|
|
189
242
|
await builder.disconnect()
|
|
190
243
|
```
|
|
191
244
|
|
|
192
|
-
#### Dry run your XCM Calls:
|
|
193
|
-
```ts
|
|
194
|
-
//Builder pattern
|
|
195
|
-
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
196
|
-
.from(TSubstrateChain)
|
|
197
|
-
.to(TChain)
|
|
198
|
-
.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*/}]})
|
|
199
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
200
|
-
.address(ADDRESS)
|
|
201
|
-
.senderAddress(SENDER_ADDRESS)
|
|
202
|
-
.dryRun()
|
|
203
|
-
|
|
204
|
-
//Check Parachain for DryRun support - returns true/false
|
|
205
|
-
import { hasDryRunSupport } from "@paraspell/sdk";
|
|
206
|
-
|
|
207
|
-
const result = hasDryRunSupport(chain)
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
#### Dry run preview:
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
//Builder pattern
|
|
214
|
-
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
215
|
-
.from(TSubstrateChain)
|
|
216
|
-
.to(TChain)
|
|
217
|
-
.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*/}]})
|
|
218
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
219
|
-
.address(ADDRESS)
|
|
220
|
-
.senderAddress(SENDER_ADDRESS)
|
|
221
|
-
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
222
|
-
```
|
|
223
|
-
|
|
224
245
|
### Localhost test setup
|
|
225
246
|
|
|
226
247
|
```ts
|
|
@@ -237,7 +258,7 @@ const builder = await Builder({
|
|
|
237
258
|
.to(TChain)
|
|
238
259
|
.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*/}])
|
|
239
260
|
.address(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
|
|
240
|
-
.senderAddress(address) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
261
|
+
.senderAddress(address | {address, PJS_Signer}) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
241
262
|
|
|
242
263
|
const tx = await builder.build()
|
|
243
264
|
//Or if you use prederived account as senderAddress:
|
|
@@ -251,90 +272,90 @@ await builder.disconnect()
|
|
|
251
272
|
|
|
252
273
|
For full documentation with output examples of XCM Fee queries, head to [official documentation](https://paraspell.github.io/docs/sdk/xcmUtils.html).
|
|
253
274
|
|
|
254
|
-
#### XCM
|
|
275
|
+
#### XCM Fee (Origin and Dest.)
|
|
276
|
+
|
|
255
277
|
```ts
|
|
256
|
-
const
|
|
278
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
257
279
|
.from(TSubstrateChain)
|
|
258
280
|
.to(TChain)
|
|
259
281
|
.currency(CURRENCY_SPEC)
|
|
260
282
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
261
283
|
.address(RECIPIENT_ADDRESS)
|
|
262
|
-
.senderAddress(
|
|
263
|
-
.
|
|
284
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
285
|
+
.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.
|
|
264
286
|
```
|
|
265
287
|
|
|
266
|
-
####
|
|
288
|
+
#### XCM Fee (Origin only)
|
|
289
|
+
|
|
267
290
|
```ts
|
|
268
|
-
const
|
|
291
|
+
const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
269
292
|
.from(TSubstrateChain)
|
|
270
293
|
.to(TChain)
|
|
271
294
|
.currency(CURRENCY_SPEC)
|
|
272
295
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
273
296
|
.address(RECIPIENT_ADDRESS)
|
|
274
|
-
.senderAddress(
|
|
275
|
-
.
|
|
297
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
298
|
+
.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.
|
|
276
299
|
```
|
|
277
300
|
|
|
278
|
-
####
|
|
301
|
+
#### XCM Transfer info
|
|
279
302
|
```ts
|
|
280
|
-
const
|
|
303
|
+
const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
281
304
|
.from(TSubstrateChain)
|
|
282
305
|
.to(TChain)
|
|
283
306
|
.currency(CURRENCY_SPEC)
|
|
284
307
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
285
308
|
.address(RECIPIENT_ADDRESS)
|
|
286
|
-
.senderAddress(
|
|
287
|
-
.
|
|
309
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
310
|
+
.getTransferInfo()
|
|
288
311
|
```
|
|
289
312
|
|
|
290
|
-
####
|
|
313
|
+
#### Transferable amount
|
|
291
314
|
```ts
|
|
292
|
-
const
|
|
315
|
+
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
293
316
|
.from(TSubstrateChain)
|
|
294
317
|
.to(TChain)
|
|
295
318
|
.currency(CURRENCY_SPEC)
|
|
296
319
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
297
320
|
.address(RECIPIENT_ADDRESS)
|
|
298
|
-
.senderAddress(
|
|
299
|
-
.
|
|
321
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
322
|
+
.getTransferableAmount()
|
|
300
323
|
```
|
|
301
324
|
|
|
302
|
-
####
|
|
325
|
+
#### Minimal transferable amount
|
|
303
326
|
```ts
|
|
304
|
-
const
|
|
327
|
+
const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
305
328
|
.from(TSubstrateChain)
|
|
306
329
|
.to(TChain)
|
|
307
330
|
.currency(CURRENCY_SPEC)
|
|
308
331
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
309
332
|
.address(RECIPIENT_ADDRESS)
|
|
310
|
-
.senderAddress(
|
|
311
|
-
.
|
|
333
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
334
|
+
.getMinTransferableAmount()
|
|
312
335
|
```
|
|
313
336
|
|
|
314
|
-
####
|
|
315
|
-
|
|
337
|
+
#### Receivable amount
|
|
316
338
|
```ts
|
|
317
|
-
const
|
|
339
|
+
const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
318
340
|
.from(TSubstrateChain)
|
|
319
341
|
.to(TChain)
|
|
320
342
|
.currency(CURRENCY_SPEC)
|
|
321
343
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
322
344
|
.address(RECIPIENT_ADDRESS)
|
|
323
|
-
.senderAddress(
|
|
324
|
-
.
|
|
345
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
346
|
+
.getReceivableAmount()
|
|
325
347
|
```
|
|
326
348
|
|
|
327
|
-
####
|
|
328
|
-
|
|
349
|
+
#### Verify ED on destination
|
|
329
350
|
```ts
|
|
330
|
-
const
|
|
351
|
+
const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
331
352
|
.from(TSubstrateChain)
|
|
332
353
|
.to(TChain)
|
|
333
354
|
.currency(CURRENCY_SPEC)
|
|
334
355
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
335
356
|
.address(RECIPIENT_ADDRESS)
|
|
336
|
-
.senderAddress(
|
|
337
|
-
.
|
|
357
|
+
.senderAddress(address | {address, PJS_Signer})
|
|
358
|
+
.verifyEdOnDestination()
|
|
338
359
|
```
|
|
339
360
|
|
|
340
361
|
#### Asset balance
|
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,19 @@ import { TApiOrUrl, WithApi, TEvmChainFrom, TChain, TCurrencyInputWithAmount, Fo
|
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import * as _polkadot_api from '@polkadot/api';
|
|
5
5
|
import { ApiPromise } from '@polkadot/api';
|
|
6
|
-
import { SubmittableExtrinsic } from '@polkadot/api/types';
|
|
6
|
+
import { SubmittableExtrinsic, Signer } from '@polkadot/api/types';
|
|
7
7
|
import * as ethers from 'ethers';
|
|
8
|
-
import { Signer, AbstractProvider } from 'ethers';
|
|
8
|
+
import { Signer as Signer$1, AbstractProvider } from 'ethers';
|
|
9
9
|
import { WalletClient } from 'viem';
|
|
10
10
|
import * as _snowbridge_api_dist_toPolkadot_v2 from '@snowbridge/api/dist/toPolkadot_v2';
|
|
11
11
|
|
|
12
12
|
type TPjsApi = ApiPromise;
|
|
13
13
|
type TPjsApiOrUrl = TApiOrUrl<TPjsApi>;
|
|
14
14
|
type Extrinsic = SubmittableExtrinsic<'promise'>;
|
|
15
|
+
type TPjsSigner = {
|
|
16
|
+
signer: Signer;
|
|
17
|
+
address: string;
|
|
18
|
+
};
|
|
15
19
|
type TEvmBuilderOptionsBase = {
|
|
16
20
|
/**
|
|
17
21
|
* The source chain. Can be either 'Ethereum', 'Moonbeam', 'Moonriver', or 'Darwinia'.
|
|
@@ -36,9 +40,9 @@ type TEvmBuilderOptionsBase = {
|
|
|
36
40
|
/**
|
|
37
41
|
* The Ethereum signer.
|
|
38
42
|
*/
|
|
39
|
-
signer: Signer | WalletClient;
|
|
43
|
+
signer: Signer$1 | WalletClient;
|
|
40
44
|
};
|
|
41
|
-
type TPjsEvmBuilderOptions<TApi, TRes> = WithApi<TEvmBuilderOptionsBase, TApi, TRes> & {
|
|
45
|
+
type TPjsEvmBuilderOptions<TApi, TRes, TSigner> = WithApi<TEvmBuilderOptionsBase, TApi, TRes, TSigner> & {
|
|
42
46
|
provider?: AbstractProvider;
|
|
43
47
|
};
|
|
44
48
|
|
|
@@ -113,10 +117,10 @@ declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
|
113
117
|
/**
|
|
114
118
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
115
119
|
*/
|
|
116
|
-
declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions<TApi, TRes>> = object> {
|
|
120
|
+
declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuilderOptions<TApi, TRes, TSigner>> = object> {
|
|
117
121
|
protected readonly _options: T;
|
|
118
122
|
constructor(options: T);
|
|
119
|
-
from(chain: TEvmChainFrom): EvmBuilderCore<TApi, TRes, T & {
|
|
123
|
+
from(chain: TEvmChainFrom): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
120
124
|
from: TEvmChainFrom;
|
|
121
125
|
}>;
|
|
122
126
|
/**
|
|
@@ -125,7 +129,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions
|
|
|
125
129
|
* @param chain - The Polkadot chain to which the transfer will be made.
|
|
126
130
|
* @returns An instance of EvmBuilder
|
|
127
131
|
*/
|
|
128
|
-
to(chain: TChain): EvmBuilderCore<TApi, TRes, T & {
|
|
132
|
+
to(chain: TChain): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
129
133
|
to: TChain;
|
|
130
134
|
}>;
|
|
131
135
|
/**
|
|
@@ -134,7 +138,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions
|
|
|
134
138
|
* @param currency - The currency to be transferred.
|
|
135
139
|
* @returns An instance of EvmBuilder
|
|
136
140
|
*/
|
|
137
|
-
currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, T & {
|
|
141
|
+
currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
138
142
|
currency: TCurrencyInputWithAmount;
|
|
139
143
|
}>;
|
|
140
144
|
/**
|
|
@@ -143,7 +147,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions
|
|
|
143
147
|
* @param address - The Polkadot address to receive the transfer.
|
|
144
148
|
* @returns An instance of EvmBuilder
|
|
145
149
|
*/
|
|
146
|
-
address(address: string): EvmBuilderCore<TApi, TRes, T & {
|
|
150
|
+
address(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
147
151
|
address: string;
|
|
148
152
|
}>;
|
|
149
153
|
/**
|
|
@@ -152,7 +156,7 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions
|
|
|
152
156
|
* @param address - The address to be used.
|
|
153
157
|
* @returns An instance of EvmBuilder
|
|
154
158
|
*/
|
|
155
|
-
ahAddress(address: string | undefined): EvmBuilderCore<unknown, unknown, T & {
|
|
159
|
+
ahAddress(address: string | undefined): EvmBuilderCore<unknown, unknown, unknown, T & {
|
|
156
160
|
ahAddress: string | undefined;
|
|
157
161
|
}>;
|
|
158
162
|
/**
|
|
@@ -161,15 +165,15 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions
|
|
|
161
165
|
* @param signer - The Ethereum signer to authorize the transfer.
|
|
162
166
|
* @returns An instance of EvmBuilder
|
|
163
167
|
*/
|
|
164
|
-
signer(signer: Signer | WalletClient): EvmBuilderCore<TApi, TRes, T & {
|
|
165
|
-
signer: Signer | WalletClient;
|
|
168
|
+
signer(signer: Signer$1 | WalletClient): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
169
|
+
signer: Signer$1 | WalletClient;
|
|
166
170
|
}>;
|
|
167
171
|
/**
|
|
168
172
|
* Builds and executes the transfer from Ethereum to Polkadot.
|
|
169
173
|
*
|
|
170
174
|
* @throws Error if any required parameters are missing.
|
|
171
175
|
*/
|
|
172
|
-
build(this: EvmBuilderCore<TApi, TRes, TPjsEvmBuilderOptions<TApi, TRes>>): Promise<string>;
|
|
176
|
+
build(this: EvmBuilderCore<TApi, TRes, TSigner, TPjsEvmBuilderOptions<TApi, TRes, TSigner>>): Promise<string>;
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
/**
|
|
@@ -178,31 +182,31 @@ declare class EvmBuilderCore<TApi, TRes, T extends Partial<TPjsEvmBuilderOptions
|
|
|
178
182
|
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
179
183
|
* @returns A new Builder instance.
|
|
180
184
|
*/
|
|
181
|
-
declare const Builder: (api?: TBuilderOptions<TPjsApiOrUrl>) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, object>;
|
|
182
|
-
type GeneralBuilder<T extends Partial<TSendBaseOptions
|
|
183
|
-
declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<TPjsApiOrUrl>) => EvmBuilderCore<unknown, unknown, {
|
|
184
|
-
api: _paraspell_sdk_core.IPolkadotApi<_polkadot_api.ApiPromise, Extrinsic>;
|
|
185
|
+
declare const Builder: (api?: TBuilderOptions<TPjsApiOrUrl>) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object>;
|
|
186
|
+
type GeneralBuilder<T extends Partial<TSendBaseOptions<Extrinsic>> = object> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T>;
|
|
187
|
+
declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<TPjsApiOrUrl>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
188
|
+
api: _paraspell_sdk_core.IPolkadotApi<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner>;
|
|
185
189
|
provider: AbstractProvider | undefined;
|
|
186
190
|
}>;
|
|
187
191
|
|
|
188
|
-
declare const approveToken: (signer: Signer, amount: bigint, symbol: string) => Promise<{
|
|
192
|
+
declare const approveToken: (signer: Signer$1, amount: bigint, symbol: string) => Promise<{
|
|
189
193
|
result: ethers.ContractTransactionResponse;
|
|
190
194
|
receipt: ethers.ContractTransactionReceipt | null;
|
|
191
195
|
}>;
|
|
192
196
|
|
|
193
|
-
declare const depositToken: (signer: Signer, amount: bigint, symbol: string) => Promise<{
|
|
197
|
+
declare const depositToken: (signer: Signer$1, amount: bigint, symbol: string) => Promise<{
|
|
194
198
|
result: ethers.ContractTransactionResponse;
|
|
195
199
|
receipt: ethers.ContractTransactionReceipt | null;
|
|
196
200
|
}>;
|
|
197
201
|
|
|
198
|
-
declare const getTokenBalance: (signer: Signer, symbol: string) => Promise<bigint>;
|
|
202
|
+
declare const getTokenBalance: (signer: Signer$1, symbol: string) => Promise<bigint>;
|
|
199
203
|
|
|
200
204
|
/**
|
|
201
205
|
* Transfers assets from parachain to another parachain or from/to relay chain.
|
|
202
206
|
* @param options - The transfer options.
|
|
203
207
|
* @returns An extrinsic to be signed and sent.
|
|
204
208
|
*/
|
|
205
|
-
declare const send: (options: _paraspell_sdk_core.TSendBaseOptions & {
|
|
209
|
+
declare const send: (options: _paraspell_sdk_core.TSendBaseOptions<Extrinsic> & {
|
|
206
210
|
isAmountAll: boolean;
|
|
207
211
|
} & {
|
|
208
212
|
api?: TPjsApiOrUrl;
|
|
@@ -213,7 +217,7 @@ declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<Extrinsic
|
|
|
213
217
|
declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<Extrinsic> & {
|
|
214
218
|
api?: TPjsApiOrUrl;
|
|
215
219
|
}) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
|
|
216
|
-
declare const transferEthToPolkadot: (options: Omit<TPjsEvmBuilderOptions<TPjsApi, Extrinsic>, "api">) => Promise<{
|
|
220
|
+
declare const transferEthToPolkadot: (options: Omit<TPjsEvmBuilderOptions<TPjsApi, Extrinsic, TPjsSigner>, "api">) => Promise<{
|
|
217
221
|
response: ethers.TransactionResponse;
|
|
218
222
|
messageReceipt: _snowbridge_api_dist_toPolkadot_v2.MessageReceipt;
|
|
219
223
|
}>;
|
|
@@ -249,4 +253,4 @@ declare namespace transfer {
|
|
|
249
253
|
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TPjsApiOrUrl>) => Promise<_polkadot_api.ApiPromise>;
|
|
250
254
|
|
|
251
255
|
export { Builder, EvmBuilder, approveToken, assets, claimAssets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, send, transferEthToPolkadot, transfer as xcmPallet };
|
|
252
|
-
export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsApiOrUrl, TPjsEvmBuilderOptions };
|
|
256
|
+
export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsApiOrUrl, TPjsEvmBuilderOptions, TPjsSigner };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEvmPrivateKeyHex, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, addXcmVersionHeader,
|
|
1
|
+
import { getEvmPrivateKeyHex, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, BatchMode, findNativeAssetInfoOrThrow, isSenderSigner, MissingChainApiError, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, 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, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
|
|
4
4
|
import { isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
@@ -410,6 +410,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
410
410
|
method = _this$convertToPjsCal.method;
|
|
411
411
|
return (_this$api$tx$module = this.api.tx[module])[method].apply(_this$api$tx$module, values);
|
|
412
412
|
}
|
|
413
|
+
}, {
|
|
414
|
+
key: "txFromHex",
|
|
415
|
+
value: function txFromHex(hex) {
|
|
416
|
+
return Promise.resolve(this.api.tx(hex));
|
|
417
|
+
}
|
|
413
418
|
}, {
|
|
414
419
|
key: "queryState",
|
|
415
420
|
value: function () {
|
|
@@ -476,10 +481,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
476
481
|
return stringToU8a(str);
|
|
477
482
|
}
|
|
478
483
|
}, {
|
|
479
|
-
key: "
|
|
484
|
+
key: "getPaymentInfo",
|
|
480
485
|
value: function () {
|
|
481
|
-
var
|
|
482
|
-
var _yield$tx$paymentInfo, partialFee;
|
|
486
|
+
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(tx, address) {
|
|
487
|
+
var _yield$tx$paymentInfo, _yield$tx$paymentInfo2, proofSize, refTime, partialFee;
|
|
483
488
|
return _regenerator().w(function (_context5) {
|
|
484
489
|
while (1) switch (_context5.n) {
|
|
485
490
|
case 0:
|
|
@@ -487,15 +492,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
487
492
|
return tx.paymentInfo(address);
|
|
488
493
|
case 1:
|
|
489
494
|
_yield$tx$paymentInfo = _context5.v;
|
|
495
|
+
_yield$tx$paymentInfo2 = _yield$tx$paymentInfo.weight;
|
|
496
|
+
proofSize = _yield$tx$paymentInfo2.proofSize;
|
|
497
|
+
refTime = _yield$tx$paymentInfo2.refTime;
|
|
490
498
|
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
491
|
-
return _context5.a(2,
|
|
499
|
+
return _context5.a(2, {
|
|
500
|
+
weight: {
|
|
501
|
+
proofSize: proofSize.toBigInt(),
|
|
502
|
+
refTime: refTime.toBigInt()
|
|
503
|
+
},
|
|
504
|
+
partialFee: partialFee.toBigInt()
|
|
505
|
+
});
|
|
492
506
|
}
|
|
493
507
|
}, _callee5);
|
|
494
508
|
}));
|
|
495
|
-
function
|
|
496
|
-
return
|
|
509
|
+
function getPaymentInfo(_x5, _x6) {
|
|
510
|
+
return _getPaymentInfo.apply(this, arguments);
|
|
497
511
|
}
|
|
498
|
-
return
|
|
512
|
+
return getPaymentInfo;
|
|
499
513
|
}()
|
|
500
514
|
}, {
|
|
501
515
|
key: "quoteAhPrice",
|
|
@@ -661,21 +675,20 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
661
675
|
}, {
|
|
662
676
|
key: "getDryRunCall",
|
|
663
677
|
value: function () {
|
|
664
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
678
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
|
|
665
679
|
var _this = this;
|
|
666
|
-
var tx, address, feeAsset, chain, destination, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi,
|
|
667
|
-
return _regenerator().w(function (
|
|
668
|
-
while (1) switch (
|
|
680
|
+
var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, nativeAsset, hasLocation, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
|
|
681
|
+
return _regenerator().w(function (_context1) {
|
|
682
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
669
683
|
case 0:
|
|
670
|
-
tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
|
|
684
|
+
tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
|
|
671
685
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
672
686
|
if (supportsDryRunApi) {
|
|
673
|
-
|
|
687
|
+
_context1.n = 1;
|
|
674
688
|
break;
|
|
675
689
|
}
|
|
676
690
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
677
691
|
case 1:
|
|
678
|
-
DEFAULT_XCM_VERSION = 3;
|
|
679
692
|
basePayload = useRootOrigin ? {
|
|
680
693
|
system: {
|
|
681
694
|
Root: null
|
|
@@ -686,32 +699,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
686
699
|
}
|
|
687
700
|
};
|
|
688
701
|
if (!useRootOrigin) {
|
|
689
|
-
|
|
702
|
+
_context1.n = 3;
|
|
690
703
|
break;
|
|
691
704
|
}
|
|
692
|
-
|
|
705
|
+
_context1.n = 2;
|
|
693
706
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
694
707
|
api: this
|
|
695
708
|
}), bypassOptions);
|
|
696
709
|
case 2:
|
|
697
|
-
_t =
|
|
698
|
-
|
|
710
|
+
_t = _context1.v;
|
|
711
|
+
_context1.n = 4;
|
|
699
712
|
break;
|
|
700
713
|
case 3:
|
|
701
714
|
_t = tx;
|
|
702
715
|
case 4:
|
|
703
716
|
resolvedTx = _t;
|
|
704
|
-
|
|
717
|
+
_context1.n = 5;
|
|
705
718
|
return this.resolveFeeAsset(options);
|
|
706
719
|
case 5:
|
|
707
|
-
resolvedFeeAsset =
|
|
720
|
+
resolvedFeeAsset = _context1.v;
|
|
708
721
|
performDryRunCall = /*#__PURE__*/function () {
|
|
709
722
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
|
|
710
723
|
var _this$api$call$dryRun;
|
|
724
|
+
var versionNum;
|
|
711
725
|
return _regenerator().w(function (_context0) {
|
|
712
726
|
while (1) switch (_context0.n) {
|
|
713
727
|
case 0:
|
|
714
|
-
|
|
728
|
+
versionNum = Number(version.charAt(1));
|
|
729
|
+
return _context0.a(2, (_this$api$call$dryRun = _this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
|
|
715
730
|
}
|
|
716
731
|
}, _callee0);
|
|
717
732
|
}));
|
|
@@ -759,11 +774,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
759
774
|
failureReason: ''
|
|
760
775
|
};
|
|
761
776
|
shouldRetryWithVersion = false;
|
|
762
|
-
|
|
763
|
-
|
|
777
|
+
_context1.p = 6;
|
|
778
|
+
_context1.n = 7;
|
|
764
779
|
return performDryRunCall(false);
|
|
765
780
|
case 7:
|
|
766
|
-
response =
|
|
781
|
+
response = _context1.v;
|
|
767
782
|
resultHuman = response.toHuman();
|
|
768
783
|
resultJson = response.toJSON();
|
|
769
784
|
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
@@ -773,49 +788,49 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
773
788
|
shouldRetryWithVersion = true;
|
|
774
789
|
}
|
|
775
790
|
}
|
|
776
|
-
|
|
791
|
+
_context1.n = 10;
|
|
777
792
|
break;
|
|
778
793
|
case 8:
|
|
779
|
-
|
|
780
|
-
_t2 =
|
|
794
|
+
_context1.p = 8;
|
|
795
|
+
_t2 = _context1.v;
|
|
781
796
|
msg = _t2 instanceof Error ? _t2.message : String(_t2);
|
|
782
797
|
if (!msg.includes('Expected 3 arguments')) {
|
|
783
|
-
|
|
798
|
+
_context1.n = 9;
|
|
784
799
|
break;
|
|
785
800
|
}
|
|
786
801
|
shouldRetryWithVersion = true;
|
|
787
|
-
|
|
802
|
+
_context1.n = 10;
|
|
788
803
|
break;
|
|
789
804
|
case 9:
|
|
790
|
-
return
|
|
805
|
+
return _context1.a(2, {
|
|
791
806
|
success: false,
|
|
792
807
|
failureReason: msg,
|
|
793
808
|
asset: resolvedFeeAsset.asset
|
|
794
809
|
});
|
|
795
810
|
case 10:
|
|
796
811
|
if (!shouldRetryWithVersion) {
|
|
797
|
-
|
|
812
|
+
_context1.n = 14;
|
|
798
813
|
break;
|
|
799
814
|
}
|
|
800
|
-
|
|
801
|
-
|
|
815
|
+
_context1.p = 11;
|
|
816
|
+
_context1.n = 12;
|
|
802
817
|
return performDryRunCall(true);
|
|
803
818
|
case 12:
|
|
804
|
-
response =
|
|
819
|
+
response = _context1.v;
|
|
805
820
|
resultHuman = response.toHuman();
|
|
806
821
|
resultJson = response.toJSON();
|
|
807
822
|
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
808
823
|
if (!isSuccess) {
|
|
809
824
|
failureErr = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
810
825
|
}
|
|
811
|
-
|
|
826
|
+
_context1.n = 14;
|
|
812
827
|
break;
|
|
813
828
|
case 13:
|
|
814
|
-
|
|
815
|
-
_t3 =
|
|
829
|
+
_context1.p = 13;
|
|
830
|
+
_t3 = _context1.v;
|
|
816
831
|
_msg = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
817
832
|
failureErr = failureErr || _msg;
|
|
818
|
-
return
|
|
833
|
+
return _context1.a(2, {
|
|
819
834
|
success: false,
|
|
820
835
|
failureReason: failureErr.failureReason,
|
|
821
836
|
failureSubReason: failureErr.failureSubReason,
|
|
@@ -823,10 +838,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
823
838
|
});
|
|
824
839
|
case 14:
|
|
825
840
|
if (isSuccess) {
|
|
826
|
-
|
|
841
|
+
_context1.n = 15;
|
|
827
842
|
break;
|
|
828
843
|
}
|
|
829
|
-
return
|
|
844
|
+
return _context1.a(2, {
|
|
830
845
|
success: false,
|
|
831
846
|
failureReason: failureErr.failureReason || 'Unknown error',
|
|
832
847
|
failureSubReason: failureErr.failureSubReason,
|
|
@@ -845,51 +860,32 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
845
860
|
return i.here === null ? 0 : (_ref7 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref7 === void 0 ? void 0 : _ref7.parachain;
|
|
846
861
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
847
862
|
if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
848
|
-
|
|
863
|
+
_context1.n = 21;
|
|
849
864
|
break;
|
|
850
865
|
}
|
|
851
|
-
getPaymentInfoWeight = /*#__PURE__*/function () {
|
|
852
|
-
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
853
|
-
var _yield$tx$paymentInfo2, weight;
|
|
854
|
-
return _regenerator().w(function (_context1) {
|
|
855
|
-
while (1) switch (_context1.n) {
|
|
856
|
-
case 0:
|
|
857
|
-
_context1.n = 1;
|
|
858
|
-
return tx.paymentInfo(address);
|
|
859
|
-
case 1:
|
|
860
|
-
_yield$tx$paymentInfo2 = _context1.v;
|
|
861
|
-
weight = _yield$tx$paymentInfo2.weight;
|
|
862
|
-
return _context1.a(2, weight);
|
|
863
|
-
}
|
|
864
|
-
}, _callee1);
|
|
865
|
-
}));
|
|
866
|
-
return function getPaymentInfoWeight() {
|
|
867
|
-
return _ref8.apply(this, arguments);
|
|
868
|
-
};
|
|
869
|
-
}();
|
|
870
866
|
if (resultJson.ok.local_xcm) {
|
|
871
|
-
|
|
867
|
+
_context1.n = 17;
|
|
872
868
|
break;
|
|
873
869
|
}
|
|
874
|
-
|
|
875
|
-
return
|
|
870
|
+
_context1.n = 16;
|
|
871
|
+
return this.getPaymentInfo(tx, address);
|
|
876
872
|
case 16:
|
|
877
|
-
_t4 =
|
|
878
|
-
|
|
873
|
+
_t4 = _context1.v.weight;
|
|
874
|
+
_context1.n = 18;
|
|
879
875
|
break;
|
|
880
876
|
case 17:
|
|
881
877
|
_t4 = undefined;
|
|
882
878
|
case 18:
|
|
883
879
|
overriddenWeight = _t4;
|
|
884
|
-
|
|
885
|
-
return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, resolvedFeeAsset.asset, false, overriddenWeight);
|
|
880
|
+
_context1.n = 19;
|
|
881
|
+
return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
886
882
|
case 19:
|
|
887
|
-
xcmFee =
|
|
883
|
+
xcmFee = _context1.v;
|
|
888
884
|
if (!(typeof xcmFee === 'bigint')) {
|
|
889
|
-
|
|
885
|
+
_context1.n = 20;
|
|
890
886
|
break;
|
|
891
887
|
}
|
|
892
|
-
return
|
|
888
|
+
return _context1.a(2, Promise.resolve({
|
|
893
889
|
success: true,
|
|
894
890
|
fee: xcmFee,
|
|
895
891
|
asset: resolvedFeeAsset.asset,
|
|
@@ -903,12 +899,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
903
899
|
asset: this.resolveDefaultFeeAsset(options)
|
|
904
900
|
};
|
|
905
901
|
case 21:
|
|
906
|
-
|
|
907
|
-
return this.
|
|
902
|
+
_context1.n = 22;
|
|
903
|
+
return this.getPaymentInfo(tx, address);
|
|
908
904
|
case 22:
|
|
909
|
-
|
|
905
|
+
_yield$this$getPaymen = _context1.v;
|
|
906
|
+
executionFee = _yield$this$getPaymen.partialFee;
|
|
910
907
|
fee = computeFeeFromDryRunPjs(resultHuman, chain, executionFee);
|
|
911
|
-
return
|
|
908
|
+
return _context1.a(2, {
|
|
912
909
|
success: true,
|
|
913
910
|
fee: fee,
|
|
914
911
|
asset: resolvedFeeAsset.asset,
|
|
@@ -917,7 +914,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
917
914
|
destParaId: destParaId
|
|
918
915
|
});
|
|
919
916
|
}
|
|
920
|
-
},
|
|
917
|
+
}, _callee1, this, [[11, 13], [6, 8]]);
|
|
921
918
|
}));
|
|
922
919
|
function getDryRunCall(_x13) {
|
|
923
920
|
return _getDryRunCall.apply(this, arguments);
|
|
@@ -927,7 +924,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
927
924
|
}, {
|
|
928
925
|
key: "getXcmPaymentApiFee",
|
|
929
926
|
value: function () {
|
|
930
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
927
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, localXcm, forwardedXcm, asset, version) {
|
|
931
928
|
var overridenWeight,
|
|
932
929
|
weight,
|
|
933
930
|
assetLocalizedLoc,
|
|
@@ -938,57 +935,57 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
938
935
|
isAssetNotFound,
|
|
939
936
|
bridgeHubExecFee,
|
|
940
937
|
deliveryFee,
|
|
941
|
-
|
|
938
|
+
_args0 = arguments,
|
|
942
939
|
_t5;
|
|
943
|
-
return _regenerator().w(function (
|
|
944
|
-
while (1) switch (
|
|
940
|
+
return _regenerator().w(function (_context10) {
|
|
941
|
+
while (1) switch (_context10.n) {
|
|
945
942
|
case 0:
|
|
946
|
-
overridenWeight =
|
|
943
|
+
overridenWeight = _args0.length > 6 ? _args0[6] : undefined;
|
|
947
944
|
if (!(overridenWeight !== null && overridenWeight !== void 0)) {
|
|
948
|
-
|
|
945
|
+
_context10.n = 1;
|
|
949
946
|
break;
|
|
950
947
|
}
|
|
951
948
|
_t5 = overridenWeight;
|
|
952
|
-
|
|
949
|
+
_context10.n = 3;
|
|
953
950
|
break;
|
|
954
951
|
case 1:
|
|
955
|
-
|
|
952
|
+
_context10.n = 2;
|
|
956
953
|
return this.getXcmWeight(localXcm);
|
|
957
954
|
case 2:
|
|
958
|
-
_t5 =
|
|
955
|
+
_t5 = _context10.v;
|
|
959
956
|
case 3:
|
|
960
957
|
weight = _t5;
|
|
961
958
|
assertHasLocation(asset);
|
|
962
959
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
963
|
-
|
|
964
|
-
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetLocalizedLoc,
|
|
960
|
+
_context10.n = 4;
|
|
961
|
+
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetLocalizedLoc, version));
|
|
965
962
|
case 4:
|
|
966
|
-
feeResult =
|
|
963
|
+
feeResult = _context10.v;
|
|
967
964
|
execFeeRes = feeResult.toJSON();
|
|
968
965
|
execFeeOk = execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.ok;
|
|
969
966
|
execFee = typeof execFeeOk === 'string' || typeof execFeeOk === 'number' ? BigInt(execFeeOk) : 0n;
|
|
970
967
|
isAssetNotFound = (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.err) === 'AssetNotFound';
|
|
971
968
|
if (!(chain.startsWith('BridgeHub') && isAssetNotFound)) {
|
|
972
|
-
|
|
969
|
+
_context10.n = 6;
|
|
973
970
|
break;
|
|
974
971
|
}
|
|
975
|
-
|
|
976
|
-
return this.getBridgeHubFallbackExecFee(chain, weight, asset);
|
|
972
|
+
_context10.n = 5;
|
|
973
|
+
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
977
974
|
case 5:
|
|
978
|
-
bridgeHubExecFee =
|
|
975
|
+
bridgeHubExecFee = _context10.v;
|
|
979
976
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
980
977
|
execFee = bridgeHubExecFee;
|
|
981
978
|
}
|
|
982
979
|
case 6:
|
|
983
|
-
|
|
984
|
-
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc);
|
|
980
|
+
_context10.n = 7;
|
|
981
|
+
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
985
982
|
case 7:
|
|
986
|
-
deliveryFee =
|
|
987
|
-
return
|
|
983
|
+
deliveryFee = _context10.v;
|
|
984
|
+
return _context10.a(2, execFee + deliveryFee);
|
|
988
985
|
}
|
|
989
|
-
},
|
|
986
|
+
}, _callee10, this);
|
|
990
987
|
}));
|
|
991
|
-
function getXcmPaymentApiFee(_x15, _x16, _x17, _x18) {
|
|
988
|
+
function getXcmPaymentApiFee(_x15, _x16, _x17, _x18, _x19) {
|
|
992
989
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
993
990
|
}
|
|
994
991
|
return getXcmPaymentApiFee;
|
|
@@ -996,68 +993,68 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
996
993
|
}, {
|
|
997
994
|
key: "getDeliveryFee",
|
|
998
995
|
value: function () {
|
|
999
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1000
|
-
var _deliveryFeeRes,
|
|
996
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
997
|
+
var _deliveryFeeRes, _ref8, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref9, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
|
|
1001
998
|
var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, versionedAssetLoc, deliveryFeeResJson, deliveryFeeResolved, nativeAsset, res, _t6;
|
|
1002
|
-
return _regenerator().w(function (
|
|
1003
|
-
while (1) switch (
|
|
999
|
+
return _regenerator().w(function (_context11) {
|
|
1000
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
1004
1001
|
case 0:
|
|
1005
1002
|
usedThirdParam = false;
|
|
1006
1003
|
if (!(forwardedXcm.length > 0)) {
|
|
1007
|
-
|
|
1004
|
+
_context11.n = 6;
|
|
1008
1005
|
break;
|
|
1009
1006
|
}
|
|
1010
1007
|
baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
|
|
1011
|
-
|
|
1012
|
-
|
|
1008
|
+
_context11.p = 1;
|
|
1009
|
+
_context11.n = 2;
|
|
1013
1010
|
return (_this$api$call$xcmPay = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay, baseArgs);
|
|
1014
1011
|
case 2:
|
|
1015
|
-
deliveryFeeRes =
|
|
1016
|
-
|
|
1012
|
+
deliveryFeeRes = _context11.v;
|
|
1013
|
+
_context11.n = 6;
|
|
1017
1014
|
break;
|
|
1018
1015
|
case 3:
|
|
1019
|
-
|
|
1020
|
-
_t6 =
|
|
1016
|
+
_context11.p = 3;
|
|
1017
|
+
_t6 = _context11.v;
|
|
1021
1018
|
message = _t6 instanceof Error ? _t6.message : String(_t6);
|
|
1022
1019
|
if (!message.includes('Expected 3 arguments')) {
|
|
1023
|
-
|
|
1020
|
+
_context11.n = 5;
|
|
1024
1021
|
break;
|
|
1025
1022
|
}
|
|
1026
1023
|
usedThirdParam = true;
|
|
1027
|
-
versionedAssetLoc = addXcmVersionHeader(assetLocalizedLoc,
|
|
1028
|
-
|
|
1024
|
+
versionedAssetLoc = addXcmVersionHeader(assetLocalizedLoc, version);
|
|
1025
|
+
_context11.n = 4;
|
|
1029
1026
|
return (_this$api$call$xcmPay2 = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay2, baseArgs.concat([versionedAssetLoc]));
|
|
1030
1027
|
case 4:
|
|
1031
|
-
deliveryFeeRes =
|
|
1032
|
-
|
|
1028
|
+
deliveryFeeRes = _context11.v;
|
|
1029
|
+
_context11.n = 6;
|
|
1033
1030
|
break;
|
|
1034
1031
|
case 5:
|
|
1035
1032
|
throw _t6;
|
|
1036
1033
|
case 6:
|
|
1037
1034
|
deliveryFeeResJson = (_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.toJSON();
|
|
1038
|
-
deliveryFeeResolved = deliveryFeeRes && ((
|
|
1035
|
+
deliveryFeeResolved = deliveryFeeRes && ((_ref8 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref8 === void 0 ? void 0 : _ref8.length) > 0 ? BigInt((_ref9 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref9 === void 0 || (_ref9 = _ref9[0]) === null || _ref9 === void 0 || (_ref9 = _ref9.fun) === null || _ref9 === void 0 ? void 0 : _ref9.fungible) : 0n;
|
|
1039
1036
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1040
1037
|
if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
|
|
1041
|
-
|
|
1038
|
+
_context11.n = 7;
|
|
1042
1039
|
break;
|
|
1043
1040
|
}
|
|
1044
|
-
return
|
|
1041
|
+
return _context11.a(2, deliveryFeeResolved);
|
|
1045
1042
|
case 7:
|
|
1046
|
-
|
|
1043
|
+
_context11.p = 7;
|
|
1047
1044
|
assertHasLocation(nativeAsset);
|
|
1048
|
-
|
|
1045
|
+
_context11.n = 8;
|
|
1049
1046
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1050
1047
|
case 8:
|
|
1051
|
-
res =
|
|
1052
|
-
return
|
|
1048
|
+
res = _context11.v;
|
|
1049
|
+
return _context11.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
1053
1050
|
case 9:
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
return
|
|
1051
|
+
_context11.p = 9;
|
|
1052
|
+
_context11.v;
|
|
1053
|
+
return _context11.a(2, 0n);
|
|
1057
1054
|
}
|
|
1058
|
-
},
|
|
1055
|
+
}, _callee11, this, [[7, 9], [1, 3]]);
|
|
1059
1056
|
}));
|
|
1060
|
-
function getDeliveryFee(
|
|
1057
|
+
function getDeliveryFee(_x20, _x21, _x22, _x23, _x24) {
|
|
1061
1058
|
return _getDeliveryFee.apply(this, arguments);
|
|
1062
1059
|
}
|
|
1063
1060
|
return getDeliveryFee;
|
|
@@ -1065,46 +1062,46 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1065
1062
|
}, {
|
|
1066
1063
|
key: "getBridgeHubFallbackExecFee",
|
|
1067
1064
|
value: function () {
|
|
1068
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1065
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, weightValue, asset, version) {
|
|
1069
1066
|
var fallbackExecFeeRes, fallbackJson, fallbackOk, fallbackExecFee, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1070
|
-
return _regenerator().w(function (
|
|
1071
|
-
while (1) switch (
|
|
1067
|
+
return _regenerator().w(function (_context12) {
|
|
1068
|
+
while (1) switch (_context12.n) {
|
|
1072
1069
|
case 0:
|
|
1073
|
-
|
|
1074
|
-
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION,
|
|
1070
|
+
_context12.n = 1;
|
|
1071
|
+
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION, version));
|
|
1075
1072
|
case 1:
|
|
1076
|
-
fallbackExecFeeRes =
|
|
1073
|
+
fallbackExecFeeRes = _context12.v;
|
|
1077
1074
|
fallbackJson = fallbackExecFeeRes.toJSON();
|
|
1078
1075
|
fallbackOk = fallbackJson === null || fallbackJson === void 0 ? void 0 : fallbackJson.ok;
|
|
1079
1076
|
fallbackExecFee = typeof fallbackOk === 'string' || typeof fallbackOk === 'number' ? BigInt(fallbackOk) : undefined;
|
|
1080
1077
|
if (!(fallbackExecFee === undefined)) {
|
|
1081
|
-
|
|
1078
|
+
_context12.n = 2;
|
|
1082
1079
|
break;
|
|
1083
1080
|
}
|
|
1084
|
-
return
|
|
1081
|
+
return _context12.a(2, undefined);
|
|
1085
1082
|
case 2:
|
|
1086
1083
|
ahApi = this.clone();
|
|
1087
1084
|
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1088
|
-
|
|
1085
|
+
_context12.n = 3;
|
|
1089
1086
|
return ahApi.init(assetHubChain);
|
|
1090
1087
|
case 3:
|
|
1091
1088
|
assertHasLocation(asset);
|
|
1092
1089
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1093
|
-
|
|
1090
|
+
_context12.n = 4;
|
|
1094
1091
|
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false);
|
|
1095
1092
|
case 4:
|
|
1096
|
-
convertedExecFee =
|
|
1093
|
+
convertedExecFee = _context12.v;
|
|
1097
1094
|
if (!(typeof convertedExecFee === 'bigint')) {
|
|
1098
|
-
|
|
1095
|
+
_context12.n = 5;
|
|
1099
1096
|
break;
|
|
1100
1097
|
}
|
|
1101
|
-
return
|
|
1098
|
+
return _context12.a(2, convertedExecFee);
|
|
1102
1099
|
case 5:
|
|
1103
|
-
return
|
|
1100
|
+
return _context12.a(2, undefined);
|
|
1104
1101
|
}
|
|
1105
|
-
},
|
|
1102
|
+
}, _callee12, this);
|
|
1106
1103
|
}));
|
|
1107
|
-
function getBridgeHubFallbackExecFee(
|
|
1104
|
+
function getBridgeHubFallbackExecFee(_x25, _x26, _x27, _x28) {
|
|
1108
1105
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1109
1106
|
}
|
|
1110
1107
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1112,21 +1109,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1112
1109
|
}, {
|
|
1113
1110
|
key: "getXcmWeight",
|
|
1114
1111
|
value: function () {
|
|
1115
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1112
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(xcm) {
|
|
1116
1113
|
var result, resultJson;
|
|
1117
|
-
return _regenerator().w(function (
|
|
1118
|
-
while (1) switch (
|
|
1114
|
+
return _regenerator().w(function (_context13) {
|
|
1115
|
+
while (1) switch (_context13.n) {
|
|
1119
1116
|
case 0:
|
|
1120
|
-
|
|
1117
|
+
_context13.n = 1;
|
|
1121
1118
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
1122
1119
|
case 1:
|
|
1123
|
-
result =
|
|
1120
|
+
result = _context13.v;
|
|
1124
1121
|
resultJson = result.toJSON();
|
|
1125
|
-
return
|
|
1122
|
+
return _context13.a(2, resultJson.ok);
|
|
1126
1123
|
}
|
|
1127
|
-
},
|
|
1124
|
+
}, _callee13, this);
|
|
1128
1125
|
}));
|
|
1129
|
-
function getXcmWeight(
|
|
1126
|
+
function getXcmWeight(_x29) {
|
|
1130
1127
|
return _getXcmWeight.apply(this, arguments);
|
|
1131
1128
|
}
|
|
1132
1129
|
return getXcmWeight;
|
|
@@ -1134,34 +1131,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1134
1131
|
}, {
|
|
1135
1132
|
key: "getDryRunXcm",
|
|
1136
1133
|
value: function () {
|
|
1137
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1138
|
-
var _ref11, _ref12
|
|
1139
|
-
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, isSuccess, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
|
|
1140
|
-
return _regenerator().w(function (
|
|
1141
|
-
while (1) switch (
|
|
1134
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref0) {
|
|
1135
|
+
var _ref10, _ref11, _ref12;
|
|
1136
|
+
var originLocation, xcm, asset, chain, version, origin, supportsDryRunApi, response, result, resultJson, isSuccess, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
|
|
1137
|
+
return _regenerator().w(function (_context14) {
|
|
1138
|
+
while (1) switch (_context14.n) {
|
|
1142
1139
|
case 0:
|
|
1143
|
-
originLocation =
|
|
1140
|
+
originLocation = _ref0.originLocation, xcm = _ref0.xcm, asset = _ref0.asset, chain = _ref0.chain, version = _ref0.version, origin = _ref0.origin;
|
|
1144
1141
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1145
1142
|
if (supportsDryRunApi) {
|
|
1146
|
-
|
|
1143
|
+
_context14.n = 1;
|
|
1147
1144
|
break;
|
|
1148
1145
|
}
|
|
1149
1146
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1150
1147
|
case 1:
|
|
1151
|
-
|
|
1148
|
+
_context14.n = 2;
|
|
1152
1149
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
1153
1150
|
case 2:
|
|
1154
|
-
response =
|
|
1151
|
+
response = _context14.v;
|
|
1155
1152
|
result = response.toHuman();
|
|
1156
1153
|
resultJson = response.toJSON();
|
|
1157
1154
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
1158
1155
|
if (isSuccess) {
|
|
1159
|
-
|
|
1156
|
+
_context14.n = 3;
|
|
1160
1157
|
break;
|
|
1161
1158
|
}
|
|
1162
1159
|
error = result.Ok.executionResult.Incomplete.error;
|
|
1163
1160
|
failureReason = typeof error === 'string' ? error : error.error;
|
|
1164
|
-
return
|
|
1161
|
+
return _context14.a(2, {
|
|
1165
1162
|
success: false,
|
|
1166
1163
|
failureReason: failureReason,
|
|
1167
1164
|
asset: asset
|
|
@@ -1173,22 +1170,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1173
1170
|
refTime: BigInt(actualWeight.refTime),
|
|
1174
1171
|
proofSize: BigInt(actualWeight.proofSize)
|
|
1175
1172
|
} : undefined;
|
|
1176
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
1177
|
-
return i.Here ? 0 : (
|
|
1173
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref1) {
|
|
1174
|
+
return i.Here ? 0 : (_ref1 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref1 === void 0 ? void 0 : _ref1.parachain;
|
|
1178
1175
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
1179
1176
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1180
|
-
|
|
1177
|
+
_context14.n = 5;
|
|
1181
1178
|
break;
|
|
1182
1179
|
}
|
|
1183
|
-
|
|
1184
|
-
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1180
|
+
_context14.n = 4;
|
|
1181
|
+
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1185
1182
|
case 4:
|
|
1186
|
-
_fee =
|
|
1183
|
+
_fee = _context14.v;
|
|
1187
1184
|
if (!(typeof _fee === 'bigint')) {
|
|
1188
|
-
|
|
1185
|
+
_context14.n = 5;
|
|
1189
1186
|
break;
|
|
1190
1187
|
}
|
|
1191
|
-
return
|
|
1188
|
+
return _context14.a(2, {
|
|
1192
1189
|
success: true,
|
|
1193
1190
|
fee: _fee,
|
|
1194
1191
|
asset: asset,
|
|
@@ -1200,24 +1197,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1200
1197
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
1201
1198
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1202
1199
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
1203
|
-
feeEvent = (
|
|
1200
|
+
feeEvent = (_ref10 = (_ref11 = (_ref12 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1204
1201
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
1205
|
-
}) : undefined) !== null &&
|
|
1202
|
+
}) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
|
|
1206
1203
|
// Prefer an Issued event
|
|
1207
1204
|
reversedEvents.find(function (event) {
|
|
1208
1205
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
1209
|
-
})) !== null &&
|
|
1206
|
+
})) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1210
1207
|
// Fallback to Minted event
|
|
1211
1208
|
reversedEvents.find(function (event) {
|
|
1212
1209
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
1213
|
-
})) !== null &&
|
|
1210
|
+
})) !== null && _ref10 !== void 0 ? _ref10 : reversedEvents.find(function (event) {
|
|
1214
1211
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
1215
1212
|
});
|
|
1216
1213
|
if (feeEvent) {
|
|
1217
|
-
|
|
1214
|
+
_context14.n = 6;
|
|
1218
1215
|
break;
|
|
1219
1216
|
}
|
|
1220
|
-
return
|
|
1217
|
+
return _context14.a(2, Promise.resolve({
|
|
1221
1218
|
success: false,
|
|
1222
1219
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
1223
1220
|
asset: asset
|
|
@@ -1225,7 +1222,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1225
1222
|
case 6:
|
|
1226
1223
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
1227
1224
|
fee = BigInt(feeAmount.replace(/,/g, ''));
|
|
1228
|
-
return
|
|
1225
|
+
return _context14.a(2, {
|
|
1229
1226
|
success: true,
|
|
1230
1227
|
fee: fee,
|
|
1231
1228
|
asset: asset,
|
|
@@ -1234,9 +1231,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1234
1231
|
destParaId: destParaId
|
|
1235
1232
|
});
|
|
1236
1233
|
}
|
|
1237
|
-
},
|
|
1234
|
+
}, _callee14, this);
|
|
1238
1235
|
}));
|
|
1239
|
-
function getDryRunXcm(
|
|
1236
|
+
function getDryRunXcm(_x30) {
|
|
1240
1237
|
return _getDryRunXcm.apply(this, arguments);
|
|
1241
1238
|
}
|
|
1242
1239
|
return getDryRunXcm;
|
|
@@ -1244,18 +1241,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1244
1241
|
}, {
|
|
1245
1242
|
key: "getBridgeStatus",
|
|
1246
1243
|
value: function () {
|
|
1247
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1244
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1248
1245
|
var outboundOperatingMode;
|
|
1249
|
-
return _regenerator().w(function (
|
|
1250
|
-
while (1) switch (
|
|
1246
|
+
return _regenerator().w(function (_context15) {
|
|
1247
|
+
while (1) switch (_context15.n) {
|
|
1251
1248
|
case 0:
|
|
1252
|
-
|
|
1249
|
+
_context15.n = 1;
|
|
1253
1250
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1254
1251
|
case 1:
|
|
1255
|
-
outboundOperatingMode =
|
|
1256
|
-
return
|
|
1252
|
+
outboundOperatingMode = _context15.v;
|
|
1253
|
+
return _context15.a(2, outboundOperatingMode.toPrimitive());
|
|
1257
1254
|
}
|
|
1258
|
-
},
|
|
1255
|
+
}, _callee15, this);
|
|
1259
1256
|
}));
|
|
1260
1257
|
function getBridgeStatus() {
|
|
1261
1258
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1307,29 +1304,44 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1307
1304
|
}
|
|
1308
1305
|
}, {
|
|
1309
1306
|
key: "deriveAddress",
|
|
1310
|
-
value: function deriveAddress(
|
|
1311
|
-
|
|
1307
|
+
value: function deriveAddress(sender) {
|
|
1308
|
+
if (isSenderSigner(sender)) return sender.address;
|
|
1309
|
+
var _createKeyringPair = createKeyringPair(sender),
|
|
1312
1310
|
address = _createKeyringPair.address;
|
|
1313
1311
|
return address;
|
|
1314
1312
|
}
|
|
1315
1313
|
}, {
|
|
1316
1314
|
key: "signAndSubmit",
|
|
1317
1315
|
value: function () {
|
|
1318
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1319
|
-
var
|
|
1320
|
-
return _regenerator().w(function (
|
|
1321
|
-
while (1) switch (
|
|
1316
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
|
|
1317
|
+
var hash, _t8;
|
|
1318
|
+
return _regenerator().w(function (_context16) {
|
|
1319
|
+
while (1) switch (_context16.n) {
|
|
1322
1320
|
case 0:
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1321
|
+
if (!isSenderSigner(sender)) {
|
|
1322
|
+
_context16.n = 2;
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
_context16.n = 1;
|
|
1326
|
+
return tx.signAndSend(sender.address, {
|
|
1327
|
+
signer: sender.signer
|
|
1328
|
+
});
|
|
1326
1329
|
case 1:
|
|
1327
|
-
|
|
1328
|
-
|
|
1330
|
+
_t8 = _context16.v;
|
|
1331
|
+
_context16.n = 4;
|
|
1332
|
+
break;
|
|
1333
|
+
case 2:
|
|
1334
|
+
_context16.n = 3;
|
|
1335
|
+
return tx.signAndSend(createKeyringPair(sender));
|
|
1336
|
+
case 3:
|
|
1337
|
+
_t8 = _context16.v;
|
|
1338
|
+
case 4:
|
|
1339
|
+
hash = _t8;
|
|
1340
|
+
return _context16.a(2, hash.toHex());
|
|
1329
1341
|
}
|
|
1330
|
-
},
|
|
1342
|
+
}, _callee16);
|
|
1331
1343
|
}));
|
|
1332
|
-
function signAndSubmit(
|
|
1344
|
+
function signAndSubmit(_x31, _x32) {
|
|
1333
1345
|
return _signAndSubmit.apply(this, arguments);
|
|
1334
1346
|
}
|
|
1335
1347
|
return signAndSubmit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.6.0",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@snowbridge/registry": "^0.3.2",
|
|
30
30
|
"ethers": "6.15.0",
|
|
31
31
|
"viem": "2.45.0",
|
|
32
|
-
"@paraspell/sdk-core": "12.
|
|
32
|
+
"@paraspell/sdk-core": "12.6.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@polkadot/api": ">= 16.0 < 17",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"@polkadot/util-crypto": ">= 14"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@babel/plugin-syntax-import-attributes": "^7.
|
|
43
|
-
"@babel/preset-env": "^7.28.
|
|
42
|
+
"@babel/plugin-syntax-import-attributes": "^7.28.6",
|
|
43
|
+
"@babel/preset-env": "^7.28.6",
|
|
44
44
|
"@codecov/rollup-plugin": "^1.9.1",
|
|
45
45
|
"@rollup/plugin-babel": "^6.1.0",
|
|
46
46
|
"@rollup/plugin-json": "^6.1.0",
|
|
47
47
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
48
|
-
"@vitest/coverage-v8": "^4.0.
|
|
49
|
-
"axios": "^1.13.
|
|
48
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
49
|
+
"axios": "^1.13.4",
|
|
50
50
|
"dotenv": "^17.2.3",
|
|
51
|
-
"rollup": "^4.
|
|
51
|
+
"rollup": "^4.57.0",
|
|
52
52
|
"rollup-plugin-dts": "^6.3.0",
|
|
53
53
|
"tslib": "^2.8.1"
|
|
54
54
|
},
|