@paraspell/sdk 11.9.0 → 11.9.2
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 +8 -8
- package/dist/index.cjs +332 -389
- package/dist/index.mjs +333 -390
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { InvalidParameterError, isConfig, BatchMode, getChainProviders, MissingChainApiError,
|
|
1
|
+
import { InvalidParameterError, isConfig, BatchMode, getChainProviders, MissingChainApiError, createChainClient as createChainClient$1, Parents, Version, assertHasId, assertHasLocation, getChain, isForeignAsset, computeFeeFromDryRun, findNativeAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, ChainNotSupportedError, wrapTxBypass, localizeLocation, isAssetXcEqual, padFeeBy, isRelayChain, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { blake2b } from '@noble/hashes/blake2';
|
|
4
4
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
5
|
+
import { withLegacy } from '@polkadot-api/legacy-provider';
|
|
5
6
|
import { Binary, FixedSizeBinary, getSs58AddressInfo, AccountId, createClient } from 'polkadot-api';
|
|
6
7
|
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
|
|
8
|
+
import { getWsProvider } from 'polkadot-api/ws-provider';
|
|
7
9
|
import { isAddress } from 'viem';
|
|
8
10
|
|
|
9
11
|
function _arrayLikeToArray(r, a) {
|
|
@@ -311,6 +313,12 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
311
313
|
}
|
|
312
314
|
}
|
|
313
315
|
|
|
316
|
+
var LEGACY_CHAINS = ['ComposableFinance', 'Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'Pendulum', 'Subsocial'];
|
|
317
|
+
// Cache settings
|
|
318
|
+
var DEFAULT_TTL_MS = 60000; // 1 minute
|
|
319
|
+
var MAX_CLIENTS = 100;
|
|
320
|
+
var EXTENSION_MS = 5 * 60000; // 5 minutes
|
|
321
|
+
|
|
314
322
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
315
323
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
316
324
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
@@ -701,83 +709,35 @@ function createClientCache(maxSize, onEviction) {
|
|
|
701
709
|
};
|
|
702
710
|
}
|
|
703
711
|
|
|
704
|
-
var DEFAULT_TTL_MS = 60000; // 1 minute
|
|
705
|
-
var MAX_CLIENTS = 100;
|
|
706
|
-
var EXTENSION_MS = 5 * 60000; // 5 minutes
|
|
707
712
|
var clientPool = createClientCache(MAX_CLIENTS, function (_key, entry) {
|
|
708
713
|
entry.client.destroy();
|
|
709
714
|
}, EXTENSION_MS);
|
|
710
715
|
var keyFromWs = function keyFromWs(ws) {
|
|
711
716
|
return Array.isArray(ws) ? JSON.stringify(ws) : ws;
|
|
712
717
|
};
|
|
713
|
-
var createPolkadotClient =
|
|
714
|
-
var
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
_ref2 = _t;
|
|
737
|
-
getWsProvider = _ref2.getWsProvider;
|
|
738
|
-
provider = Array.isArray(ws) ? getWsProvider(ws) : getWsProvider(ws);
|
|
739
|
-
return _context.a(2, createClient(withPolkadotSdkCompat(provider)));
|
|
740
|
-
}
|
|
741
|
-
}, _callee);
|
|
742
|
-
}));
|
|
743
|
-
return function createPolkadotClient(_x) {
|
|
744
|
-
return _ref.apply(this, arguments);
|
|
745
|
-
};
|
|
746
|
-
}();
|
|
747
|
-
var leasePolkadotClient = /*#__PURE__*/function () {
|
|
748
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(ws, ttlMs) {
|
|
749
|
-
var key, entry, _t2;
|
|
750
|
-
return _regenerator().w(function (_context2) {
|
|
751
|
-
while (1) switch (_context2.n) {
|
|
752
|
-
case 0:
|
|
753
|
-
key = keyFromWs(ws);
|
|
754
|
-
entry = clientPool.peek(key);
|
|
755
|
-
if (entry) {
|
|
756
|
-
_context2.n = 2;
|
|
757
|
-
break;
|
|
758
|
-
}
|
|
759
|
-
_context2.n = 1;
|
|
760
|
-
return createPolkadotClient(ws);
|
|
761
|
-
case 1:
|
|
762
|
-
_t2 = _context2.v;
|
|
763
|
-
entry = {
|
|
764
|
-
client: _t2,
|
|
765
|
-
refs: 0,
|
|
766
|
-
destroyWanted: false
|
|
767
|
-
};
|
|
768
|
-
clientPool.set(key, entry, ttlMs);
|
|
769
|
-
case 2:
|
|
770
|
-
entry.refs += 1;
|
|
771
|
-
clientPool.revive(key, ttlMs);
|
|
772
|
-
entry.destroyWanted = false;
|
|
773
|
-
return _context2.a(2, entry.client);
|
|
774
|
-
}
|
|
775
|
-
}, _callee2);
|
|
776
|
-
}));
|
|
777
|
-
return function leasePolkadotClient(_x2, _x3) {
|
|
778
|
-
return _ref3.apply(this, arguments);
|
|
779
|
-
};
|
|
780
|
-
}();
|
|
718
|
+
var createPolkadotClient = function createPolkadotClient(ws, useLegacy) {
|
|
719
|
+
var options = useLegacy ? {
|
|
720
|
+
innerEnhancer: withLegacy()
|
|
721
|
+
} : {};
|
|
722
|
+
var provider = getWsProvider(ws, options);
|
|
723
|
+
return createClient(withPolkadotSdkCompat(provider));
|
|
724
|
+
};
|
|
725
|
+
var leasePolkadotClient = function leasePolkadotClient(ws, ttlMs, useLegacy) {
|
|
726
|
+
var key = keyFromWs(ws);
|
|
727
|
+
var entry = clientPool.peek(key);
|
|
728
|
+
if (!entry) {
|
|
729
|
+
entry = {
|
|
730
|
+
client: createPolkadotClient(ws, useLegacy),
|
|
731
|
+
refs: 0,
|
|
732
|
+
destroyWanted: false
|
|
733
|
+
};
|
|
734
|
+
clientPool.set(key, entry, ttlMs);
|
|
735
|
+
}
|
|
736
|
+
entry.refs += 1;
|
|
737
|
+
clientPool.revive(key, ttlMs);
|
|
738
|
+
entry.destroyWanted = false;
|
|
739
|
+
return entry.client;
|
|
740
|
+
};
|
|
781
741
|
var releasePolkadotClient = function releasePolkadotClient(ws) {
|
|
782
742
|
var key = keyFromWs(ws);
|
|
783
743
|
var entry = clientPool.peek(key);
|
|
@@ -789,22 +749,21 @@ var releasePolkadotClient = function releasePolkadotClient(ws) {
|
|
|
789
749
|
clientPool["delete"](key);
|
|
790
750
|
}
|
|
791
751
|
};
|
|
792
|
-
var unsupportedChains = ['ComposableFinance', 'Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'Pendulum', 'Subsocial'];
|
|
793
752
|
var isHex = function isHex(str) {
|
|
794
753
|
return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
|
|
795
754
|
};
|
|
796
755
|
var extractDryRunXcmFailureReason = function extractDryRunXcmFailureReason(result) {
|
|
797
|
-
var _result$value, _executionResult$valu,
|
|
756
|
+
var _result$value, _executionResult$valu, _ref, _ref2, _ref3, _error$error$type, _error$error, _error$value, _error$value2, _error$value3, _ref4, _result$value2;
|
|
798
757
|
var executionResult = result === null || result === void 0 || (_result$value = result.value) === null || _result$value === void 0 ? void 0 : _result$value.execution_result;
|
|
799
758
|
var error = executionResult === null || executionResult === void 0 || (_executionResult$valu = executionResult.value) === null || _executionResult$valu === void 0 ? void 0 : _executionResult$valu.error;
|
|
800
|
-
var failureType = (
|
|
759
|
+
var failureType = (_ref = (_ref2 = (_ref3 = (_error$error$type = error === null || error === void 0 || (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.type) !== null && _error$error$type !== void 0 ? _error$error$type : error === null || error === void 0 || (_error$value = error.value) === null || _error$value === void 0 || (_error$value = _error$value.error) === null || _error$value === void 0 ? void 0 : _error$value.type) !== null && _ref3 !== void 0 ? _ref3 : error === null || error === void 0 || (_error$value2 = error.value) === null || _error$value2 === void 0 || (_error$value2 = _error$value2.value) === null || _error$value2 === void 0 ? void 0 : _error$value2.type) !== null && _ref2 !== void 0 ? _ref2 : error === null || error === void 0 || (_error$value3 = error.value) === null || _error$value3 === void 0 ? void 0 : _error$value3.type) !== null && _ref !== void 0 ? _ref : error === null || error === void 0 ? void 0 : error.type;
|
|
801
760
|
if (typeof failureType === 'string') {
|
|
802
761
|
return failureType;
|
|
803
762
|
}
|
|
804
763
|
if (typeof (executionResult === null || executionResult === void 0 ? void 0 : executionResult.type) === 'string') {
|
|
805
764
|
return executionResult.type;
|
|
806
765
|
}
|
|
807
|
-
return JSON.stringify((
|
|
766
|
+
return JSON.stringify((_ref4 = (_result$value2 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value2 !== void 0 ? _result$value2 : result) !== null && _ref4 !== void 0 ? _ref4 : 'Unknown error structure', replaceBigInt);
|
|
808
767
|
};
|
|
809
768
|
var PapiApi = /*#__PURE__*/function () {
|
|
810
769
|
function PapiApi(config) {
|
|
@@ -827,46 +786,40 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
827
786
|
}, {
|
|
828
787
|
key: "init",
|
|
829
788
|
value: function () {
|
|
830
|
-
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
789
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain) {
|
|
831
790
|
var clientTtlMs,
|
|
832
791
|
apiConfig,
|
|
833
|
-
|
|
834
|
-
return _regenerator().w(function (
|
|
835
|
-
while (1) switch (
|
|
792
|
+
_args = arguments;
|
|
793
|
+
return _regenerator().w(function (_context) {
|
|
794
|
+
while (1) switch (_context.n) {
|
|
836
795
|
case 0:
|
|
837
|
-
clientTtlMs =
|
|
796
|
+
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
838
797
|
if (!(this.initialized || chain === 'Ethereum')) {
|
|
839
|
-
|
|
798
|
+
_context.n = 1;
|
|
840
799
|
break;
|
|
841
800
|
}
|
|
842
|
-
return
|
|
801
|
+
return _context.a(2);
|
|
843
802
|
case 1:
|
|
844
|
-
if (!unsupportedChains.includes(chain)) {
|
|
845
|
-
_context3.n = 2;
|
|
846
|
-
break;
|
|
847
|
-
}
|
|
848
|
-
throw new ChainNotSupportedError("The chain ".concat(chain, " is not yet supported by the Polkadot API."));
|
|
849
|
-
case 2:
|
|
850
803
|
this._ttlMs = clientTtlMs;
|
|
851
804
|
this._chain = chain;
|
|
852
805
|
apiConfig = this.getApiConfigForChain(chain); // For development mode, api for each used chain must be provided
|
|
853
806
|
if (!(isConfig(this._config) && this._config.development && !apiConfig)) {
|
|
854
|
-
|
|
807
|
+
_context.n = 2;
|
|
855
808
|
break;
|
|
856
809
|
}
|
|
857
810
|
throw new MissingChainApiError(chain);
|
|
858
|
-
case
|
|
859
|
-
|
|
811
|
+
case 2:
|
|
812
|
+
_context.n = 3;
|
|
860
813
|
return this.resolveApi(apiConfig, chain);
|
|
861
|
-
case
|
|
862
|
-
this.api =
|
|
814
|
+
case 3:
|
|
815
|
+
this.api = _context.v;
|
|
863
816
|
this.initialized = true;
|
|
864
|
-
case
|
|
865
|
-
return
|
|
817
|
+
case 4:
|
|
818
|
+
return _context.a(2);
|
|
866
819
|
}
|
|
867
|
-
},
|
|
820
|
+
}, _callee, this);
|
|
868
821
|
}));
|
|
869
|
-
function init(
|
|
822
|
+
function init(_x) {
|
|
870
823
|
return _init.apply(this, arguments);
|
|
871
824
|
}
|
|
872
825
|
return init;
|
|
@@ -883,47 +836,37 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
883
836
|
}, {
|
|
884
837
|
key: "resolveApi",
|
|
885
838
|
value: function () {
|
|
886
|
-
var _resolveApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
887
|
-
return _regenerator().w(function (
|
|
888
|
-
while (1) switch (
|
|
839
|
+
var _resolveApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(apiConfig, chain) {
|
|
840
|
+
return _regenerator().w(function (_context2) {
|
|
841
|
+
while (1) switch (_context2.n) {
|
|
889
842
|
case 0:
|
|
890
843
|
if (apiConfig) {
|
|
891
|
-
|
|
844
|
+
_context2.n = 1;
|
|
892
845
|
break;
|
|
893
846
|
}
|
|
894
|
-
return
|
|
847
|
+
return _context2.a(2, createChainClient$1(this, chain));
|
|
895
848
|
case 1:
|
|
896
849
|
if (!(typeof apiConfig === 'string' || apiConfig instanceof Array)) {
|
|
897
|
-
|
|
850
|
+
_context2.n = 2;
|
|
898
851
|
break;
|
|
899
852
|
}
|
|
900
|
-
return
|
|
853
|
+
return _context2.a(2, this.createApiInstance(apiConfig, chain));
|
|
901
854
|
case 2:
|
|
902
|
-
return
|
|
855
|
+
return _context2.a(2, apiConfig);
|
|
903
856
|
}
|
|
904
|
-
},
|
|
857
|
+
}, _callee2, this);
|
|
905
858
|
}));
|
|
906
|
-
function resolveApi(
|
|
859
|
+
function resolveApi(_x2, _x3) {
|
|
907
860
|
return _resolveApi.apply(this, arguments);
|
|
908
861
|
}
|
|
909
862
|
return resolveApi;
|
|
910
863
|
}()
|
|
911
864
|
}, {
|
|
912
865
|
key: "createApiInstance",
|
|
913
|
-
value: function () {
|
|
914
|
-
var
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
case 0:
|
|
918
|
-
return _context5.a(2, leasePolkadotClient(wsUrl, this._ttlMs));
|
|
919
|
-
}
|
|
920
|
-
}, _callee5, this);
|
|
921
|
-
}));
|
|
922
|
-
function createApiInstance(_x7) {
|
|
923
|
-
return _createApiInstance.apply(this, arguments);
|
|
924
|
-
}
|
|
925
|
-
return createApiInstance;
|
|
926
|
-
}()
|
|
866
|
+
value: function createApiInstance(wsUrl, chain) {
|
|
867
|
+
var useLegacy = LEGACY_CHAINS.includes(chain);
|
|
868
|
+
return Promise.resolve(leasePolkadotClient(wsUrl, this._ttlMs, useLegacy));
|
|
869
|
+
}
|
|
927
870
|
}, {
|
|
928
871
|
key: "accountToHex",
|
|
929
872
|
value: function accountToHex(address) {
|
|
@@ -943,10 +886,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
943
886
|
}
|
|
944
887
|
}, {
|
|
945
888
|
key: "callTxMethod",
|
|
946
|
-
value: function callTxMethod(
|
|
947
|
-
var module =
|
|
948
|
-
method =
|
|
949
|
-
parameters =
|
|
889
|
+
value: function callTxMethod(_ref5) {
|
|
890
|
+
var module = _ref5.module,
|
|
891
|
+
method = _ref5.method,
|
|
892
|
+
parameters = _ref5.parameters;
|
|
950
893
|
var transformedParameters = _transform(parameters);
|
|
951
894
|
return this.api.getUnsafeApi().tx[module][method](transformedParameters);
|
|
952
895
|
}
|
|
@@ -978,10 +921,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
978
921
|
}, {
|
|
979
922
|
key: "objectToHex",
|
|
980
923
|
value: function () {
|
|
981
|
-
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
924
|
+
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(obj) {
|
|
982
925
|
var transformedObj, tx, removeFirst5Bytes, encodedData;
|
|
983
|
-
return _regenerator().w(function (
|
|
984
|
-
while (1) switch (
|
|
926
|
+
return _regenerator().w(function (_context3) {
|
|
927
|
+
while (1) switch (_context3.n) {
|
|
985
928
|
case 0:
|
|
986
929
|
transformedObj = _transform(obj);
|
|
987
930
|
tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
|
|
@@ -999,15 +942,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
999
942
|
removeFirst5Bytes = function removeFirst5Bytes(hexString) {
|
|
1000
943
|
return '0x' + hexString.slice(12);
|
|
1001
944
|
};
|
|
1002
|
-
|
|
945
|
+
_context3.n = 1;
|
|
1003
946
|
return tx.getEncodedData();
|
|
1004
947
|
case 1:
|
|
1005
|
-
encodedData =
|
|
1006
|
-
return
|
|
948
|
+
encodedData = _context3.v;
|
|
949
|
+
return _context3.a(2, removeFirst5Bytes(encodedData.asHex()));
|
|
1007
950
|
}
|
|
1008
|
-
},
|
|
951
|
+
}, _callee3, this);
|
|
1009
952
|
}));
|
|
1010
|
-
function objectToHex(
|
|
953
|
+
function objectToHex(_x4) {
|
|
1011
954
|
return _objectToHex.apply(this, arguments);
|
|
1012
955
|
}
|
|
1013
956
|
return objectToHex;
|
|
@@ -1032,30 +975,30 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1032
975
|
}, {
|
|
1033
976
|
key: "hasMethod",
|
|
1034
977
|
value: function () {
|
|
1035
|
-
var _hasMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1036
|
-
var
|
|
1037
|
-
return _regenerator().w(function (
|
|
1038
|
-
while (1) switch (
|
|
978
|
+
var _hasMethod = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(pallet, method) {
|
|
979
|
+
var _t;
|
|
980
|
+
return _regenerator().w(function (_context4) {
|
|
981
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
1039
982
|
case 0:
|
|
1040
|
-
|
|
1041
|
-
|
|
983
|
+
_context4.p = 0;
|
|
984
|
+
_context4.n = 1;
|
|
1042
985
|
return this.api.getUnsafeApi().tx[pallet][method]().getEncodedData();
|
|
1043
986
|
case 1:
|
|
1044
|
-
return
|
|
987
|
+
return _context4.a(2, true);
|
|
1045
988
|
case 2:
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
if (!(
|
|
1049
|
-
|
|
989
|
+
_context4.p = 2;
|
|
990
|
+
_t = _context4.v;
|
|
991
|
+
if (!(_t instanceof Error && _t.message.includes("Runtime entry Tx(".concat(pallet, ".").concat(method, ") not found")))) {
|
|
992
|
+
_context4.n = 3;
|
|
1050
993
|
break;
|
|
1051
994
|
}
|
|
1052
|
-
return
|
|
995
|
+
return _context4.a(2, false);
|
|
1053
996
|
case 3:
|
|
1054
|
-
return
|
|
997
|
+
return _context4.a(2, true);
|
|
1055
998
|
}
|
|
1056
|
-
},
|
|
999
|
+
}, _callee4, this, [[0, 2]]);
|
|
1057
1000
|
}));
|
|
1058
|
-
function hasMethod(
|
|
1001
|
+
function hasMethod(_x5, _x6) {
|
|
1059
1002
|
return _hasMethod.apply(this, arguments);
|
|
1060
1003
|
}
|
|
1061
1004
|
return hasMethod;
|
|
@@ -1068,15 +1011,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1068
1011
|
}, {
|
|
1069
1012
|
key: "calculateTransactionFee",
|
|
1070
1013
|
value: function () {
|
|
1071
|
-
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1072
|
-
return _regenerator().w(function (
|
|
1073
|
-
while (1) switch (
|
|
1014
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(tx, address) {
|
|
1015
|
+
return _regenerator().w(function (_context5) {
|
|
1016
|
+
while (1) switch (_context5.n) {
|
|
1074
1017
|
case 0:
|
|
1075
|
-
return
|
|
1018
|
+
return _context5.a(2, tx.getEstimatedFees(address));
|
|
1076
1019
|
}
|
|
1077
|
-
},
|
|
1020
|
+
}, _callee5);
|
|
1078
1021
|
}));
|
|
1079
|
-
function calculateTransactionFee(
|
|
1022
|
+
function calculateTransactionFee(_x7, _x8) {
|
|
1080
1023
|
return _calculateTransactionFee.apply(this, arguments);
|
|
1081
1024
|
}
|
|
1082
1025
|
return calculateTransactionFee;
|
|
@@ -1084,27 +1027,27 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1084
1027
|
}, {
|
|
1085
1028
|
key: "quoteAhPrice",
|
|
1086
1029
|
value: function () {
|
|
1087
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1030
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(fromMl, toMl, amountIn) {
|
|
1088
1031
|
var includeFee,
|
|
1089
1032
|
transformedFromMl,
|
|
1090
1033
|
transformedToMl,
|
|
1091
1034
|
response,
|
|
1092
|
-
|
|
1093
|
-
return _regenerator().w(function (
|
|
1094
|
-
while (1) switch (
|
|
1035
|
+
_args6 = arguments;
|
|
1036
|
+
return _regenerator().w(function (_context6) {
|
|
1037
|
+
while (1) switch (_context6.n) {
|
|
1095
1038
|
case 0:
|
|
1096
|
-
includeFee =
|
|
1039
|
+
includeFee = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : true;
|
|
1097
1040
|
transformedFromMl = _transform(fromMl);
|
|
1098
1041
|
transformedToMl = _transform(toMl);
|
|
1099
|
-
|
|
1042
|
+
_context6.n = 1;
|
|
1100
1043
|
return this.api.getUnsafeApi().apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
|
|
1101
1044
|
case 1:
|
|
1102
|
-
response =
|
|
1103
|
-
return
|
|
1045
|
+
response = _context6.v;
|
|
1046
|
+
return _context6.a(2, response ? BigInt(response) : undefined);
|
|
1104
1047
|
}
|
|
1105
|
-
},
|
|
1048
|
+
}, _callee6, this);
|
|
1106
1049
|
}));
|
|
1107
|
-
function quoteAhPrice(
|
|
1050
|
+
function quoteAhPrice(_x9, _x0, _x1) {
|
|
1108
1051
|
return _quoteAhPrice.apply(this, arguments);
|
|
1109
1052
|
}
|
|
1110
1053
|
return quoteAhPrice;
|
|
@@ -1117,20 +1060,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1117
1060
|
}, {
|
|
1118
1061
|
key: "getBalanceNative",
|
|
1119
1062
|
value: function () {
|
|
1120
|
-
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1063
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(address) {
|
|
1121
1064
|
var res;
|
|
1122
|
-
return _regenerator().w(function (
|
|
1123
|
-
while (1) switch (
|
|
1065
|
+
return _regenerator().w(function (_context7) {
|
|
1066
|
+
while (1) switch (_context7.n) {
|
|
1124
1067
|
case 0:
|
|
1125
|
-
|
|
1068
|
+
_context7.n = 1;
|
|
1126
1069
|
return this.api.getUnsafeApi().query.System.Account.getValue(address);
|
|
1127
1070
|
case 1:
|
|
1128
|
-
res =
|
|
1129
|
-
return
|
|
1071
|
+
res = _context7.v;
|
|
1072
|
+
return _context7.a(2, res.data.free);
|
|
1130
1073
|
}
|
|
1131
|
-
},
|
|
1074
|
+
}, _callee7, this);
|
|
1132
1075
|
}));
|
|
1133
|
-
function getBalanceNative(
|
|
1076
|
+
function getBalanceNative(_x10) {
|
|
1134
1077
|
return _getBalanceNative.apply(this, arguments);
|
|
1135
1078
|
}
|
|
1136
1079
|
return getBalanceNative;
|
|
@@ -1138,32 +1081,32 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1138
1081
|
}, {
|
|
1139
1082
|
key: "getBalanceForeignPolkadotXcm",
|
|
1140
1083
|
value: function () {
|
|
1141
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1084
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(chain, address, asset) {
|
|
1142
1085
|
var _res, res;
|
|
1143
|
-
return _regenerator().w(function (
|
|
1144
|
-
while (1) switch (
|
|
1086
|
+
return _regenerator().w(function (_context8) {
|
|
1087
|
+
while (1) switch (_context8.n) {
|
|
1145
1088
|
case 0:
|
|
1146
1089
|
if (!chain.startsWith('Kilt')) {
|
|
1147
|
-
|
|
1090
|
+
_context8.n = 2;
|
|
1148
1091
|
break;
|
|
1149
1092
|
}
|
|
1150
1093
|
assertHasLocation(asset);
|
|
1151
|
-
|
|
1094
|
+
_context8.n = 1;
|
|
1152
1095
|
return this.api.getUnsafeApi().query.Fungibles.Account.getValue(_transform(asset.location), address);
|
|
1153
1096
|
case 1:
|
|
1154
|
-
_res =
|
|
1155
|
-
return
|
|
1097
|
+
_res = _context8.v;
|
|
1098
|
+
return _context8.a(2, _res && _res.balance ? BigInt(_res.balance) : 0n);
|
|
1156
1099
|
case 2:
|
|
1157
1100
|
assertHasId(asset);
|
|
1158
|
-
|
|
1101
|
+
_context8.n = 3;
|
|
1159
1102
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(chain === 'NeuroWeb' ? BigInt(asset.assetId) : asset.assetId, address);
|
|
1160
1103
|
case 3:
|
|
1161
|
-
res =
|
|
1162
|
-
return
|
|
1104
|
+
res = _context8.v;
|
|
1105
|
+
return _context8.a(2, res && res.balance ? BigInt(res.balance) : 0n);
|
|
1163
1106
|
}
|
|
1164
|
-
},
|
|
1107
|
+
}, _callee8, this);
|
|
1165
1108
|
}));
|
|
1166
|
-
function getBalanceForeignPolkadotXcm(
|
|
1109
|
+
function getBalanceForeignPolkadotXcm(_x11, _x12, _x13) {
|
|
1167
1110
|
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
1168
1111
|
}
|
|
1169
1112
|
return getBalanceForeignPolkadotXcm;
|
|
@@ -1171,20 +1114,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1171
1114
|
}, {
|
|
1172
1115
|
key: "getMythosForeignBalance",
|
|
1173
1116
|
value: function () {
|
|
1174
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1117
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
|
|
1175
1118
|
var res;
|
|
1176
|
-
return _regenerator().w(function (
|
|
1177
|
-
while (1) switch (
|
|
1119
|
+
return _regenerator().w(function (_context9) {
|
|
1120
|
+
while (1) switch (_context9.n) {
|
|
1178
1121
|
case 0:
|
|
1179
|
-
|
|
1122
|
+
_context9.n = 1;
|
|
1180
1123
|
return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
|
|
1181
1124
|
case 1:
|
|
1182
|
-
res =
|
|
1183
|
-
return
|
|
1125
|
+
res = _context9.v;
|
|
1126
|
+
return _context9.a(2, res && res.free ? BigInt(res.free) : 0n);
|
|
1184
1127
|
}
|
|
1185
|
-
},
|
|
1128
|
+
}, _callee9, this);
|
|
1186
1129
|
}));
|
|
1187
|
-
function getMythosForeignBalance(
|
|
1130
|
+
function getMythosForeignBalance(_x14) {
|
|
1188
1131
|
return _getMythosForeignBalance.apply(this, arguments);
|
|
1189
1132
|
}
|
|
1190
1133
|
return getMythosForeignBalance;
|
|
@@ -1192,21 +1135,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1192
1135
|
}, {
|
|
1193
1136
|
key: "getBalanceForeignAssetsPallet",
|
|
1194
1137
|
value: function () {
|
|
1195
|
-
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1138
|
+
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, location) {
|
|
1196
1139
|
var transformedLocation, res;
|
|
1197
|
-
return _regenerator().w(function (
|
|
1198
|
-
while (1) switch (
|
|
1140
|
+
return _regenerator().w(function (_context0) {
|
|
1141
|
+
while (1) switch (_context0.n) {
|
|
1199
1142
|
case 0:
|
|
1200
1143
|
transformedLocation = _transform(location);
|
|
1201
|
-
|
|
1144
|
+
_context0.n = 1;
|
|
1202
1145
|
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedLocation, address);
|
|
1203
1146
|
case 1:
|
|
1204
|
-
res =
|
|
1205
|
-
return
|
|
1147
|
+
res = _context0.v;
|
|
1148
|
+
return _context0.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1206
1149
|
}
|
|
1207
|
-
},
|
|
1150
|
+
}, _callee0, this);
|
|
1208
1151
|
}));
|
|
1209
|
-
function getBalanceForeignAssetsPallet(
|
|
1152
|
+
function getBalanceForeignAssetsPallet(_x15, _x16) {
|
|
1210
1153
|
return _getBalanceForeignAssetsPallet.apply(this, arguments);
|
|
1211
1154
|
}
|
|
1212
1155
|
return getBalanceForeignAssetsPallet;
|
|
@@ -1214,20 +1157,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1214
1157
|
}, {
|
|
1215
1158
|
key: "getForeignAssetsByIdBalance",
|
|
1216
1159
|
value: function () {
|
|
1217
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1160
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address, assetId) {
|
|
1218
1161
|
var res;
|
|
1219
|
-
return _regenerator().w(function (
|
|
1220
|
-
while (1) switch (
|
|
1162
|
+
return _regenerator().w(function (_context1) {
|
|
1163
|
+
while (1) switch (_context1.n) {
|
|
1221
1164
|
case 0:
|
|
1222
|
-
|
|
1165
|
+
_context1.n = 1;
|
|
1223
1166
|
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
|
|
1224
1167
|
case 1:
|
|
1225
|
-
res =
|
|
1226
|
-
return
|
|
1168
|
+
res = _context1.v;
|
|
1169
|
+
return _context1.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1227
1170
|
}
|
|
1228
|
-
},
|
|
1171
|
+
}, _callee1, this);
|
|
1229
1172
|
}));
|
|
1230
|
-
function getForeignAssetsByIdBalance(
|
|
1173
|
+
function getForeignAssetsByIdBalance(_x17, _x18) {
|
|
1231
1174
|
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
1232
1175
|
}
|
|
1233
1176
|
return getForeignAssetsByIdBalance;
|
|
@@ -1235,23 +1178,23 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1235
1178
|
}, {
|
|
1236
1179
|
key: "getBalanceForeignBifrost",
|
|
1237
1180
|
value: function () {
|
|
1238
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1181
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, asset) {
|
|
1239
1182
|
var currencySelection, transformedParameters, response, accountData;
|
|
1240
|
-
return _regenerator().w(function (
|
|
1241
|
-
while (1) switch (
|
|
1183
|
+
return _regenerator().w(function (_context10) {
|
|
1184
|
+
while (1) switch (_context10.n) {
|
|
1242
1185
|
case 0:
|
|
1243
1186
|
currencySelection = getChain('BifrostPolkadot').getCurrencySelection(asset);
|
|
1244
1187
|
transformedParameters = _transform(currencySelection);
|
|
1245
|
-
|
|
1188
|
+
_context10.n = 1;
|
|
1246
1189
|
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1247
1190
|
case 1:
|
|
1248
|
-
response =
|
|
1191
|
+
response = _context10.v;
|
|
1249
1192
|
accountData = response ? response : null;
|
|
1250
|
-
return
|
|
1193
|
+
return _context10.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1251
1194
|
}
|
|
1252
|
-
},
|
|
1195
|
+
}, _callee10, this);
|
|
1253
1196
|
}));
|
|
1254
|
-
function getBalanceForeignBifrost(
|
|
1197
|
+
function getBalanceForeignBifrost(_x19, _x20) {
|
|
1255
1198
|
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
1256
1199
|
}
|
|
1257
1200
|
return getBalanceForeignBifrost;
|
|
@@ -1259,24 +1202,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1259
1202
|
}, {
|
|
1260
1203
|
key: "getBalanceNativeAcala",
|
|
1261
1204
|
value: function () {
|
|
1262
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1205
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, symbol) {
|
|
1263
1206
|
var transformedParameters, response, accountData;
|
|
1264
|
-
return _regenerator().w(function (
|
|
1265
|
-
while (1) switch (
|
|
1207
|
+
return _regenerator().w(function (_context11) {
|
|
1208
|
+
while (1) switch (_context11.n) {
|
|
1266
1209
|
case 0:
|
|
1267
1210
|
transformedParameters = _transform({
|
|
1268
1211
|
Token: symbol
|
|
1269
1212
|
});
|
|
1270
|
-
|
|
1213
|
+
_context11.n = 1;
|
|
1271
1214
|
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1272
1215
|
case 1:
|
|
1273
|
-
response =
|
|
1216
|
+
response = _context11.v;
|
|
1274
1217
|
accountData = response ? response : null;
|
|
1275
|
-
return
|
|
1218
|
+
return _context11.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1276
1219
|
}
|
|
1277
|
-
},
|
|
1220
|
+
}, _callee11, this);
|
|
1278
1221
|
}));
|
|
1279
|
-
function getBalanceNativeAcala(
|
|
1222
|
+
function getBalanceNativeAcala(_x21, _x22) {
|
|
1280
1223
|
return _getBalanceNativeAcala.apply(this, arguments);
|
|
1281
1224
|
}
|
|
1282
1225
|
return getBalanceNativeAcala;
|
|
@@ -1284,74 +1227,74 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1284
1227
|
}, {
|
|
1285
1228
|
key: "getBalanceForeignXTokens",
|
|
1286
1229
|
value: function () {
|
|
1287
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1230
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, address, asset) {
|
|
1288
1231
|
var pallet, _response, unsafeApi, collectionId, balance, _response2, response, entry;
|
|
1289
|
-
return _regenerator().w(function (
|
|
1290
|
-
while (1) switch (
|
|
1232
|
+
return _regenerator().w(function (_context12) {
|
|
1233
|
+
while (1) switch (_context12.n) {
|
|
1291
1234
|
case 0:
|
|
1292
1235
|
pallet = 'Tokens';
|
|
1293
1236
|
if (chain === 'Centrifuge' || chain === 'Altair') {
|
|
1294
1237
|
pallet = 'OrmlTokens';
|
|
1295
1238
|
}
|
|
1296
1239
|
if (!(chain === 'Peaq' || chain === 'Manta' || chain === 'Crust' || chain === 'Ajuna')) {
|
|
1297
|
-
|
|
1240
|
+
_context12.n = 2;
|
|
1298
1241
|
break;
|
|
1299
1242
|
}
|
|
1300
1243
|
assertHasId(asset);
|
|
1301
|
-
|
|
1244
|
+
_context12.n = 1;
|
|
1302
1245
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(chain === 'Manta' || chain === 'Crust' ? BigInt(asset.assetId) : asset.assetId, address);
|
|
1303
1246
|
case 1:
|
|
1304
|
-
_response =
|
|
1305
|
-
return
|
|
1247
|
+
_response = _context12.v;
|
|
1248
|
+
return _context12.a(2, _response ? BigInt(_response.free.toString()) : 0n);
|
|
1306
1249
|
case 2:
|
|
1307
1250
|
if (!(chain === 'Unique')) {
|
|
1308
|
-
|
|
1251
|
+
_context12.n = 5;
|
|
1309
1252
|
break;
|
|
1310
1253
|
}
|
|
1311
1254
|
assertHasLocation(asset);
|
|
1312
1255
|
assertHasId(asset);
|
|
1313
1256
|
unsafeApi = this.api.getUnsafeApi();
|
|
1314
|
-
|
|
1257
|
+
_context12.n = 3;
|
|
1315
1258
|
return unsafeApi.query.ForeignAssets.ForeignAssetToCollection.getValue(_transform(asset.location));
|
|
1316
1259
|
case 3:
|
|
1317
|
-
collectionId =
|
|
1318
|
-
|
|
1260
|
+
collectionId = _context12.v;
|
|
1261
|
+
_context12.n = 4;
|
|
1319
1262
|
return unsafeApi.apis.UniqueApi.balance(collectionId, {
|
|
1320
1263
|
type: 'Substrate',
|
|
1321
1264
|
value: address
|
|
1322
1265
|
}, asset.assetId);
|
|
1323
1266
|
case 4:
|
|
1324
|
-
balance =
|
|
1325
|
-
return
|
|
1267
|
+
balance = _context12.v;
|
|
1268
|
+
return _context12.a(2, balance.success ? BigInt(balance.value) : 0n);
|
|
1326
1269
|
case 5:
|
|
1327
1270
|
if (!(chain === 'Hydration')) {
|
|
1328
|
-
|
|
1271
|
+
_context12.n = 7;
|
|
1329
1272
|
break;
|
|
1330
1273
|
}
|
|
1331
1274
|
assertHasId(asset);
|
|
1332
|
-
|
|
1275
|
+
_context12.n = 6;
|
|
1333
1276
|
return this.api.getUnsafeApi().apis.CurrenciesApi.account(asset.assetId, address);
|
|
1334
1277
|
case 6:
|
|
1335
|
-
_response2 =
|
|
1336
|
-
return
|
|
1278
|
+
_response2 = _context12.v;
|
|
1279
|
+
return _context12.a(2, _response2 ? BigInt(_response2.free.toString()) : 0n);
|
|
1337
1280
|
case 7:
|
|
1338
|
-
|
|
1281
|
+
_context12.n = 8;
|
|
1339
1282
|
return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
|
|
1340
1283
|
case 8:
|
|
1341
|
-
response =
|
|
1342
|
-
entry = response.find(function (
|
|
1284
|
+
response = _context12.v;
|
|
1285
|
+
entry = response.find(function (_ref6) {
|
|
1343
1286
|
var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
|
|
1344
|
-
var keyArgs =
|
|
1287
|
+
var keyArgs = _ref6.keyArgs;
|
|
1345
1288
|
var _keyArgs = _slicedToArray(keyArgs, 2);
|
|
1346
1289
|
_keyArgs[0];
|
|
1347
1290
|
var assetItem = _keyArgs[1];
|
|
1348
1291
|
return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
1349
1292
|
});
|
|
1350
|
-
return
|
|
1293
|
+
return _context12.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
|
|
1351
1294
|
}
|
|
1352
|
-
},
|
|
1295
|
+
}, _callee12, this);
|
|
1353
1296
|
}));
|
|
1354
|
-
function getBalanceForeignXTokens(
|
|
1297
|
+
function getBalanceForeignXTokens(_x23, _x24, _x25) {
|
|
1355
1298
|
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1356
1299
|
}
|
|
1357
1300
|
return getBalanceForeignXTokens;
|
|
@@ -1359,20 +1302,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1359
1302
|
}, {
|
|
1360
1303
|
key: "getBalanceAssetsPallet",
|
|
1361
1304
|
value: function () {
|
|
1362
|
-
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1305
|
+
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(address, assetId) {
|
|
1363
1306
|
var response;
|
|
1364
|
-
return _regenerator().w(function (
|
|
1365
|
-
while (1) switch (
|
|
1307
|
+
return _regenerator().w(function (_context13) {
|
|
1308
|
+
while (1) switch (_context13.n) {
|
|
1366
1309
|
case 0:
|
|
1367
|
-
|
|
1310
|
+
_context13.n = 1;
|
|
1368
1311
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
|
|
1369
1312
|
case 1:
|
|
1370
|
-
response =
|
|
1371
|
-
return
|
|
1313
|
+
response = _context13.v;
|
|
1314
|
+
return _context13.a(2, BigInt(response === undefined ? 0 : response.balance));
|
|
1372
1315
|
}
|
|
1373
|
-
},
|
|
1316
|
+
}, _callee13, this);
|
|
1374
1317
|
}));
|
|
1375
|
-
function getBalanceAssetsPallet(
|
|
1318
|
+
function getBalanceAssetsPallet(_x26, _x27) {
|
|
1376
1319
|
return _getBalanceAssetsPallet.apply(this, arguments);
|
|
1377
1320
|
}
|
|
1378
1321
|
return getBalanceAssetsPallet;
|
|
@@ -1380,21 +1323,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1380
1323
|
}, {
|
|
1381
1324
|
key: "getFromRpc",
|
|
1382
1325
|
value: function () {
|
|
1383
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1326
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(module, method, key) {
|
|
1384
1327
|
var toSS58, value;
|
|
1385
|
-
return _regenerator().w(function (
|
|
1386
|
-
while (1) switch (
|
|
1328
|
+
return _regenerator().w(function (_context14) {
|
|
1329
|
+
while (1) switch (_context14.n) {
|
|
1387
1330
|
case 0:
|
|
1388
1331
|
toSS58 = AccountId().dec;
|
|
1389
|
-
|
|
1332
|
+
_context14.n = 1;
|
|
1390
1333
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? toSS58(key) : key]);
|
|
1391
1334
|
case 1:
|
|
1392
|
-
value =
|
|
1393
|
-
return
|
|
1335
|
+
value = _context14.v;
|
|
1336
|
+
return _context14.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1394
1337
|
}
|
|
1395
|
-
},
|
|
1338
|
+
}, _callee14, this);
|
|
1396
1339
|
}));
|
|
1397
|
-
function getFromRpc(
|
|
1340
|
+
function getFromRpc(_x28, _x29, _x30) {
|
|
1398
1341
|
return _getFromRpc.apply(this, arguments);
|
|
1399
1342
|
}
|
|
1400
1343
|
return getFromRpc;
|
|
@@ -1407,20 +1350,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1407
1350
|
}, {
|
|
1408
1351
|
key: "createApiForChain",
|
|
1409
1352
|
value: function () {
|
|
1410
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1353
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(chain) {
|
|
1411
1354
|
var api;
|
|
1412
|
-
return _regenerator().w(function (
|
|
1413
|
-
while (1) switch (
|
|
1355
|
+
return _regenerator().w(function (_context15) {
|
|
1356
|
+
while (1) switch (_context15.n) {
|
|
1414
1357
|
case 0:
|
|
1415
1358
|
api = new PapiApi();
|
|
1416
|
-
|
|
1359
|
+
_context15.n = 1;
|
|
1417
1360
|
return api.init(chain);
|
|
1418
1361
|
case 1:
|
|
1419
|
-
return
|
|
1362
|
+
return _context15.a(2, api);
|
|
1420
1363
|
}
|
|
1421
|
-
},
|
|
1364
|
+
}, _callee15);
|
|
1422
1365
|
}));
|
|
1423
|
-
function createApiForChain(
|
|
1366
|
+
function createApiForChain(_x31) {
|
|
1424
1367
|
return _createApiForChain.apply(this, arguments);
|
|
1425
1368
|
}
|
|
1426
1369
|
return createApiForChain;
|
|
@@ -1428,16 +1371,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1428
1371
|
}, {
|
|
1429
1372
|
key: "getDryRunCall",
|
|
1430
1373
|
value: function () {
|
|
1431
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1374
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(options) {
|
|
1432
1375
|
var _this = this;
|
|
1433
|
-
var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, usedAsset, usedSymbol, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasLocation, xcmFee, fee,
|
|
1434
|
-
return _regenerator().w(function (
|
|
1435
|
-
while (1) switch (
|
|
1376
|
+
var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, usedAsset, usedSymbol, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasLocation, xcmFee, fee, _t2;
|
|
1377
|
+
return _regenerator().w(function (_context17) {
|
|
1378
|
+
while (1) switch (_context17.n) {
|
|
1436
1379
|
case 0:
|
|
1437
1380
|
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1438
1381
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1439
1382
|
if (supportsDryRunApi) {
|
|
1440
|
-
|
|
1383
|
+
_context17.n = 1;
|
|
1441
1384
|
break;
|
|
1442
1385
|
}
|
|
1443
1386
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
@@ -1453,38 +1396,38 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1453
1396
|
}
|
|
1454
1397
|
};
|
|
1455
1398
|
if (!useRootOrigin) {
|
|
1456
|
-
|
|
1399
|
+
_context17.n = 3;
|
|
1457
1400
|
break;
|
|
1458
1401
|
}
|
|
1459
|
-
|
|
1402
|
+
_context17.n = 2;
|
|
1460
1403
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1461
1404
|
api: this
|
|
1462
1405
|
}), bypassOptions);
|
|
1463
1406
|
case 2:
|
|
1464
|
-
|
|
1465
|
-
|
|
1407
|
+
_t2 = _context17.v;
|
|
1408
|
+
_context17.n = 4;
|
|
1466
1409
|
break;
|
|
1467
1410
|
case 3:
|
|
1468
|
-
|
|
1411
|
+
_t2 = tx;
|
|
1469
1412
|
case 4:
|
|
1470
|
-
resolvedTx =
|
|
1413
|
+
resolvedTx = _t2;
|
|
1471
1414
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1472
|
-
var
|
|
1415
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(includeVersion) {
|
|
1473
1416
|
var _this$api$getUnsafeAp;
|
|
1474
1417
|
var callArgs;
|
|
1475
|
-
return _regenerator().w(function (
|
|
1476
|
-
while (1) switch (
|
|
1418
|
+
return _regenerator().w(function (_context16) {
|
|
1419
|
+
while (1) switch (_context16.n) {
|
|
1477
1420
|
case 0:
|
|
1478
1421
|
callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1479
1422
|
if (includeVersion) {
|
|
1480
1423
|
callArgs.push(DEFAULT_XCM_VERSION);
|
|
1481
1424
|
}
|
|
1482
|
-
return
|
|
1425
|
+
return _context16.a(2, (_this$api$getUnsafeAp = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, callArgs));
|
|
1483
1426
|
}
|
|
1484
|
-
},
|
|
1427
|
+
}, _callee16);
|
|
1485
1428
|
}));
|
|
1486
|
-
return function performDryRunCall(
|
|
1487
|
-
return
|
|
1429
|
+
return function performDryRunCall(_x33) {
|
|
1430
|
+
return _ref7.apply(this, arguments);
|
|
1488
1431
|
};
|
|
1489
1432
|
}();
|
|
1490
1433
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
@@ -1493,7 +1436,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1493
1436
|
return (result === null || result === void 0 ? void 0 : result.success) && ((_result$value3 = result.value) === null || _result$value3 === void 0 || (_result$value3 = _result$value3.execution_result) === null || _result$value3 === void 0 ? void 0 : _result$value3.success) && !errorInEvents;
|
|
1494
1437
|
};
|
|
1495
1438
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1496
|
-
var _result$value4, _executionResultValue, _executionResultValue2, _result$value5,
|
|
1439
|
+
var _result$value4, _executionResultValue, _executionResultValue2, _result$value5, _ref8, _result$value6;
|
|
1497
1440
|
var executionResultValue = result === null || result === void 0 || (_result$value4 = result.value) === null || _result$value4 === void 0 || (_result$value4 = _result$value4.execution_result) === null || _result$value4 === void 0 ? void 0 : _result$value4.value;
|
|
1498
1441
|
if (executionResultValue !== null && executionResultValue !== void 0 && (_executionResultValue = executionResultValue.error) !== null && _executionResultValue !== void 0 && (_executionResultValue = _executionResultValue.value) !== null && _executionResultValue !== void 0 && (_executionResultValue = _executionResultValue.value) !== null && _executionResultValue !== void 0 && _executionResultValue.type) {
|
|
1499
1442
|
return String(executionResultValue.error.value.value.type);
|
|
@@ -1510,28 +1453,28 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1510
1453
|
var _result = erroredEvent.value.value.result;
|
|
1511
1454
|
return (_result$value$value$v = (_result$value$value$v2 = _result.value.value.value) === null || _result$value$value$v2 === void 0 ? void 0 : _result$value$value$v2.type) !== null && _result$value$value$v !== void 0 ? _result$value$value$v : _result.value.value.type;
|
|
1512
1455
|
}
|
|
1513
|
-
return JSON.stringify((
|
|
1456
|
+
return JSON.stringify((_ref8 = (_result$value6 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value6 !== void 0 ? _result$value6 : result) !== null && _ref8 !== void 0 ? _ref8 : 'Unknown error structure', replaceBigInt);
|
|
1514
1457
|
};
|
|
1515
1458
|
failureOutputReason = '';
|
|
1516
|
-
|
|
1459
|
+
_context17.n = 5;
|
|
1517
1460
|
return performDryRunCall(false);
|
|
1518
1461
|
case 5:
|
|
1519
|
-
result =
|
|
1462
|
+
result = _context17.v;
|
|
1520
1463
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1521
1464
|
if (isSuccess) {
|
|
1522
|
-
|
|
1465
|
+
_context17.n = 7;
|
|
1523
1466
|
break;
|
|
1524
1467
|
}
|
|
1525
1468
|
initialFailureReason = extractFailureReasonFromResult(result);
|
|
1526
1469
|
failureOutputReason = initialFailureReason;
|
|
1527
1470
|
if (!(initialFailureReason === 'VersionedConversionFailed')) {
|
|
1528
|
-
|
|
1471
|
+
_context17.n = 7;
|
|
1529
1472
|
break;
|
|
1530
1473
|
}
|
|
1531
|
-
|
|
1474
|
+
_context17.n = 6;
|
|
1532
1475
|
return performDryRunCall(true);
|
|
1533
1476
|
case 6:
|
|
1534
|
-
result =
|
|
1477
|
+
result = _context17.v;
|
|
1535
1478
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1536
1479
|
if (!isSuccess) {
|
|
1537
1480
|
failureOutputReason = extractFailureReasonFromResult(result);
|
|
@@ -1542,10 +1485,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1542
1485
|
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
|
|
1543
1486
|
usedSymbol = usedAsset.symbol;
|
|
1544
1487
|
if (isSuccess) {
|
|
1545
|
-
|
|
1488
|
+
_context17.n = 8;
|
|
1546
1489
|
break;
|
|
1547
1490
|
}
|
|
1548
|
-
return
|
|
1491
|
+
return _context17.a(2, Promise.resolve({
|
|
1549
1492
|
success: false,
|
|
1550
1493
|
failureReason: failureOutputReason,
|
|
1551
1494
|
currency: usedSymbol,
|
|
@@ -1559,25 +1502,25 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1559
1502
|
} : undefined;
|
|
1560
1503
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1561
1504
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1562
|
-
|
|
1505
|
+
_context17.n = 9;
|
|
1563
1506
|
return this.calculateTransactionFee(tx, address);
|
|
1564
1507
|
case 9:
|
|
1565
|
-
executionFee =
|
|
1508
|
+
executionFee = _context17.v;
|
|
1566
1509
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1567
1510
|
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
1568
1511
|
if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum'))) {
|
|
1569
|
-
|
|
1512
|
+
_context17.n = 11;
|
|
1570
1513
|
break;
|
|
1571
1514
|
}
|
|
1572
|
-
|
|
1515
|
+
_context17.n = 10;
|
|
1573
1516
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
1574
1517
|
case 10:
|
|
1575
|
-
xcmFee =
|
|
1518
|
+
xcmFee = _context17.v;
|
|
1576
1519
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1577
|
-
|
|
1520
|
+
_context17.n = 11;
|
|
1578
1521
|
break;
|
|
1579
1522
|
}
|
|
1580
|
-
return
|
|
1523
|
+
return _context17.a(2, Promise.resolve({
|
|
1581
1524
|
success: true,
|
|
1582
1525
|
fee: xcmFee,
|
|
1583
1526
|
currency: usedSymbol,
|
|
@@ -1588,7 +1531,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1588
1531
|
}));
|
|
1589
1532
|
case 11:
|
|
1590
1533
|
fee = computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
|
|
1591
|
-
return
|
|
1534
|
+
return _context17.a(2, Promise.resolve({
|
|
1592
1535
|
success: true,
|
|
1593
1536
|
fee: fee,
|
|
1594
1537
|
currency: usedSymbol,
|
|
@@ -1598,9 +1541,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1598
1541
|
destParaId: destParaId
|
|
1599
1542
|
}));
|
|
1600
1543
|
}
|
|
1601
|
-
},
|
|
1544
|
+
}, _callee17, this);
|
|
1602
1545
|
}));
|
|
1603
|
-
function getDryRunCall(
|
|
1546
|
+
function getDryRunCall(_x32) {
|
|
1604
1547
|
return _getDryRunCall.apply(this, arguments);
|
|
1605
1548
|
}
|
|
1606
1549
|
return getDryRunCall;
|
|
@@ -1608,24 +1551,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1608
1551
|
}, {
|
|
1609
1552
|
key: "getXcmWeight",
|
|
1610
1553
|
value: function () {
|
|
1611
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1554
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(xcm) {
|
|
1612
1555
|
var weightResult, _weightResult$value, ref_time, proof_size;
|
|
1613
|
-
return _regenerator().w(function (
|
|
1614
|
-
while (1) switch (
|
|
1556
|
+
return _regenerator().w(function (_context18) {
|
|
1557
|
+
while (1) switch (_context18.n) {
|
|
1615
1558
|
case 0:
|
|
1616
|
-
|
|
1559
|
+
_context18.n = 1;
|
|
1617
1560
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1618
1561
|
case 1:
|
|
1619
|
-
weightResult =
|
|
1562
|
+
weightResult = _context18.v;
|
|
1620
1563
|
_weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
|
|
1621
|
-
return
|
|
1564
|
+
return _context18.a(2, {
|
|
1622
1565
|
refTime: ref_time,
|
|
1623
1566
|
proofSize: proof_size
|
|
1624
1567
|
});
|
|
1625
1568
|
}
|
|
1626
|
-
},
|
|
1569
|
+
}, _callee18, this);
|
|
1627
1570
|
}));
|
|
1628
|
-
function getXcmWeight(
|
|
1571
|
+
function getXcmWeight(_x34) {
|
|
1629
1572
|
return _getXcmWeight.apply(this, arguments);
|
|
1630
1573
|
}
|
|
1631
1574
|
return getXcmWeight;
|
|
@@ -1633,7 +1576,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1633
1576
|
}, {
|
|
1634
1577
|
key: "getXcmPaymentApiFee",
|
|
1635
1578
|
value: function () {
|
|
1636
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1579
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(chain, localXcm, forwardedXcm, asset) {
|
|
1637
1580
|
var _deliveryFeeRes$value, _deliveryFeeRes$value2;
|
|
1638
1581
|
var transformXcm,
|
|
1639
1582
|
transformedXcm,
|
|
@@ -1646,75 +1589,75 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1646
1589
|
nativeAsset,
|
|
1647
1590
|
deliveryFee,
|
|
1648
1591
|
res,
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
return _regenerator().w(function (
|
|
1653
|
-
while (1) switch (
|
|
1592
|
+
_args19 = arguments,
|
|
1593
|
+
_t3,
|
|
1594
|
+
_t4;
|
|
1595
|
+
return _regenerator().w(function (_context19) {
|
|
1596
|
+
while (1) switch (_context19.p = _context19.n) {
|
|
1654
1597
|
case 0:
|
|
1655
|
-
transformXcm =
|
|
1598
|
+
transformXcm = _args19.length > 4 && _args19[4] !== undefined ? _args19[4] : false;
|
|
1656
1599
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1657
|
-
|
|
1600
|
+
_context19.n = 1;
|
|
1658
1601
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1659
1602
|
case 1:
|
|
1660
|
-
weight =
|
|
1603
|
+
weight = _context19.v;
|
|
1661
1604
|
assertHasLocation(asset);
|
|
1662
1605
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1663
1606
|
transformedAssetLoc = _transform(assetLocalizedLoc);
|
|
1664
|
-
|
|
1607
|
+
_context19.n = 2;
|
|
1665
1608
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
|
|
1666
1609
|
type: Version.V4,
|
|
1667
1610
|
value: transformedAssetLoc
|
|
1668
1611
|
});
|
|
1669
1612
|
case 2:
|
|
1670
|
-
execFeeRes =
|
|
1613
|
+
execFeeRes = _context19.v;
|
|
1671
1614
|
if (!(forwardedXcm.length > 0)) {
|
|
1672
|
-
|
|
1615
|
+
_context19.n = 4;
|
|
1673
1616
|
break;
|
|
1674
1617
|
}
|
|
1675
|
-
|
|
1618
|
+
_context19.n = 3;
|
|
1676
1619
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_delivery_fees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
1677
1620
|
case 3:
|
|
1678
|
-
|
|
1679
|
-
|
|
1621
|
+
_t3 = _context19.v;
|
|
1622
|
+
_context19.n = 5;
|
|
1680
1623
|
break;
|
|
1681
1624
|
case 4:
|
|
1682
|
-
|
|
1625
|
+
_t3 = undefined;
|
|
1683
1626
|
case 5:
|
|
1684
|
-
deliveryFeeRes =
|
|
1627
|
+
deliveryFeeRes = _t3;
|
|
1685
1628
|
deliveryFeeResolved = (deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value = deliveryFeeRes.value) === null || _deliveryFeeRes$value === void 0 ? void 0 : _deliveryFeeRes$value.value.length) > 0 ? deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value2 = deliveryFeeRes.value) === null || _deliveryFeeRes$value2 === void 0 ? void 0 : _deliveryFeeRes$value2.value[0].fun.value : 0n;
|
|
1686
1629
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1687
1630
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
1688
|
-
|
|
1631
|
+
_context19.n = 6;
|
|
1689
1632
|
break;
|
|
1690
1633
|
}
|
|
1691
1634
|
deliveryFee = deliveryFeeResolved;
|
|
1692
|
-
|
|
1635
|
+
_context19.n = 9;
|
|
1693
1636
|
break;
|
|
1694
1637
|
case 6:
|
|
1695
|
-
|
|
1638
|
+
_context19.p = 6;
|
|
1696
1639
|
assertHasLocation(nativeAsset);
|
|
1697
|
-
|
|
1640
|
+
_context19.n = 7;
|
|
1698
1641
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1699
1642
|
case 7:
|
|
1700
|
-
res =
|
|
1643
|
+
res = _context19.v;
|
|
1701
1644
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
1702
|
-
|
|
1645
|
+
_context19.n = 9;
|
|
1703
1646
|
break;
|
|
1704
1647
|
case 8:
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
if (
|
|
1648
|
+
_context19.p = 8;
|
|
1649
|
+
_t4 = _context19.v;
|
|
1650
|
+
if (_t4 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t4.message)) {
|
|
1708
1651
|
deliveryFee = 0n;
|
|
1709
1652
|
} else {
|
|
1710
1653
|
deliveryFee = 0n;
|
|
1711
1654
|
}
|
|
1712
1655
|
case 9:
|
|
1713
|
-
return
|
|
1656
|
+
return _context19.a(2, execFeeRes.value + deliveryFee);
|
|
1714
1657
|
}
|
|
1715
|
-
},
|
|
1658
|
+
}, _callee19, this, [[6, 8]]);
|
|
1716
1659
|
}));
|
|
1717
|
-
function getXcmPaymentApiFee(
|
|
1660
|
+
function getXcmPaymentApiFee(_x35, _x36, _x37, _x38) {
|
|
1718
1661
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1719
1662
|
}
|
|
1720
1663
|
return getXcmPaymentApiFee;
|
|
@@ -1722,33 +1665,33 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1722
1665
|
}, {
|
|
1723
1666
|
key: "getDryRunXcm",
|
|
1724
1667
|
value: function () {
|
|
1725
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1726
|
-
var
|
|
1668
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(_ref9) {
|
|
1669
|
+
var _ref0, _processAssetsDeposit, _ref1, _ref10, _ref11, _ref12, _ref13;
|
|
1727
1670
|
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, symbol, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1728
|
-
return _regenerator().w(function (
|
|
1729
|
-
while (1) switch (
|
|
1671
|
+
return _regenerator().w(function (_context20) {
|
|
1672
|
+
while (1) switch (_context20.n) {
|
|
1730
1673
|
case 0:
|
|
1731
|
-
originLocation =
|
|
1674
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, chain = _ref9.chain, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
|
|
1732
1675
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1733
1676
|
if (supportsDryRunApi) {
|
|
1734
|
-
|
|
1677
|
+
_context20.n = 1;
|
|
1735
1678
|
break;
|
|
1736
1679
|
}
|
|
1737
1680
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
1738
1681
|
case 1:
|
|
1739
1682
|
transformedOriginLocation = _transform(originLocation);
|
|
1740
|
-
|
|
1683
|
+
_context20.n = 2;
|
|
1741
1684
|
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1742
1685
|
case 2:
|
|
1743
|
-
result =
|
|
1686
|
+
result = _context20.v;
|
|
1744
1687
|
symbol = asset.symbol;
|
|
1745
1688
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1746
1689
|
if (isSuccess) {
|
|
1747
|
-
|
|
1690
|
+
_context20.n = 3;
|
|
1748
1691
|
break;
|
|
1749
1692
|
}
|
|
1750
1693
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1751
|
-
return
|
|
1694
|
+
return _context20.a(2, {
|
|
1752
1695
|
success: false,
|
|
1753
1696
|
failureReason: failureReason,
|
|
1754
1697
|
currency: symbol,
|
|
@@ -1763,18 +1706,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1763
1706
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1764
1707
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1765
1708
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1766
|
-
|
|
1709
|
+
_context20.n = 5;
|
|
1767
1710
|
break;
|
|
1768
1711
|
}
|
|
1769
|
-
|
|
1712
|
+
_context20.n = 4;
|
|
1770
1713
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1771
1714
|
case 4:
|
|
1772
|
-
_fee =
|
|
1715
|
+
_fee = _context20.v;
|
|
1773
1716
|
if (!(typeof _fee === 'bigint')) {
|
|
1774
|
-
|
|
1717
|
+
_context20.n = 5;
|
|
1775
1718
|
break;
|
|
1776
1719
|
}
|
|
1777
|
-
return
|
|
1720
|
+
return _context20.a(2, {
|
|
1778
1721
|
success: true,
|
|
1779
1722
|
fee: _fee,
|
|
1780
1723
|
currency: symbol,
|
|
@@ -1788,13 +1731,13 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1788
1731
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1789
1732
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1790
1733
|
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
|
|
1791
|
-
feeAssetFeeEvent = (
|
|
1734
|
+
feeAssetFeeEvent = (_ref0 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1792
1735
|
return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
|
|
1793
|
-
}) : undefined) !== null &&
|
|
1736
|
+
}) : undefined) !== null && _ref0 !== void 0 ? _ref0 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1794
1737
|
return event.type === 'Tokens' && event.value.type === 'Deposited';
|
|
1795
1738
|
}) : undefined;
|
|
1796
1739
|
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);
|
|
1797
|
-
feeEvent = (
|
|
1740
|
+
feeEvent = (_ref1 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
|
|
1798
1741
|
//
|
|
1799
1742
|
processedAssetsAmount !== undefined ? {
|
|
1800
1743
|
type: 'Assets',
|
|
@@ -1804,30 +1747,30 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1804
1747
|
amount: processedAssetsAmount
|
|
1805
1748
|
}
|
|
1806
1749
|
}
|
|
1807
|
-
} : undefined) !== null &&
|
|
1750
|
+
} : undefined) !== null && _ref13 !== void 0 ? _ref13 :
|
|
1808
1751
|
//
|
|
1809
1752
|
chain === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1810
1753
|
return event.type === 'Balances' && event.value.type === 'Issued';
|
|
1811
|
-
}) : undefined) !== null &&
|
|
1754
|
+
}) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
|
|
1812
1755
|
//
|
|
1813
1756
|
origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
|
|
1814
1757
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1815
|
-
}) : undefined) !== null &&
|
|
1758
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1816
1759
|
// Prefer to Minted event
|
|
1817
1760
|
reversedEvents.find(function (event) {
|
|
1818
1761
|
return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
|
|
1819
|
-
})) !== null &&
|
|
1762
|
+
})) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1820
1763
|
// Fallback an Issued event
|
|
1821
1764
|
reversedEvents.find(function (event) {
|
|
1822
1765
|
return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
|
|
1823
|
-
})) !== null &&
|
|
1766
|
+
})) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
|
|
1824
1767
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1825
1768
|
});
|
|
1826
1769
|
if (feeEvent) {
|
|
1827
|
-
|
|
1770
|
+
_context20.n = 6;
|
|
1828
1771
|
break;
|
|
1829
1772
|
}
|
|
1830
|
-
return
|
|
1773
|
+
return _context20.a(2, Promise.resolve({
|
|
1831
1774
|
success: false,
|
|
1832
1775
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1833
1776
|
currency: symbol,
|
|
@@ -1839,7 +1782,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1839
1782
|
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1840
1783
|
}
|
|
1841
1784
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padFeeBy(fee, 30) : fee;
|
|
1842
|
-
return
|
|
1785
|
+
return _context20.a(2, Promise.resolve({
|
|
1843
1786
|
success: true,
|
|
1844
1787
|
fee: processedFee,
|
|
1845
1788
|
currency: symbol,
|
|
@@ -1849,9 +1792,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1849
1792
|
destParaId: destParaId
|
|
1850
1793
|
}));
|
|
1851
1794
|
}
|
|
1852
|
-
},
|
|
1795
|
+
}, _callee20, this);
|
|
1853
1796
|
}));
|
|
1854
|
-
function getDryRunXcm(
|
|
1797
|
+
function getDryRunXcm(_x39) {
|
|
1855
1798
|
return _getDryRunXcm.apply(this, arguments);
|
|
1856
1799
|
}
|
|
1857
1800
|
return getDryRunXcm;
|
|
@@ -1859,18 +1802,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1859
1802
|
}, {
|
|
1860
1803
|
key: "getBridgeStatus",
|
|
1861
1804
|
value: function () {
|
|
1862
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1805
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
1863
1806
|
var outboundOperatingMode;
|
|
1864
|
-
return _regenerator().w(function (
|
|
1865
|
-
while (1) switch (
|
|
1807
|
+
return _regenerator().w(function (_context21) {
|
|
1808
|
+
while (1) switch (_context21.n) {
|
|
1866
1809
|
case 0:
|
|
1867
|
-
|
|
1810
|
+
_context21.n = 1;
|
|
1868
1811
|
return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1869
1812
|
case 1:
|
|
1870
|
-
outboundOperatingMode =
|
|
1871
|
-
return
|
|
1813
|
+
outboundOperatingMode = _context21.v;
|
|
1814
|
+
return _context21.a(2, outboundOperatingMode.type);
|
|
1872
1815
|
}
|
|
1873
|
-
},
|
|
1816
|
+
}, _callee21, this);
|
|
1874
1817
|
}));
|
|
1875
1818
|
function getBridgeStatus() {
|
|
1876
1819
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1913,23 +1856,23 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1913
1856
|
}, {
|
|
1914
1857
|
key: "convertLocationToAccount",
|
|
1915
1858
|
value: function () {
|
|
1916
|
-
var _convertLocationToAccount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1859
|
+
var _convertLocationToAccount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(location) {
|
|
1917
1860
|
var res;
|
|
1918
|
-
return _regenerator().w(function (
|
|
1919
|
-
while (1) switch (
|
|
1861
|
+
return _regenerator().w(function (_context22) {
|
|
1862
|
+
while (1) switch (_context22.n) {
|
|
1920
1863
|
case 0:
|
|
1921
|
-
|
|
1864
|
+
_context22.n = 1;
|
|
1922
1865
|
return this.api.getUnsafeApi().apis.LocationToAccountApi.convert_location({
|
|
1923
1866
|
type: Version.V4,
|
|
1924
1867
|
value: _transform(location)
|
|
1925
1868
|
});
|
|
1926
1869
|
case 1:
|
|
1927
|
-
res =
|
|
1928
|
-
return
|
|
1870
|
+
res = _context22.v;
|
|
1871
|
+
return _context22.a(2, res.success ? res.value : undefined);
|
|
1929
1872
|
}
|
|
1930
|
-
},
|
|
1873
|
+
}, _callee22, this);
|
|
1931
1874
|
}));
|
|
1932
|
-
function convertLocationToAccount(
|
|
1875
|
+
function convertLocationToAccount(_x40) {
|
|
1933
1876
|
return _convertLocationToAccount.apply(this, arguments);
|
|
1934
1877
|
}
|
|
1935
1878
|
return convertLocationToAccount;
|