@paraspell/sdk-pjs 13.11.0 → 14.1.0-rc

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, isCustomChain, isSenderSigner, PolkadotApi, getFailingInstruction, resolveModuleError, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetEqual, RELAY_LOCATION, 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");
@@ -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,10 +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,
1016
- failureInstruction: getFailingInstruction((_resultJson = resultJson) === null || _resultJson === void 0 || (_resultJson = _resultJson.ok) === null || _resultJson === void 0 ? void 0 : _resultJson.local_xcm, failureErr.failureIndex),
1011
+ dryRunError: buildDryRunError(failureErr, (_resultJson = resultJson) === null || _resultJson === void 0 || (_resultJson = _resultJson.ok) === null || _resultJson === void 0 ? void 0 : _resultJson.local_xcm),
1017
1012
  asset: resolvedFeeAsset.asset
1018
1013
  });
1019
1014
  case 14:
@@ -1023,10 +1018,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1023
1018
  }
1024
1019
  return _context0.a(2, {
1025
1020
  success: false,
1026
- failureReason: failureErr.failureReason || 'Unknown error',
1027
- failureSubReason: failureErr.failureSubReason,
1028
- failureIndex: failureErr.failureIndex,
1029
- failureInstruction: getFailingInstruction((_resultJson2 = resultJson) === null || _resultJson2 === void 0 || (_resultJson2 = _resultJson2.ok) === null || _resultJson2 === void 0 ? void 0 : _resultJson2.local_xcm, 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),
1030
1024
  asset: resolvedFeeAsset.asset
1031
1025
  });
1032
1026
  case 15:
@@ -1114,7 +1108,6 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1114
1108
  execFeeOk,
1115
1109
  execFee,
1116
1110
  isAssetNotFound,
1117
- bridgeHubExecFee,
1118
1111
  deliveryFee,
1119
1112
  _args9 = arguments,
1120
1113
  _t5;
@@ -1153,10 +1146,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1153
1146
  _context1.n = 5;
1154
1147
  return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
1155
1148
  case 5:
1156
- bridgeHubExecFee = _context1.v;
1157
- if (typeof bridgeHubExecFee === 'bigint') {
1158
- execFee = bridgeHubExecFee;
1159
- }
1149
+ execFee = _context1.v;
1160
1150
  case 6:
1161
1151
  _context1.n = 7;
1162
1152
  return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
@@ -1175,8 +1165,8 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1175
1165
  key: "getDeliveryFee",
1176
1166
  value: function () {
1177
1167
  var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
1178
- var _deliveryFeeRes, _ref9, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref0, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
1179
- 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;
1180
1170
  return _regenerator().w(function (_context10) {
1181
1171
  while (1) switch (_context10.p = _context10.n) {
1182
1172
  case 0:
@@ -1214,7 +1204,8 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1214
1204
  throw _t6;
1215
1205
  case 6:
1216
1206
  deliveryFeeResJson = (_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.toJSON();
1217
- 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;
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;
1218
1209
  nativeAsset = this.findNativeAssetInfoOrThrow(chain);
1219
1210
  if (!(isAssetEqual(asset, nativeAsset) || usedThirdParam)) {
1220
1211
  _context10.n = 7;
@@ -1263,7 +1254,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1263
1254
  _context11.n = 2;
1264
1255
  break;
1265
1256
  }
1266
- return _context11.a(2, undefined);
1257
+ return _context11.a(2, 0n);
1267
1258
  case 2:
1268
1259
  ahApi = this.clone();
1269
1260
  assetHubChain = "AssetHub".concat(this.getRelayChainOf(chain));
@@ -1279,13 +1270,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1279
1270
  });
1280
1271
  case 4:
1281
1272
  convertedExecFee = _context11.v;
1282
- if (!(convertedExecFee != null)) {
1283
- _context11.n = 5;
1284
- break;
1285
- }
1286
- return _context11.a(2, BigInt(convertedExecFee));
1287
- case 5:
1288
- return _context11.a(2, undefined);
1273
+ return _context11.a(2, convertedExecFee != null ? BigInt(convertedExecFee) : 0n);
1289
1274
  }
1290
1275
  }, _callee11, this);
