@paraspell/sdk-pjs 11.2.4 → 11.3.0
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 +7 -1
- package/dist/index.cjs +29 -8
- package/dist/index.mjs +29 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -427,7 +427,7 @@ let result = convertSs58(address, chain) // returns converted address in string
|
|
|
427
427
|
For full documentation with examples on this feature head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
|
|
428
428
|
|
|
429
429
|
```ts
|
|
430
|
-
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, CHAINS } from '@paraspell/sdk-pjs'
|
|
430
|
+
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk-pjs'
|
|
431
431
|
|
|
432
432
|
//Get chains that support the specific asset related to origin
|
|
433
433
|
getSupportedDestinations(CHAIN, CURRENCY)
|
|
@@ -438,6 +438,12 @@ getFeeAssets(CHAIN)
|
|
|
438
438
|
// Get Location for asset ID or symbol on a specific chain
|
|
439
439
|
getAssetLocation(CHAIN, { symbol: symbol } | { id: assetId })
|
|
440
440
|
|
|
441
|
+
//Find out whether asset is registered on chain and return its entire parameters. If not found, returns null.
|
|
442
|
+
findAssetInfo(CHAIN, CURRENCY, DESTINATION?)
|
|
443
|
+
|
|
444
|
+
//Find out whether asset is registered on chain and return its entire parameters. If not found, returns error.
|
|
445
|
+
findAssetInfoOrThrow(CHAIN, CURRENCY, DESTINATION?)
|
|
446
|
+
|
|
441
447
|
// Retrieve assets object from assets.json for a particular chain, including information about native and foreign assets
|
|
442
448
|
getAssetsObject(CHAIN)
|
|
443
449
|
|
package/dist/index.cjs
CHANGED
|
@@ -706,6 +706,14 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
706
706
|
value: function getMethod(tx) {
|
|
707
707
|
return tx.method.toString();
|
|
708
708
|
}
|
|
709
|
+
}, {
|
|
710
|
+
key: "hasMethod",
|
|
711
|
+
value: function hasMethod(pallet, method) {
|
|
712
|
+
var _this$api$tx$palletFo;
|
|
713
|
+
var palletFormatted = lowercaseFirstLetter(pallet);
|
|
714
|
+
var methodFormatted = snakeToCamel(method);
|
|
715
|
+
return Promise.resolve(((_this$api$tx$palletFo = this.api.tx[palletFormatted]) === null || _this$api$tx$palletFo === void 0 ? void 0 : _this$api$tx$palletFo[methodFormatted]) !== undefined);
|
|
716
|
+
}
|
|
709
717
|
}, {
|
|
710
718
|
key: "getFromRpc",
|
|
711
719
|
value: function () {
|
|
@@ -769,12 +777,12 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
769
777
|
key: "getDryRunCall",
|
|
770
778
|
value: function () {
|
|
771
779
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref4) {
|
|
772
|
-
var _this$api$call$dryRun;
|
|
773
|
-
var tx, address, chain, supportsDryRunApi, chainsRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
780
|
+
var _this$api$call$dryRun, _feeAsset$symbol;
|
|
781
|
+
var tx, address, asset, feeAsset, chain, supportsDryRunApi, chainsRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, usedSymbol, usedAsset, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
774
782
|
return _regenerator().w(function (_context15) {
|
|
775
783
|
while (1) switch (_context15.n) {
|
|
776
784
|
case 0:
|
|
777
|
-
tx = _ref4.tx, address = _ref4.address, chain = _ref4.chain;
|
|
785
|
+
tx = _ref4.tx, address = _ref4.address, asset = _ref4.asset, feeAsset = _ref4.feeAsset, chain = _ref4.chain;
|
|
778
786
|
supportsDryRunApi = sdkCore.getAssetsObject(chain).supportsDryRunApi;
|
|
779
787
|
if (supportsDryRunApi) {
|
|
780
788
|
_context15.n = 1;
|
|
@@ -795,6 +803,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
795
803
|
response = _context15.v;
|
|
796
804
|
result = response.toHuman();
|
|
797
805
|
resultJson = response.toJSON();
|
|
806
|
+
usedSymbol = (_feeAsset$symbol = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.symbol) !== null && _feeAsset$symbol !== void 0 ? _feeAsset$symbol : asset === null || asset === void 0 ? void 0 : asset.symbol;
|
|
807
|
+
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : asset;
|
|
798
808
|
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
799
809
|
if (isSuccess) {
|
|
800
810
|
_context15.n = 3;
|
|
@@ -804,7 +814,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
804
814
|
failureReason = sdkCore.resolveModuleError(chain, moduleError);
|
|
805
815
|
return _context15.a(2, {
|
|
806
816
|
success: false,
|
|
807
|
-
failureReason: failureReason
|
|
817
|
+
failureReason: failureReason,
|
|
818
|
+
currency: usedSymbol,
|
|
819
|
+
asset: usedAsset
|
|
808
820
|
});
|
|
809
821
|
case 3:
|
|
810
822
|
_context15.n = 4;
|
|
@@ -824,6 +836,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
824
836
|
return _context15.a(2, {
|
|
825
837
|
success: true,
|
|
826
838
|
fee: fee,
|
|
839
|
+
currency: usedSymbol,
|
|
840
|
+
asset: usedAsset,
|
|
827
841
|
weight: weight,
|
|
828
842
|
forwardedXcms: forwardedXcms,
|
|
829
843
|
destParaId: destParaId
|
|
@@ -891,11 +905,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
891
905
|
value: function () {
|
|
892
906
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref6) {
|
|
893
907
|
var _ref7, _ref8, _ref9;
|
|
894
|
-
var originLocation, xcm, chain, origin, supportsDryRunApi, response, result, resultJson, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
908
|
+
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, symbol, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
895
909
|
return _regenerator().w(function (_context18) {
|
|
896
910
|
while (1) switch (_context18.n) {
|
|
897
911
|
case 0:
|
|
898
|
-
originLocation = _ref6.originLocation, xcm = _ref6.xcm, chain = _ref6.chain, origin = _ref6.origin;
|
|
912
|
+
originLocation = _ref6.originLocation, xcm = _ref6.xcm, asset = _ref6.asset, chain = _ref6.chain, origin = _ref6.origin;
|
|
899
913
|
supportsDryRunApi = sdkCore.getAssetsObject(chain).supportsDryRunApi;
|
|
900
914
|
if (supportsDryRunApi) {
|
|
901
915
|
_context18.n = 1;
|
|
@@ -909,6 +923,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
909
923
|
response = _context18.v;
|
|
910
924
|
result = response.toHuman();
|
|
911
925
|
resultJson = response.toJSON();
|
|
926
|
+
symbol = asset.symbol;
|
|
912
927
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
913
928
|
if (isSuccess) {
|
|
914
929
|
_context18.n = 3;
|
|
@@ -917,7 +932,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
917
932
|
failureReason = result.Ok.executionResult.Incomplete.error;
|
|
918
933
|
return _context18.a(2, {
|
|
919
934
|
success: false,
|
|
920
|
-
failureReason: failureReason
|
|
935
|
+
failureReason: failureReason,
|
|
936
|
+
currency: symbol,
|
|
937
|
+
asset: asset
|
|
921
938
|
});
|
|
922
939
|
case 3:
|
|
923
940
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
@@ -942,7 +959,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
942
959
|
}
|
|
943
960
|
return _context18.a(2, Promise.resolve({
|
|
944
961
|
success: false,
|
|
945
|
-
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
962
|
+
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
963
|
+
currency: symbol,
|
|
964
|
+
asset: asset
|
|
946
965
|
}));
|
|
947
966
|
case 4:
|
|
948
967
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
@@ -959,6 +978,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
959
978
|
return _context18.a(2, {
|
|
960
979
|
success: true,
|
|
961
980
|
fee: fee,
|
|
981
|
+
currency: symbol,
|
|
982
|
+
asset: asset,
|
|
962
983
|
weight: weight,
|
|
963
984
|
forwardedXcms: forwardedXcms,
|
|
964
985
|
destParaId: destParaId
|
package/dist/index.mjs
CHANGED
|
@@ -705,6 +705,14 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
705
705
|
value: function getMethod(tx) {
|
|
706
706
|
return tx.method.toString();
|
|
707
707
|
}
|
|
708
|
+
}, {
|
|
709
|
+
key: "hasMethod",
|
|
710
|
+
value: function hasMethod(pallet, method) {
|
|
711
|
+
var _this$api$tx$palletFo;
|
|
712
|
+
var palletFormatted = lowercaseFirstLetter(pallet);
|
|
713
|
+
var methodFormatted = snakeToCamel(method);
|
|
714
|
+
return Promise.resolve(((_this$api$tx$palletFo = this.api.tx[palletFormatted]) === null || _this$api$tx$palletFo === void 0 ? void 0 : _this$api$tx$palletFo[methodFormatted]) !== undefined);
|
|
715
|
+
}
|
|
708
716
|
}, {
|
|
709
717
|
key: "getFromRpc",
|
|
710
718
|
value: function () {
|
|
@@ -768,12 +776,12 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
768
776
|
key: "getDryRunCall",
|
|
769
777
|
value: function () {
|
|
770
778
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref4) {
|
|
771
|
-
var _this$api$call$dryRun;
|
|
772
|
-
var tx, address, chain, supportsDryRunApi, chainsRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
779
|
+
var _this$api$call$dryRun, _feeAsset$symbol;
|
|
780
|
+
var tx, address, asset, feeAsset, chain, supportsDryRunApi, chainsRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, usedSymbol, usedAsset, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
773
781
|
return _regenerator().w(function (_context15) {
|
|
774
782
|
while (1) switch (_context15.n) {
|
|
775
783
|
case 0:
|
|
776
|
-
tx = _ref4.tx, address = _ref4.address, chain = _ref4.chain;
|
|
784
|
+
tx = _ref4.tx, address = _ref4.address, asset = _ref4.asset, feeAsset = _ref4.feeAsset, chain = _ref4.chain;
|
|
777
785
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
778
786
|
if (supportsDryRunApi) {
|
|
779
787
|
_context15.n = 1;
|
|
@@ -794,6 +802,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
794
802
|
response = _context15.v;
|
|
795
803
|
result = response.toHuman();
|
|
796
804
|
resultJson = response.toJSON();
|
|
805
|
+
usedSymbol = (_feeAsset$symbol = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.symbol) !== null && _feeAsset$symbol !== void 0 ? _feeAsset$symbol : asset === null || asset === void 0 ? void 0 : asset.symbol;
|
|
806
|
+
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : asset;
|
|
797
807
|
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
798
808
|
if (isSuccess) {
|
|
799
809
|
_context15.n = 3;
|
|
@@ -803,7 +813,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
803
813
|
failureReason = resolveModuleError(chain, moduleError);
|
|
804
814
|
return _context15.a(2, {
|
|
805
815
|
success: false,
|
|
806
|
-
failureReason: failureReason
|
|
816
|
+
failureReason: failureReason,
|
|
817
|
+
currency: usedSymbol,
|
|
818
|
+
asset: usedAsset
|
|
807
819
|
});
|
|
808
820
|
case 3:
|
|
809
821
|
_context15.n = 4;
|
|
@@ -823,6 +835,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
823
835
|
return _context15.a(2, {
|
|
824
836
|
success: true,
|
|
825
837
|
fee: fee,
|
|
838
|
+
currency: usedSymbol,
|
|
839
|
+
asset: usedAsset,
|
|
826
840
|
weight: weight,
|
|
827
841
|
forwardedXcms: forwardedXcms,
|
|
828
842
|
destParaId: destParaId
|
|
@@ -890,11 +904,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
890
904
|
value: function () {
|
|
891
905
|
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref6) {
|
|
892
906
|
var _ref7, _ref8, _ref9;
|
|
893
|
-
var originLocation, xcm, chain, origin, supportsDryRunApi, response, result, resultJson, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
907
|
+
var originLocation, xcm, asset, chain, origin, supportsDryRunApi, response, result, resultJson, symbol, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
894
908
|
return _regenerator().w(function (_context18) {
|
|
895
909
|
while (1) switch (_context18.n) {
|
|
896
910
|
case 0:
|
|
897
|
-
originLocation = _ref6.originLocation, xcm = _ref6.xcm, chain = _ref6.chain, origin = _ref6.origin;
|
|
911
|
+
originLocation = _ref6.originLocation, xcm = _ref6.xcm, asset = _ref6.asset, chain = _ref6.chain, origin = _ref6.origin;
|
|
898
912
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
899
913
|
if (supportsDryRunApi) {
|
|
900
914
|
_context18.n = 1;
|
|
@@ -908,6 +922,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
908
922
|
response = _context18.v;
|
|
909
923
|
result = response.toHuman();
|
|
910
924
|
resultJson = response.toJSON();
|
|
925
|
+
symbol = asset.symbol;
|
|
911
926
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
912
927
|
if (isSuccess) {
|
|
913
928
|
_context18.n = 3;
|
|
@@ -916,7 +931,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
916
931
|
failureReason = result.Ok.executionResult.Incomplete.error;
|
|
917
932
|
return _context18.a(2, {
|
|
918
933
|
success: false,
|
|
919
|
-
failureReason: failureReason
|
|
934
|
+
failureReason: failureReason,
|
|
935
|
+
currency: symbol,
|
|
936
|
+
asset: asset
|
|
920
937
|
});
|
|
921
938
|
case 3:
|
|
922
939
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
@@ -941,7 +958,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
941
958
|
}
|
|
942
959
|
return _context18.a(2, Promise.resolve({
|
|
943
960
|
success: false,
|
|
944
|
-
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
961
|
+
failureReason: 'Cannot determine destination fee. No Issued event found',
|
|
962
|
+
currency: symbol,
|
|
963
|
+
asset: asset
|
|
945
964
|
}));
|
|
946
965
|
case 4:
|
|
947
966
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
@@ -958,6 +977,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
958
977
|
return _context18.a(2, {
|
|
959
978
|
success: true,
|
|
960
979
|
fee: fee,
|
|
980
|
+
currency: symbol,
|
|
981
|
+
asset: asset,
|
|
961
982
|
weight: weight,
|
|
962
983
|
forwardedXcms: forwardedXcms,
|
|
963
984
|
destParaId: destParaId
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
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.3.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 16.0 < 17",
|