@paraspell/sdk-pjs 12.1.0 → 12.1.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/dist/index.mjs +210 -149
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -636,16 +636,16 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
636
636
|
}, {
|
|
637
637
|
key: "getDryRunCall",
|
|
638
638
|
value: function () {
|
|
639
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
639
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
|
|
640
640
|
var _this = this;
|
|
641
|
-
var tx, address, feeAsset, chain, destination, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, nativeAsset, hasLocation, destParaId, xcmFee, executionFee, fee, _t, _t2, _t3;
|
|
642
|
-
return _regenerator().w(function (
|
|
643
|
-
while (1) switch (
|
|
641
|
+
var tx, address, feeAsset, chain, destination, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, nativeAsset, hasLocation, destParaId, getPaymentInfoWeight, overriddenWeight, xcmFee, executionFee, fee, _t, _t2, _t3, _t4;
|
|
642
|
+
return _regenerator().w(function (_context10) {
|
|
643
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
644
644
|
case 0:
|
|
645
645
|
tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
|
|
646
646
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
647
647
|
if (supportsDryRunApi) {
|
|
648
|
-
|
|
648
|
+
_context10.n = 1;
|
|
649
649
|
break;
|
|
650
650
|
}
|
|
651
651
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
@@ -661,25 +661,25 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
663
|
if (!useRootOrigin) {
|
|
664
|
-
|
|
664
|
+
_context10.n = 3;
|
|
665
665
|
break;
|
|
666
666
|
}
|
|
667
|
-
|
|
667
|
+
_context10.n = 2;
|
|
668
668
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
669
669
|
api: this
|
|
670
670
|
}), bypassOptions);
|
|
671
671
|
case 2:
|
|
672
|
-
_t =
|
|
673
|
-
|
|
672
|
+
_t = _context10.v;
|
|
673
|
+
_context10.n = 4;
|
|
674
674
|
break;
|
|
675
675
|
case 3:
|
|
676
676
|
_t = tx;
|
|
677
677
|
case 4:
|
|
678
678
|
resolvedTx = _t;
|
|
679
|
-
|
|
679
|
+
_context10.n = 5;
|
|
680
680
|
return this.resolveFeeAsset(options);
|
|
681
681
|
case 5:
|
|
682
|
-
resolvedFeeAsset =
|
|
682
|
+
resolvedFeeAsset = _context10.v;
|
|
683
683
|
performDryRunCall = /*#__PURE__*/function () {
|
|
684
684
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
|
|
685
685
|
var _this$api$call$dryRun;
|
|
@@ -728,11 +728,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
728
728
|
failureReason: ''
|
|
729
729
|
};
|
|
730
730
|
shouldRetryWithVersion = false;
|
|
731
|
-
|
|
732
|
-
|
|
731
|
+
_context10.p = 6;
|
|
732
|
+
_context10.n = 7;
|
|
733
733
|
return performDryRunCall(false);
|
|
734
734
|
case 7:
|
|
735
|
-
response =
|
|
735
|
+
response = _context10.v;
|
|
736
736
|
resultHuman = response.toHuman();
|
|
737
737
|
resultJson = response.toJSON();
|
|
738
738
|
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
@@ -742,49 +742,49 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
742
742
|
shouldRetryWithVersion = true;
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
|
-
|
|
745
|
+
_context10.n = 10;
|
|
746
746
|
break;
|
|
747
747
|
case 8:
|
|
748
|
-
|
|
749
|
-
_t2 =
|
|
748
|
+
_context10.p = 8;
|
|
749
|
+
_t2 = _context10.v;
|
|
750
750
|
msg = _t2 instanceof Error ? _t2.message : String(_t2);
|
|
751
751
|
if (!msg.includes('Expected 3 arguments')) {
|
|
752
|
-
|
|
752
|
+
_context10.n = 9;
|
|
753
753
|
break;
|
|
754
754
|
}
|
|
755
755
|
shouldRetryWithVersion = true;
|
|
756
|
-
|
|
756
|
+
_context10.n = 10;
|
|
757
757
|
break;
|
|
758
758
|
case 9:
|
|
759
|
-
return
|
|
759
|
+
return _context10.a(2, {
|
|
760
760
|
success: false,
|
|
761
761
|
failureReason: msg,
|
|
762
762
|
asset: resolvedFeeAsset.asset
|
|
763
763
|
});
|
|
764
764
|
case 10:
|
|
765
765
|
if (!shouldRetryWithVersion) {
|
|
766
|
-
|
|
766
|
+
_context10.n = 14;
|
|
767
767
|
break;
|
|
768
768
|
}
|
|
769
|
-
|
|
770
|
-
|
|
769
|
+
_context10.p = 11;
|
|
770
|
+
_context10.n = 12;
|
|
771
771
|
return performDryRunCall(true);
|
|
772
772
|
case 12:
|
|
773
|
-
response =
|
|
773
|
+
response = _context10.v;
|
|
774
774
|
resultHuman = response.toHuman();
|
|
775
775
|
resultJson = response.toJSON();
|
|
776
776
|
isSuccess = getExecutionSuccessFromResult(resultHuman);
|
|
777
777
|
if (!isSuccess) {
|
|
778
778
|
failureErr = extractFailureReasonFromResult(resultHuman, resultJson);
|
|
779
779
|
}
|
|
780
|
-
|
|
780
|
+
_context10.n = 14;
|
|
781
781
|
break;
|
|
782
782
|
case 13:
|
|
783
|
-
|
|
784
|
-
_t3 =
|
|
783
|
+
_context10.p = 13;
|
|
784
|
+
_t3 = _context10.v;
|
|
785
785
|
_msg = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
786
786
|
failureErr = failureErr || _msg;
|
|
787
|
-
return
|
|
787
|
+
return _context10.a(2, {
|
|
788
788
|
success: false,
|
|
789
789
|
failureReason: failureErr.failureReason,
|
|
790
790
|
failureSubReason: failureErr.failureSubReason,
|
|
@@ -792,10 +792,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
792
792
|
});
|
|
793
793
|
case 14:
|
|
794
794
|
if (isSuccess) {
|
|
795
|
-
|
|
795
|
+
_context10.n = 15;
|
|
796
796
|
break;
|
|
797
797
|
}
|
|
798
|
-
return
|
|
798
|
+
return _context10.a(2, {
|
|
799
799
|
success: false,
|
|
800
800
|
failureReason: failureErr.failureReason || 'Unknown error',
|
|
801
801
|
failureSubReason: failureErr.failureSubReason,
|
|
@@ -814,18 +814,51 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
814
814
|
return i.here === null ? 0 : (_ref5 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref5 === void 0 ? void 0 : _ref5.parachain;
|
|
815
815
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
816
816
|
if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
|
|
817
|
-
|
|
817
|
+
_context10.n = 21;
|
|
818
818
|
break;
|
|
819
819
|
}
|
|
820
|
-
|
|
821
|
-
|
|
820
|
+
getPaymentInfoWeight = /*#__PURE__*/function () {
|
|
821
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
822
|
+
var _yield$tx$paymentInfo2, weight;
|
|
823
|
+
return _regenerator().w(function (_context1) {
|
|
824
|
+
while (1) switch (_context1.n) {
|
|
825
|
+
case 0:
|
|
826
|
+
_context1.n = 1;
|
|
827
|
+
return tx.paymentInfo(address);
|
|
828
|
+
case 1:
|
|
829
|
+
_yield$tx$paymentInfo2 = _context1.v;
|
|
830
|
+
weight = _yield$tx$paymentInfo2.weight;
|
|
831
|
+
return _context1.a(2, weight);
|
|
832
|
+
}
|
|
833
|
+
}, _callee1);
|
|
834
|
+
}));
|
|
835
|
+
return function getPaymentInfoWeight() {
|
|
836
|
+
return _ref6.apply(this, arguments);
|
|
837
|
+
};
|
|
838
|
+
}();
|
|
839
|
+
if (resultJson.ok.local_xcm) {
|
|
840
|
+
_context10.n = 17;
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
_context10.n = 16;
|
|
844
|
+
return getPaymentInfoWeight();
|
|
822
845
|
case 16:
|
|
823
|
-
|
|
846
|
+
_t4 = _context10.v;
|
|
847
|
+
_context10.n = 18;
|
|
848
|
+
break;
|
|
849
|
+
case 17:
|
|
850
|
+
_t4 = undefined;
|
|
851
|
+
case 18:
|
|
852
|
+
overriddenWeight = _t4;
|
|
853
|
+
_context10.n = 19;
|
|
854
|
+
return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, resolvedFeeAsset.asset, false, overriddenWeight);
|
|
855
|
+
case 19:
|
|
856
|
+
xcmFee = _context10.v;
|
|
824
857
|
if (!(typeof xcmFee === 'bigint')) {
|
|
825
|
-
|
|
858
|
+
_context10.n = 20;
|
|
826
859
|
break;
|
|
827
860
|
}
|
|
828
|
-
return
|
|
861
|
+
return _context10.a(2, Promise.resolve({
|
|
829
862
|
success: true,
|
|
830
863
|
fee: xcmFee,
|
|
831
864
|
asset: resolvedFeeAsset.asset,
|
|
@@ -833,18 +866,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
833
866
|
forwardedXcms: forwardedXcms,
|
|
834
867
|
destParaId: destParaId
|
|
835
868
|
}));
|
|
836
|
-
case
|
|
869
|
+
case 20:
|
|
837
870
|
resolvedFeeAsset = {
|
|
838
871
|
isCustomAsset: false,
|
|
839
872
|
asset: this.resolveDefaultFeeAsset(options)
|
|
840
873
|
};
|
|
841
|
-
case
|
|
842
|
-
|
|
874
|
+
case 21:
|
|
875
|
+
_context10.n = 22;
|
|
843
876
|
return this.calculateTransactionFee(tx, address);
|
|
844
|
-
case
|
|
845
|
-
executionFee =
|
|
877
|
+
case 22:
|
|
878
|
+
executionFee = _context10.v;
|
|
846
879
|
fee = computeFeeFromDryRunPjs(resultHuman, chain, executionFee);
|
|
847
|
-
return
|
|
880
|
+
return _context10.a(2, {
|
|
848
881
|
success: true,
|
|
849
882
|
fee: fee,
|
|
850
883
|
asset: resolvedFeeAsset.asset,
|
|
@@ -853,7 +886,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
853
886
|
destParaId: destParaId
|
|
854
887
|
});
|
|
855
888
|
}
|
|
856
|
-
},
|
|
889
|
+
}, _callee10, this, [[11, 13], [6, 8]]);
|
|
857
890
|
}));
|
|
858
891
|
function getDryRunCall(_x16) {
|
|
859
892
|
return _getDryRunCall.apply(this, arguments);
|
|
@@ -863,80 +896,108 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
863
896
|
}, {
|
|
864
897
|
key: "getXcmPaymentApiFee",
|
|
865
898
|
value: function () {
|
|
866
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
867
|
-
var
|
|
868
|
-
var
|
|
869
|
-
|
|
870
|
-
|
|
899
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, localXcm, forwardedXcm, asset) {
|
|
900
|
+
var _ref7, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref8, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
|
|
901
|
+
var overridenWeight,
|
|
902
|
+
weight,
|
|
903
|
+
assetLocalizedLoc,
|
|
904
|
+
feeResult,
|
|
905
|
+
execFeeRes,
|
|
906
|
+
execFeeOk,
|
|
907
|
+
execFee,
|
|
908
|
+
isAssetNotFound,
|
|
909
|
+
bridgeHubExecFee,
|
|
910
|
+
deliveryFeeRes,
|
|
911
|
+
deliveryFeeResJson,
|
|
912
|
+
deliveryFeeResolved,
|
|
913
|
+
nativeAsset,
|
|
914
|
+
deliveryFee,
|
|
915
|
+
res,
|
|
916
|
+
_args11 = arguments,
|
|
917
|
+
_t5,
|
|
918
|
+
_t6;
|
|
919
|
+
return _regenerator().w(function (_context11) {
|
|
920
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
871
921
|
case 0:
|
|
872
|
-
|
|
873
|
-
|
|
922
|
+
overridenWeight = _args11.length > 5 ? _args11[5] : undefined;
|
|
923
|
+
if (!(overridenWeight !== null && overridenWeight !== void 0)) {
|
|
924
|
+
_context11.n = 1;
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
_t5 = overridenWeight;
|
|
928
|
+
_context11.n = 3;
|
|
929
|
+
break;
|
|
874
930
|
case 1:
|
|
875
|
-
|
|
931
|
+
_context11.n = 2;
|
|
932
|
+
return this.getXcmWeight(localXcm);
|
|
933
|
+
case 2:
|
|
934
|
+
_t5 = _context11.v;
|
|
935
|
+
case 3:
|
|
936
|
+
weight = _t5;
|
|
876
937
|
assertHasLocation(asset);
|
|
877
938
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
878
|
-
|
|
939
|
+
_context11.n = 4;
|
|
879
940
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetLocalizedLoc, Version.V4));
|
|
880
|
-
case
|
|
881
|
-
feeResult =
|
|
941
|
+
case 4:
|
|
942
|
+
feeResult = _context11.v;
|
|
882
943
|
execFeeRes = feeResult.toJSON();
|
|
883
944
|
execFeeOk = execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.ok;
|
|
884
945
|
execFee = typeof execFeeOk === 'string' || typeof execFeeOk === 'number' ? BigInt(execFeeOk) : 0n;
|
|
885
946
|
isAssetNotFound = (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.err) === 'AssetNotFound';
|
|
886
947
|
if (!(chain.startsWith('BridgeHub') && isAssetNotFound)) {
|
|
887
|
-
|
|
948
|
+
_context11.n = 6;
|
|
888
949
|
break;
|
|
889
950
|
}
|
|
890
|
-
|
|
951
|
+
_context11.n = 5;
|
|
891
952
|
return this.getBridgeHubFallbackExecFee(chain, weight, asset);
|
|
892
|
-
case
|
|
893
|
-
bridgeHubExecFee =
|
|
953
|
+
case 5:
|
|
954
|
+
bridgeHubExecFee = _context11.v;
|
|
894
955
|
if (typeof bridgeHubExecFee === 'bigint') {
|
|
895
956
|
execFee = bridgeHubExecFee;
|
|
896
957
|
}
|
|
897
|
-
case
|
|
958
|
+
case 6:
|
|
898
959
|
if (!(forwardedXcm.length > 0)) {
|
|
899
|
-
|
|
960
|
+
_context11.n = 8;
|
|
900
961
|
break;
|
|
901
962
|
}
|
|
902
|
-
|
|
963
|
+
_context11.n = 7;
|
|
903
964
|
return this.api.call.xcmPaymentApi.queryDeliveryFees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
904
|
-
case 5:
|
|
905
|
-
_t4 = _context10.v;
|
|
906
|
-
_context10.n = 7;
|
|
907
|
-
break;
|
|
908
|
-
case 6:
|
|
909
|
-
_t4 = undefined;
|
|
910
965
|
case 7:
|
|
911
|
-
|
|
966
|
+
_t6 = _context11.v;
|
|
967
|
+
_context11.n = 9;
|
|
968
|
+
break;
|
|
969
|
+
case 8:
|
|
970
|
+
_t6 = undefined;
|
|
971
|
+
case 9:
|
|
972
|
+
deliveryFeeRes = _t6;
|
|
912
973
|
deliveryFeeResJson = deliveryFeeRes === null || deliveryFeeRes === void 0 ? void 0 : deliveryFeeRes.toJSON();
|
|
913
|
-
deliveryFeeResolved = deliveryFeeRes && ((
|
|
974
|
+
deliveryFeeResolved = deliveryFeeRes && ((_ref7 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref7 === void 0 ? void 0 : _ref7.length) > 0 ? BigInt((_ref8 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref8 === void 0 || (_ref8 = _ref8[0]) === null || _ref8 === void 0 || (_ref8 = _ref8.fun) === null || _ref8 === void 0 ? void 0 : _ref8.fungible) : 0n;
|
|
914
975
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
915
976
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
916
|
-
|
|
977
|
+
_context11.n = 10;
|
|
917
978
|
break;
|
|
918
979
|
}
|
|
919
980
|
deliveryFee = deliveryFeeResolved;
|
|
920
|
-
|
|
981
|
+
_context11.n = 13;
|
|
921
982
|
break;
|
|
922
|
-
case
|
|
923
|
-
|
|
983
|
+
case 10:
|
|
984
|
+
_context11.p = 10;
|
|
924
985
|
assertHasLocation(nativeAsset);
|
|
925
|
-
|
|
986
|
+
_context11.n = 11;
|
|
926
987
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
927
|
-
case
|
|
928
|
-
res =
|
|
988
|
+
case 11:
|
|
989
|
+
res = _context11.v;
|
|
929
990
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
930
|
-
|
|
991
|
+
_context11.n = 13;
|
|
931
992
|
break;
|
|
932
|
-
case
|
|
933
|
-
|
|
934
|
-
|
|
993
|
+
case 12:
|
|
994
|
+
_context11.p = 12;
|
|
995
|
+
_context11.v;
|
|
935
996
|
deliveryFee = 0n;
|
|
936
|
-
case
|
|
937
|
-
return
|
|
997
|
+
case 13:
|
|
998
|
+
return _context11.a(2, execFee + deliveryFee);
|
|
938
999
|
}
|
|
939
|
-
},
|
|
1000
|
+
}, _callee11, this, [[10, 12]]);
|
|
940
1001
|
}));
|
|
941
1002
|
function getXcmPaymentApiFee(_x18, _x19, _x20, _x21) {
|
|
942
1003
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
@@ -946,44 +1007,44 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
946
1007
|
}, {
|
|
947
1008
|
key: "getBridgeHubFallbackExecFee",
|
|
948
1009
|
value: function () {
|
|
949
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1010
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, weightValue, asset) {
|
|
950
1011
|
var fallbackExecFeeRes, fallbackJson, fallbackOk, fallbackExecFee, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
951
|
-
return _regenerator().w(function (
|
|
952
|
-
while (1) switch (
|
|
1012
|
+
return _regenerator().w(function (_context12) {
|
|
1013
|
+
while (1) switch (_context12.n) {
|
|
953
1014
|
case 0:
|
|
954
|
-
|
|
1015
|
+
_context12.n = 1;
|
|
955
1016
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION, Version.V4));
|
|
956
1017
|
case 1:
|
|
957
|
-
fallbackExecFeeRes =
|
|
1018
|
+
fallbackExecFeeRes = _context12.v;
|
|
958
1019
|
fallbackJson = fallbackExecFeeRes.toJSON();
|
|
959
1020
|
fallbackOk = fallbackJson === null || fallbackJson === void 0 ? void 0 : fallbackJson.ok;
|
|
960
1021
|
fallbackExecFee = typeof fallbackOk === 'string' || typeof fallbackOk === 'number' ? BigInt(fallbackOk) : undefined;
|
|
961
1022
|
if (!(fallbackExecFee === undefined)) {
|
|
962
|
-
|
|
1023
|
+
_context12.n = 2;
|
|
963
1024
|
break;
|
|
964
1025
|
}
|
|
965
|
-
return
|
|
1026
|
+
return _context12.a(2, undefined);
|
|
966
1027
|
case 2:
|
|
967
1028
|
ahApi = this.clone();
|
|
968
1029
|
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
969
|
-
|
|
1030
|
+
_context12.n = 3;
|
|
970
1031
|
return ahApi.init(assetHubChain);
|
|
971
1032
|
case 3:
|
|
972
1033
|
assertHasLocation(asset);
|
|
973
1034
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
974
|
-
|
|
1035
|
+
_context12.n = 4;
|
|
975
1036
|
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false);
|
|
976
1037
|
case 4:
|
|
977
|
-
convertedExecFee =
|
|
1038
|
+
convertedExecFee = _context12.v;
|
|
978
1039
|
if (!(typeof convertedExecFee === 'bigint')) {
|
|
979
|
-
|
|
1040
|
+
_context12.n = 5;
|
|
980
1041
|
break;
|
|
981
1042
|
}
|
|
982
|
-
return
|
|
1043
|
+
return _context12.a(2, convertedExecFee);
|
|
983
1044
|
case 5:
|
|
984
|
-
return
|
|
1045
|
+
return _context12.a(2, undefined);
|
|
985
1046
|
}
|
|
986
|
-
},
|
|
1047
|
+
}, _callee12, this);
|
|
987
1048
|
}));
|
|
988
1049
|
function getBridgeHubFallbackExecFee(_x22, _x23, _x24) {
|
|
989
1050
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
@@ -993,19 +1054,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
993
1054
|
}, {
|
|
994
1055
|
key: "getXcmWeight",
|
|
995
1056
|
value: function () {
|
|
996
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1057
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(xcm) {
|
|
997
1058
|
var result, resultJson;
|
|
998
|
-
return _regenerator().w(function (
|
|
999
|
-
while (1) switch (
|
|
1059
|
+
return _regenerator().w(function (_context13) {
|
|
1060
|
+
while (1) switch (_context13.n) {
|
|
1000
1061
|
case 0:
|
|
1001
|
-
|
|
1062
|
+
_context13.n = 1;
|
|
1002
1063
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
1003
1064
|
case 1:
|
|
1004
|
-
result =
|
|
1065
|
+
result = _context13.v;
|
|
1005
1066
|
resultJson = result.toJSON();
|
|
1006
|
-
return
|
|
1067
|
+
return _context13.a(2, resultJson.ok);
|
|
1007
1068
|
}
|
|
1008
|
-
},
|
|
1069
|
+
}, _callee13, this);
|
|
1009
1070
|
}));
|
|
1010
1071
|
function getXcmWeight(_x25) {
|
|
1011
1072
|
return _getXcmWeight.apply(this, arguments);
|
|
@@ -1015,34 +1076,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1015
1076
|
}, {
|
|
1016
1077
|
key: "getDryRunXcm",
|
|
1017
1078
|
value: function () {
|
|
1018
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1019
|
-
var
|
|
1079
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref9) {
|
|
1080
|
+
var _ref1, _ref10, _ref11;
|
|
1020
1081
|
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, isSuccess, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
|
|
1021
|
-
return _regenerator().w(function (
|
|
1022
|
-
while (1) switch (
|
|
1082
|
+
return _regenerator().w(function (_context14) {
|
|
1083
|
+
while (1) switch (_context14.n) {
|
|
1023
1084
|
case 0:
|
|
1024
|
-
originLocation =
|
|
1085
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, asset = _ref9.asset, chain = _ref9.chain, origin = _ref9.origin;
|
|
1025
1086
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1026
1087
|
if (supportsDryRunApi) {
|
|
1027
|
-
|
|
1088
|
+
_context14.n = 1;
|
|
1028
1089
|
break;
|
|
1029
1090
|
}
|
|
1030
1091
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
1031
1092
|
case 1:
|
|
1032
|
-
|
|
1093
|
+
_context14.n = 2;
|
|
1033
1094
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
1034
1095
|
case 2:
|
|
1035
|
-
response =
|
|
1096
|
+
response = _context14.v;
|
|
1036
1097
|
result = response.toHuman();
|
|
1037
1098
|
resultJson = response.toJSON();
|
|
1038
1099
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
1039
1100
|
if (isSuccess) {
|
|
1040
|
-
|
|
1101
|
+
_context14.n = 3;
|
|
1041
1102
|
break;
|
|
1042
1103
|
}
|
|
1043
1104
|
error = result.Ok.executionResult.Incomplete.error;
|
|
1044
1105
|
failureReason = typeof error === 'string' ? error : error.error;
|
|
1045
|
-
return
|
|
1106
|
+
return _context14.a(2, {
|
|
1046
1107
|
success: false,
|
|
1047
1108
|
failureReason: failureReason,
|
|
1048
1109
|
asset: asset
|
|
@@ -1054,22 +1115,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1054
1115
|
refTime: BigInt(actualWeight.refTime),
|
|
1055
1116
|
proofSize: BigInt(actualWeight.proofSize)
|
|
1056
1117
|
} : undefined;
|
|
1057
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
1058
|
-
return i.Here ? 0 : (
|
|
1118
|
+
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref0) {
|
|
1119
|
+
return i.Here ? 0 : (_ref0 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref0 === void 0 ? void 0 : _ref0.parachain;
|
|
1059
1120
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
1060
1121
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1061
|
-
|
|
1122
|
+
_context14.n = 5;
|
|
1062
1123
|
break;
|
|
1063
1124
|
}
|
|
1064
|
-
|
|
1125
|
+
_context14.n = 4;
|
|
1065
1126
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1066
1127
|
case 4:
|
|
1067
|
-
_fee =
|
|
1128
|
+
_fee = _context14.v;
|
|
1068
1129
|
if (!(typeof _fee === 'bigint')) {
|
|
1069
|
-
|
|
1130
|
+
_context14.n = 5;
|
|
1070
1131
|
break;
|
|
1071
1132
|
}
|
|
1072
|
-
return
|
|
1133
|
+
return _context14.a(2, {
|
|
1073
1134
|
success: true,
|
|
1074
1135
|
fee: _fee,
|
|
1075
1136
|
asset: asset,
|
|
@@ -1081,24 +1142,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1081
1142
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
1082
1143
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1083
1144
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
1084
|
-
feeEvent = (
|
|
1145
|
+
feeEvent = (_ref1 = (_ref10 = (_ref11 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1085
1146
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
1086
|
-
}) : undefined) !== null &&
|
|
1147
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1087
1148
|
// Prefer an Issued event
|
|
1088
1149
|
reversedEvents.find(function (event) {
|
|
1089
1150
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
1090
|
-
})) !== null &&
|
|
1151
|
+
})) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1091
1152
|
// Fallback to Minted event
|
|
1092
1153
|
reversedEvents.find(function (event) {
|
|
1093
1154
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
1094
|
-
})) !== null &&
|
|
1155
|
+
})) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
|
|
1095
1156
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
1096
1157
|
});
|
|
1097
1158
|
if (feeEvent) {
|
|
1098
|
-
|
|
1159
|
+
_context14.n = 6;
|
|
1099
1160
|
break;
|
|
1100
1161
|
}
|
|
1101
|
-
return
|
|
1162
|
+
return _context14.a(2, Promise.resolve({
|
|
1102
1163
|
success: false,
|
|
1103
1164
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
1104
1165
|
asset: asset
|
|
@@ -1106,7 +1167,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1106
1167
|
case 6:
|
|
1107
1168
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
1108
1169
|
fee = BigInt(feeAmount.replace(/,/g, ''));
|
|
1109
|
-
return
|
|
1170
|
+
return _context14.a(2, {
|
|
1110
1171
|
success: true,
|
|
1111
1172
|
fee: fee,
|
|
1112
1173
|
asset: asset,
|
|
@@ -1115,7 +1176,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1115
1176
|
destParaId: destParaId
|
|
1116
1177
|
});
|
|
1117
1178
|
}
|
|
1118
|
-
},
|
|
1179
|
+
}, _callee14, this);
|
|
1119
1180
|
}));
|
|
1120
1181
|
function getDryRunXcm(_x26) {
|
|
1121
1182
|
return _getDryRunXcm.apply(this, arguments);
|
|
@@ -1125,18 +1186,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1125
1186
|
}, {
|
|
1126
1187
|
key: "getBridgeStatus",
|
|
1127
1188
|
value: function () {
|
|
1128
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1189
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1129
1190
|
var outboundOperatingMode;
|
|
1130
|
-
return _regenerator().w(function (
|
|
1131
|
-
while (1) switch (
|
|
1191
|
+
return _regenerator().w(function (_context15) {
|
|
1192
|
+
while (1) switch (_context15.n) {
|
|
1132
1193
|
case 0:
|
|
1133
|
-
|
|
1194
|
+
_context15.n = 1;
|
|
1134
1195
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1135
1196
|
case 1:
|
|
1136
|
-
outboundOperatingMode =
|
|
1137
|
-
return
|
|
1197
|
+
outboundOperatingMode = _context15.v;
|
|
1198
|
+
return _context15.a(2, outboundOperatingMode.toPrimitive());
|
|
1138
1199
|
}
|
|
1139
|
-
},
|
|
1200
|
+
}, _callee15, this);
|
|
1140
1201
|
}));
|
|
1141
1202
|
function getBridgeStatus() {
|
|
1142
1203
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1156,38 +1217,38 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1156
1217
|
}, {
|
|
1157
1218
|
key: "disconnect",
|
|
1158
1219
|
value: function () {
|
|
1159
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1220
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
1160
1221
|
var _this$_config$apiOver2;
|
|
1161
1222
|
var force,
|
|
1162
1223
|
api,
|
|
1163
|
-
|
|
1164
|
-
return _regenerator().w(function (
|
|
1165
|
-
while (1) switch (
|
|
1224
|
+
_args16 = arguments;
|
|
1225
|
+
return _regenerator().w(function (_context16) {
|
|
1226
|
+
while (1) switch (_context16.n) {
|
|
1166
1227
|
case 0:
|
|
1167
|
-
force =
|
|
1228
|
+
force = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : false;
|
|
1168
1229
|
if (this.initialized) {
|
|
1169
|
-
|
|
1230
|
+
_context16.n = 1;
|
|
1170
1231
|
break;
|
|
1171
1232
|
}
|
|
1172
|
-
return
|
|
1233
|
+
return _context16.a(2, Promise.resolve());
|
|
1173
1234
|
case 1:
|
|
1174
1235
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1175
|
-
|
|
1236
|
+
_context16.n = 2;
|
|
1176
1237
|
break;
|
|
1177
1238
|
}
|
|
1178
|
-
return
|
|
1239
|
+
return _context16.a(2);
|
|
1179
1240
|
case 2:
|
|
1180
1241
|
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
|
|
1181
1242
|
if (!(force || typeof api === 'string' || api === undefined)) {
|
|
1182
|
-
|
|
1243
|
+
_context16.n = 3;
|
|
1183
1244
|
break;
|
|
1184
1245
|
}
|
|
1185
|
-
|
|
1246
|
+
_context16.n = 3;
|
|
1186
1247
|
return this.api.disconnect();
|
|
1187
1248
|
case 3:
|
|
1188
|
-
return
|
|
1249
|
+
return _context16.a(2);
|
|
1189
1250
|
}
|
|
1190
|
-
},
|
|
1251
|
+
}, _callee16, this);
|
|
1191
1252
|
}));
|
|
1192
1253
|
function disconnect() {
|
|
1193
1254
|
return _disconnect.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@snowbridge/api": "0.2.
|
|
27
|
-
"@snowbridge/contract-types": "0.2.
|
|
28
|
-
"ethers": "
|
|
29
|
-
"viem": "
|
|
30
|
-
"@paraspell/sdk-core": "12.1.
|
|
26
|
+
"@snowbridge/api": "0.2.20",
|
|
27
|
+
"@snowbridge/contract-types": "0.2.20",
|
|
28
|
+
"ethers": "6.15.0",
|
|
29
|
+
"viem": "2.40.3",
|
|
30
|
+
"@paraspell/sdk-core": "12.1.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 16.0 < 17",
|
|
34
34
|
"@polkadot/api-base": ">= 16.0 < 17",
|
|
35
35
|
"@polkadot/types": ">= 16.0 < 17",
|
|
36
|
-
"@polkadot/util": ">=
|
|
37
|
-
"@polkadot/util-crypto": ">=
|
|
36
|
+
"@polkadot/util": ">= 14",
|
|
37
|
+
"@polkadot/util-crypto": ">= 14"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@rollup/plugin-babel": "^6.1.0",
|
|
44
44
|
"@rollup/plugin-json": "^6.1.0",
|
|
45
45
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
46
|
-
"@vitest/coverage-v8": "^4.0.
|
|
46
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
47
47
|
"axios": "^1.13.2",
|
|
48
48
|
"dotenv": "^17.2.3",
|
|
49
|
-
"rollup": "^4.
|
|
49
|
+
"rollup": "^4.54.0",
|
|
50
50
|
"rollup-plugin-dts": "^6.3.0",
|
|
51
51
|
"tslib": "^2.8.1"
|
|
52
52
|
},
|