@paraspell/sdk-pjs 13.10.1 → 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 CHANGED
@@ -125,10 +125,7 @@ import * as paraspell from '@paraspell/sdk-pjs'
125
125
 
126
126
  > [!NOTE]
127
127
  > **Latest news:**
128
- > - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
129
- > - Swap extension is now available on every XCM SDK version: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-swap-extension
130
- > - EVM extension is now available: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-evm-extension
131
- > - Snowbridge extension is now available: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-snowbridge-extension
128
+ > - V13 > V14 Migration guide: https://paraspell.github.io/docs/migration/v13-to-v14.html
132
129
 
133
130
 
134
131
  ### Sending XCM
@@ -341,7 +338,7 @@ SDK features ability to add custom chain and/or custom assets simply by adding i
341
338
  {
342
339
  symbol: 'USDC',
343
340
  decimals: 6,
344
- existentialDeposit: 0.1,
341
+ existentialDeposit: 100000000, //Needs to be in plancks
345
342
  location: {
346
343
  parents: 1,
347
344
  interior: { X3: [{ Parachain: 1000 }, { PalletInstance: 50 }, {
@@ -360,7 +357,7 @@ SDK features ability to add custom chain and/or custom assets simply by adding i
360
357
  symbol: 'MYNEWUSD',
361
358
  decimals: 6,
362
359
  assetId: '9999',
363
- existentialDeposit: 0.1,
360
+ existentialDeposit: 100000000, //Needs to be in plancks
364
361
  location: {
365
362
  parents: 0,
366
363
  interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 9999 }] }
@@ -371,7 +368,7 @@ SDK features ability to add custom chain and/or custom assets simply by adding i
371
368
  symbol: 'USDT',
372
369
  decimals: 6,
373
370
  assetId: '1984',
374
- existentialDeposit: 0.1,
371
+ existentialDeposit: 100000000, //Needs to be in plancks
375
372
  location: {
376
373
  parents: 0,
377
374
  interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] }
@@ -729,7 +726,7 @@ We run an open Bug Bounty Program that rewards contributors for reporting and fi
729
726
 
730
727
  Made with 💛 by [ParaSpell✨](https://paraspell.xyz/)
731
728
 
732
- Published under [MIT License](https://github.com/paraspell/xcm-tools/blob/main/packages/sdk/LICENSE).
729
+ Published under [MIT License](https://github.com/paraspell/xcm-tools/blob/main/packages/sdk-pjs/LICENSE).
733
730
 
734
731
  ## Supported by
735
732
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  import * as _paraspell_sdk_core from '@paraspell/sdk-core';
2
- import { WithApi, TChain, TCurrencyInputWithAmount, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TCustomChainFrom, TTransferBaseOptions } from '@paraspell/sdk-core';
2
+ import { Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TCustomChainFrom, TTransferBaseOptions } from '@paraspell/sdk-core';
3
3
  export * from '@paraspell/sdk-core';
4
4
  import * as _polkadot_api from '@polkadot/api';
5
5
  import { ApiPromise } from '@polkadot/api';
6
6
  import { SubmittableExtrinsic, Signer } from '@polkadot/api/types';
7
- import * as ethers from 'ethers';
8
- import { Signer as Signer$1, AbstractProvider } from 'ethers';
9
- import { WalletClient } from 'viem';
10
- import * as _snowbridge_api_dist_transfers_toPolkadot_transferInterface from '@snowbridge/api/dist/transfers/toPolkadot/transferInterface';
11
7
 
12
8
  type TPjsApi = ApiPromise;
13
9
  type Extrinsic = SubmittableExtrinsic<'promise'>;
@@ -15,36 +11,6 @@ type TPjsSigner = {
15
11
  signer: Signer;
16
12
  address: string;
17
13
  };
18
- type TEvmChainFrom = Extract<TChain, 'Ethereum' | 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
19
- type TEvmBuilderOptionsBase = {
20
- /**
21
- * The source chain. Can be either 'Ethereum', 'Moonbeam', 'Moonriver', or 'Darwinia'.
22
- */
23
- from: TEvmChainFrom;
24
- /**
25
- * The destination chain.
26
- */
27
- to: TChain;
28
- /**
29
- * The currency to transfer. Symbol or ID.
30
- */
31
- currency: TCurrencyInputWithAmount;
32
- /**
33
- * The Polkadot destination address.
34
- */
35
- recipient: string;
36
- /**
37
- * The AssetHub address
38
- */
39
- ahAddress?: string;
40
- /**
41
- * The Ethereum signer.
42
- */
43
- signer: Signer$1 | WalletClient;
44
- };
45
- type TPjsEvmBuilderOptions<TApi, TRes, TSigner> = WithApi<TEvmBuilderOptionsBase, TApi, TRes, TSigner> & {
46
- provider?: AbstractProvider;
47
- };
48
14
 
49
15
  /**
50
16
  * Retrieves the asset balance for a given account on a specified chain.
@@ -60,11 +26,8 @@ declare const getBalance: (options: _paraspell_sdk_core.TGetBalanceCommonOptions
60
26
  declare const assets_Foreign: typeof Foreign;
61
27
  declare const assets_ForeignAbstract: typeof ForeignAbstract;
62
28
  declare const assets_Native: typeof Native;
63
- declare const assets_Override: typeof Override;
64
29
  declare const assets_findAssetInfo: typeof findAssetInfo;
65
30
  declare const assets_getAllAssetsSymbols: typeof getAllAssetsSymbols;
66
- declare const assets_getAssetDecimals: typeof getAssetDecimals;
67
- declare const assets_getAssetId: typeof getAssetId;
68
31
  declare const assets_getAssets: typeof getAssets;
69
32
  declare const assets_getAssetsObject: typeof getAssetsObject;
70
33
  declare const assets_getBalance: typeof getBalance;
@@ -75,18 +38,14 @@ declare const assets_getOtherAssets: typeof getOtherAssets;
75
38
  declare const assets_getRelayChainSymbol: typeof getRelayChainSymbol;
76
39
  declare const assets_getSupportedAssets: typeof getSupportedAssets;
77
40
  declare const assets_getTChain: typeof getTChain;
78
- declare const assets_hasSupportForAsset: typeof hasSupportForAsset;
79
41
  declare const assets_isChainEvm: typeof isChainEvm;
80
42
  declare namespace assets {
81
43
  export {
82
44
  assets_Foreign as Foreign,
83
45
  assets_ForeignAbstract as ForeignAbstract,
84
46
  assets_Native as Native,
85
- assets_Override as Override,
86
47
  assets_findAssetInfo as findAssetInfo,
87
48
  assets_getAllAssetsSymbols as getAllAssetsSymbols,
88
- assets_getAssetDecimals as getAssetDecimals,
89
- assets_getAssetId as getAssetId,
90
49
  assets_getAssets as getAssets,
91
50
  assets_getAssetsObject as getAssetsObject,
92
51
  assets_getBalance as getBalance,
@@ -97,77 +56,12 @@ declare namespace assets {
97
56
  assets_getRelayChainSymbol as getRelayChainSymbol,
98
57
  assets_getSupportedAssets as getSupportedAssets,
99
58
  assets_getTChain as getTChain,
100
- assets_hasSupportForAsset as hasSupportForAsset,
101
59
  assets_isChainEvm as isChainEvm,
102
60
  };
103
61
  }
104
62
 
105
63
  declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
106
64
 
107
- /**
108
- * Builder class for constructing transfers from Ethereum to Polkadot.
109
- *
110
- * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
111
- */
112
- declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuilderOptions<TApi, TRes, TSigner>> = object> {
113
- protected readonly _options: T;
114
- constructor(options: T);
115
- from(chain: TEvmChainFrom): EvmBuilderCore<TApi, TRes, TSigner, T & {
116
- from: TEvmChainFrom;
117
- }>;
118
- /**
119
- * Specifies the destination chain on Polkadot.
120
- *
121
- * @param chain - The Polkadot chain to which the transfer will be made.
122
- * @returns An instance of EvmBuilder
123
- */
124
- to(chain: TChain): EvmBuilderCore<TApi, TRes, TSigner, T & {
125
- to: TChain;
126
- }>;
127
- /**
128
- * Specifies the currency to transfer.
129
- *
130
- * @param currency - The currency to be transferred.
131
- * @returns An instance of EvmBuilder
132
- */
133
- currency(currency: TCurrencyInputWithAmount): EvmBuilderCore<TApi, TRes, TSigner, T & {
134
- currency: TCurrencyInputWithAmount;
135
- }>;
136
- /**
137
- * Specifies the recipient address on Polkadot.
138
- *
139
- * @param address - The Polkadot address to receive the transfer.
140
- * @returns An instance of EvmBuilder
141
- */
142
- recipient(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
143
- recipient: string;
144
- }>;
145
- /**
146
- * Sets the asset hub address. This is used for transfers that go through the Asset Hub.
147
- *
148
- * @param address - The address to be used.
149
- * @returns An instance of EvmBuilder
150
- */
151
- ahAddress(address: string | undefined): EvmBuilderCore<unknown, unknown, unknown, T & {
152
- ahAddress: string | undefined;
153
- }>;
154
- /**
155
- * Specifies the signer for the Ethereum transaction.
156
- *
157
- * @param signer - The Ethereum signer to authorize the transfer.
158
- * @returns An instance of EvmBuilder
159
- */
160
- signer(signer: Signer$1 | WalletClient): EvmBuilderCore<TApi, TRes, TSigner, T & {
161
- signer: Signer$1 | WalletClient;
162
- }>;
163
- /**
164
- * Builds and executes the transfer from Ethereum to Polkadot.
165
- *
166
- * @throws Error if any required parameters are missing.
167
- */
168
- build(this: EvmBuilderCore<TApi, TRes, TSigner, TPjsEvmBuilderOptions<TApi, TRes, TSigner>>): Promise<string>;
169
- }
170
-
171
65
  /**
172
66
  * Creates a new Builder instance.
173
67
  *
@@ -176,74 +70,33 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuild
176
70
  */
177
71
  declare const Builder: <const TOpts extends TBuilderOptions<TApiOrUrl<TPjsApi>>>(options?: TOpts) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object, TCustomChainFrom<TOpts>>;
178
72
  type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPjsApi, Extrinsic, TPjsSigner>> = object, TCustomChain extends string = never> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T, TCustomChain>;
179
- /** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
180
- declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
181
- api: _paraspell_sdk_core.PolkadotApi<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, never>;
182
- provider: AbstractProvider | undefined;
183
- }>;
184
-
185
- declare const approveToken: (signer: Signer$1, amount: bigint, symbol: string) => Promise<{
186
- result: ethers.ContractTransactionResponse;
187
- receipt: ethers.ContractTransactionReceipt | null;
188
- }>;
189
-
190
- declare const depositToken: (signer: Signer$1, amount: bigint, symbol: string) => Promise<{
191
- result: ethers.ContractTransactionResponse;
192
- receipt: ethers.ContractTransactionReceipt | null;
193
- }>;
194
-
195
- /**
196
- * Transfers an Ethereum asset to a Polkadot account.
197
- *
198
- * @param provider - The Ethereum provider instance to interact with the Ethereum network.
199
- * @param options - The options for the transfer.
200
- *
201
- * @returns A Promise that resolves to an object containing the result and the plan of the transfer.
202
- *
203
- * @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
204
- */
205
- declare const transferEthToPolkadot$1: <TApi, TRes, TSigner>({ api, provider, signer, recipient, to, currency }: TPjsEvmBuilderOptions<TApi, TRes, TSigner>) => Promise<{
206
- response: ethers.TransactionResponse;
207
- messageReceipt: _snowbridge_api_dist_transfers_toPolkadot_transferInterface.MessageReceipt;
208
- }>;
209
-
210
- declare const getTokenBalance: (signer: Signer$1, symbol: string) => Promise<bigint>;
211
73
 
212
74
  declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<Extrinsic, never> & {
213
75
  api?: TApiOrUrl<TPjsApi>;
214
- }) => Promise<_paraspell_sdk_core.TDryRunResult>;
76
+ }) => Promise<_paraspell_sdk_core.TDryRunResult<never>>;
215
77
  declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<Extrinsic, never> & {
216
78
  api?: TApiOrUrl<TPjsApi>;
217
79
  }) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
218
- declare const transferEthToPolkadot: (options: Omit<TPjsEvmBuilderOptions<TPjsApi, Extrinsic, TPjsSigner>, "api">) => ReturnType<typeof transferEthToPolkadot$1>;
219
80
  declare const getParaEthTransferFees: (api?: TApiOrUrl<TPjsApi>) => Promise<[bigint, bigint]>;
220
81
  /**
221
82
  * Gets the Ethereum bridge status.
222
83
  */
223
84
  declare const getBridgeStatus: (api?: TApiOrUrl<TPjsApi>) => Promise<_paraspell_sdk_core.TBridgeStatus>;
224
85
 
225
- declare const transfer_approveToken: typeof approveToken;
226
- declare const transfer_depositToken: typeof depositToken;
227
86
  declare const transfer_dryRun: typeof dryRun;
228
87
  declare const transfer_dryRunOrigin: typeof dryRunOrigin;
229
88
  declare const transfer_getBridgeStatus: typeof getBridgeStatus;
230
89
  declare const transfer_getParaEthTransferFees: typeof getParaEthTransferFees;
231
- declare const transfer_getTokenBalance: typeof getTokenBalance;
232
- declare const transfer_transferEthToPolkadot: typeof transferEthToPolkadot;
233
90
  declare namespace transfer {
234
91
  export {
235
- transfer_approveToken as approveToken,
236
- transfer_depositToken as depositToken,
237
92
  transfer_dryRun as dryRun,
238
93
  transfer_dryRunOrigin as dryRunOrigin,
239
94
  transfer_getBridgeStatus as getBridgeStatus,
240
95
  transfer_getParaEthTransferFees as getParaEthTransferFees,
241
- transfer_getTokenBalance as getTokenBalance,
242
- transfer_transferEthToPolkadot as transferEthToPolkadot,
243
96
  };
244
97
  }
245
98
 
246
99
  declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => Promise<_polkadot_api.ApiPromise>;
247
100
 
248
- export { Builder, EvmBuilder, approveToken, assets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, transferEthToPolkadot, transfer as xcmPallet };
249
- export type { Extrinsic, GeneralBuilder, TEvmChainFrom, TPjsApi, TPjsEvmBuilderOptions, TPjsSigner };
101
+ export { Builder, assets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
102
+ export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsSigner };
package/dist/index.mjs CHANGED
@@ -1,13 +1,9 @@
1
- import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrowImpl, isCustomChain, getChainProvidersImpl, isSenderSigner, PolkadotApi, findAssetInfoOrThrowImpl, hasXcmPaymentApiSupportImpl, resolveModuleError, hasDryRunSupportImpl, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetEqual, RELAY_LOCATION, getRelayChainOfImpl, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, findAssetInfoOrThrow, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, isCustomChain, isSenderSigner, PolkadotApi, buildDryRunError, resolveModuleError, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetEqual, RELAY_LOCATION, 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, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
4
4
  import { snakeToCamel, lowercaseFirstLetter } from '@paraspell/sdk-common';
5
5
  import { u8aConcat, compactToU8a, u8aEq, isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
6
6
  import { decodeAddress, blake2AsHex, validateAddress } from '@polkadot/util-crypto';
7
- import { WETH9__factory } from '@snowbridge/contract-types';
8
- import { bridgeInfoFor } from '@snowbridge/registry';
9
- import { toPolkadotV2, SnowbridgeApi } from '@snowbridge/api';
10
- import { EthersEthereumProvider } from '@snowbridge/provider-ethers';
11
7
 
12
8
  function _arrayLikeToArray(r, a) {
13
9
  (null == a || a > r.length) && (a = r.length);
@@ -300,7 +296,7 @@ function _toPrimitive(t, r) {
300
296
  if ("object" != typeof i) return i;
301
297
  throw new TypeError("@@toPrimitive must return a primitive value.");
302
298
  }
303
- return ("string" === r ? String : Number)(t);
299
+ return (String )(t);
304
300
  }
305
301
  function _toPropertyKey(t) {
306
302
  var i = _toPrimitive(t, "string");
@@ -781,7 +777,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
781
777
  value: function resolveDefaultFeeAsset(_ref5) {
782
778
  var chain = _ref5.chain,
783
779
  feeAsset = _ref5.feeAsset;
784
- return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrowImpl(chain, this._customCtx);
780
+ return feeAsset !== null && feeAsset !== void 0 ? feeAsset : this.findNativeAssetInfoOrThrow(chain);
785
781
  }
786
782
  }, {
787
783
  key: "resolveFeeAsset",
@@ -817,9 +813,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
817
813
  case 3:
818
814
  return _context8.a(2, {
819
815
  isCustomAsset: true,
820
- asset: findAssetInfoOrThrowImpl(chain, {
816
+ asset: this.findAssetInfoOrThrow(chain, {
821
817
  id: assetId
822
- }, undefined, this._customCtx)
818
+ })
823
819
  });
824
820
  }
825
821
  }, _callee8, this);
