@paraspell/sdk 13.2.2 → 13.4.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 +62 -22
- package/dist/index.d.ts +10 -7
- package/dist/index.mjs +240 -261
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<img alt="build" src="https://github.com/paraspell/xcm-tools/actions/workflows/ci.yml/badge.svg" />
|
|
15
15
|
</a>
|
|
16
16
|
</p>
|
|
17
|
-
<p>Supporting every XCM Active Parachain <a href = "https://paraspell.github.io/docs/supported.html"\>[list]</p>
|
|
17
|
+
<p>Supporting every XCM Active Parachain <a href = "https://paraspell.github.io/docs/supported-chains.html"\>[list]</p>
|
|
18
18
|
<p>SDK documentation <a href = "https://paraspell.github.io/docs/" \>[here]</p>
|
|
19
19
|
<p>SDK starter template project <a href = "https://github.com/paraspell/xcm-sdk-template" \>[here]</p>
|
|
20
20
|
</div>
|
|
@@ -42,9 +42,9 @@ npm install | pnpm add | yarn add polkadot-api
|
|
|
42
42
|
npm install | pnpm add | yarn add @paraspell/sdk
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
### Install Swap extension
|
|
45
|
+
### (OPTIONAL) Install Swap extension
|
|
46
46
|
|
|
47
|
-
If you plan to [do Swap XCMs](https://paraspell.github.io/docs/sdk/
|
|
47
|
+
If you plan to [do Swap XCMs](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#swap) you can install Swap package which allows you to do cross-chain swaps on popular Polkadot, Kusama, Paseo, Westend exchanges. Now available in all JS client versions of SDK.
|
|
48
48
|
|
|
49
49
|
> [!IMPORTANT]
|
|
50
50
|
> - ⚠️ **WebAssembly (Wasm) must be enabled in your project** because of the Hydration SDK (One of the exchanges implemented in XCM Router). Wasm can be enabled either through the web application configuration or through the appropriate plugin.
|
|
@@ -55,7 +55,7 @@ If you plan to [do Swap XCMs](https://paraspell.github.io/docs/sdk/xcmPallet.htm
|
|
|
55
55
|
npm install | pnpm add | yarn add @paraspell/swap @galacticcouncil/api-augment
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
#### Setup Swap extension
|
|
59
59
|
|
|
60
60
|
Add the `@paraspell/swap` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
61
61
|
|
|
@@ -68,6 +68,48 @@ export default function App() {
|
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
### (OPTIONAL) Install EVM extension
|
|
72
|
+
If you plan to [do EVM contract transfers](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#moonbeam-xtokens-smart-contract) you can install EVM package which allows you to interact with EVM contract based XCMs on Moonbeam, Moonriver and Darwinia. Available in **ALL** versions of SDK.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install | pnpm add | yarn add @paraspell/evm
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Setup EVM extension
|
|
79
|
+
|
|
80
|
+
Add the `@paraspell/evm` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// Import EVM extension here
|
|
84
|
+
import '@paraspell/evm';
|
|
85
|
+
|
|
86
|
+
export default function App() {
|
|
87
|
+
return {/* Your app here */};
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### (OPTIONAL) Install Snowbridge extension
|
|
92
|
+
If you plan to [do Snowbridge transfers from Ethereum](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#ethereum-polkadot-transfer) you can install Snowbridge package which allows you to input "Ethereum" as from chain parameter. Available in **ALL** versions of SDK.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install | pnpm add | yarn add @paraspell/evm-snowbridge
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Setup Snowbridge extension
|
|
99
|
+
|
|
100
|
+
Add the `@paraspell/evm-snowbridge` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
// Import Snowbridge extension here
|
|
104
|
+
import '@paraspell/evm-snowbridge';
|
|
105
|
+
|
|
106
|
+
export default function App() {
|
|
107
|
+
return {/* Your app here */};
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
71
113
|
### Importing SDK functionality
|
|
72
114
|
|
|
73
115
|
Named import:
|
|
@@ -84,18 +126,16 @@ import * as paraspell from '@paraspell/sdk'
|
|
|
84
126
|
## Implementation
|
|
85
127
|
|
|
86
128
|
> [!NOTE]
|
|
87
|
-
> - You can now pass signer directly into sender parameter
|
|
88
|
-
> - The local transfers now have additional builder parameter called keepAlive
|
|
89
|
-
> - Transact is here! Find out more: https://paraspell.github.io/docs/sdk/xcmPallet.html#transact
|
|
90
|
-
> - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
|
|
91
|
-
> - Swap package is now available on every XCM SDK version: https://paraspell.github.io/docs/sdk/getting-started.html#install-swap-extension
|
|
92
|
-
>
|
|
93
129
|
> **Latest news:**
|
|
94
|
-
> -
|
|
95
|
-
> -
|
|
130
|
+
> - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
|
|
131
|
+
> - Swap extension is now available on every XCM SDK version: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-swap-extension
|
|
132
|
+
> - EVM extension is now available: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-evm-extension
|
|
133
|
+
> - Snowbridge extension is now available: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-snowbridge-extension
|
|
134
|
+
|
|
135
|
+
|
|
96
136
|
|
|
97
137
|
### Sending XCM
|
|
98
|
-
For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
138
|
+
For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html).
|
|
99
139
|
|
|
100
140
|
#### Transfer assets from Substrate to Substrate
|
|
101
141
|
|
|
@@ -173,7 +213,7 @@ await builder.disconnect()
|
|
|
173
213
|
|
|
174
214
|
```ts
|
|
175
215
|
const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
176
|
-
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
216
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
177
217
|
.to(TChain) // Has to be same as origin (from)
|
|
178
218
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/})
|
|
179
219
|
.sender(sender | PAPI SIGNER)
|
|
@@ -192,8 +232,8 @@ await builder.disconnect()
|
|
|
192
232
|
|
|
193
233
|
```ts
|
|
194
234
|
const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
195
|
-
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
196
|
-
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
235
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
236
|
+
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
197
237
|
.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*/})
|
|
198
238
|
.recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address location in one object (x2)*/)
|
|
199
239
|
.sender(address | PAPI_SIGNER /*Only in PAPI SDK*/ | {address, PJS_SIGNER} /*Only in PJS SDK*/) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub/Hydration with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
@@ -309,7 +349,7 @@ await builder.disconnect()
|
|
|
309
349
|
```
|
|
310
350
|
|
|
311
351
|
### XCM Fee queries
|
|
312
|
-
For full documentation with output examples of XCM Fee queries, head to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
352
|
+
For full documentation with output examples of XCM Fee queries, head to [official documentation](https://paraspell.github.io/docs/xcm-sdk/xcm-utils.html).
|
|
313
353
|
|
|
314
354
|
#### XCM Fee (Origin and Dest.)
|
|
315
355
|
|
|
@@ -425,8 +465,8 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
425
465
|
|
|
426
466
|
```ts
|
|
427
467
|
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
428
|
-
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
429
|
-
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
468
|
+
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
469
|
+
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
430
470
|
.currency(CURRENCY_SPEC)
|
|
431
471
|
.recipient(RECIPIENT_ADDRESS)
|
|
432
472
|
.sender(SENDER_ADDRESS)
|
|
@@ -474,7 +514,7 @@ let result = convertSs58(ADDRESS, TChain) // returns converted address in string
|
|
|
474
514
|
|
|
475
515
|
### Asset queries:
|
|
476
516
|
|
|
477
|
-
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
517
|
+
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/xcm-sdk/asset-package.html).
|
|
478
518
|
|
|
479
519
|
```ts
|
|
480
520
|
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk'
|
|
@@ -523,7 +563,7 @@ CHAINS
|
|
|
523
563
|
```
|
|
524
564
|
|
|
525
565
|
### Parachain XCM Pallet queries
|
|
526
|
-
For full documentation with output examples of pallet queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
566
|
+
For full documentation with output examples of pallet queries, head over to [official documentation](https://paraspell.github.io/docs/xcm-sdk/pallet-package.html).
|
|
527
567
|
|
|
528
568
|
```ts
|
|
529
569
|
import { getDefaultPallet, getSupportedPallets, getPalletIndex, getNativeAssetsPallet, getOtherAssetsPallets, SUPPORTED_PALLETS } from '@paraspell/sdk';
|
|
@@ -611,7 +651,7 @@ console.log(CHAINS)
|
|
|
611
651
|
|
|
612
652
|
## Contribute to XCM Tools and earn rewards 💰
|
|
613
653
|
|
|
614
|
-
We run an open Bug Bounty Program that rewards contributors for reporting and fixing bugs in the project. More information on bug bounty can be found in the [official documentation](https://paraspell.github.io/docs/contribution.html).
|
|
654
|
+
We run an open Bug Bounty Program that rewards contributors for reporting and fixing bugs in the project. More information on bug bounty can be found in the [official documentation](https://paraspell.github.io/docs/contribution-guidelines.html).
|
|
615
655
|
|
|
616
656
|
## Get Support 🚑
|
|
617
657
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { TChain, TSwapEvent as TSwapEvent$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TEvmTransferOptions, TCurrencyInputWithAmount, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions, TGetXcmFeeBaseOptions, TCreateBaseSwapXcmOptions } from '@paraspell/sdk-core';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import * as polkadot_api from 'polkadot-api';
|
|
5
5
|
import { PolkadotClient, Transaction, PolkadotSigner } from 'polkadot-api';
|
|
@@ -8,7 +8,7 @@ import { WalletClient } from 'viem';
|
|
|
8
8
|
type TPapiApi = PolkadotClient;
|
|
9
9
|
type TPapiSigner = PolkadotSigner;
|
|
10
10
|
type TPapiTransaction = Transaction<any, any>;
|
|
11
|
-
type
|
|
11
|
+
type TEvmChainFrom = Extract<TChain, 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
|
|
12
12
|
type TSwapEvent = TSwapEvent$1<TPapiApi, TPapiTransaction>;
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -71,12 +71,14 @@ declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
74
|
+
*
|
|
75
|
+
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
74
76
|
*/
|
|
75
|
-
declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<
|
|
77
|
+
declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmTransferOptions<TApi, TRes, TSigner>> = object> {
|
|
76
78
|
protected readonly _options: T;
|
|
77
79
|
constructor(options: T);
|
|
78
|
-
from(chain:
|
|
79
|
-
from:
|
|
80
|
+
from(chain: TEvmChainFrom): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
81
|
+
from: TEvmChainFrom;
|
|
80
82
|
}>;
|
|
81
83
|
/**
|
|
82
84
|
* Specifies the destination chain on Polkadot.
|
|
@@ -128,7 +130,7 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmBuilderO
|
|
|
128
130
|
*
|
|
129
131
|
* @throws Error if any required parameters are missing.
|
|
130
132
|
*/
|
|
131
|
-
build(this: EvmBuilderCore<TApi, TRes, TSigner,
|
|
133
|
+
build(this: EvmBuilderCore<TApi, TRes, TSigner, TEvmTransferOptions<TApi, TRes, TSigner>>): Promise<string>;
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
/**
|
|
@@ -139,6 +141,7 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmBuilderO
|
|
|
139
141
|
*/
|
|
140
142
|
declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, object>;
|
|
141
143
|
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPapiApi, TPapiTransaction, TPapiSigner>> = object> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T>;
|
|
144
|
+
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
142
145
|
declare const EvmBuilder: (api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
143
146
|
api: _paraspell_sdk_core.PolkadotApi<PolkadotClient, TPapiTransaction, PolkadotSigner>;
|
|
144
147
|
}>;
|
|
@@ -188,4 +191,4 @@ declare const checkAndConvertToNumberOrBigInt: (input: string) => number | bigin
|
|
|
188
191
|
declare const transform: (obj: any) => any;
|
|
189
192
|
|
|
190
193
|
export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, transform, transfer as xcmPallet };
|
|
191
|
-
export type { GeneralBuilder,
|
|
194
|
+
export type { GeneralBuilder, TEvmChainFrom, TPapiApi, TPapiSigner, TPapiTransaction, TSwapEvent };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, PolkadotApi,
|
|
1
|
+
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, PolkadotApi, Parents, findAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, RuntimeApiError, localizeLocation, isAssetXcEqual, createAssetId, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, isRelayChain, padValueBy, isAssetEqual, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
4
4
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
@@ -636,6 +636,10 @@ var _transform = function transform(obj) {
|
|
|
636
636
|
newObj[k] = Number(v);
|
|
637
637
|
continue;
|
|
638
638
|
}
|
|
639
|
+
if (k === 'call') {
|
|
640
|
+
newObj[k] = v;
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
639
643
|
if (k === 'currency_id' && typeof v === 'string') {
|
|
640
644
|
try {
|
|
641
645
|
newObj[k] = checkAndConvertToNumberOrBigInt(v);
|
|
@@ -707,7 +711,7 @@ var clientPool = createClientCache(MAX_CLIENTS, /*#__PURE__*/function () {
|
|
|
707
711
|
entry.client.destroy();
|
|
708
712
|
}, EXTENSION_MS);
|
|
709
713
|
var _createClientPoolHelp = createClientPoolHelpers(clientPool, createWsClient),
|
|
710
|
-
|
|
714
|
+
_leaseClient = _createClientPoolHelp.leaseClient,
|
|
711
715
|
releaseClient = _createClientPoolHelp.releaseClient;
|
|
712
716
|
var extractDryRunXcmFailureReason = function extractDryRunXcmFailureReason(result) {
|
|
713
717
|
var _result$value, _executionResult$valu, _ref2, _ref3, _ref4, _error$error$type, _error$error, _error$value, _error$value2, _error$value3, _ref5, _result$value2;
|
|
@@ -733,51 +737,16 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
733
737
|
}
|
|
734
738
|
_inherits(PapiApi, _PolkadotApi);
|
|
735
739
|
return _createClass(PapiApi, [{
|
|
736
|
-
key: "
|
|
737
|
-
value: function () {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
var clientTtlMs,
|
|
741
|
-
_args = arguments;
|
|
742
|
-
return _regenerator().w(function (_context2) {
|
|
743
|
-
while (1) switch (_context2.n) {
|
|
744
|
-
case 0:
|
|
745
|
-
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
746
|
-
if (!(this._chain !== undefined || isExternalChain(chain))) {
|
|
747
|
-
_context2.n = 1;
|
|
748
|
-
break;
|
|
749
|
-
}
|
|
750
|
-
return _context2.a(2);
|
|
751
|
-
case 1:
|
|
752
|
-
this._ttlMs = clientTtlMs;
|
|
753
|
-
this._chain = chain;
|
|
754
|
-
_context2.n = 2;
|
|
755
|
-
return resolveChainApi(this._config, chain, function (wsUrl) {
|
|
756
|
-
return leaseClient(wsUrl, _this2._ttlMs);
|
|
757
|
-
});
|
|
758
|
-
case 2:
|
|
759
|
-
this._api = _context2.v;
|
|
760
|
-
case 3:
|
|
761
|
-
return _context2.a(2);
|
|
762
|
-
}
|
|
763
|
-
}, _callee2, this);
|
|
764
|
-
}));
|
|
765
|
-
function init(_x2) {
|
|
766
|
-
return _init.apply(this, arguments);
|
|
767
|
-
}
|
|
768
|
-
return init;
|
|
769
|
-
}()
|
|
740
|
+
key: "leaseClient",
|
|
741
|
+
value: function leaseClient(wsUrl, ttlMs) {
|
|
742
|
+
return _leaseClient(wsUrl, ttlMs);
|
|
743
|
+
}
|
|
770
744
|
}, {
|
|
771
745
|
key: "untypedApi",
|
|
772
746
|
get: function get() {
|
|
773
747
|
if (!this._untypedApi) this._untypedApi = this.api.getUnsafeApi();
|
|
774
748
|
return this._untypedApi;
|
|
775
749
|
}
|
|
776
|
-
}, {
|
|
777
|
-
key: "createApiInstance",
|
|
778
|
-
value: function createApiInstance(wsUrl) {
|
|
779
|
-
return Promise.resolve(createWsClient(wsUrl));
|
|
780
|
-
}
|
|
781
750
|
}, {
|
|
782
751
|
key: "accountToHex",
|
|
783
752
|
value: function accountToHex(address) {
|
|
@@ -816,6 +785,32 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
816
785
|
var callData = Binary.fromHex(hex);
|
|
817
786
|
return this.untypedApi.txFromCallData(callData);
|
|
818
787
|
}
|
|
788
|
+
}, {
|
|
789
|
+
key: "txToHex",
|
|
790
|
+
value: function () {
|
|
791
|
+
var _txToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(tx) {
|
|
792
|
+
var encoded;
|
|
793
|
+
return _regenerator().w(function (_context2) {
|
|
794
|
+
while (1) switch (_context2.n) {
|
|
795
|
+
case 0:
|
|
796
|
+
_context2.n = 1;
|
|
797
|
+
return tx.getEncodedData();
|
|
798
|
+
case 1:
|
|
799
|
+
encoded = _context2.v;
|
|
800
|
+
return _context2.a(2, toHex(encoded));
|
|
801
|
+
}
|
|
802
|
+
}, _callee2);
|
|
803
|
+
}));
|
|
804
|
+
function txToHex(_x2) {
|
|
805
|
+
return _txToHex.apply(this, arguments);
|
|
806
|
+
}
|
|
807
|
+
return txToHex;
|
|
808
|
+
}()
|
|
809
|
+
}, {
|
|
810
|
+
key: "encodeTx",
|
|
811
|
+
value: function encodeTx(hex) {
|
|
812
|
+
return Binary.fromHex(hex);
|
|
813
|
+
}
|
|
819
814
|
}, {
|
|
820
815
|
key: "queryState",
|
|
821
816
|
value: function queryState(_ref7) {
|
|
@@ -988,34 +983,6 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
988
983
|
}
|
|
989
984
|
return getPaymentInfo;
|
|
990
985
|
}()
|
|
991
|
-
}, {
|
|
992
|
-
key: "quoteAhPrice",
|
|
993
|
-
value: function () {
|
|
994
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(fromMl, toMl, amountIn) {
|
|
995
|
-
var includeFee,
|
|
996
|
-
transformedFromMl,
|
|
997
|
-
transformedToMl,
|
|
998
|
-
response,
|
|
999
|
-
_args5 = arguments;
|
|
1000
|
-
return _regenerator().w(function (_context6) {
|
|
1001
|
-
while (1) switch (_context6.n) {
|
|
1002
|
-
case 0:
|
|
1003
|
-
includeFee = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : true;
|
|
1004
|
-
transformedFromMl = _transform(fromMl);
|
|
1005
|
-
transformedToMl = _transform(toMl);
|
|
1006
|
-
_context6.n = 1;
|
|
1007
|
-
return this.untypedApi.apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
|
|
1008
|
-
case 1:
|
|
1009
|
-
response = _context6.v;
|
|
1010
|
-
return _context6.a(2, response ? BigInt(response) : undefined);
|
|
1011
|
-
}
|
|
1012
|
-
}, _callee6, this);
|
|
1013
|
-
}));
|
|
1014
|
-
function quoteAhPrice(_x0, _x1, _x10) {
|
|
1015
|
-
return _quoteAhPrice.apply(this, arguments);
|
|
1016
|
-
}
|
|
1017
|
-
return quoteAhPrice;
|
|
1018
|
-
}()
|
|
1019
986
|
}, {
|
|
1020
987
|
key: "getEvmStorage",
|
|
1021
988
|
value: function getEvmStorage(contract, slot) {
|
|
@@ -1024,20 +991,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1024
991
|
}, {
|
|
1025
992
|
key: "getFromRpc",
|
|
1026
993
|
value: function () {
|
|
1027
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
994
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(module, method, key) {
|
|
1028
995
|
var value;
|
|
1029
|
-
return _regenerator().w(function (
|
|
1030
|
-
while (1) switch (
|
|
996
|
+
return _regenerator().w(function (_context6) {
|
|
997
|
+
while (1) switch (_context6.n) {
|
|
1031
998
|
case 0:
|
|
1032
|
-
|
|
999
|
+
_context6.n = 1;
|
|
1033
1000
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? AccountId().dec(key) : key]);
|
|
1034
1001
|
case 1:
|
|
1035
|
-
value =
|
|
1036
|
-
return
|
|
1002
|
+
value = _context6.v;
|
|
1003
|
+
return _context6.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1037
1004
|
}
|
|
1038
|
-
},
|
|
1005
|
+
}, _callee6, this);
|
|
1039
1006
|
}));
|
|
1040
|
-
function getFromRpc(
|
|
1007
|
+
function getFromRpc(_x0, _x1, _x10) {
|
|
1041
1008
|
return _getFromRpc.apply(this, arguments);
|
|
1042
1009
|
}
|
|
1043
1010
|
return getFromRpc;
|
|
@@ -1050,20 +1017,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1050
1017
|
}, {
|
|
1051
1018
|
key: "createApiForChain",
|
|
1052
1019
|
value: function () {
|
|
1053
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1020
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(chain) {
|
|
1054
1021
|
var api;
|
|
1055
|
-
return _regenerator().w(function (
|
|
1056
|
-
while (1) switch (
|
|
1022
|
+
return _regenerator().w(function (_context7) {
|
|
1023
|
+
while (1) switch (_context7.n) {
|
|
1057
1024
|
case 0:
|
|
1058
1025
|
api = new PapiApi(isConfig(this._config) ? this._config : undefined);
|
|
1059
|
-
|
|
1026
|
+
_context7.n = 1;
|
|
1060
1027
|
return api.init(chain);
|
|
1061
1028
|
case 1:
|
|
1062
|
-
return
|
|
1029
|
+
return _context7.a(2, api);
|
|
1063
1030
|
}
|
|
1064
|
-
},
|
|
1031
|
+
}, _callee7, this);
|
|
1065
1032
|
}));
|
|
1066
|
-
function createApiForChain(
|
|
1033
|
+
function createApiForChain(_x11) {
|
|
1067
1034
|
return _createApiForChain.apply(this, arguments);
|
|
1068
1035
|
}
|
|
1069
1036
|
return createApiForChain;
|
|
@@ -1078,44 +1045,44 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1078
1045
|
}, {
|
|
1079
1046
|
key: "resolveFeeAsset",
|
|
1080
1047
|
value: function () {
|
|
1081
|
-
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1048
|
+
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(options) {
|
|
1082
1049
|
var chain, address, feeAsset, assetId;
|
|
1083
|
-
return _regenerator().w(function (
|
|
1084
|
-
while (1) switch (
|
|
1050
|
+
return _regenerator().w(function (_context8) {
|
|
1051
|
+
while (1) switch (_context8.n) {
|
|
1085
1052
|
case 0:
|
|
1086
1053
|
chain = options.chain, address = options.address, feeAsset = options.feeAsset;
|
|
1087
1054
|
if (!(!chain.startsWith('Hydration') || feeAsset)) {
|
|
1088
|
-
|
|
1055
|
+
_context8.n = 1;
|
|
1089
1056
|
break;
|
|
1090
1057
|
}
|
|
1091
|
-
return
|
|
1058
|
+
return _context8.a(2, {
|
|
1092
1059
|
isCustomAsset: false,
|
|
1093
1060
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1094
1061
|
});
|
|
1095
1062
|
case 1:
|
|
1096
|
-
|
|
1063
|
+
_context8.n = 2;
|
|
1097
1064
|
return this.untypedApi.query.MultiTransactionPayment.AccountCurrencyMap.getValue(address);
|
|
1098
1065
|
case 2:
|
|
1099
|
-
assetId =
|
|
1066
|
+
assetId = _context8.v;
|
|
1100
1067
|
if (!(assetId === undefined)) {
|
|
1101
|
-
|
|
1068
|
+
_context8.n = 3;
|
|
1102
1069
|
break;
|
|
1103
1070
|
}
|
|
1104
|
-
return
|
|
1071
|
+
return _context8.a(2, {
|
|
1105
1072
|
isCustomAsset: false,
|
|
1106
1073
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1107
1074
|
});
|
|
1108
1075
|
case 3:
|
|
1109
|
-
return
|
|
1076
|
+
return _context8.a(2, {
|
|
1110
1077
|
isCustomAsset: true,
|
|
1111
1078
|
asset: findAssetInfoOrThrow(chain, {
|
|
1112
1079
|
id: assetId
|
|
1113
1080
|
})
|
|
1114
1081
|
});
|
|
1115
1082
|
}
|
|
1116
|
-
},
|
|
1083
|
+
}, _callee8, this);
|
|
1117
1084
|
}));
|
|
1118
|
-
function resolveFeeAsset(
|
|
1085
|
+
function resolveFeeAsset(_x12) {
|
|
1119
1086
|
return _resolveFeeAsset.apply(this, arguments);
|
|
1120
1087
|
}
|
|
1121
1088
|
return resolveFeeAsset;
|
|
@@ -1123,16 +1090,16 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1123
1090
|
}, {
|
|
1124
1091
|
key: "getDryRunCall",
|
|
1125
1092
|
value: function () {
|
|
1126
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1127
|
-
var
|
|
1093
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(options) {
|
|
1094
|
+
var _this2 = this;
|
|
1128
1095
|
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, message, isSuccess, resolvedFeeAsset, failureOutputReason, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t2, _t3, _t4;
|
|
1129
|
-
return _regenerator().w(function (
|
|
1130
|
-
while (1) switch (
|
|
1096
|
+
return _regenerator().w(function (_context9) {
|
|
1097
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
1131
1098
|
case 0:
|
|
1132
1099
|
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1133
1100
|
_getAssetsObject = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject.supportsDryRunApi;
|
|
1134
1101
|
if (supportsDryRunApi) {
|
|
1135
|
-
|
|
1102
|
+
_context9.n = 1;
|
|
1136
1103
|
break;
|
|
1137
1104
|
}
|
|
1138
1105
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
@@ -1147,29 +1114,29 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1147
1114
|
}
|
|
1148
1115
|
};
|
|
1149
1116
|
if (!useRootOrigin) {
|
|
1150
|
-
|
|
1117
|
+
_context9.n = 3;
|
|
1151
1118
|
break;
|
|
1152
1119
|
}
|
|
1153
|
-
|
|
1120
|
+
_context9.n = 2;
|
|
1154
1121
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1155
1122
|
api: this
|
|
1156
1123
|
}), bypassOptions);
|
|
1157
1124
|
case 2:
|
|
1158
|
-
_t2 =
|
|
1159
|
-
|
|
1125
|
+
_t2 = _context9.v;
|
|
1126
|
+
_context9.n = 4;
|
|
1160
1127
|
break;
|
|
1161
1128
|
case 3:
|
|
1162
1129
|
_t2 = tx;
|
|
1163
1130
|
case 4:
|
|
1164
1131
|
resolvedTx = _t2;
|
|
1165
1132
|
performDryRunCall = function performDryRunCall(includeVersion) {
|
|
1166
|
-
var
|
|
1133
|
+
var _this2$untypedApi$api;
|
|
1167
1134
|
var callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1168
1135
|
if (includeVersion) {
|
|
1169
1136
|
var versionNum = Number(version.charAt(1));
|
|
1170
1137
|
callArgs.push(versionNum);
|
|
1171
1138
|
}
|
|
1172
|
-
return (
|
|
1139
|
+
return (_this2$untypedApi$api = _this2.untypedApi.apis.DryRunApi).dry_run_call.apply(_this2$untypedApi$api, callArgs);
|
|
1173
1140
|
};
|
|
1174
1141
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
1175
1142
|
var _result$value3;
|
|
@@ -1217,41 +1184,41 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1217
1184
|
failureReason: JSON.stringify((_ref10 = (_result$value6 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value6 !== void 0 ? _result$value6 : result) !== null && _ref10 !== void 0 ? _ref10 : 'Unknown error structure', replaceBigInt)
|
|
1218
1185
|
};
|
|
1219
1186
|
};
|
|
1220
|
-
|
|
1221
|
-
|
|
1187
|
+
_context9.p = 5;
|
|
1188
|
+
_context9.n = 6;
|
|
1222
1189
|
return performDryRunCall(false);
|
|
1223
1190
|
case 6:
|
|
1224
|
-
result =
|
|
1225
|
-
|
|
1191
|
+
result = _context9.v;
|
|
1192
|
+
_context9.n = 10;
|
|
1226
1193
|
break;
|
|
1227
1194
|
case 7:
|
|
1228
|
-
|
|
1229
|
-
_t3 =
|
|
1195
|
+
_context9.p = 7;
|
|
1196
|
+
_t3 = _context9.v;
|
|
1230
1197
|
message = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
1231
1198
|
if (!message.includes('Incompatible runtime entry')) {
|
|
1232
|
-
|
|
1199
|
+
_context9.n = 9;
|
|
1233
1200
|
break;
|
|
1234
1201
|
}
|
|
1235
|
-
|
|
1202
|
+
_context9.n = 8;
|
|
1236
1203
|
return performDryRunCall(true);
|
|
1237
1204
|
case 8:
|
|
1238
|
-
result =
|
|
1239
|
-
|
|
1205
|
+
result = _context9.v;
|
|
1206
|
+
_context9.n = 10;
|
|
1240
1207
|
break;
|
|
1241
1208
|
case 9:
|
|
1242
1209
|
throw _t3;
|
|
1243
1210
|
case 10:
|
|
1244
1211
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1245
|
-
|
|
1212
|
+
_context9.n = 11;
|
|
1246
1213
|
return this.resolveFeeAsset(options);
|
|
1247
1214
|
case 11:
|
|
1248
|
-
resolvedFeeAsset =
|
|
1215
|
+
resolvedFeeAsset = _context9.v;
|
|
1249
1216
|
if (isSuccess) {
|
|
1250
|
-
|
|
1217
|
+
_context9.n = 12;
|
|
1251
1218
|
break;
|
|
1252
1219
|
}
|
|
1253
1220
|
failureOutputReason = extractFailureReasonFromResult(result);
|
|
1254
|
-
return
|
|
1221
|
+
return _context9.a(2, Promise.resolve({
|
|
1255
1222
|
success: false,
|
|
1256
1223
|
failureReason: failureOutputReason.failureReason,
|
|
1257
1224
|
failureSubReason: failureOutputReason.failureSubReason,
|
|
@@ -1267,32 +1234,32 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1267
1234
|
destParaId = extractDestParaId(forwardedXcms);
|
|
1268
1235
|
USE_XCM_PAYMENT_API_CHAINS = ['Astar'];
|
|
1269
1236
|
if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && (feeAsset || USE_XCM_PAYMENT_API_CHAINS.includes(chain) || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
1270
|
-
|
|
1237
|
+
_context9.n = 18;
|
|
1271
1238
|
break;
|
|
1272
1239
|
}
|
|
1273
1240
|
if (result.value.local_xcm) {
|
|
1274
|
-
|
|
1241
|
+
_context9.n = 14;
|
|
1275
1242
|
break;
|
|
1276
1243
|
}
|
|
1277
|
-
|
|
1244
|
+
_context9.n = 13;
|
|
1278
1245
|
return this.getPaymentInfo(tx, address);
|
|
1279
1246
|
case 13:
|
|
1280
|
-
_t4 =
|
|
1281
|
-
|
|
1247
|
+
_t4 = _context9.v.weight;
|
|
1248
|
+
_context9.n = 15;
|
|
1282
1249
|
break;
|
|
1283
1250
|
case 14:
|
|
1284
1251
|
_t4 = undefined;
|
|
1285
1252
|
case 15:
|
|
1286
1253
|
overriddenWeight = _t4;
|
|
1287
|
-
|
|
1254
|
+
_context9.n = 16;
|
|
1288
1255
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
1289
1256
|
case 16:
|
|
1290
|
-
xcmFee =
|
|
1257
|
+
xcmFee = _context9.v;
|
|
1291
1258
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1292
|
-
|
|
1259
|
+
_context9.n = 17;
|
|
1293
1260
|
break;
|
|
1294
1261
|
}
|
|
1295
|
-
return
|
|
1262
|
+
return _context9.a(2, Promise.resolve({
|
|
1296
1263
|
success: true,
|
|
1297
1264
|
fee: xcmFee,
|
|
1298
1265
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1306,13 +1273,13 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1306
1273
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1307
1274
|
};
|
|
1308
1275
|
case 18:
|
|
1309
|
-
|
|
1276
|
+
_context9.n = 19;
|
|
1310
1277
|
return this.getPaymentInfo(tx, address);
|
|
1311
1278
|
case 19:
|
|
1312
|
-
_yield$this$getPaymen =
|
|
1279
|
+
_yield$this$getPaymen = _context9.v;
|
|
1313
1280
|
executionFee = _yield$this$getPaymen.partialFee;
|
|
1314
1281
|
fee = computeOriginFee(result, chain, executionFee, !!feeAsset);
|
|
1315
|
-
return
|
|
1282
|
+
return _context9.a(2, Promise.resolve({
|
|
1316
1283
|
success: true,
|
|
1317
1284
|
fee: fee,
|
|
1318
1285
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1321,9 +1288,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1321
1288
|
destParaId: destParaId
|
|
1322
1289
|
}));
|
|
1323
1290
|
}
|
|
1324
|
-
},
|
|
1291
|
+
}, _callee9, this, [[5, 7]]);
|
|
1325
1292
|
}));
|
|
1326
|
-
function getDryRunCall(
|
|
1293
|
+
function getDryRunCall(_x13) {
|
|
1327
1294
|
return _getDryRunCall.apply(this, arguments);
|
|
1328
1295
|
}
|
|
1329
1296
|
return getDryRunCall;
|
|
@@ -1331,31 +1298,31 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1331
1298
|
}, {
|
|
1332
1299
|
key: "getXcmWeight",
|
|
1333
1300
|
value: function () {
|
|
1334
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1301
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(xcm) {
|
|
1335
1302
|
var weightRes, success, value, ref_time, proof_size;
|
|
1336
|
-
return _regenerator().w(function (
|
|
1337
|
-
while (1) switch (
|
|
1303
|
+
return _regenerator().w(function (_context0) {
|
|
1304
|
+
while (1) switch (_context0.n) {
|
|
1338
1305
|
case 0:
|
|
1339
|
-
|
|
1306
|
+
_context0.n = 1;
|
|
1340
1307
|
return this.untypedApi.apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1341
1308
|
case 1:
|
|
1342
|
-
weightRes =
|
|
1309
|
+
weightRes = _context0.v;
|
|
1343
1310
|
success = weightRes.success, value = weightRes.value;
|
|
1344
1311
|
if (success) {
|
|
1345
|
-
|
|
1312
|
+
_context0.n = 2;
|
|
1346
1313
|
break;
|
|
1347
1314
|
}
|
|
1348
1315
|
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(value)));
|
|
1349
1316
|
case 2:
|
|
1350
1317
|
ref_time = value.ref_time, proof_size = value.proof_size;
|
|
1351
|
-
return
|
|
1318
|
+
return _context0.a(2, {
|
|
1352
1319
|
refTime: ref_time,
|
|
1353
1320
|
proofSize: proof_size
|
|
1354
1321
|
});
|
|
1355
1322
|
}
|
|
1356
|
-
},
|
|
1323
|
+
}, _callee0, this);
|
|
1357
1324
|
}));
|
|
1358
|
-
function getXcmWeight(
|
|
1325
|
+
function getXcmWeight(_x14) {
|
|
1359
1326
|
return _getXcmWeight.apply(this, arguments);
|
|
1360
1327
|
}
|
|
1361
1328
|
return getXcmWeight;
|
|
@@ -1363,82 +1330,86 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1363
1330
|
}, {
|
|
1364
1331
|
key: "getDeliveryFee",
|
|
1365
1332
|
value: function () {
|
|
1366
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1333
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
1367
1334
|
var _deliveryFeeRes, _deliveryFeeRes2, _deliveryFeeRes3;
|
|
1368
1335
|
var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, assetId, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res, _t5, _t6;
|
|
1369
|
-
return _regenerator().w(function (
|
|
1370
|
-
while (1) switch (
|
|
1336
|
+
return _regenerator().w(function (_context1) {
|
|
1337
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
1371
1338
|
case 0:
|
|
1372
1339
|
xcmPaymentApi = this.untypedApi.apis.XcmPaymentApi;
|
|
1373
1340
|
usedThirdParam = false;
|
|
1374
1341
|
if (!(forwardedXcm.length > 0)) {
|
|
1375
|
-
|
|
1342
|
+
_context1.n = 6;
|
|
1376
1343
|
break;
|
|
1377
1344
|
}
|
|
1378
1345
|
baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
|
|
1379
|
-
|
|
1380
|
-
|
|
1346
|
+
_context1.p = 1;
|
|
1347
|
+
_context1.n = 2;
|
|
1381
1348
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs);
|
|
1382
1349
|
case 2:
|
|
1383
|
-
deliveryFeeRes =
|
|
1384
|
-
|
|
1350
|
+
deliveryFeeRes = _context1.v;
|
|
1351
|
+
_context1.n = 6;
|
|
1385
1352
|
break;
|
|
1386
1353
|
case 3:
|
|
1387
|
-
|
|
1388
|
-
_t5 =
|
|
1354
|
+
_context1.p = 3;
|
|
1355
|
+
_t5 = _context1.v;
|
|
1389
1356
|
message = _t5 instanceof Error ? _t5.message : String(_t5); // Some runtimes require the 3rd arg
|
|
1390
1357
|
if (!message.includes('Incompatible runtime entry')) {
|
|
1391
|
-
|
|
1358
|
+
_context1.n = 5;
|
|
1392
1359
|
break;
|
|
1393
1360
|
}
|
|
1394
1361
|
usedThirdParam = true;
|
|
1395
1362
|
assetId = createAssetId(version, assetLocalizedLoc);
|
|
1396
1363
|
transformedAssetLoc = _transform(addXcmVersionHeader(assetId, version));
|
|
1397
|
-
|
|
1364
|
+
_context1.n = 4;
|
|
1398
1365
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs.concat([transformedAssetLoc]));
|
|
1399
1366
|
case 4:
|
|
1400
|
-
deliveryFeeRes =
|
|
1401
|
-
|
|
1367
|
+
deliveryFeeRes = _context1.v;
|
|
1368
|
+
_context1.n = 6;
|
|
1402
1369
|
break;
|
|
1403
1370
|
case 5:
|
|
1404
1371
|
throw _t5;
|
|
1405
1372
|
case 6:
|
|
1406
1373
|
if (!(((_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 || (_deliveryFeeRes = _deliveryFeeRes.value) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.type) === 'Unimplemented')) {
|
|
1407
|
-
|
|
1374
|
+
_context1.n = 7;
|
|
1408
1375
|
break;
|
|
1409
1376
|
}
|
|
1410
|
-
return
|
|
1377
|
+
return _context1.a(2, 0n);
|
|
1411
1378
|
case 7:
|
|
1412
1379
|
deliveryFeeResolved = ((_deliveryFeeRes2 = deliveryFeeRes) === null || _deliveryFeeRes2 === void 0 || (_deliveryFeeRes2 = _deliveryFeeRes2.value) === null || _deliveryFeeRes2 === void 0 ? void 0 : _deliveryFeeRes2.value.length) > 0 ? (_deliveryFeeRes3 = deliveryFeeRes) === null || _deliveryFeeRes3 === void 0 || (_deliveryFeeRes3 = _deliveryFeeRes3.value) === null || _deliveryFeeRes3 === void 0 ? void 0 : _deliveryFeeRes3.value[0].fun.value : 0n;
|
|
1413
1380
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1414
1381
|
if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
|
|
1415
|
-
|
|
1382
|
+
_context1.n = 8;
|
|
1416
1383
|
break;
|
|
1417
1384
|
}
|
|
1418
|
-
return
|
|
1385
|
+
return _context1.a(2, deliveryFeeResolved);
|
|
1419
1386
|
case 8:
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
return this.
|
|
1387
|
+
_context1.p = 8;
|
|
1388
|
+
_context1.n = 9;
|
|
1389
|
+
return this.queryRuntimeApi({
|
|
1390
|
+
module: 'AssetConversionApi',
|
|
1391
|
+
method: 'quote_price_exact_tokens_for_tokens',
|
|
1392
|
+
params: [localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false]
|
|
1393
|
+
});
|
|
1423
1394
|
case 9:
|
|
1424
|
-
res =
|
|
1425
|
-
return
|
|
1395
|
+
res = _context1.v;
|
|
1396
|
+
return _context1.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
1426
1397
|
case 10:
|
|
1427
|
-
|
|
1428
|
-
_t6 =
|
|
1398
|
+
_context1.p = 10;
|
|
1399
|
+
_t6 = _context1.v;
|
|
1429
1400
|
if (!(_t6 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t6.message))) {
|
|
1430
|
-
|
|
1401
|
+
_context1.n = 11;
|
|
1431
1402
|
break;
|
|
1432
1403
|
}
|
|
1433
|
-
return
|
|
1404
|
+
return _context1.a(2, 0n);
|
|
1434
1405
|
case 11:
|
|
1435
|
-
return
|
|
1406
|
+
return _context1.a(2, 0n);
|
|
1436
1407
|
case 12:
|
|
1437
|
-
return
|
|
1408
|
+
return _context1.a(2);
|
|
1438
1409
|
}
|
|
1439
|
-
},
|
|
1410
|
+
}, _callee1, this, [[8, 10], [1, 3]]);
|
|
1440
1411
|
}));
|
|
1441
|
-
function getDeliveryFee(
|
|
1412
|
+
function getDeliveryFee(_x15, _x16, _x17, _x18, _x19) {
|
|
1442
1413
|
return _getDeliveryFee.apply(this, arguments);
|
|
1443
1414
|
}
|
|
1444
1415
|
return getDeliveryFee;
|
|
@@ -1446,8 +1417,8 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1446
1417
|
}, {
|
|
1447
1418
|
key: "getXcmPaymentApiFee",
|
|
1448
1419
|
value: function () {
|
|
1449
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1450
|
-
var
|
|
1420
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, localXcm, forwardedXcm, asset, version) {
|
|
1421
|
+
var _this3 = this,
|
|
1451
1422
|
_execFeeRes$value;
|
|
1452
1423
|
var transformXcm,
|
|
1453
1424
|
overridenWeight,
|
|
@@ -1462,85 +1433,85 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1462
1433
|
execFee,
|
|
1463
1434
|
bridgeHubExecFee,
|
|
1464
1435
|
deliveryFee,
|
|
1465
|
-
|
|
1436
|
+
_args10 = arguments,
|
|
1466
1437
|
_t7;
|
|
1467
|
-
return _regenerator().w(function (
|
|
1468
|
-
while (1) switch (
|
|
1438
|
+
return _regenerator().w(function (_context11) {
|
|
1439
|
+
while (1) switch (_context11.n) {
|
|
1469
1440
|
case 0:
|
|
1470
|
-
transformXcm =
|
|
1471
|
-
overridenWeight =
|
|
1441
|
+
transformXcm = _args10.length > 5 && _args10[5] !== undefined ? _args10[5] : false;
|
|
1442
|
+
overridenWeight = _args10.length > 6 ? _args10[6] : undefined;
|
|
1472
1443
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1473
1444
|
queryWeight = /*#__PURE__*/function () {
|
|
1474
|
-
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1445
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
1475
1446
|
var weightRes;
|
|
1476
|
-
return _regenerator().w(function (
|
|
1477
|
-
while (1) switch (
|
|
1447
|
+
return _regenerator().w(function (_context10) {
|
|
1448
|
+
while (1) switch (_context10.n) {
|
|
1478
1449
|
case 0:
|
|
1479
|
-
|
|
1480
|
-
return
|
|
1450
|
+
_context10.n = 1;
|
|
1451
|
+
return _this3.untypedApi.apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1481
1452
|
case 1:
|
|
1482
|
-
weightRes =
|
|
1453
|
+
weightRes = _context10.v;
|
|
1483
1454
|
if (weightRes.success) {
|
|
1484
|
-
|
|
1455
|
+
_context10.n = 2;
|
|
1485
1456
|
break;
|
|
1486
1457
|
}
|
|
1487
1458
|
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(weightRes.value)));
|
|
1488
1459
|
case 2:
|
|
1489
|
-
return
|
|
1460
|
+
return _context10.a(2, weightRes.value);
|
|
1490
1461
|
}
|
|
1491
|
-
},
|
|
1462
|
+
}, _callee10);
|
|
1492
1463
|
}));
|
|
1493
1464
|
return function queryWeight() {
|
|
1494
1465
|
return _ref11.apply(this, arguments);
|
|
1495
1466
|
};
|
|
1496
1467
|
}();
|
|
1497
1468
|
if (!overridenWeight) {
|
|
1498
|
-
|
|
1469
|
+
_context11.n = 1;
|
|
1499
1470
|
break;
|
|
1500
1471
|
}
|
|
1501
1472
|
_t7 = {
|
|
1502
1473
|
proof_size: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.proofSize,
|
|
1503
1474
|
ref_time: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.refTime
|
|
1504
1475
|
};
|
|
1505
|
-
|
|
1476
|
+
_context11.n = 3;
|
|
1506
1477
|
break;
|
|
1507
1478
|
case 1:
|
|
1508
|
-
|
|
1479
|
+
_context11.n = 2;
|
|
1509
1480
|
return queryWeight();
|
|
1510
1481
|
case 2:
|
|
1511
|
-
_t7 =
|
|
1482
|
+
_t7 = _context11.v;
|
|
1512
1483
|
case 3:
|
|
1513
1484
|
weight = _t7;
|
|
1514
1485
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1515
1486
|
assetId = createAssetId(version, assetLocalizedLoc);
|
|
1516
1487
|
versionedAssetId = addXcmVersionHeader(assetId, version);
|
|
1517
1488
|
transformedAssetLoc = _transform(versionedAssetId);
|
|
1518
|
-
|
|
1489
|
+
_context11.n = 4;
|
|
1519
1490
|
return this.untypedApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weight, transformedAssetLoc);
|
|
1520
1491
|
case 4:
|
|
1521
|
-
execFeeRes =
|
|
1492
|
+
execFeeRes = _context11.v;
|
|
1522
1493
|
execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === 'bigint' ? execFeeRes.value : 0n;
|
|
1523
1494
|
if (!(chain.startsWith('BridgeHub') && (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.success) === false && (execFeeRes === null || execFeeRes === void 0 || (_execFeeRes$value = execFeeRes.value) === null || _execFeeRes$value === void 0 ? void 0 : _execFeeRes$value.type) === 'AssetNotFound')) {
|
|
1524
|
-
|
|
1495
|
+
_context11.n = 6;
|
|
1525
1496
|
break;
|
|
1526
1497
|
}
|
|
1527
|
-
|
|
1498
|
+
_context11.n = 5;
|
|
1528
1499
|
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
1529
1500
|
case 5:
|
|
1530
|
-
bridgeHubExecFee =
|
|
1501
|
+
bridgeHubExecFee = _context11.v;
|
|
1531
1502
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
1532
1503
|
execFee = bridgeHubExecFee;
|
|
1533
1504
|
}
|
|
1534
1505
|
case 6:
|
|
1535
|
-
|
|
1506
|
+
_context11.n = 7;
|
|
1536
1507
|
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
1537
1508
|
case 7:
|
|
1538
|
-
deliveryFee =
|
|
1539
|
-
return
|
|
1509
|
+
deliveryFee = _context11.v;
|
|
1510
|
+
return _context11.a(2, execFee + deliveryFee);
|
|
1540
1511
|
}
|
|
1541
|
-
},
|
|
1512
|
+
}, _callee11, this);
|
|
1542
1513
|
}));
|
|
1543
|
-
function getXcmPaymentApiFee(
|
|
1514
|
+
function getXcmPaymentApiFee(_x20, _x21, _x22, _x23, _x24) {
|
|
1544
1515
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1545
1516
|
}
|
|
1546
1517
|
return getXcmPaymentApiFee;
|
|
@@ -1548,45 +1519,49 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1548
1519
|
}, {
|
|
1549
1520
|
key: "getBridgeHubFallbackExecFee",
|
|
1550
1521
|
value: function () {
|
|
1551
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1522
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, weightValue, asset, version) {
|
|
1552
1523
|
var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1553
|
-
return _regenerator().w(function (
|
|
1554
|
-
while (1) switch (
|
|
1524
|
+
return _regenerator().w(function (_context12) {
|
|
1525
|
+
while (1) switch (_context12.n) {
|
|
1555
1526
|
case 0:
|
|
1556
|
-
|
|
1527
|
+
_context12.n = 1;
|
|
1557
1528
|
return this.untypedApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
|
|
1558
1529
|
type: version,
|
|
1559
1530
|
value: _transform(RELAY_LOCATION)
|
|
1560
1531
|
});
|
|
1561
1532
|
case 1:
|
|
1562
|
-
fallbackExecFeeRes =
|
|
1533
|
+
fallbackExecFeeRes = _context12.v;
|
|
1563
1534
|
if (!(typeof (fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value) !== 'bigint')) {
|
|
1564
|
-
|
|
1535
|
+
_context12.n = 2;
|
|
1565
1536
|
break;
|
|
1566
1537
|
}
|
|
1567
|
-
return
|
|
1538
|
+
return _context12.a(2, undefined);
|
|
1568
1539
|
case 2:
|
|
1569
1540
|
ahApi = this.clone();
|
|
1570
1541
|
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1571
|
-
|
|
1542
|
+
_context12.n = 3;
|
|
1572
1543
|
return ahApi.init(assetHubChain);
|
|
1573
1544
|
case 3:
|
|
1574
1545
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1575
|
-
|
|
1576
|
-
return ahApi.
|
|
1546
|
+
_context12.n = 4;
|
|
1547
|
+
return ahApi.queryRuntimeApi({
|
|
1548
|
+
module: 'AssetConversionApi',
|
|
1549
|
+
method: 'quote_price_exact_tokens_for_tokens',
|
|
1550
|
+
params: [RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false]
|
|
1551
|
+
});
|
|
1577
1552
|
case 4:
|
|
1578
|
-
convertedExecFee =
|
|
1579
|
-
if (!(
|
|
1580
|
-
|
|
1553
|
+
convertedExecFee = _context12.v;
|
|
1554
|
+
if (!(convertedExecFee !== undefined)) {
|
|
1555
|
+
_context12.n = 5;
|
|
1581
1556
|
break;
|
|
1582
1557
|
}
|
|
1583
|
-
return
|
|
1558
|
+
return _context12.a(2, convertedExecFee);
|
|
1584
1559
|
case 5:
|
|
1585
|
-
return
|
|
1560
|
+
return _context12.a(2, undefined);
|
|
1586
1561
|
}
|
|
1587
|
-
},
|
|
1562
|
+
}, _callee12, this);
|
|
1588
1563
|
}));
|
|
1589
|
-
function getBridgeHubFallbackExecFee(
|
|
1564
|
+
function getBridgeHubFallbackExecFee(_x25, _x26, _x27, _x28) {
|
|
1590
1565
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1591
1566
|
}
|
|
1592
1567
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1594,32 +1569,32 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1594
1569
|
}, {
|
|
1595
1570
|
key: "getDryRunXcm",
|
|
1596
1571
|
value: function () {
|
|
1597
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1572
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref12) {
|
|
1598
1573
|
var _ref13, _processAssetsDeposit, _ref14, _ref15, _ref16, _ref17, _ref18;
|
|
1599
1574
|
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, _getAssetsObject2, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, execResult, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, feeEventValue, fee, processedFee;
|
|
1600
|
-
return _regenerator().w(function (
|
|
1601
|
-
while (1) switch (
|
|
1575
|
+
return _regenerator().w(function (_context13) {
|
|
1576
|
+
while (1) switch (_context13.n) {
|
|
1602
1577
|
case 0:
|
|
1603
1578
|
originLocation = _ref12.originLocation, xcm = _ref12.xcm, chain = _ref12.chain, origin = _ref12.origin, asset = _ref12.asset, feeAsset = _ref12.feeAsset, originFee = _ref12.originFee, amount = _ref12.amount, version = _ref12.version;
|
|
1604
1579
|
_getAssetsObject2 = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject2.supportsDryRunApi;
|
|
1605
1580
|
if (supportsDryRunApi) {
|
|
1606
|
-
|
|
1581
|
+
_context13.n = 1;
|
|
1607
1582
|
break;
|
|
1608
1583
|
}
|
|
1609
1584
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1610
1585
|
case 1:
|
|
1611
1586
|
transformedOriginLocation = _transform(originLocation);
|
|
1612
|
-
|
|
1587
|
+
_context13.n = 2;
|
|
1613
1588
|
return this.untypedApi.apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1614
1589
|
case 2:
|
|
1615
|
-
result =
|
|
1590
|
+
result = _context13.v;
|
|
1616
1591
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1617
1592
|
if (isSuccess) {
|
|
1618
|
-
|
|
1593
|
+
_context13.n = 3;
|
|
1619
1594
|
break;
|
|
1620
1595
|
}
|
|
1621
1596
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1622
|
-
return
|
|
1597
|
+
return _context13.a(2, {
|
|
1623
1598
|
success: false,
|
|
1624
1599
|
failureReason: failureReason,
|
|
1625
1600
|
asset: asset
|
|
@@ -1633,18 +1608,18 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1633
1608
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1634
1609
|
destParaId = extractDestParaId(forwardedXcms);
|
|
1635
1610
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1636
|
-
|
|
1611
|
+
_context13.n = 5;
|
|
1637
1612
|
break;
|
|
1638
1613
|
}
|
|
1639
|
-
|
|
1614
|
+
_context13.n = 4;
|
|
1640
1615
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1641
1616
|
case 4:
|
|
1642
|
-
_fee =
|
|
1617
|
+
_fee = _context13.v;
|
|
1643
1618
|
if (!(typeof _fee === 'bigint')) {
|
|
1644
|
-
|
|
1619
|
+
_context13.n = 5;
|
|
1645
1620
|
break;
|
|
1646
1621
|
}
|
|
1647
|
-
return
|
|
1622
|
+
return _context13.a(2, {
|
|
1648
1623
|
success: true,
|
|
1649
1624
|
fee: _fee,
|
|
1650
1625
|
asset: asset,
|
|
@@ -1687,10 +1662,10 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1687
1662
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1688
1663
|
});
|
|
1689
1664
|
if (feeEvent) {
|
|
1690
|
-
|
|
1665
|
+
_context13.n = 6;
|
|
1691
1666
|
break;
|
|
1692
1667
|
}
|
|
1693
|
-
return
|
|
1668
|
+
return _context13.a(2, Promise.resolve({
|
|
1694
1669
|
success: false,
|
|
1695
1670
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1696
1671
|
asset: asset
|
|
@@ -1702,7 +1677,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1702
1677
|
fee = amount - originFee - feeEventValue.amount;
|
|
1703
1678
|
}
|
|
1704
1679
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
|
|
1705
|
-
return
|
|
1680
|
+
return _context13.a(2, Promise.resolve({
|
|
1706
1681
|
success: true,
|
|
1707
1682
|
fee: processedFee,
|
|
1708
1683
|
asset: asset,
|
|
@@ -1711,9 +1686,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1711
1686
|
destParaId: destParaId
|
|
1712
1687
|
}));
|
|
1713
1688
|
}
|
|
1714
|
-
},
|
|
1689
|
+
}, _callee13, this);
|
|
1715
1690
|
}));
|
|
1716
|
-
function getDryRunXcm(
|
|
1691
|
+
function getDryRunXcm(_x29) {
|
|
1717
1692
|
return _getDryRunXcm.apply(this, arguments);
|
|
1718
1693
|
}
|
|
1719
1694
|
return getDryRunXcm;
|
|
@@ -1721,18 +1696,18 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1721
1696
|
}, {
|
|
1722
1697
|
key: "getBridgeStatus",
|
|
1723
1698
|
value: function () {
|
|
1724
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1699
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
1725
1700
|
var mode;
|
|
1726
|
-
return _regenerator().w(function (
|
|
1727
|
-
while (1) switch (
|
|
1701
|
+
return _regenerator().w(function (_context14) {
|
|
1702
|
+
while (1) switch (_context14.n) {
|
|
1728
1703
|
case 0:
|
|
1729
|
-
|
|
1704
|
+
_context14.n = 1;
|
|
1730
1705
|
return this.untypedApi.query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1731
1706
|
case 1:
|
|
1732
|
-
mode =
|
|
1733
|
-
return
|
|
1707
|
+
mode = _context14.v;
|
|
1708
|
+
return _context14.a(2, mode.type);
|
|
1734
1709
|
}
|
|
1735
|
-
},
|
|
1710
|
+
}, _callee14, this);
|
|
1736
1711
|
}));
|
|
1737
1712
|
function getBridgeStatus() {
|
|
1738
1713
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1770,22 +1745,22 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1770
1745
|
}, {
|
|
1771
1746
|
key: "signAndSubmit",
|
|
1772
1747
|
value: function () {
|
|
1773
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1748
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(tx, sender) {
|
|
1774
1749
|
var signer, _yield$tx$signAndSubm, txHash;
|
|
1775
|
-
return _regenerator().w(function (
|
|
1776
|
-
while (1) switch (
|
|
1750
|
+
return _regenerator().w(function (_context15) {
|
|
1751
|
+
while (1) switch (_context15.n) {
|
|
1777
1752
|
case 0:
|
|
1778
1753
|
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1779
|
-
|
|
1754
|
+
_context15.n = 1;
|
|
1780
1755
|
return tx.signAndSubmit(signer);
|
|
1781
1756
|
case 1:
|
|
1782
|
-
_yield$tx$signAndSubm =
|
|
1757
|
+
_yield$tx$signAndSubm = _context15.v;
|
|
1783
1758
|
txHash = _yield$tx$signAndSubm.txHash;
|
|
1784
|
-
return
|
|
1759
|
+
return _context15.a(2, txHash);
|
|
1785
1760
|
}
|
|
1786
|
-
},
|
|
1761
|
+
}, _callee15);
|
|
1787
1762
|
}));
|
|
1788
|
-
function signAndSubmit(
|
|
1763
|
+
function signAndSubmit(_x30, _x31) {
|
|
1789
1764
|
return _signAndSubmit.apply(this, arguments);
|
|
1790
1765
|
}
|
|
1791
1766
|
return signAndSubmit;
|
|
@@ -1793,13 +1768,13 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1793
1768
|
}, {
|
|
1794
1769
|
key: "signAndSubmitFinalized",
|
|
1795
1770
|
value: function () {
|
|
1796
|
-
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1771
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
|
|
1797
1772
|
var signer;
|
|
1798
|
-
return _regenerator().w(function (
|
|
1799
|
-
while (1) switch (
|
|
1773
|
+
return _regenerator().w(function (_context16) {
|
|
1774
|
+
while (1) switch (_context16.n) {
|
|
1800
1775
|
case 0:
|
|
1801
1776
|
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1802
|
-
return
|
|
1777
|
+
return _context16.a(2, new Promise(function (resolve, reject) {
|
|
1803
1778
|
tx.signSubmitAndWatch(signer).subscribe({
|
|
1804
1779
|
next: function next(event) {
|
|
1805
1780
|
if (event.type === 'finalized' || event.type === 'txBestBlocksState' && event.found) {
|
|
@@ -1816,9 +1791,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1816
1791
|
});
|
|
1817
1792
|
}));
|
|
1818
1793
|
}
|
|
1819
|
-
},
|
|
1794
|
+
}, _callee16);
|
|
1820
1795
|
}));
|
|
1821
|
-
function signAndSubmitFinalized(
|
|
1796
|
+
function signAndSubmitFinalized(_x32, _x33) {
|
|
1822
1797
|
return _signAndSubmitFinalized.apply(this, arguments);
|
|
1823
1798
|
}
|
|
1824
1799
|
return signAndSubmitFinalized;
|
|
@@ -1904,6 +1879,8 @@ var convertSs58 = function convertSs58(address, chain) {
|
|
|
1904
1879
|
|
|
1905
1880
|
/**
|
|
1906
1881
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
1882
|
+
*
|
|
1883
|
+
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
1907
1884
|
*/
|
|
1908
1885
|
var EvmBuilderCore = /*#__PURE__*/function () {
|
|
1909
1886
|
function EvmBuilderCore(options) {
|
|
@@ -2019,6 +1996,7 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
2019
1996
|
*
|
|
2020
1997
|
* @param provider - The Ethereum provider to use for the transfer.
|
|
2021
1998
|
* @returns An instance of EvmBuilder class
|
|
1999
|
+
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
2022
2000
|
*/
|
|
2023
2001
|
var EvmBuilder$1 = function EvmBuilder(api) {
|
|
2024
2002
|
return new EvmBuilderCore({
|
|
@@ -2036,6 +2014,7 @@ var Builder = function Builder(api) {
|
|
|
2036
2014
|
var papiApi = new PapiApi(api);
|
|
2037
2015
|
return Builder$1(papiApi);
|
|
2038
2016
|
};
|
|
2017
|
+
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
2039
2018
|
var EvmBuilder = function EvmBuilder(api) {
|
|
2040
2019
|
var papiApi = new PapiApi(api);
|
|
2041
2020
|
return EvmBuilder$1(papiApi);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.4.0",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.mjs"
|
|
16
|
-
"require": "./dist/index.cjs"
|
|
15
|
+
"import": "./dist/index.mjs"
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
|
-
"main": "dist/index.
|
|
18
|
+
"main": "dist/index.mjs",
|
|
20
19
|
"module": "dist/index.mjs",
|
|
21
20
|
"types": "dist/index.d.ts",
|
|
22
21
|
"files": [
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
"@polkadot-labs/hdkd": "^0.0.27",
|
|
28
27
|
"@polkadot-labs/hdkd-helpers": "^0.0.28",
|
|
29
28
|
"viem": "^2.47.6",
|
|
30
|
-
"@paraspell/sdk-core": "13.
|
|
29
|
+
"@paraspell/sdk-core": "13.4.0"
|
|
31
30
|
},
|
|
32
31
|
"peerDependencies": {
|
|
33
32
|
"polkadot-api": ">= 2 < 3"
|