@paraspell/sdk-pjs 12.0.6 → 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 +256 -134
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isConfig, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, getChainProviders, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, 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';
|
|
1
|
+
import { isConfig, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, getChainProviders, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, RELAY_LOCATION, getRelayChainOf, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, 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 { isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
@@ -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
|
+
break;
|
|
819
|
+
}
|
|
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;
|
|
818
841
|
break;
|
|
819
842
|
}
|
|
820
|
-
|
|
821
|
-
return
|
|
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,90 +896,179 @@ 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;
|
|
945
|
+
execFee = typeof execFeeOk === 'string' || typeof execFeeOk === 'number' ? BigInt(execFeeOk) : 0n;
|
|
946
|
+
isAssetNotFound = (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.err) === 'AssetNotFound';
|
|
947
|
+
if (!(chain.startsWith('BridgeHub') && isAssetNotFound)) {
|
|
948
|
+
_context11.n = 6;
|
|
949
|
+
break;
|
|
950
|
+
}
|
|
951
|
+
_context11.n = 5;
|
|
952
|
+
return this.getBridgeHubFallbackExecFee(chain, weight, asset);
|
|
953
|
+
case 5:
|
|
954
|
+
bridgeHubExecFee = _context11.v;
|
|
955
|
+
if (typeof bridgeHubExecFee === 'bigint') {
|
|
956
|
+
execFee = bridgeHubExecFee;
|
|
957
|
+
}
|
|
958
|
+
case 6:
|
|
884
959
|
if (!(forwardedXcm.length > 0)) {
|
|
885
|
-
|
|
960
|
+
_context11.n = 8;
|
|
886
961
|
break;
|
|
887
962
|
}
|
|
888
|
-
|
|
963
|
+
_context11.n = 7;
|
|
889
964
|
return this.api.call.xcmPaymentApi.queryDeliveryFees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
890
|
-
case
|
|
891
|
-
|
|
892
|
-
|
|
965
|
+
case 7:
|
|
966
|
+
_t6 = _context11.v;
|
|
967
|
+
_context11.n = 9;
|
|
893
968
|
break;
|
|
894
|
-
case
|
|
895
|
-
|
|
896
|
-
case
|
|
897
|
-
deliveryFeeRes =
|
|
969
|
+
case 8:
|
|
970
|
+
_t6 = undefined;
|
|
971
|
+
case 9:
|
|
972
|
+
deliveryFeeRes = _t6;
|
|
898
973
|
deliveryFeeResJson = deliveryFeeRes === null || deliveryFeeRes === void 0 ? void 0 : deliveryFeeRes.toJSON();
|
|
899
|
-
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;
|
|
900
975
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
901
976
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
902
|
-
|
|
977
|
+
_context11.n = 10;
|
|
903
978
|
break;
|
|
904
979
|
}
|
|
905
980
|
deliveryFee = deliveryFeeResolved;
|
|
906
|
-
|
|
981
|
+
_context11.n = 13;
|
|
907
982
|
break;
|
|
908
|
-
case
|
|
909
|
-
|
|
983
|
+
case 10:
|
|
984
|
+
_context11.p = 10;
|
|
910
985
|
assertHasLocation(nativeAsset);
|
|
911
|
-
|
|
986
|
+
_context11.n = 11;
|
|
912
987
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
913
|
-
case
|
|
914
|
-
res =
|
|
988
|
+
case 11:
|
|
989
|
+
res = _context11.v;
|
|
915
990
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
916
|
-
|
|
991
|
+
_context11.n = 13;
|
|
917
992
|
break;
|
|
918
|
-
case
|
|
919
|
-
|
|
920
|
-
|
|
993
|
+
case 12:
|
|
994
|
+
_context11.p = 12;
|
|
995
|
+
_context11.v;
|
|
921
996
|
deliveryFee = 0n;
|
|
922
|
-
case
|
|
923
|
-
return
|
|
997
|
+
case 13:
|
|
998
|
+
return _context11.a(2, execFee + deliveryFee);
|
|
924
999
|
}
|
|
925
|
-
},
|
|
1000
|
+
}, _callee11, this, [[10, 12]]);
|
|
926
1001
|
}));
|
|
927
1002
|
function getXcmPaymentApiFee(_x18, _x19, _x20, _x21) {
|
|
928
1003
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
929
1004
|
}
|
|
930
1005
|
return getXcmPaymentApiFee;
|
|
931
1006
|
}()
|
|
1007
|
+
}, {
|
|
1008
|
+
key: "getBridgeHubFallbackExecFee",
|
|
1009
|
+
value: function () {
|
|
1010
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, weightValue, asset) {
|
|
1011
|
+
var fallbackExecFeeRes, fallbackJson, fallbackOk, fallbackExecFee, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1012
|
+
return _regenerator().w(function (_context12) {
|
|
1013
|
+
while (1) switch (_context12.n) {
|
|
1014
|
+
case 0:
|
|
1015
|
+
_context12.n = 1;
|
|
1016
|
+
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION, Version.V4));
|
|
1017
|
+
case 1:
|
|
1018
|
+
fallbackExecFeeRes = _context12.v;
|
|
1019
|
+
fallbackJson = fallbackExecFeeRes.toJSON();
|
|
1020
|
+
fallbackOk = fallbackJson === null || fallbackJson === void 0 ? void 0 : fallbackJson.ok;
|
|
1021
|
+
fallbackExecFee = typeof fallbackOk === 'string' || typeof fallbackOk === 'number' ? BigInt(fallbackOk) : undefined;
|
|
1022
|
+
if (!(fallbackExecFee === undefined)) {
|
|
1023
|
+
_context12.n = 2;
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
return _context12.a(2, undefined);
|
|
1027
|
+
case 2:
|
|
1028
|
+
ahApi = this.clone();
|
|
1029
|
+
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1030
|
+
_context12.n = 3;
|
|
1031
|
+
return ahApi.init(assetHubChain);
|
|
1032
|
+
case 3:
|
|
1033
|
+
assertHasLocation(asset);
|
|
1034
|
+
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1035
|
+
_context12.n = 4;
|
|
1036
|
+
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false);
|
|
1037
|
+
case 4:
|
|
1038
|
+
convertedExecFee = _context12.v;
|
|
1039
|
+
if (!(typeof convertedExecFee === 'bigint')) {
|
|
1040
|
+
_context12.n = 5;
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
return _context12.a(2, convertedExecFee);
|
|
1044
|
+
case 5:
|
|
1045
|
+
return _context12.a(2, undefined);
|
|
1046
|
+
}
|
|
1047
|
+
}, _callee12, this);
|
|
1048
|
+
}));
|
|
1049
|
+
function getBridgeHubFallbackExecFee(_x22, _x23, _x24) {
|
|
1050
|
+
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1051
|
+
}
|
|
1052
|
+
return getBridgeHubFallbackExecFee;
|
|
1053
|
+
}()
|
|
932
1054
|
}, {
|
|
933
1055
|
key: "getXcmWeight",
|
|
934
1056
|
value: function () {
|
|
935
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1057
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(xcm) {
|
|
936
1058
|
var result, resultJson;
|
|
937
|
-
return _regenerator().w(function (
|
|
938
|
-
while (1) switch (
|
|
1059
|
+
return _regenerator().w(function (_context13) {
|
|
1060
|
+
while (1) switch (_context13.n) {
|
|
939
1061
|
case 0:
|
|
940
|
-
|
|
1062
|
+
_context13.n = 1;
|
|
941
1063
|
return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
|
|
942
1064
|
case 1:
|
|
943
|
-
result =
|
|
1065
|
+
result = _context13.v;
|
|
944
1066
|
resultJson = result.toJSON();
|
|
945
|
-
return
|
|
1067
|
+
return _context13.a(2, resultJson.ok);
|
|
946
1068
|
}
|
|
947
|
-
},
|
|
1069
|
+
}, _callee13, this);
|
|
948
1070
|
}));
|
|
949
|
-
function getXcmWeight(
|
|
1071
|
+
function getXcmWeight(_x25) {
|
|
950
1072
|
return _getXcmWeight.apply(this, arguments);
|
|
951
1073
|
}
|
|
952
1074
|
return getXcmWeight;
|
|
@@ -954,34 +1076,34 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
954
1076
|
}, {
|
|
955
1077
|
key: "getDryRunXcm",
|
|
956
1078
|
value: function () {
|
|
957
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
958
|
-
var
|
|
1079
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref9) {
|
|
1080
|
+
var _ref1, _ref10, _ref11;
|
|
959
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;
|
|
960
|
-
return _regenerator().w(function (
|
|
961
|
-
while (1) switch (
|
|
1082
|
+
return _regenerator().w(function (_context14) {
|
|
1083
|
+
while (1) switch (_context14.n) {
|
|
962
1084
|
case 0:
|
|
963
|
-
originLocation =
|
|
1085
|
+
originLocation = _ref9.originLocation, xcm = _ref9.xcm, asset = _ref9.asset, chain = _ref9.chain, origin = _ref9.origin;
|
|
964
1086
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
965
1087
|
if (supportsDryRunApi) {
|
|
966
|
-
|
|
1088
|
+
_context14.n = 1;
|
|
967
1089
|
break;
|
|
968
1090
|
}
|
|
969
1091
|
throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
|
|
970
1092
|
case 1:
|
|
971
|
-
|
|
1093
|
+
_context14.n = 2;
|
|
972
1094
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
973
1095
|
case 2:
|
|
974
|
-
response =
|
|
1096
|
+
response = _context14.v;
|
|
975
1097
|
result = response.toHuman();
|
|
976
1098
|
resultJson = response.toJSON();
|
|
977
1099
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
978
1100
|
if (isSuccess) {
|
|
979
|
-
|
|
1101
|
+
_context14.n = 3;
|
|
980
1102
|
break;
|
|
981
1103
|
}
|
|
982
1104
|
error = result.Ok.executionResult.Incomplete.error;
|
|
983
1105
|
failureReason = typeof error === 'string' ? error : error.error;
|
|
984
|
-
return
|
|
1106
|
+
return _context14.a(2, {
|
|
985
1107
|
success: false,
|
|
986
1108
|
failureReason: failureReason,
|
|
987
1109
|
asset: asset
|
|
@@ -993,22 +1115,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
993
1115
|
refTime: BigInt(actualWeight.refTime),
|
|
994
1116
|
proofSize: BigInt(actualWeight.proofSize)
|
|
995
1117
|
} : undefined;
|
|
996
|
-
destParaId = forwardedXcms.length === 0 ? undefined : function (i,
|
|
997
|
-
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;
|
|
998
1120
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
999
1121
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1000
|
-
|
|
1122
|
+
_context14.n = 5;
|
|
1001
1123
|
break;
|
|
1002
1124
|
}
|
|
1003
|
-
|
|
1125
|
+
_context14.n = 4;
|
|
1004
1126
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1005
1127
|
case 4:
|
|
1006
|
-
_fee =
|
|
1128
|
+
_fee = _context14.v;
|
|
1007
1129
|
if (!(typeof _fee === 'bigint')) {
|
|
1008
|
-
|
|
1130
|
+
_context14.n = 5;
|
|
1009
1131
|
break;
|
|
1010
1132
|
}
|
|
1011
|
-
return
|
|
1133
|
+
return _context14.a(2, {
|
|
1012
1134
|
success: true,
|
|
1013
1135
|
fee: _fee,
|
|
1014
1136
|
asset: asset,
|
|
@@ -1020,24 +1142,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1020
1142
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
1021
1143
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1022
1144
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
1023
|
-
feeEvent = (
|
|
1145
|
+
feeEvent = (_ref1 = (_ref10 = (_ref11 = origin === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1024
1146
|
return event.section === 'assetConversion' && event.method === 'SwapCreditExecuted';
|
|
1025
|
-
}) : undefined) !== null &&
|
|
1147
|
+
}) : undefined) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1026
1148
|
// Prefer an Issued event
|
|
1027
1149
|
reversedEvents.find(function (event) {
|
|
1028
1150
|
return palletsWithIssued.includes(event.section) && event.method === 'Issued';
|
|
1029
|
-
})) !== null &&
|
|
1151
|
+
})) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1030
1152
|
// Fallback to Minted event
|
|
1031
1153
|
reversedEvents.find(function (event) {
|
|
1032
1154
|
return ['balances', 'foreignAssets'].includes(event.section) && event.method === 'Minted';
|
|
1033
|
-
})) !== null &&
|
|
1155
|
+
})) !== null && _ref1 !== void 0 ? _ref1 : reversedEvents.find(function (event) {
|
|
1034
1156
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
1035
1157
|
});
|
|
1036
1158
|
if (feeEvent) {
|
|
1037
|
-
|
|
1159
|
+
_context14.n = 6;
|
|
1038
1160
|
break;
|
|
1039
1161
|
}
|
|
1040
|
-
return
|
|
1162
|
+
return _context14.a(2, Promise.resolve({
|
|
1041
1163
|
success: false,
|
|
1042
1164
|
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
1043
1165
|
asset: asset
|
|
@@ -1045,7 +1167,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1045
1167
|
case 6:
|
|
1046
1168
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
1047
1169
|
fee = BigInt(feeAmount.replace(/,/g, ''));
|
|
1048
|
-
return
|
|
1170
|
+
return _context14.a(2, {
|
|
1049
1171
|
success: true,
|
|
1050
1172
|
fee: fee,
|
|
1051
1173
|
asset: asset,
|
|
@@ -1054,9 +1176,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1054
1176
|
destParaId: destParaId
|
|
1055
1177
|
});
|
|
1056
1178
|
}
|
|
1057
|
-
},
|
|
1179
|
+
}, _callee14, this);
|
|
1058
1180
|
}));
|
|
1059
|
-
function getDryRunXcm(
|
|
1181
|
+
function getDryRunXcm(_x26) {
|
|
1060
1182
|
return _getDryRunXcm.apply(this, arguments);
|
|
1061
1183
|
}
|
|
1062
1184
|
return getDryRunXcm;
|
|
@@ -1064,18 +1186,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1064
1186
|
}, {
|
|
1065
1187
|
key: "getBridgeStatus",
|
|
1066
1188
|
value: function () {
|
|
1067
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1189
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1068
1190
|
var outboundOperatingMode;
|
|
1069
|
-
return _regenerator().w(function (
|
|
1070
|
-
while (1) switch (
|
|
1191
|
+
return _regenerator().w(function (_context15) {
|
|
1192
|
+
while (1) switch (_context15.n) {
|
|
1071
1193
|
case 0:
|
|
1072
|
-
|
|
1194
|
+
_context15.n = 1;
|
|
1073
1195
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1074
1196
|
case 1:
|
|
1075
|
-
outboundOperatingMode =
|
|
1076
|
-
return
|
|
1197
|
+
outboundOperatingMode = _context15.v;
|
|
1198
|
+
return _context15.a(2, outboundOperatingMode.toPrimitive());
|
|
1077
1199
|
}
|
|
1078
|
-
},
|
|
1200
|
+
}, _callee15, this);
|
|
1079
1201
|
}));
|
|
1080
1202
|
function getBridgeStatus() {
|
|
1081
1203
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1095,38 +1217,38 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1095
1217
|
}, {
|
|
1096
1218
|
key: "disconnect",
|
|
1097
1219
|
value: function () {
|
|
1098
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1220
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
1099
1221
|
var _this$_config$apiOver2;
|
|
1100
1222
|
var force,
|
|
1101
1223
|
api,
|
|
1102
|
-
|
|
1103
|
-
return _regenerator().w(function (
|
|
1104
|
-
while (1) switch (
|
|
1224
|
+
_args16 = arguments;
|
|
1225
|
+
return _regenerator().w(function (_context16) {
|
|
1226
|
+
while (1) switch (_context16.n) {
|
|
1105
1227
|
case 0:
|
|
1106
|
-
force =
|
|
1228
|
+
force = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : false;
|
|
1107
1229
|
if (this.initialized) {
|
|
1108
|
-
|
|
1230
|
+
_context16.n = 1;
|
|
1109
1231
|
break;
|
|
1110
1232
|
}
|
|
1111
|
-
return
|
|
1233
|
+
return _context16.a(2, Promise.resolve());
|
|
1112
1234
|
case 1:
|
|
1113
1235
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1114
|
-
|
|
1236
|
+
_context16.n = 2;
|
|
1115
1237
|
break;
|
|
1116
1238
|
}
|
|
1117
|
-
return
|
|
1239
|
+
return _context16.a(2);
|
|
1118
1240
|
case 2:
|
|
1119
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
|
|
1120
1242
|
if (!(force || typeof api === 'string' || api === undefined)) {
|
|
1121
|
-
|
|
1243
|
+
_context16.n = 3;
|
|
1122
1244
|
break;
|
|
1123
1245
|
}
|
|
1124
|
-
|
|
1246
|
+
_context16.n = 3;
|
|
1125
1247
|
return this.api.disconnect();
|
|
1126
1248
|
case 3:
|
|
1127
|
-
return
|
|
1249
|
+
return _context16.a(2);
|
|
1128
1250
|
}
|
|
1129
|
-
},
|
|
1251
|
+
}, _callee16, this);
|
|
1130
1252
|
}));
|
|
1131
1253
|
function disconnect() {
|
|
1132
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.
|
|
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.
|
|
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
|
},
|