@paraspell/sdk 6.2.2 → 6.2.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 +1 -1
- package/dist/index.cjs +122 -133
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +122 -134
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -293,7 +293,7 @@ await getBalanceForeign(address, Parachain name, currency /*- {id: currencyID} |
|
|
|
293
293
|
await getBalanceNative(address, Parachain name)
|
|
294
294
|
|
|
295
295
|
//Get fee information regarding XCM call
|
|
296
|
-
await getOriginFeeDetails(from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress)
|
|
296
|
+
await getOriginFeeDetails(from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress, api /* optional */, feeMargin /* 10% by default */)
|
|
297
297
|
|
|
298
298
|
//Get all the information about XCM transfer
|
|
299
299
|
await getTransferInfo(from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount)
|
package/dist/index.cjs
CHANGED
|
@@ -11518,60 +11518,6 @@ var getBalanceForeign = function getBalanceForeign(address, node, symbolOrId, ap
|
|
|
11518
11518
|
}));
|
|
11519
11519
|
};
|
|
11520
11520
|
|
|
11521
|
-
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
11522
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
11523
|
-
var _a, api, isNativeSymbol;
|
|
11524
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
11525
|
-
while (1) switch (_context.prev = _context.next) {
|
|
11526
|
-
case 0:
|
|
11527
|
-
_context.next = 2;
|
|
11528
|
-
return createApiInstanceForNode(node);
|
|
11529
|
-
case 2:
|
|
11530
|
-
api = _context.sent;
|
|
11531
|
-
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
11532
|
-
if (!isNativeSymbol) {
|
|
11533
|
-
_context.next = 10;
|
|
11534
|
-
break;
|
|
11535
|
-
}
|
|
11536
|
-
_context.next = 7;
|
|
11537
|
-
return getBalanceNative(account, node, api);
|
|
11538
|
-
case 7:
|
|
11539
|
-
_context.t0 = _context.sent;
|
|
11540
|
-
_context.next = 22;
|
|
11541
|
-
break;
|
|
11542
|
-
case 10:
|
|
11543
|
-
_context.next = 12;
|
|
11544
|
-
return getBalanceForeign(account, node, currency, api);
|
|
11545
|
-
case 12:
|
|
11546
|
-
_context.t2 = _a = _context.sent;
|
|
11547
|
-
_context.t1 = _context.t2 !== null;
|
|
11548
|
-
if (!_context.t1) {
|
|
11549
|
-
_context.next = 16;
|
|
11550
|
-
break;
|
|
11551
|
-
}
|
|
11552
|
-
_context.t1 = _a !== void 0;
|
|
11553
|
-
case 16:
|
|
11554
|
-
if (!_context.t1) {
|
|
11555
|
-
_context.next = 20;
|
|
11556
|
-
break;
|
|
11557
|
-
}
|
|
11558
|
-
_context.t3 = _a;
|
|
11559
|
-
_context.next = 21;
|
|
11560
|
-
break;
|
|
11561
|
-
case 20:
|
|
11562
|
-
_context.t3 = BigInt(0);
|
|
11563
|
-
case 21:
|
|
11564
|
-
_context.t0 = _context.t3;
|
|
11565
|
-
case 22:
|
|
11566
|
-
return _context.abrupt("return", _context.t0);
|
|
11567
|
-
case 23:
|
|
11568
|
-
case "end":
|
|
11569
|
-
return _context.stop();
|
|
11570
|
-
}
|
|
11571
|
-
}, _callee);
|
|
11572
|
-
}));
|
|
11573
|
-
};
|
|
11574
|
-
|
|
11575
11521
|
var palletsMap = edsMapJson;
|
|
11576
11522
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
11577
11523
|
return BigInt(palletsMap[node]);
|
|
@@ -12689,6 +12635,26 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
12689
12635
|
return new EvmBuilderClass(provider);
|
|
12690
12636
|
};
|
|
12691
12637
|
|
|
12638
|
+
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
12639
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12640
|
+
var _yield$tx$paymentInfo, partialFee;
|
|
12641
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12642
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12643
|
+
case 0:
|
|
12644
|
+
_context.next = 2;
|
|
12645
|
+
return tx.paymentInfo(address);
|
|
12646
|
+
case 2:
|
|
12647
|
+
_yield$tx$paymentInfo = _context.sent;
|
|
12648
|
+
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
12649
|
+
return _context.abrupt("return", partialFee.toBn());
|
|
12650
|
+
case 5:
|
|
12651
|
+
case "end":
|
|
12652
|
+
return _context.stop();
|
|
12653
|
+
}
|
|
12654
|
+
}, _callee);
|
|
12655
|
+
}));
|
|
12656
|
+
};
|
|
12657
|
+
|
|
12692
12658
|
var createTx$1 = function createTx(originApi, address, amount, currency, originNode, destNode) {
|
|
12693
12659
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12694
12660
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -12723,74 +12689,115 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
12723
12689
|
}, _callee);
|
|
12724
12690
|
}));
|
|
12725
12691
|
};
|
|
12726
|
-
var
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12692
|
+
var getOriginFeeDetails = function getOriginFeeDetails(origin_1, destination_1, currency_1, amount_1, account_1, api_1) {
|
|
12693
|
+
for (var _len = arguments.length, args_1 = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
|
|
12694
|
+
args_1[_key - 6] = arguments[_key];
|
|
12695
|
+
}
|
|
12696
|
+
return __awaiter(void 0, [origin_1, destination_1, currency_1, amount_1, account_1, api_1].concat(args_1), void 0, function (origin, destination, currency, amount, account, api) {
|
|
12697
|
+
var feeMarginPercentage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 10;
|
|
12698
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
12699
|
+
var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
|
|
12700
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
12701
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
12702
|
+
case 0:
|
|
12703
|
+
_context2.next = 2;
|
|
12704
|
+
return getBalanceNative(account, origin);
|
|
12705
|
+
case 2:
|
|
12706
|
+
nativeBalance = _context2.sent;
|
|
12707
|
+
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
12708
|
+
if (!(api !== null && api !== void 0)) {
|
|
12709
|
+
_context2.next = 8;
|
|
12710
|
+
break;
|
|
12711
|
+
}
|
|
12712
|
+
_context2.t0 = api;
|
|
12713
|
+
_context2.next = 11;
|
|
12714
|
+
break;
|
|
12715
|
+
case 8:
|
|
12716
|
+
_context2.next = 10;
|
|
12717
|
+
return createApiInstanceForNode(origin);
|
|
12718
|
+
case 10:
|
|
12719
|
+
_context2.t0 = _context2.sent;
|
|
12720
|
+
case 11:
|
|
12721
|
+
apiWithFallback = _context2.t0;
|
|
12722
|
+
_context2.next = 14;
|
|
12723
|
+
return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
|
|
12724
|
+
case 14:
|
|
12725
|
+
tx = _context2.sent;
|
|
12726
|
+
_context2.next = 17;
|
|
12727
|
+
return calculateTransactionFee(tx, account);
|
|
12728
|
+
case 17:
|
|
12729
|
+
xcmFee = _context2.sent;
|
|
12730
|
+
xcmFeeBigInt = BigInt(xcmFee.toString());
|
|
12731
|
+
xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(feeMarginPercentage);
|
|
12732
|
+
console.log('nativeBalance', nativeBalance);
|
|
12733
|
+
console.log('minTransferableAmount', minTransferableAmount);
|
|
12734
|
+
console.log('xcmFeeBigInt', xcmFeeBigInt);
|
|
12735
|
+
console.log('xcmFeeWithMargin', xcmFeeWithMargin);
|
|
12736
|
+
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
12737
|
+
return _context2.abrupt("return", {
|
|
12738
|
+
sufficientForXCM: sufficientForXCM,
|
|
12739
|
+
xcmFee: xcmFeeBigInt
|
|
12740
|
+
});
|
|
12741
|
+
case 26:
|
|
12742
|
+
case "end":
|
|
12743
|
+
return _context2.stop();
|
|
12744
|
+
}
|
|
12745
|
+
}, _callee2);
|
|
12746
|
+
})();
|
|
12747
|
+
});
|
|
12744
12748
|
};
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12749
|
+
|
|
12750
|
+
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
12751
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12752
|
+
var _a, api, isNativeSymbol;
|
|
12753
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12754
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12750
12755
|
case 0:
|
|
12751
|
-
|
|
12752
|
-
return
|
|
12756
|
+
_context.next = 2;
|
|
12757
|
+
return createApiInstanceForNode(node);
|
|
12753
12758
|
case 2:
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
if (!
|
|
12757
|
-
|
|
12759
|
+
api = _context.sent;
|
|
12760
|
+
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
12761
|
+
if (!isNativeSymbol) {
|
|
12762
|
+
_context.next = 10;
|
|
12758
12763
|
break;
|
|
12759
12764
|
}
|
|
12760
|
-
|
|
12761
|
-
|
|
12765
|
+
_context.next = 7;
|
|
12766
|
+
return getBalanceNative(account, node, api);
|
|
12767
|
+
case 7:
|
|
12768
|
+
_context.t0 = _context.sent;
|
|
12769
|
+
_context.next = 22;
|
|
12762
12770
|
break;
|
|
12763
|
-
case 8:
|
|
12764
|
-
_context3.next = 10;
|
|
12765
|
-
return createApiInstanceForNode(origin);
|
|
12766
12771
|
case 10:
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
case
|
|
12772
|
+
_context.next = 12;
|
|
12773
|
+
return getBalanceForeign(account, node, currency, api);
|
|
12774
|
+
case 12:
|
|
12775
|
+
_context.t2 = _a = _context.sent;
|
|
12776
|
+
_context.t1 = _context.t2 !== null;
|
|
12777
|
+
if (!_context.t1) {
|
|
12778
|
+
_context.next = 16;
|
|
12779
|
+
break;
|
|
12780
|
+
}
|
|
12781
|
+
_context.t1 = _a !== void 0;
|
|
12782
|
+
case 16:
|
|
12783
|
+
if (!_context.t1) {
|
|
12784
|
+
_context.next = 20;
|
|
12785
|
+
break;
|
|
12786
|
+
}
|
|
12787
|
+
_context.t3 = _a;
|
|
12788
|
+
_context.next = 21;
|
|
12789
|
+
break;
|
|
12790
|
+
case 20:
|
|
12791
|
+
_context.t3 = BigInt(0);
|
|
12792
|
+
case 21:
|
|
12793
|
+
_context.t0 = _context.t3;
|
|
12794
|
+
case 22:
|
|
12795
|
+
return _context.abrupt("return", _context.t0);
|
|
12796
|
+
case 23:
|
|
12790
12797
|
case "end":
|
|
12791
|
-
return
|
|
12798
|
+
return _context.stop();
|
|
12792
12799
|
}
|
|
12793
|
-
},
|
|
12800
|
+
}, _callee);
|
|
12794
12801
|
}));
|
|
12795
12802
|
};
|
|
12796
12803
|
|
|
@@ -12946,6 +12953,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
12946
12953
|
getExistentialDeposit: getExistentialDeposit$1,
|
|
12947
12954
|
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
12948
12955
|
getNativeAssets: getNativeAssets,
|
|
12956
|
+
getOriginFeeDetails: getOriginFeeDetails,
|
|
12949
12957
|
getOtherAssets: getOtherAssets,
|
|
12950
12958
|
getParaId: getParaId,
|
|
12951
12959
|
getRelayChainSymbol: getRelayChainSymbol,
|
|
@@ -13222,26 +13230,6 @@ var KeepAliveError = /*#__PURE__*/function (_Error) {
|
|
|
13222
13230
|
return _createClass(KeepAliveError);
|
|
13223
13231
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
13224
13232
|
|
|
13225
|
-
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
13226
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13227
|
-
var _yield$tx$paymentInfo, partialFee;
|
|
13228
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13229
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13230
|
-
case 0:
|
|
13231
|
-
_context.next = 2;
|
|
13232
|
-
return tx.paymentInfo(address);
|
|
13233
|
-
case 2:
|
|
13234
|
-
_yield$tx$paymentInfo = _context.sent;
|
|
13235
|
-
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
13236
|
-
return _context.abrupt("return", partialFee.toBn());
|
|
13237
|
-
case 5:
|
|
13238
|
-
case "end":
|
|
13239
|
-
return _context.stop();
|
|
13240
|
-
}
|
|
13241
|
-
}, _callee);
|
|
13242
|
-
}));
|
|
13243
|
-
};
|
|
13244
|
-
|
|
13245
13233
|
var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
|
|
13246
13234
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13247
13235
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -13846,6 +13834,7 @@ exports.getNativeAssets = getNativeAssets;
|
|
|
13846
13834
|
exports.getNode = getNode;
|
|
13847
13835
|
exports.getNodeEndpointOption = getNodeEndpointOption;
|
|
13848
13836
|
exports.getNodeProvider = getNodeProvider;
|
|
13837
|
+
exports.getOriginFeeDetails = getOriginFeeDetails;
|
|
13849
13838
|
exports.getOtherAssets = getOtherAssets;
|
|
13850
13839
|
exports.getParaId = getParaId;
|
|
13851
13840
|
exports.getRelayChainSymbol = getRelayChainSymbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -1121,6 +1121,8 @@ declare const getBalanceNative: (address: string, node: TNodeWithRelayChains, ap
|
|
|
1121
1121
|
*/
|
|
1122
1122
|
declare const getBalanceForeign: (address: string, node: TNodePolkadotKusama, symbolOrId: TCurrencyCore, api?: ApiPromise) => Promise<bigint | null>;
|
|
1123
1123
|
|
|
1124
|
+
declare const getOriginFeeDetails: (origin: TNodeDotKsmWithRelayChains, destination: TNodeDotKsmWithRelayChains, currency: TCurrencyCore, amount: string, account: string, api?: ApiPromise, feeMarginPercentage?: number) => Promise<TOriginFeeDetails>;
|
|
1125
|
+
|
|
1124
1126
|
/**
|
|
1125
1127
|
* Retrieves detailed transfer information for a cross-chain transfer.
|
|
1126
1128
|
*
|
|
@@ -1153,6 +1155,7 @@ declare const index_getBalanceNative: typeof getBalanceNative;
|
|
|
1153
1155
|
declare const index_getExistentialDeposit: typeof getExistentialDeposit;
|
|
1154
1156
|
declare const index_getNativeAssetSymbol: typeof getNativeAssetSymbol;
|
|
1155
1157
|
declare const index_getNativeAssets: typeof getNativeAssets;
|
|
1158
|
+
declare const index_getOriginFeeDetails: typeof getOriginFeeDetails;
|
|
1156
1159
|
declare const index_getOtherAssets: typeof getOtherAssets;
|
|
1157
1160
|
declare const index_getParaId: typeof getParaId;
|
|
1158
1161
|
declare const index_getRelayChainSymbol: typeof getRelayChainSymbol;
|
|
@@ -1161,7 +1164,7 @@ declare const index_getTNode: typeof getTNode;
|
|
|
1161
1164
|
declare const index_getTransferInfo: typeof getTransferInfo;
|
|
1162
1165
|
declare const index_hasSupportForAsset: typeof hasSupportForAsset;
|
|
1163
1166
|
declare namespace index {
|
|
1164
|
-
export { index_getAllAssetsSymbols as getAllAssetsSymbols, index_getAssetDecimals as getAssetDecimals, index_getAssetId as getAssetId, index_getAssets as getAssets, index_getAssetsObject as getAssetsObject, index_getBalanceForeign as getBalanceForeign, index_getBalanceNative as getBalanceNative, index_getExistentialDeposit as getExistentialDeposit, index_getNativeAssetSymbol as getNativeAssetSymbol, index_getNativeAssets as getNativeAssets, index_getOtherAssets as getOtherAssets, index_getParaId as getParaId, index_getRelayChainSymbol as getRelayChainSymbol, index_getSupportedAssets as getSupportedAssets, index_getTNode as getTNode, index_getTransferInfo as getTransferInfo, index_hasSupportForAsset as hasSupportForAsset };
|
|
1167
|
+
export { index_getAllAssetsSymbols as getAllAssetsSymbols, index_getAssetDecimals as getAssetDecimals, index_getAssetId as getAssetId, index_getAssets as getAssets, index_getAssetsObject as getAssetsObject, index_getBalanceForeign as getBalanceForeign, index_getBalanceNative as getBalanceNative, index_getExistentialDeposit as getExistentialDeposit, index_getNativeAssetSymbol as getNativeAssetSymbol, index_getNativeAssets as getNativeAssets, index_getOriginFeeDetails as getOriginFeeDetails, index_getOtherAssets as getOtherAssets, index_getParaId as getParaId, index_getRelayChainSymbol as getRelayChainSymbol, index_getSupportedAssets as getSupportedAssets, index_getTNode as getTNode, index_getTransferInfo as getTransferInfo, index_hasSupportForAsset as hasSupportForAsset };
|
|
1165
1168
|
}
|
|
1166
1169
|
|
|
1167
1170
|
/**
|
|
@@ -1514,4 +1517,4 @@ declare class DuplicateAssetIdError extends Error {
|
|
|
1514
1517
|
constructor(id: string);
|
|
1515
1518
|
}
|
|
1516
1519
|
|
|
1517
|
-
export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
|
|
1520
|
+
export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOriginFeeDetails, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
|
package/dist/index.mjs
CHANGED
|
@@ -11516,60 +11516,6 @@ var getBalanceForeign = function getBalanceForeign(address, node, symbolOrId, ap
|
|
|
11516
11516
|
}));
|
|
11517
11517
|
};
|
|
11518
11518
|
|
|
11519
|
-
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
11520
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
11521
|
-
var _a, api, isNativeSymbol;
|
|
11522
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
11523
|
-
while (1) switch (_context.prev = _context.next) {
|
|
11524
|
-
case 0:
|
|
11525
|
-
_context.next = 2;
|
|
11526
|
-
return createApiInstanceForNode(node);
|
|
11527
|
-
case 2:
|
|
11528
|
-
api = _context.sent;
|
|
11529
|
-
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
11530
|
-
if (!isNativeSymbol) {
|
|
11531
|
-
_context.next = 10;
|
|
11532
|
-
break;
|
|
11533
|
-
}
|
|
11534
|
-
_context.next = 7;
|
|
11535
|
-
return getBalanceNative(account, node, api);
|
|
11536
|
-
case 7:
|
|
11537
|
-
_context.t0 = _context.sent;
|
|
11538
|
-
_context.next = 22;
|
|
11539
|
-
break;
|
|
11540
|
-
case 10:
|
|
11541
|
-
_context.next = 12;
|
|
11542
|
-
return getBalanceForeign(account, node, currency, api);
|
|
11543
|
-
case 12:
|
|
11544
|
-
_context.t2 = _a = _context.sent;
|
|
11545
|
-
_context.t1 = _context.t2 !== null;
|
|
11546
|
-
if (!_context.t1) {
|
|
11547
|
-
_context.next = 16;
|
|
11548
|
-
break;
|
|
11549
|
-
}
|
|
11550
|
-
_context.t1 = _a !== void 0;
|
|
11551
|
-
case 16:
|
|
11552
|
-
if (!_context.t1) {
|
|
11553
|
-
_context.next = 20;
|
|
11554
|
-
break;
|
|
11555
|
-
}
|
|
11556
|
-
_context.t3 = _a;
|
|
11557
|
-
_context.next = 21;
|
|
11558
|
-
break;
|
|
11559
|
-
case 20:
|
|
11560
|
-
_context.t3 = BigInt(0);
|
|
11561
|
-
case 21:
|
|
11562
|
-
_context.t0 = _context.t3;
|
|
11563
|
-
case 22:
|
|
11564
|
-
return _context.abrupt("return", _context.t0);
|
|
11565
|
-
case 23:
|
|
11566
|
-
case "end":
|
|
11567
|
-
return _context.stop();
|
|
11568
|
-
}
|
|
11569
|
-
}, _callee);
|
|
11570
|
-
}));
|
|
11571
|
-
};
|
|
11572
|
-
|
|
11573
11519
|
var palletsMap = edsMapJson;
|
|
11574
11520
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
11575
11521
|
return BigInt(palletsMap[node]);
|
|
@@ -12687,6 +12633,26 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
12687
12633
|
return new EvmBuilderClass(provider);
|
|
12688
12634
|
};
|
|
12689
12635
|
|
|
12636
|
+
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
12637
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12638
|
+
var _yield$tx$paymentInfo, partialFee;
|
|
12639
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12640
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12641
|
+
case 0:
|
|
12642
|
+
_context.next = 2;
|
|
12643
|
+
return tx.paymentInfo(address);
|
|
12644
|
+
case 2:
|
|
12645
|
+
_yield$tx$paymentInfo = _context.sent;
|
|
12646
|
+
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
12647
|
+
return _context.abrupt("return", partialFee.toBn());
|
|
12648
|
+
case 5:
|
|
12649
|
+
case "end":
|
|
12650
|
+
return _context.stop();
|
|
12651
|
+
}
|
|
12652
|
+
}, _callee);
|
|
12653
|
+
}));
|
|
12654
|
+
};
|
|
12655
|
+
|
|
12690
12656
|
var createTx$1 = function createTx(originApi, address, amount, currency, originNode, destNode) {
|
|
12691
12657
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12692
12658
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -12721,74 +12687,115 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
12721
12687
|
}, _callee);
|
|
12722
12688
|
}));
|
|
12723
12689
|
};
|
|
12724
|
-
var
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12690
|
+
var getOriginFeeDetails = function getOriginFeeDetails(origin_1, destination_1, currency_1, amount_1, account_1, api_1) {
|
|
12691
|
+
for (var _len = arguments.length, args_1 = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
|
|
12692
|
+
args_1[_key - 6] = arguments[_key];
|
|
12693
|
+
}
|
|
12694
|
+
return __awaiter(void 0, [origin_1, destination_1, currency_1, amount_1, account_1, api_1].concat(args_1), void 0, function (origin, destination, currency, amount, account, api) {
|
|
12695
|
+
var feeMarginPercentage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 10;
|
|
12696
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
12697
|
+
var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
|
|
12698
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
12699
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
12700
|
+
case 0:
|
|
12701
|
+
_context2.next = 2;
|
|
12702
|
+
return getBalanceNative(account, origin);
|
|
12703
|
+
case 2:
|
|
12704
|
+
nativeBalance = _context2.sent;
|
|
12705
|
+
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
12706
|
+
if (!(api !== null && api !== void 0)) {
|
|
12707
|
+
_context2.next = 8;
|
|
12708
|
+
break;
|
|
12709
|
+
}
|
|
12710
|
+
_context2.t0 = api;
|
|
12711
|
+
_context2.next = 11;
|
|
12712
|
+
break;
|
|
12713
|
+
case 8:
|
|
12714
|
+
_context2.next = 10;
|
|
12715
|
+
return createApiInstanceForNode(origin);
|
|
12716
|
+
case 10:
|
|
12717
|
+
_context2.t0 = _context2.sent;
|
|
12718
|
+
case 11:
|
|
12719
|
+
apiWithFallback = _context2.t0;
|
|
12720
|
+
_context2.next = 14;
|
|
12721
|
+
return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
|
|
12722
|
+
case 14:
|
|
12723
|
+
tx = _context2.sent;
|
|
12724
|
+
_context2.next = 17;
|
|
12725
|
+
return calculateTransactionFee(tx, account);
|
|
12726
|
+
case 17:
|
|
12727
|
+
xcmFee = _context2.sent;
|
|
12728
|
+
xcmFeeBigInt = BigInt(xcmFee.toString());
|
|
12729
|
+
xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(feeMarginPercentage);
|
|
12730
|
+
console.log('nativeBalance', nativeBalance);
|
|
12731
|
+
console.log('minTransferableAmount', minTransferableAmount);
|
|
12732
|
+
console.log('xcmFeeBigInt', xcmFeeBigInt);
|
|
12733
|
+
console.log('xcmFeeWithMargin', xcmFeeWithMargin);
|
|
12734
|
+
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
12735
|
+
return _context2.abrupt("return", {
|
|
12736
|
+
sufficientForXCM: sufficientForXCM,
|
|
12737
|
+
xcmFee: xcmFeeBigInt
|
|
12738
|
+
});
|
|
12739
|
+
case 26:
|
|
12740
|
+
case "end":
|
|
12741
|
+
return _context2.stop();
|
|
12742
|
+
}
|
|
12743
|
+
}, _callee2);
|
|
12744
|
+
})();
|
|
12745
|
+
});
|
|
12742
12746
|
};
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12747
|
+
|
|
12748
|
+
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
12749
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12750
|
+
var _a, api, isNativeSymbol;
|
|
12751
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12752
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12748
12753
|
case 0:
|
|
12749
|
-
|
|
12750
|
-
return
|
|
12754
|
+
_context.next = 2;
|
|
12755
|
+
return createApiInstanceForNode(node);
|
|
12751
12756
|
case 2:
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
if (!
|
|
12755
|
-
|
|
12757
|
+
api = _context.sent;
|
|
12758
|
+
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
12759
|
+
if (!isNativeSymbol) {
|
|
12760
|
+
_context.next = 10;
|
|
12756
12761
|
break;
|
|
12757
12762
|
}
|
|
12758
|
-
|
|
12759
|
-
|
|
12763
|
+
_context.next = 7;
|
|
12764
|
+
return getBalanceNative(account, node, api);
|
|
12765
|
+
case 7:
|
|
12766
|
+
_context.t0 = _context.sent;
|
|
12767
|
+
_context.next = 22;
|
|
12760
12768
|
break;
|
|
12761
|
-
case 8:
|
|
12762
|
-
_context3.next = 10;
|
|
12763
|
-
return createApiInstanceForNode(origin);
|
|
12764
12769
|
case 10:
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
case
|
|
12770
|
+
_context.next = 12;
|
|
12771
|
+
return getBalanceForeign(account, node, currency, api);
|
|
12772
|
+
case 12:
|
|
12773
|
+
_context.t2 = _a = _context.sent;
|
|
12774
|
+
_context.t1 = _context.t2 !== null;
|
|
12775
|
+
if (!_context.t1) {
|
|
12776
|
+
_context.next = 16;
|
|
12777
|
+
break;
|
|
12778
|
+
}
|
|
12779
|
+
_context.t1 = _a !== void 0;
|
|
12780
|
+
case 16:
|
|
12781
|
+
if (!_context.t1) {
|
|
12782
|
+
_context.next = 20;
|
|
12783
|
+
break;
|
|
12784
|
+
}
|
|
12785
|
+
_context.t3 = _a;
|
|
12786
|
+
_context.next = 21;
|
|
12787
|
+
break;
|
|
12788
|
+
case 20:
|
|
12789
|
+
_context.t3 = BigInt(0);
|
|
12790
|
+
case 21:
|
|
12791
|
+
_context.t0 = _context.t3;
|
|
12792
|
+
case 22:
|
|
12793
|
+
return _context.abrupt("return", _context.t0);
|
|
12794
|
+
case 23:
|
|
12788
12795
|
case "end":
|
|
12789
|
-
return
|
|
12796
|
+
return _context.stop();
|
|
12790
12797
|
}
|
|
12791
|
-
},
|
|
12798
|
+
}, _callee);
|
|
12792
12799
|
}));
|
|
12793
12800
|
};
|
|
12794
12801
|
|
|
@@ -12944,6 +12951,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
12944
12951
|
getExistentialDeposit: getExistentialDeposit$1,
|
|
12945
12952
|
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
12946
12953
|
getNativeAssets: getNativeAssets,
|
|
12954
|
+
getOriginFeeDetails: getOriginFeeDetails,
|
|
12947
12955
|
getOtherAssets: getOtherAssets,
|
|
12948
12956
|
getParaId: getParaId,
|
|
12949
12957
|
getRelayChainSymbol: getRelayChainSymbol,
|
|
@@ -13220,26 +13228,6 @@ var KeepAliveError = /*#__PURE__*/function (_Error) {
|
|
|
13220
13228
|
return _createClass(KeepAliveError);
|
|
13221
13229
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
13222
13230
|
|
|
13223
|
-
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
13224
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13225
|
-
var _yield$tx$paymentInfo, partialFee;
|
|
13226
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13227
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13228
|
-
case 0:
|
|
13229
|
-
_context.next = 2;
|
|
13230
|
-
return tx.paymentInfo(address);
|
|
13231
|
-
case 2:
|
|
13232
|
-
_yield$tx$paymentInfo = _context.sent;
|
|
13233
|
-
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
13234
|
-
return _context.abrupt("return", partialFee.toBn());
|
|
13235
|
-
case 5:
|
|
13236
|
-
case "end":
|
|
13237
|
-
return _context.stop();
|
|
13238
|
-
}
|
|
13239
|
-
}, _callee);
|
|
13240
|
-
}));
|
|
13241
|
-
};
|
|
13242
|
-
|
|
13243
13231
|
var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
|
|
13244
13232
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13245
13233
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -13810,4 +13798,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
13810
13798
|
transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
|
|
13811
13799
|
});
|
|
13812
13800
|
|
|
13813
|
-
export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
|
|
13801
|
+
export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOriginFeeDetails, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
|