@paraspell/sdk-pjs 11.3.2 → 11.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/index.cjs +188 -93
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +189 -94
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -276,6 +276,21 @@ import { hasDryRunSupport } from "@paraspell/sdk";
|
|
|
276
276
|
const result = hasDryRunSupport(chain)
|
|
277
277
|
```
|
|
278
278
|
|
|
279
|
+
#### Dry run preview:
|
|
280
|
+
More on this feature in [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html#preview-your-call-results)
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
//Builder pattern
|
|
284
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
285
|
+
.from(CHAIN)
|
|
286
|
+
.to(CHAIN_2)
|
|
287
|
+
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {location: AssetLocationString, amount: amount | AssetLocationJson, amount: amount} | {location: Override('Custom Location'), amount: amount} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount}]})
|
|
288
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
289
|
+
.address(ADDRESS)
|
|
290
|
+
.senderAddress(SENDER_ADDRESS)
|
|
291
|
+
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
292
|
+
```
|
|
293
|
+
|
|
279
294
|
### Localhost test setup
|
|
280
295
|
|
|
281
296
|
SDK offers enhanced localhost support. You can pass an object containing overrides for all WS endpoints (Including hops) used in the test transfer. This allows for advanced localhost testing such as localhost dry-run or xcm-fee queries. More information about available options can be found in the [official documentation](https://paraspell.github.io/docs/sdk/xcmPallet.html#localhost-testing-setup).
|
package/dist/index.cjs
CHANGED
|
@@ -776,64 +776,159 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
776
776
|
}, {
|
|
777
777
|
key: "getDryRunCall",
|
|
778
778
|
value: function () {
|
|
779
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
780
|
-
var _this
|
|
781
|
-
var tx, address,
|
|
782
|
-
return _regenerator().w(function (
|
|
783
|
-
while (1) switch (
|
|
779
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref4) {
|
|
780
|
+
var _this = this;
|
|
781
|
+
var tx, address, feeAsset, chain, supportsDryRunApi, DEFAULT_XCM_VERSION, usedAsset, usedSymbol, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureReason, shouldRetryWithVersion, msg, _msg, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId, _t, _t2;
|
|
782
|
+
return _regenerator().w(function (_context16) {
|
|
783
|
+
while (1) switch (_context16.p = _context16.n) {
|
|
784
784
|
case 0:
|
|
785
|
-
tx = _ref4.tx, address = _ref4.address,
|
|
785
|
+
tx = _ref4.tx, address = _ref4.address, feeAsset = _ref4.feeAsset, chain = _ref4.chain;
|
|
786
786
|
supportsDryRunApi = sdkCore.getAssetsObject(chain).supportsDryRunApi;
|
|
787
787
|
if (supportsDryRunApi) {
|
|
788
|
-
|
|
788
|
+
_context16.n = 1;
|
|
789
789
|
break;
|
|
790
790
|
}
|
|
791
791
|
throw new sdkCore.ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
792
792
|
case 1:
|
|
793
|
-
chainsRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec', 'Astar'];
|
|
794
|
-
needsVersionParam = chainsRequiringVersionParam.includes(chain);
|
|
795
793
|
DEFAULT_XCM_VERSION = 3;
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
794
|
+
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : sdkCore.findAssetInfoOrThrow(chain, {
|
|
795
|
+
symbol: sdkCore.Native(sdkCore.getNativeAssetSymbol(chain))
|
|
796
|
+
}, null);
|
|
797
|
+
usedSymbol = usedAsset.symbol;
|
|
798
|
+
performDryRunCall = /*#__PURE__*/function () {
|
|
799
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(includeVersion) {
|
|
800
|
+
var _this$api$call$dryRun;
|
|
801
|
+
return _regenerator().w(function (_context15) {
|
|
802
|
+
while (1) switch (_context15.n) {
|
|
803
|
+
case 0:
|
|
804
|
+
return _context15.a(2, (_this$api$call$dryRun = _this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [{
|
|
805
|
+
system: {
|
|
806
|
+
Signed: address
|
|
807
|
+
}
|
|
808
|
+
}, tx].concat(_toConsumableArray(includeVersion ? [DEFAULT_XCM_VERSION] : []))));
|
|
809
|
+
}
|
|
810
|
+
}, _callee15);
|
|
811
|
+
}));
|
|
812
|
+
return function performDryRunCall(_x31) {
|
|
813
|
+
return _ref5.apply(this, arguments);
|
|
814
|
+
};
|
|
815
|
+
}();
|
|
816
|
+
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(resultHuman) {
|
|
817
|
+
var _resultHuman$Ok$execu;
|
|
818
|
+
return Boolean((resultHuman === null || resultHuman === void 0 ? void 0 : resultHuman.Ok) && ((_resultHuman$Ok$execu = resultHuman.Ok.executionResult) === null || _resultHuman$Ok$execu === void 0 ? void 0 : _resultHuman$Ok$execu.Ok));
|
|
819
|
+
};
|
|
820
|
+
extractFailureReasonFromResult = function extractFailureReasonFromResult(resultHuman, resultJson) {
|
|
821
|
+
var _resultHuman$Ok, _resultHuman$Ok2, _resultJson$ok, _ref6;
|
|
822
|
+
var modErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok = resultHuman.Ok) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.executionResult) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.Err) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.error) === null || _resultHuman$Ok === void 0 ? void 0 : _resultHuman$Ok.Module;
|
|
823
|
+
if (modErrHuman) {
|
|
824
|
+
return sdkCore.resolveModuleError(chain, modErrHuman);
|
|
800
825
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
826
|
+
var otherErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok2 = resultHuman.Ok) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.executionResult) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.Err) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.error) === null || _resultHuman$Ok2 === void 0 ? void 0 : _resultHuman$Ok2.Other;
|
|
827
|
+
if (otherErrHuman) {
|
|
828
|
+
return String(otherErrHuman);
|
|
829
|
+
}
|
|
830
|
+
var execErrJson = resultJson === null || resultJson === void 0 || (_resultJson$ok = resultJson.ok) === null || _resultJson$ok === void 0 || (_resultJson$ok = _resultJson$ok.executionResult) === null || _resultJson$ok === void 0 || (_resultJson$ok = _resultJson$ok.err) === null || _resultJson$ok === void 0 ? void 0 : _resultJson$ok.error;
|
|
831
|
+
if (execErrJson !== null && execErrJson !== void 0 && execErrJson.module) {
|
|
832
|
+
return sdkCore.resolveModuleError(chain, execErrJson.module);
|
|
833
|
+
}
|
|
834
|
+
if (execErrJson !== null && execErrJson !== void 0 && execErrJson.other) {
|
|
835
|
+
return String(execErrJson.other);
|
|
836
|
+
}
|
|
837
|
+
return JSON.stringify((_ref6 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref6 !== void 0 ? _ref6 : 'Unknown error');
|
|
838
|
+
}; // Attempt 1: WITHOUT version
|
|
839
|
+
isSuccess = false;
|
|
840
|
+
failureReason = '';
|
|
841
|
+
shouldRetryWithVersion = false;
|
|
842
|
+
_context16.p = 2;
|
|
843
|
+
_context16.n = 3;
|
|
844
|
+
return performDryRunCall(false);
|
|
845
|
+
case 3:
|
|
846
|
+
response = _context16.v;
|
|
847
|
+
resultHuman = response.toHuman();
|
|
805
848
|
resultJson = response.toJSON();
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
849
|
+
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
850
|
+
if (!isSuccess) {
|
|
851
|
+
failureReason = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
852
|
+
if (failureReason === 'VersionedConversionFailed') {
|
|
853
|
+
shouldRetryWithVersion = true;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
_context16.n = 6;
|
|
857
|
+
break;
|
|
858
|
+
case 4:
|
|
859
|
+
_context16.p = 4;
|
|
860
|
+
_t = _context16.v;
|
|
861
|
+
msg = _t instanceof Error ? _t.message : String(_t);
|
|
862
|
+
if (!msg.includes('Expected 3 arguments')) {
|
|
863
|
+
_context16.n = 5;
|
|
811
864
|
break;
|
|
812
865
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
866
|
+
shouldRetryWithVersion = true;
|
|
867
|
+
_context16.n = 6;
|
|
868
|
+
break;
|
|
869
|
+
case 5:
|
|
870
|
+
return _context16.a(2, {
|
|
871
|
+
success: false,
|
|
872
|
+
failureReason: msg,
|
|
873
|
+
currency: usedSymbol,
|
|
874
|
+
asset: usedAsset
|
|
875
|
+
});
|
|
876
|
+
case 6:
|
|
877
|
+
if (!shouldRetryWithVersion) {
|
|
878
|
+
_context16.n = 10;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
_context16.p = 7;
|
|
882
|
+
_context16.n = 8;
|
|
883
|
+
return performDryRunCall(true);
|
|
884
|
+
case 8:
|
|
885
|
+
response = _context16.v;
|
|
886
|
+
resultHuman = response.toHuman();
|
|
887
|
+
resultJson = response.toJSON();
|
|
888
|
+
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
889
|
+
if (!isSuccess) {
|
|
890
|
+
failureReason = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
891
|
+
}
|
|
892
|
+
_context16.n = 10;
|
|
893
|
+
break;
|
|
894
|
+
case 9:
|
|
895
|
+
_context16.p = 9;
|
|
896
|
+
_t2 = _context16.v;
|
|
897
|
+
_msg = _t2 instanceof Error ? _t2.message : String(_t2);
|
|
898
|
+
failureReason = failureReason || _msg;
|
|
899
|
+
return _context16.a(2, {
|
|
816
900
|
success: false,
|
|
817
901
|
failureReason: failureReason,
|
|
818
902
|
currency: usedSymbol,
|
|
819
903
|
asset: usedAsset
|
|
820
904
|
});
|
|
821
|
-
case
|
|
822
|
-
|
|
905
|
+
case 10:
|
|
906
|
+
if (isSuccess) {
|
|
907
|
+
_context16.n = 11;
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
return _context16.a(2, {
|
|
911
|
+
success: false,
|
|
912
|
+
failureReason: failureReason || 'Unknown error',
|
|
913
|
+
currency: usedSymbol,
|
|
914
|
+
asset: usedAsset
|
|
915
|
+
});
|
|
916
|
+
case 11:
|
|
917
|
+
_context16.n = 12;
|
|
823
918
|
return this.calculateTransactionFee(tx, address);
|
|
824
|
-
case
|
|
825
|
-
executionFee =
|
|
826
|
-
fee = sdkCore.computeFeeFromDryRunPjs(
|
|
919
|
+
case 12:
|
|
920
|
+
executionFee = _context16.v;
|
|
921
|
+
fee = sdkCore.computeFeeFromDryRunPjs(resultHuman, chain, executionFee);
|
|
827
922
|
actualWeight = resultJson.ok.executionResult.ok.actualWeight;
|
|
828
923
|
weight = actualWeight ? {
|
|
829
924
|
refTime: BigInt(actualWeight.refTime),
|
|
830
925
|
proofSize: BigInt(actualWeight.proofSize)
|
|
831
926
|
} : undefined;
|
|
832
927
|
forwardedXcms = resultJson.ok.forwardedXcms.length > 0 ? resultJson.ok.forwardedXcms[0] : [];
|
|
833
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
834
|
-
return i.here === null ? 0 : (
|
|
928
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref7) {
|
|
929
|
+
return i.here === null ? 0 : (_ref7 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref7 === void 0 ? void 0 : _ref7.parachain;
|
|
835
930
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
836
|
-
return
|
|
931
|
+
return _context16.a(2, {
|
|
837
932
|
success: true,
|
|
838
933
|
fee: fee,
|
|
839
934
|
currency: usedSymbol,
|
|
@@ -843,7 +938,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
843
938
|
destParaId: destParaId
|
|
844
939
|
});
|
|
845
940
|
}
|
|
846
|
-
},
|
|
941
|
+
}, _callee16, this, [[7, 9], [2, 4]]);
|
|
847
942
|
}));
|
|
848
943
|
function getDryRunCall(_x30) {
|
|
849
944
|
return _getDryRunCall.apply(this, arguments);
|
|
@@ -853,27 +948,27 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
853
948
|
}, {
|
|
854
949
|
key: "getXcmPaymentApiFee",
|
|
855
950
|
value: function () {
|
|
856
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
951
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(chain, xcm, asset) {
|
|
857
952
|
var weight, localizedLocation, feeResult, res;
|
|
858
|
-
return _regenerator().w(function (
|
|
859
|
-
while (1) switch (
|
|
953
|
+
return _regenerator().w(function (_context17) {
|
|
954
|
+
while (1) switch (_context17.n) {
|
|
860
955
|
case 0:
|
|
861
|
-
|
|
956
|
+
_context17.n = 1;
|
|
862
957
|
return this.getXcmWeight(xcm);
|
|
863
958
|
case 1:
|
|
864
|
-
weight =
|
|
959
|
+
weight = _context17.v;
|
|
865
960
|
sdkCore.assertHasLocation(asset);
|
|
866
961
|
localizedLocation = chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama' || sdkCore.isRelayChain(chain) ? sdkCore.localizeLocation(chain, asset.location) : asset.location;
|
|
867
|
-
|
|
962
|
+
_context17.n = 2;
|
|
868
963
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, sdkCore.addXcmVersionHeader(localizedLocation, sdkCore.Version.V4));
|
|
869
964
|
case 2:
|
|
870
|
-
feeResult =
|
|
965
|
+
feeResult = _context17.v;
|
|
871
966
|
res = feeResult.toJSON();
|
|
872
|
-
return
|
|
967
|
+
return _context17.a(2, BigInt(res.ok));
|
|
873
968
|
}
|
|
874
|
-
},
|
|
969
|
+
}, _callee17, this);
|
|
875
970
|
}));
|
|
876
|
-
function getXcmPaymentApiFee(
|
|
971
|
+
function getXcmPaymentApiFee(_x32, _x33, _x34) {
|
|
877
972
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
878
973
|
}
|
|
879
974
|
return getXcmPaymentApiFee;
|
|
@@ -881,21 +976,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
881
976
|
}, {
|
|
882
977
|
key: "getXcmWeight",
|
|
883
978
|
value: function () {
|
|
884
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
979
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(xcm) {
|
|
885
980
|
var result, resultJson;
|
|
886
|
-
return _regenerator().w(function (
|
|
887
|
-
while (1) switch (
|
|
981
|
+
return _regenerator().w(function (_context18) {
|
|
982
|
+
while (1) switch (_context18.n) {
|
|
888
983
|
case 0:
|
|
889
|
-
|
|
984
|
+
_context18.n = 1;
|
|
890
985
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
891
986
|
case 1:
|
|
892
|
-
result =
|
|
987
|
+
result = _context18.v;
|
|
893
988
|
resultJson = result.toJSON();
|
|
894
|
-
return
|
|
989
|
+
return _context18.a(2, resultJson.ok);
|
|
895
990
|
}
|
|
896
|
-
},
|
|
991
|
+
}, _callee18, this);
|
|
897
992
|
}));
|
|
898
|
-
function getXcmWeight(
|
|
993
|
+
function getXcmWeight(_x35) {
|
|
899
994
|
return _getXcmWeight.apply(this, arguments);
|
|
900
995
|
}
|
|
901
996
|
return getXcmWeight;
|
|
@@ -903,34 +998,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
903
998
|
}, {
|
|
904
999
|
key: "getDryRunXcm",
|
|
905
1000
|
value: function () {
|
|
906
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
907
|
-
var
|
|
1001
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref8) {
|
|
1002
|
+
var _ref9, _ref0, _ref1;
|
|
908
1003
|
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, symbol, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
909
|
-
return _regenerator().w(function (
|
|
910
|
-
while (1) switch (
|
|
1004
|
+
return _regenerator().w(function (_context19) {
|
|
1005
|
+
while (1) switch (_context19.n) {
|
|
911
1006
|
case 0:
|
|
912
|
-
originLocation =
|
|
1007
|
+
originLocation = _ref8.originLocation, xcm = _ref8.xcm, asset = _ref8.asset, chain = _ref8.chain, origin = _ref8.origin;
|
|
913
1008
|
supportsDryRunApi = sdkCore.getAssetsObject(chain).supportsDryRunApi;
|
|
914
1009
|
if (supportsDryRunApi) {
|
|
915
|
-
|
|
1010
|
+
_context19.n = 1;
|
|
916
1011
|
break;
|
|
917
1012
|
}
|
|
918
1013
|
throw new sdkCore.ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
919
1014
|
case 1:
|
|
920
|
-
|
|
1015
|
+
_context19.n = 2;
|
|
921
1016
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
922
1017
|
case 2:
|
|
923
|
-
response =
|
|
1018
|
+
response = _context19.v;
|
|
924
1019
|
result = response.toHuman();
|
|
925
1020
|
resultJson = response.toJSON();
|
|
926
1021
|
symbol = asset.symbol;
|
|
927
1022
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
928
1023
|
if (isSuccess) {
|
|
929
|
-
|
|
1024
|
+
_context19.n = 3;
|
|
930
1025
|
break;
|
|
931
1026
|
}
|
|
932
1027
|
failureReason = result.Ok.executionResult.Incomplete.error;
|
|
933
|
-
return
|
|
1028
|
+
return _context19.a(2, {
|
|
934
1029
|
success: false,
|
|
935
1030
|
failureReason: failureReason,
|
|
936
1031
|
currency: symbol,
|
|
@@ -940,24 +1035,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
940
1035
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
941
1036
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
942
1037
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
943
|
-
feeEvent = (
|
|
1038
|
+
feeEvent = (_ref9 = (_ref0 = (_ref1 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
944
1039
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
945
|
-
}) : undefined) !== null &&
|
|
1040
|
+
}) : undefined) !== null && _ref1 !== void 0 ? _ref1 :
|
|
946
1041
|
// Prefer an Issued event
|
|
947
1042
|
reversedEvents.find(function (event) {
|
|
948
1043
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
949
|
-
})) !== null &&
|
|
1044
|
+
})) !== null && _ref0 !== void 0 ? _ref0 :
|
|
950
1045
|
// Fallback to Minted event
|
|
951
1046
|
reversedEvents.find(function (event) {
|
|
952
1047
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
953
|
-
})) !== null &&
|
|
1048
|
+
})) !== null && _ref9 !== void 0 ? _ref9 : reversedEvents.find(function (event) {
|
|
954
1049
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
955
1050
|
});
|
|
956
1051
|
if (feeEvent) {
|
|
957
|
-
|
|
1052
|
+
_context19.n = 4;
|
|
958
1053
|
break;
|
|
959
1054
|
}
|
|
960
|
-
return
|
|
1055
|
+
return _context19.a(2, Promise.resolve({
|
|
961
1056
|
success: false,
|
|
962
1057
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
963
1058
|
currency: symbol,
|
|
@@ -972,10 +1067,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
972
1067
|
proofSize: BigInt(actualWeight.proofSize)
|
|
973
1068
|
} : undefined;
|
|
974
1069
|
forwardedXcms = resultJson.ok.forwardedXcms.length > 0 ? resultJson.ok.forwardedXcms[0] : [];
|
|
975
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
976
|
-
return i.Here ? 0 : (
|
|
1070
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref10) {
|
|
1071
|
+
return i.Here ? 0 : (_ref10 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref10 === void 0 ? void 0 : _ref10.parachain;
|
|
977
1072
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
978
|
-
return
|
|
1073
|
+
return _context19.a(2, {
|
|
979
1074
|
success: true,
|
|
980
1075
|
fee: fee,
|
|
981
1076
|
currency: symbol,
|
|
@@ -985,9 +1080,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
985
1080
|
destParaId: destParaId
|
|
986
1081
|
});
|
|
987
1082
|
}
|
|
988
|
-
},
|
|
1083
|
+
}, _callee19, this);
|
|
989
1084
|
}));
|
|
990
|
-
function getDryRunXcm(
|
|
1085
|
+
function getDryRunXcm(_x36) {
|
|
991
1086
|
return _getDryRunXcm.apply(this, arguments);
|
|
992
1087
|
}
|
|
993
1088
|
return getDryRunXcm;
|
|
@@ -995,18 +1090,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
995
1090
|
}, {
|
|
996
1091
|
key: "getBridgeStatus",
|
|
997
1092
|
value: function () {
|
|
998
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1093
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
999
1094
|
var outboundOperatingMode;
|
|
1000
|
-
return _regenerator().w(function (
|
|
1001
|
-
while (1) switch (
|
|
1095
|
+
return _regenerator().w(function (_context20) {
|
|
1096
|
+
while (1) switch (_context20.n) {
|
|
1002
1097
|
case 0:
|
|
1003
|
-
|
|
1098
|
+
_context20.n = 1;
|
|
1004
1099
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1005
1100
|
case 1:
|
|
1006
|
-
outboundOperatingMode =
|
|
1007
|
-
return
|
|
1101
|
+
outboundOperatingMode = _context20.v;
|
|
1102
|
+
return _context20.a(2, outboundOperatingMode.toPrimitive());
|
|
1008
1103
|
}
|
|
1009
|
-
},
|
|
1104
|
+
}, _callee20, this);
|
|
1010
1105
|
}));
|
|
1011
1106
|
function getBridgeStatus() {
|
|
1012
1107
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1026,38 +1121,38 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1026
1121
|
}, {
|
|
1027
1122
|
key: "disconnect",
|
|
1028
1123
|
value: function () {
|
|
1029
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1124
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
1030
1125
|
var _this$_config$apiOver2;
|
|
1031
1126
|
var force,
|
|
1032
1127
|
api,
|
|
1033
|
-
|
|
1034
|
-
return _regenerator().w(function (
|
|
1035
|
-
while (1) switch (
|
|
1128
|
+
_args21 = arguments;
|
|
1129
|
+
return _regenerator().w(function (_context21) {
|
|
1130
|
+
while (1) switch (_context21.n) {
|
|
1036
1131
|
case 0:
|
|
1037
|
-
force =
|
|
1132
|
+
force = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : false;
|
|
1038
1133
|
if (this.initialized) {
|
|
1039
|
-
|
|
1134
|
+
_context21.n = 1;
|
|
1040
1135
|
break;
|
|
1041
1136
|
}
|
|
1042
|
-
return
|
|
1137
|
+
return _context21.a(2, Promise.resolve());
|
|
1043
1138
|
case 1:
|
|
1044
1139
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1045
|
-
|
|
1140
|
+
_context21.n = 2;
|
|
1046
1141
|
break;
|
|
1047
1142
|
}
|
|
1048
|
-
return
|
|
1143
|
+
return _context21.a(2);
|
|
1049
1144
|
case 2:
|
|
1050
1145
|
api = sdkCore.isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._chain] : this._config; // Disconnect api only if it was created automatically
|
|
1051
1146
|
if (!(force || typeof api === 'string' || api === undefined)) {
|
|
1052
|
-
|
|
1147
|
+
_context21.n = 3;
|
|
1053
1148
|
break;
|
|
1054
1149
|
}
|
|
1055
|
-
|
|
1150
|
+
_context21.n = 3;
|
|
1056
1151
|
return this.api.disconnect();
|
|
1057
1152
|
case 3:
|
|
1058
|
-
return
|
|
1153
|
+
return _context21.a(2);
|
|
1059
1154
|
}
|
|
1060
|
-
},
|
|
1155
|
+
}, _callee21, this);
|
|
1061
1156
|
}));
|
|
1062
1157
|
function disconnect() {
|
|
1063
1158
|
return _disconnect.apply(this, arguments);
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ declare const getBalanceNative: (options: _paraspell_sdk_core.TGetBalanceNativeO
|
|
|
57
57
|
* @returns The balance of the foreign asset as a bigint, or null if not found.
|
|
58
58
|
*/
|
|
59
59
|
declare const getBalanceForeign: (options: _paraspell_sdk_core.TGetBalanceForeignOptionsBase & {
|
|
60
|
+
currency: _paraspell_sdk_core.TCurrencyCore;
|
|
61
|
+
} & {
|
|
60
62
|
api?: TPjsApiOrUrl;
|
|
61
63
|
}) => Promise<bigint>;
|
|
62
64
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isConfig, BatchMode, MissingChainApiError, createChainClient as createChainClient$1, getChain, isForeignAsset, InvalidParameterError, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, ChainNotSupportedError, assertHasLocation, localizeLocation, isRelayChain, addXcmVersionHeader, Version, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract,
|
|
1
|
+
import { isConfig, BatchMode, MissingChainApiError, createChainClient as createChainClient$1, getChain, isForeignAsset, InvalidParameterError, computeFeeFromDryRunPjs, findAssetInfoOrThrow, Native, getNativeAssetSymbol, resolveModuleError, getAssetsObject, ChainNotSupportedError, assertHasLocation, localizeLocation, isRelayChain, addXcmVersionHeader, Version, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, abstractDecimals, assertHasId, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { WsProvider, ApiPromise } from '@polkadot/api';
|
|
4
4
|
import { u32 } from '@polkadot/types';
|
|
@@ -775,64 +775,159 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
775
775
|
}, {
|
|
776
776
|
key: "getDryRunCall",
|
|
777
777
|
value: function () {
|
|
778
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
779
|
-
var _this
|
|
780
|
-
var tx, address,
|
|
781
|
-
return _regenerator().w(function (
|
|
782
|
-
while (1) switch (
|
|
778
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref4) {
|
|
779
|
+
var _this = this;
|
|
780
|
+
var tx, address, feeAsset, chain, supportsDryRunApi, DEFAULT_XCM_VERSION, usedAsset, usedSymbol, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureReason, shouldRetryWithVersion, msg, _msg, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId, _t, _t2;
|
|
781
|
+
return _regenerator().w(function (_context16) {
|
|
782
|
+
while (1) switch (_context16.p = _context16.n) {
|
|
783
783
|
case 0:
|
|
784
|
-
tx = _ref4.tx, address = _ref4.address,
|
|
784
|
+
tx = _ref4.tx, address = _ref4.address, feeAsset = _ref4.feeAsset, chain = _ref4.chain;
|
|
785
785
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
786
786
|
if (supportsDryRunApi) {
|
|
787
|
-
|
|
787
|
+
_context16.n = 1;
|
|
788
788
|
break;
|
|
789
789
|
}
|
|
790
790
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
791
791
|
case 1:
|
|
792
|
-
chainsRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec', 'Astar'];
|
|
793
|
-
needsVersionParam = chainsRequiringVersionParam.includes(chain);
|
|
794
792
|
DEFAULT_XCM_VERSION = 3;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
793
|
+
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : findAssetInfoOrThrow(chain, {
|
|
794
|
+
symbol: Native(getNativeAssetSymbol(chain))
|
|
795
|
+
}, null);
|
|
796
|
+
usedSymbol = usedAsset.symbol;
|
|
797
|
+
performDryRunCall = /*#__PURE__*/function () {
|
|
798
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(includeVersion) {
|
|
799
|
+
var _this$api$call$dryRun;
|
|
800
|
+
return _regenerator().w(function (_context15) {
|
|
801
|
+
while (1) switch (_context15.n) {
|
|
802
|
+
case 0:
|
|
803
|
+
return _context15.a(2, (_this$api$call$dryRun = _this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [{
|
|
804
|
+
system: {
|
|
805
|
+
Signed: address
|
|
806
|
+
}
|
|
807
|
+
}, tx].concat(_toConsumableArray(includeVersion ? [DEFAULT_XCM_VERSION] : []))));
|
|
808
|
+
}
|
|
809
|
+
}, _callee15);
|
|
810
|
+
}));
|
|
811
|
+
return function performDryRunCall(_x31) {
|
|
812
|
+
return _ref5.apply(this, arguments);
|
|
813
|
+
};
|
|
814
|
+
}();
|
|
815
|
+
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(resultHuman) {
|
|
816
|
+
var _resultHuman$Ok$execu;
|
|
817
|
+
return Boolean((resultHuman === null || resultHuman === void 0 ? void 0 : resultHuman.Ok) && ((_resultHuman$Ok$execu = resultHuman.Ok.executionResult) === null || _resultHuman$Ok$execu === void 0 ? void 0 : _resultHuman$Ok$execu.Ok));
|
|
818
|
+
};
|
|
819
|
+
extractFailureReasonFromResult = function extractFailureReasonFromResult(resultHuman, resultJson) {
|
|
820
|
+
var _resultHuman$Ok, _resultHuman$Ok2, _resultJson$ok, _ref6;
|
|
821
|
+
var modErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok = resultHuman.Ok) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.executionResult) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.Err) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.error) === null || _resultHuman$Ok === void 0 ? void 0 : _resultHuman$Ok.Module;
|
|
822
|
+
if (modErrHuman) {
|
|
823
|
+
return resolveModuleError(chain, modErrHuman);
|
|
799
824
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
825
|
+
var otherErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok2 = resultHuman.Ok) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.executionResult) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.Err) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.error) === null || _resultHuman$Ok2 === void 0 ? void 0 : _resultHuman$Ok2.Other;
|
|
826
|
+
if (otherErrHuman) {
|
|
827
|
+
return String(otherErrHuman);
|
|
828
|
+
}
|
|
829
|
+
var execErrJson = resultJson === null || resultJson === void 0 || (_resultJson$ok = resultJson.ok) === null || _resultJson$ok === void 0 || (_resultJson$ok = _resultJson$ok.executionResult) === null || _resultJson$ok === void 0 || (_resultJson$ok = _resultJson$ok.err) === null || _resultJson$ok === void 0 ? void 0 : _resultJson$ok.error;
|
|
830
|
+
if (execErrJson !== null && execErrJson !== void 0 && execErrJson.module) {
|
|
831
|
+
return resolveModuleError(chain, execErrJson.module);
|
|
832
|
+
}
|
|
833
|
+
if (execErrJson !== null && execErrJson !== void 0 && execErrJson.other) {
|
|
834
|
+
return String(execErrJson.other);
|
|
835
|
+
}
|
|
836
|
+
return JSON.stringify((_ref6 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref6 !== void 0 ? _ref6 : 'Unknown error');
|
|
837
|
+
}; // Attempt 1: WITHOUT version
|
|
838
|
+
isSuccess = false;
|
|
839
|
+
failureReason = '';
|
|
840
|
+
shouldRetryWithVersion = false;
|
|
841
|
+
_context16.p = 2;
|
|
842
|
+
_context16.n = 3;
|
|
843
|
+
return performDryRunCall(false);
|
|
844
|
+
case 3:
|
|
845
|
+
response = _context16.v;
|
|
846
|
+
resultHuman = response.toHuman();
|
|
804
847
|
resultJson = response.toJSON();
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
848
|
+
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
849
|
+
if (!isSuccess) {
|
|
850
|
+
failureReason = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
851
|
+
if (failureReason === 'VersionedConversionFailed') {
|
|
852
|
+
shouldRetryWithVersion = true;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
_context16.n = 6;
|
|
856
|
+
break;
|
|
857
|
+
case 4:
|
|
858
|
+
_context16.p = 4;
|
|
859
|
+
_t = _context16.v;
|
|
860
|
+
msg = _t instanceof Error ? _t.message : String(_t);
|
|
861
|
+
if (!msg.includes('Expected 3 arguments')) {
|
|
862
|
+
_context16.n = 5;
|
|
810
863
|
break;
|
|
811
864
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
865
|
+
shouldRetryWithVersion = true;
|
|
866
|
+
_context16.n = 6;
|
|
867
|
+
break;
|
|
868
|
+
case 5:
|
|
869
|
+
return _context16.a(2, {
|
|
870
|
+
success: false,
|
|
871
|
+
failureReason: msg,
|
|
872
|
+
currency: usedSymbol,
|
|
873
|
+
asset: usedAsset
|
|
874
|
+
});
|
|
875
|
+
case 6:
|
|
876
|
+
if (!shouldRetryWithVersion) {
|
|
877
|
+
_context16.n = 10;
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
_context16.p = 7;
|
|
881
|
+
_context16.n = 8;
|
|
882
|
+
return performDryRunCall(true);
|
|
883
|
+
case 8:
|
|
884
|
+
response = _context16.v;
|
|
885
|
+
resultHuman = response.toHuman();
|
|
886
|
+
resultJson = response.toJSON();
|
|
887
|
+
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
888
|
+
if (!isSuccess) {
|
|
889
|
+
failureReason = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
890
|
+
}
|
|
891
|
+
_context16.n = 10;
|
|
892
|
+
break;
|
|
893
|
+
case 9:
|
|
894
|
+
_context16.p = 9;
|
|
895
|
+
_t2 = _context16.v;
|
|
896
|
+
_msg = _t2 instanceof Error ? _t2.message : String(_t2);
|
|
897
|
+
failureReason = failureReason || _msg;
|
|
898
|
+
return _context16.a(2, {
|
|
815
899
|
success: false,
|
|
816
900
|
failureReason: failureReason,
|
|
817
901
|
currency: usedSymbol,
|
|
818
902
|
asset: usedAsset
|
|
819
903
|
});
|
|
820
|
-
case
|
|
821
|
-
|
|
904
|
+
case 10:
|
|
905
|
+
if (isSuccess) {
|
|
906
|
+
_context16.n = 11;
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
return _context16.a(2, {
|
|
910
|
+
success: false,
|
|
911
|
+
failureReason: failureReason || 'Unknown error',
|
|
912
|
+
currency: usedSymbol,
|
|
913
|
+
asset: usedAsset
|
|
914
|
+
});
|
|
915
|
+
case 11:
|
|
916
|
+
_context16.n = 12;
|
|
822
917
|
return this.calculateTransactionFee(tx, address);
|
|
823
|
-
case
|
|
824
|
-
executionFee =
|
|
825
|
-
fee = computeFeeFromDryRunPjs(
|
|
918
|
+
case 12:
|
|
919
|
+
executionFee = _context16.v;
|
|
920
|
+
fee = computeFeeFromDryRunPjs(resultHuman, chain, executionFee);
|
|
826
921
|
actualWeight = resultJson.ok.executionResult.ok.actualWeight;
|
|
827
922
|
weight = actualWeight ? {
|
|
828
923
|
refTime: BigInt(actualWeight.refTime),
|
|
829
924
|
proofSize: BigInt(actualWeight.proofSize)
|
|
830
925
|
} : undefined;
|
|
831
926
|
forwardedXcms = resultJson.ok.forwardedXcms.length > 0 ? resultJson.ok.forwardedXcms[0] : [];
|
|
832
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
833
|
-
return i.here === null ? 0 : (
|
|
927
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref7) {
|
|
928
|
+
return i.here === null ? 0 : (_ref7 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref7 === void 0 ? void 0 : _ref7.parachain;
|
|
834
929
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
835
|
-
return
|
|
930
|
+
return _context16.a(2, {
|
|
836
931
|
success: true,
|
|
837
932
|
fee: fee,
|
|
838
933
|
currency: usedSymbol,
|
|
@@ -842,7 +937,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
842
937
|
destParaId: destParaId
|
|
843
938
|
});
|
|
844
939
|
}
|
|
845
|
-
},
|
|
940
|
+
}, _callee16, this, [[7, 9], [2, 4]]);
|
|
846
941
|
}));
|
|
847
942
|
function getDryRunCall(_x30) {
|
|
848
943
|
return _getDryRunCall.apply(this, arguments);
|
|
@@ -852,27 +947,27 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
852
947
|
}, {
|
|
853
948
|
key: "getXcmPaymentApiFee",
|
|
854
949
|
value: function () {
|
|
855
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
950
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(chain, xcm, asset) {
|
|
856
951
|
var weight, localizedLocation, feeResult, res;
|
|
857
|
-
return _regenerator().w(function (
|
|
858
|
-
while (1) switch (
|
|
952
|
+
return _regenerator().w(function (_context17) {
|
|
953
|
+
while (1) switch (_context17.n) {
|
|
859
954
|
case 0:
|
|
860
|
-
|
|
955
|
+
_context17.n = 1;
|
|
861
956
|
return this.getXcmWeight(xcm);
|
|
862
957
|
case 1:
|
|
863
|
-
weight =
|
|
958
|
+
weight = _context17.v;
|
|
864
959
|
assertHasLocation(asset);
|
|
865
960
|
localizedLocation = chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama' || isRelayChain(chain) ? localizeLocation(chain, asset.location) : asset.location;
|
|
866
|
-
|
|
961
|
+
_context17.n = 2;
|
|
867
962
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(localizedLocation, Version.V4));
|
|
868
963
|
case 2:
|
|
869
|
-
feeResult =
|
|
964
|
+
feeResult = _context17.v;
|
|
870
965
|
res = feeResult.toJSON();
|
|
871
|
-
return
|
|
966
|
+
return _context17.a(2, BigInt(res.ok));
|
|
872
967
|
}
|
|
873
|
-
},
|
|
968
|
+
}, _callee17, this);
|
|
874
969
|
}));
|
|
875
|
-
function getXcmPaymentApiFee(
|
|
970
|
+
function getXcmPaymentApiFee(_x32, _x33, _x34) {
|
|
876
971
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
877
972
|
}
|
|
878
973
|
return getXcmPaymentApiFee;
|
|
@@ -880,21 +975,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
880
975
|
}, {
|
|
881
976
|
key: "getXcmWeight",
|
|
882
977
|
value: function () {
|
|
883
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
978
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(xcm) {
|
|
884
979
|
var result, resultJson;
|
|
885
|
-
return _regenerator().w(function (
|
|
886
|
-
while (1) switch (
|
|
980
|
+
return _regenerator().w(function (_context18) {
|
|
981
|
+
while (1) switch (_context18.n) {
|
|
887
982
|
case 0:
|
|
888
|
-
|
|
983
|
+
_context18.n = 1;
|
|
889
984
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
890
985
|
case 1:
|
|
891
|
-
result =
|
|
986
|
+
result = _context18.v;
|
|
892
987
|
resultJson = result.toJSON();
|
|
893
|
-
return
|
|
988
|
+
return _context18.a(2, resultJson.ok);
|
|
894
989
|
}
|
|
895
|
-
},
|
|
990
|
+
}, _callee18, this);
|
|
896
991
|
}));
|
|
897
|
-
function getXcmWeight(
|
|
992
|
+
function getXcmWeight(_x35) {
|
|
898
993
|
return _getXcmWeight.apply(this, arguments);
|
|
899
994
|
}
|
|
900
995
|
return getXcmWeight;
|
|
@@ -902,34 +997,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
902
997
|
}, {
|
|
903
998
|
key: "getDryRunXcm",
|
|
904
999
|
value: function () {
|
|
905
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
906
|
-
var
|
|
1000
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref8) {
|
|
1001
|
+
var _ref9, _ref0, _ref1;
|
|
907
1002
|
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, symbol, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
908
|
-
return _regenerator().w(function (
|
|
909
|
-
while (1) switch (
|
|
1003
|
+
return _regenerator().w(function (_context19) {
|
|
1004
|
+
while (1) switch (_context19.n) {
|
|
910
1005
|
case 0:
|
|
911
|
-
originLocation =
|
|
1006
|
+
originLocation = _ref8.originLocation, xcm = _ref8.xcm, asset = _ref8.asset, chain = _ref8.chain, origin = _ref8.origin;
|
|
912
1007
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
913
1008
|
if (supportsDryRunApi) {
|
|
914
|
-
|
|
1009
|
+
_context19.n = 1;
|
|
915
1010
|
break;
|
|
916
1011
|
}
|
|
917
1012
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
918
1013
|
case 1:
|
|
919
|
-
|
|
1014
|
+
_context19.n = 2;
|
|
920
1015
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
921
1016
|
case 2:
|
|
922
|
-
response =
|
|
1017
|
+
response = _context19.v;
|
|
923
1018
|
result = response.toHuman();
|
|
924
1019
|
resultJson = response.toJSON();
|
|
925
1020
|
symbol = asset.symbol;
|
|
926
1021
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
927
1022
|
if (isSuccess) {
|
|
928
|
-
|
|
1023
|
+
_context19.n = 3;
|
|
929
1024
|
break;
|
|
930
1025
|
}
|
|
931
1026
|
failureReason = result.Ok.executionResult.Incomplete.error;
|
|
932
|
-
return
|
|
1027
|
+
return _context19.a(2, {
|
|
933
1028
|
success: false,
|
|
934
1029
|
failureReason: failureReason,
|
|
935
1030
|
currency: symbol,
|
|
@@ -939,24 +1034,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
939
1034
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
940
1035
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
941
1036
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
942
|
-
feeEvent = (
|
|
1037
|
+
feeEvent = (_ref9 = (_ref0 = (_ref1 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
943
1038
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
944
|
-
}) : undefined) !== null &&
|
|
1039
|
+
}) : undefined) !== null && _ref1 !== void 0 ? _ref1 :
|
|
945
1040
|
// Prefer an Issued event
|
|
946
1041
|
reversedEvents.find(function (event) {
|
|
947
1042
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
948
|
-
})) !== null &&
|
|
1043
|
+
})) !== null && _ref0 !== void 0 ? _ref0 :
|
|
949
1044
|
// Fallback to Minted event
|
|
950
1045
|
reversedEvents.find(function (event) {
|
|
951
1046
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
952
|
-
})) !== null &&
|
|
1047
|
+
})) !== null && _ref9 !== void 0 ? _ref9 : reversedEvents.find(function (event) {
|
|
953
1048
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
954
1049
|
});
|
|
955
1050
|
if (feeEvent) {
|
|
956
|
-
|
|
1051
|
+
_context19.n = 4;
|
|
957
1052
|
break;
|
|
958
1053
|
}
|
|
959
|
-
return
|
|
1054
|
+
return _context19.a(2, Promise.resolve({
|
|
960
1055
|
success: false,
|
|
961
1056
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
962
1057
|
currency: symbol,
|
|
@@ -971,10 +1066,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
971
1066
|
proofSize: BigInt(actualWeight.proofSize)
|
|
972
1067
|
} : undefined;
|
|
973
1068
|
forwardedXcms = resultJson.ok.forwardedXcms.length > 0 ? resultJson.ok.forwardedXcms[0] : [];
|
|
974
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
975
|
-
return i.Here ? 0 : (
|
|
1069
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref10) {
|
|
1070
|
+
return i.Here ? 0 : (_ref10 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref10 === void 0 ? void 0 : _ref10.parachain;
|
|
976
1071
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
977
|
-
return
|
|
1072
|
+
return _context19.a(2, {
|
|
978
1073
|
success: true,
|
|
979
1074
|
fee: fee,
|
|
980
1075
|
currency: symbol,
|
|
@@ -984,9 +1079,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
984
1079
|
destParaId: destParaId
|
|
985
1080
|
});
|
|
986
1081
|
}
|
|
987
|
-
},
|
|
1082
|
+
}, _callee19, this);
|
|
988
1083
|
}));
|
|
989
|
-
function getDryRunXcm(
|
|
1084
|
+
function getDryRunXcm(_x36) {
|
|
990
1085
|
return _getDryRunXcm.apply(this, arguments);
|
|
991
1086
|
}
|
|
992
1087
|
return getDryRunXcm;
|
|
@@ -994,18 +1089,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
994
1089
|
}, {
|
|
995
1090
|
key: "getBridgeStatus",
|
|
996
1091
|
value: function () {
|
|
997
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1092
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
998
1093
|
var outboundOperatingMode;
|
|
999
|
-
return _regenerator().w(function (
|
|
1000
|
-
while (1) switch (
|
|
1094
|
+
return _regenerator().w(function (_context20) {
|
|
1095
|
+
while (1) switch (_context20.n) {
|
|
1001
1096
|
case 0:
|
|
1002
|
-
|
|
1097
|
+
_context20.n = 1;
|
|
1003
1098
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1004
1099
|
case 1:
|
|
1005
|
-
outboundOperatingMode =
|
|
1006
|
-
return
|
|
1100
|
+
outboundOperatingMode = _context20.v;
|
|
1101
|
+
return _context20.a(2, outboundOperatingMode.toPrimitive());
|
|
1007
1102
|
}
|
|
1008
|
-
},
|
|
1103
|
+
}, _callee20, this);
|
|
1009
1104
|
}));
|
|
1010
1105
|
function getBridgeStatus() {
|
|
1011
1106
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1025,38 +1120,38 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1025
1120
|
}, {
|
|
1026
1121
|
key: "disconnect",
|
|
1027
1122
|
value: function () {
|
|
1028
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1123
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
1029
1124
|
var _this$_config$apiOver2;
|
|
1030
1125
|
var force,
|
|
1031
1126
|
api,
|
|
1032
|
-
|
|
1033
|
-
return _regenerator().w(function (
|
|
1034
|
-
while (1) switch (
|
|
1127
|
+
_args21 = arguments;
|
|
1128
|
+
return _regenerator().w(function (_context21) {
|
|
1129
|
+
while (1) switch (_context21.n) {
|
|
1035
1130
|
case 0:
|
|
1036
|
-
force =
|
|
1131
|
+
force = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : false;
|
|
1037
1132
|
if (this.initialized) {
|
|
1038
|
-
|
|
1133
|
+
_context21.n = 1;
|
|
1039
1134
|
break;
|
|
1040
1135
|
}
|
|
1041
|
-
return
|
|
1136
|
+
return _context21.a(2, Promise.resolve());
|
|
1042
1137
|
case 1:
|
|
1043
1138
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1044
|
-
|
|
1139
|
+
_context21.n = 2;
|
|
1045
1140
|
break;
|
|
1046
1141
|
}
|
|
1047
|
-
return
|
|
1142
|
+
return _context21.a(2);
|
|
1048
1143
|
case 2:
|
|
1049
1144
|
api = isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._chain] : this._config; // Disconnect api only if it was created automatically
|
|
1050
1145
|
if (!(force || typeof api === 'string' || api === undefined)) {
|
|
1051
|
-
|
|
1146
|
+
_context21.n = 3;
|
|
1052
1147
|
break;
|
|
1053
1148
|
}
|
|
1054
|
-
|
|
1149
|
+
_context21.n = 3;
|
|
1055
1150
|
return this.api.disconnect();
|
|
1056
1151
|
case 3:
|
|
1057
|
-
return
|
|
1152
|
+
return _context21.a(2);
|
|
1058
1153
|
}
|
|
1059
|
-
},
|
|
1154
|
+
}, _callee21, this);
|
|
1060
1155
|
}));
|
|
1061
1156
|
function disconnect() {
|
|
1062
1157
|
return _disconnect.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.4.1",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@snowbridge/contract-types": "0.2.0",
|
|
28
28
|
"ethers": "^6.15.0",
|
|
29
29
|
"viem": "^2.36.0",
|
|
30
|
-
"@paraspell/sdk-core": "11.
|
|
30
|
+
"@paraspell/sdk-core": "11.4.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 16.0 < 17",
|