@paraspell/sdk-core 12.0.4 → 12.0.5
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.d.ts +2 -2
- package/dist/index.mjs +67 -21
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -292,7 +292,7 @@ declare abstract class BaseAssetsPallet {
|
|
|
292
292
|
protected palletName: TAssetsPallet;
|
|
293
293
|
constructor(palletName: TAssetsPallet);
|
|
294
294
|
abstract mint<TApi, TRes>(address: string, assetInfo: WithAmount<TAssetInfo>, balance: bigint, chain: TSubstrateChain, api: IPolkadotApi<TApi, TRes>): Promise<TSetBalanceRes>;
|
|
295
|
-
abstract getBalance<TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: string, asset: TAssetInfo, customCurrencyId?: unknown
|
|
295
|
+
abstract getBalance<TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: string, asset: TAssetInfo, customCurrencyId?: unknown): Promise<bigint>;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
/**
|
|
@@ -608,7 +608,7 @@ type TDryRunCallBaseOptions<TRes> = {
|
|
|
608
608
|
*/
|
|
609
609
|
destination: TDestination;
|
|
610
610
|
/**
|
|
611
|
-
* The address to dry-run with
|
|
611
|
+
* The address to dry-run with (senderAddress)
|
|
612
612
|
*/
|
|
613
613
|
address: string;
|
|
614
614
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -3017,6 +3017,9 @@ var getMythosOriginFee = /*#__PURE__*/function () {
|
|
|
3017
3017
|
}();
|
|
3018
3018
|
|
|
3019
3019
|
var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
|
|
3020
|
+
if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
|
|
3021
|
+
throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
|
|
3022
|
+
}
|
|
3020
3023
|
var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
|
|
3021
3024
|
var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
|
|
3022
3025
|
if (!asset && !usesRawOverriddenMultiAssets) {
|
|
@@ -6485,7 +6488,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
6485
6488
|
sufficient = _context.v;
|
|
6486
6489
|
return _context.a(2, {
|
|
6487
6490
|
fee: paddedFee,
|
|
6488
|
-
asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset :
|
|
6491
|
+
asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset : findNativeAssetInfoOrThrow(origin),
|
|
6489
6492
|
feeType: 'paymentInfo',
|
|
6490
6493
|
sufficient: sufficient
|
|
6491
6494
|
});
|
|
@@ -6765,7 +6768,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6765
6768
|
feeType: originFeeType
|
|
6766
6769
|
}), {}, {
|
|
6767
6770
|
sufficient: sufficientOriginFee,
|
|
6768
|
-
asset:
|
|
6771
|
+
asset: originAsset
|
|
6769
6772
|
}, originDryRunError && {
|
|
6770
6773
|
dryRunError: originDryRunError
|
|
6771
6774
|
}), originDryRunSubError && {
|
|
@@ -8171,8 +8174,8 @@ var resolveBuyExecutionAmount = function resolveBuyExecutionAmount(_ref, isForFe
|
|
|
8171
8174
|
// We have actual fees, calculate exact buy execution amount
|
|
8172
8175
|
return isRelayAsset ? assetInfo.amount - hopFees : destFee;
|
|
8173
8176
|
};
|
|
8174
|
-
var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount) {
|
|
8175
|
-
var fees = arguments.length >
|
|
8177
|
+
var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction) {
|
|
8178
|
+
var fees = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
8176
8179
|
hopFees: 0n,
|
|
8177
8180
|
destFee: 0n
|
|
8178
8181
|
};
|
|
@@ -8236,25 +8239,44 @@ var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc
|
|
|
8236
8239
|
var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
|
|
8237
8240
|
// If destination is a system chain, use teleport instead of reserve deposit
|
|
8238
8241
|
if (isSystemChain(dest.chain)) {
|
|
8239
|
-
return [{
|
|
8242
|
+
return [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
|
|
8240
8243
|
InitiateTeleport: {
|
|
8241
8244
|
assets: filter,
|
|
8242
8245
|
dest: destLoc,
|
|
8243
8246
|
xcm: [buyExecution, depositInstruction]
|
|
8244
8247
|
}
|
|
8245
|
-
}];
|
|
8248
|
+
}]);
|
|
8246
8249
|
}
|
|
8247
|
-
return [{
|
|
8250
|
+
return [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
|
|
8248
8251
|
DepositReserveAsset: {
|
|
8249
8252
|
assets: filter,
|
|
8250
8253
|
dest: destLoc,
|
|
8251
8254
|
xcm: [buyExecution, depositInstruction]
|
|
8252
8255
|
}
|
|
8253
|
-
}];
|
|
8256
|
+
}]);
|
|
8254
8257
|
}
|
|
8255
8258
|
return [depositInstruction];
|
|
8256
8259
|
};
|
|
8257
8260
|
|
|
8261
|
+
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
|
|
8262
|
+
return {
|
|
8263
|
+
SetAppendix: [{
|
|
8264
|
+
DepositAsset: {
|
|
8265
|
+
assets: {
|
|
8266
|
+
Wild: {
|
|
8267
|
+
AllCounted: assetCount
|
|
8268
|
+
}
|
|
8269
|
+
},
|
|
8270
|
+
beneficiary: createBeneficiaryLocation({
|
|
8271
|
+
api: api,
|
|
8272
|
+
address: senderAddress,
|
|
8273
|
+
version: version
|
|
8274
|
+
})
|
|
8275
|
+
}
|
|
8276
|
+
}]
|
|
8277
|
+
};
|
|
8278
|
+
};
|
|
8279
|
+
|
|
8258
8280
|
var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, version) {
|
|
8259
8281
|
var assets = [];
|
|
8260
8282
|
var shouldLocalizeAndSort = isRelayChain(chain) || chain.startsWith('AssetHub');
|
|
@@ -8276,19 +8298,22 @@ var constructTypeAndThenCall = function constructTypeAndThenCall(context) {
|
|
|
8276
8298
|
var fees = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
8277
8299
|
var origin = context.origin,
|
|
8278
8300
|
assetInfo = context.assetInfo,
|
|
8301
|
+
isSubBridge = context.isSubBridge,
|
|
8279
8302
|
isRelayAsset = context.isRelayAsset,
|
|
8280
|
-
|
|
8303
|
+
_context$options = context.options,
|
|
8304
|
+
senderAddress = _context$options.senderAddress,
|
|
8305
|
+
version = _context$options.version;
|
|
8281
8306
|
var assetCount = isRelayAsset ? 1 : 2;
|
|
8282
|
-
var
|
|
8307
|
+
var refundInstruction = senderAddress && !isSubBridge ? createRefundInstruction(origin.api, senderAddress, version, assetCount) : null;
|
|
8283
8308
|
var resolvedFees = fees !== null && fees !== void 0 ? fees : {
|
|
8284
8309
|
hopFees: 0n,
|
|
8285
8310
|
destFee: 0n
|
|
8286
8311
|
};
|
|
8287
8312
|
var isForFeeCalc = fees === null;
|
|
8288
8313
|
var systemAssetAmount = resolveSystemAssetAmount(context, isForFeeCalc, resolvedFees);
|
|
8289
|
-
|
|
8314
|
+
var customXcm = createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction, resolvedFees);
|
|
8290
8315
|
var assets = buildAssets(origin.chain, assetInfo, systemAssetAmount, isRelayAsset, version);
|
|
8291
|
-
return buildTypeAndThenCall(context, isRelayAsset,
|
|
8316
|
+
return buildTypeAndThenCall(context, isRelayAsset, customXcm, assets);
|
|
8292
8317
|
};
|
|
8293
8318
|
/**
|
|
8294
8319
|
* Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
|
|
@@ -9198,7 +9223,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
9198
9223
|
instance = getPalletInstance(pallet);
|
|
9199
9224
|
_context5.p = 4;
|
|
9200
9225
|
_context5.n = 5;
|
|
9201
|
-
return instance.getBalance(api, address, asset, customCurrencyId
|
|
9226
|
+
return instance.getBalance(api, address, asset, customCurrencyId);
|
|
9202
9227
|
case 5:
|
|
9203
9228
|
return _context5.a(2, _context5.v);
|
|
9204
9229
|
case 6:
|
|
@@ -11623,9 +11648,31 @@ var EnergyWebX = /*#__PURE__*/function (_Parachain) {
|
|
|
11623
11648
|
}
|
|
11624
11649
|
}, {
|
|
11625
11650
|
key: "getBalanceForeign",
|
|
11626
|
-
value: function
|
|
11627
|
-
|
|
11628
|
-
|
|
11651
|
+
value: function () {
|
|
11652
|
+
var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
|
|
11653
|
+
var _balance$balance;
|
|
11654
|
+
var balance;
|
|
11655
|
+
return _regenerator().w(function (_context) {
|
|
11656
|
+
while (1) switch (_context.n) {
|
|
11657
|
+
case 0:
|
|
11658
|
+
assertHasLocation(asset);
|
|
11659
|
+
_context.n = 1;
|
|
11660
|
+
return api.queryState({
|
|
11661
|
+
module: 'Assets',
|
|
11662
|
+
method: 'Account',
|
|
11663
|
+
params: [asset.location, address]
|
|
11664
|
+
});
|
|
11665
|
+
case 1:
|
|
11666
|
+
balance = _context.v;
|
|
11667
|
+
return _context.a(2, (_balance$balance = balance === null || balance === void 0 ? void 0 : balance.balance) !== null && _balance$balance !== void 0 ? _balance$balance : 0n);
|
|
11668
|
+
}
|
|
11669
|
+
}, _callee);
|
|
11670
|
+
}));
|
|
11671
|
+
function getBalanceForeign(_x, _x2, _x3) {
|
|
11672
|
+
return _getBalanceForeign.apply(this, arguments);
|
|
11673
|
+
}
|
|
11674
|
+
return getBalanceForeign;
|
|
11675
|
+
}()
|
|
11629
11676
|
}]);
|
|
11630
11677
|
}(Parachain);
|
|
11631
11678
|
|
|
@@ -13515,22 +13562,21 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
13515
13562
|
}, {
|
|
13516
13563
|
key: "getBalance",
|
|
13517
13564
|
value: function () {
|
|
13518
|
-
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset
|
|
13565
|
+
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
|
|
13519
13566
|
var _this = this,
|
|
13520
13567
|
_balance$balance,
|
|
13521
13568
|
_balance2;
|
|
13522
|
-
var
|
|
13569
|
+
var fetchBalance, balance, _t;
|
|
13523
13570
|
return _regenerator().w(function (_context) {
|
|
13524
13571
|
while (1) switch (_context.p = _context.n) {
|
|
13525
13572
|
case 0:
|
|
13526
13573
|
assertHasId(asset);
|
|
13527
|
-
isEnergyWebX = chain === 'EnergyWebX';
|
|
13528
13574
|
fetchBalance = function fetchBalance() {
|
|
13529
13575
|
var useBigInt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
13530
13576
|
return api.queryState({
|
|
13531
13577
|
module: _this.palletName,
|
|
13532
13578
|
method: 'Account',
|
|
13533
|
-
params: [
|
|
13579
|
+
params: [useBigInt ? BigInt(asset.assetId) : Number(asset.assetId), address]
|
|
13534
13580
|
});
|
|
13535
13581
|
}; // Try with number ID first, if it fails, try with bigint ID
|
|
13536
13582
|
_context.p = 1;
|
|
@@ -13560,7 +13606,7 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
|
|
|
13560
13606
|
}
|
|
13561
13607
|
}, _callee, null, [[1, 3]]);
|
|
13562
13608
|
}));
|
|
13563
|
-
function getBalance(_x, _x2, _x3
|
|
13609
|
+
function getBalance(_x, _x2, _x3) {
|
|
13564
13610
|
return _getBalance.apply(this, arguments);
|
|
13565
13611
|
}
|
|
13566
13612
|
return getBalance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.5",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@noble/hashes": "^2.0.1",
|
|
27
27
|
"@scure/base": "^2.0.0",
|
|
28
28
|
"viem": "^2.40.3",
|
|
29
|
-
"@paraspell/
|
|
30
|
-
"@paraspell/sdk-common": "12.0.
|
|
31
|
-
"@paraspell/
|
|
29
|
+
"@paraspell/pallets": "12.0.5",
|
|
30
|
+
"@paraspell/sdk-common": "12.0.5",
|
|
31
|
+
"@paraspell/assets": "12.0.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|