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