@@ -834,12 +830,12 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
834
830
  value: function () {
835
831
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
836
832
  var _this3 = this;
837
- var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
833
+ var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _resultJson, _msg, _resultJson2, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
838
834
  return _regenerator().w(function (_context0) {
839
835
  while (1) switch (_context0.p = _context0.n) {
840
836
  case 0:
841
837
  tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
842
- supportsDryRunApi = hasDryRunSupportImpl(chain, this._customCtx);
838
+ supportsDryRunApi = this.hasDryRunSupport(chain);
843
839
  if (supportsDryRunApi) {
844
840
  _context0.n = 1;
845
841
  break;
@@ -912,13 +908,13 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
912
908
  var otherErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok3 = resultHuman.Ok) === null || _resultHuman$Ok3 === void 0 || (_resultHuman$Ok3 = _resultHuman$Ok3.executionResult) === null || _resultHuman$Ok3 === void 0 || (_resultHuman$Ok3 = _resultHuman$Ok3.Err) === null || _resultHuman$Ok3 === void 0 || (_resultHuman$Ok3 = _resultHuman$Ok3.error) === null || _resultHuman$Ok3 === void 0 ? void 0 : _resultHuman$Ok3.Other;
913
909
  if (otherErrHuman) {
914
910
  return {
915
- failureReason: String(otherErrHuman)
911
+ reason: String(otherErrHuman)
916
912
  };
917
913
  }
918
914
  var secondErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok4 = resultHuman.Ok) === null || _resultHuman$Ok4 === void 0 || (_resultHuman$Ok4 = _resultHuman$Ok4.executionResult) === null || _resultHuman$Ok4 === void 0 || (_resultHuman$Ok4 = _resultHuman$Ok4.Err) === null || _resultHuman$Ok4 === void 0 ? void 0 : _resultHuman$Ok4.error;
919
915
  if (secondErrHuman) {
920
916
  return {
921
- failureReason: String(secondErrHuman)
917
+ reason: String(secondErrHuman)
922
918
  };
923
919
  }
924
920
  var execErrJson = resultJson === null || resultJson === void 0 || (_resultJson$ok = resultJson.ok) === null || _resultJson$ok === void 0 || (_resultJson$ok = _resultJson$ok.executionResult) === null || _resultJson$ok === void 0 || (_resultJson$ok = _resultJson$ok.err) === null || _resultJson$ok === void 0 ? void 0 : _resultJson$ok.error;
@@ -927,7 +923,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
927
923
  }
928
924
  if (execErrJson !== null && execErrJson !== void 0 && execErrJson.other) {
929
925
  return {
930
- failureReason: String(execErrJson.other)
926
+ reason: String(execErrJson.other)
931
927
  };
932
928
  }
933
929
  var erroredEvent = findFailingEventInResult(resultHuman);
@@ -939,17 +935,17 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
939
935
  }
940
936
  if (err) {
941
937
  return {
942
- failureReason: typeof err === 'string' ? err : JSON.stringify(err)
938
+ reason: typeof err === 'string' ? err : JSON.stringify(err)
943
939
  };
944
940
  }
945
941
  }
