@paraspell/sdk 13.5.0 → 13.7.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 +71 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.mjs +403 -224
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -321,6 +321,77 @@ const tx = await builder.buildBatch({
|
|
|
321
321
|
await builder.disconnect()
|
|
322
322
|
```
|
|
323
323
|
|
|
324
|
+
#### Adding chain and/or assets
|
|
325
|
+
SDK features ability to add custom chain and/or custom assets simply by adding its config to the Builder.
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
const tx = await Builder({
|
|
329
|
+
// Adding custom chain
|
|
330
|
+
customChains: {
|
|
331
|
+
MyChain: {
|
|
332
|
+
paraId: 4242,
|
|
333
|
+
ecosystem: 'Polkadot',
|
|
334
|
+
xcmVersion: Version.V5,
|
|
335
|
+
providers: [{ name: 'Primary', endpoint: 'wss://rpc.mychain.example/ws' }],
|
|
336
|
+
// Everything below is optional — auto-fetched from runtime `system.properties` when omitted
|
|
337
|
+
nativeAssetSymbol: 'MYC',
|
|
338
|
+
nativeAssetDecimals: 12,
|
|
339
|
+
ss58Prefix: 42,
|
|
340
|
+
pallets: {
|
|
341
|
+
nativeAssets: "Balances”,
|
|
342
|
+
otherAssets: "Assets",
|
|
343
|
+
}
|
|
344
|
+
assets: [
|
|
345
|
+
{
|
|
346
|
+
symbol: 'USDC',
|
|
347
|
+
decimals: 6,
|
|
348
|
+
existentialDeposit: 0.1,
|
|
349
|
+
location: {
|
|
350
|
+
parents: 1,
|
|
351
|
+
interior: { X3: [{ Parachain: 1000 }, { PalletInstance: 50 }, {
|
|
352
|
+
GeneralIndex: 1337 }] }
|
|
353
|
+
},
|
|
354
|
+
assetId: '1337'
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
// Adding assets to existing chains
|
|
361
|
+
customAssets: {
|
|
362
|
+
AssetHubPolkadot: [
|
|
363
|
+
{
|
|
364
|
+
symbol: 'MYNEWUSD',
|
|
365
|
+
decimals: 6,
|
|
366
|
+
assetId: '9999',
|
|
367
|
+
existentialDeposit: 0.1,
|
|
368
|
+
location: {
|
|
369
|
+
parents: 0,
|
|
370
|
+
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 9999 }] }
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
// Replace an existing registry asset that shares the same location
|
|
375
|
+
symbol: 'USDT',
|
|
376
|
+
decimals: 6,
|
|
377
|
+
assetId: '1984',
|
|
378
|
+
existentialDeposit: 0.1,
|
|
379
|
+
location: {
|
|
380
|
+
parents: 0,
|
|
381
|
+
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] }
|
|
382
|
+
},
|
|
383
|
+
forceOverride: true
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
.from('MyChain') // custom chain name — TS-autocompletes
|
|
389
|
+
.to('AssetHubPolkadot') // could be any of the existing or also the new ones added
|
|
390
|
+
.currency({ symbol: 'USDC', amount: amount })
|
|
391
|
+
.recipient(address)
|
|
392
|
+
.build()
|
|
393
|
+
```
|
|
394
|
+
|
|
324
395
|
### Localhost test setup
|
|
325
396
|
|
|
326
397
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import { TChain, TSwapEvent as TSwapEvent$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TEvmTransferOptions, TCurrencyInputWithAmount, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions, TGetXcmFeeBaseOptions, TCreateBaseSwapXcmOptions } from '@paraspell/sdk-core';
|
|
2
|
+
import { TChain, TSwapEvent as TSwapEvent$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TEvmTransferOptions, TCurrencyInputWithAmount, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TCustomChainFrom, TTransferBaseOptions, TCustomChainInput, TChainAssetsInfo, TGetXcmFeeBaseOptions, TCreateBaseSwapXcmOptions } from '@paraspell/sdk-core';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import * as polkadot_api from 'polkadot-api';
|
|
5
5
|
import { PolkadotClient, Transaction, PolkadotSigner } from 'polkadot-api';
|
|
@@ -136,16 +136,18 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TEvmTransfer
|
|
|
136
136
|
/**
|
|
137
137
|
* Creates a new Builder instance.
|
|
138
138
|
*
|
|
139
|
-
* @param
|
|
139
|
+
* @param options - Either an existing API instance, a WS URL, or a config object.
|
|
140
140
|
* @returns A new Builder instance.
|
|
141
141
|
*/
|
|
142
|
-
declare const Builder:
|
|
143
|
-
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPapiApi, TPapiTransaction, TPapiSigner>> = object> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T>;
|
|
142
|
+
declare const Builder: <const TOpts extends TBuilderOptions<TApiOrUrl<TPapiApi>>>(options?: TOpts) => GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, object, TCustomChainFrom<TOpts>>;
|
|
143
|
+
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPapiApi, TPapiTransaction, TPapiSigner>> = object, TCustomChain extends string = never> = GeneralBuilder$1<PolkadotClient, TPapiTransaction, PolkadotSigner, T, TCustomChain>;
|
|
144
144
|
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
145
145
|
declare const EvmBuilder: (api?: TBuilderOptions<TApiOrUrl<TPapiApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
146
|
-
api: _paraspell_sdk_core.PolkadotApi<PolkadotClient, TPapiTransaction, PolkadotSigner>;
|
|
146
|
+
api: _paraspell_sdk_core.PolkadotApi<PolkadotClient, TPapiTransaction, PolkadotSigner, never>;
|
|
147
147
|
}>;
|
|
148
148
|
|
|
149
|
+
declare const hydrateCustomChain: (name: string, input: TCustomChainInput) => Promise<TChainAssetsInfo>;
|
|
150
|
+
|
|
149
151
|
declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<TPapiTransaction> & {
|
|
150
152
|
api?: TApiOrUrl<TPapiApi>;
|
|
151
153
|
}) => Promise<_paraspell_sdk_core.TDryRunResult>;
|
|
@@ -187,5 +189,5 @@ declare const createChainClient: (chain: TSubstrateChain, api?: TBuilderOptions<
|
|
|
187
189
|
declare const checkAndConvertToNumberOrBigInt: (input: string) => number | bigint;
|
|
188
190
|
declare const transform: (obj: any) => any;
|
|
189
191
|
|
|
190
|
-
export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, transform, transfer as xcmPallet };
|
|
192
|
+
export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, hydrateCustomChain, transform, transfer as xcmPallet };
|
|
191
193
|
export type { GeneralBuilder, TEvmChainFrom, TPapiApi, TPapiSigner, TPapiTransaction, TSwapEvent };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig,
|
|
1
|
+
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrowImpl, getChainProvidersImpl, PolkadotApi, Parents, findAssetInfoOrThrowImpl, hasXcmPaymentApiSupportImpl, replaceBigInt, hasDryRunSupportImpl, RuntimeApiUnavailableError, wrapTxBypass, RuntimeApiError, localizeLocation, isAssetXcEqual, createAssetId, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOfImpl, isRelayChain, padValueBy, isAssetEqual, 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, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, CustomChainInvalidError, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
4
4
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
@@ -8,6 +8,7 @@ import { entropyToMiniSecret, mnemonicToEntropy, DEV_PHRASE } from '@polkadot-la
|
|
|
8
8
|
import { AccountId, Binary, getSs58AddressInfo } from 'polkadot-api';
|
|
9
9
|
import { getPolkadotSigner } from 'polkadot-api/signer';
|
|
10
10
|
import { blake2b } from '@noble/hashes/blake2.js';
|
|
11
|
+
import { unifyMetadata, decAnyMetadata } from '@polkadot-api/substrate-bindings';
|
|
11
12
|
import { toHex } from 'polkadot-api/utils';
|
|
12
13
|
import { createWsClient } from 'polkadot-api/ws';
|
|
13
14
|
import { isAddress, isHex } from 'viem';
|
|
@@ -941,6 +942,99 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
941
942
|
}
|
|
942
943
|
return hasMethod;
|
|
943
944
|
}()
|
|
945
|
+
}, {
|
|
946
|
+
key: "hasRuntimeApi",
|
|
947
|
+
value: function () {
|
|
948
|
+
var _hasRuntimeApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(runtimeApi) {
|
|
949
|
+
var probeMethod, _t2;
|
|
950
|
+
return _regenerator().w(function (_context5) {
|
|
951
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
952
|
+
case 0:
|
|
953
|
+
probeMethod = runtimeApi === 'DryRunApi' ? 'dry_run_call' : 'query_xcm_weight';
|
|
954
|
+
_context5.p = 1;
|
|
955
|
+
_context5.n = 2;
|
|
956
|
+
return this.untypedApi.apis[runtimeApi][probeMethod]();
|
|
957
|
+
case 2:
|
|
958
|
+
return _context5.a(2, true);
|
|
959
|
+
case 3:
|
|
960
|
+
_context5.p = 3;
|
|
961
|
+
_t2 = _context5.v;
|
|
962
|
+
if (!(_t2 instanceof Error && /not found/i.test(_t2.message))) {
|
|
963
|
+
_context5.n = 4;
|
|
964
|
+
break;
|
|
965
|
+
}
|
|
966
|
+
return _context5.a(2, false);
|
|
967
|
+
case 4:
|
|
968
|
+
return _context5.a(2, true);
|
|
969
|
+
}
|
|
970
|
+
}, _callee5, this, [[1, 3]]);
|
|
971
|
+
}));
|
|
972
|
+
function hasRuntimeApi(_x8) {
|
|
973
|
+
return _hasRuntimeApi.apply(this, arguments);
|
|
974
|
+
}
|
|
975
|
+
return hasRuntimeApi;
|
|
976
|
+
}()
|
|
977
|
+
}, {
|
|
978
|
+
key: "isEvmChain",
|
|
979
|
+
value: function () {
|
|
980
|
+
var _isEvmChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
981
|
+
var _unifyMetadata$lookup, _path$includes;
|
|
982
|
+
var _yield$this$api$getFi, hash, bytes, path;
|
|
983
|
+
return _regenerator().w(function (_context6) {
|
|
984
|
+
while (1) switch (_context6.n) {
|
|
985
|
+
case 0:
|
|
986
|
+
_context6.n = 1;
|
|
987
|
+
return this.api.getFinalizedBlock();
|
|
988
|
+
case 1:
|
|
989
|
+
_yield$this$api$getFi = _context6.v;
|
|
990
|
+
hash = _yield$this$api$getFi.hash;
|
|
991
|
+
_context6.n = 2;
|
|
992
|
+
return this.api.getMetadata(hash);
|
|
993
|
+
case 2:
|
|
994
|
+
bytes = _context6.v;
|
|
995
|
+
path = (_unifyMetadata$lookup = unifyMetadata(decAnyMetadata(bytes)).lookup[0]) === null || _unifyMetadata$lookup === void 0 ? void 0 : _unifyMetadata$lookup.path;
|
|
996
|
+
return _context6.a(2, (_path$includes = path === null || path === void 0 ? void 0 : path.includes('AccountId20')) !== null && _path$includes !== void 0 ? _path$includes : false);
|
|
997
|
+
}
|
|
998
|
+
}, _callee6, this);
|
|
999
|
+
}));
|
|
1000
|
+
function isEvmChain() {
|
|
1001
|
+
return _isEvmChain.apply(this, arguments);
|
|
1002
|
+
}
|
|
1003
|
+
return isEvmChain;
|
|
1004
|
+
}()
|
|
1005
|
+
}, {
|
|
1006
|
+
key: "fetchPalletList",
|
|
1007
|
+
value: function () {
|
|
1008
|
+
var _fetchPalletList = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
1009
|
+
var _yield$this$api$getFi2, hash, bytes, meta;
|
|
1010
|
+
return _regenerator().w(function (_context7) {
|
|
1011
|
+
while (1) switch (_context7.n) {
|
|
1012
|
+
case 0:
|
|
1013
|
+
_context7.n = 1;
|
|
1014
|
+
return this.api.getFinalizedBlock();
|
|
1015
|
+
case 1:
|
|
1016
|
+
_yield$this$api$getFi2 = _context7.v;
|
|
1017
|
+
hash = _yield$this$api$getFi2.hash;
|
|
1018
|
+
_context7.n = 2;
|
|
1019
|
+
return this.api.getMetadata(hash);
|
|
1020
|
+
case 2:
|
|
1021
|
+
bytes = _context7.v;
|
|
1022
|
+
meta = unifyMetadata(decAnyMetadata(bytes));
|
|
1023
|
+
return _context7.a(2, meta.pallets.map(function (p) {
|
|
1024
|
+
return {
|
|
1025
|
+
name: p.name,
|
|
1026
|
+
index: p.index,
|
|
1027
|
+
hasExtrinsics: p.calls !== undefined
|
|
1028
|
+
};
|
|
1029
|
+
}));
|
|
1030
|
+
}
|
|
1031
|
+
}, _callee7, this);
|
|
1032
|
+
}));
|
|
1033
|
+
function fetchPalletList() {
|
|
1034
|
+
return _fetchPalletList.apply(this, arguments);
|
|
1035
|
+
}
|
|
1036
|
+
return fetchPalletList;
|
|
1037
|
+
}()
|
|
944
1038
|
}, {
|
|
945
1039
|
key: "getMethod",
|
|
946
1040
|
value: function getMethod(tx) {
|
|
@@ -955,20 +1049,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
955
1049
|
}, {
|
|
956
1050
|
key: "getPaymentInfo",
|
|
957
1051
|
value: function () {
|
|
958
|
-
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1052
|
+
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(tx, address) {
|
|
959
1053
|
var _yield$tx$getPaymentI, partial_fee, _yield$tx$getPaymentI2, proof_size, ref_time;
|
|
960
|
-
return _regenerator().w(function (
|
|
961
|
-
while (1) switch (
|
|
1054
|
+
return _regenerator().w(function (_context8) {
|
|
1055
|
+
while (1) switch (_context8.n) {
|
|
962
1056
|
case 0:
|
|
963
|
-
|
|
1057
|
+
_context8.n = 1;
|
|
964
1058
|
return tx.getPaymentInfo(address);
|
|
965
1059
|
case 1:
|
|
966
|
-
_yield$tx$getPaymentI =
|
|
1060
|
+
_yield$tx$getPaymentI = _context8.v;
|
|
967
1061
|
partial_fee = _yield$tx$getPaymentI.partial_fee;
|
|
968
1062
|
_yield$tx$getPaymentI2 = _yield$tx$getPaymentI.weight;
|
|
969
1063
|
proof_size = _yield$tx$getPaymentI2.proof_size;
|
|
970
1064
|
ref_time = _yield$tx$getPaymentI2.ref_time;
|
|
971
|
-
return
|
|
1065
|
+
return _context8.a(2, {
|
|
972
1066
|
partialFee: partial_fee,
|
|
973
1067
|
weight: {
|
|
974
1068
|
proofSize: proof_size,
|
|
@@ -976,9 +1070,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
976
1070
|
}
|
|
977
1071
|
});
|
|
978
1072
|
}
|
|
979
|
-
},
|
|
1073
|
+
}, _callee8);
|
|
980
1074
|
}));
|
|
981
|
-
function getPaymentInfo(
|
|
1075
|
+
function getPaymentInfo(_x9, _x0) {
|
|
982
1076
|
return _getPaymentInfo.apply(this, arguments);
|
|
983
1077
|
}
|
|
984
1078
|
return getPaymentInfo;
|
|
@@ -991,20 +1085,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
991
1085
|
}, {
|
|
992
1086
|
key: "getFromRpc",
|
|
993
1087
|
value: function () {
|
|
994
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1088
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(module, method, key) {
|
|
995
1089
|
var value;
|
|
996
|
-
return _regenerator().w(function (
|
|
997
|
-
while (1) switch (
|
|
1090
|
+
return _regenerator().w(function (_context9) {
|
|
1091
|
+
while (1) switch (_context9.n) {
|
|
998
1092
|
case 0:
|
|
999
|
-
|
|
1093
|
+
_context9.n = 1;
|
|
1000
1094
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? AccountId().dec(key) : key]);
|
|
1001
1095
|
case 1:
|
|
1002
|
-
value =
|
|
1003
|
-
return
|
|
1096
|
+
value = _context9.v;
|
|
1097
|
+
return _context9.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1004
1098
|
}
|
|
1005
|
-
},
|
|
1099
|
+
}, _callee9, this);
|
|
1006
1100
|
}));
|
|
1007
|
-
function getFromRpc(
|
|
1101
|
+
function getFromRpc(_x1, _x10, _x11) {
|
|
1008
1102
|
return _getFromRpc.apply(this, arguments);
|
|
1009
1103
|
}
|
|
1010
1104
|
return getFromRpc;
|
|
@@ -1017,20 +1111,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1017
1111
|
}, {
|
|
1018
1112
|
key: "createApiForChain",
|
|
1019
1113
|
value: function () {
|
|
1020
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1114
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(chain) {
|
|
1021
1115
|
var api;
|
|
1022
|
-
return _regenerator().w(function (
|
|
1023
|
-
while (1) switch (
|
|
1116
|
+
return _regenerator().w(function (_context0) {
|
|
1117
|
+
while (1) switch (_context0.n) {
|
|
1024
1118
|
case 0:
|
|
1025
1119
|
api = new PapiApi(isConfig(this._config) ? this._config : undefined);
|
|
1026
|
-
|
|
1120
|
+
_context0.n = 1;
|
|
1027
1121
|
return api.init(chain);
|
|
1028
1122
|
case 1:
|
|
1029
|
-
return
|
|
1123
|
+
return _context0.a(2, api);
|
|
1030
1124
|
}
|
|
1031
|
-
},
|
|
1125
|
+
}, _callee0, this);
|
|
1032
1126
|
}));
|
|
1033
|
-
function createApiForChain(
|
|
1127
|
+
function createApiForChain(_x12) {
|
|
1034
1128
|
return _createApiForChain.apply(this, arguments);
|
|
1035
1129
|
}
|
|
1036
1130
|
return createApiForChain;
|
|
@@ -1040,49 +1134,49 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1040
1134
|
value: function resolveDefaultFeeAsset(_ref1) {
|
|
1041
1135
|
var chain = _ref1.chain,
|
|
1042
1136
|
feeAsset = _ref1.feeAsset;
|
|
1043
|
-
return feeAsset !== null && feeAsset !== void 0 ? feeAsset :
|
|
1137
|
+
return feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrowImpl(chain, this._customCtx);
|
|
1044
1138
|
}
|
|
1045
1139
|
}, {
|
|
1046
1140
|
key: "resolveFeeAsset",
|
|
1047
1141
|
value: function () {
|
|
1048
|
-
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1142
|
+
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
|
|
1049
1143
|
var chain, address, feeAsset, assetId;
|
|
1050
|
-
return _regenerator().w(function (
|
|
1051
|
-
while (1) switch (
|
|
1144
|
+
return _regenerator().w(function (_context1) {
|
|
1145
|
+
while (1) switch (_context1.n) {
|
|
1052
1146
|
case 0:
|
|
1053
1147
|
chain = options.chain, address = options.address, feeAsset = options.feeAsset;
|
|
1054
1148
|
if (!(!chain.startsWith('Hydration') || feeAsset)) {
|
|
1055
|
-
|
|
1149
|
+
_context1.n = 1;
|
|
1056
1150
|
break;
|
|
1057
1151
|
}
|
|
1058
|
-
return
|
|
1152
|
+
return _context1.a(2, {
|
|
1059
1153
|
isCustomAsset: false,
|
|
1060
1154
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1061
1155
|
});
|
|
1062
1156
|
case 1:
|
|
1063
|
-
|
|
1157
|
+
_context1.n = 2;
|
|
1064
1158
|
return this.untypedApi.query.MultiTransactionPayment.AccountCurrencyMap.getValue(address);
|
|
1065
1159
|
case 2:
|
|
1066
|
-
assetId =
|
|
1160
|
+
assetId = _context1.v;
|
|
1067
1161
|
if (!(assetId === undefined)) {
|
|
1068
|
-
|
|
1162
|
+
_context1.n = 3;
|
|
1069
1163
|
break;
|
|
1070
1164
|
}
|
|
1071
|
-
return
|
|
1165
|
+
return _context1.a(2, {
|
|
1072
1166
|
isCustomAsset: false,
|
|
1073
1167
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1074
1168
|
});
|
|
1075
1169
|
case 3:
|
|
1076
|
-
return
|
|
1170
|
+
return _context1.a(2, {
|
|
1077
1171
|
isCustomAsset: true,
|
|
1078
|
-
asset:
|
|
1172
|
+
asset: findAssetInfoOrThrowImpl(chain, {
|
|
1079
1173
|
id: assetId
|
|
1080
|
-
})
|
|
1174
|
+
}, undefined, this._customCtx)
|
|
1081
1175
|
});
|
|
1082
1176
|
}
|
|
1083
|
-
},
|
|
1177
|
+
}, _callee1, this);
|
|
1084
1178
|
}));
|
|
1085
|
-
function resolveFeeAsset(
|
|
1179
|
+
function resolveFeeAsset(_x13) {
|
|
1086
1180
|
return _resolveFeeAsset.apply(this, arguments);
|
|
1087
1181
|
}
|
|
1088
1182
|
return resolveFeeAsset;
|
|
@@ -1090,16 +1184,15 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1090
1184
|
}, {
|
|
1091
1185
|
key: "getDryRunCall",
|
|
1092
1186
|
value: function () {
|
|
1093
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1187
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
|
|
1094
1188
|
var _this2 = this;
|
|
1095
|
-
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin,
|
|
1096
|
-
return _regenerator().w(function (
|
|
1097
|
-
while (1) switch (
|
|
1189
|
+
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, message, isSuccess, resolvedFeeAsset, failureOutputReason, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t3, _t4, _t5;
|
|
1190
|
+
return _regenerator().w(function (_context10) {
|
|
1191
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1098
1192
|
case 0:
|
|
1099
1193
|
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
_context9.n = 1;
|
|
1194
|
+
if (hasDryRunSupportImpl(chain, this._customCtx)) {
|
|
1195
|
+
_context10.n = 1;
|
|
1103
1196
|
break;
|
|
1104
1197
|
}
|
|
1105
1198
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
@@ -1114,21 +1207,21 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1114
1207
|
}
|
|
1115
1208
|
};
|
|
1116
1209
|
if (!useRootOrigin) {
|
|
1117
|
-
|
|
1210
|
+
_context10.n = 3;
|
|
1118
1211
|
break;
|
|
1119
1212
|
}
|
|
1120
|
-
|
|
1213
|
+
_context10.n = 2;
|
|
1121
1214
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1122
1215
|
api: this
|
|
1123
1216
|
}), bypassOptions);
|
|
1124
1217
|
case 2:
|
|
1125
|
-
|
|
1126
|
-
|
|
1218
|
+
_t3 = _context10.v;
|
|
1219
|
+
_context10.n = 4;
|
|
1127
1220
|
break;
|
|
1128
1221
|
case 3:
|
|
1129
|
-
|
|
1222
|
+
_t3 = tx;
|
|
1130
1223
|
case 4:
|
|
1131
|
-
resolvedTx =
|
|
1224
|
+
resolvedTx = _t3;
|
|
1132
1225
|
performDryRunCall = function performDryRunCall(includeVersion) {
|
|
1133
1226
|
var _this2$untypedApi$api;
|
|
1134
1227
|
var callArgs = [basePayload, resolvedTx.decodedCall];
|
|
@@ -1184,41 +1277,41 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1184
1277
|
failureReason: JSON.stringify((_ref10 = (_result$value6 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value6 !== void 0 ? _result$value6 : result) !== null && _ref10 !== void 0 ? _ref10 : 'Unknown error structure', replaceBigInt)
|
|
1185
1278
|
};
|
|
1186
1279
|
};
|
|
1187
|
-
|
|
1188
|
-
|
|
1280
|
+
_context10.p = 5;
|
|
1281
|
+
_context10.n = 6;
|
|
1189
1282
|
return performDryRunCall(false);
|
|
1190
1283
|
case 6:
|
|
1191
|
-
result =
|
|
1192
|
-
|
|
1284
|
+
result = _context10.v;
|
|
1285
|
+
_context10.n = 10;
|
|
1193
1286
|
break;
|
|
1194
1287
|
case 7:
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
message =
|
|
1288
|
+
_context10.p = 7;
|
|
1289
|
+
_t4 = _context10.v;
|
|
1290
|
+
message = _t4 instanceof Error ? _t4.message : String(_t4);
|
|
1198
1291
|
if (!message.includes('Incompatible runtime entry')) {
|
|
1199
|
-
|
|
1292
|
+
_context10.n = 9;
|
|
1200
1293
|
break;
|
|
1201
1294
|
}
|
|
1202
|
-
|
|
1295
|
+
_context10.n = 8;
|
|
1203
1296
|
return performDryRunCall(true);
|
|
1204
1297
|
case 8:
|
|
1205
|
-
result =
|
|
1206
|
-
|
|
1298
|
+
result = _context10.v;
|
|
1299
|
+
_context10.n = 10;
|
|
1207
1300
|
break;
|
|
1208
1301
|
case 9:
|
|
1209
|
-
throw
|
|
1302
|
+
throw _t4;
|
|
1210
1303
|
case 10:
|
|
1211
1304
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1212
|
-
|
|
1305
|
+
_context10.n = 11;
|
|
1213
1306
|
return this.resolveFeeAsset(options);
|
|
1214
1307
|
case 11:
|
|
1215
|
-
resolvedFeeAsset =
|
|
1308
|
+
resolvedFeeAsset = _context10.v;
|
|
1216
1309
|
if (isSuccess) {
|
|
1217
|
-
|
|
1310
|
+
_context10.n = 12;
|
|
1218
1311
|
break;
|
|
1219
1312
|
}
|
|
1220
1313
|
failureOutputReason = extractFailureReasonFromResult(result);
|
|
1221
|
-
return
|
|
1314
|
+
return _context10.a(2, Promise.resolve({
|
|
1222
1315
|
success: false,
|
|
1223
1316
|
failureReason: failureOutputReason.failureReason,
|
|
1224
1317
|
failureSubReason: failureOutputReason.failureSubReason,
|
|
@@ -1233,33 +1326,33 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1233
1326
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1234
1327
|
destParaId = extractDestParaId(forwardedXcms);
|
|
1235
1328
|
USE_XCM_PAYMENT_API_CHAINS = ['Astar'];
|
|
1236
|
-
if (!(
|
|
1237
|
-
|
|
1329
|
+
if (!(hasXcmPaymentApiSupportImpl(chain, this._customCtx) && result.value.local_xcm && (feeAsset || USE_XCM_PAYMENT_API_CHAINS.includes(chain) || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
1330
|
+
_context10.n = 18;
|
|
1238
1331
|
break;
|
|
1239
1332
|
}
|
|
1240
1333
|
if (result.value.local_xcm) {
|
|
1241
|
-
|
|
1334
|
+
_context10.n = 14;
|
|
1242
1335
|
break;
|
|
1243
1336
|
}
|
|
1244
|
-
|
|
1337
|
+
_context10.n = 13;
|
|
1245
1338
|
return this.getPaymentInfo(tx, address);
|
|
1246
1339
|
case 13:
|
|
1247
|
-
|
|
1248
|
-
|
|
1340
|
+
_t5 = _context10.v.weight;
|
|
1341
|
+
_context10.n = 15;
|
|
1249
1342
|
break;
|
|
1250
1343
|
case 14:
|
|
1251
|
-
|
|
1344
|
+
_t5 = undefined;
|
|
1252
1345
|
case 15:
|
|
1253
|
-
overriddenWeight =
|
|
1254
|
-
|
|
1346
|
+
overriddenWeight = _t5;
|
|
1347
|
+
_context10.n = 16;
|
|
1255
1348
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
1256
1349
|
case 16:
|
|
1257
|
-
xcmFee =
|
|
1350
|
+
xcmFee = _context10.v;
|
|
1258
1351
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1259
|
-
|
|
1352
|
+
_context10.n = 17;
|
|
1260
1353
|
break;
|
|
1261
1354
|
}
|
|
1262
|
-
return
|
|
1355
|
+
return _context10.a(2, Promise.resolve({
|
|
1263
1356
|
success: true,
|
|
1264
1357
|
fee: xcmFee,
|
|
1265
1358
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1273,13 +1366,13 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1273
1366
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1274
1367
|
};
|
|
1275
1368
|
case 18:
|
|
1276
|
-
|
|
1369
|
+
_context10.n = 19;
|
|
1277
1370
|
return this.getPaymentInfo(tx, address);
|
|
1278
1371
|
case 19:
|
|
1279
|
-
_yield$this$getPaymen =
|
|
1372
|
+
_yield$this$getPaymen = _context10.v;
|
|
1280
1373
|
executionFee = _yield$this$getPaymen.partialFee;
|
|
1281
1374
|
fee = computeOriginFee(result, chain, executionFee, !!feeAsset);
|
|
1282
|
-
return
|
|
1375
|
+
return _context10.a(2, Promise.resolve({
|
|
1283
1376
|
success: true,
|
|
1284
1377
|
fee: fee,
|
|
1285
1378
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1288,9 +1381,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1288
1381
|
destParaId: destParaId
|
|
1289
1382
|
}));
|
|
1290
1383
|
}
|
|
1291
|
-
},
|
|
1384
|
+
}, _callee10, this, [[5, 7]]);
|
|
1292
1385
|
}));
|
|
1293
|
-
function getDryRunCall(
|
|
1386
|
+
function getDryRunCall(_x14) {
|
|
1294
1387
|
return _getDryRunCall.apply(this, arguments);
|
|
1295
1388
|
}
|
|
1296
1389
|
return getDryRunCall;
|
|
@@ -1298,31 +1391,31 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1298
1391
|
}, {
|
|
1299
1392
|
key: "getXcmWeight",
|
|
1300
1393
|
value: function () {
|
|
1301
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1394
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(xcm) {
|
|
1302
1395
|
var weightRes, success, value, ref_time, proof_size;
|
|
1303
|
-
return _regenerator().w(function (
|
|
1304
|
-
while (1) switch (
|
|
1396
|
+
return _regenerator().w(function (_context11) {
|
|
1397
|
+
while (1) switch (_context11.n) {
|
|
1305
1398
|
case 0:
|
|
1306
|
-
|
|
1399
|
+
_context11.n = 1;
|
|
1307
1400
|
return this.untypedApi.apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1308
1401
|
case 1:
|
|
1309
|
-
weightRes =
|
|
1402
|
+
weightRes = _context11.v;
|
|
1310
1403
|
success = weightRes.success, value = weightRes.value;
|
|
1311
1404
|
if (success) {
|
|
1312
|
-
|
|
1405
|
+
_context11.n = 2;
|
|
1313
1406
|
break;
|
|
1314
1407
|
}
|
|
1315
1408
|
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(value)));
|
|
1316
1409
|
case 2:
|
|
1317
1410
|
ref_time = value.ref_time, proof_size = value.proof_size;
|
|
1318
|
-
return
|
|
1411
|
+
return _context11.a(2, {
|
|
1319
1412
|
refTime: ref_time,
|
|
1320
1413
|
proofSize: proof_size
|
|
1321
1414
|
});
|
|
1322
1415
|
}
|
|
1323
|
-
},
|
|
1416
|
+
}, _callee11, this);
|
|
1324
1417
|
}));
|
|
1325
|
-
function getXcmWeight(
|
|
1418
|
+
function getXcmWeight(_x15) {
|
|
1326
1419
|
return _getXcmWeight.apply(this, arguments);
|
|
1327
1420
|
}
|
|
1328
1421
|
return getXcmWeight;
|
|
@@ -1330,86 +1423,86 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1330
1423
|
}, {
|
|
1331
1424
|
key: "getDeliveryFee",
|
|
1332
1425
|
value: function () {
|
|
1333
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1426
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
1334
1427
|
var _deliveryFeeRes, _deliveryFeeRes2, _deliveryFeeRes3;
|
|
1335
|
-
var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, assetId, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res,
|
|
1336
|
-
return _regenerator().w(function (
|
|
1337
|
-
while (1) switch (
|
|
1428
|
+
var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, assetId, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res, _t6, _t7;
|
|
1429
|
+
return _regenerator().w(function (_context12) {
|
|
1430
|
+
while (1) switch (_context12.p = _context12.n) {
|
|
1338
1431
|
case 0:
|
|
1339
1432
|
xcmPaymentApi = this.untypedApi.apis.XcmPaymentApi;
|
|
1340
1433
|
usedThirdParam = false;
|
|
1341
1434
|
if (!(forwardedXcm.length > 0)) {
|
|
1342
|
-
|
|
1435
|
+
_context12.n = 6;
|
|
1343
1436
|
break;
|
|
1344
1437
|
}
|
|
1345
1438
|
baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
|
|
1346
|
-
|
|
1347
|
-
|
|
1439
|
+
_context12.p = 1;
|
|
1440
|
+
_context12.n = 2;
|
|
1348
1441
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs);
|
|
1349
1442
|
case 2:
|
|
1350
|
-
deliveryFeeRes =
|
|
1351
|
-
|
|
1443
|
+
deliveryFeeRes = _context12.v;
|
|
1444
|
+
_context12.n = 6;
|
|
1352
1445
|
break;
|
|
1353
1446
|
case 3:
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
message =
|
|
1447
|
+
_context12.p = 3;
|
|
1448
|
+
_t6 = _context12.v;
|
|
1449
|
+
message = _t6 instanceof Error ? _t6.message : String(_t6); // Some runtimes require the 3rd arg
|
|
1357
1450
|
if (!message.includes('Incompatible runtime entry')) {
|
|
1358
|
-
|
|
1451
|
+
_context12.n = 5;
|
|
1359
1452
|
break;
|
|
1360
1453
|
}
|
|
1361
1454
|
usedThirdParam = true;
|
|
1362
1455
|
assetId = createAssetId(version, assetLocalizedLoc);
|
|
1363
1456
|
transformedAssetLoc = _transform(addXcmVersionHeader(assetId, version));
|
|
1364
|
-
|
|
1457
|
+
_context12.n = 4;
|
|
1365
1458
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs.concat([transformedAssetLoc]));
|
|
1366
1459
|
case 4:
|
|
1367
|
-
deliveryFeeRes =
|
|
1368
|
-
|
|
1460
|
+
deliveryFeeRes = _context12.v;
|
|
1461
|
+
_context12.n = 6;
|
|
1369
1462
|
break;
|
|
1370
1463
|
case 5:
|
|
1371
|
-
throw
|
|
1464
|
+
throw _t6;
|
|
1372
1465
|
case 6:
|
|
1373
1466
|
if (!(((_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 || (_deliveryFeeRes = _deliveryFeeRes.value) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.type) === 'Unimplemented')) {
|
|
1374
|
-
|
|
1467
|
+
_context12.n = 7;
|
|
1375
1468
|
break;
|
|
1376
1469
|
}
|
|
1377
|
-
return
|
|
1470
|
+
return _context12.a(2, 0n);
|
|
1378
1471
|
case 7:
|
|
1379
1472
|
deliveryFeeResolved = ((_deliveryFeeRes2 = deliveryFeeRes) === null || _deliveryFeeRes2 === void 0 || (_deliveryFeeRes2 = _deliveryFeeRes2.value) === null || _deliveryFeeRes2 === void 0 ? void 0 : _deliveryFeeRes2.value.length) > 0 ? (_deliveryFeeRes3 = deliveryFeeRes) === null || _deliveryFeeRes3 === void 0 || (_deliveryFeeRes3 = _deliveryFeeRes3.value) === null || _deliveryFeeRes3 === void 0 ? void 0 : _deliveryFeeRes3.value[0].fun.value : 0n;
|
|
1380
|
-
nativeAsset =
|
|
1473
|
+
nativeAsset = findNativeAssetInfoOrThrowImpl(chain, this._customCtx);
|
|
1381
1474
|
if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
|
|
1382
|
-
|
|
1475
|
+
_context12.n = 8;
|
|
1383
1476
|
break;
|
|
1384
1477
|
}
|
|
1385
|
-
return
|
|
1478
|
+
return _context12.a(2, deliveryFeeResolved);
|
|
1386
1479
|
case 8:
|
|
1387
|
-
|
|
1388
|
-
|
|
1480
|
+
_context12.p = 8;
|
|
1481
|
+
_context12.n = 9;
|
|
1389
1482
|
return this.queryRuntimeApi({
|
|
1390
1483
|
module: 'AssetConversionApi',
|
|
1391
1484
|
method: 'quote_price_exact_tokens_for_tokens',
|
|
1392
1485
|
params: [localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false]
|
|
1393
1486
|
});
|
|
1394
1487
|
case 9:
|
|
1395
|
-
res =
|
|
1396
|
-
return
|
|
1488
|
+
res = _context12.v;
|
|
1489
|
+
return _context12.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
1397
1490
|
case 10:
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
if (!(
|
|
1401
|
-
|
|
1491
|
+
_context12.p = 10;
|
|
1492
|
+
_t7 = _context12.v;
|
|
1493
|
+
if (!(_t7 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t7.message))) {
|
|
1494
|
+
_context12.n = 11;
|
|
1402
1495
|
break;
|
|
1403
1496
|
}
|
|
1404
|
-
return
|
|
1497
|
+
return _context12.a(2, 0n);
|
|
1405
1498
|
case 11:
|
|
1406
|
-
return
|
|
1499
|
+
return _context12.a(2, 0n);
|
|
1407
1500
|
case 12:
|
|
1408
|
-
return
|
|
1501
|
+
return _context12.a(2);
|
|
1409
1502
|
}
|
|
1410
|
-
},
|
|
1503
|
+
}, _callee12, this, [[8, 10], [1, 3]]);
|
|
1411
1504
|
}));
|
|
1412
|
-
function getDeliveryFee(
|
|
1505
|
+
function getDeliveryFee(_x16, _x17, _x18, _x19, _x20) {
|
|
1413
1506
|
return _getDeliveryFee.apply(this, arguments);
|
|
1414
1507
|
}
|
|
1415
1508
|
return getDeliveryFee;
|
|
@@ -1417,7 +1510,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1417
1510
|
}, {
|
|
1418
1511
|
key: "getXcmPaymentApiFee",
|
|
1419
1512
|
value: function () {
|
|
1420
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1513
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, localXcm, forwardedXcm, asset, version) {
|
|
1421
1514
|
var _this3 = this,
|
|
1422
1515
|
_execFeeRes$value;
|
|
1423
1516
|
var transformXcm,
|
|
@@ -1433,85 +1526,85 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1433
1526
|
execFee,
|
|
1434
1527
|
bridgeHubExecFee,
|
|
1435
1528
|
deliveryFee,
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
return _regenerator().w(function (
|
|
1439
|
-
while (1) switch (
|
|
1529
|
+
_args13 = arguments,
|
|
1530
|
+
_t8;
|
|
1531
|
+
return _regenerator().w(function (_context14) {
|
|
1532
|
+
while (1) switch (_context14.n) {
|
|
1440
1533
|
case 0:
|
|
1441
|
-
transformXcm =
|
|
1442
|
-
overridenWeight =
|
|
1534
|
+
transformXcm = _args13.length > 5 && _args13[5] !== undefined ? _args13[5] : false;
|
|
1535
|
+
overridenWeight = _args13.length > 6 ? _args13[6] : undefined;
|
|
1443
1536
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1444
1537
|
queryWeight = /*#__PURE__*/function () {
|
|
1445
|
-
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1538
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1446
1539
|
var weightRes;
|
|
1447
|
-
return _regenerator().w(function (
|
|
1448
|
-
while (1) switch (
|
|
1540
|
+
return _regenerator().w(function (_context13) {
|
|
1541
|
+
while (1) switch (_context13.n) {
|
|
1449
1542
|
case 0:
|
|
1450
|
-
|
|
1543
|
+
_context13.n = 1;
|
|
1451
1544
|
return _this3.untypedApi.apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1452
1545
|
case 1:
|
|
1453
|
-
weightRes =
|
|
1546
|
+
weightRes = _context13.v;
|
|
1454
1547
|
if (weightRes.success) {
|
|
1455
|
-
|
|
1548
|
+
_context13.n = 2;
|
|
1456
1549
|
break;
|
|
1457
1550
|
}
|
|
1458
1551
|
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(weightRes.value)));
|
|
1459
1552
|
case 2:
|
|
1460
|
-
return
|
|
1553
|
+
return _context13.a(2, weightRes.value);
|
|
1461
1554
|
}
|
|
1462
|
-
},
|
|
1555
|
+
}, _callee13);
|
|
1463
1556
|
}));
|
|
1464
1557
|
return function queryWeight() {
|
|
1465
1558
|
return _ref11.apply(this, arguments);
|
|
1466
1559
|
};
|
|
1467
1560
|
}();
|
|
1468
1561
|
if (!overridenWeight) {
|
|
1469
|
-
|
|
1562
|
+
_context14.n = 1;
|
|
1470
1563
|
break;
|
|
1471
1564
|
}
|
|
1472
|
-
|
|
1565
|
+
_t8 = {
|
|
1473
1566
|
proof_size: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.proofSize,
|
|
1474
1567
|
ref_time: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.refTime
|
|
1475
1568
|
};
|
|
1476
|
-
|
|
1569
|
+
_context14.n = 3;
|
|
1477
1570
|
break;
|
|
1478
1571
|
case 1:
|
|
1479
|
-
|
|
1572
|
+
_context14.n = 2;
|
|
1480
1573
|
return queryWeight();
|
|
1481
1574
|
case 2:
|
|
1482
|
-
|
|
1575
|
+
_t8 = _context14.v;
|
|
1483
1576
|
case 3:
|
|
1484
|
-
weight =
|
|
1577
|
+
weight = _t8;
|
|
1485
1578
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1486
1579
|
assetId = createAssetId(version, assetLocalizedLoc);
|
|
1487
1580
|
versionedAssetId = addXcmVersionHeader(assetId, version);
|
|
1488
1581
|
transformedAssetLoc = _transform(versionedAssetId);
|
|
1489
|
-
|
|
1582
|
+
_context14.n = 4;
|
|
1490
1583
|
return this.untypedApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weight, transformedAssetLoc);
|
|
1491
1584
|
case 4:
|
|
1492
|
-
execFeeRes =
|
|
1585
|
+
execFeeRes = _context14.v;
|
|
1493
1586
|
execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === 'bigint' ? execFeeRes.value : 0n;
|
|
1494
1587
|
if (!(chain.startsWith('BridgeHub') && (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.success) === false && (execFeeRes === null || execFeeRes === void 0 || (_execFeeRes$value = execFeeRes.value) === null || _execFeeRes$value === void 0 ? void 0 : _execFeeRes$value.type) === 'AssetNotFound')) {
|
|
1495
|
-
|
|
1588
|
+
_context14.n = 6;
|
|
1496
1589
|
break;
|
|
1497
1590
|
}
|
|
1498
|
-
|
|
1591
|
+
_context14.n = 5;
|
|
1499
1592
|
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
1500
1593
|
case 5:
|
|
1501
|
-
bridgeHubExecFee =
|
|
1594
|
+
bridgeHubExecFee = _context14.v;
|
|
1502
1595
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
1503
1596
|
execFee = bridgeHubExecFee;
|
|
1504
1597
|
}
|
|
1505
1598
|
case 6:
|
|
1506
|
-
|
|
1599
|
+
_context14.n = 7;
|
|
1507
1600
|
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
1508
1601
|
case 7:
|
|
1509
|
-
deliveryFee =
|
|
1510
|
-
return
|
|
1602
|
+
deliveryFee = _context14.v;
|
|
1603
|
+
return _context14.a(2, execFee + deliveryFee);
|
|
1511
1604
|
}
|
|
1512
|
-
},
|
|
1605
|
+
}, _callee14, this);
|
|
1513
1606
|
}));
|
|
1514
|
-
function getXcmPaymentApiFee(
|
|
1607
|
+
function getXcmPaymentApiFee(_x21, _x22, _x23, _x24, _x25) {
|
|
1515
1608
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1516
1609
|
}
|
|
1517
1610
|
return getXcmPaymentApiFee;
|
|
@@ -1519,49 +1612,49 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1519
1612
|
}, {
|
|
1520
1613
|
key: "getBridgeHubFallbackExecFee",
|
|
1521
1614
|
value: function () {
|
|
1522
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1615
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(chain, weightValue, asset, version) {
|
|
1523
1616
|
var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1524
|
-
return _regenerator().w(function (
|
|
1525
|
-
while (1) switch (
|
|
1617
|
+
return _regenerator().w(function (_context15) {
|
|
1618
|
+
while (1) switch (_context15.n) {
|
|
1526
1619
|
case 0:
|
|
1527
|
-
|
|
1620
|
+
_context15.n = 1;
|
|
1528
1621
|
return this.untypedApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
|
|
1529
1622
|
type: version,
|
|
1530
1623
|
value: _transform(RELAY_LOCATION)
|
|
1531
1624
|
});
|
|
1532
1625
|
case 1:
|
|
1533
|
-
fallbackExecFeeRes =
|
|
1626
|
+
fallbackExecFeeRes = _context15.v;
|
|
1534
1627
|
if (!(typeof (fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value) !== 'bigint')) {
|
|
1535
|
-
|
|
1628
|
+
_context15.n = 2;
|
|
1536
1629
|
break;
|
|
1537
1630
|
}
|
|
1538
|
-
return
|
|
1631
|
+
return _context15.a(2, undefined);
|
|
1539
1632
|
case 2:
|
|
1540
1633
|
ahApi = this.clone();
|
|
1541
|
-
assetHubChain = "AssetHub".concat(
|
|
1542
|
-
|
|
1634
|
+
assetHubChain = "AssetHub".concat(getRelayChainOfImpl(this, chain));
|
|
1635
|
+
_context15.n = 3;
|
|
1543
1636
|
return ahApi.init(assetHubChain);
|
|
1544
1637
|
case 3:
|
|
1545
1638
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1546
|
-
|
|
1639
|
+
_context15.n = 4;
|
|
1547
1640
|
return ahApi.queryRuntimeApi({
|
|
1548
1641
|
module: 'AssetConversionApi',
|
|
1549
1642
|
method: 'quote_price_exact_tokens_for_tokens',
|
|
1550
1643
|
params: [RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false]
|
|
1551
1644
|
});
|
|
1552
1645
|
case 4:
|
|
1553
|
-
convertedExecFee =
|
|
1646
|
+
convertedExecFee = _context15.v;
|
|
1554
1647
|
if (!(convertedExecFee !== undefined)) {
|
|
1555
|
-
|
|
1648
|
+
_context15.n = 5;
|
|
1556
1649
|
break;
|
|
1557
1650
|
}
|
|
1558
|
-
return
|
|
1651
|
+
return _context15.a(2, convertedExecFee);
|
|
1559
1652
|
case 5:
|
|
1560
|
-
return
|
|
1653
|
+
return _context15.a(2, undefined);
|
|
1561
1654
|
}
|
|
1562
|
-
},
|
|
1655
|
+
}, _callee15, this);
|
|
1563
1656
|
}));
|
|
1564
|
-
function getBridgeHubFallbackExecFee(
|
|
1657
|
+
function getBridgeHubFallbackExecFee(_x26, _x27, _x28, _x29) {
|
|
1565
1658
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1566
1659
|
}
|
|
1567
1660
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1569,32 +1662,31 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1569
1662
|
}, {
|
|
1570
1663
|
key: "getDryRunXcm",
|
|
1571
1664
|
value: function () {
|
|
1572
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1665
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref12) {
|
|
1573
1666
|
var _ref13, _processAssetsDeposit, _ref14, _ref15, _ref16, _ref17, _ref18;
|
|
1574
|
-
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version,
|
|
1575
|
-
return _regenerator().w(function (
|
|
1576
|
-
while (1) switch (
|
|
1667
|
+
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, transformedOriginLocation, result, isSuccess, failureReason, execResult, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, feeEventValue, fee, processedFee;
|
|
1668
|
+
return _regenerator().w(function (_context16) {
|
|
1669
|
+
while (1) switch (_context16.n) {
|
|
1577
1670
|
case 0:
|
|
1578
1671
|
originLocation = _ref12.originLocation, xcm = _ref12.xcm, chain = _ref12.chain, origin = _ref12.origin, asset = _ref12.asset, feeAsset = _ref12.feeAsset, originFee = _ref12.originFee, amount = _ref12.amount, version = _ref12.version;
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
_context13.n = 1;
|
|
1672
|
+
if (hasDryRunSupportImpl(chain, this._customCtx)) {
|
|
1673
|
+
_context16.n = 1;
|
|
1582
1674
|
break;
|
|
1583
1675
|
}
|
|
1584
1676
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1585
1677
|
case 1:
|
|
1586
1678
|
transformedOriginLocation = _transform(originLocation);
|
|
1587
|
-
|
|
1679
|
+
_context16.n = 2;
|
|
1588
1680
|
return this.untypedApi.apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1589
1681
|
case 2:
|
|
1590
|
-
result =
|
|
1682
|
+
result = _context16.v;
|
|
1591
1683
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1592
1684
|
if (isSuccess) {
|
|
1593
|
-
|
|
1685
|
+
_context16.n = 3;
|
|
1594
1686
|
break;
|
|
1595
1687
|
}
|
|
1596
1688
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1597
|
-
return
|
|
1689
|
+
return _context16.a(2, {
|
|
1598
1690
|
success: false,
|
|
1599
1691
|
failureReason: failureReason,
|
|
1600
1692
|
asset: asset
|
|
@@ -1607,19 +1699,19 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1607
1699
|
} : undefined;
|
|
1608
1700
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1609
1701
|
destParaId = extractDestParaId(forwardedXcms);
|
|
1610
|
-
if (!(
|
|
1611
|
-
|
|
1702
|
+
if (!(hasXcmPaymentApiSupportImpl(chain, this._customCtx) && asset)) {
|
|
1703
|
+
_context16.n = 5;
|
|
1612
1704
|
break;
|
|
1613
1705
|
}
|
|
1614
|
-
|
|
1706
|
+
_context16.n = 4;
|
|
1615
1707
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1616
1708
|
case 4:
|
|
1617
|
-
_fee =
|
|
1709
|
+
_fee = _context16.v;
|
|
1618
1710
|
if (!(typeof _fee === 'bigint')) {
|
|
1619
|
-
|
|
1711
|
+
_context16.n = 5;
|
|
1620
1712
|
break;
|
|
1621
1713
|
}
|
|
1622
|
-
return
|
|
1714
|
+
return _context16.a(2, {
|
|
1623
1715
|
success: true,
|
|
1624
1716
|
fee: _fee,
|
|
1625
1717
|
asset: asset,
|
|
@@ -1662,10 +1754,10 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1662
1754
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1663
1755
|
});
|
|
1664
1756
|
if (feeEvent) {
|
|
1665
|
-
|
|
1757
|
+
_context16.n = 6;
|
|
1666
1758
|
break;
|
|
1667
1759
|
}
|
|
1668
|
-
return
|
|
1760
|
+
return _context16.a(2, Promise.resolve({
|
|
1669
1761
|
success: false,
|
|
1670
1762
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1671
1763
|
asset: asset
|
|
@@ -1677,7 +1769,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1677
1769
|
fee = amount - originFee - feeEventValue.amount;
|
|
1678
1770
|
}
|
|
1679
1771
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
|
|
1680
|
-
return
|
|
1772
|
+
return _context16.a(2, Promise.resolve({
|
|
1681
1773
|
success: true,
|
|
1682
1774
|
fee: processedFee,
|
|
1683
1775
|
asset: asset,
|
|
@@ -1686,9 +1778,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1686
1778
|
destParaId: destParaId
|
|
1687
1779
|
}));
|
|
1688
1780
|
}
|
|
1689
|
-
},
|
|
1781
|
+
}, _callee16, this);
|
|
1690
1782
|
}));
|
|
1691
|
-
function getDryRunXcm(
|
|
1783
|
+
function getDryRunXcm(_x30) {
|
|
1692
1784
|
return _getDryRunXcm.apply(this, arguments);
|
|
1693
1785
|
}
|
|
1694
1786
|
return getDryRunXcm;
|
|
@@ -1696,24 +1788,74 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1696
1788
|
}, {
|
|
1697
1789
|
key: "getBridgeStatus",
|
|
1698
1790
|
value: function () {
|
|
1699
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1791
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
1700
1792
|
var mode;
|
|
1701
|
-
return _regenerator().w(function (
|
|
1702
|
-
while (1) switch (
|
|
1793
|
+
return _regenerator().w(function (_context17) {
|
|
1794
|
+
while (1) switch (_context17.n) {
|
|
1703
1795
|
case 0:
|
|
1704
|
-
|
|
1796
|
+
_context17.n = 1;
|
|
1705
1797
|
return this.untypedApi.query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1706
1798
|
case 1:
|
|
1707
|
-
mode =
|
|
1708
|
-
return
|
|
1799
|
+
mode = _context17.v;
|
|
1800
|
+
return _context17.a(2, mode.type);
|
|
1709
1801
|
}
|
|
1710
|
-
},
|
|
1802
|
+
}, _callee17, this);
|
|
1711
1803
|
}));
|
|
1712
1804
|
function getBridgeStatus() {
|
|
1713
1805
|
return _getBridgeStatus.apply(this, arguments);
|
|
1714
1806
|
}
|
|
1715
1807
|
return getBridgeStatus;
|
|
1716
1808
|
}()
|
|
1809
|
+
}, {
|
|
1810
|
+
key: "getConstant",
|
|
1811
|
+
value: function () {
|
|
1812
|
+
var _getConstant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(pallet, name) {
|
|
1813
|
+
return _regenerator().w(function (_context18) {
|
|
1814
|
+
while (1) switch (_context18.p = _context18.n) {
|
|
1815
|
+
case 0:
|
|
1816
|
+
_context18.p = 0;
|
|
1817
|
+
_context18.n = 1;
|
|
1818
|
+
return this.untypedApi.constants[pallet][name]();
|
|
1819
|
+
case 1:
|
|
1820
|
+
return _context18.a(2, _context18.v);
|
|
1821
|
+
case 2:
|
|
1822
|
+
_context18.p = 2;
|
|
1823
|
+
_context18.v;
|
|
1824
|
+
return _context18.a(2, undefined);
|
|
1825
|
+
}
|
|
1826
|
+
}, _callee18, this, [[0, 2]]);
|
|
1827
|
+
}));
|
|
1828
|
+
function getConstant(_x31, _x32) {
|
|
1829
|
+
return _getConstant.apply(this, arguments);
|
|
1830
|
+
}
|
|
1831
|
+
return getConstant;
|
|
1832
|
+
}()
|
|
1833
|
+
}, {
|
|
1834
|
+
key: "getSystemProperties",
|
|
1835
|
+
value: function () {
|
|
1836
|
+
var _getSystemProperties = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
1837
|
+
var spec, props;
|
|
1838
|
+
return _regenerator().w(function (_context19) {
|
|
1839
|
+
while (1) switch (_context19.n) {
|
|
1840
|
+
case 0:
|
|
1841
|
+
_context19.n = 1;
|
|
1842
|
+
return this.api.getChainSpecData();
|
|
1843
|
+
case 1:
|
|
1844
|
+
spec = _context19.v;
|
|
1845
|
+
props = spec === null || spec === void 0 ? void 0 : spec.properties;
|
|
1846
|
+
return _context19.a(2, {
|
|
1847
|
+
ss58Format: typeof (props === null || props === void 0 ? void 0 : props.ss58Format) === 'number' ? props.ss58Format : undefined,
|
|
1848
|
+
tokenSymbol: [props === null || props === void 0 ? void 0 : props.tokenSymbol].flat()[0],
|
|
1849
|
+
tokenDecimals: [props === null || props === void 0 ? void 0 : props.tokenDecimals].flat()[0]
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
}, _callee19, this);
|
|
1853
|
+
}));
|
|
1854
|
+
function getSystemProperties() {
|
|
1855
|
+
return _getSystemProperties.apply(this, arguments);
|
|
1856
|
+
}
|
|
1857
|
+
return getSystemProperties;
|
|
1858
|
+
}()
|
|
1717
1859
|
}, {
|
|
1718
1860
|
key: "disconnect",
|
|
1719
1861
|
value: function disconnect() {
|
|
@@ -1731,7 +1873,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1731
1873
|
if (force) {
|
|
1732
1874
|
this.api.destroy();
|
|
1733
1875
|
} else {
|
|
1734
|
-
var key = api === undefined ?
|
|
1876
|
+
var key = api === undefined ? getChainProvidersImpl(this._chain, this._customCtx) : api;
|
|
1735
1877
|
releaseClient(key);
|
|
1736
1878
|
}
|
|
1737
1879
|
}
|
|
@@ -1745,22 +1887,22 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1745
1887
|
}, {
|
|
1746
1888
|
key: "signAndSubmit",
|
|
1747
1889
|
value: function () {
|
|
1748
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1890
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(tx, sender) {
|
|
1749
1891
|
var signer, _yield$tx$signAndSubm, txHash;
|
|
1750
|
-
return _regenerator().w(function (
|
|
1751
|
-
while (1) switch (
|
|
1892
|
+
return _regenerator().w(function (_context20) {
|
|
1893
|
+
while (1) switch (_context20.n) {
|
|
1752
1894
|
case 0:
|
|
1753
1895
|
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1754
|
-
|
|
1896
|
+
_context20.n = 1;
|
|
1755
1897
|
return tx.signAndSubmit(signer);
|
|
1756
1898
|
case 1:
|
|
1757
|
-
_yield$tx$signAndSubm =
|
|
1899
|
+
_yield$tx$signAndSubm = _context20.v;
|
|
1758
1900
|
txHash = _yield$tx$signAndSubm.txHash;
|
|
1759
|
-
return
|
|
1901
|
+
return _context20.a(2, txHash);
|
|
1760
1902
|
}
|
|
1761
|
-
},
|
|
1903
|
+
}, _callee20);
|
|
1762
1904
|
}));
|
|
1763
|
-
function signAndSubmit(
|
|
1905
|
+
function signAndSubmit(_x33, _x34) {
|
|
1764
1906
|
return _signAndSubmit.apply(this, arguments);
|
|
1765
1907
|
}
|
|
1766
1908
|
return signAndSubmit;
|
|
@@ -1768,13 +1910,13 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1768
1910
|
}, {
|
|
1769
1911
|
key: "signAndSubmitFinalized",
|
|
1770
1912
|
value: function () {
|
|
1771
|
-
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1913
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(tx, sender) {
|
|
1772
1914
|
var signer;
|
|
1773
|
-
return _regenerator().w(function (
|
|
1774
|
-
while (1) switch (
|
|
1915
|
+
return _regenerator().w(function (_context21) {
|
|
1916
|
+
while (1) switch (_context21.n) {
|
|
1775
1917
|
case 0:
|
|
1776
1918
|
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1777
|
-
return
|
|
1919
|
+
return _context21.a(2, new Promise(function (resolve, reject) {
|
|
1778
1920
|
tx.signSubmitAndWatch(signer).subscribe({
|
|
1779
1921
|
next: function next(event) {
|
|
1780
1922
|
if (event.type === 'finalized' || event.type === 'txBestBlocksState' && event.found) {
|
|
@@ -1791,9 +1933,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1791
1933
|
});
|
|
1792
1934
|
}));
|
|
1793
1935
|
}
|
|
1794
|
-
},
|
|
1936
|
+
}, _callee21);
|
|
1795
1937
|
}));
|
|
1796
|
-
function signAndSubmitFinalized(
|
|
1938
|
+
function signAndSubmitFinalized(_x35, _x36) {
|
|
1797
1939
|
return _signAndSubmitFinalized.apply(this, arguments);
|
|
1798
1940
|
}
|
|
1799
1941
|
return signAndSubmitFinalized;
|
|
@@ -2007,11 +2149,11 @@ var EvmBuilder$1 = function EvmBuilder(api) {
|
|
|
2007
2149
|
/**
|
|
2008
2150
|
* Creates a new Builder instance.
|
|
2009
2151
|
*
|
|
2010
|
-
* @param
|
|
2152
|
+
* @param options - Either an existing API instance, a WS URL, or a config object.
|
|
2011
2153
|
* @returns A new Builder instance.
|
|
2012
2154
|
*/
|
|
2013
|
-
var Builder = function Builder(
|
|
2014
|
-
var papiApi = new PapiApi(
|
|
2155
|
+
var Builder = function Builder(options) {
|
|
2156
|
+
var papiApi = new PapiApi(options);
|
|
2015
2157
|
return Builder$1(papiApi);
|
|
2016
2158
|
};
|
|
2017
2159
|
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
@@ -2020,6 +2162,43 @@ var EvmBuilder = function EvmBuilder(api) {
|
|
|
2020
2162
|
return EvmBuilder$1(papiApi);
|
|
2021
2163
|
};
|
|
2022
2164
|
|
|
2165
|
+
var hydrateCustomChain = /*#__PURE__*/function () {
|
|
2166
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(name, input) {
|
|
2167
|
+
var api, _api$_customCtx$custo, info;
|
|
2168
|
+
return _regenerator().w(function (_context) {
|
|
2169
|
+
while (1) switch (_context.p = _context.n) {
|
|
2170
|
+
case 0:
|
|
2171
|
+
api = new PapiApi({
|
|
2172
|
+
customChains: _defineProperty({}, name, input)
|
|
2173
|
+
});
|
|
2174
|
+
_context.p = 1;
|
|
2175
|
+
_context.n = 2;
|
|
2176
|
+
return api.init(name);
|
|
2177
|
+
case 2:
|
|
2178
|
+
info = (_api$_customCtx$custo = api._customCtx.customChainAssets) === null || _api$_customCtx$custo === void 0 ? void 0 : _api$_customCtx$custo[name];
|
|
2179
|
+
if (info) {
|
|
2180
|
+
_context.n = 3;
|
|
2181
|
+
break;
|
|
2182
|
+
}
|
|
2183
|
+
throw new CustomChainInvalidError("Custom chain '".concat(name, "' could not be hydrated from its providers."));
|
|
2184
|
+
case 3:
|
|
2185
|
+
return _context.a(2, info);
|
|
2186
|
+
case 4:
|
|
2187
|
+
_context.p = 4;
|
|
2188
|
+
_context.n = 5;
|
|
2189
|
+
return api.disconnect();
|
|
2190
|
+
case 5:
|
|
2191
|
+
return _context.f(4);
|
|
2192
|
+
case 6:
|
|
2193
|
+
return _context.a(2);
|
|
2194
|
+
}
|
|
2195
|
+
}, _callee, null, [[1,, 4, 6]]);
|
|
2196
|
+
}));
|
|
2197
|
+
return function hydrateCustomChain(_x, _x2) {
|
|
2198
|
+
return _ref.apply(this, arguments);
|
|
2199
|
+
};
|
|
2200
|
+
}();
|
|
2201
|
+
|
|
2023
2202
|
var dryRun = createPapiApiCall(dryRun$1);
|
|
2024
2203
|
var dryRunOrigin = createPapiApiCall(dryRunOrigin$1);
|
|
2025
2204
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
@@ -2094,4 +2273,4 @@ var transfer = /*#__PURE__*/Object.freeze({
|
|
|
2094
2273
|
handleSwapExecuteTransfer: handleSwapExecuteTransfer
|
|
2095
2274
|
});
|
|
2096
2275
|
|
|
2097
|
-
export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, _transform as transform, transfer as xcmPallet };
|
|
2276
|
+
export { Builder, EvmBuilder, assets, checkAndConvertToNumberOrBigInt, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getOriginXcmFee, getParaEthTransferFees, getXcmFee, handleSwapExecuteTransfer, hydrateCustomChain, _transform as transform, transfer as xcmPallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.7.0",
|
|
4
4
|
"description": "SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,18 +23,19 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@noble/hashes": "^2.2.0",
|
|
26
|
+
"@polkadot-api/substrate-bindings": "^0.20.3",
|
|
26
27
|
"@polkadot-labs/hdkd": "^0.0.28",
|
|
27
28
|
"@polkadot-labs/hdkd-helpers": "^0.0.30",
|
|
28
|
-
"viem": "^2.
|
|
29
|
-
"@paraspell/sdk-core": "13.
|
|
29
|
+
"viem": "^2.51.3",
|
|
30
|
+
"@paraspell/sdk-core": "13.7.0"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"polkadot-api": ">= 2 < 3"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@acala-network/chopsticks": "^1.
|
|
36
|
-
"@babel/plugin-syntax-import-attributes": "^7.
|
|
37
|
-
"@babel/preset-env": "^7.29.
|
|
36
|
+
"@acala-network/chopsticks": "^1.4.1",
|
|
37
|
+
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|
|
38
|
+
"@babel/preset-env": "^7.29.7",
|
|
38
39
|
"@codecov/rollup-plugin": "^2.0.1",
|
|
39
40
|
"@noble/curves": "^2.2.0",
|
|
40
41
|
"@rollup/plugin-babel": "^7.0.0",
|
|
@@ -42,10 +43,10 @@
|
|
|
42
43
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
43
44
|
"@scure/bip32": "^2.2.0",
|
|
44
45
|
"@scure/bip39": "^2.2.0",
|
|
45
|
-
"@vitest/coverage-v8": "^4.1.
|
|
46
|
-
"axios": "^1.
|
|
46
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
47
|
+
"axios": "^1.16.1",
|
|
47
48
|
"dotenv": "^17.4.2",
|
|
48
|
-
"rollup": "^4.60.
|
|
49
|
+
"rollup": "^4.60.4",
|
|
49
50
|
"rollup-plugin-dts": "^6.4.1",
|
|
50
51
|
"tslib": "^2.8.1"
|
|
51
52
|
},
|