@paraspell/sdk-pjs 12.5.1 → 12.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -69
- package/dist/index.d.ts +27 -23
- package/dist/index.mjs +211 -204
- package/package.json +2 -2
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,
|
|
1
|
+
import { getEvmPrivateKeyHex, createClientCache, createClientPoolHelpers, isConfig, getChainProviders, BatchMode, findNativeAssetInfoOrThrow, isSenderSigner, MissingChainApiError, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, 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, 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,
|
|
@@ -839,57 +854,36 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
839
854
|
refTime: BigInt(actualWeight.refTime),
|
|
840
855
|
proofSize: BigInt(actualWeight.proofSize)
|
|
841
856
|
} : undefined;
|
|
842
|
-
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
843
|
-
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
844
857
|
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref7) {
|
|
845
858
|
return i.here === null ? 0 : (_ref7 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref7 === void 0 ? void 0 : _ref7.parachain;
|
|
846
859
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
847
|
-
if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm &&
|
|
848
|
-
|
|
860
|
+
if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
861
|
+
_context1.n = 21;
|
|
849
862
|
break;
|
|
850
863
|
}
|
|
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
864
|
if (resultJson.ok.local_xcm) {
|
|
871
|
-
|
|
865
|
+
_context1.n = 17;
|
|
872
866
|
break;
|
|
873
867
|
}
|
|
874
|
-
|
|
875
|
-
return
|
|
868
|
+
_context1.n = 16;
|
|
869
|
+
return this.getPaymentInfo(tx, address);
|
|
876
870
|
case 16:
|
|
877
|
-
_t4 =
|
|
878
|
-
|
|
871
|
+
_t4 = _context1.v.weight;
|
|
872
|
+
_context1.n = 18;
|
|
879
873
|
break;
|
|
880
874
|
case 17:
|
|
881
875
|
_t4 = undefined;
|
|
882
876
|
case 18:
|
|
883
877
|
overriddenWeight = _t4;
|
|
884
|
-
|
|
885
|
-
return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, resolvedFeeAsset.asset, false, overriddenWeight);
|
|
878
|
+
_context1.n = 19;
|
|
879
|
+
return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
886
880
|
case 19:
|
|
887
|
-
xcmFee =
|
|
881
|
+
xcmFee = _context1.v;
|
|
888
882
|
if (!(typeof xcmFee === 'bigint')) {
|
|
889
|
-
|
|
883
|
+
_context1.n = 20;
|
|
890
884
|
break;
|
|
891
885
|
}
|
|
892
|
-
return
|
|
886
|
+
return _context1.a(2, Promise.resolve({
|
|
893
887
|
success: true,
|
|
894
888
|
fee: xcmFee,
|
|
895
889
|
asset: resolvedFeeAsset.asset,
|
|
@@ -903,12 +897,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
903
897
|
asset: this.resolveDefaultFeeAsset(options)
|
|
904
898
|
};
|
|
905
899
|
case 21:
|
|
906
|
-
|
|
907
|
-
return this.
|
|
900
|
+
_context1.n = 22;
|
|
901
|
+
return this.getPaymentInfo(tx, address);
|
|
908
902
|
case 22:
|
|
909
|
-
|
|
903
|
+
_yield$this$getPaymen = _context1.v;
|
|
904
|
+
executionFee = _yield$this$getPaymen.partialFee;
|
|
910
905
|
fee = computeFeeFromDryRunPjs(resultHuman, chain, executionFee);
|
|
911
|
-
return
|
|
906
|
+
return _context1.a(2, {
|
|
912
907
|
success: true,
|
|
913
908
|
fee: fee,
|
|
914
909
|
asset: resolvedFeeAsset.asset,
|
|
@@ -917,7 +912,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
917
912
|
destParaId: destParaId
|
|
918
913
|
});
|
|
919
914
|
}
|
|
920
|
-
},
|
|
915
|
+
}, _callee1, this, [[11, 13], [6, 8]]);
|
|
921
916
|
}));
|
|
922
917
|
function getDryRunCall(_x13) {
|
|
923
918
|
return _getDryRunCall.apply(this, arguments);
|
|
@@ -927,7 +922,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
927
922
|
}, {
|
|
928
923
|
key: "getXcmPaymentApiFee",
|
|
929
924
|
value: function () {
|
|
930
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
925
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, localXcm, forwardedXcm, asset, version) {
|
|
931
926
|
var overridenWeight,
|
|
932
927
|
weight,
|
|
933
928
|
assetLocalizedLoc,
|
|
@@ -938,57 +933,56 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
938
933
|
isAssetNotFound,
|
|
939
934
|
bridgeHubExecFee,
|
|
940
935
|
deliveryFee,
|
|
941
|
-
|
|
936
|
+
_args0 = arguments,
|
|
942
937
|
_t5;
|
|
943
|
-
return _regenerator().w(function (
|
|
944
|
-
while (1) switch (
|
|
938
|
+
return _regenerator().w(function (_context10) {
|
|
939
|
+
while (1) switch (_context10.n) {
|
|
945
940
|
case 0:
|
|
946
|
-
overridenWeight =
|
|
941
|
+
overridenWeight = _args0.length > 6 ? _args0[6] : undefined;
|
|
947
942
|
if (!(overridenWeight !== null && overridenWeight !== void 0)) {
|
|
948
|
-
|
|
943
|
+
_context10.n = 1;
|
|
949
944
|
break;
|
|
950
945
|
}
|
|
951
946
|
_t5 = overridenWeight;
|
|
952
|
-
|
|
947
|
+
_context10.n = 3;
|
|
953
948
|
break;
|
|
954
949
|
case 1:
|
|
955
|
-
|
|
950
|
+
_context10.n = 2;
|
|
956
951
|
return this.getXcmWeight(localXcm);
|
|
957
952
|
case 2:
|
|
958
|
-
_t5 =
|
|
953
|
+
_t5 = _context10.v;
|
|
959
954
|
case 3:
|
|
960
955
|
weight = _t5;
|
|
961
|
-
assertHasLocation(asset);
|
|
962
956
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
963
|
-
|
|
964
|
-
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetLocalizedLoc,
|
|
957
|
+
_context10.n = 4;
|
|
958
|
+
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetLocalizedLoc, version));
|
|
965
959
|
case 4:
|
|
966
|
-
feeResult =
|
|
960
|
+
feeResult = _context10.v;
|
|
967
961
|
execFeeRes = feeResult.toJSON();
|
|
968
962
|
execFeeOk = execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.ok;
|
|
969
963
|
execFee = typeof execFeeOk === 'string' || typeof execFeeOk === 'number' ? BigInt(execFeeOk) : 0n;
|
|
970
964
|
isAssetNotFound = (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.err) === 'AssetNotFound';
|
|
971
965
|
if (!(chain.startsWith('BridgeHub') && isAssetNotFound)) {
|
|
972
|
-
|
|
966
|
+
_context10.n = 6;
|
|
973
967
|
break;
|
|
974
968
|
}
|
|
975
|
-
|
|
976
|
-
return this.getBridgeHubFallbackExecFee(chain, weight, asset);
|
|
969
|
+
_context10.n = 5;
|
|
970
|
+
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
977
971
|
case 5:
|
|
978
|
-
bridgeHubExecFee =
|
|
972
|
+
bridgeHubExecFee = _context10.v;
|
|
979
973
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
980
974
|
execFee = bridgeHubExecFee;
|
|
981
975
|
}
|
|
982
976
|
case 6:
|
|
983
|
-
|
|
984
|
-
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc);
|
|
977
|
+
_context10.n = 7;
|
|
978
|
+
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
985
979
|
case 7:
|
|
986
|
-
deliveryFee =
|
|
987
|
-
return
|
|
980
|
+
deliveryFee = _context10.v;
|
|
981
|
+
return _context10.a(2, execFee + deliveryFee);
|
|
988
982
|
}
|
|
989
|
-
},
|
|
983
|
+
}, _callee10, this);
|
|
990
984
|
}));
|
|
991
|
-
function getXcmPaymentApiFee(_x15, _x16, _x17, _x18) {
|
|
985
|
+
function getXcmPaymentApiFee(_x15, _x16, _x17, _x18, _x19) {
|
|
992
986
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
993
987
|
}
|
|
994
988
|
return getXcmPaymentApiFee;
|
|
@@ -996,68 +990,67 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
996
990
|
}, {
|
|
997
991
|
key: "getDeliveryFee",
|
|
998
992
|
value: function () {
|
|
999
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1000
|
-
var _deliveryFeeRes,
|
|
993
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
994
|
+
var _deliveryFeeRes, _ref8, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref9, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
|
|
1001
995
|
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 (
|
|
996
|
+
return _regenerator().w(function (_context11) {
|
|
997
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
1004
998
|
case 0:
|
|
1005
999
|
usedThirdParam = false;
|
|
1006
1000
|
if (!(forwardedXcm.length > 0)) {
|
|
1007
|
-
|
|
1001
|
+
_context11.n = 6;
|
|
1008
1002
|
break;
|
|
1009
1003
|
}
|
|
1010
1004
|
baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
|
|
1011
|
-
|
|
1012
|
-
|
|
1005
|
+
_context11.p = 1;
|
|
1006
|
+
_context11.n = 2;
|
|
1013
1007
|
return (_this$api$call$xcmPay = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay, baseArgs);
|
|
1014
1008
|
case 2:
|
|
1015
|
-
deliveryFeeRes =
|
|
1016
|
-
|
|
1009
|
+
deliveryFeeRes = _context11.v;
|
|
1010
|
+
_context11.n = 6;
|
|
1017
1011
|
break;
|
|
1018
1012
|
case 3:
|
|
1019
|
-
|
|
1020
|
-
_t6 =
|
|
1013
|
+
_context11.p = 3;
|
|
1014
|
+
_t6 = _context11.v;
|
|
1021
1015
|
message = _t6 instanceof Error ? _t6.message : String(_t6);
|
|
1022
1016
|
if (!message.includes('Expected 3 arguments')) {
|
|
1023
|
-
|
|
1017
|
+
_context11.n = 5;
|
|
1024
1018
|
break;
|
|
1025
1019
|
}
|
|
1026
1020
|
usedThirdParam = true;
|
|
1027
|
-
versionedAssetLoc = addXcmVersionHeader(assetLocalizedLoc,
|
|
1028
|
-
|
|
1021
|
+
versionedAssetLoc = addXcmVersionHeader(assetLocalizedLoc, version);
|
|
1022
|
+
_context11.n = 4;
|
|
1029
1023
|
return (_this$api$call$xcmPay2 = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay2, baseArgs.concat([versionedAssetLoc]));
|
|
1030
1024
|
case 4:
|
|
1031
|
-
deliveryFeeRes =
|
|
1032
|
-
|
|
1025
|
+
deliveryFeeRes = _context11.v;
|
|
1026
|
+
_context11.n = 6;
|
|
1033
1027
|
break;
|
|
1034
1028
|
case 5:
|
|
1035
1029
|
throw _t6;
|
|
1036
1030
|
case 6:
|
|
1037
1031
|
deliveryFeeResJson = (_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.toJSON();
|
|
1038
|
-
deliveryFeeResolved = deliveryFeeRes && ((
|
|
1032
|
+
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
1033
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1040
1034
|
if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
|
|
1041
|
-
|
|
1035
|
+
_context11.n = 7;
|
|
1042
1036
|
break;
|
|
1043
1037
|
}
|
|
1044
|
-
return
|
|
1038
|
+
return _context11.a(2, deliveryFeeResolved);
|
|
1045
1039
|
case 7:
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
_context12.n = 8;
|
|
1040
|
+
_context11.p = 7;
|
|
1041
|
+
_context11.n = 8;
|
|
1049
1042
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1050
1043
|
case 8:
|
|
1051
|
-
res =
|
|
1052
|
-
return
|
|
1044
|
+
res = _context11.v;
|
|
1045
|
+
return _context11.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
1053
1046
|
case 9:
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
return
|
|
1047
|
+
_context11.p = 9;
|
|
1048
|
+
_context11.v;
|
|
1049
|
+
return _context11.a(2, 0n);
|
|
1057
1050
|
}
|
|
1058
|
-
},
|
|
1051
|
+
}, _callee11, this, [[7, 9], [1, 3]]);
|
|
1059
1052
|
}));
|
|
1060
|
-
function getDeliveryFee(
|
|
1053
|
+
function getDeliveryFee(_x20, _x21, _x22, _x23, _x24) {
|
|
1061
1054
|
return _getDeliveryFee.apply(this, arguments);
|
|
1062
1055
|
}
|
|
1063
1056
|
return getDeliveryFee;
|
|
@@ -1065,46 +1058,45 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1065
1058
|
}, {
|
|
1066
1059
|
key: "getBridgeHubFallbackExecFee",
|
|
1067
1060
|
value: function () {
|
|
1068
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1061
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, weightValue, asset, version) {
|
|
1069
1062
|
var fallbackExecFeeRes, fallbackJson, fallbackOk, fallbackExecFee, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1070
|
-
return _regenerator().w(function (
|
|
1071
|
-
while (1) switch (
|
|
1063
|
+
return _regenerator().w(function (_context12) {
|
|
1064
|
+
while (1) switch (_context12.n) {
|
|
1072
1065
|
case 0:
|
|
1073
|
-
|
|
1074
|
-
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION,
|
|
1066
|
+
_context12.n = 1;
|
|
1067
|
+
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION, version));
|
|
1075
1068
|
case 1:
|
|
1076
|
-
fallbackExecFeeRes =
|
|
1069
|
+
fallbackExecFeeRes = _context12.v;
|
|
1077
1070
|
fallbackJson = fallbackExecFeeRes.toJSON();
|
|
1078
1071
|
fallbackOk = fallbackJson === null || fallbackJson === void 0 ? void 0 : fallbackJson.ok;
|
|
1079
1072
|
fallbackExecFee = typeof fallbackOk === 'string' || typeof fallbackOk === 'number' ? BigInt(fallbackOk) : undefined;
|
|
1080
1073
|
if (!(fallbackExecFee === undefined)) {
|
|
1081
|
-
|
|
1074
|
+
_context12.n = 2;
|
|
1082
1075
|
break;
|
|
1083
1076
|
}
|
|
1084
|
-
return
|
|
1077
|
+
return _context12.a(2, undefined);
|
|
1085
1078
|
case 2:
|
|
1086
1079
|
ahApi = this.clone();
|
|
1087
1080
|
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1088
|
-
|
|
1081
|
+
_context12.n = 3;
|
|
1089
1082
|
return ahApi.init(assetHubChain);
|
|
1090
1083
|
case 3:
|
|
1091
|
-
assertHasLocation(asset);
|
|
1092
1084
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1093
|
-
|
|
1085
|
+
_context12.n = 4;
|
|
1094
1086
|
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false);
|
|
1095
1087
|
case 4:
|
|
1096
|
-
convertedExecFee =
|
|
1088
|
+
convertedExecFee = _context12.v;
|
|
1097
1089
|
if (!(typeof convertedExecFee === 'bigint')) {
|
|
1098
|
-
|
|
1090
|
+
_context12.n = 5;
|
|
1099
1091
|
break;
|
|
1100
1092
|
}
|
|
1101
|
-
return
|
|
1093
|
+
return _context12.a(2, convertedExecFee);
|
|
1102
1094
|
case 5:
|
|
1103
|
-
return
|
|
1095
|
+
return _context12.a(2, undefined);
|
|
1104
1096
|
}
|
|
1105
|
-
},
|
|
1097
|
+
}, _callee12, this);
|
|
1106
1098
|
}));
|
|
1107
|
-
function getBridgeHubFallbackExecFee(
|
|
1099
|
+
function getBridgeHubFallbackExecFee(_x25, _x26, _x27, _x28) {
|
|
1108
1100
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1109
1101
|
}
|
|
1110
1102
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1112,21 +1104,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1112
1104
|
}, {
|
|
1113
1105
|
key: "getXcmWeight",
|
|
1114
1106
|
value: function () {
|
|
1115
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1107
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(xcm) {
|
|
1116
1108
|
var result, resultJson;
|
|
1117
|
-
return _regenerator().w(function (
|
|
1118
|
-
while (1) switch (
|
|
1109
|
+
return _regenerator().w(function (_context13) {
|
|
1110
|
+
while (1) switch (_context13.n) {
|
|
1119
1111
|
case 0:
|
|
1120
|
-
|
|
1112
|
+
_context13.n = 1;
|
|
1121
1113
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
1122
1114
|
case 1:
|
|
1123
|
-
result =
|
|
1115
|
+
result = _context13.v;
|
|
1124
1116
|
resultJson = result.toJSON();
|
|
1125
|
-
return
|
|
1117
|
+
return _context13.a(2, resultJson.ok);
|
|
1126
1118
|
}
|
|
1127
|
-
},
|
|
1119
|
+
}, _callee13, this);
|
|
1128
1120
|
}));
|
|
1129
|
-
function getXcmWeight(
|
|
1121
|
+
function getXcmWeight(_x29) {
|
|
1130
1122
|
return _getXcmWeight.apply(this, arguments);
|
|
1131
1123
|
}
|
|
1132
1124
|
return getXcmWeight;
|
|
@@ -1134,34 +1126,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1134
1126
|
}, {
|
|
1135
1127
|
key: "getDryRunXcm",
|
|
1136
1128
|
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 (
|
|
1129
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref0) {
|
|
1130
|
+
var _ref10, _ref11, _ref12;
|
|
1131
|
+
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;
|
|
1132
|
+
return _regenerator().w(function (_context14) {
|
|
1133
|
+
while (1) switch (_context14.n) {
|
|
1142
1134
|
case 0:
|
|
1143
|
-
originLocation =
|
|
1135
|
+
originLocation = _ref0.originLocation, xcm = _ref0.xcm, asset = _ref0.asset, chain = _ref0.chain, version = _ref0.version, origin = _ref0.origin;
|
|
1144
1136
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1145
1137
|
if (supportsDryRunApi) {
|
|
1146
|
-
|
|
1138
|
+
_context14.n = 1;
|
|
1147
1139
|
break;
|
|
1148
1140
|
}
|
|
1149
1141
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1150
1142
|
case 1:
|
|
1151
|
-
|
|
1143
|
+
_context14.n = 2;
|
|
1152
1144
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
1153
1145
|
case 2:
|
|
1154
|
-
response =
|
|
1146
|
+
response = _context14.v;
|
|
1155
1147
|
result = response.toHuman();
|
|
1156
1148
|
resultJson = response.toJSON();
|
|
1157
1149
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
1158
1150
|
if (isSuccess) {
|
|
1159
|
-
|
|
1151
|
+
_context14.n = 3;
|
|
1160
1152
|
break;
|
|
1161
1153
|
}
|
|
1162
1154
|
error = result.Ok.executionResult.Incomplete.error;
|
|
1163
1155
|
failureReason = typeof error === 'string' ? error : error.error;
|
|
1164
|
-
return
|
|
1156
|
+
return _context14.a(2, {
|
|
1165
1157
|
success: false,
|
|
1166
1158
|
failureReason: failureReason,
|
|
1167
1159
|
asset: asset
|
|
@@ -1173,22 +1165,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1173
1165
|
refTime: BigInt(actualWeight.refTime),
|
|
1174
1166
|
proofSize: BigInt(actualWeight.proofSize)
|
|
1175
1167
|
} : undefined;
|
|
1176
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
1177
|
-
return i.Here ? 0 : (
|
|
1168
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref1) {
|
|
1169
|
+
return i.Here ? 0 : (_ref1 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref1 === void 0 ? void 0 : _ref1.parachain;
|
|
1178
1170
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
1179
1171
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1180
|
-
|
|
1172
|
+
_context14.n = 5;
|
|
1181
1173
|
break;
|
|
1182
1174
|
}
|
|
1183
|
-
|
|
1184
|
-
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1175
|
+
_context14.n = 4;
|
|
1176
|
+
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1185
1177
|
case 4:
|
|
1186
|
-
_fee =
|
|
1178
|
+
_fee = _context14.v;
|
|
1187
1179
|
if (!(typeof _fee === 'bigint')) {
|
|
1188
|
-
|
|
1180
|
+
_context14.n = 5;
|
|
1189
1181
|
break;
|
|
1190
1182
|
}
|
|
1191
|
-
return
|
|
1183
|
+
return _context14.a(2, {
|
|
1192
1184
|
success: true,
|
|
1193
1185
|
fee: _fee,
|
|
1194
1186
|
asset: asset,
|
|
@@ -1200,24 +1192,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1200
1192
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
1201
1193
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1202
1194
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
1203
|
-
feeEvent = (
|
|
1195
|
+
feeEvent = (_ref10 = (_ref11 = (_ref12 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1204
1196
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
1205
|
-
}) : undefined) !== null &&
|
|
1197
|
+
}) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
|
|
1206
1198
|
// Prefer an Issued event
|
|
1207
1199
|
reversedEvents.find(function (event) {
|
|
1208
1200
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
1209
|
-
})) !== null &&
|
|
1201
|
+
})) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1210
1202
|
// Fallback to Minted event
|
|
1211
1203
|
reversedEvents.find(function (event) {
|
|
1212
1204
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
1213
|
-
})) !== null &&
|
|
1205
|
+
})) !== null && _ref10 !== void 0 ? _ref10 : reversedEvents.find(function (event) {
|
|
1214
1206
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
1215
1207
|
});
|
|
1216
1208
|
if (feeEvent) {
|
|
1217
|
-
|
|
1209
|
+
_context14.n = 6;
|
|
1218
1210
|
break;
|
|
1219
1211
|
}
|
|
1220
|
-
return
|
|
1212
|
+
return _context14.a(2, Promise.resolve({
|
|
1221
1213
|
success: false,
|
|
1222
1214
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
1223
1215
|
asset: asset
|
|
@@ -1225,7 +1217,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1225
1217
|
case 6:
|
|
1226
1218
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
1227
1219
|
fee = BigInt(feeAmount.replace(/,/g, ''));
|
|
1228
|
-
return
|
|
1220
|
+
return _context14.a(2, {
|
|
1229
1221
|
success: true,
|
|
1230
1222
|
fee: fee,
|
|
1231
1223
|
asset: asset,
|
|
@@ -1234,9 +1226,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1234
1226
|
destParaId: destParaId
|
|
1235
1227
|
});
|
|
1236
1228
|
}
|
|
1237
|
-
},
|
|
1229
|
+
}, _callee14, this);
|
|
1238
1230
|
}));
|
|
1239
|
-
function getDryRunXcm(
|
|
1231
|
+
function getDryRunXcm(_x30) {
|
|
1240
1232
|
return _getDryRunXcm.apply(this, arguments);
|
|
1241
1233
|
}
|
|
1242
1234
|
return getDryRunXcm;
|
|
@@ -1244,18 +1236,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1244
1236
|
}, {
|
|
1245
1237
|
key: "getBridgeStatus",
|
|
1246
1238
|
value: function () {
|
|
1247
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1239
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1248
1240
|
var outboundOperatingMode;
|
|
1249
|
-
return _regenerator().w(function (
|
|
1250
|
-
while (1) switch (
|
|
1241
|
+
return _regenerator().w(function (_context15) {
|
|
1242
|
+
while (1) switch (_context15.n) {
|
|
1251
1243
|
case 0:
|
|
1252
|
-
|
|
1244
|
+
_context15.n = 1;
|
|
1253
1245
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1254
1246
|
case 1:
|
|
1255
|
-
outboundOperatingMode =
|
|
1256
|
-
return
|
|
1247
|
+
outboundOperatingMode = _context15.v;
|
|
1248
|
+
return _context15.a(2, outboundOperatingMode.toPrimitive());
|
|
1257
1249
|
}
|
|
1258
|
-
},
|
|
1250
|
+
}, _callee15, this);
|
|
1259
1251
|
}));
|
|
1260
1252
|
function getBridgeStatus() {
|
|
1261
1253
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1307,29 +1299,44 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1307
1299
|
}
|
|
1308
1300
|
}, {
|
|
1309
1301
|
key: "deriveAddress",
|
|
1310
|
-
value: function deriveAddress(
|
|
1311
|
-
|
|
1302
|
+
value: function deriveAddress(sender) {
|
|
1303
|
+
if (isSenderSigner(sender)) return sender.address;
|
|
1304
|
+
var _createKeyringPair = createKeyringPair(sender),
|
|
1312
1305
|
address = _createKeyringPair.address;
|
|
1313
1306
|
return address;
|
|
1314
1307
|
}
|
|
1315
1308
|
}, {
|
|
1316
1309
|
key: "signAndSubmit",
|
|
1317
1310
|
value: function () {
|
|
1318
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1319
|
-
var
|
|
1320
|
-
return _regenerator().w(function (
|
|
1321
|
-
while (1) switch (
|
|
1311
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
|
|
1312
|
+
var hash, _t8;
|
|
1313
|
+
return _regenerator().w(function (_context16) {
|
|
1314
|
+
while (1) switch (_context16.n) {
|
|
1322
1315
|
case 0:
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1316
|
+
if (!isSenderSigner(sender)) {
|
|
1317
|
+
_context16.n = 2;
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
_context16.n = 1;
|
|
1321
|
+
return tx.signAndSend(sender.address, {
|
|
1322
|
+
signer: sender.signer
|
|
1323
|
+
});
|
|
1326
1324
|
case 1:
|
|
1327
|
-
|
|
1328
|
-
|
|
1325
|
+
_t8 = _context16.v;
|
|
1326
|
+
_context16.n = 4;
|
|
1327
|
+
break;
|
|
1328
|
+
case 2:
|
|
1329
|
+
_context16.n = 3;
|
|
1330
|
+
return tx.signAndSend(createKeyringPair(sender));
|
|
1331
|
+
case 3:
|
|
1332
|
+
_t8 = _context16.v;
|
|
1333
|
+
case 4:
|
|
1334
|
+
hash = _t8;
|
|
1335
|
+
return _context16.a(2, hash.toHex());
|
|
1329
1336
|
}
|
|
1330
|
-
},
|
|
1337
|
+
}, _callee16);
|
|
1331
1338
|
}));
|
|
1332
|
-
function signAndSubmit(
|
|
1339
|
+
function signAndSubmit(_x31, _x32) {
|
|
1333
1340
|
return _signAndSubmit.apply(this, arguments);
|
|
1334
1341
|
}
|
|
1335
1342
|
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.1",
|
|
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.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@polkadot/api": ">= 16.0 < 17",
|