946
942
  return {
947
- failureReason: JSON.stringify((_ref7 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref7 !== void 0 ? _ref7 : 'Unknown error')
943
+ reason: JSON.stringify((_ref7 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref7 !== void 0 ? _ref7 : 'Unknown error')
948
944
  };
949
945
  }; // Attempt 1: WITHOUT version
950
946
  isSuccess = false;
951
947
  failureErr = {
952
- failureReason: ''
948
+ reason: ''
953
949
  };
954
950
  shouldRetryWithVersion = false;
955
951
  _context0.p = 6;
@@ -962,7 +958,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
962
958
  isSuccess = getExecutionSuccessFromResult(resultHuman);
963
959
  if (!isSuccess) {
964
960
  failureErr = extractFailureReasonFromResult(resultHuman, resultJson);
965
- if (failureErr.failureReason === 'VersionedConversionFailed') {
961
+ if (failureErr.reason === 'VersionedConversionFailed') {
966
962
  shouldRetryWithVersion = true;
967
963
  }
968
964
  }
@@ -982,7 +978,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
982
978
  case 9:
983
979
  return _context0.a(2, {
984
980
  success: false,
985
- failureReason: msg,
981
+ dryRunError: {
982
+ reason: msg
983
+ },
986
984
  asset: resolvedFeeAsset.asset
987
985
  });
988
986
  case 10:
@@ -1010,9 +1008,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1010
1008
  failureErr = failureErr || _msg;
1011
1009
  return _context0.a(2, {
1012
1010
  success: false,
1013
- failureReason: failureErr.failureReason,
1014
- failureSubReason: failureErr.failureSubReason,
1015
- failureIndex: failureErr.failureIndex,
1011
+ dryRunError: buildDryRunError(failureErr, (_resultJson = resultJson) === null || _resultJson === void 0 || (_resultJson = _resultJson.ok) === null || _resultJson === void 0 ? void 0 : _resultJson.local_xcm),
1016
1012
  asset: resolvedFeeAsset.asset
1017
1013
  });
1018
1014
  case 14:
@@ -1022,9 +1018,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1022
1018
  }
1023
1019
  return _context0.a(2, {
1024
1020
  success: false,
1025
- failureReason: failureErr.failureReason || 'Unknown error',
1026
- failureSubReason: failureErr.failureSubReason,
1027
- failureIndex: failureErr.failureIndex,
1021
+ dryRunError: buildDryRunError(_objectSpread2(_objectSpread2({}, failureErr), {}, {
1022
+ reason: failureErr.reason || 'Unknown error'
1023
+ }), (_resultJson2 = resultJson) === null || _resultJson2 === void 0 || (_resultJson2 = _resultJson2.ok) === null || _resultJson2 === void 0 ? void 0 : _resultJson2.local_xcm),
1028
1024
  asset: resolvedFeeAsset.asset
1029
1025
  });
1030
1026
  case 15:
@@ -1037,7 +1033,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1037
1033
  destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref8) {
1038
1034
  return i.here === null ? 0 : (_ref8 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref8 === void 0 ? void 0 : _ref8.parachain;
1039
1035
  }(Object.values(forwardedXcms[0])[0].interior);
1040
- if (!(hasXcmPaymentApiSupportImpl(chain, this._customCtx) && resultJson.ok.local_xcm && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
1036
+ if (!(this.hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
1041
1037
  _context0.n = 21;
1042
1038
  break;
1043
1039
  }
@@ -1112,7 +1108,6 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1112
1108
  execFeeOk,
1113
1109
  execFee,
1114
1110
  isAssetNotFound,
1115
- bridgeHubExecFee,
1116
1111
  deliveryFee,
1117
1112
  _args9 = arguments,
1118
1113
  _t5;
@@ -1151,10 +1146,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1151
1146
  _context1.n = 5;
1152
1147
  return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
1153
1148
  case 5:
1154
- bridgeHubExecFee = _context1.v;
1155
- if (typeof bridgeHubExecFee === 'bigint') {
1156
- execFee = bridgeHubExecFee;
1157
- }
1149
+ execFee = _context1.v;
1158
1150
  case 6:
1159
1151
  _context1.n = 7;
1160
1152
  return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
@@ -1173,8 +1165,8 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1173
1165
  key: "getDeliveryFee",
1174
1166
  value: function () {
1175
1167
  var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
1176
- var _deliveryFeeRes, _ref9, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref0, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
1177
- var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, assetId, versionedAssetLoc, deliveryFeeResJson, deliveryFeeResolved, nativeAsset, res, _t6;
1168
+ var _deliveryFeeRes, _versionedAssets$;
1169
+ var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, assetId, versionedAssetLoc, deliveryFeeResJson, versionedAssets, deliveryFeeResolved, nativeAsset, res, _t6;
1178
1170
  return _regenerator().w(function (_context10) {
1179
1171
  while (1) switch (_context10.p = _context10.n) {
1180
1172
  case 0:
@@ -1212,8 +1204,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1212
1204
  throw _t6;
1213
1205
  case 6:
1214
1206
  deliveryFeeResJson = (_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.toJSON();
1215
- deliveryFeeResolved = deliveryFeeRes && ((_ref9 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref9 === void 0 ? void 0 : _ref9.length) > 0 ? BigInt((_ref0 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref0 === void 0 || (_ref0 = _ref0[0]) === null || _ref0 === void 0 || (_ref0 = _ref0.fun) === null || _ref0 === void 0 ? void 0 : _ref0.fungible) : 0n;
1216
- nativeAsset = findNativeAssetInfoOrThrowImpl(chain, this._customCtx);
1207
+ versionedAssets = deliveryFeeResJson !== null && deliveryFeeResJson !== void 0 && deliveryFeeResJson.ok ? Object.values(deliveryFeeResJson.ok)[0] : undefined;
1208
+ deliveryFeeResolved = Array.isArray(versionedAssets) && versionedAssets.length > 0 ? BigInt((_versionedAssets$ = versionedAssets[0]) === null || _versionedAssets$ === void 0 || (_versionedAssets$ = _versionedAssets$.fun) === null || _versionedAssets$ === void 0 ? void 0 : _versionedAssets$.fungible) : 0n;
1209
+ nativeAsset = this.findNativeAssetInfoOrThrow(chain);
1217
1210
  if (!(isAssetEqual(asset, nativeAsset) || usedThirdParam)) {
1218
1211
  _context10.n = 7;
1219
1212
  break;
@@ -1261,10 +1254,10 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1261
1254
  _context11.n = 2;
1262
1255
  break;
1263
1256
  }
1264
- return _context11.a(2, undefined);
1257
+ return _context11.a(2, 0n);
1265
1258
  case 2:
1266
1259
  ahApi = this.clone();
1267
- assetHubChain = "AssetHub".concat(getRelayChainOfImpl(this, chain));
1260
+ assetHubChain = "AssetHub".concat(this.getRelayChainOf(chain));
1268
1261
  _context11.n = 3;
1269
1262
  return ahApi.init(assetHubChain);
1270
1263
  case 3:
@@ -1277,13 +1270,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1277
1270
  });
1278
1271
  case 4:
1279
1272
  convertedExecFee = _context11.v;
1280
- if (!(convertedExecFee != null)) {
1281
- _context11.n = 5;
1282
- break;
1283
- }
1284
- return _context11.a(2, BigInt(convertedExecFee));
1285
- case 5:
1286
- return _context11.a(2, undefined);
1273
+ return _context11.a(2, convertedExecFee != null ? BigInt(convertedExecFee) : 0n);
1287
1274
  }
1288
1275
  }, _callee11, this);
1289
1276
  }));
@@ -1317,14 +1304,14 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1317
1304
  }, {
1318
1305
  key: "getDryRunXcm",
1319
1306
  value: function () {
1320
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref1) {
1321
- var _ref11, _ref12, _ref13;
1322
- var originLocation, xcm, asset, chain, version, origin, supportsDryRunApi, response, result, resultJson, isSuccess, _result$Ok, _execRes$Incomplete$e, _execRes$Incomplete, _execRes$Error, execRes, error, isInstructionError, failureReason, failureIndex, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
1307
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref9) {
1308
+ var _ref1, _ref10, _ref11;
1309
+ var originLocation, xcm, asset, chain, version, origin, supportsDryRunApi, response, result, resultJson, isSuccess, _result$Ok, _execRes$Incomplete$e, _execRes$Incomplete, _execRes$Error, execRes, error, isInstructionError, reason, instructionIndex, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
1323
1310
  return _regenerator().w(function (_context13) {
1324
1311
  while (1) switch (_context13.n) {
1325
1312
  case 0:
1326
- originLocation = _ref1.originLocation, xcm = _ref1.xcm, asset = _ref1.asset, chain = _ref1.chain, version = _ref1.version, origin = _ref1.origin;
1327
- supportsDryRunApi = hasDryRunSupportImpl(chain, this._customCtx);
1313
+ originLocation = _ref9.originLocation, xcm = _ref9.xcm, asset = _ref9.asset, chain = _ref9.chain, version = _ref9.version, origin = _ref9.origin;
1314
+ supportsDryRunApi = this.hasDryRunSupport(chain);
1328
1315
  if (supportsDryRunApi) {
1329
1316
  _context13.n = 1;
1330
1317
  break;
@@ -1345,12 +1332,14 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1345
1332
  execRes = (_result$Ok = result.Ok) === null || _result$Ok === void 0 ? void 0 : _result$Ok.executionResult;
1346
1333
  error = (_execRes$Incomplete$e = execRes === null || execRes === void 0 || (_execRes$Incomplete = execRes.Incomplete) === null || _execRes$Incomplete === void 0 ? void 0 : _execRes$Incomplete.error) !== null && _execRes$Incomplete$e !== void 0 ? _execRes$Incomplete$e : execRes === null || execRes === void 0 || (_execRes$Error = execRes.Error) === null || _execRes$Error === void 0 ? void 0 : _execRes$Error.error;
1347
1334
  isInstructionError = typeof error !== 'string';
1348
- failureReason = isInstructionError ? error.error : error;
1349
- failureIndex = isInstructionError && (error === null || error === void 0 ? void 0 : error.index) != null ? Number(error.index) : undefined;
1335
+ reason = isInstructionError ? error.error : error;
1336
+ instructionIndex = isInstructionError && (error === null || error === void 0 ? void 0 : error.index) != null ? Number(error.index) : undefined;
1350
1337
  return _context13.a(2, {
1351
1338
  success: false,
1352
- failureReason: failureReason,
1353
- failureIndex: failureIndex,
1339
+ dryRunError: buildDryRunError({
1340
+ reason: reason,
1341
+ instructionIndex: instructionIndex
1342
+ }, xcm),
1354
1343
  asset: asset
1355
1344
  });
1356
1345
  case 3:
@@ -1360,10 +1349,10 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1360
1349
  refTime: BigInt(actualWeight.refTime),
1361
1350
  proofSize: BigInt(actualWeight.proofSize)
1362
1351
  } : undefined;
1363
- destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref10) {
1364
- return i.Here ? 0 : (_ref10 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref10 === void 0 ? void 0 : _ref10.parachain;
1352
+ destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref0) {
1353
+ return i.Here ? 0 : (_ref0 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref0 === void 0 ? void 0 : _ref0.parachain;
1365
1354
  }(Object.values(forwardedXcms[0])[0].interior);
1366
- if (!(hasXcmPaymentApiSupportImpl(chain, this._customCtx) && asset)) {
1355
+ if (!(this.hasXcmPaymentApiSupport(chain) && asset)) {
1367
1356
  _context13.n = 5;
1368
1357
  break;
1369
1358
  }
@@ -1387,17 +1376,17 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1387
1376
  emitted = result.Ok.emittedEvents; // We want to look for the last event
1388
1377
  reversedEvents = _toConsumableArray(emitted).reverse();
1389
1378
  palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
1390
- feeEvent = (_ref11 = (_ref12 = (_ref13 = origin === 'Mythos' ? reversedEvents.find(function (event) {
1379
+ feeEvent = (_ref1 = (_ref10 = (_ref11 = origin === 'Mythos' ? reversedEvents.find(function (event) {
1391
1380
  return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
1392
- }) : undefined) !== null && _ref13 !== void 0 ? _ref13 :
1381
+ }) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
1393
1382
  // Prefer an Issued event
1394
1383
  reversedEvents.find(function (event) {
1395
1384
  return palletsWithIssued.includes(event.section) && event.method === 'Issued';
1396
- })) !== null && _ref12 !== void 0 ? _ref12 :
1385
+ })) !== null && _ref10 !== void 0 ? _ref10 :
1397
1386
  // Fallback to Minted event
1398
1387
  reversedEvents.find(function (event) {
1399
1388
  return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
1400
- })) !== null && _ref11 !== void 0 ? _ref11 : reversedEvents.find(function (event) {
1389
+ })) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
1401
1390
  return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
1402
1391
  });
1403
1392
  if (feeEvent) {
@@ -1406,7 +1395,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1406
1395
  }
1407
1396
  return _context13.a(2, Promise.resolve({
1408
1397
  success: false,
1409
- failureReason: 'Cannot determine destination fee. No Issued event found',
1398
+ dryRunError: {
1399
+ reason: 'Cannot determine destination fee. No Issued event found'
1400
+ },
1410
1401
  asset: asset
1411
1402
  }));
1412
1403
  case 6:
@@ -1500,7 +1491,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1500
1491
  if (force) {
1501
1492
  void this.api.disconnect();
1502
1493
  } else {
1503
- var key = api === undefined ? getChainProvidersImpl(chain, this._customCtx) : api;
1494
+ var key = api === undefined ? this.getChainProviders(chain) : api;
1504
1495
  releaseClient(key);
1505
1496
  }
1506
1497
  }
@@ -1584,10 +1575,10 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1584
1575
  return tx.signAsync(createKeyringPair(sender));
1585
1576
  case 3:
1586
1577
  return _context17.a(2, new Promise(function (resolve, reject) {
1587
- tx.send(function (_ref14) {
1588
- var status = _ref14.status,
1589
- dispatchError = _ref14.dispatchError,
1590
- txHash = _ref14.txHash;
1578
+ tx.send(function (_ref12) {
1579
+ var status = _ref12.status,
1580
+ dispatchError = _ref12.dispatchError,
1581
+ txHash = _ref12.txHash;
1591
1582
  if (status.isFinalized) {
1592
1583
  if (dispatchError !== undefined) {
1593
1584
  if (dispatchError.isModule) {
@@ -1642,9 +1633,6 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
1642
1633
  };
1643
1634
  }();
1644
1635
  };
1645
- var isEthersSigner = function isEthersSigner(signer) {
1646
- return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
1647
- };
1648
1636
 
1649
1637
  /**
1650
1638
  * Retrieves the asset balance for a given account on a specified chain.
@@ -1658,11 +1646,8 @@ var assets = /*#__PURE__*/Object.freeze({
1658
1646
  Foreign: Foreign,
1659
1647
  ForeignAbstract: ForeignAbstract,
1660
1648
  Native: Native,
1661
- Override: Override,
1662
1649
  findAssetInfo: findAssetInfo,
1663
1650
  getAllAssetsSymbols: getAllAssetsSymbols,
1664
- getAssetDecimals: getAssetDecimals,
1665
- getAssetId: getAssetId,
1666
1651
  getAssets: getAssets,
1667
1652
  getAssetsObject: getAssetsObject,
1668
1653
  getBalance: getBalance,
@@ -1673,7 +1658,6 @@ var assets = /*#__PURE__*/Object.freeze({
1673
1658
  getRelayChainSymbol: getRelayChainSymbol,
1674
1659
  getSupportedAssets: getSupportedAssets,
1675
1660
  getTChain: getTChain,
1676
- hasSupportForAsset: hasSupportForAsset,
1677
1661
  isChainEvm: isChainEvm
1678
1662
  });
1679
1663
 
@@ -1682,398 +1666,6 @@ var convertSs58 = function convertSs58(address, chain) {
1682
1666
  return convertSs58$1(papiApi, address, chain);
1683
1667
  };
1684
1668
 
1685
- var approveToken = /*#__PURE__*/function () {
1686
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
1687
- var _bridgeInfoFor, gatewayContract, asset, weth9, result, receipt;
1688
- return _regenerator().w(function (_context) {
1689
- while (1) switch (_context.n) {
1690
- case 0:
1691
- _bridgeInfoFor = bridgeInfoFor('polkadot_mainnet'), gatewayContract = _bridgeInfoFor.environment.gatewayContract;
1692
- asset = findAssetInfoOrThrow('Ethereum', {
1693
- symbol: symbol
1694
- });
1695
- assertHasId(asset);
1696
- weth9 = WETH9__factory.connect(asset.assetId, signer);
1697
- _context.n = 1;
1698
- return weth9.approve(gatewayContract, amount);
1699
- case 1:
1700
- result = _context.v;
1701
- _context.n = 2;
1702
- return result.wait();
1703
- case 2:
1704
- receipt = _context.v;
1705
- return _context.a(2, {
1706
- result: result,
1707
- receipt: receipt
1708
- });
1709
- }
1710
- }, _callee);
1711
- }));
1712
- return function approveToken(_x, _x2, _x3) {
1713
- return _ref.apply(this, arguments);
1714
- };
1715
- }();
1716
-
1717
- var depositToken = /*#__PURE__*/function () {
1718
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
1719
- var asset, weth9, result, receipt;
1720
- return _regenerator().w(function (_context) {
1721
- while (1) switch (_context.n) {
1722
- case 0:
1723
- asset = findAssetInfoOrThrow('Ethereum', {
1724
- symbol: symbol
1725
- });
1726
- assertHasId(asset);
1727
- weth9 = WETH9__factory.connect(asset.assetId, signer);
1728
- _context.n = 1;
1729
- return weth9.deposit({
1730
- value: amount
1731
- });
1732
- case 1:
1733
- result = _context.v;
1734
- _context.n = 2;
1735
- return result.wait();
1736
- case 2:
1737
- receipt = _context.v;
1738
- return _context.a(2, {
1739
- result: result,
1740
- receipt: receipt
1741
- });
1742
- }
1743
- }, _callee);
1744
- }));
1745
- return function depositToken(_x, _x2, _x3) {
1746
- return _ref.apply(this, arguments);
1747
- };
1748
- }();
1749
-
1750
- var createEnvironment = function createEnvironment(env, executionUrl) {
1751
- return _objectSpread2(_objectSpread2({}, env), {}, {
1752
- assetOverrides: {
1753
- '3369': [{
1754
- token: '0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003',
1755
- name: 'Mythos',
1756
- minimumBalance: 10000000000000000n,
1757
- symbol: 'MYTH',
1758
- decimals: 18,
1759
- isSufficient: true
1760
- }]
1761
- },
1762
- precompiles: {
1763
- '2004': '0x000000000000000000000000000000000000081A'
1764
- },
1765
- ethereumChains: _objectSpread2(_objectSpread2(_objectSpread2({}, env.ethereumChains), executionUrl !== undefined ? _defineProperty({}, env.ethChainId.toString(), executionUrl) : {}), {}, _defineProperty({}, getParaId('Moonbeam'), 'https://rpc.api.moonbeam.network'))
1766
- });
1767
- };
1768
-
1769
- /**
1770
- * Transfers an Ethereum asset to a Polkadot account.
1771
- *
1772
- * @param provider - The Ethereum provider instance to interact with the Ethereum network.
1773
- * @param options - The options for the transfer.
1774
- *
1775
- * @returns A Promise that resolves to an object containing the result and the plan of the transfer.
1776
- *
1777
- * @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
1778
- */
1779
- var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1780
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
1781
- var api, provider, signer, recipient, to, currency, ethAsset, amount, info, environment, snowbridgeApi, destParaId, sender, sourceAddress, fee, transfer, validated, response, receipt, messageReceipt;
1782
- return _regenerator().w(function (_context) {
1783
- while (1) switch (_context.n) {
1784
- case 0:
1785
- api = _ref.api, provider = _ref.provider, signer = _ref.signer, recipient = _ref.recipient, to = _ref.to, currency = _ref.currency;
1786
- if (!Array.isArray(currency)) {
1787
- _context.n = 1;
1788
- break;
1789
- }
1790
- throw new UnsupportedOperationError('Multi-assets are not yet supported for EVM transfers');
1791
- case 1:
1792
- if (!('location' in currency && isOverrideLocationSpecifier(currency.location))) {
1793
- _context.n = 2;
1794
- break;
1795
- }
1796
- throw new UnsupportedOperationError('Override location is not supported for EVM transfers');
1797
- case 2:
1798
- if (provider) {
1799
- _context.n = 3;
1800
- break;
1801
- }
1802
- throw new MissingParameterError('provider', 'provider parameter is required for Snowbridge transfers.');
1803
- case 3:
1804
- if (isEthersSigner(signer)) {
1805
- _context.n = 4;
1806
- break;
1807
- }
1808
- throw new UnsupportedOperationError('Snowbridge does not support Viem provider yet.');
1809
- case 4:
1810
- ethAsset = findAssetInfoOrThrow('Ethereum', currency, to);
1811
- amount = abstractDecimals(currency.amount, ethAsset.decimals, api);
1812
- info = bridgeInfoFor('polkadot_mainnet');
1813
- environment = createEnvironment(info.environment, typeof provider === 'string' ? provider : undefined);
1814
- snowbridgeApi = new SnowbridgeApi({
1815
- info: _objectSpread2(_objectSpread2({}, info), {}, {
1816
- environment: environment
1817
- }),
1818
- ethereumProvider: new EthersEthereumProvider()
1819
- });
1820
- if (typeof provider !== 'string') {
1821
- snowbridgeApi.context.setEthProvider(environment.ethChainId, provider);
1822
- }
1823
- destParaId = getParaId(to);
1824
- assertHasId(ethAsset);
1825
- sender = snowbridgeApi.sender({
1826
- kind: 'ethereum',
1827
- id: environment.ethChainId
1828
- }, {
1829
- kind: 'polkadot',
1830
- id: destParaId
1831
- });
1832
- _context.n = 5;
1833
- return signer.getAddress();
1834
- case 5:
1835
- sourceAddress = _context.v;
1836
- _context.n = 6;
1837
- return sender.fee(ethAsset.assetId);
1838
- case 6:
1839
- fee = _context.v;
1840
- _context.n = 7;
1841
- return sender.tx(sourceAddress, recipient, ethAsset.assetId, amount, fee);
1842
- case 7:
1843
- transfer = _context.v;
1844
- _context.n = 8;
1845
- return sender.validate(transfer);
1846
- case 8:
1847
- validated = _context.v;
1848
- if (!validated.logs.find(function (l) {
1849
- return l.kind === toPolkadotV2.ValidationKind.Error;
1850
- })) {
1851
- _context.n = 9;
1852
- break;
1853
- }
1854
- throw new RoutingResolutionError("Validation failed with following errors: \n\n ".concat(validated.logs.filter(function (l) {
1855
- return l.kind === toPolkadotV2.ValidationKind.Error;
1856
- }).map(function (l) {
1857
- return l.message;
1858
- }).join('\n\n')));
1859
- case 9:
1860
- _context.n = 10;
1861
- return signer.sendTransaction(transfer.tx);
1862
- case 10:
1863
- response = _context.v;
1864
- _context.n = 11;
1865
- return response.wait(1);
1866
- case 11:
1867
- receipt = _context.v;
1868
- if (receipt) {
1869
- _context.n = 12;
1870
- break;
1871
- }
1872
- throw new RoutingResolutionError("Transaction ".concat(response.hash, " not included."));
1873
- case 12:
1874
- _context.n = 13;
1875
- return sender.messageId(receipt);
1876
- case 13:
1877
- messageReceipt = _context.v;
1878
- if (messageReceipt) {
1879
- _context.n = 14;
1880
- break;
1881
- }
1882
- throw new RoutingResolutionError("Transaction ".concat(receipt.hash, " did not emit a message."));
1883
- case 14:
1884
- return _context.a(2, {
1885
- response: response,
1886
- messageReceipt: messageReceipt
1887
- });
1888
- }
1889
- }, _callee);
1890
- }));
1891
- return function transferEthToPolkadot(_x) {
1892
- return _ref2.apply(this, arguments);
1893
- };
1894
- }();
1895
-
1896
- var getTokenBalance = /*#__PURE__*/function () {
1897
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, symbol) {
1898
- var asset, weth9, address;
1899
- return _regenerator().w(function (_context) {
1900
- while (1) switch (_context.n) {
1901
- case 0:
1902
- asset = findAssetInfoOrThrow('Ethereum', {
1903
- symbol: symbol
1904
- });
1905
- assertHasId(asset);
1906
- weth9 = WETH9__factory.connect(asset.assetId, signer);
1907
- _context.n = 1;
1908
- return signer.getAddress();
1909
- case 1:
1910
- address = _context.v;
1911
- return _context.a(2, weth9.balanceOf(address));
1912
- }
1913
- }, _callee);
1914
- }));
1915
- return function getTokenBalance(_x, _x2) {
1916
- return _ref.apply(this, arguments);
1917
- };
1918
- }();
1919
-
1920
- /**
1921
- * Builder class for constructing transfers from Ethereum to Polkadot.
1922
- *
1923
- * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
1924
- */
1925
- var EvmBuilderCore = /*#__PURE__*/function () {
1926
- function EvmBuilderCore(options) {
1927
- _classCallCheck(this, EvmBuilderCore);
1928
- this._options = options;
1929
- }
1930
- return _createClass(EvmBuilderCore, [{
1931
- key: "from",
1932
- value: function from(chain) {
1933
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1934
- from: chain
1935
- }));
1936
- }
1937
- /**
1938
- * Specifies the destination chain on Polkadot.
1939
- *
1940
- * @param chain - The Polkadot chain to which the transfer will be made.
1941
- * @returns An instance of EvmBuilder
1942
- */
1943
- }, {
1944
- key: "to",
1945
- value: function to(chain) {
1946
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1947
- to: chain
1948
- }));
1949
- }
1950
- /**
1951
- * Specifies the currency to transfer.
1952
- *
1953
- * @param currency - The currency to be transferred.
1954
- * @returns An instance of EvmBuilder
1955
- */
1956
- }, {
1957
- key: "currency",
1958
- value: function currency(_currency) {
1959
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1960
- currency: _currency
1961
- }));
1962
- }
1963
- /**
1964
- * Specifies the recipient address on Polkadot.
1965
- *
1966
- * @param address - The Polkadot address to receive the transfer.
1967
- * @returns An instance of EvmBuilder
1968
- */
1969
- }, {
1970
- key: "recipient",
1971
- value: function recipient(address) {
1972
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1973
- recipient: address
1974
- }));
1975
- }
1976
- /**
1977
- * Sets the asset hub address. This is used for transfers that go through the Asset Hub.
1978
- *
1979
- * @param address - The address to be used.
1980
- * @returns An instance of EvmBuilder
1981
- */
1982
- }, {
1983
- key: "ahAddress",
1984
- value: function ahAddress(address) {
1985
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1986
- ahAddress: address
1987
- }));
1988
- }
1989
- /**
1990
- * Specifies the signer for the Ethereum transaction.
1991
- *
1992
- * @param signer - The Ethereum signer to authorize the transfer.
1993
- * @returns An instance of EvmBuilder
1994
- */
1995
- }, {
1996
- key: "signer",
1997
- value: function signer(_signer) {
1998
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1999
- signer: _signer
2000
- }));
2001
- }
2002
- /**
2003
- * Builds and executes the transfer from Ethereum to Polkadot.
2004
- *
2005
- * @throws Error if any required parameters are missing.
2006
- */
2007
- }, {
2008
- key: "build",
2009
- value: (function () {
2010
- var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2011
- var _this$_options, from, to, recipient, signer, api, _yield$transferEthToP, response;
2012
- return _regenerator().w(function (_context) {
2013
- while (1) switch (_context.n) {
2014
- case 0:
2015
- _this$_options = this._options, from = _this$_options.from, to = _this$_options.to, recipient = _this$_options.recipient, signer = _this$_options.signer, api = _this$_options.api;
2016
- validateAddress$1(api, recipient, to);
2017
- if (!(from === 'Moonbeam' && to === 'Ethereum')) {
2018
- _context.n = 2;
2019
- break;
2020
- }
2021
- if (!isEthersSigner(signer)) {
2022
- _context.n = 1;
2023
- break;
2024
- }
2025
- throw new UnsupportedOperationError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
2026
- case 1:
2027
- return _context.a(2, transferMoonbeamToEth(from, _objectSpread2(_objectSpread2({}, this._options), {}, {
2028
- signer: signer
2029
- })));
2030
- case 2:
2031
- if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
2032
- _context.n = 4;
2033
- break;
2034
- }
2035
- if (!isEthersSigner(signer)) {
2036
- _context.n = 3;
2037
- break;
2038
- }
2039
- throw new UnsupportedOperationError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
2040
- case 3:
2041
- return _context.a(2, transferMoonbeamEvm(_objectSpread2(_objectSpread2({}, this._options), {}, {
2042
- signer: signer
2043
- })));
2044
- case 4:
2045
- _context.n = 5;
2046
- return transferEthToPolkadot$1(this._options);
2047
- case 5:
2048
- _yield$transferEthToP = _context.v;
2049
- response = _yield$transferEthToP.response;
2050
- return _context.a(2, response.hash);
2051
- case 6:
2052
- return _context.a(2);
2053
- }
2054
- }, _callee, this);
2055
- }));
2056
- function build() {
2057
- return _build.apply(this, arguments);
2058
- }
2059
- return build;
2060
- }())
2061
- }]);
2062
- }();
2063
- /**
2064
- * Creates a new EvmBuilder instance for constructing Ethereum to Polkadot transfers.
2065
- *
2066
- * @param provider - The Ethereum provider to use for the transfer.
2067
- * @returns An instance of EvmBuilder class
2068
- * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
2069
- */
2070
- var EvmBuilder$1 = function EvmBuilder(api, provider) {
2071
- return new EvmBuilderCore({
2072
- api: api,
2073
- provider: provider
2074
- });
2075
- };
2076
-
2077
1669
  /**
2078
1670
  * Creates a new Builder instance.
2079
1671
  *
@@ -2084,20 +1676,9 @@ var Builder = function Builder(options) {
2084
1676
  var pjsApi = new PolkadotJsApi(options);
2085
1677
  return Builder$1(pjsApi);
2086
1678
  };
2087
- /** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
2088
- var EvmBuilder = function EvmBuilder(provider, api) {
2089
- var pjsApi = new PolkadotJsApi(api);
2090
- return EvmBuilder$1(pjsApi, provider);
2091
- };
2092
1679
 
2093
1680
  var dryRun = createPolkadotJsApiCall(dryRun$1);
2094
1681
  var dryRunOrigin = createPolkadotJsApiCall(dryRunOrigin$1);
2095
- var transferEthToPolkadot = function transferEthToPolkadot(options) {
2096
- var api = new PolkadotJsApi();
2097
- return transferEthToPolkadot$1(_objectSpread2(_objectSpread2({}, options), {}, {
2098
- api: api
2099
- }));
2100
- };
2101
1682
  var getParaEthTransferFees = /*#__PURE__*/function () {
2102
1683
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
2103
1684
  var pjsApi;
@@ -2137,14 +1718,10 @@ var getBridgeStatus = /*#__PURE__*/function () {
2137
1718
 
2138
1719
  var transfer = /*#__PURE__*/Object.freeze({
2139
1720
  __proto__: null,
2140
- approveToken: approveToken,
2141
- depositToken: depositToken,
2142
1721
  dryRun: dryRun,
2143
1722
  dryRunOrigin: dryRunOrigin,
2144
1723
  getBridgeStatus: getBridgeStatus,
2145
- getParaEthTransferFees: getParaEthTransferFees,
2146
- getTokenBalance: getTokenBalance,
2147
- transferEthToPolkadot: transferEthToPolkadot
1724
+ getParaEthTransferFees: getParaEthTransferFees
2148
1725
  });
2149
1726
 
2150
- export { Builder, EvmBuilder, approveToken, assets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, transferEthToPolkadot, transfer as xcmPallet };
1727
+ export { Builder, assets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "13.10.1",
3
+ "version": "14.0.0",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,8 +29,8 @@
29
29
  "@snowbridge/registry": "^1.1.6",
30
30
  "ethers": "6.16.0",
31
31
  "viem": "^2.53.1",
32
- "@paraspell/sdk-common": "13.10.1",
33
- "@paraspell/sdk-core": "13.10.1"
32
+ "@paraspell/sdk-common": "14.0.0",
33
+ "@paraspell/sdk-core": "14.0.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@polkadot/api": ">= 16.0 < 17",