@paraspell/sdk 8.5.1 → 8.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.cjs +211 -131
- package/dist/index.d.ts +9 -5
- package/dist/index.mjs +213 -134
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getParaEthTransferFees as getParaEthTransferFees$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
|
|
1
|
+
import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, NodeNotSupportedError, Version, Parents, getNode, isForeignAsset, computeFeeFromDryRun, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getParaEthTransferFees as getParaEthTransferFees$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, verifyEdOnDestination as verifyEdOnDestination$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';
|
|
4
|
-
import { FixedSizeBinary, createClient } from 'polkadot-api';
|
|
4
|
+
import { FixedSizeBinary, Binary, createClient, AccountId } from 'polkadot-api';
|
|
5
|
+
import { blake2b } from '@noble/hashes/blake2b';
|
|
6
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
5
7
|
|
|
6
8
|
function _arrayLikeToArray(r, a) {
|
|
7
9
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -544,6 +546,11 @@ var _transform = function transform(obj) {
|
|
|
544
546
|
key: FixedSizeBinary.fromHex(value.key)
|
|
545
547
|
}
|
|
546
548
|
};
|
|
549
|
+
} else if (key === 'SetTopic') {
|
|
550
|
+
return {
|
|
551
|
+
type: key,
|
|
552
|
+
value: FixedSizeBinary.fromHex(value)
|
|
553
|
+
};
|
|
547
554
|
} else if (key === 'X1' && Array.isArray(value)) {
|
|
548
555
|
return {
|
|
549
556
|
type: key,
|
|
@@ -631,6 +638,9 @@ var _transform = function transform(obj) {
|
|
|
631
638
|
};
|
|
632
639
|
|
|
633
640
|
var unsupportedNodes = ['ComposableFinance', 'Interlay', 'Parallel', 'CrustShadow', 'Kintsugi', 'ParallelHeiko', 'Picasso', 'RobonomicsKusama', 'Turing', 'Pendulum', 'Subsocial'];
|
|
641
|
+
var isHex = function isHex(str) {
|
|
642
|
+
return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
|
|
643
|
+
};
|
|
634
644
|
var PapiApi = /*#__PURE__*/function () {
|
|
635
645
|
function PapiApi() {
|
|
636
646
|
_classCallCheck(this, PapiApi);
|
|
@@ -748,16 +758,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
748
758
|
}
|
|
749
759
|
return createApiInstance;
|
|
750
760
|
}()
|
|
751
|
-
}, {
|
|
752
|
-
key: "createAccountId",
|
|
753
|
-
value: function createAccountId(address) {
|
|
754
|
-
return FixedSizeBinary.fromAccountId32(address).asHex();
|
|
755
|
-
}
|
|
756
761
|
}, {
|
|
757
762
|
key: "accountToHex",
|
|
758
763
|
value: function accountToHex(address) {
|
|
759
764
|
var isPrefixed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
760
|
-
|
|
765
|
+
if (isHex(address)) return address;
|
|
766
|
+
var hex = FixedSizeBinary.fromAccountId32(address).asHex();
|
|
761
767
|
return isPrefixed ? hex : hex.slice(2);
|
|
762
768
|
}
|
|
763
769
|
}, {
|
|
@@ -780,92 +786,149 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
780
786
|
});
|
|
781
787
|
}
|
|
782
788
|
}, {
|
|
783
|
-
key: "
|
|
789
|
+
key: "objectToHex",
|
|
784
790
|
value: function () {
|
|
785
|
-
var
|
|
791
|
+
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(obj) {
|
|
792
|
+
var transformedObj, tx, removeFirst5Bytes, encodedData;
|
|
786
793
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
787
794
|
while (1) switch (_context3.prev = _context3.next) {
|
|
788
795
|
case 0:
|
|
789
|
-
|
|
790
|
-
|
|
796
|
+
transformedObj = _transform(obj);
|
|
797
|
+
tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
|
|
798
|
+
dest: {
|
|
799
|
+
type: Version.V4,
|
|
800
|
+
value: {
|
|
801
|
+
parents: Parents.ZERO,
|
|
802
|
+
interior: {
|
|
803
|
+
type: 'Here'
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
message: transformedObj
|
|
808
|
+
});
|
|
809
|
+
removeFirst5Bytes = function removeFirst5Bytes(hexString) {
|
|
810
|
+
return '0x' + hexString.slice(12);
|
|
811
|
+
};
|
|
812
|
+
_context3.next = 5;
|
|
813
|
+
return tx.getEncodedData();
|
|
814
|
+
case 5:
|
|
815
|
+
encodedData = _context3.sent;
|
|
816
|
+
return _context3.abrupt("return", removeFirst5Bytes(encodedData.asHex()));
|
|
817
|
+
case 7:
|
|
791
818
|
case "end":
|
|
792
819
|
return _context3.stop();
|
|
793
820
|
}
|
|
794
|
-
}, _callee3);
|
|
821
|
+
}, _callee3, this);
|
|
795
822
|
}));
|
|
796
|
-
function
|
|
797
|
-
return
|
|
823
|
+
function objectToHex(_x3) {
|
|
824
|
+
return _objectToHex.apply(this, arguments);
|
|
798
825
|
}
|
|
799
|
-
return
|
|
826
|
+
return objectToHex;
|
|
800
827
|
}()
|
|
801
828
|
}, {
|
|
802
|
-
key: "
|
|
829
|
+
key: "hexToUint8a",
|
|
830
|
+
value: function hexToUint8a(hex) {
|
|
831
|
+
return Binary.fromHex(hex).asBytes();
|
|
832
|
+
}
|
|
833
|
+
}, {
|
|
834
|
+
key: "stringToUint8a",
|
|
835
|
+
value: function stringToUint8a(str) {
|
|
836
|
+
return Binary.fromText(str).asBytes();
|
|
837
|
+
}
|
|
838
|
+
}, {
|
|
839
|
+
key: "blake2AsHex",
|
|
840
|
+
value: function blake2AsHex(data) {
|
|
841
|
+
return "0x".concat(bytesToHex(blake2b(data, {
|
|
842
|
+
dkLen: 32
|
|
843
|
+
})));
|
|
844
|
+
}
|
|
845
|
+
}, {
|
|
846
|
+
key: "calculateTransactionFee",
|
|
803
847
|
value: function () {
|
|
804
|
-
var
|
|
805
|
-
var res;
|
|
848
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tx, address) {
|
|
806
849
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
807
850
|
while (1) switch (_context4.prev = _context4.next) {
|
|
808
851
|
case 0:
|
|
809
|
-
_context4.
|
|
810
|
-
|
|
811
|
-
case 2:
|
|
812
|
-
res = _context4.sent;
|
|
813
|
-
return _context4.abrupt("return", res.data.free);
|
|
814
|
-
case 4:
|
|
852
|
+
return _context4.abrupt("return", tx.getEstimatedFees(address));
|
|
853
|
+
case 1:
|
|
815
854
|
case "end":
|
|
816
855
|
return _context4.stop();
|
|
817
856
|
}
|
|
818
|
-
}, _callee4
|
|
857
|
+
}, _callee4);
|
|
819
858
|
}));
|
|
820
|
-
function
|
|
821
|
-
return
|
|
859
|
+
function calculateTransactionFee(_x4, _x5) {
|
|
860
|
+
return _calculateTransactionFee.apply(this, arguments);
|
|
822
861
|
}
|
|
823
|
-
return
|
|
862
|
+
return calculateTransactionFee;
|
|
824
863
|
}()
|
|
825
864
|
}, {
|
|
826
|
-
key: "
|
|
865
|
+
key: "getBalanceNative",
|
|
827
866
|
value: function () {
|
|
828
|
-
var
|
|
867
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address) {
|
|
829
868
|
var res;
|
|
830
869
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
831
870
|
while (1) switch (_context5.prev = _context5.next) {
|
|
832
871
|
case 0:
|
|
833
872
|
_context5.next = 2;
|
|
834
|
-
return this.api.getUnsafeApi().query.
|
|
873
|
+
return this.api.getUnsafeApi().query.System.Account.getValue(address);
|
|
835
874
|
case 2:
|
|
836
875
|
res = _context5.sent;
|
|
837
|
-
return _context5.abrupt("return", res
|
|
876
|
+
return _context5.abrupt("return", res.data.free);
|
|
838
877
|
case 4:
|
|
839
878
|
case "end":
|
|
840
879
|
return _context5.stop();
|
|
841
880
|
}
|
|
842
881
|
}, _callee5, this);
|
|
843
882
|
}));
|
|
844
|
-
function
|
|
845
|
-
return
|
|
883
|
+
function getBalanceNative(_x6) {
|
|
884
|
+
return _getBalanceNative.apply(this, arguments);
|
|
846
885
|
}
|
|
847
|
-
return
|
|
886
|
+
return getBalanceNative;
|
|
848
887
|
}()
|
|
849
888
|
}, {
|
|
850
|
-
key: "
|
|
889
|
+
key: "getBalanceForeignPolkadotXcm",
|
|
851
890
|
value: function () {
|
|
852
|
-
var
|
|
891
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address, id) {
|
|
853
892
|
var res;
|
|
854
893
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
855
894
|
while (1) switch (_context6.prev = _context6.next) {
|
|
856
895
|
case 0:
|
|
857
896
|
_context6.next = 2;
|
|
858
|
-
return this.api.getUnsafeApi().query.
|
|
897
|
+
return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
|
|
859
898
|
case 2:
|
|
860
899
|
res = _context6.sent;
|
|
861
|
-
return _context6.abrupt("return", res && res.
|
|
900
|
+
return _context6.abrupt("return", res && res.balance ? BigInt(res.balance) : 0n);
|
|
862
901
|
case 4:
|
|
863
902
|
case "end":
|
|
864
903
|
return _context6.stop();
|
|
865
904
|
}
|
|
866
905
|
}, _callee6, this);
|
|
867
906
|
}));
|
|
868
|
-
function
|
|
907
|
+
function getBalanceForeignPolkadotXcm(_x7, _x8) {
|
|
908
|
+
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
909
|
+
}
|
|
910
|
+
return getBalanceForeignPolkadotXcm;
|
|
911
|
+
}()
|
|
912
|
+
}, {
|
|
913
|
+
key: "getMythosForeignBalance",
|
|
914
|
+
value: function () {
|
|
915
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address) {
|
|
916
|
+
var res;
|
|
917
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
918
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
919
|
+
case 0:
|
|
920
|
+
_context7.next = 2;
|
|
921
|
+
return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
|
|
922
|
+
case 2:
|
|
923
|
+
res = _context7.sent;
|
|
924
|
+
return _context7.abrupt("return", res && res.free ? BigInt(res.free) : 0n);
|
|
925
|
+
case 4:
|
|
926
|
+
case "end":
|
|
927
|
+
return _context7.stop();
|
|
928
|
+
}
|
|
929
|
+
}, _callee7, this);
|
|
930
|
+
}));
|
|
931
|
+
function getMythosForeignBalance(_x9) {
|
|
869
932
|
return _getMythosForeignBalance.apply(this, arguments);
|
|
870
933
|
}
|
|
871
934
|
return getMythosForeignBalance;
|
|
@@ -873,24 +936,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
873
936
|
}, {
|
|
874
937
|
key: "getAssetHubForeignBalance",
|
|
875
938
|
value: function () {
|
|
876
|
-
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
939
|
+
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, multiLocation) {
|
|
877
940
|
var transformedMultiLocation, res;
|
|
878
|
-
return _regeneratorRuntime().wrap(function
|
|
879
|
-
while (1) switch (
|
|
941
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
942
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
880
943
|
case 0:
|
|
881
944
|
transformedMultiLocation = _transform(multiLocation);
|
|
882
|
-
|
|
945
|
+
_context8.next = 3;
|
|
883
946
|
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
|
|
884
947
|
case 3:
|
|
885
|
-
res =
|
|
886
|
-
return
|
|
948
|
+
res = _context8.sent;
|
|
949
|
+
return _context8.abrupt("return", BigInt(res === undefined ? 0 : res.balance));
|
|
887
950
|
case 5:
|
|
888
951
|
case "end":
|
|
889
|
-
return
|
|
952
|
+
return _context8.stop();
|
|
890
953
|
}
|
|
891
|
-
},
|
|
954
|
+
}, _callee8, this);
|
|
892
955
|
}));
|
|
893
|
-
function getAssetHubForeignBalance(
|
|
956
|
+
function getAssetHubForeignBalance(_x10, _x11) {
|
|
894
957
|
return _getAssetHubForeignBalance.apply(this, arguments);
|
|
895
958
|
}
|
|
896
959
|
return getAssetHubForeignBalance;
|
|
@@ -898,23 +961,23 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
898
961
|
}, {
|
|
899
962
|
key: "getForeignAssetsByIdBalance",
|
|
900
963
|
value: function () {
|
|
901
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
964
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, assetId) {
|
|
902
965
|
var res;
|
|
903
|
-
return _regeneratorRuntime().wrap(function
|
|
904
|
-
while (1) switch (
|
|
966
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
967
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
905
968
|
case 0:
|
|
906
|
-
|
|
969
|
+
_context9.next = 2;
|
|
907
970
|
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
|
|
908
971
|
case 2:
|
|
909
|
-
res =
|
|
910
|
-
return
|
|
972
|
+
res = _context9.sent;
|
|
973
|
+
return _context9.abrupt("return", BigInt(res === undefined ? 0 : res.balance));
|
|
911
974
|
case 4:
|
|
912
975
|
case "end":
|
|
913
|
-
return
|
|
976
|
+
return _context9.stop();
|
|
914
977
|
}
|
|
915
|
-
},
|
|
978
|
+
}, _callee9, this);
|
|
916
979
|
}));
|
|
917
|
-
function getForeignAssetsByIdBalance(
|
|
980
|
+
function getForeignAssetsByIdBalance(_x12, _x13) {
|
|
918
981
|
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
919
982
|
}
|
|
920
983
|
return getForeignAssetsByIdBalance;
|
|
@@ -922,26 +985,26 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
922
985
|
}, {
|
|
923
986
|
key: "getBalanceForeignBifrost",
|
|
924
987
|
value: function () {
|
|
925
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
988
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, asset) {
|
|
926
989
|
var currencySelection, transformedParameters, response, accountData;
|
|
927
|
-
return _regeneratorRuntime().wrap(function
|
|
928
|
-
while (1) switch (
|
|
990
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
991
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
929
992
|
case 0:
|
|
930
993
|
currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
931
994
|
transformedParameters = _transform(currencySelection);
|
|
932
|
-
|
|
995
|
+
_context10.next = 4;
|
|
933
996
|
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
934
997
|
case 4:
|
|
935
|
-
response =
|
|
998
|
+
response = _context10.sent;
|
|
936
999
|
accountData = response ? response : null;
|
|
937
|
-
return
|
|
1000
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
938
1001
|
case 7:
|
|
939
1002
|
case "end":
|
|
940
|
-
return
|
|
1003
|
+
return _context10.stop();
|
|
941
1004
|
}
|
|
942
|
-
},
|
|
1005
|
+
}, _callee10, this);
|
|
943
1006
|
}));
|
|
944
|
-
function getBalanceForeignBifrost(
|
|
1007
|
+
function getBalanceForeignBifrost(_x14, _x15) {
|
|
945
1008
|
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
946
1009
|
}
|
|
947
1010
|
return getBalanceForeignBifrost;
|
|
@@ -949,27 +1012,27 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
949
1012
|
}, {
|
|
950
1013
|
key: "getBalanceNativeAcala",
|
|
951
1014
|
value: function () {
|
|
952
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1015
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(address, symbol) {
|
|
953
1016
|
var transformedParameters, response, accountData;
|
|
954
|
-
return _regeneratorRuntime().wrap(function
|
|
955
|
-
while (1) switch (
|
|
1017
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1018
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
956
1019
|
case 0:
|
|
957
1020
|
transformedParameters = _transform({
|
|
958
1021
|
Token: symbol
|
|
959
1022
|
});
|
|
960
|
-
|
|
1023
|
+
_context11.next = 3;
|
|
961
1024
|
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
962
1025
|
case 3:
|
|
963
|
-
response =
|
|
1026
|
+
response = _context11.sent;
|
|
964
1027
|
accountData = response ? response : null;
|
|
965
|
-
return
|
|
1028
|
+
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
966
1029
|
case 6:
|
|
967
1030
|
case "end":
|
|
968
|
-
return
|
|
1031
|
+
return _context11.stop();
|
|
969
1032
|
}
|
|
970
|
-
},
|
|
1033
|
+
}, _callee11, this);
|
|
971
1034
|
}));
|
|
972
|
-
function getBalanceNativeAcala(
|
|
1035
|
+
function getBalanceNativeAcala(_x16, _x17) {
|
|
973
1036
|
return _getBalanceNativeAcala.apply(this, arguments);
|
|
974
1037
|
}
|
|
975
1038
|
return getBalanceNativeAcala;
|
|
@@ -977,19 +1040,19 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
977
1040
|
}, {
|
|
978
1041
|
key: "getBalanceForeignXTokens",
|
|
979
1042
|
value: function () {
|
|
980
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1043
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(node, address, asset) {
|
|
981
1044
|
var pallet, response, entry;
|
|
982
|
-
return _regeneratorRuntime().wrap(function
|
|
983
|
-
while (1) switch (
|
|
1045
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1046
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
984
1047
|
case 0:
|
|
985
1048
|
pallet = 'Tokens';
|
|
986
1049
|
if (node === 'Centrifuge' || node === 'Altair') {
|
|
987
1050
|
pallet = 'OrmlTokens';
|
|
988
1051
|
}
|
|
989
|
-
|
|
1052
|
+
_context12.next = 4;
|
|
990
1053
|
return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
|
|
991
1054
|
case 4:
|
|
992
|
-
response =
|
|
1055
|
+
response = _context12.sent;
|
|
993
1056
|
entry = response.find(function (_ref2) {
|
|
994
1057
|
var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
|
|
995
1058
|
var keyArgs = _ref2.keyArgs;
|
|
@@ -998,14 +1061,14 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
998
1061
|
var assetItem = _keyArgs[1];
|
|
999
1062
|
return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === undefined ? undefined : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === undefined ? undefined : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === undefined ? undefined : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === undefined ? undefined : _asset$assetId2.toLowerCase());
|
|
1000
1063
|
});
|
|
1001
|
-
return
|
|
1064
|
+
return _context12.abrupt("return", entry !== null && entry !== undefined && entry.value ? BigInt(entry.value.free.toString()) : 0n);
|
|
1002
1065
|
case 7:
|
|
1003
1066
|
case "end":
|
|
1004
|
-
return
|
|
1067
|
+
return _context12.stop();
|
|
1005
1068
|
}
|
|
1006
|
-
},
|
|
1069
|
+
}, _callee12, this);
|
|
1007
1070
|
}));
|
|
1008
|
-
function getBalanceForeignXTokens(
|
|
1071
|
+
function getBalanceForeignXTokens(_x18, _x19, _x20) {
|
|
1009
1072
|
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1010
1073
|
}
|
|
1011
1074
|
return getBalanceForeignXTokens;
|
|
@@ -1013,45 +1076,51 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1013
1076
|
}, {
|
|
1014
1077
|
key: "getBalanceForeignAssetsAccount",
|
|
1015
1078
|
value: function () {
|
|
1016
|
-
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1079
|
+
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, assetId) {
|
|
1017
1080
|
var response;
|
|
1018
|
-
return _regeneratorRuntime().wrap(function
|
|
1019
|
-
while (1) switch (
|
|
1081
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1082
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1020
1083
|
case 0:
|
|
1021
|
-
|
|
1084
|
+
_context13.next = 2;
|
|
1022
1085
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
|
|
1023
1086
|
case 2:
|
|
1024
|
-
response =
|
|
1025
|
-
return
|
|
1087
|
+
response = _context13.sent;
|
|
1088
|
+
return _context13.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
|
|
1026
1089
|
case 4:
|
|
1027
1090
|
case "end":
|
|
1028
|
-
return
|
|
1091
|
+
return _context13.stop();
|
|
1029
1092
|
}
|
|
1030
|
-
},
|
|
1093
|
+
}, _callee13, this);
|
|
1031
1094
|
}));
|
|
1032
|
-
function getBalanceForeignAssetsAccount(
|
|
1095
|
+
function getBalanceForeignAssetsAccount(_x21, _x22) {
|
|
1033
1096
|
return _getBalanceForeignAssetsAccount.apply(this, arguments);
|
|
1034
1097
|
}
|
|
1035
1098
|
return getBalanceForeignAssetsAccount;
|
|
1036
1099
|
}()
|
|
1037
1100
|
}, {
|
|
1038
|
-
key: "
|
|
1101
|
+
key: "getFromRpc",
|
|
1039
1102
|
value: function () {
|
|
1040
|
-
var
|
|
1041
|
-
|
|
1042
|
-
|
|
1103
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(module, method, key) {
|
|
1104
|
+
var toSS58, value;
|
|
1105
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1106
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1043
1107
|
case 0:
|
|
1044
|
-
|
|
1045
|
-
|
|
1108
|
+
toSS58 = AccountId().dec;
|
|
1109
|
+
_context14.next = 3;
|
|
1110
|
+
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) ? toSS58(key) : key]);
|
|
1111
|
+
case 3:
|
|
1112
|
+
value = _context14.sent;
|
|
1113
|
+
return _context14.abrupt("return", isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1114
|
+
case 5:
|
|
1046
1115
|
case "end":
|
|
1047
|
-
return
|
|
1116
|
+
return _context14.stop();
|
|
1048
1117
|
}
|
|
1049
|
-
},
|
|
1118
|
+
}, _callee14, this);
|
|
1050
1119
|
}));
|
|
1051
|
-
function
|
|
1052
|
-
return
|
|
1120
|
+
function getFromRpc(_x23, _x24, _x25) {
|
|
1121
|
+
return _getFromRpc.apply(this, arguments);
|
|
1053
1122
|
}
|
|
1054
|
-
return
|
|
1123
|
+
return getFromRpc;
|
|
1055
1124
|
}()
|
|
1056
1125
|
}, {
|
|
1057
1126
|
key: "clone",
|
|
@@ -1061,23 +1130,23 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1061
1130
|
}, {
|
|
1062
1131
|
key: "createApiForNode",
|
|
1063
1132
|
value: function () {
|
|
1064
|
-
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1133
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(node) {
|
|
1065
1134
|
var api;
|
|
1066
|
-
return _regeneratorRuntime().wrap(function
|
|
1067
|
-
while (1) switch (
|
|
1135
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1136
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1068
1137
|
case 0:
|
|
1069
1138
|
api = new PapiApi();
|
|
1070
|
-
|
|
1139
|
+
_context15.next = 3;
|
|
1071
1140
|
return api.init(node);
|
|
1072
1141
|
case 3:
|
|
1073
|
-
return
|
|
1142
|
+
return _context15.abrupt("return", api);
|
|
1074
1143
|
case 4:
|
|
1075
1144
|
case "end":
|
|
1076
|
-
return
|
|
1145
|
+
return _context15.stop();
|
|
1077
1146
|
}
|
|
1078
|
-
},
|
|
1147
|
+
}, _callee15);
|
|
1079
1148
|
}));
|
|
1080
|
-
function createApiForNode(
|
|
1149
|
+
function createApiForNode(_x26) {
|
|
1081
1150
|
return _createApiForNode.apply(this, arguments);
|
|
1082
1151
|
}
|
|
1083
1152
|
return createApiForNode;
|
|
@@ -1085,20 +1154,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1085
1154
|
}, {
|
|
1086
1155
|
key: "getDryRun",
|
|
1087
1156
|
value: function () {
|
|
1088
|
-
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1157
|
+
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref3) {
|
|
1089
1158
|
var tx, address, node, supportsDryRunApi, result, isSuccess, failureReason, executionFee, fee;
|
|
1090
|
-
return _regeneratorRuntime().wrap(function
|
|
1091
|
-
while (1) switch (
|
|
1159
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1160
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1092
1161
|
case 0:
|
|
1093
1162
|
tx = _ref3.tx, address = _ref3.address, node = _ref3.node;
|
|
1094
1163
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1095
1164
|
if (supportsDryRunApi) {
|
|
1096
|
-
|
|
1165
|
+
_context16.next = 4;
|
|
1097
1166
|
break;
|
|
1098
1167
|
}
|
|
1099
1168
|
throw new Error("DryRunApi is not available on node ".concat(node));
|
|
1100
1169
|
case 4:
|
|
1101
|
-
|
|
1170
|
+
_context16.next = 6;
|
|
1102
1171
|
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_call({
|
|
1103
1172
|
type: 'system',
|
|
1104
1173
|
value: {
|
|
@@ -1107,34 +1176,34 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1107
1176
|
}
|
|
1108
1177
|
}, tx.decodedCall);
|
|
1109
1178
|
case 6:
|
|
1110
|
-
result =
|
|
1179
|
+
result = _context16.sent;
|
|
1111
1180
|
isSuccess = result.success && result.value.execution_result.success;
|
|
1112
1181
|
if (isSuccess) {
|
|
1113
|
-
|
|
1182
|
+
_context16.next = 11;
|
|
1114
1183
|
break;
|
|
1115
1184
|
}
|
|
1116
1185
|
failureReason = result.value.execution_result.value.error.value.value.type;
|
|
1117
|
-
return
|
|
1186
|
+
return _context16.abrupt("return", Promise.resolve({
|
|
1118
1187
|
success: false,
|
|
1119
1188
|
failureReason: failureReason
|
|
1120
1189
|
}));
|
|
1121
1190
|
case 11:
|
|
1122
|
-
|
|
1191
|
+
_context16.next = 13;
|
|
1123
1192
|
return this.calculateTransactionFee(tx, address);
|
|
1124
1193
|
case 13:
|
|
1125
|
-
executionFee =
|
|
1194
|
+
executionFee = _context16.sent;
|
|
1126
1195
|
fee = computeFeeFromDryRun(result, node, executionFee);
|
|
1127
|
-
return
|
|
1196
|
+
return _context16.abrupt("return", Promise.resolve({
|
|
1128
1197
|
success: true,
|
|
1129
1198
|
fee: fee
|
|
1130
1199
|
}));
|
|
1131
1200
|
case 16:
|
|
1132
1201
|
case "end":
|
|
1133
|
-
return
|
|
1202
|
+
return _context16.stop();
|
|
1134
1203
|
}
|
|
1135
|
-
},
|
|
1204
|
+
}, _callee16, this);
|
|
1136
1205
|
}));
|
|
1137
|
-
function getDryRun(
|
|
1206
|
+
function getDryRun(_x27) {
|
|
1138
1207
|
return _getDryRun.apply(this, arguments);
|
|
1139
1208
|
}
|
|
1140
1209
|
return getDryRun;
|
|
@@ -1264,6 +1333,7 @@ var getOriginFeeDetails = createPapiApiCall(getOriginFeeDetails$1);
|
|
|
1264
1333
|
var getMaxNativeTransferableAmount = createPapiApiCall(getMaxNativeTransferableAmount$1);
|
|
1265
1334
|
var getMaxForeignTransferableAmount = createPapiApiCall(getMaxForeignTransferableAmount$1);
|
|
1266
1335
|
var getTransferableAmount = createPapiApiCall(getTransferableAmount$1);
|
|
1336
|
+
var verifyEdOnDestination = createPapiApiCall(verifyEdOnDestination$1);
|
|
1267
1337
|
|
|
1268
1338
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1269
1339
|
__proto__: null,
|
|
@@ -1294,7 +1364,8 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1294
1364
|
getTransferInfo: getTransferInfo,
|
|
1295
1365
|
getTransferableAmount: getTransferableAmount,
|
|
1296
1366
|
hasSupportForAsset: hasSupportForAsset,
|
|
1297
|
-
isNodeEvm: isNodeEvm
|
|
1367
|
+
isNodeEvm: isNodeEvm,
|
|
1368
|
+
verifyEdOnDestination: verifyEdOnDestination
|
|
1298
1369
|
});
|
|
1299
1370
|
|
|
1300
1371
|
/**
|
|
@@ -1344,8 +1415,9 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1344
1415
|
*/
|
|
1345
1416
|
}, {
|
|
1346
1417
|
key: "address",
|
|
1347
|
-
value: function address(_address) {
|
|
1418
|
+
value: function address(_address, ahAddress) {
|
|
1348
1419
|
this._options.address = _address;
|
|
1420
|
+
this._options.ahAddress = ahAddress;
|
|
1349
1421
|
return this;
|
|
1350
1422
|
}
|
|
1351
1423
|
/**
|
|
@@ -1391,11 +1463,18 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1391
1463
|
_context.next = 2;
|
|
1392
1464
|
break;
|
|
1393
1465
|
case 9:
|
|
1394
|
-
|
|
1466
|
+
validateAddress(this._options.address, this._options.to);
|
|
1467
|
+
if (!(this._options.from === 'Moonbeam' && this._options.to === 'Ethereum')) {
|
|
1468
|
+
_context.next = 12;
|
|
1469
|
+
break;
|
|
1470
|
+
}
|
|
1471
|
+
return _context.abrupt("return", transferMoonbeamToEth(this._options));
|
|
1472
|
+
case 12:
|
|
1473
|
+
_context.next = 14;
|
|
1395
1474
|
return transferMoonbeamEvm(this._options);
|
|
1396
|
-
case
|
|
1475
|
+
case 14:
|
|
1397
1476
|
return _context.abrupt("return", _context.sent);
|
|
1398
|
-
case
|
|
1477
|
+
case 15:
|
|
1399
1478
|
case "end":
|
|
1400
1479
|
return _context.stop();
|
|
1401
1480
|
}
|
|
@@ -1435,4 +1514,4 @@ var EvmBuilder = function EvmBuilder() {
|
|
|
1435
1514
|
return EvmBuilder$1(papiApi);
|
|
1436
1515
|
};
|
|
1437
1516
|
|
|
1438
|
-
export { Builder, EvmBuilder, GeneralBuilder, assets, claimAssets, createApiInstanceForNode, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, transfer as xcmPallet };
|
|
1517
|
+
export { Builder, EvmBuilder, GeneralBuilder, assets, claimAssets, createApiInstanceForNode, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getParaEthTransferFees, getTransferInfo, getTransferableAmount, send, verifyEdOnDestination, transfer as xcmPallet };
|