1291
1276
  }));
@@ -1319,13 +1304,13 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1319
1304
  }, {
1320
1305
  key: "getDryRunXcm",
1321
1306
  value: function () {
1322
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref1) {
1323
- var _ref11, _ref12, _ref13;
1324
- 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;
1325
1310
  return _regenerator().w(function (_context13) {
1326
1311
  while (1) switch (_context13.n) {
1327
1312
  case 0:
1328
- originLocation = _ref1.originLocation, xcm = _ref1.xcm, asset = _ref1.asset, chain = _ref1.chain, version = _ref1.version, origin = _ref1.origin;
1313
+ originLocation = _ref9.originLocation, xcm = _ref9.xcm, asset = _ref9.asset, chain = _ref9.chain, version = _ref9.version, origin = _ref9.origin;
1329
1314
  supportsDryRunApi = this.hasDryRunSupport(chain);
1330
1315
  if (supportsDryRunApi) {
1331
1316
  _context13.n = 1;
@@ -1347,13 +1332,14 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1347
1332
  execRes = (_result$Ok = result.Ok) === null || _result$Ok === void 0 ? void 0 : _result$Ok.executionResult;
1348
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;
1349
1334
  isInstructionError = typeof error !== 'string';
1350
- failureReason = isInstructionError ? error.error : error;
1351
- 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;
1352
1337
  return _context13.a(2, {
1353
1338
  success: false,
1354
- failureReason: failureReason,
1355
- failureIndex: failureIndex,
1356
- failureInstruction: getFailingInstruction(xcm, failureIndex),
1339
+ dryRunError: buildDryRunError({
1340
+ reason: reason,
1341
+ instructionIndex: instructionIndex
1342
+ }, xcm),
1357
1343
  asset: asset
1358
1344
  });
1359
1345
  case 3:
@@ -1363,8 +1349,8 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1363
1349
  refTime: BigInt(actualWeight.refTime),
1364
1350
  proofSize: BigInt(actualWeight.proofSize)
1365
1351
  } : undefined;
1366
- destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref10) {
1367
- 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;
1368
1354
  }(Object.values(forwardedXcms[0])[0].interior);
1369
1355
  if (!(this.hasXcmPaymentApiSupport(chain) && asset)) {
1370
1356
  _context13.n = 5;
@@ -1390,17 +1376,17 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1390
1376
  emitted = result.Ok.emittedEvents; // We want to look for the last event
1391
1377
  reversedEvents = _toConsumableArray(emitted).reverse();
1392
1378
  palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
1393
- feeEvent = (_ref11 = (_ref12 = (_ref13 = origin === 'Mythos' ? reversedEvents.find(function (event) {
1379
+ feeEvent = (_ref1 = (_ref10 = (_ref11 = origin === 'Mythos' ? reversedEvents.find(function (event) {
1394
1380
  return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
1395
- }) : undefined) !== null && _ref13 !== void 0 ? _ref13 :
1381
+ }) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
1396
1382
  // Prefer an Issued event
1397
1383
  reversedEvents.find(function (event) {
1398
1384
  return palletsWithIssued.includes(event.section) && event.method === 'Issued';
1399
- })) !== null && _ref12 !== void 0 ? _ref12 :
1385
+ })) !== null && _ref10 !== void 0 ? _ref10 :
1400
1386
  // Fallback to Minted event
1401
1387
  reversedEvents.find(function (event) {
1402
1388
  return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
1403
- })) !== null && _ref11 !== void 0 ? _ref11 : reversedEvents.find(function (event) {
1389
+ })) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
1404
1390
  return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
1405
1391
  });
1406
1392
  if (feeEvent) {
@@ -1409,7 +1395,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1409
1395
  }
1410
1396
  return _context13.a(2, Promise.resolve({
1411
1397
  success: false,
1412
- failureReason: 'Cannot determine destination fee. No Issued event found',
1398
+ dryRunError: {
1399
+ reason: 'Cannot determine destination fee. No Issued event found'
1400
+ },
1413
1401
  asset: asset
1414
1402
  }));
1415
1403
  case 6:
@@ -1587,10 +1575,10 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1587
1575
  return tx.signAsync(createKeyringPair(sender));
1588
1576
  case 3:
1589
1577
  return _context17.a(2, new Promise(function (resolve, reject) {
1590
- tx.send(function (_ref14) {
1591
- var status = _ref14.status,
1592
- dispatchError = _ref14.dispatchError,
1593
- txHash = _ref14.txHash;
1578
+ tx.send(function (_ref12) {
1579
+ var status = _ref12.status,
1580
+ dispatchError = _ref12.dispatchError,
1581
+ txHash = _ref12.txHash;
1594
1582
  if (status.isFinalized) {
1595
1583
  if (dispatchError !== undefined) {
1596
1584
  if (dispatchError.isModule) {
@@ -1645,9 +1633,6 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
1645
1633
  };
1646
1634
  }();
1647
1635
  };
1648
- var isEthersSigner = function isEthersSigner(signer) {
1649
- return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
1650
- };
1651
1636
 
1652
1637
  /**
1653
1638
  * Retrieves the asset balance for a given account on a specified chain.
@@ -1661,11 +1646,8 @@ var assets = /*#__PURE__*/Object.freeze({
1661
1646
  Foreign: Foreign,
1662
1647
  ForeignAbstract: ForeignAbstract,
1663
1648
  Native: Native,
1664
- Override: Override,
1665
1649
  findAssetInfo: findAssetInfo,
1666
1650
  getAllAssetsSymbols: getAllAssetsSymbols,
1667
- getAssetDecimals: getAssetDecimals,
1668
- getAssetId: getAssetId,
1669
1651
  getAssets: getAssets,
1670
1652
  getAssetsObject: getAssetsObject,
1671
1653
  getBalance: getBalance,
@@ -1676,7 +1658,6 @@ var assets = /*#__PURE__*/Object.freeze({
1676
1658
  getRelayChainSymbol: getRelayChainSymbol,
1677
1659
  getSupportedAssets: getSupportedAssets,
1678
1660
  getTChain: getTChain,
1679
- hasSupportForAsset: hasSupportForAsset,
1680
1661
  isChainEvm: isChainEvm
1681
1662
  });
1682
1663
 
@@ -1685,398 +1666,6 @@ var convertSs58 = function convertSs58(address, chain) {
1685
1666
  return convertSs58$1(papiApi, address, chain);
1686
1667
  };
1687
1668
 
1688
- var approveToken = /*#__PURE__*/function () {
1689
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
1690
- var _bridgeInfoFor, gatewayContract, asset, weth9, result, receipt;
1691
- return _regenerator().w(function (_context) {
1692
- while (1) switch (_context.n) {
1693
- case 0:
1694
- _bridgeInfoFor = bridgeInfoFor('polkadot_mainnet'), gatewayContract = _bridgeInfoFor.environment.gatewayContract;
1695
- asset = findAssetInfoOrThrow('Ethereum', {
1696
- symbol: symbol
1697
- });
1698
- assertHasId(asset);
1699
- weth9 = WETH9__factory.connect(asset.assetId, signer);
1700
- _context.n = 1;
1701
- return weth9.approve(gatewayContract, amount);
1702
- case 1:
1703
- result = _context.v;
1704
- _context.n = 2;
1705
- return result.wait();
1706
- case 2:
1707
- receipt = _context.v;
1708
- return _context.a(2, {
1709
- result: result,
1710
- receipt: receipt
1711
- });
1712
- }
1713
- }, _callee);
1714
- }));
1715
- return function approveToken(_x, _x2, _x3) {
1716
- return _ref.apply(this, arguments);
1717
- };
1718
- }();
1719
-
1720
- var depositToken = /*#__PURE__*/function () {
1721
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
1722
- var asset, weth9, result, receipt;
1723
- return _regenerator().w(function (_context) {
1724
- while (1) switch (_context.n) {
1725
- case 0:
1726
- asset = findAssetInfoOrThrow('Ethereum', {
1727
- symbol: symbol
1728
- });
1729
- assertHasId(asset);
1730
- weth9 = WETH9__factory.connect(asset.assetId, signer);
1731
- _context.n = 1;
1732
- return weth9.deposit({
1733
- value: amount
1734
- });
1735
- case 1:
1736
- result = _context.v;
1737
- _context.n = 2;
1738
- return result.wait();
1739
- case 2:
1740
- receipt = _context.v;
1741
- return _context.a(2, {
1742
- result: result,
1743
- receipt: receipt
1744
- });
1745
- }
1746
- }, _callee);
1747
- }));
1748
- return function depositToken(_x, _x2, _x3) {
1749
- return _ref.apply(this, arguments);
1750
- };
1751
- }();
1752
-
1753
- var createEnvironment = function createEnvironment(env, executionUrl) {
1754
- return _objectSpread2(_objectSpread2({}, env), {}, {
1755
- assetOverrides: {
1756
- '3369': [{
1757
- token: '0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003',
1758
- name: 'Mythos',
1759
- minimumBalance: 10000000000000000n,
1760
- symbol: 'MYTH',
1761
- decimals: 18,
1762
- isSufficient: true
1763
- }]
1764
- },
1765
- precompiles: {
1766
- '2004': '0x000000000000000000000000000000000000081A'
1767
- },
1768
- ethereumChains: _objectSpread2(_objectSpread2(_objectSpread2({}, env.ethereumChains), executionUrl !== undefined ? _defineProperty({}, env.ethChainId.toString(), executionUrl) : {}), {}, _defineProperty({}, getParaId('Moonbeam'), 'https://rpc.api.moonbeam.network'))
1769
- });
1770
- };
1771
-
1772
- /**
1773
- * Transfers an Ethereum asset to a Polkadot account.
1774
- *
1775
- * @param provider - The Ethereum provider instance to interact with the Ethereum network.
1776
- * @param options - The options for the transfer.
1777
- *
1778
- * @returns A Promise that resolves to an object containing the result and the plan of the transfer.
1779
- *
1780
- * @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
1781
- */
1782
- var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1783
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
1784
- var api, provider, signer, recipient, to, currency, ethAsset, amount, info, environment, snowbridgeApi, destParaId, sender, sourceAddress, fee, transfer, validated, response, receipt, messageReceipt;
1785
- return _regenerator().w(function (_context) {
1786
- while (1) switch (_context.n) {
1787
- case 0:
1788
- api = _ref.api, provider = _ref.provider, signer = _ref.signer, recipient = _ref.recipient, to = _ref.to, currency = _ref.currency;
1789
- if (!Array.isArray(currency)) {
1790
- _context.n = 1;
1791
- break;
1792
- }
1793
- throw new UnsupportedOperationError('Multi-assets are not yet supported for EVM transfers');
1794
- case 1:
1795
- if (!('location' in currency && isOverrideLocationSpecifier(currency.location))) {
1796
- _context.n = 2;
1797
- break;
1798
- }
1799
- throw new UnsupportedOperationError('Override location is not supported for EVM transfers');
1800
- case 2:
1801
- if (provider) {
1802
- _context.n = 3;
1803
- break;
1804
- }
1805
- throw new MissingParameterError('provider', 'provider parameter is required for Snowbridge transfers.');
1806
- case 3:
1807
- if (isEthersSigner(signer)) {
1808
- _context.n = 4;
1809
- break;
1810
- }
1811
- throw new UnsupportedOperationError('Snowbridge does not support Viem provider yet.');
1812
- case 4:
1813
- ethAsset = findAssetInfoOrThrow('Ethereum', currency, to);
1814
- amount = abstractDecimals(currency.amount, ethAsset.decimals, api);
1815
- info = bridgeInfoFor('polkadot_mainnet');
1816
- environment = createEnvironment(info.environment, typeof provider === 'string' ? provider : undefined);
1817
- snowbridgeApi = new SnowbridgeApi({
1818
- info: _objectSpread2(_objectSpread2({}, info), {}, {
1819
- environment: environment
1820
- }),
1821
- ethereumProvider: new EthersEthereumProvider()
1822
- });
1823
- if (typeof provider !== 'string') {
1824
- snowbridgeApi.context.setEthProvider(environment.ethChainId, provider);
1825
- }
1826
- destParaId = getParaId(to);
1827
- assertHasId(ethAsset);
1828
- sender = snowbridgeApi.sender({
1829
- kind: 'ethereum',
1830
- id: environment.ethChainId
1831
- }, {
1832
- kind: 'polkadot',
1833
- id: destParaId
1834
- });
1835
- _context.n = 5;
1836
- return signer.getAddress();
1837
- case 5:
1838
- sourceAddress = _context.v;
1839
- _context.n = 6;
1840
- return sender.fee(ethAsset.assetId);
1841
- case 6:
1842
- fee = _context.v;
1843
- _context.n = 7;
1844
- return sender.tx(sourceAddress, recipient, ethAsset.assetId, amount, fee);
1845
- case 7:
1846
- transfer = _context.v;
1847
- _context.n = 8;
1848
- return sender.validate(transfer);
1849
- case 8:
1850
- validated = _context.v;
1851
- if (!validated.logs.find(function (l) {
1852
- return l.kind === toPolkadotV2.ValidationKind.Error;
1853
- })) {
1854
- _context.n = 9;
1855
- break;
1856
- }
1857
- throw new RoutingResolutionError("Validation failed with following errors: \n\n ".concat(validated.logs.filter(function (l) {
1858
- return l.kind === toPolkadotV2.ValidationKind.Error;
1859
- }).map(function (l) {
1860
- return l.message;
1861
- }).join('\n\n')));
1862
- case 9:
1863
- _context.n = 10;
1864
- return signer.sendTransaction(transfer.tx);
1865
- case 10:
1866
- response = _context.v;
1867
- _context.n = 11;
1868
- return response.wait(1);
1869
- case 11:
1870
- receipt = _context.v;
1871
- if (receipt) {
1872
- _context.n = 12;
1873
- break;
1874
- }
1875
- throw new RoutingResolutionError("Transaction ".concat(response.hash, " not included."));
1876
- case 12:
1877
- _context.n = 13;
1878
- return sender.messageId(receipt);
1879
- case 13:
1880
- messageReceipt = _context.v;
1881
- if (messageReceipt) {
1882
- _context.n = 14;
1883
- break;
1884
- }
1885
- throw new RoutingResolutionError("Transaction ".concat(receipt.hash, " did not emit a message."));
1886
- case 14:
1887
- return _context.a(2, {
1888
- response: response,
1889
- messageReceipt: messageReceipt
1890
- });
1891
- }
1892
- }, _callee);
1893
- }));
1894
- return function transferEthToPolkadot(_x) {
1895
- return _ref2.apply(this, arguments);
1896
- };
1897
- }();
1898
-
1899
- var getTokenBalance = /*#__PURE__*/function () {
1900
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, symbol) {
1901
- var asset, weth9, address;
1902
- return _regenerator().w(function (_context) {
1903
- while (1) switch (_context.n) {
1904
- case 0:
1905
- asset = findAssetInfoOrThrow('Ethereum', {
1906
- symbol: symbol
1907
- });
1908
- assertHasId(asset);
1909
- weth9 = WETH9__factory.connect(asset.assetId, signer);
1910
- _context.n = 1;
1911
- return signer.getAddress();
1912
- case 1:
1913
- address = _context.v;
1914
- return _context.a(2, weth9.balanceOf(address));
1915
- }
1916
- }, _callee);
1917
- }));
1918
- return function getTokenBalance(_x, _x2) {
1919
- return _ref.apply(this, arguments);
1920
- };
1921
- }();
1922
-
1923
- /**
1924
- * Builder class for constructing transfers from Ethereum to Polkadot.
1925
- *
1926
- * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
1927
- */
1928
- var EvmBuilderCore = /*#__PURE__*/function () {
1929
- function EvmBuilderCore(options) {
1930
- _classCallCheck(this, EvmBuilderCore);
1931
- this._options = options;
1932
- }
1933
- return _createClass(EvmBuilderCore, [{
1934
- key: "from",
1935
- value: function from(chain) {
1936
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1937
- from: chain
1938
- }));
1939
- }
1940
- /**
1941
- * Specifies the destination chain on Polkadot.
1942
- *
1943
- * @param chain - The Polkadot chain to which the transfer will be made.
1944
- * @returns An instance of EvmBuilder
1945
- */
1946
- }, {
1947
- key: "to",
1948
- value: function to(chain) {
1949
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1950
- to: chain
1951
- }));
1952
- }
1953
- /**
1954
- * Specifies the currency to transfer.
1955
- *
1956
- * @param currency - The currency to be transferred.
1957
- * @returns An instance of EvmBuilder
1958
- */
1959
- }, {
1960
- key: "currency",
1961
- value: function currency(_currency) {
1962
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1963
- currency: _currency
1964
- }));
1965
- }
1966
- /**
1967
- * Specifies the recipient address on Polkadot.
1968
- *
1969
- * @param address - The Polkadot address to receive the transfer.
1970
- * @returns An instance of EvmBuilder
1971
- */
1972
- }, {
1973
- key: "recipient",
1974
- value: function recipient(address) {
1975
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1976
- recipient: address
1977
- }));
1978
- }
1979
- /**
1980
- * Sets the asset hub address. This is used for transfers that go through the Asset Hub.
1981
- *
1982
- * @param address - The address to be used.
1983
- * @returns An instance of EvmBuilder
1984
- */
1985
- }, {
1986
- key: "ahAddress",
1987
- value: function ahAddress(address) {
1988
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
1989
- ahAddress: address
1990
- }));
1991
- }
1992
- /**
1993
- * Specifies the signer for the Ethereum transaction.
1994
- *
1995
- * @param signer - The Ethereum signer to authorize the transfer.
1996
- * @returns An instance of EvmBuilder
1997
- */
1998
- }, {
1999
- key: "signer",
2000
- value: function signer(_signer) {
2001
- return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
2002
- signer: _signer
2003
- }));
2004
- }
2005
- /**
2006
- * Builds and executes the transfer from Ethereum to Polkadot.
2007
- *
2008
- * @throws Error if any required parameters are missing.
2009
- */
2010
- }, {
2011
- key: "build",
2012
- value: (function () {
2013
- var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2014
- var _this$_options, from, to, recipient, signer, api, _yield$transferEthToP, response;
2015
- return _regenerator().w(function (_context) {
2016
- while (1) switch (_context.n) {
2017
- case 0:
2018
- _this$_options = this._options, from = _this$_options.from, to = _this$_options.to, recipient = _this$_options.recipient, signer = _this$_options.signer, api = _this$_options.api;
2019
- validateAddress$1(api, recipient, to);
2020
- if (!(from === 'Moonbeam' && to === 'Ethereum')) {
2021
- _context.n = 2;
2022
- break;
2023
- }
2024
- if (!isEthersSigner(signer)) {
2025
- _context.n = 1;
2026
- break;
2027
- }
2028
- throw new UnsupportedOperationError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
2029
- case 1:
2030
- return _context.a(2, transferMoonbeamToEth(from, _objectSpread2(_objectSpread2({}, this._options), {}, {
2031
- signer: signer
2032
- })));
2033
- case 2:
2034
- if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
2035
- _context.n = 4;
2036
- break;
2037
- }
2038
- if (!isEthersSigner(signer)) {
2039
- _context.n = 3;
2040
- break;
2041
- }
2042
- throw new UnsupportedOperationError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
2043
- case 3:
2044
- return _context.a(2, transferMoonbeamEvm(_objectSpread2(_objectSpread2({}, this._options), {}, {
2045
- signer: signer
2046
- })));
2047
- case 4:
2048
- _context.n = 5;
2049
- return transferEthToPolkadot$1(this._options);
2050
- case 5:
2051
- _yield$transferEthToP = _context.v;
2052
- response = _yield$transferEthToP.response;
2053
- return _context.a(2, response.hash);
2054
- case 6:
2055
- return _context.a(2);
2056
- }
2057
- }, _callee, this);
2058
- }));
2059
- function build() {
2060
- return _build.apply(this, arguments);
2061
- }
2062
- return build;
2063
- }())
2064
- }]);
2065
- }();
2066
- /**
2067
- * Creates a new EvmBuilder instance for constructing Ethereum to Polkadot transfers.
2068
- *
2069
- * @param provider - The Ethereum provider to use for the transfer.
2070
- * @returns An instance of EvmBuilder class
2071
- * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
2072
- */
2073
- var EvmBuilder$1 = function EvmBuilder(api, provider) {
2074
- return new EvmBuilderCore({
2075
- api: api,
2076
- provider: provider
2077
- });
2078
- };
2079
-
2080
1669
  /**
2081
1670
  * Creates a new Builder instance.
2082
1671
  *
@@ -2087,20 +1676,9 @@ var Builder = function Builder(options) {
2087
1676
  var pjsApi = new PolkadotJsApi(options);
2088
1677
  return Builder$1(pjsApi);
2089
1678
  };
2090
- /** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
2091
- var EvmBuilder = function EvmBuilder(provider, api) {
2092
- var pjsApi = new PolkadotJsApi(api);
2093
- return EvmBuilder$1(pjsApi, provider);
2094
- };
2095
1679
 
2096
1680
  var dryRun = createPolkadotJsApiCall(dryRun$1);
2097
1681
  var dryRunOrigin = createPolkadotJsApiCall(dryRunOrigin$1);
2098
- var transferEthToPolkadot = function transferEthToPolkadot(options) {
2099
- var api = new PolkadotJsApi();
2100
- return transferEthToPolkadot$1(_objectSpread2(_objectSpread2({}, options), {}, {
2101
- api: api
2102
- }));
2103
- };
2104
1682
  var getParaEthTransferFees = /*#__PURE__*/function () {
2105
1683
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
2106
1684
  var pjsApi;
@@ -2140,14 +1718,10 @@ var getBridgeStatus = /*#__PURE__*/function () {
2140
1718
 
2141
1719
  var transfer = /*#__PURE__*/Object.freeze({
2142
1720
  __proto__: null,
2143
- approveToken: approveToken,
2144
- depositToken: depositToken,
2145
1721
  dryRun: dryRun,
2146
1722
  dryRunOrigin: dryRunOrigin,
2147
1723
  getBridgeStatus: getBridgeStatus,
2148
- getParaEthTransferFees: getParaEthTransferFees,
2149
- getTokenBalance: getTokenBalance,
2150
- transferEthToPolkadot: transferEthToPolkadot
1724
+ getParaEthTransferFees: getParaEthTransferFees
2151
1725
  });
2152
1726
 
2153
- 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.11.0",
3
+ "version": "14.1.0-rc",
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.11.0",
33
- "@paraspell/sdk-core": "13.11.0"
32
+ "@paraspell/sdk-core": "14.1.0-rc",
33
+ "@paraspell/sdk-common": "14.1.0-rc"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@polkadot/api": ">= 16.0 < 17",