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