@paraspell/sdk 13.1.0 → 13.2.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 +4 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +384 -383
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, Parents, findAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, isRelayChain, padValueBy, isAssetEqual, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
1
|
+
import { getNativeAssetSymbol, getOtherAssets, isSenderSigner, getEvmPrivateKeyHex, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, InvalidAddressError, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, Parents, findAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, RuntimeApiError, localizeLocation, isAssetXcEqual, createAssetId, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, isRelayChain, padValueBy, isAssetEqual, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, getXcmFee as getXcmFee$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
4
4
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
5
5
|
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
|
|
6
6
|
import { sr25519CreateDerive } from '@polkadot-labs/hdkd';
|
|
7
7
|
import { entropyToMiniSecret, mnemonicToEntropy, DEV_PHRASE } from '@polkadot-labs/hdkd-helpers';
|
|
8
|
-
import { AccountId, Binary,
|
|
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 {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { XcmVersionedLocation, XcmV5Junctions } from '@polkadot-api/descriptors';
|
|
12
|
+
import { toHex } from 'polkadot-api/utils';
|
|
13
|
+
import { createWsClient } from 'polkadot-api/ws';
|
|
14
14
|
import { isAddress, isHex } from 'viem';
|
|
15
15
|
|
|
16
16
|
function _arrayLikeToArray(r, a) {
|
|
@@ -450,8 +450,6 @@ var deriveAddress = function deriveAddress(sender) {
|
|
|
450
450
|
return AccountId().dec(keyPair.publicKey);
|
|
451
451
|
};
|
|
452
452
|
|
|
453
|
-
var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'Pendulum'];
|
|
454
|
-
|
|
455
453
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
456
454
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
457
455
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
@@ -527,7 +525,7 @@ var _transform = function transform(obj) {
|
|
|
527
525
|
network: value.network === 'any' ? {
|
|
528
526
|
type: 'Any'
|
|
529
527
|
} : undefined,
|
|
530
|
-
id:
|
|
528
|
+
id: value.id
|
|
531
529
|
}
|
|
532
530
|
};
|
|
533
531
|
} else if (key === 'Id') {
|
|
@@ -576,13 +574,13 @@ var _transform = function transform(obj) {
|
|
|
576
574
|
network: value.network === 'any' ? {
|
|
577
575
|
type: 'Any'
|
|
578
576
|
} : undefined,
|
|
579
|
-
key:
|
|
577
|
+
key: value.key
|
|
580
578
|
}
|
|
581
579
|
};
|
|
582
580
|
} else if (key === 'SetTopic') {
|
|
583
581
|
return {
|
|
584
582
|
type: key,
|
|
585
|
-
value:
|
|
583
|
+
value: value
|
|
586
584
|
};
|
|
587
585
|
} else if (key === 'SetFeesMode') {
|
|
588
586
|
var _value$jit_withdraw;
|
|
@@ -669,7 +667,7 @@ var _transform = function transform(obj) {
|
|
|
669
667
|
if (typeof v === 'string' && isAddress(v)) {
|
|
670
668
|
newObj[k] = v;
|
|
671
669
|
} else if (typeof v === 'string' && v.startsWith('0x')) {
|
|
672
|
-
newObj[k] =
|
|
670
|
+
newObj[k] = v;
|
|
673
671
|
} else if (typeof v === 'string') {
|
|
674
672
|
newObj[k] = {
|
|
675
673
|
type: v
|
|
@@ -709,14 +707,7 @@ var clientPool = createClientCache(MAX_CLIENTS, /*#__PURE__*/function () {
|
|
|
709
707
|
}(), function (_key, entry) {
|
|
710
708
|
entry.client.destroy();
|
|
711
709
|
}, EXTENSION_MS);
|
|
712
|
-
var
|
|
713
|
-
var options = useLegacy ? {
|
|
714
|
-
innerEnhancer: withLegacy()
|
|
715
|
-
} : {};
|
|
716
|
-
var provider = getWsProvider(ws, options);
|
|
717
|
-
return createClient(useLegacy ? provider : withPolkadotSdkCompat(provider));
|
|
718
|
-
};
|
|
719
|
-
var _createClientPoolHelp = createClientPoolHelpers(clientPool, createPolkadotClient),
|
|
710
|
+
var _createClientPoolHelp = createClientPoolHelpers(clientPool, createWsClient),
|
|
720
711
|
leaseClient = _createClientPoolHelp.leaseClient,
|
|
721
712
|
releaseClient = _createClientPoolHelp.releaseClient;
|
|
722
713
|
var extractDryRunXcmFailureReason = function extractDryRunXcmFailureReason(result) {
|
|
@@ -738,6 +729,8 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
738
729
|
_classCallCheck(this, PapiApi);
|
|
739
730
|
_this = _callSuper(this, PapiApi, arguments);
|
|
740
731
|
_this.type = 'PAPI';
|
|
732
|
+
_this._typedApi = null;
|
|
733
|
+
_this._untypedApi = null;
|
|
741
734
|
return _this;
|
|
742
735
|
}
|
|
743
736
|
_inherits(PapiApi, _PolkadotApi);
|
|
@@ -761,8 +754,8 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
761
754
|
this._ttlMs = clientTtlMs;
|
|
762
755
|
this._chain = chain;
|
|
763
756
|
_context2.n = 2;
|
|
764
|
-
return resolveChainApi(this._config, chain, function (wsUrl
|
|
765
|
-
return
|
|
757
|
+
return resolveChainApi(this._config, chain, function (wsUrl) {
|
|
758
|
+
return leaseClient(wsUrl, _this2._ttlMs);
|
|
766
759
|
});
|
|
767
760
|
case 2:
|
|
768
761
|
this._api = _context2.v;
|
|
@@ -776,18 +769,29 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
776
769
|
}
|
|
777
770
|
return init;
|
|
778
771
|
}()
|
|
772
|
+
}, {
|
|
773
|
+
key: "typedApi",
|
|
774
|
+
get: function get() {
|
|
775
|
+
if (!this._typedApi) this._typedApi = this.api.getUnsafeApi();
|
|
776
|
+
return this._typedApi;
|
|
777
|
+
}
|
|
778
|
+
}, {
|
|
779
|
+
key: "untypedApi",
|
|
780
|
+
get: function get() {
|
|
781
|
+
if (!this._untypedApi) this._untypedApi = this.api.getUnsafeApi();
|
|
782
|
+
return this._untypedApi;
|
|
783
|
+
}
|
|
779
784
|
}, {
|
|
780
785
|
key: "createApiInstance",
|
|
781
|
-
value: function createApiInstance(wsUrl
|
|
782
|
-
|
|
783
|
-
return Promise.resolve(leaseClient(wsUrl, this._ttlMs, useLegacy));
|
|
786
|
+
value: function createApiInstance(wsUrl) {
|
|
787
|
+
return Promise.resolve(createWsClient(wsUrl));
|
|
784
788
|
}
|
|
785
789
|
}, {
|
|
786
790
|
key: "accountToHex",
|
|
787
791
|
value: function accountToHex(address) {
|
|
788
792
|
var isPrefixed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
789
793
|
if (isHex(address)) return address;
|
|
790
|
-
var hex =
|
|
794
|
+
var hex = toHex(AccountId().enc(address));
|
|
791
795
|
return isPrefixed ? hex : hex.slice(2);
|
|
792
796
|
}
|
|
793
797
|
}, {
|
|
@@ -812,49 +816,37 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
812
816
|
method = _ref6.method,
|
|
813
817
|
params = _ref6.params;
|
|
814
818
|
var transformedParams = _transform(params);
|
|
815
|
-
return this.
|
|
819
|
+
return this.untypedApi.tx[module][method](transformedParams);
|
|
816
820
|
}
|
|
817
821
|
}, {
|
|
818
822
|
key: "txFromHex",
|
|
819
|
-
value: function () {
|
|
820
|
-
var
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
while (1) switch (_context3.n) {
|
|
824
|
-
case 0:
|
|
825
|
-
callData = Binary.fromHex(hex);
|
|
826
|
-
return _context3.a(2, this.api.getUnsafeApi().txFromCallData(callData));
|
|
827
|
-
}
|
|
828
|
-
}, _callee3, this);
|
|
829
|
-
}));
|
|
830
|
-
function txFromHex(_x3) {
|
|
831
|
-
return _txFromHex.apply(this, arguments);
|
|
832
|
-
}
|
|
833
|
-
return txFromHex;
|
|
834
|
-
}()
|
|
823
|
+
value: function txFromHex(hex) {
|
|
824
|
+
var callData = Binary.fromHex(hex);
|
|
825
|
+
return this.untypedApi.txFromCallData(callData);
|
|
826
|
+
}
|
|
835
827
|
}, {
|
|
836
828
|
key: "queryState",
|
|
837
829
|
value: function queryState(_ref7) {
|
|
838
|
-
var _this$
|
|
830
|
+
var _this$untypedApi$quer;
|
|
839
831
|
var module = _ref7.module,
|
|
840
832
|
method = _ref7.method,
|
|
841
833
|
params = _ref7.params;
|
|
842
|
-
return (_this$
|
|
834
|
+
return (_this$untypedApi$quer = this.untypedApi.query[module][method]).getValue.apply(_this$untypedApi$quer, _toConsumableArray(params.map(_transform)));
|
|
843
835
|
}
|
|
844
836
|
}, {
|
|
845
837
|
key: "queryRuntimeApi",
|
|
846
838
|
value: function queryRuntimeApi(_ref8) {
|
|
847
|
-
var _this$
|
|
839
|
+
var _this$untypedApi$apis;
|
|
848
840
|
var module = _ref8.module,
|
|
849
841
|
method = _ref8.method,
|
|
850
842
|
params = _ref8.params;
|
|
851
|
-
return (_this$
|
|
843
|
+
return (_this$untypedApi$apis = this.untypedApi.apis[module])[method].apply(_this$untypedApi$apis, _toConsumableArray(params.map(_transform)));
|
|
852
844
|
}
|
|
853
845
|
}, {
|
|
854
846
|
key: "callBatchMethod",
|
|
855
847
|
value: function callBatchMethod(calls, mode) {
|
|
856
848
|
var method = mode === BatchMode.BATCH_ALL ? 'batch_all' : 'batch';
|
|
857
|
-
return this.
|
|
849
|
+
return this.untypedApi.tx.Utility[method]({
|
|
858
850
|
calls: calls.map(function (_ref9) {
|
|
859
851
|
var decodedCall = _ref9.decodedCall;
|
|
860
852
|
return decodedCall;
|
|
@@ -872,7 +864,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
872
864
|
value: address
|
|
873
865
|
}
|
|
874
866
|
};
|
|
875
|
-
return this.
|
|
867
|
+
return this.untypedApi.tx.Utility.dispatch_as({
|
|
876
868
|
as_origin: origin,
|
|
877
869
|
call: decodedCall
|
|
878
870
|
});
|
|
@@ -880,36 +872,31 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
880
872
|
}, {
|
|
881
873
|
key: "objectToHex",
|
|
882
874
|
value: function () {
|
|
883
|
-
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
875
|
+
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(obj, _typeName, version) {
|
|
884
876
|
var transformedObj, tx, removeFirst5Bytes, encodedData;
|
|
885
|
-
return _regenerator().w(function (
|
|
886
|
-
while (1) switch (
|
|
877
|
+
return _regenerator().w(function (_context3) {
|
|
878
|
+
while (1) switch (_context3.n) {
|
|
887
879
|
case 0:
|
|
888
880
|
transformedObj = _transform(obj);
|
|
889
|
-
tx = this.
|
|
890
|
-
dest: {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
interior: {
|
|
895
|
-
type: 'Here'
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
},
|
|
881
|
+
tx = this.typedApi.tx.PolkadotXcm.send({
|
|
882
|
+
dest: XcmVersionedLocation[version]({
|
|
883
|
+
parents: Parents.ZERO,
|
|
884
|
+
interior: XcmV5Junctions.Here()
|
|
885
|
+
}),
|
|
899
886
|
message: transformedObj
|
|
900
887
|
});
|
|
901
888
|
removeFirst5Bytes = function removeFirst5Bytes(hexString) {
|
|
902
889
|
return '0x' + hexString.slice(12);
|
|
903
890
|
};
|
|
904
|
-
|
|
891
|
+
_context3.n = 1;
|
|
905
892
|
return tx.getEncodedData();
|
|
906
893
|
case 1:
|
|
907
|
-
encodedData =
|
|
908
|
-
return
|
|
894
|
+
encodedData = _context3.v;
|
|
895
|
+
return _context3.a(2, removeFirst5Bytes(toHex(encodedData)));
|
|
909
896
|
}
|
|
910
|
-
},
|
|
897
|
+
}, _callee3, this);
|
|
911
898
|
}));
|
|
912
|
-
function objectToHex(_x4, _x5
|
|
899
|
+
function objectToHex(_x3, _x4, _x5) {
|
|
913
900
|
return _objectToHex.apply(this, arguments);
|
|
914
901
|
}
|
|
915
902
|
return objectToHex;
|
|
@@ -917,12 +904,12 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
917
904
|
}, {
|
|
918
905
|
key: "hexToUint8a",
|
|
919
906
|
value: function hexToUint8a(hex) {
|
|
920
|
-
return Binary.fromHex(hex)
|
|
907
|
+
return Binary.fromHex(hex);
|
|
921
908
|
}
|
|
922
909
|
}, {
|
|
923
910
|
key: "stringToUint8a",
|
|
924
911
|
value: function stringToUint8a(str) {
|
|
925
|
-
return Binary.fromText(str)
|
|
912
|
+
return Binary.fromText(str);
|
|
926
913
|
}
|
|
927
914
|
}, {
|
|
928
915
|
key: "blake2AsHex",
|
|
@@ -934,30 +921,30 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
934
921
|
}, {
|
|
935
922
|
key: "hasMethod",
|
|
936
923
|
value: function () {
|
|
937
|
-
var _hasMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
924
|
+
var _hasMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(pallet, method) {
|
|
938
925
|
var _t;
|
|
939
|
-
return _regenerator().w(function (
|
|
940
|
-
while (1) switch (
|
|
926
|
+
return _regenerator().w(function (_context4) {
|
|
927
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
941
928
|
case 0:
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
return this.
|
|
929
|
+
_context4.p = 0;
|
|
930
|
+
_context4.n = 1;
|
|
931
|
+
return this.untypedApi.tx[pallet][method]().getEncodedData();
|
|
945
932
|
case 1:
|
|
946
|
-
return
|
|
933
|
+
return _context4.a(2, true);
|
|
947
934
|
case 2:
|
|
948
|
-
|
|
949
|
-
_t =
|
|
935
|
+
_context4.p = 2;
|
|
936
|
+
_t = _context4.v;
|
|
950
937
|
if (!(_t instanceof Error && _t.message.includes("Runtime entry Tx(".concat(pallet, ".").concat(method, ") not found")))) {
|
|
951
|
-
|
|
938
|
+
_context4.n = 3;
|
|
952
939
|
break;
|
|
953
940
|
}
|
|
954
|
-
return
|
|
941
|
+
return _context4.a(2, false);
|
|
955
942
|
case 3:
|
|
956
|
-
return
|
|
943
|
+
return _context4.a(2, true);
|
|
957
944
|
}
|
|
958
|
-
},
|
|
945
|
+
}, _callee4, this, [[0, 2]]);
|
|
959
946
|
}));
|
|
960
|
-
function hasMethod(
|
|
947
|
+
function hasMethod(_x6, _x7) {
|
|
961
948
|
return _hasMethod.apply(this, arguments);
|
|
962
949
|
}
|
|
963
950
|
return hasMethod;
|
|
@@ -976,20 +963,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
976
963
|
}, {
|
|
977
964
|
key: "getPaymentInfo",
|
|
978
965
|
value: function () {
|
|
979
|
-
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
966
|
+
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(tx, address) {
|
|
980
967
|
var _yield$tx$getPaymentI, partial_fee, _yield$tx$getPaymentI2, proof_size, ref_time;
|
|
981
|
-
return _regenerator().w(function (
|
|
982
|
-
while (1) switch (
|
|
968
|
+
return _regenerator().w(function (_context5) {
|
|
969
|
+
while (1) switch (_context5.n) {
|
|
983
970
|
case 0:
|
|
984
|
-
|
|
971
|
+
_context5.n = 1;
|
|
985
972
|
return tx.getPaymentInfo(address);
|
|
986
973
|
case 1:
|
|
987
|
-
_yield$tx$getPaymentI =
|
|
974
|
+
_yield$tx$getPaymentI = _context5.v;
|
|
988
975
|
partial_fee = _yield$tx$getPaymentI.partial_fee;
|
|
989
976
|
_yield$tx$getPaymentI2 = _yield$tx$getPaymentI.weight;
|
|
990
977
|
proof_size = _yield$tx$getPaymentI2.proof_size;
|
|
991
978
|
ref_time = _yield$tx$getPaymentI2.ref_time;
|
|
992
|
-
return
|
|
979
|
+
return _context5.a(2, {
|
|
993
980
|
partialFee: partial_fee,
|
|
994
981
|
weight: {
|
|
995
982
|
proofSize: proof_size,
|
|
@@ -997,9 +984,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
997
984
|
}
|
|
998
985
|
});
|
|
999
986
|
}
|
|
1000
|
-
},
|
|
987
|
+
}, _callee5);
|
|
1001
988
|
}));
|
|
1002
|
-
function getPaymentInfo(
|
|
989
|
+
function getPaymentInfo(_x8, _x9) {
|
|
1003
990
|
return _getPaymentInfo.apply(this, arguments);
|
|
1004
991
|
}
|
|
1005
992
|
return getPaymentInfo;
|
|
@@ -1007,27 +994,27 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1007
994
|
}, {
|
|
1008
995
|
key: "quoteAhPrice",
|
|
1009
996
|
value: function () {
|
|
1010
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
997
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(fromMl, toMl, amountIn) {
|
|
1011
998
|
var includeFee,
|
|
1012
999
|
transformedFromMl,
|
|
1013
1000
|
transformedToMl,
|
|
1014
1001
|
response,
|
|
1015
|
-
|
|
1016
|
-
return _regenerator().w(function (
|
|
1017
|
-
while (1) switch (
|
|
1002
|
+
_args5 = arguments;
|
|
1003
|
+
return _regenerator().w(function (_context6) {
|
|
1004
|
+
while (1) switch (_context6.n) {
|
|
1018
1005
|
case 0:
|
|
1019
|
-
includeFee =
|
|
1006
|
+
includeFee = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : true;
|
|
1020
1007
|
transformedFromMl = _transform(fromMl);
|
|
1021
1008
|
transformedToMl = _transform(toMl);
|
|
1022
|
-
|
|
1023
|
-
return this.
|
|
1009
|
+
_context6.n = 1;
|
|
1010
|
+
return this.typedApi.apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
|
|
1024
1011
|
case 1:
|
|
1025
|
-
response =
|
|
1026
|
-
return
|
|
1012
|
+
response = _context6.v;
|
|
1013
|
+
return _context6.a(2, response ? BigInt(response) : undefined);
|
|
1027
1014
|
}
|
|
1028
|
-
},
|
|
1015
|
+
}, _callee6, this);
|
|
1029
1016
|
}));
|
|
1030
|
-
function quoteAhPrice(_x1, _x10
|
|
1017
|
+
function quoteAhPrice(_x0, _x1, _x10) {
|
|
1031
1018
|
return _quoteAhPrice.apply(this, arguments);
|
|
1032
1019
|
}
|
|
1033
1020
|
return quoteAhPrice;
|
|
@@ -1035,25 +1022,25 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1035
1022
|
}, {
|
|
1036
1023
|
key: "getEvmStorage",
|
|
1037
1024
|
value: function getEvmStorage(contract, slot) {
|
|
1038
|
-
return this.
|
|
1025
|
+
return this.untypedApi.query.EVM.AccountStorages.getKey(contract, slot);
|
|
1039
1026
|
}
|
|
1040
1027
|
}, {
|
|
1041
1028
|
key: "getFromRpc",
|
|
1042
1029
|
value: function () {
|
|
1043
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1030
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(module, method, key) {
|
|
1044
1031
|
var value;
|
|
1045
|
-
return _regenerator().w(function (
|
|
1046
|
-
while (1) switch (
|
|
1032
|
+
return _regenerator().w(function (_context7) {
|
|
1033
|
+
while (1) switch (_context7.n) {
|
|
1047
1034
|
case 0:
|
|
1048
|
-
|
|
1035
|
+
_context7.n = 1;
|
|
1049
1036
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? AccountId().dec(key) : key]);
|
|
1050
1037
|
case 1:
|
|
1051
|
-
value =
|
|
1052
|
-
return
|
|
1038
|
+
value = _context7.v;
|
|
1039
|
+
return _context7.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1053
1040
|
}
|
|
1054
|
-
},
|
|
1041
|
+
}, _callee7, this);
|
|
1055
1042
|
}));
|
|
1056
|
-
function getFromRpc(_x12, _x13
|
|
1043
|
+
function getFromRpc(_x11, _x12, _x13) {
|
|
1057
1044
|
return _getFromRpc.apply(this, arguments);
|
|
1058
1045
|
}
|
|
1059
1046
|
return getFromRpc;
|
|
@@ -1066,20 +1053,20 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1066
1053
|
}, {
|
|
1067
1054
|
key: "createApiForChain",
|
|
1068
1055
|
value: function () {
|
|
1069
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1056
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(chain) {
|
|
1070
1057
|
var api;
|
|
1071
|
-
return _regenerator().w(function (
|
|
1072
|
-
while (1) switch (
|
|
1058
|
+
return _regenerator().w(function (_context8) {
|
|
1059
|
+
while (1) switch (_context8.n) {
|
|
1073
1060
|
case 0:
|
|
1074
1061
|
api = new PapiApi(isConfig(this._config) ? this._config : undefined);
|
|
1075
|
-
|
|
1062
|
+
_context8.n = 1;
|
|
1076
1063
|
return api.init(chain);
|
|
1077
1064
|
case 1:
|
|
1078
|
-
return
|
|
1065
|
+
return _context8.a(2, api);
|
|
1079
1066
|
}
|
|
1080
|
-
},
|
|
1067
|
+
}, _callee8, this);
|
|
1081
1068
|
}));
|
|
1082
|
-
function createApiForChain(
|
|
1069
|
+
function createApiForChain(_x14) {
|
|
1083
1070
|
return _createApiForChain.apply(this, arguments);
|
|
1084
1071
|
}
|
|
1085
1072
|
return createApiForChain;
|
|
@@ -1094,44 +1081,44 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1094
1081
|
}, {
|
|
1095
1082
|
key: "resolveFeeAsset",
|
|
1096
1083
|
value: function () {
|
|
1097
|
-
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1084
|
+
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(options) {
|
|
1098
1085
|
var chain, address, feeAsset, assetId;
|
|
1099
|
-
return _regenerator().w(function (
|
|
1100
|
-
while (1) switch (
|
|
1086
|
+
return _regenerator().w(function (_context9) {
|
|
1087
|
+
while (1) switch (_context9.n) {
|
|
1101
1088
|
case 0:
|
|
1102
1089
|
chain = options.chain, address = options.address, feeAsset = options.feeAsset;
|
|
1103
1090
|
if (!(!chain.startsWith('Hydration') || feeAsset)) {
|
|
1104
|
-
|
|
1091
|
+
_context9.n = 1;
|
|
1105
1092
|
break;
|
|
1106
1093
|
}
|
|
1107
|
-
return
|
|
1094
|
+
return _context9.a(2, {
|
|
1108
1095
|
isCustomAsset: false,
|
|
1109
1096
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1110
1097
|
});
|
|
1111
1098
|
case 1:
|
|
1112
|
-
|
|
1113
|
-
return this.
|
|
1099
|
+
_context9.n = 2;
|
|
1100
|
+
return this.untypedApi.query.MultiTransactionPayment.AccountCurrencyMap.getValue(address);
|
|
1114
1101
|
case 2:
|
|
1115
|
-
assetId =
|
|
1102
|
+
assetId = _context9.v;
|
|
1116
1103
|
if (!(assetId === undefined)) {
|
|
1117
|
-
|
|
1104
|
+
_context9.n = 3;
|
|
1118
1105
|
break;
|
|
1119
1106
|
}
|
|
1120
|
-
return
|
|
1107
|
+
return _context9.a(2, {
|
|
1121
1108
|
isCustomAsset: false,
|
|
1122
1109
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1123
1110
|
});
|
|
1124
1111
|
case 3:
|
|
1125
|
-
return
|
|
1112
|
+
return _context9.a(2, {
|
|
1126
1113
|
isCustomAsset: true,
|
|
1127
1114
|
asset: findAssetInfoOrThrow(chain, {
|
|
1128
1115
|
id: assetId
|
|
1129
1116
|
})
|
|
1130
1117
|
});
|
|
1131
1118
|
}
|
|
1132
|
-
},
|
|
1119
|
+
}, _callee9, this);
|
|
1133
1120
|
}));
|
|
1134
|
-
function resolveFeeAsset(
|
|
1121
|
+
function resolveFeeAsset(_x15) {
|
|
1135
1122
|
return _resolveFeeAsset.apply(this, arguments);
|
|
1136
1123
|
}
|
|
1137
1124
|
return resolveFeeAsset;
|
|
@@ -1139,16 +1126,16 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1139
1126
|
}, {
|
|
1140
1127
|
key: "getDryRunCall",
|
|
1141
1128
|
value: function () {
|
|
1142
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1129
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
|
|
1143
1130
|
var _this3 = this;
|
|
1144
|
-
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result,
|
|
1145
|
-
return _regenerator().w(function (
|
|
1146
|
-
while (1) switch (
|
|
1131
|
+
var tx, chain, destination, address, feeAsset, bypassOptions, version, _options$useRootOrigi, useRootOrigin, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, message, isSuccess, resolvedFeeAsset, failureOutputReason, actualWeight, weight, forwardedXcms, destParaId, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t2, _t3, _t4;
|
|
1132
|
+
return _regenerator().w(function (_context0) {
|
|
1133
|
+
while (1) switch (_context0.p = _context0.n) {
|
|
1147
1134
|
case 0:
|
|
1148
1135
|
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;
|
|
1149
1136
|
_getAssetsObject = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject.supportsDryRunApi;
|
|
1150
1137
|
if (supportsDryRunApi) {
|
|
1151
|
-
|
|
1138
|
+
_context0.n = 1;
|
|
1152
1139
|
break;
|
|
1153
1140
|
}
|
|
1154
1141
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
@@ -1163,41 +1150,30 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1163
1150
|
}
|
|
1164
1151
|
};
|
|
1165
1152
|
if (!useRootOrigin) {
|
|
1166
|
-
|
|
1153
|
+
_context0.n = 3;
|
|
1167
1154
|
break;
|
|
1168
1155
|
}
|
|
1169
|
-
|
|
1156
|
+
_context0.n = 2;
|
|
1170
1157
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1171
1158
|
api: this
|
|
1172
1159
|
}), bypassOptions);
|
|
1173
1160
|
case 2:
|
|
1174
|
-
_t2 =
|
|
1175
|
-
|
|
1161
|
+
_t2 = _context0.v;
|
|
1162
|
+
_context0.n = 4;
|
|
1176
1163
|
break;
|
|
1177
1164
|
case 3:
|
|
1178
1165
|
_t2 = tx;
|
|
1179
1166
|
case 4:
|
|
1180
1167
|
resolvedTx = _t2;
|
|
1181
|
-
performDryRunCall =
|
|
1182
|
-
var
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
versionNum = Number(version.charAt(1));
|
|
1191
|
-
callArgs.push(versionNum);
|
|
1192
|
-
}
|
|
1193
|
-
return _context1.a(2, (_this3$api$getUnsafeA = _this3.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this3$api$getUnsafeA, callArgs));
|
|
1194
|
-
}
|
|
1195
|
-
}, _callee1);
|
|
1196
|
-
}));
|
|
1197
|
-
return function performDryRunCall(_x18) {
|
|
1198
|
-
return _ref10.apply(this, arguments);
|
|
1199
|
-
};
|
|
1200
|
-
}();
|
|
1168
|
+
performDryRunCall = function performDryRunCall(includeVersion) {
|
|
1169
|
+
var _this3$untypedApi$api;
|
|
1170
|
+
var callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1171
|
+
if (includeVersion) {
|
|
1172
|
+
var versionNum = Number(version.charAt(1));
|
|
1173
|
+
callArgs.push(versionNum);
|
|
1174
|
+
}
|
|
1175
|
+
return (_this3$untypedApi$api = _this3.untypedApi.apis.DryRunApi).dry_run_call.apply(_this3$untypedApi$api, callArgs);
|
|
1176
|
+
};
|
|
1201
1177
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
1202
1178
|
var _result$value3;
|
|
1203
1179
|
var errorInEvents = findFailingEvent(result);
|
|
@@ -1227,7 +1203,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1227
1203
|
return result;
|
|
1228
1204
|
};
|
|
1229
1205
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1230
|
-
var _obj$value,
|
|
1206
|
+
var _obj$value, _ref10, _result$value6;
|
|
1231
1207
|
var obj = findFailureObjectFromResult(result);
|
|
1232
1208
|
if (obj !== null && obj !== void 0 && obj.type && obj !== null && obj !== void 0 && (_obj$value = obj.value) !== null && _obj$value !== void 0 && (_obj$value = _obj$value.error) !== null && _obj$value !== void 0 && _obj$value.type) {
|
|
1233
1209
|
return {
|
|
@@ -1241,91 +1217,85 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1241
1217
|
};
|
|
1242
1218
|
}
|
|
1243
1219
|
return {
|
|
1244
|
-
failureReason: JSON.stringify((
|
|
1220
|
+
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)
|
|
1245
1221
|
};
|
|
1246
1222
|
};
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
};
|
|
1250
|
-
_context10.n = 5;
|
|
1223
|
+
_context0.p = 5;
|
|
1224
|
+
_context0.n = 6;
|
|
1251
1225
|
return performDryRunCall(false);
|
|
1252
|
-
case
|
|
1253
|
-
result =
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
_context10.n = 7;
|
|
1226
|
+
case 6:
|
|
1227
|
+
result = _context0.v;
|
|
1228
|
+
_context0.n = 10;
|
|
1229
|
+
break;
|
|
1230
|
+
case 7:
|
|
1231
|
+
_context0.p = 7;
|
|
1232
|
+
_t3 = _context0.v;
|
|
1233
|
+
message = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
1234
|
+
if (!message.includes('Incompatible runtime entry')) {
|
|
1235
|
+
_context0.n = 9;
|
|
1263
1236
|
break;
|
|
1264
1237
|
}
|
|
1265
|
-
|
|
1238
|
+
_context0.n = 8;
|
|
1266
1239
|
return performDryRunCall(true);
|
|
1267
|
-
case
|
|
1268
|
-
result =
|
|
1240
|
+
case 8:
|
|
1241
|
+
result = _context0.v;
|
|
1242
|
+
_context0.n = 10;
|
|
1243
|
+
break;
|
|
1244
|
+
case 9:
|
|
1245
|
+
throw _t3;
|
|
1246
|
+
case 10:
|
|
1269
1247
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1270
|
-
|
|
1271
|
-
failureOutputReason = extractFailureReasonFromResult(result);
|
|
1272
|
-
} else {
|
|
1273
|
-
failureOutputReason = {
|
|
1274
|
-
failureReason: '',
|
|
1275
|
-
failureSubReason: undefined
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
case 7:
|
|
1279
|
-
_context10.n = 8;
|
|
1248
|
+
_context0.n = 11;
|
|
1280
1249
|
return this.resolveFeeAsset(options);
|
|
1281
|
-
case
|
|
1282
|
-
resolvedFeeAsset =
|
|
1250
|
+
case 11:
|
|
1251
|
+
resolvedFeeAsset = _context0.v;
|
|
1283
1252
|
if (isSuccess) {
|
|
1284
|
-
|
|
1253
|
+
_context0.n = 12;
|
|
1285
1254
|
break;
|
|
1286
1255
|
}
|
|
1287
|
-
|
|
1256
|
+
failureOutputReason = extractFailureReasonFromResult(result);
|
|
1257
|
+
return _context0.a(2, Promise.resolve({
|
|
1288
1258
|
success: false,
|
|
1289
1259
|
failureReason: failureOutputReason.failureReason,
|
|
1290
1260
|
failureSubReason: failureOutputReason.failureSubReason,
|
|
1291
1261
|
asset: resolvedFeeAsset.asset
|
|
1292
1262
|
}));
|
|
1293
|
-
case
|
|
1263
|
+
case 12:
|
|
1294
1264
|
actualWeight = result.value.execution_result.value.actual_weight;
|
|
1295
1265
|
weight = actualWeight ? {
|
|
1296
1266
|
refTime: actualWeight.ref_time,
|
|
1297
1267
|
proofSize: actualWeight.proof_size
|
|
1298
1268
|
} : undefined;
|
|
1299
1269
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1300
|
-
destParaId = forwardedXcms
|
|
1270
|
+
destParaId = extractDestParaId(forwardedXcms);
|
|
1301
1271
|
USE_XCM_PAYMENT_API_CHAINS = ['Astar'];
|
|
1302
1272
|
if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && (feeAsset || USE_XCM_PAYMENT_API_CHAINS.includes(chain) || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
1303
|
-
|
|
1273
|
+
_context0.n = 18;
|
|
1304
1274
|
break;
|
|
1305
1275
|
}
|
|
1306
1276
|
if (result.value.local_xcm) {
|
|
1307
|
-
|
|
1277
|
+
_context0.n = 14;
|
|
1308
1278
|
break;
|
|
1309
1279
|
}
|
|
1310
|
-
|
|
1280
|
+
_context0.n = 13;
|
|
1311
1281
|
return this.getPaymentInfo(tx, address);
|
|
1312
|
-
case
|
|
1313
|
-
|
|
1314
|
-
|
|
1282
|
+
case 13:
|
|
1283
|
+
_t4 = _context0.v.weight;
|
|
1284
|
+
_context0.n = 15;
|
|
1315
1285
|
break;
|
|
1316
|
-
case
|
|
1317
|
-
|
|
1318
|
-
case
|
|
1319
|
-
overriddenWeight =
|
|
1320
|
-
|
|
1286
|
+
case 14:
|
|
1287
|
+
_t4 = undefined;
|
|
1288
|
+
case 15:
|
|
1289
|
+
overriddenWeight = _t4;
|
|
1290
|
+
_context0.n = 16;
|
|
1321
1291
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
1322
|
-
case
|
|
1323
|
-
xcmFee =
|
|
1292
|
+
case 16:
|
|
1293
|
+
xcmFee = _context0.v;
|
|
1324
1294
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1325
|
-
|
|
1295
|
+
_context0.n = 17;
|
|
1326
1296
|
break;
|
|
1327
1297
|
}
|
|
1328
|
-
return
|
|
1298
|
+
return _context0.a(2, Promise.resolve({
|
|
1329
1299
|
success: true,
|
|
1330
1300
|
fee: xcmFee,
|
|
1331
1301
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1333,19 +1303,19 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1333
1303
|
forwardedXcms: forwardedXcms,
|
|
1334
1304
|
destParaId: destParaId
|
|
1335
1305
|
}));
|
|
1336
|
-
case
|
|
1306
|
+
case 17:
|
|
1337
1307
|
resolvedFeeAsset = {
|
|
1338
1308
|
isCustomAsset: false,
|
|
1339
1309
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1340
1310
|
};
|
|
1341
|
-
case
|
|
1342
|
-
|
|
1311
|
+
case 18:
|
|
1312
|
+
_context0.n = 19;
|
|
1343
1313
|
return this.getPaymentInfo(tx, address);
|
|
1344
|
-
case
|
|
1345
|
-
_yield$this$getPaymen =
|
|
1314
|
+
case 19:
|
|
1315
|
+
_yield$this$getPaymen = _context0.v;
|
|
1346
1316
|
executionFee = _yield$this$getPaymen.partialFee;
|
|
1347
1317
|
fee = computeOriginFee(result, chain, executionFee, !!feeAsset);
|
|
1348
|
-
return
|
|
1318
|
+
return _context0.a(2, Promise.resolve({
|
|
1349
1319
|
success: true,
|
|
1350
1320
|
fee: fee,
|
|
1351
1321
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1354,9 +1324,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1354
1324
|
destParaId: destParaId
|
|
1355
1325
|
}));
|
|
1356
1326
|
}
|
|
1357
|
-
},
|
|
1327
|
+
}, _callee0, this, [[5, 7]]);
|
|
1358
1328
|
}));
|
|
1359
|
-
function getDryRunCall(
|
|
1329
|
+
function getDryRunCall(_x16) {
|
|
1360
1330
|
return _getDryRunCall.apply(this, arguments);
|
|
1361
1331
|
}
|
|
1362
1332
|
return getDryRunCall;
|
|
@@ -1364,24 +1334,32 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1364
1334
|
}, {
|
|
1365
1335
|
key: "getXcmWeight",
|
|
1366
1336
|
value: function () {
|
|
1367
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1368
|
-
var
|
|
1369
|
-
return _regenerator().w(function (
|
|
1370
|
-
while (1) switch (
|
|
1337
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(xcm) {
|
|
1338
|
+
var _yield$this$typedApi$, success, value, ref_time, proof_size;
|
|
1339
|
+
return _regenerator().w(function (_context1) {
|
|
1340
|
+
while (1) switch (_context1.n) {
|
|
1371
1341
|
case 0:
|
|
1372
|
-
|
|
1373
|
-
return this.
|
|
1342
|
+
_context1.n = 1;
|
|
1343
|
+
return this.typedApi.apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1374
1344
|
case 1:
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1345
|
+
_yield$this$typedApi$ = _context1.v;
|
|
1346
|
+
success = _yield$this$typedApi$.success;
|
|
1347
|
+
value = _yield$this$typedApi$.value;
|
|
1348
|
+
if (success) {
|
|
1349
|
+
_context1.n = 2;
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(value)));
|
|
1353
|
+
case 2:
|
|
1354
|
+
ref_time = value.ref_time, proof_size = value.proof_size;
|
|
1355
|
+
return _context1.a(2, {
|
|
1378
1356
|
refTime: ref_time,
|
|
1379
1357
|
proofSize: proof_size
|
|
1380
1358
|
});
|
|
1381
1359
|
}
|
|
1382
|
-
},
|
|
1360
|
+
}, _callee1, this);
|
|
1383
1361
|
}));
|
|
1384
|
-
function getXcmWeight(
|
|
1362
|
+
function getXcmWeight(_x17) {
|
|
1385
1363
|
return _getXcmWeight.apply(this, arguments);
|
|
1386
1364
|
}
|
|
1387
1365
|
return getXcmWeight;
|
|
@@ -1389,76 +1367,82 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1389
1367
|
}, {
|
|
1390
1368
|
key: "getDeliveryFee",
|
|
1391
1369
|
value: function () {
|
|
1392
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1393
|
-
var _deliveryFeeRes, _deliveryFeeRes2;
|
|
1394
|
-
var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res,
|
|
1395
|
-
return _regenerator().w(function (
|
|
1396
|
-
while (1) switch (
|
|
1370
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
1371
|
+
var _deliveryFeeRes, _deliveryFeeRes2, _deliveryFeeRes3;
|
|
1372
|
+
var xcmPaymentApi, usedThirdParam, deliveryFeeRes, baseArgs, message, assetId, transformedAssetLoc, deliveryFeeResolved, nativeAsset, res, _t5, _t6;
|
|
1373
|
+
return _regenerator().w(function (_context10) {
|
|
1374
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1397
1375
|
case 0:
|
|
1398
|
-
xcmPaymentApi = this.
|
|
1376
|
+
xcmPaymentApi = this.untypedApi.apis.XcmPaymentApi;
|
|
1399
1377
|
usedThirdParam = false;
|
|
1400
1378
|
if (!(forwardedXcm.length > 0)) {
|
|
1401
|
-
|
|
1379
|
+
_context10.n = 6;
|
|
1402
1380
|
break;
|
|
1403
1381
|
}
|
|
1404
1382
|
baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
|
|
1405
|
-
|
|
1406
|
-
|
|
1383
|
+
_context10.p = 1;
|
|
1384
|
+
_context10.n = 2;
|
|
1407
1385
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs);
|
|
1408
1386
|
case 2:
|
|
1409
|
-
deliveryFeeRes =
|
|
1410
|
-
|
|
1387
|
+
deliveryFeeRes = _context10.v;
|
|
1388
|
+
_context10.n = 6;
|
|
1411
1389
|
break;
|
|
1412
1390
|
case 3:
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
message =
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
_context12.n = 5;
|
|
1391
|
+
_context10.p = 3;
|
|
1392
|
+
_t5 = _context10.v;
|
|
1393
|
+
message = _t5 instanceof Error ? _t5.message : String(_t5); // Some runtimes require the 3rd arg
|
|
1394
|
+
if (!message.includes('Incompatible runtime entry')) {
|
|
1395
|
+
_context10.n = 5;
|
|
1419
1396
|
break;
|
|
1420
1397
|
}
|
|
1421
1398
|
usedThirdParam = true;
|
|
1422
|
-
|
|
1423
|
-
|
|
1399
|
+
assetId = createAssetId(version, assetLocalizedLoc);
|
|
1400
|
+
transformedAssetLoc = _transform(addXcmVersionHeader(assetId, version));
|
|
1401
|
+
_context10.n = 4;
|
|
1424
1402
|
return xcmPaymentApi.query_delivery_fees.apply(xcmPaymentApi, baseArgs.concat([transformedAssetLoc]));
|
|
1425
1403
|
case 4:
|
|
1426
|
-
deliveryFeeRes =
|
|
1427
|
-
|
|
1404
|
+
deliveryFeeRes = _context10.v;
|
|
1405
|
+
_context10.n = 6;
|
|
1428
1406
|
break;
|
|
1429
1407
|
case 5:
|
|
1430
|
-
throw
|
|
1408
|
+
throw _t5;
|
|
1431
1409
|
case 6:
|
|
1432
|
-
|
|
1410
|
+
if (!(((_deliveryFeeRes = deliveryFeeRes) === null || _deliveryFeeRes === void 0 || (_deliveryFeeRes = _deliveryFeeRes.value) === null || _deliveryFeeRes === void 0 ? void 0 : _deliveryFeeRes.type) === 'Unimplemented')) {
|
|
1411
|
+
_context10.n = 7;
|
|
1412
|
+
break;
|
|
1413
|
+
}
|
|
1414
|
+
return _context10.a(2, 0n);
|
|
1415
|
+
case 7:
|
|
1416
|
+
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;
|
|
1433
1417
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1434
1418
|
if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
|
|
1435
|
-
|
|
1419
|
+
_context10.n = 8;
|
|
1436
1420
|
break;
|
|
1437
1421
|
}
|
|
1438
|
-
return
|
|
1439
|
-
case 7:
|
|
1440
|
-
_context12.p = 7;
|
|
1441
|
-
_context12.n = 8;
|
|
1442
|
-
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1422
|
+
return _context10.a(2, deliveryFeeResolved);
|
|
1443
1423
|
case 8:
|
|
1444
|
-
|
|
1445
|
-
|
|
1424
|
+
_context10.p = 8;
|
|
1425
|
+
_context10.n = 9;
|
|
1426
|
+
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1446
1427
|
case 9:
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1428
|
+
res = _context10.v;
|
|
1429
|
+
return _context10.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
1430
|
+
case 10:
|
|
1431
|
+
_context10.p = 10;
|
|
1432
|
+
_t6 = _context10.v;
|
|
1433
|
+
if (!(_t6 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t6.message))) {
|
|
1434
|
+
_context10.n = 11;
|
|
1451
1435
|
break;
|
|
1452
1436
|
}
|
|
1453
|
-
return
|
|
1454
|
-
case 10:
|
|
1455
|
-
return _context12.a(2, 0n);
|
|
1437
|
+
return _context10.a(2, 0n);
|
|
1456
1438
|
case 11:
|
|
1457
|
-
return
|
|
1439
|
+
return _context10.a(2, 0n);
|
|
1440
|
+
case 12:
|
|
1441
|
+
return _context10.a(2);
|
|
1458
1442
|
}
|
|
1459
|
-
},
|
|
1443
|
+
}, _callee10, this, [[8, 10], [1, 3]]);
|
|
1460
1444
|
}));
|
|
1461
|
-
function getDeliveryFee(
|
|
1445
|
+
function getDeliveryFee(_x18, _x19, _x20, _x21, _x22) {
|
|
1462
1446
|
return _getDeliveryFee.apply(this, arguments);
|
|
1463
1447
|
}
|
|
1464
1448
|
return getDeliveryFee;
|
|
@@ -1466,7 +1450,7 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1466
1450
|
}, {
|
|
1467
1451
|
key: "getXcmPaymentApiFee",
|
|
1468
1452
|
value: function () {
|
|
1469
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1453
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, localXcm, forwardedXcm, asset, version) {
|
|
1470
1454
|
var _this4 = this,
|
|
1471
1455
|
_execFeeRes$value;
|
|
1472
1456
|
var transformXcm,
|
|
@@ -1475,85 +1459,92 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1475
1459
|
queryWeight,
|
|
1476
1460
|
weight,
|
|
1477
1461
|
assetLocalizedLoc,
|
|
1462
|
+
assetId,
|
|
1463
|
+
versionedAssetId,
|
|
1478
1464
|
transformedAssetLoc,
|
|
1479
1465
|
execFeeRes,
|
|
1480
1466
|
execFee,
|
|
1481
1467
|
bridgeHubExecFee,
|
|
1482
1468
|
deliveryFee,
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return _regenerator().w(function (
|
|
1486
|
-
while (1) switch (
|
|
1469
|
+
_args11 = arguments,
|
|
1470
|
+
_t7;
|
|
1471
|
+
return _regenerator().w(function (_context12) {
|
|
1472
|
+
while (1) switch (_context12.n) {
|
|
1487
1473
|
case 0:
|
|
1488
|
-
transformXcm =
|
|
1489
|
-
overridenWeight =
|
|
1474
|
+
transformXcm = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : false;
|
|
1475
|
+
overridenWeight = _args11.length > 6 ? _args11[6] : undefined;
|
|
1490
1476
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1491
1477
|
queryWeight = /*#__PURE__*/function () {
|
|
1492
|
-
var
|
|
1478
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
1493
1479
|
var weightRes;
|
|
1494
|
-
return _regenerator().w(function (
|
|
1495
|
-
while (1) switch (
|
|
1480
|
+
return _regenerator().w(function (_context11) {
|
|
1481
|
+
while (1) switch (_context11.n) {
|
|
1496
1482
|
case 0:
|
|
1497
|
-
|
|
1498
|
-
return _this4.
|
|
1483
|
+
_context11.n = 1;
|
|
1484
|
+
return _this4.typedApi.apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1499
1485
|
case 1:
|
|
1500
|
-
weightRes =
|
|
1501
|
-
|
|
1486
|
+
weightRes = _context11.v;
|
|
1487
|
+
if (weightRes.success) {
|
|
1488
|
+
_context11.n = 2;
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(weightRes.value)));
|
|
1492
|
+
case 2:
|
|
1493
|
+
return _context11.a(2, weightRes.value);
|
|
1502
1494
|
}
|
|
1503
|
-
},
|
|
1495
|
+
}, _callee11);
|
|
1504
1496
|
}));
|
|
1505
1497
|
return function queryWeight() {
|
|
1506
|
-
return
|
|
1498
|
+
return _ref11.apply(this, arguments);
|
|
1507
1499
|
};
|
|
1508
1500
|
}();
|
|
1509
1501
|
if (!overridenWeight) {
|
|
1510
|
-
|
|
1502
|
+
_context12.n = 1;
|
|
1511
1503
|
break;
|
|
1512
1504
|
}
|
|
1513
|
-
|
|
1505
|
+
_t7 = {
|
|
1514
1506
|
proof_size: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.proofSize,
|
|
1515
1507
|
ref_time: overridenWeight === null || overridenWeight === void 0 ? void 0 : overridenWeight.refTime
|
|
1516
1508
|
};
|
|
1517
|
-
|
|
1509
|
+
_context12.n = 3;
|
|
1518
1510
|
break;
|
|
1519
1511
|
case 1:
|
|
1520
|
-
|
|
1512
|
+
_context12.n = 2;
|
|
1521
1513
|
return queryWeight();
|
|
1522
1514
|
case 2:
|
|
1523
|
-
|
|
1515
|
+
_t7 = _context12.v;
|
|
1524
1516
|
case 3:
|
|
1525
|
-
weight =
|
|
1517
|
+
weight = _t7;
|
|
1526
1518
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
});
|
|
1519
|
+
assetId = createAssetId(version, assetLocalizedLoc);
|
|
1520
|
+
versionedAssetId = addXcmVersionHeader(assetId, version);
|
|
1521
|
+
transformedAssetLoc = _transform(versionedAssetId);
|
|
1522
|
+
_context12.n = 4;
|
|
1523
|
+
return this.typedApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weight, transformedAssetLoc);
|
|
1533
1524
|
case 4:
|
|
1534
|
-
execFeeRes =
|
|
1525
|
+
execFeeRes = _context12.v;
|
|
1535
1526
|
execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === 'bigint' ? execFeeRes.value : 0n;
|
|
1536
1527
|
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')) {
|
|
1537
|
-
|
|
1528
|
+
_context12.n = 6;
|
|
1538
1529
|
break;
|
|
1539
1530
|
}
|
|
1540
|
-
|
|
1531
|
+
_context12.n = 5;
|
|
1541
1532
|
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
1542
1533
|
case 5:
|
|
1543
|
-
bridgeHubExecFee =
|
|
1534
|
+
bridgeHubExecFee = _context12.v;
|
|
1544
1535
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
1545
1536
|
execFee = bridgeHubExecFee;
|
|
1546
1537
|
}
|
|
1547
1538
|
case 6:
|
|
1548
|
-
|
|
1539
|
+
_context12.n = 7;
|
|
1549
1540
|
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
1550
1541
|
case 7:
|
|
1551
|
-
deliveryFee =
|
|
1552
|
-
return
|
|
1542
|
+
deliveryFee = _context12.v;
|
|
1543
|
+
return _context12.a(2, execFee + deliveryFee);
|
|
1553
1544
|
}
|
|
1554
|
-
},
|
|
1545
|
+
}, _callee12, this);
|
|
1555
1546
|
}));
|
|
1556
|
-
function getXcmPaymentApiFee(
|
|
1547
|
+
function getXcmPaymentApiFee(_x23, _x24, _x25, _x26, _x27) {
|
|
1557
1548
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1558
1549
|
}
|
|
1559
1550
|
return getXcmPaymentApiFee;
|
|
@@ -1561,45 +1552,45 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1561
1552
|
}, {
|
|
1562
1553
|
key: "getBridgeHubFallbackExecFee",
|
|
1563
1554
|
value: function () {
|
|
1564
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1555
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(chain, weightValue, asset, version) {
|
|
1565
1556
|
var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1566
|
-
return _regenerator().w(function (
|
|
1567
|
-
while (1) switch (
|
|
1557
|
+
return _regenerator().w(function (_context13) {
|
|
1558
|
+
while (1) switch (_context13.n) {
|
|
1568
1559
|
case 0:
|
|
1569
|
-
|
|
1570
|
-
return this.
|
|
1560
|
+
_context13.n = 1;
|
|
1561
|
+
return this.typedApi.apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
|
|
1571
1562
|
type: version,
|
|
1572
1563
|
value: _transform(RELAY_LOCATION)
|
|
1573
1564
|
});
|
|
1574
1565
|
case 1:
|
|
1575
|
-
fallbackExecFeeRes =
|
|
1566
|
+
fallbackExecFeeRes = _context13.v;
|
|
1576
1567
|
if (!(typeof (fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value) !== 'bigint')) {
|
|
1577
|
-
|
|
1568
|
+
_context13.n = 2;
|
|
1578
1569
|
break;
|
|
1579
1570
|
}
|
|
1580
|
-
return
|
|
1571
|
+
return _context13.a(2, undefined);
|
|
1581
1572
|
case 2:
|
|
1582
1573
|
ahApi = this.clone();
|
|
1583
1574
|
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1584
|
-
|
|
1575
|
+
_context13.n = 3;
|
|
1585
1576
|
return ahApi.init(assetHubChain);
|
|
1586
1577
|
case 3:
|
|
1587
1578
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1588
|
-
|
|
1579
|
+
_context13.n = 4;
|
|
1589
1580
|
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false);
|
|
1590
1581
|
case 4:
|
|
1591
|
-
convertedExecFee =
|
|
1582
|
+
convertedExecFee = _context13.v;
|
|
1592
1583
|
if (!(typeof convertedExecFee === 'bigint')) {
|
|
1593
|
-
|
|
1584
|
+
_context13.n = 5;
|
|
1594
1585
|
break;
|
|
1595
1586
|
}
|
|
1596
|
-
return
|
|
1587
|
+
return _context13.a(2, convertedExecFee);
|
|
1597
1588
|
case 5:
|
|
1598
|
-
return
|
|
1589
|
+
return _context13.a(2, undefined);
|
|
1599
1590
|
}
|
|
1600
|
-
},
|
|
1591
|
+
}, _callee13, this);
|
|
1601
1592
|
}));
|
|
1602
|
-
function getBridgeHubFallbackExecFee(
|
|
1593
|
+
function getBridgeHubFallbackExecFee(_x28, _x29, _x30, _x31) {
|
|
1603
1594
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1604
1595
|
}
|
|
1605
1596
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1607,57 +1598,57 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1607
1598
|
}, {
|
|
1608
1599
|
key: "getDryRunXcm",
|
|
1609
1600
|
value: function () {
|
|
1610
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1611
|
-
var
|
|
1612
|
-
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, _getAssetsObject2, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason,
|
|
1613
|
-
return _regenerator().w(function (
|
|
1614
|
-
while (1) switch (
|
|
1601
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref12) {
|
|
1602
|
+
var _ref13, _processAssetsDeposit, _ref14, _ref15, _ref16, _ref17, _ref18;
|
|
1603
|
+
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, version, _getAssetsObject2, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, execResult, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, feeEventValue, fee, processedFee;
|
|
1604
|
+
return _regenerator().w(function (_context14) {
|
|
1605
|
+
while (1) switch (_context14.n) {
|
|
1615
1606
|
case 0:
|
|
1616
|
-
originLocation =
|
|
1607
|
+
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;
|
|
1617
1608
|
_getAssetsObject2 = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject2.supportsDryRunApi;
|
|
1618
1609
|
if (supportsDryRunApi) {
|
|
1619
|
-
|
|
1610
|
+
_context14.n = 1;
|
|
1620
1611
|
break;
|
|
1621
1612
|
}
|
|
1622
1613
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1623
1614
|
case 1:
|
|
1624
1615
|
transformedOriginLocation = _transform(originLocation);
|
|
1625
|
-
|
|
1626
|
-
return this.
|
|
1616
|
+
_context14.n = 2;
|
|
1617
|
+
return this.typedApi.apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1627
1618
|
case 2:
|
|
1628
|
-
result =
|
|
1619
|
+
result = _context14.v;
|
|
1629
1620
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1630
1621
|
if (isSuccess) {
|
|
1631
|
-
|
|
1622
|
+
_context14.n = 3;
|
|
1632
1623
|
break;
|
|
1633
1624
|
}
|
|
1634
1625
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1635
|
-
return
|
|
1626
|
+
return _context14.a(2, {
|
|
1636
1627
|
success: false,
|
|
1637
1628
|
failureReason: failureReason,
|
|
1638
1629
|
asset: asset
|
|
1639
1630
|
});
|
|
1640
1631
|
case 3:
|
|
1641
|
-
|
|
1642
|
-
weight =
|
|
1643
|
-
refTime:
|
|
1644
|
-
proofSize:
|
|
1632
|
+
execResult = result.value.execution_result;
|
|
1633
|
+
weight = execResult.type === 'Complete' ? {
|
|
1634
|
+
refTime: execResult.value.used.ref_time,
|
|
1635
|
+
proofSize: execResult.value.used.proof_size
|
|
1645
1636
|
} : undefined;
|
|
1646
1637
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1647
|
-
destParaId = forwardedXcms
|
|
1638
|
+
destParaId = extractDestParaId(forwardedXcms);
|
|
1648
1639
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1649
|
-
|
|
1640
|
+
_context14.n = 5;
|
|
1650
1641
|
break;
|
|
1651
1642
|
}
|
|
1652
|
-
|
|
1643
|
+
_context14.n = 4;
|
|
1653
1644
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1654
1645
|
case 4:
|
|
1655
|
-
_fee =
|
|
1646
|
+
_fee = _context14.v;
|
|
1656
1647
|
if (!(typeof _fee === 'bigint')) {
|
|
1657
|
-
|
|
1648
|
+
_context14.n = 5;
|
|
1658
1649
|
break;
|
|
1659
1650
|
}
|
|
1660
|
-
return
|
|
1651
|
+
return _context14.a(2, {
|
|
1661
1652
|
success: true,
|
|
1662
1653
|
fee: _fee,
|
|
1663
1654
|
asset: asset,
|
|
@@ -1670,15 +1661,15 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1670
1661
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1671
1662
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1672
1663
|
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
|
|
1673
|
-
feeAssetFeeEvent = (
|
|
1664
|
+
feeAssetFeeEvent = (_ref13 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1674
1665
|
return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
|
|
1675
|
-
}) : undefined) !== null &&
|
|
1666
|
+
}) : undefined) !== null && _ref13 !== void 0 ? _ref13 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1676
1667
|
return event.type === 'Tokens' && event.value.type === 'Deposited';
|
|
1677
1668
|
}) : undefined;
|
|
1678
1669
|
processedAssetsAmount = chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount, 'Assets', 'Deposited', true) : (_processAssetsDeposit = processAssetsDepositedEvents(emitted, amount, 'Balances', 'Minted', false)) !== null && _processAssetsDeposit !== void 0 ? _processAssetsDeposit : processAssetsDepositedEvents(emitted, amount, 'Balances', 'Issued', false);
|
|
1679
|
-
feeEvent = (_ref15 = (_ref16 = (_ref17 = (_ref18 =
|
|
1670
|
+
feeEvent = (_ref14 = (_ref15 = (_ref16 = (_ref17 = (_ref18 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent : chain === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1680
1671
|
return event.type === 'Balances' && event.value.type === 'Issued';
|
|
1681
|
-
}) : undefined) !== null &&
|
|
1672
|
+
}) : undefined) !== null && _ref18 !== void 0 ? _ref18 : processedAssetsAmount !== undefined ? {
|
|
1682
1673
|
type: 'Assets',
|
|
1683
1674
|
value: {
|
|
1684
1675
|
type: 'Deposited',
|
|
@@ -1686,35 +1677,36 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1686
1677
|
amount: processedAssetsAmount
|
|
1687
1678
|
}
|
|
1688
1679
|
}
|
|
1689
|
-
} : undefined) !== null &&
|
|
1680
|
+
} : undefined) !== null && _ref17 !== void 0 ? _ref17 : origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
|
|
1690
1681
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1691
|
-
}) : undefined) !== null &&
|
|
1682
|
+
}) : undefined) !== null && _ref16 !== void 0 ? _ref16 :
|
|
1692
1683
|
// Prefer to Minted event
|
|
1693
1684
|
reversedEvents.find(function (event) {
|
|
1694
1685
|
return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
|
|
1695
|
-
})) !== null &&
|
|
1686
|
+
})) !== null && _ref15 !== void 0 ? _ref15 :
|
|
1696
1687
|
// Fallback an Issued event
|
|
1697
1688
|
reversedEvents.find(function (event) {
|
|
1698
1689
|
return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
|
|
1699
|
-
})) !== null &&
|
|
1690
|
+
})) !== null && _ref14 !== void 0 ? _ref14 : reversedEvents.find(function (event) {
|
|
1700
1691
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1701
1692
|
});
|
|
1702
1693
|
if (feeEvent) {
|
|
1703
|
-
|
|
1694
|
+
_context14.n = 6;
|
|
1704
1695
|
break;
|
|
1705
1696
|
}
|
|
1706
|
-
return
|
|
1697
|
+
return _context14.a(2, Promise.resolve({
|
|
1707
1698
|
success: false,
|
|
1708
1699
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1709
1700
|
asset: asset
|
|
1710
1701
|
}));
|
|
1711
1702
|
case 6:
|
|
1712
|
-
|
|
1703
|
+
feeEventValue = feeEvent.value.value;
|
|
1704
|
+
fee = feeEvent.type === 'AssetConversion' ? feeEventValue.amount_in : feeEventValue.amount;
|
|
1713
1705
|
if (feeAssetFeeEvent) {
|
|
1714
|
-
fee = amount - originFee -
|
|
1706
|
+
fee = amount - originFee - feeEventValue.amount;
|
|
1715
1707
|
}
|
|
1716
1708
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
|
|
1717
|
-
return
|
|
1709
|
+
return _context14.a(2, Promise.resolve({
|
|
1718
1710
|
success: true,
|
|
1719
1711
|
fee: processedFee,
|
|
1720
1712
|
asset: asset,
|
|
@@ -1723,9 +1715,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1723
1715
|
destParaId: destParaId
|
|
1724
1716
|
}));
|
|
1725
1717
|
}
|
|
1726
|
-
},
|
|
1718
|
+
}, _callee14, this);
|
|
1727
1719
|
}));
|
|
1728
|
-
function getDryRunXcm(
|
|
1720
|
+
function getDryRunXcm(_x32) {
|
|
1729
1721
|
return _getDryRunXcm.apply(this, arguments);
|
|
1730
1722
|
}
|
|
1731
1723
|
return getDryRunXcm;
|
|
@@ -1733,18 +1725,18 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1733
1725
|
}, {
|
|
1734
1726
|
key: "getBridgeStatus",
|
|
1735
1727
|
value: function () {
|
|
1736
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1737
|
-
var
|
|
1738
|
-
return _regenerator().w(function (
|
|
1739
|
-
while (1) switch (
|
|
1728
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1729
|
+
var mode;
|
|
1730
|
+
return _regenerator().w(function (_context15) {
|
|
1731
|
+
while (1) switch (_context15.n) {
|
|
1740
1732
|
case 0:
|
|
1741
|
-
|
|
1742
|
-
return this.
|
|
1733
|
+
_context15.n = 1;
|
|
1734
|
+
return this.untypedApi.query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1743
1735
|
case 1:
|
|
1744
|
-
|
|
1745
|
-
return
|
|
1736
|
+
mode = _context15.v;
|
|
1737
|
+
return _context15.a(2, mode.type);
|
|
1746
1738
|
}
|
|
1747
|
-
},
|
|
1739
|
+
}, _callee15, this);
|
|
1748
1740
|
}));
|
|
1749
1741
|
function getBridgeStatus() {
|
|
1750
1742
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1782,22 +1774,22 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1782
1774
|
}, {
|
|
1783
1775
|
key: "signAndSubmit",
|
|
1784
1776
|
value: function () {
|
|
1785
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1777
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
|
|
1786
1778
|
var signer, _yield$tx$signAndSubm, txHash;
|
|
1787
|
-
return _regenerator().w(function (
|
|
1788
|
-
while (1) switch (
|
|
1779
|
+
return _regenerator().w(function (_context16) {
|
|
1780
|
+
while (1) switch (_context16.n) {
|
|
1789
1781
|
case 0:
|
|
1790
1782
|
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1791
|
-
|
|
1783
|
+
_context16.n = 1;
|
|
1792
1784
|
return tx.signAndSubmit(signer);
|
|
1793
1785
|
case 1:
|
|
1794
|
-
_yield$tx$signAndSubm =
|
|
1786
|
+
_yield$tx$signAndSubm = _context16.v;
|
|
1795
1787
|
txHash = _yield$tx$signAndSubm.txHash;
|
|
1796
|
-
return
|
|
1788
|
+
return _context16.a(2, txHash);
|
|
1797
1789
|
}
|
|
1798
|
-
},
|
|
1790
|
+
}, _callee16);
|
|
1799
1791
|
}));
|
|
1800
|
-
function signAndSubmit(
|
|
1792
|
+
function signAndSubmit(_x33, _x34) {
|
|
1801
1793
|
return _signAndSubmit.apply(this, arguments);
|
|
1802
1794
|
}
|
|
1803
1795
|
return signAndSubmit;
|
|
@@ -1805,13 +1797,13 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1805
1797
|
}, {
|
|
1806
1798
|
key: "signAndSubmitFinalized",
|
|
1807
1799
|
value: function () {
|
|
1808
|
-
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1800
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, sender) {
|
|
1809
1801
|
var signer;
|
|
1810
|
-
return _regenerator().w(function (
|
|
1811
|
-
while (1) switch (
|
|
1802
|
+
return _regenerator().w(function (_context17) {
|
|
1803
|
+
while (1) switch (_context17.n) {
|
|
1812
1804
|
case 0:
|
|
1813
1805
|
signer = isSenderSigner(sender) ? sender : createDevSigner(sender);
|
|
1814
|
-
return
|
|
1806
|
+
return _context17.a(2, new Promise(function (resolve, reject) {
|
|
1815
1807
|
tx.signSubmitAndWatch(signer).subscribe({
|
|
1816
1808
|
next: function next(event) {
|
|
1817
1809
|
if (event.type === 'finalized' || event.type === 'txBestBlocksState' && event.found) {
|
|
@@ -1828,9 +1820,9 @@ var PapiApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1828
1820
|
});
|
|
1829
1821
|
}));
|
|
1830
1822
|
}
|
|
1831
|
-
},
|
|
1823
|
+
}, _callee17);
|
|
1832
1824
|
}));
|
|
1833
|
-
function signAndSubmitFinalized(
|
|
1825
|
+
function signAndSubmitFinalized(_x35, _x36) {
|
|
1834
1826
|
return _signAndSubmitFinalized.apply(this, arguments);
|
|
1835
1827
|
}
|
|
1836
1828
|
return signAndSubmitFinalized;
|
|
@@ -1862,6 +1854,15 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1862
1854
|
};
|
|
1863
1855
|
}();
|
|
1864
1856
|
};
|
|
1857
|
+
var extractDestParaId = function extractDestParaId(forwardedXcms) {
|
|
1858
|
+
if (forwardedXcms.length === 0) return undefined;
|
|
1859
|
+
var interior = forwardedXcms[0].value.interior;
|
|
1860
|
+
if (interior.type === 'Here') return 0;
|
|
1861
|
+
if (interior.type === 'X1' && interior.value.type === 'Parachain') {
|
|
1862
|
+
return interior.value.value;
|
|
1863
|
+
}
|
|
1864
|
+
return undefined;
|
|
1865
|
+
};
|
|
1865
1866
|
var findFailingEvent = function findFailingEvent(result) {
|
|
1866
1867
|
var _result$value;
|
|
1867
1868
|
return (_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.emitted_events) === null || _result$value === void 0 ? void 0 : _result$value.find(function (event) {
|