@paraspell/sdk 13.11.0 → 14.0.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 +5 -8
- package/dist/index.d.ts +10 -98
- package/dist/index.mjs +94 -241
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ ParaSpell XCM SDK is the 🥇 in the ecosystem to support **PolkadotJS**, **Dedo
|
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
#Polkadot API peer dependencies
|
|
36
|
-
npm install | pnpm add | yarn add polkadot-api
|
|
36
|
+
npm install | pnpm add | yarn add polkadot-api @paraspell/descriptors
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
### Install SDK
|
|
@@ -127,10 +127,7 @@ import * as paraspell from '@paraspell/sdk'
|
|
|
127
127
|
|
|
128
128
|
> [!NOTE]
|
|
129
129
|
> **Latest news:**
|
|
130
|
-
> -
|
|
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
|
|
130
|
+
> - V13 > V14 Migration guide: https://paraspell.github.io/docs/migration/v13-to-v14.html
|
|
134
131
|
|
|
135
132
|
|
|
136
133
|
|
|
@@ -345,7 +342,7 @@ SDK features ability to add custom chain and/or custom assets simply by adding i
|
|
|
345
342
|
{
|
|
346
343
|
symbol: 'USDC',
|
|
347
344
|
decimals: 6,
|
|
348
|
-
existentialDeposit:
|
|
345
|
+
existentialDeposit: 100000000, //Needs to be in plancks
|
|
349
346
|
location: {
|
|
350
347
|
parents: 1,
|
|
351
348
|
interior: { X3: [{ Parachain: 1000 }, { PalletInstance: 50 }, {
|
|
@@ -364,7 +361,7 @@ SDK features ability to add custom chain and/or custom assets simply by adding i
|
|
|
364
361
|
symbol: 'MYNEWUSD',
|
|
365
362
|
decimals: 6,
|
|
366
363
|
assetId: '9999',
|
|
367
|
-
existentialDeposit:
|
|
364
|
+
existentialDeposit: 100000000, //Needs to be in plancks
|
|
368
365
|
location: {
|
|
369
366
|
parents: 0,
|
|
370
367
|
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 9999 }] }
|
|
@@ -375,7 +372,7 @@ SDK features ability to add custom chain and/or custom assets simply by adding i
|
|
|
375
372
|
symbol: 'USDT',
|
|
376
373
|
decimals: 6,
|
|
377
374
|
assetId: '1984',
|
|
378
|
-
existentialDeposit:
|
|
375
|
+
existentialDeposit: 100000000, //Needs to be in plancks
|
|
379
376
|
location: {
|
|
380
377
|
parents: 0,
|
|
381
378
|
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] }
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { TSwapEvent as TSwapEvent$1, Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TCustomChainFrom, TTransferBaseOptions, TCustomChainInput, TChainAssetsInfo, 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';
|
|
6
|
-
import
|
|
6
|
+
import * as _paraspell_descriptors from '@paraspell/descriptors';
|
|
7
7
|
|
|
8
8
|
type TPapiApi = PolkadotClient;
|
|
9
9
|
type TPapiSigner = PolkadotSigner;
|
|
10
10
|
type TPapiTransaction = Transaction<any, any>;
|
|
11
|
-
type TEvmChainFrom = Extract<TChain, 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
|
|
12
11
|
type TSwapEvent = TSwapEvent$1<TPapiApi, TPapiTransaction>;
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -25,11 +24,8 @@ declare const getBalance: (options: _paraspell_sdk_core.TGetBalanceCommonOptions
|
|
|
25
24
|
declare const assets_Foreign: typeof Foreign;
|
|
26
25
|
declare const assets_ForeignAbstract: typeof ForeignAbstract;
|
|
27
26
|
declare const assets_Native: typeof Native;
|
|
28
|
-
declare const assets_Override: typeof Override;
|
|
29
27
|
declare const assets_findAssetInfo: typeof findAssetInfo;
|
|
30
28
|
declare const assets_getAllAssetsSymbols: typeof getAllAssetsSymbols;
|
|
31
|
-
declare const assets_getAssetDecimals: typeof getAssetDecimals;
|
|
32
|
-
declare const assets_getAssetId: typeof getAssetId;
|
|
33
29
|
declare const assets_getAssets: typeof getAssets;
|
|
34
30
|
declare const assets_getAssetsObject: typeof getAssetsObject;
|
|
35
31
|
declare const assets_getBalance: typeof getBalance;
|
|
@@ -40,18 +36,14 @@ declare const assets_getOtherAssets: typeof getOtherAssets;
|
|
|
40
36
|
declare const assets_getRelayChainSymbol: typeof getRelayChainSymbol;
|
|
41
37
|
declare const assets_getSupportedAssets: typeof getSupportedAssets;
|
|
42
38
|
declare const assets_getTChain: typeof getTChain;
|
|
43
|
-
declare const assets_hasSupportForAsset: typeof hasSupportForAsset;
|
|
44
39
|
declare const assets_isChainEvm: typeof isChainEvm;
|
|
45
40
|
declare namespace assets {
|
|
46
41
|
export {
|
|
47
42
|
assets_Foreign as Foreign,
|
|
48
43
|
assets_ForeignAbstract as ForeignAbstract,
|
|
49
44
|
assets_Native as Native,
|
|
50
|
-
assets_Override as Override,
|
|
51
45
|
assets_findAssetInfo as findAssetInfo,
|
|
52
46
|
assets_getAllAssetsSymbols as getAllAssetsSymbols,
|
|
53
|
-
assets_getAssetDecimals as getAssetDecimals,
|
|
54
|
-
assets_getAssetId as getAssetId,
|
|
55
47
|
assets_getAssets as getAssets,
|
|
56
48
|
assets_getAssetsObject as getAssetsObject,
|
|
57
49
|
assets_getBalance as getBalance,
|
|
@@ -62,77 +54,12 @@ declare namespace assets {
|
|
|
62
54
|
assets_getRelayChainSymbol as getRelayChainSymbol,
|
|
63
55
|
assets_getSupportedAssets as getSupportedAssets,
|
|
64
56
|
assets_getTChain as getTChain,
|
|
65
|
-
assets_hasSupportForAsset as hasSupportForAsset,
|
|
66
57
|
assets_isChainEvm as isChainEvm,
|
|
67
58
|
};
|
|
68
59
|
}
|
|
69
60
|
|
|
70
61
|
declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
71
62
|
|
|
72
|
-
/**
|
|
73
|
-
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
74
|
-
*
|
|
75
|
-
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
76
|
-
*/
|
|
77
|
-
declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmTransferOptions<TApi, TRes, TSigner>> = object> {
|
|
78
|
-
protected readonly _options: T;
|
|
79
|
-
constructor(options: T);
|
|
80
|
-
from(chain: TEvmChainFrom): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
81
|
-
from: TEvmChainFrom;
|
|
82
|
-
}>;
|
|
83
|
-
/**
|
|
84
|
-
* Specifies the destination chain on Polkadot.
|
|
85
|
-
*
|
|
86
|
-
* @param chain - The Polkadot chain to which the transfer will be made.
|
|
87
|
-
* @returns An instance of EvmBuilder
|
|
88
|
-
*/
|
|
89
|
-
to(chain: TChain): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
90
|
-
to: TChain;
|
|
91
|
-
}>;
|
|
92
|
-
/**
|
|
93
|
-
* Specifies the currency to transfer.
|
|
94
|
-
*
|
|
95
|
-
* @param currency - The currency to be transferred.
|
|
96
|
-
* @returns An instance of EvmBuilder
|
|
97
|
-
*/
|
|
98
|
-
currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
99
|
-
currency: TCurrencyInputWithAmount;
|
|
100
|
-
}>;
|
|
101
|
-
/**
|
|
102
|
-
* Specifies the recipient address on Polkadot.
|
|
103
|
-
*
|
|
104
|
-
* @param address - The Polkadot address to receive the transfer.
|
|
105
|
-
* @returns An instance of EvmBuilder
|
|
106
|
-
*/
|
|
107
|
-
recipient(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
108
|
-
recipient: string;
|
|
109
|
-
}>;
|
|
110
|
-
/**
|
|
111
|
-
* Sets the asset hub address. This is used for transfers that go through the Asset Hub.
|
|
112
|
-
*
|
|
113
|
-
* @param address - The address to be used.
|
|
114
|
-
* @returns An instance of EvmBuilder
|
|
115
|
-
*/
|
|
116
|
-
ahAddress(address: string | undefined): EvmBuilderCore<unknown, unknown, unknown, T & {
|
|
117
|
-
ahAddress: string | undefined;
|
|
118
|
-
}>;
|
|
119
|
-
/**
|
|
120
|
-
* Specifies the signer for the Ethereum transaction.
|
|
121
|
-
*
|
|
122
|
-
* @param signer - The Ethereum signer to authorize the transfer.
|
|
123
|
-
* @returns An instance of EvmBuilder
|
|
124
|
-
*/
|
|
125
|
-
signer(signer: WalletClient): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
126
|
-
signer: WalletClient;
|
|
127
|
-
}>;
|
|
128
|
-
/**
|
|
129
|
-
* Builds and executes the transfer from Ethereum to Polkadot.
|
|
130
|
-
*
|
|
131
|
-
* @throws Error if any required parameters are missing.
|
|
132
|
-
*/
|
|
133
|
-
build(this: EvmBuilderCore<TApi, TRes, TSigner, TEvmTransferOptions<TApi, TRes, TSigner>>): Promise<string>;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
63
|
/**
|
|
137
64
|
* Creates a new Builder instance.
|
|
138
65
|
*
|
|
@@ -141,23 +68,12 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmTransfer
|
|
|
141
68
|
*/
|
|
142
69
|
declare const Builder: <const TOpts extends TBuilderOptions<TApiOrUrl<TPapiApi>>>(options?: TOpts) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, object, TCustomChainFrom<TOpts>>;
|
|
143
70
|
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPapiApi, TPapiTransaction, TPapiSigner>> = object, TCustomChain extends string = never> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T, TCustomChain>;
|
|
144
|
-
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
145
|
-
declare const EvmBuilder: (api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
146
|
-
api: _paraspell_sdk_core.PolkadotApi<PolkadotClient, polkadot_api.Transaction<any, Record<string, {
|
|
147
|
-
value: any;
|
|
148
|
-
additionalSigned: any;
|
|
149
|
-
} | {
|
|
150
|
-
value: any;
|
|
151
|
-
} | {
|
|
152
|
-
additionalSigned: any;
|
|
153
|
-
}> | Partial<any>>, any, never>;
|
|
154
|
-
}>;
|
|
155
71
|
|
|
156
72
|
declare const hydrateCustomChain: <TCustomChain extends string>(name: TCustomChain, input: TCustomChainInput) => Promise<TChainAssetsInfo>;
|
|
157
73
|
|
|
158
74
|
declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<TPapiTransaction, never> & {
|
|
159
75
|
api?: TApiOrUrl<TPapiApi>;
|
|
160
|
-
}) => Promise<_paraspell_sdk_core.TDryRunResult
|
|
76
|
+
}) => Promise<_paraspell_sdk_core.TDryRunResult<never>>;
|
|
161
77
|
declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<TPapiTransaction, never> & {
|
|
162
78
|
api?: TApiOrUrl<TPapiApi>;
|
|
163
79
|
}) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
|
|
@@ -169,15 +85,11 @@ declare const getBridgeStatus: (ahApi?: TApiOrUrl<TPapiApi>) => Promise<_paraspe
|
|
|
169
85
|
declare const getOriginXcmFee: (options: _paraspell_sdk_core.TGetOriginXcmFeeBaseOptions<TPapiTransaction, boolean, never> & {
|
|
170
86
|
api?: TApiOrUrl<TPapiApi>;
|
|
171
87
|
}) => Promise<_paraspell_sdk_core.TXcmFeeDetailWithForwardedXcm<boolean>>;
|
|
172
|
-
declare const getXcmFee: <TDisableFallback extends boolean>(options: TGetXcmFeeBaseOptions<TPapiTransaction, TDisableFallback>, builderOptions?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<_paraspell_sdk_core.TGetXcmFeeResult<TDisableFallback>>;
|
|
173
|
-
declare const handleSwapExecuteTransfer: (options: TCreateBaseSwapXcmOptions, builderOptions?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<polkadot_api.Transaction<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} |
|
|
177
|
-
value: any;
|
|
178
|
-
} | {
|
|
179
|
-
additionalSigned: any;
|
|
180
|
-
}> | Partial<any>>>;
|
|
88
|
+
declare const getXcmFee: <TDisableFallback extends boolean>(options: TGetXcmFeeBaseOptions<TPapiTransaction, TDisableFallback>, builderOptions?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<_paraspell_sdk_core.TGetXcmFeeResult<TDisableFallback, never>>;
|
|
89
|
+
declare const handleSwapExecuteTransfer: (options: TCreateBaseSwapXcmOptions, builderOptions?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => Promise<polkadot_api.Transaction<{
|
|
90
|
+
parents: number;
|
|
91
|
+
interior: _paraspell_descriptors.XcmV5Junctions;
|
|
92
|
+
} | undefined, Partial<_paraspell_descriptors.AhpExtensions>>>;
|
|
181
93
|
|
|
182
94
|
declare const transfer_dryRun: typeof dryRun;
|
|
183
95
|
declare const transfer_dryRunOrigin: typeof dryRunOrigin;
|
|
@@ -203,5 +115,5 @@ declare const createChainClient: (chain: TSubstrateChain, api?: TBuilderOptions<
|
|
|
203
115
|
declare const checkAndConvertToNumberOrBigInt: (input: string) => number | bigint;
|
|
204
116
|
declare const transform: (obj: any) => any;
|
|
205
117
|
|
|
206
|
-
export { Builder,
|
|
207
|
-
export type { GeneralBuilder,
|
|
118
|
+
export { Builder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, hydrateCustomChain, transform, transfer as xcmPallet };
|
|
119
|
+
export type { GeneralBuilder, 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, isCustomChain, PolkadotApi, Parents,
|
|
1
|
+
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, isCustomChain, PolkadotApi, Parents, buildDryRunError, replaceBigInt, RuntimeApiUnavailableError, wrapTxBypass, RuntimeApiError, localizeLocation, isAssetEqual, createAssetId, addXcmVersionHeader, RELAY_LOCATION, isRelayChain, padValueBy, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, convertSs58 as convertSs58$1, Builder as Builder$1, CustomChainInvalidError, 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';
|
|
@@ -8,6 +8,7 @@ import { entropyToMiniSecret, mnemonicToEntropy, DEV_PHRASE } from '@polkadot-la
|
|
|
8
8
|
import { AccountId, Binary, getSs58AddressInfo } from 'polkadot-api';
|
|
9
9
|
import { getPolkadotSigner } from 'polkadot-api/signer';
|
|
10
10
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
11
|
+
import { hydration } from '@paraspell/descriptors';
|
|
11
12
|
import { unifyMetadata, decAnyMetadata } from '@polkadot-api/substrate-bindings';
|
|
12
13
|
import { toHex } from 'polkadot-api/utils';
|
|
13
14
|
import { createWsClient } from 'polkadot-api/ws';
|
|
@@ -750,22 +751,22 @@ var extractDryRunXcmFailureReason = function extractDryRunXcmFailureReason(resul
|
|
|
750
751
|
var executionResult = result === null || result === void 0 || (_result$value = result.value) === null || _result$value === void 0 ? void 0 : _result$value.execution_result;
|
|
751
752
|
var error = executionResult === null || executionResult === void 0 || (_executionResult$valu = executionResult.value) === null || _executionResult$valu === void 0 ? void 0 : _executionResult$valu.error;
|
|
752
753
|
var failureType = (_ref2 = (_ref3 = (_ref4 = (_error$error$type = error === null || error === void 0 || (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.type) !== null && _error$error$type !== void 0 ? _error$error$type : error === null || error === void 0 || (_error$value = error.value) === null || _error$value === void 0 || (_error$value = _error$value.error) === null || _error$value === void 0 ? void 0 : _error$value.type) !== null && _ref4 !== void 0 ? _ref4 : error === null || error === void 0 || (_error$value2 = error.value) === null || _error$value2 === void 0 || (_error$value2 = _error$value2.value) === null || _error$value2 === void 0 ? void 0 : _error$value2.type) !== null && _ref3 !== void 0 ? _ref3 : error === null || error === void 0 || (_error$value3 = error.value) === null || _error$value3 === void 0 ? void 0 : _error$value3.type) !== null && _ref2 !== void 0 ? _ref2 : error === null || error === void 0 ? void 0 : error.type;
|
|
753
|
-
var
|
|
754
|
+
var instructionIndex = typeof (error === null || error === void 0 ? void 0 : error.index) === 'number' ? error.index : undefined;
|
|
754
755
|
if (typeof failureType === 'string') {
|
|
755
756
|
return {
|
|
756
|
-
|
|
757
|
-
|
|
757
|
+
reason: failureType,
|
|
758
|
+
instructionIndex: instructionIndex
|
|
758
759
|
};
|
|
759
760
|
}
|
|
760
761
|
if (typeof (executionResult === null || executionResult === void 0 ? void 0 : executionResult.type) === 'string') {
|
|
761
762
|
return {
|
|
762
|
-
|
|
763
|
-
|
|
763
|
+
reason: executionResult.type,
|
|
764
|
+
instructionIndex: instructionIndex
|
|
764
765
|
};
|
|
765
766
|
}
|
|
766
767
|
return {
|
|
767
|
-
|
|
768
|
-
|
|
768
|
+
reason: JSON.stringify((_ref5 = (_result$value2 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value2 !== void 0 ? _result$value2 : result) !== null && _ref5 !== void 0 ? _ref5 : 'Unknown error structure', replaceBigInt),
|
|
769
|
+
instructionIndex: instructionIndex
|
|
769
770
|
};
|
|
770
771
|
};
|
|
771
772
|
var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
@@ -774,7 +775,6 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
774
775
|
_classCallCheck(this, PapiApi);
|
|
775
776
|
_this = _callSuper(this, PapiApi, arguments);
|
|
776
777
|
_this.type = 'PAPI';
|
|
777
|
-
_this._untypedApi = null;
|
|
778
778
|
return _this;
|
|
779
779
|
}
|
|
780
780
|
_inherits(PapiApi, _PolkadotApi);
|
|
@@ -786,8 +786,32 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
786
786
|
}, {
|
|
787
787
|
key: "untypedApi",
|
|
788
788
|
get: function get() {
|
|
789
|
-
|
|
790
|
-
return this._untypedApi;
|
|
789
|
+
var _this$_untypedApi;
|
|
790
|
+
return (_this$_untypedApi = this._untypedApi) !== null && _this$_untypedApi !== void 0 ? _this$_untypedApi : this._untypedApi = this.api.getUnsafeApi();
|
|
791
|
+
}
|
|
792
|
+
}, {
|
|
793
|
+
key: "ahpApi",
|
|
794
|
+
get: function get() {
|
|
795
|
+
var _this$_ahpApi;
|
|
796
|
+
return (_this$_ahpApi = this._ahpApi) !== null && _this$_ahpApi !== void 0 ? _this$_ahpApi : this._ahpApi = this.api.getUnsafeApi();
|
|
797
|
+
}
|
|
798
|
+
}, {
|
|
799
|
+
key: "bridgeHubApi",
|
|
800
|
+
get: function get() {
|
|
801
|
+
var _this$_bridgeHubApi;
|
|
802
|
+
return (_this$_bridgeHubApi = this._bridgeHubApi) !== null && _this$_bridgeHubApi !== void 0 ? _this$_bridgeHubApi : this._bridgeHubApi = this.api.getUnsafeApi();
|
|
803
|
+
}
|
|
804
|
+
}, {
|
|
805
|
+
key: "hydrationApi",
|
|
806
|
+
get: function get() {
|
|
807
|
+
var _this$_hydrationApi;
|
|
808
|
+
return (_this$_hydrationApi = this._hydrationApi) !== null && _this$_hydrationApi !== void 0 ? _this$_hydrationApi : this._hydrationApi = this.api.getTypedApi(hydration);
|
|
809
|
+
}
|
|
810
|
+
}, {
|
|
811
|
+
key: "moonbeamApi",
|
|
812
|
+
get: function get() {
|
|
813
|
+
var _this$_moonbeamApi;
|
|
814
|
+
return (_this$_moonbeamApi = this._moonbeamApi) !== null && _this$_moonbeamApi !== void 0 ? _this$_moonbeamApi : this._moonbeamApi = this.api.getUnsafeApi();
|
|
791
815
|
}
|
|
792
816
|
}, {
|
|
793
817
|
key: "accountToHex",
|
|
@@ -875,7 +899,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
875
899
|
key: "callBatchMethod",
|
|
876
900
|
value: function callBatchMethod(calls, mode) {
|
|
877
901
|
var method = mode === BatchMode.BATCH_ALL ? 'batch_all' : 'batch';
|
|
878
|
-
return this.
|
|
902
|
+
return this.ahpApi.tx.Utility[method]({
|
|
879
903
|
calls: calls.map(function (_ref9) {
|
|
880
904
|
var decodedCall = _ref9.decodedCall;
|
|
881
905
|
return decodedCall;
|
|
@@ -886,15 +910,14 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
886
910
|
key: "callDispatchAsMethod",
|
|
887
911
|
value: function callDispatchAsMethod(_ref0, address) {
|
|
888
912
|
var decodedCall = _ref0.decodedCall;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
as_origin: origin,
|
|
913
|
+
return this.ahpApi.tx.Utility.dispatch_as({
|
|
914
|
+
as_origin: {
|
|
915
|
+
type: 'system',
|
|
916
|
+
value: {
|
|
917
|
+
type: 'Signed',
|
|
918
|
+
value: address
|
|
919
|
+
}
|
|
920
|
+
},
|
|
898
921
|
call: decodedCall
|
|
899
922
|
});
|
|
900
923
|
}
|
|
@@ -907,13 +930,14 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
907
930
|
while (1) switch (_context3.n) {
|
|
908
931
|
case 0:
|
|
909
932
|
transformedObj = _transform(obj);
|
|
910
|
-
tx = this.
|
|
933
|
+
tx = this.ahpApi.tx.PolkadotXcm.send({
|
|
911
934
|
dest: {
|
|
912
935
|
type: version,
|
|
913
936
|
value: {
|
|
914
937
|
parents: Parents.ZERO,
|
|
915
938
|
interior: {
|
|
916
|
-
type: 'Here'
|
|
939
|
+
type: 'Here',
|
|
940
|
+
value: undefined
|
|
917
941
|
}
|
|
918
942
|
}
|
|
919
943
|
},
|
|
@@ -1104,7 +1128,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1104
1128
|
}, {
|
|
1105
1129
|
key: "getEvmStorage",
|
|
1106
1130
|
value: function getEvmStorage(contract, slot) {
|
|
1107
|
-
return this.
|
|
1131
|
+
return this.moonbeamApi.query.EVM.AccountStorages.getKey(contract, slot);
|
|
1108
1132
|
}
|
|
1109
1133
|
}, {
|
|
1110
1134
|
key: "getFromRpc",
|
|
@@ -1179,7 +1203,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1179
1203
|
});
|
|
1180
1204
|
case 1:
|
|
1181
1205
|
_context1.n = 2;
|
|
1182
|
-
return this.
|
|
1206
|
+
return this.hydrationApi.query.MultiTransactionPayment.AccountCurrencyMap.getValue(address);
|
|
1183
1207
|
case 2:
|
|
1184
1208
|
assetId = _context1.v;
|
|
1185
1209
|
if (!(assetId === undefined)) {
|
|
@@ -1210,7 +1234,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1210
1234
|
value: function () {
|
|
1211
1235
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
|
|
1212
1236
|
var _this2 = this;
|
|
1213
|
-
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, message, isSuccess, resolvedFeeAsset, _result2,
|
|
1237
|
+
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, message, isSuccess, resolvedFeeAsset, _result2, failure, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t3, _t4, _t5;
|
|
1214
1238
|
return _regenerator().w(function (_context10) {
|
|
1215
1239
|
while (1) switch (_context10.p = _context10.n) {
|
|
1216
1240
|
case 0:
|
|
@@ -1286,22 +1310,22 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1286
1310
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1287
1311
|
var _obj$value, _obj$value2, _ref10, _result$value6;
|
|
1288
1312
|
var obj = findFailureObjectFromResult(result);
|
|
1289
|
-
var
|
|
1313
|
+
var instructionIndex = typeof (obj === null || obj === void 0 || (_obj$value = obj.value) === null || _obj$value === void 0 ? void 0 : _obj$value.index) === 'number' ? obj.value.index : undefined;
|
|
1290
1314
|
if (obj !== null && obj !== void 0 && obj.type && obj !== null && obj !== void 0 && (_obj$value2 = obj.value) !== null && _obj$value2 !== void 0 && (_obj$value2 = _obj$value2.error) !== null && _obj$value2 !== void 0 && _obj$value2.type) {
|
|
1291
1315
|
return {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1316
|
+
reason: obj.type,
|
|
1317
|
+
subReason: obj.value.error.type,
|
|
1318
|
+
instructionIndex: instructionIndex
|
|
1295
1319
|
};
|
|
1296
1320
|
}
|
|
1297
1321
|
if (obj !== null && obj !== void 0 && obj.type) {
|
|
1298
1322
|
return {
|
|
1299
|
-
|
|
1300
|
-
|
|
1323
|
+
reason: obj.type,
|
|
1324
|
+
instructionIndex: instructionIndex
|
|
1301
1325
|
};
|
|
1302
1326
|
}
|
|
1303
1327
|
return {
|
|
1304
|
-
|
|
1328
|
+
reason: 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)
|
|
1305
1329
|
};
|
|
1306
1330
|
};
|
|
1307
1331
|
_context10.p = 5;
|
|
@@ -1337,13 +1361,10 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1337
1361
|
_context10.n = 12;
|
|
1338
1362
|
break;
|
|
1339
1363
|
}
|
|
1340
|
-
|
|
1364
|
+
failure = extractFailureReasonFromResult(result);
|
|
1341
1365
|
return _context10.a(2, Promise.resolve({
|
|
1342
1366
|
success: false,
|
|
1343
|
-
|
|
1344
|
-
failureSubReason: failureOutputReason.failureSubReason,
|
|
1345
|
-
failureIndex: failureOutputReason.failureIndex,
|
|
1346
|
-
failureInstruction: getFailingInstruction((_result2 = result) === null || _result2 === void 0 || (_result2 = _result2.value) === null || _result2 === void 0 ? void 0 : _result2.local_xcm, failureOutputReason.failureIndex),
|
|
1367
|
+
dryRunError: buildDryRunError(failure, (_result2 = result) === null || _result2 === void 0 || (_result2 = _result2.value) === null || _result2 === void 0 ? void 0 : _result2.local_xcm),
|
|
1347
1368
|
asset: resolvedFeeAsset.asset
|
|
1348
1369
|
}));
|
|
1349
1370
|
case 12:
|
|
@@ -1356,7 +1377,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1356
1377
|
destParaId = extractDestParaId(forwardedXcms);
|
|
1357
1378
|
USE_XCM_PAYMENT_API_CHAINS = ['Astar'];
|
|
1358
1379
|
if (!(this.hasXcmPaymentApiSupport(chain) && result.value.local_xcm && (feeAsset || USE_XCM_PAYMENT_API_CHAINS.includes(chain) || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
1359
|
-
_context10.n =
|
|
1380
|
+
_context10.n = 17;
|
|
1360
1381
|
break;
|
|
1361
1382
|
}
|
|
1362
1383
|
if (result.value.local_xcm) {
|
|
@@ -1377,10 +1398,6 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1377
1398
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
1378
1399
|
case 16:
|
|
1379
1400
|
xcmFee = _context10.v;
|
|
1380
|
-
if (!(typeof xcmFee === 'bigint')) {
|
|
1381
|
-
_context10.n = 17;
|
|
1382
|
-
break;
|
|
1383
|
-
}
|
|
1384
1401
|
return _context10.a(2, Promise.resolve({
|
|
1385
1402
|
success: true,
|
|
1386
1403
|
fee: xcmFee,
|
|
@@ -1390,14 +1407,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1390
1407
|
destParaId: destParaId
|
|
1391
1408
|
}));
|
|
1392
1409
|
case 17:
|
|
1393
|
-
|
|
1394
|
-
isCustomAsset: false,
|
|
1395
|
-
asset: this.resolveDefaultFeeAsset(options)
|
|
1396
|
-
};
|
|
1397
|
-
case 18:
|
|
1398
|
-
_context10.n = 19;
|
|
1410
|
+
_context10.n = 18;
|
|
1399
1411
|
return this.getPaymentInfo(tx, address);
|
|
1400
|
-
case
|
|
1412
|
+
case 18:
|
|
1401
1413
|
_yield$this$getPaymen = _context10.v;
|
|
1402
1414
|
executionFee = _yield$this$getPaymen.partialFee;
|
|
1403
1415
|
fee = computeOriginFee(result, chain, executionFee, !!feeAsset);
|
|
@@ -1421,22 +1433,21 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1421
1433
|
key: "getXcmWeight",
|
|
1422
1434
|
value: function () {
|
|
1423
1435
|
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(xcm) {
|
|
1424
|
-
var weightRes,
|
|
1436
|
+
var weightRes, _weightRes$value, ref_time, proof_size;
|
|
1425
1437
|
return _regenerator().w(function (_context11) {
|
|
1426
1438
|
while (1) switch (_context11.n) {
|
|
1427
1439
|
case 0:
|
|
1428
1440
|
_context11.n = 1;
|
|
1429
|
-
return this.
|
|
1441
|
+
return this.ahpApi.apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1430
1442
|
case 1:
|
|
1431
1443
|
weightRes = _context11.v;
|
|
1432
|
-
|
|
1433
|
-
if (success) {
|
|
1444
|
+
if (weightRes.success) {
|
|
1434
1445
|
_context11.n = 2;
|
|
1435
1446
|
break;
|
|
1436
1447
|
}
|
|
1437
|
-
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(value)));
|
|
1448
|
+
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(weightRes.value)));
|
|
1438
1449
|
case 2:
|
|
1439
|
-
ref_time = value.ref_time, proof_size = value.proof_size;
|
|
1450
|
+
_weightRes$value = weightRes.value, ref_time = _weightRes$value.ref_time, proof_size = _weightRes$value.proof_size;
|
|
1440
1451
|
return _context11.a(2, {
|
|
1441
1452
|
refTime: ref_time,
|
|
1442
1453
|
proofSize: proof_size
|
|
@@ -1508,11 +1519,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1508
1519
|
case 8:
|
|
1509
1520
|
_context12.p = 8;
|
|
1510
1521
|
_context12.n = 9;
|
|
1511
|
-
return this.
|
|
1512
|
-
module: 'AssetConversionApi',
|
|
1513
|
-
method: 'quote_price_exact_tokens_for_tokens',
|
|
1514
|
-
params: [localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false]
|
|
1515
|
-
});
|
|
1522
|
+
return this.ahpApi.apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(_transform(localizeLocation(chain, nativeAsset.location)), _transform(assetLocalizedLoc), deliveryFeeResolved, false);
|
|
1516
1523
|
case 9:
|
|
1517
1524
|
res = _context12.v;
|
|
1518
1525
|
return _context12.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
@@ -1540,8 +1547,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1540
1547
|
key: "getXcmPaymentApiFee",
|
|
1541
1548
|
value: function () {
|
|
1542
1549
|
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset, version) {
|
|
1543
|
-
var _this3 = this
|
|
1544
|
-
_execFeeRes$value;
|
|
1550
|
+
var _this3 = this;
|
|
1545
1551
|
var transformXcm,
|
|
1546
1552
|
overridenWeight,
|
|
1547
1553
|
transformedXcm,
|
|
@@ -1553,7 +1559,6 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1553
1559
|
transformedAssetLoc,
|
|
1554
1560
|
execFeeRes,
|
|
1555
1561
|
execFee,
|
|
1556
|
-
bridgeHubExecFee,
|
|
1557
1562
|
deliveryFee,
|
|
1558
1563
|
_args13 = arguments,
|
|
1559
1564
|
_t8;
|
|
@@ -1570,7 +1575,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1570
1575
|
while (1) switch (_context13.n) {
|
|
1571
1576
|
case 0:
|
|
1572
1577
|
_context13.n = 1;
|
|
1573
|
-
return _this3.
|
|
1578
|
+
return _this3.ahpApi.apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1574
1579
|
case 1:
|
|
1575
1580
|
weightRes = _context13.v;
|
|
1576
1581
|
if (weightRes.success) {
|
|
@@ -1592,8 +1597,8 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1592
1597
|
break;
|
|
1593
1598
|
}
|
|
1594
1599
|
_t8 = {
|
|
1595
|
-
proof_size: overridenWeight
|
|
1596
|
-
ref_time: overridenWeight
|
|
1600
|
+
proof_size: overridenWeight.proofSize,
|
|
1601
|
+
ref_time: overridenWeight.refTime
|
|
1597
1602
|
};
|
|
1598
1603
|
_context14.n = 3;
|
|
1599
1604
|
break;
|
|
@@ -1609,21 +1614,18 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1609
1614
|
versionedAssetId = addXcmVersionHeader(assetId, version);
|
|
1610
1615
|
transformedAssetLoc = _transform(versionedAssetId);
|
|
1611
1616
|
_context14.n = 4;
|
|
1612
|
-
return this.
|
|
1617
|
+
return this.ahpApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weight, transformedAssetLoc);
|
|
1613
1618
|
case 4:
|
|
1614
1619
|
execFeeRes = _context14.v;
|
|
1615
|
-
execFee =
|
|
1616
|
-
if (!(chain.startsWith('BridgeHub') &&
|
|
1620
|
+
execFee = execFeeRes.success ? execFeeRes.value : 0n;
|
|
1621
|
+
if (!(chain.startsWith('BridgeHub') && execFeeRes.success === false && execFeeRes.value.type === 'AssetNotFound')) {
|
|
1617
1622
|
_context14.n = 6;
|
|
1618
1623
|
break;
|
|
1619
1624
|
}
|
|
1620
1625
|
_context14.n = 5;
|
|
1621
1626
|
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
1622
1627
|
case 5:
|
|
1623
|
-
|
|
1624
|
-
if (typeof bridgeHubExecFee === 'bigint') {
|
|
1625
|
-
execFee = bridgeHubExecFee;
|
|
1626
|
-
}
|
|
1628
|
+
execFee = _context14.v;
|
|
1627
1629
|
case 6:
|
|
1628
1630
|
_context14.n = 7;
|
|
1629
1631
|
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
@@ -1647,17 +1649,17 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1647
1649
|
while (1) switch (_context15.n) {
|
|
1648
1650
|
case 0:
|
|
1649
1651
|
_context15.n = 1;
|
|
1650
|
-
return this.
|
|
1652
|
+
return this.ahpApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
|
|
1651
1653
|
type: version,
|
|
1652
1654
|
value: _transform(RELAY_LOCATION)
|
|
1653
1655
|
});
|
|
1654
1656
|
case 1:
|
|
1655
1657
|
fallbackExecFeeRes = _context15.v;
|
|
1656
|
-
if (
|
|
1658
|
+
if (fallbackExecFeeRes.success) {
|
|
1657
1659
|
_context15.n = 2;
|
|
1658
1660
|
break;
|
|
1659
1661
|
}
|
|
1660
|
-
return _context15.a(2,
|
|
1662
|
+
return _context15.a(2, 0n);
|
|
1661
1663
|
case 2:
|
|
1662
1664
|
ahApi = this.clone();
|
|
1663
1665
|
assetHubChain = "AssetHub".concat(this.getRelayChainOf(chain));
|
|
@@ -1666,20 +1668,10 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1666
1668
|
case 3:
|
|
1667
1669
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1668
1670
|
_context15.n = 4;
|
|
1669
|
-
return ahApi.
|
|
1670
|
-
module: 'AssetConversionApi',
|
|
1671
|
-
method: 'quote_price_exact_tokens_for_tokens',
|
|
1672
|
-
params: [RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false]
|
|
1673
|
-
});
|
|
1671
|
+
return ahApi.ahpApi.apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(_transform(RELAY_LOCATION), _transform(ahLocalizedLoc), fallbackExecFeeRes.value, false);
|
|
1674
1672
|
case 4:
|
|
1675
1673
|
convertedExecFee = _context15.v;
|
|
1676
|
-
|
|
1677
|
-
_context15.n = 5;
|
|
1678
|
-
break;
|
|
1679
|
-
}
|
|
1680
|
-
return _context15.a(2, convertedExecFee);
|
|
1681
|
-
case 5:
|
|
1682
|
-
return _context15.a(2, undefined);
|
|
1674
|
+
return _context15.a(2, convertedExecFee !== null && convertedExecFee !== void 0 ? convertedExecFee : 0n);
|
|
1683
1675
|
}
|
|
1684
1676
|
}, _callee15, this);
|
|
1685
1677
|
}));
|
|
@@ -1693,7 +1685,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1693
1685
|
value: function () {
|
|
1694
1686
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref12) {
|
|
1695
1687
|
var _ref13, _processAssetsDeposit, _ref14, _ref15, _ref16, _ref17, _ref18;
|
|
1696
|
-
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, transformedOriginLocation, result, isSuccess,
|
|
1688
|
+
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, transformedOriginLocation, result, isSuccess, failure, execResult, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, feeEventValue, fee, processedFee;
|
|
1697
1689
|
return _regenerator().w(function (_context16) {
|
|
1698
1690
|
while (1) switch (_context16.n) {
|
|
1699
1691
|
case 0:
|
|
@@ -1706,7 +1698,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1706
1698
|
case 1:
|
|
1707
1699
|
transformedOriginLocation = _transform(originLocation);
|
|
1708
1700
|
_context16.n = 2;
|
|
1709
|
-
return this.
|
|
1701
|
+
return this.ahpApi.apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1710
1702
|
case 2:
|
|
1711
1703
|
result = _context16.v;
|
|
1712
1704
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
@@ -1714,12 +1706,10 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1714
1706
|
_context16.n = 3;
|
|
1715
1707
|
break;
|
|
1716
1708
|
}
|
|
1717
|
-
|
|
1709
|
+
failure = extractDryRunXcmFailureReason(result);
|
|
1718
1710
|
return _context16.a(2, {
|
|
1719
1711
|
success: false,
|
|
1720
|
-
|
|
1721
|
-
failureIndex: failureIndex,
|
|
1722
|
-
failureInstruction: getFailingInstruction(xcm, failureIndex),
|
|
1712
|
+
dryRunError: buildDryRunError(failure, xcm),
|
|
1723
1713
|
asset: asset
|
|
1724
1714
|
});
|
|
1725
1715
|
case 3:
|
|
@@ -1738,10 +1728,6 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1738
1728
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1739
1729
|
case 4:
|
|
1740
1730
|
_fee = _context16.v;
|
|
1741
|
-
if (!(typeof _fee === 'bigint')) {
|
|
1742
|
-
_context16.n = 5;
|
|
1743
|
-
break;
|
|
1744
|
-
}
|
|
1745
1731
|
return _context16.a(2, {
|
|
1746
1732
|
success: true,
|
|
1747
1733
|
fee: _fee,
|
|
@@ -1790,7 +1776,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1790
1776
|
}
|
|
1791
1777
|
return _context16.a(2, Promise.resolve({
|
|
1792
1778
|
success: false,
|
|
1793
|
-
|
|
1779
|
+
dryRunError: {
|
|
1780
|
+
reason: 'Cannot determine destination fee. No fee event found'
|
|
1781
|
+
},
|
|
1794
1782
|
asset: asset
|
|
1795
1783
|
}));
|
|
1796
1784
|
case 6:
|
|
@@ -1820,15 +1808,16 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1820
1808
|
key: "getBridgeStatus",
|
|
1821
1809
|
value: function () {
|
|
1822
1810
|
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
1823
|
-
var
|
|
1811
|
+
var _yield$this$bridgeHub, type;
|
|
1824
1812
|
return _regenerator().w(function (_context17) {
|
|
1825
1813
|
while (1) switch (_context17.n) {
|
|
1826
1814
|
case 0:
|
|
1827
1815
|
_context17.n = 1;
|
|
1828
|
-
return this.
|
|
1816
|
+
return this.bridgeHubApi.query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1829
1817
|
case 1:
|
|
1830
|
-
|
|
1831
|
-
|
|
1818
|
+
_yield$this$bridgeHub = _context17.v;
|
|
1819
|
+
type = _yield$this$bridgeHub.type;
|
|
1820
|
+
return _context17.a(2, type);
|
|
1832
1821
|
}
|
|
1833
1822
|
}, _callee17, this);
|
|
1834
1823
|
}));
|
|
@@ -2027,11 +2016,8 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
2027
2016
|
Foreign: Foreign,
|
|
2028
2017
|
ForeignAbstract: ForeignAbstract,
|
|
2029
2018
|
Native: Native,
|
|
2030
|
-
Override: Override,
|
|
2031
2019
|
findAssetInfo: findAssetInfo,
|
|
2032
2020
|
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
2033
|
-
getAssetDecimals: getAssetDecimals,
|
|
2034
|
-
getAssetId: getAssetId,
|
|
2035
2021
|
getAssets: getAssets,
|
|
2036
2022
|
getAssetsObject: getAssetsObject,
|
|
2037
2023
|
getBalance: getBalance,
|
|
@@ -2042,7 +2028,6 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
2042
2028
|
getRelayChainSymbol: getRelayChainSymbol,
|
|
2043
2029
|
getSupportedAssets: getSupportedAssets,
|
|
2044
2030
|
getTChain: getTChain,
|
|
2045
|
-
hasSupportForAsset: hasSupportForAsset,
|
|
2046
2031
|
isChainEvm: isChainEvm
|
|
2047
2032
|
});
|
|
2048
2033
|
|
|
@@ -2051,133 +2036,6 @@ var convertSs58 = function convertSs58(address, chain) {
|
|
|
2051
2036
|
return convertSs58$1(papiApi, address, chain);
|
|
2052
2037
|
};
|
|
2053
2038
|
|
|
2054
|
-
/**
|
|
2055
|
-
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
2056
|
-
*
|
|
2057
|
-
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
2058
|
-
*/
|
|
2059
|
-
var EvmBuilderCore = /*#__PURE__*/function () {
|
|
2060
|
-
function EvmBuilderCore(options) {
|
|
2061
|
-
_classCallCheck(this, EvmBuilderCore);
|
|
2062
|
-
this._options = options;
|
|
2063
|
-
}
|
|
2064
|
-
return _createClass(EvmBuilderCore, [{
|
|
2065
|
-
key: "from",
|
|
2066
|
-
value: function from(chain) {
|
|
2067
|
-
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
2068
|
-
from: chain
|
|
2069
|
-
}));
|
|
2070
|
-
}
|
|
2071
|
-
/**
|
|
2072
|
-
* Specifies the destination chain on Polkadot.
|
|
2073
|
-
*
|
|
2074
|
-
* @param chain - The Polkadot chain to which the transfer will be made.
|
|
2075
|
-
* @returns An instance of EvmBuilder
|
|
2076
|
-
*/
|
|
2077
|
-
}, {
|
|
2078
|
-
key: "to",
|
|
2079
|
-
value: function to(chain) {
|
|
2080
|
-
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
2081
|
-
to: chain
|
|
2082
|
-
}));
|
|
2083
|
-
}
|
|
2084
|
-
/**
|
|
2085
|
-
* Specifies the currency to transfer.
|
|
2086
|
-
*
|
|
2087
|
-
* @param currency - The currency to be transferred.
|
|
2088
|
-
* @returns An instance of EvmBuilder
|
|
2089
|
-
*/
|
|
2090
|
-
}, {
|
|
2091
|
-
key: "currency",
|
|
2092
|
-
value: function currency(_currency) {
|
|
2093
|
-
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
2094
|
-
currency: _currency
|
|
2095
|
-
}));
|
|
2096
|
-
}
|
|
2097
|
-
/**
|
|
2098
|
-
* Specifies the recipient address on Polkadot.
|
|
2099
|
-
*
|
|
2100
|
-
* @param address - The Polkadot address to receive the transfer.
|
|
2101
|
-
* @returns An instance of EvmBuilder
|
|
2102
|
-
*/
|
|
2103
|
-
}, {
|
|
2104
|
-
key: "recipient",
|
|
2105
|
-
value: function recipient(address) {
|
|
2106
|
-
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
2107
|
-
recipient: address
|
|
2108
|
-
}));
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Sets the asset hub address. This is used for transfers that go through the Asset Hub.
|
|
2112
|
-
*
|
|
2113
|
-
* @param address - The address to be used.
|
|
2114
|
-
* @returns An instance of EvmBuilder
|
|
2115
|
-
*/
|
|
2116
|
-
}, {
|
|
2117
|
-
key: "ahAddress",
|
|
2118
|
-
value: function ahAddress(address) {
|
|
2119
|
-
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
2120
|
-
ahAddress: address
|
|
2121
|
-
}));
|
|
2122
|
-
}
|
|
2123
|
-
/**
|
|
2124
|
-
* Specifies the signer for the Ethereum transaction.
|
|
2125
|
-
*
|
|
2126
|
-
* @param signer - The Ethereum signer to authorize the transfer.
|
|
2127
|
-
* @returns An instance of EvmBuilder
|
|
2128
|
-
*/
|
|
2129
|
-
}, {
|
|
2130
|
-
key: "signer",
|
|
2131
|
-
value: function signer(_signer) {
|
|
2132
|
-
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
2133
|
-
signer: _signer
|
|
2134
|
-
}));
|
|
2135
|
-
}
|
|
2136
|
-
/**
|
|
2137
|
-
* Builds and executes the transfer from Ethereum to Polkadot.
|
|
2138
|
-
*
|
|
2139
|
-
* @throws Error if any required parameters are missing.
|
|
2140
|
-
*/
|
|
2141
|
-
}, {
|
|
2142
|
-
key: "build",
|
|
2143
|
-
value: (function () {
|
|
2144
|
-
var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
2145
|
-
var _this$_options, from, to, recipient, api;
|
|
2146
|
-
return _regenerator().w(function (_context) {
|
|
2147
|
-
while (1) switch (_context.n) {
|
|
2148
|
-
case 0:
|
|
2149
|
-
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, recipient = _this$_options.recipient, api = _this$_options.api;
|
|
2150
|
-
validateAddress(api, recipient, to);
|
|
2151
|
-
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
2152
|
-
_context.n = 1;
|
|
2153
|
-
break;
|
|
2154
|
-
}
|
|
2155
|
-
return _context.a(2, transferMoonbeamToEth(from, this._options));
|
|
2156
|
-
case 1:
|
|
2157
|
-
return _context.a(2, transferMoonbeamEvm(this._options));
|
|
2158
|
-
}
|
|
2159
|
-
}, _callee, this);
|
|
2160
|
-
}));
|
|
2161
|
-
function build() {
|
|
2162
|
-
return _build.apply(this, arguments);
|
|
2163
|
-
}
|
|
2164
|
-
return build;
|
|
2165
|
-
}())
|
|
2166
|
-
}]);
|
|
2167
|
-
}();
|
|
2168
|
-
/**
|
|
2169
|
-
* Creates a new EvmBuilder instance for constructing Ethereum to Polkadot transfers.
|
|
2170
|
-
*
|
|
2171
|
-
* @param provider - The Ethereum provider to use for the transfer.
|
|
2172
|
-
* @returns An instance of EvmBuilder class
|
|
2173
|
-
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
2174
|
-
*/
|
|
2175
|
-
var EvmBuilder$1 = function EvmBuilder(api) {
|
|
2176
|
-
return new EvmBuilderCore({
|
|
2177
|
-
api: api
|
|
2178
|
-
});
|
|
2179
|
-
};
|
|
2180
|
-
|
|
2181
2039
|
/**
|
|
2182
2040
|
* Creates a new Builder instance.
|
|
2183
2041
|
*
|
|
@@ -2188,11 +2046,6 @@ var Builder = function Builder(options) {
|
|
|
2188
2046
|
var papiApi = new PapiApi(options);
|
|
2189
2047
|
return Builder$1(papiApi);
|
|
2190
2048
|
};
|
|
2191
|
-
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
2192
|
-
var EvmBuilder = function EvmBuilder(api) {
|
|
2193
|
-
var papiApi = new PapiApi(api);
|
|
2194
|
-
return EvmBuilder$1(papiApi);
|
|
2195
|
-
};
|
|
2196
2049
|
|
|
2197
2050
|
var hydrateCustomChain = /*#__PURE__*/function () {
|
|
2198
2051
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(name, input) {
|
|
@@ -2305,4 +2158,4 @@ var transfer = /*#__PURE__*/Object.freeze({
|
|
|
2305
2158
|
handleSwapExecuteTransfer: handleSwapExecuteTransfer
|
|
2306
2159
|
});
|
|
2307
2160
|
|
|
2308
|
-
export { Builder,
|
|
2161
|
+
export { Builder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, hydrateCustomChain, _transform as transform, transfer as xcmPallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
"@polkadot-labs/hdkd": "^0.0.28",
|
|
28
28
|
"@polkadot-labs/hdkd-helpers": "^0.0.30",
|
|
29
29
|
"viem": "^2.53.1",
|
|
30
|
-
"@paraspell/sdk-core": "
|
|
30
|
+
"@paraspell/sdk-core": "14.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"polkadot-api": "2
|
|
33
|
+
"polkadot-api": ">= 2 < 3",
|
|
34
|
+
"@paraspell/descriptors": "14.0.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@acala-network/chopsticks": "^1.5.0",
|