@paraspell/sdk-core 11.1.1 → 11.2.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/dist/index.cjs +474 -34
- package/dist/index.d.ts +39 -12
- package/dist/index.mjs +475 -38
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3473,6 +3473,49 @@ var createDirectExecuteXcm = function createDirectExecuteXcm(options) {
|
|
|
3473
3473
|
return addXcmVersionHeader(fullXcm, version);
|
|
3474
3474
|
};
|
|
3475
3475
|
|
|
3476
|
+
var AssetsPallet = /*#__PURE__*/function () {
|
|
3477
|
+
function AssetsPallet() {
|
|
3478
|
+
_classCallCheck(this, AssetsPallet);
|
|
3479
|
+
}
|
|
3480
|
+
return _createClass(AssetsPallet, [{
|
|
3481
|
+
key: "setBalance",
|
|
3482
|
+
value: function setBalance(address, asset, chain) {
|
|
3483
|
+
assertHasId(asset);
|
|
3484
|
+
var assetId = asset.assetId,
|
|
3485
|
+
amount = asset.amount;
|
|
3486
|
+
var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
|
|
3487
|
+
var addr = assets.isChainEvm(chain) ? address : {
|
|
3488
|
+
Id: address
|
|
3489
|
+
};
|
|
3490
|
+
return Promise.resolve({
|
|
3491
|
+
assetStatusTx: {
|
|
3492
|
+
module: 'Assets',
|
|
3493
|
+
method: 'force_asset_status',
|
|
3494
|
+
parameters: {
|
|
3495
|
+
id: id,
|
|
3496
|
+
owner: addr,
|
|
3497
|
+
issuer: addr,
|
|
3498
|
+
admin: addr,
|
|
3499
|
+
freezer: addr,
|
|
3500
|
+
min_balance: 0n,
|
|
3501
|
+
is_sufficient: true,
|
|
3502
|
+
is_frozen: false
|
|
3503
|
+
}
|
|
3504
|
+
},
|
|
3505
|
+
balanceTx: {
|
|
3506
|
+
module: 'Assets',
|
|
3507
|
+
method: 'mint',
|
|
3508
|
+
parameters: {
|
|
3509
|
+
id: id,
|
|
3510
|
+
beneficiary: addr,
|
|
3511
|
+
amount: amount
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
}]);
|
|
3517
|
+
}();
|
|
3518
|
+
|
|
3476
3519
|
// Inspired by Moonbeam XCM-SDK
|
|
3477
3520
|
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/utils/src/format/asset.ts#L1
|
|
3478
3521
|
var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
|
|
@@ -4147,7 +4190,7 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
|
4147
4190
|
};
|
|
4148
4191
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4149
4192
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
4150
|
-
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2,
|
|
4193
|
+
var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
|
|
4151
4194
|
return _regenerator().w(function (_context2) {
|
|
4152
4195
|
while (1) switch (_context2.n) {
|
|
4153
4196
|
case 0:
|
|
@@ -4227,7 +4270,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4227
4270
|
return _context2.a(2, {
|
|
4228
4271
|
fee: _fee,
|
|
4229
4272
|
feeType: 'paymentInfo',
|
|
4230
|
-
sufficient: sufficient
|
|
4273
|
+
sufficient: !assets.hasDryRunSupport(destination) ? sufficient : false
|
|
4231
4274
|
});
|
|
4232
4275
|
case 3:
|
|
4233
4276
|
_context2.n = 4;
|
|
@@ -4244,7 +4287,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4244
4287
|
case 4:
|
|
4245
4288
|
dryRunResult = _context2.v;
|
|
4246
4289
|
if (dryRunResult.success) {
|
|
4247
|
-
_context2.n =
|
|
4290
|
+
_context2.n = 7;
|
|
4248
4291
|
break;
|
|
4249
4292
|
}
|
|
4250
4293
|
if (!disableFallback) {
|
|
@@ -4259,17 +4302,13 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4259
4302
|
return calcPaymentInfoFee();
|
|
4260
4303
|
case 6:
|
|
4261
4304
|
_fee2 = _context2.v;
|
|
4262
|
-
_context2.n = 7;
|
|
4263
|
-
return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee2);
|
|
4264
|
-
case 7:
|
|
4265
|
-
_sufficient = _context2.v;
|
|
4266
4305
|
return _context2.a(2, {
|
|
4267
4306
|
fee: _fee2,
|
|
4268
4307
|
feeType: 'paymentInfo',
|
|
4269
4308
|
dryRunError: dryRunResult.failureReason,
|
|
4270
|
-
sufficient:
|
|
4309
|
+
sufficient: false
|
|
4271
4310
|
});
|
|
4272
|
-
case
|
|
4311
|
+
case 7:
|
|
4273
4312
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
4274
4313
|
return _context2.a(2, {
|
|
4275
4314
|
fee: fee,
|
|
@@ -5063,6 +5102,9 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5063
5102
|
tx: tx,
|
|
5064
5103
|
chain: origin,
|
|
5065
5104
|
address: senderAddress,
|
|
5105
|
+
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5106
|
+
amount: amount
|
|
5107
|
+
}),
|
|
5066
5108
|
feeAsset: resolvedFeeAsset
|
|
5067
5109
|
});
|
|
5068
5110
|
case 1:
|
|
@@ -5290,13 +5332,332 @@ var dryRunOrigin = /*#__PURE__*/function () {
|
|
|
5290
5332
|
};
|
|
5291
5333
|
}();
|
|
5292
5334
|
|
|
5293
|
-
var
|
|
5335
|
+
var AssetManagerPallet = /*#__PURE__*/function () {
|
|
5336
|
+
function AssetManagerPallet() {
|
|
5337
|
+
_classCallCheck(this, AssetManagerPallet);
|
|
5338
|
+
}
|
|
5339
|
+
return _createClass(AssetManagerPallet, [{
|
|
5340
|
+
key: "setBalance",
|
|
5341
|
+
value: function setBalance(address, asset) {
|
|
5342
|
+
assertHasId(asset);
|
|
5343
|
+
var assetId = asset.assetId,
|
|
5344
|
+
amount = asset.amount;
|
|
5345
|
+
return Promise.resolve({
|
|
5346
|
+
balanceTx: {
|
|
5347
|
+
module: 'AssetManager',
|
|
5348
|
+
method: 'updateBalance',
|
|
5349
|
+
parameters: {
|
|
5350
|
+
who: {
|
|
5351
|
+
Id: address
|
|
5352
|
+
},
|
|
5353
|
+
currency_id: {
|
|
5354
|
+
ForeignAsset: assetId
|
|
5355
|
+
},
|
|
5356
|
+
amount: amount
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
});
|
|
5360
|
+
}
|
|
5361
|
+
}]);
|
|
5362
|
+
}();
|
|
5363
|
+
|
|
5364
|
+
var BalancesPallet = /*#__PURE__*/function () {
|
|
5365
|
+
function BalancesPallet() {
|
|
5366
|
+
_classCallCheck(this, BalancesPallet);
|
|
5367
|
+
}
|
|
5368
|
+
return _createClass(BalancesPallet, [{
|
|
5369
|
+
key: "setBalance",
|
|
5370
|
+
value: function setBalance(address, assetInfo, chain) {
|
|
5371
|
+
var amount = assetInfo.amount;
|
|
5372
|
+
var notUseId = chain.startsWith('Hydration') || chain === 'Basilisk' || assets.isChainEvm(chain);
|
|
5373
|
+
return Promise.resolve({
|
|
5374
|
+
balanceTx: {
|
|
5375
|
+
module: 'Balances',
|
|
5376
|
+
method: 'force_set_balance',
|
|
5377
|
+
parameters: {
|
|
5378
|
+
who: notUseId ? address : {
|
|
5379
|
+
Id: address
|
|
5380
|
+
},
|
|
5381
|
+
new_free: amount
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
});
|
|
5385
|
+
}
|
|
5386
|
+
}]);
|
|
5387
|
+
}();
|
|
5388
|
+
|
|
5389
|
+
var CurrenciesPallet = /*#__PURE__*/function () {
|
|
5390
|
+
function CurrenciesPallet() {
|
|
5391
|
+
_classCallCheck(this, CurrenciesPallet);
|
|
5392
|
+
}
|
|
5393
|
+
return _createClass(CurrenciesPallet, [{
|
|
5394
|
+
key: "setBalance",
|
|
5395
|
+
value: function setBalance(address, assetInfo) {
|
|
5396
|
+
assertHasId(assetInfo);
|
|
5397
|
+
var assetId = assetInfo.assetId,
|
|
5398
|
+
amount = assetInfo.amount;
|
|
5399
|
+
return Promise.resolve({
|
|
5400
|
+
balanceTx: {
|
|
5401
|
+
module: 'Currencies',
|
|
5402
|
+
method: 'update_balance',
|
|
5403
|
+
parameters: {
|
|
5404
|
+
who: address,
|
|
5405
|
+
currency_id: Number(assetId),
|
|
5406
|
+
amount: amount
|
|
5407
|
+
}
|
|
5408
|
+
}
|
|
5409
|
+
});
|
|
5410
|
+
}
|
|
5411
|
+
}]);
|
|
5412
|
+
}();
|
|
5413
|
+
|
|
5414
|
+
var ForeignAssetsPallet = /*#__PURE__*/function () {
|
|
5415
|
+
function ForeignAssetsPallet() {
|
|
5416
|
+
_classCallCheck(this, ForeignAssetsPallet);
|
|
5417
|
+
}
|
|
5418
|
+
return _createClass(ForeignAssetsPallet, [{
|
|
5419
|
+
key: "setBalance",
|
|
5420
|
+
value: function setBalance(address, asset) {
|
|
5421
|
+
assertHasLocation(asset);
|
|
5422
|
+
var location = asset.location,
|
|
5423
|
+
amount = asset.amount;
|
|
5424
|
+
return Promise.resolve({
|
|
5425
|
+
assetStatusTx: {
|
|
5426
|
+
module: 'ForeignAssets',
|
|
5427
|
+
method: 'force_asset_status',
|
|
5428
|
+
parameters: {
|
|
5429
|
+
id: location,
|
|
5430
|
+
owner: {
|
|
5431
|
+
Id: address
|
|
5432
|
+
},
|
|
5433
|
+
issuer: {
|
|
5434
|
+
Id: address
|
|
5435
|
+
},
|
|
5436
|
+
admin: {
|
|
5437
|
+
Id: address
|
|
5438
|
+
},
|
|
5439
|
+
freezer: {
|
|
5440
|
+
Id: address
|
|
5441
|
+
},
|
|
5442
|
+
min_balance: 0n,
|
|
5443
|
+
is_sufficient: true,
|
|
5444
|
+
is_frozen: false
|
|
5445
|
+
}
|
|
5446
|
+
},
|
|
5447
|
+
balanceTx: {
|
|
5448
|
+
module: 'ForeignAssets',
|
|
5449
|
+
method: 'mint',
|
|
5450
|
+
parameters: {
|
|
5451
|
+
id: location,
|
|
5452
|
+
beneficiary: {
|
|
5453
|
+
Id: address
|
|
5454
|
+
},
|
|
5455
|
+
amount: amount
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
});
|
|
5459
|
+
}
|
|
5460
|
+
}]);
|
|
5461
|
+
}();
|
|
5462
|
+
|
|
5463
|
+
var SIZE = 32;
|
|
5464
|
+
var BALANCE_SLOT = 0;
|
|
5465
|
+
var calculateMappingSlot = function calculateMappingSlot(key) {
|
|
5466
|
+
var normalizedKey = viem.getAddress(key);
|
|
5467
|
+
var keyPadded = viem.pad(normalizedKey, {
|
|
5468
|
+
size: SIZE
|
|
5469
|
+
});
|
|
5470
|
+
var slotHex = viem.pad(viem.toHex(BALANCE_SLOT), {
|
|
5471
|
+
size: SIZE
|
|
5472
|
+
});
|
|
5473
|
+
var encoded = viem.concat([keyPadded, slotHex]);
|
|
5474
|
+
return viem.keccak256(encoded);
|
|
5475
|
+
};
|
|
5476
|
+
var SystemPallet = /*#__PURE__*/function () {
|
|
5477
|
+
function SystemPallet() {
|
|
5478
|
+
_classCallCheck(this, SystemPallet);
|
|
5479
|
+
}
|
|
5480
|
+
return _createClass(SystemPallet, [{
|
|
5481
|
+
key: "setBalance",
|
|
5482
|
+
value: function () {
|
|
5483
|
+
var _setBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(address, assetInfo, _chain, api) {
|
|
5484
|
+
var contractAddr, slot, amountEncoded, storageKey;
|
|
5485
|
+
return _regenerator().w(function (_context) {
|
|
5486
|
+
while (1) switch (_context.n) {
|
|
5487
|
+
case 0:
|
|
5488
|
+
assertHasId(assetInfo);
|
|
5489
|
+
contractAddr = formatAssetIdToERC20(assetInfo.assetId);
|
|
5490
|
+
slot = calculateMappingSlot(address);
|
|
5491
|
+
amountEncoded = viem.pad(viem.toHex(assetInfo.amount), {
|
|
5492
|
+
size: SIZE
|
|
5493
|
+
});
|
|
5494
|
+
_context.n = 1;
|
|
5495
|
+
return api.getEvmStorage(contractAddr, slot);
|
|
5496
|
+
case 1:
|
|
5497
|
+
storageKey = _context.v;
|
|
5498
|
+
return _context.a(2, {
|
|
5499
|
+
balanceTx: {
|
|
5500
|
+
module: 'System',
|
|
5501
|
+
method: 'set_storage',
|
|
5502
|
+
parameters: {
|
|
5503
|
+
items: [[storageKey, amountEncoded]]
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
});
|
|
5507
|
+
}
|
|
5508
|
+
}, _callee);
|
|
5509
|
+
}));
|
|
5510
|
+
function setBalance(_x, _x2, _x3, _x4) {
|
|
5511
|
+
return _setBalance.apply(this, arguments);
|
|
5512
|
+
}
|
|
5513
|
+
return setBalance;
|
|
5514
|
+
}()
|
|
5515
|
+
}]);
|
|
5516
|
+
}();
|
|
5517
|
+
|
|
5518
|
+
var TokensPallet = /*#__PURE__*/function () {
|
|
5519
|
+
function TokensPallet() {
|
|
5520
|
+
_classCallCheck(this, TokensPallet);
|
|
5521
|
+
}
|
|
5522
|
+
return _createClass(TokensPallet, [{
|
|
5523
|
+
key: "setBalance",
|
|
5524
|
+
value: function setBalance(address, asset, chain) {
|
|
5525
|
+
var isBifrost = chain.startsWith('Bifrost');
|
|
5526
|
+
if (!isBifrost) assertHasId(asset);
|
|
5527
|
+
var id = isBifrost ? getChain('BifrostPolkadot').getCurrencySelection(asset) : (assertHasId(asset), asset.assetId);
|
|
5528
|
+
var amount = asset.amount;
|
|
5529
|
+
return Promise.resolve({
|
|
5530
|
+
balanceTx: {
|
|
5531
|
+
module: 'Tokens',
|
|
5532
|
+
method: 'set_balance',
|
|
5533
|
+
parameters: {
|
|
5534
|
+
who: {
|
|
5535
|
+
Id: address
|
|
5536
|
+
},
|
|
5537
|
+
currency_id: id,
|
|
5538
|
+
new_free: amount,
|
|
5539
|
+
new_reserved: 0n
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5542
|
+
});
|
|
5543
|
+
}
|
|
5544
|
+
}]);
|
|
5545
|
+
}();
|
|
5546
|
+
|
|
5547
|
+
var palletRegistry = {
|
|
5548
|
+
Balances: BalancesPallet,
|
|
5549
|
+
Tokens: TokensPallet,
|
|
5550
|
+
Currencies: CurrenciesPallet,
|
|
5551
|
+
Assets: AssetsPallet,
|
|
5552
|
+
ForeignAssets: ForeignAssetsPallet,
|
|
5553
|
+
AssetManager: AssetManagerPallet,
|
|
5554
|
+
System: SystemPallet
|
|
5555
|
+
};
|
|
5556
|
+
var getPalletInstance = function getPalletInstance(type) {
|
|
5557
|
+
var HandlerClass = palletRegistry[type];
|
|
5558
|
+
return new HandlerClass();
|
|
5559
|
+
};
|
|
5560
|
+
|
|
5561
|
+
var MINT_AMOUNT = 1000n; // Mint 1000 units of asset
|
|
5562
|
+
var pickOtherPallet = function pickOtherPallet(asset, pallets) {
|
|
5563
|
+
if (assets.isForeignAsset(asset) && asset.assetId === undefined) {
|
|
5564
|
+
var _pallets$find;
|
|
5565
|
+
// No assetId means it's probably a ForeignAssets pallet asset
|
|
5566
|
+
return (_pallets$find = pallets.find(function (pallet) {
|
|
5567
|
+
return pallet.startsWith('Foreign');
|
|
5568
|
+
})) !== null && _pallets$find !== void 0 ? _pallets$find : pallets[0];
|
|
5569
|
+
}
|
|
5570
|
+
return pallets[0];
|
|
5571
|
+
};
|
|
5572
|
+
var createMintTxs = function createMintTxs(chain, asset, address, api) {
|
|
5573
|
+
var nativePallet = pallets.getNativeAssetsPallet(chain);
|
|
5574
|
+
var otherPallets = pallets.getOtherAssetsPallets(chain);
|
|
5575
|
+
var isMainNativeAsset = assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(chain));
|
|
5576
|
+
var pallet = assets.isForeignAsset(asset) || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
5577
|
+
var palletInstance = getPalletInstance(pallet);
|
|
5578
|
+
return palletInstance.setBalance(address, asset, chain, api);
|
|
5579
|
+
};
|
|
5580
|
+
var createRequiredMintTxs = function createRequiredMintTxs(chain, currency, amountHuman, address, api) {
|
|
5581
|
+
var asset = assets.findAssetInfoOrThrow(chain, currency, null);
|
|
5582
|
+
var amount = viem.parseUnits(amountHuman.toString(), asset.decimals);
|
|
5583
|
+
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5584
|
+
amount: amount
|
|
5585
|
+
}), address, api);
|
|
5586
|
+
};
|
|
5587
|
+
var createOptionalMintTxs = function createOptionalMintTxs(chain, currency, amountHuman, address, api) {
|
|
5588
|
+
var asset = assets.findAssetInfo(chain, currency, null);
|
|
5589
|
+
if (!asset) return null;
|
|
5590
|
+
var amount = viem.parseUnits(amountHuman.toString(), asset.decimals);
|
|
5591
|
+
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5592
|
+
amount: amount
|
|
5593
|
+
}), address, api);
|
|
5594
|
+
};
|
|
5595
|
+
var resultToExtrinsics = function resultToExtrinsics(api, address, _ref) {
|
|
5596
|
+
var assetStatusTx = _ref.assetStatusTx,
|
|
5597
|
+
balanceTx = _ref.balanceTx;
|
|
5598
|
+
return [].concat(_toConsumableArray(assetStatusTx ? [api.callTxMethod(assetStatusTx)] : []), _toConsumableArray(assetStatusTx ? [api.callDispatchAsMethod(api.callTxMethod(balanceTx), address)] : [api.callTxMethod(balanceTx)]));
|
|
5599
|
+
};
|
|
5600
|
+
var wrapTxBypass = /*#__PURE__*/function () {
|
|
5601
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, chain, asset, feeAsset, address, tx) {
|
|
5602
|
+
var mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes, amount, mintAmount, mintAssetRes;
|
|
5603
|
+
return _regenerator().w(function (_context) {
|
|
5604
|
+
while (1) switch (_context.n) {
|
|
5605
|
+
case 0:
|
|
5606
|
+
_context.n = 1;
|
|
5607
|
+
return createRequiredMintTxs(chain, {
|
|
5608
|
+
symbol: assets.Native(assets.getNativeAssetSymbol(chain))
|
|
5609
|
+
}, MINT_AMOUNT, address, api);
|
|
5610
|
+
case 1:
|
|
5611
|
+
mintNativeAssetRes = _context.v;
|
|
5612
|
+
_context.n = 2;
|
|
5613
|
+
return createOptionalMintTxs(chain, {
|
|
5614
|
+
location: {
|
|
5615
|
+
parents: sdkCommon.Parents.ONE,
|
|
5616
|
+
interior: {
|
|
5617
|
+
Here: null
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
}, MINT_AMOUNT, address, api);
|
|
5621
|
+
case 2:
|
|
5622
|
+
mintRelayAssetRes = _context.v;
|
|
5623
|
+
if (!feeAsset) {
|
|
5624
|
+
_context.n = 4;
|
|
5625
|
+
break;
|
|
5626
|
+
}
|
|
5627
|
+
amount = viem.parseUnits(MINT_AMOUNT.toString(), feeAsset.decimals);
|
|
5628
|
+
_context.n = 3;
|
|
5629
|
+
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, feeAsset), {}, {
|
|
5630
|
+
amount: amount
|
|
5631
|
+
}), address, api);
|
|
5632
|
+
case 3:
|
|
5633
|
+
mintFeeAssetRes = _context.v;
|
|
5634
|
+
case 4:
|
|
5635
|
+
// mint asset that is being sent
|
|
5636
|
+
mintAmount = viem.parseUnits(MINT_AMOUNT.toString(), asset.decimals);
|
|
5637
|
+
_context.n = 5;
|
|
5638
|
+
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5639
|
+
amount: asset.amount + mintAmount
|
|
5640
|
+
}), address, api);
|
|
5641
|
+
case 5:
|
|
5642
|
+
mintAssetRes = _context.v;
|
|
5643
|
+
return _context.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes, mintAssetRes].flatMap(function (tx) {
|
|
5644
|
+
return tx ? resultToExtrinsics(api, address, tx) : [];
|
|
5645
|
+
})), [api.callDispatchAsMethod(tx, address)]), exports.BatchMode.BATCH_ALL));
|
|
5646
|
+
}
|
|
5647
|
+
}, _callee);
|
|
5648
|
+
}));
|
|
5649
|
+
return function wrapTxBypass(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
5650
|
+
return _ref2.apply(this, arguments);
|
|
5651
|
+
};
|
|
5652
|
+
}();
|
|
5653
|
+
|
|
5654
|
+
var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
5294
5655
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
5295
|
-
var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, asset, amount, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee,
|
|
5656
|
+
var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, _ref$useRootOrigin, useRootOrigin, asset, amount, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, fee, forwardedXcms, destParaId, weight, currencySymbol;
|
|
5296
5657
|
return _regenerator().w(function (_context) {
|
|
5297
5658
|
while (1) switch (_context.n) {
|
|
5298
5659
|
case 0:
|
|
5299
|
-
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency;
|
|
5660
|
+
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency, _ref$useRootOrigin = _ref.useRootOrigin, useRootOrigin = _ref$useRootOrigin === void 0 ? false : _ref$useRootOrigin;
|
|
5300
5661
|
asset = assets.findAssetInfoOrThrow(origin, currency, destination);
|
|
5301
5662
|
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
5302
5663
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
@@ -5331,12 +5692,17 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5331
5692
|
tx: tx,
|
|
5332
5693
|
chain: origin,
|
|
5333
5694
|
address: senderAddress,
|
|
5334
|
-
|
|
5695
|
+
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5696
|
+
amount: amount
|
|
5697
|
+
}),
|
|
5698
|
+
feeAsset: resolvedFeeAsset,
|
|
5699
|
+
// Force dryRun pass
|
|
5700
|
+
useRootOrigin: useRootOrigin
|
|
5335
5701
|
});
|
|
5336
5702
|
case 5:
|
|
5337
5703
|
dryRunResult = _context.v;
|
|
5338
5704
|
if (dryRunResult.success) {
|
|
5339
|
-
_context.n =
|
|
5705
|
+
_context.n = 8;
|
|
5340
5706
|
break;
|
|
5341
5707
|
}
|
|
5342
5708
|
if (!disableFallback) {
|
|
@@ -5352,20 +5718,14 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5352
5718
|
case 7:
|
|
5353
5719
|
_rawFee = _context.v;
|
|
5354
5720
|
_paddedFee = padFee(_rawFee, origin, destination, 'origin');
|
|
5355
|
-
_context.n = 8;
|
|
5356
|
-
return isSufficientOrigin(api, origin, destination, senderAddress, _paddedFee, _objectSpread2(_objectSpread2({}, currency), {}, {
|
|
5357
|
-
amount: amount
|
|
5358
|
-
}), asset, resolvedFeeAsset);
|
|
5359
|
-
case 8:
|
|
5360
|
-
_sufficient = _context.v;
|
|
5361
5721
|
return _context.a(2, {
|
|
5362
5722
|
fee: _paddedFee,
|
|
5363
5723
|
currency: nativeAssetSymbol,
|
|
5364
5724
|
feeType: 'paymentInfo',
|
|
5365
5725
|
dryRunError: dryRunResult.failureReason,
|
|
5366
|
-
sufficient:
|
|
5726
|
+
sufficient: false
|
|
5367
5727
|
});
|
|
5368
|
-
case
|
|
5728
|
+
case 8:
|
|
5369
5729
|
fee = dryRunResult.fee, forwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId, weight = dryRunResult.weight;
|
|
5370
5730
|
currencySymbol = resolvedFeeAsset ? resolvedFeeAsset.symbol : nativeAssetSymbol;
|
|
5371
5731
|
return _context.a(2, {
|
|
@@ -5380,11 +5740,40 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5380
5740
|
}
|
|
5381
5741
|
}, _callee);
|
|
5382
5742
|
}));
|
|
5383
|
-
return function
|
|
5743
|
+
return function getOriginXcmFeeInternal(_x) {
|
|
5384
5744
|
return _ref2.apply(this, arguments);
|
|
5385
5745
|
};
|
|
5386
5746
|
}();
|
|
5387
5747
|
|
|
5748
|
+
var getOriginXcmFee = /*#__PURE__*/function () {
|
|
5749
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
5750
|
+
var forced, real;
|
|
5751
|
+
return _regenerator().w(function (_context) {
|
|
5752
|
+
while (1) switch (_context.n) {
|
|
5753
|
+
case 0:
|
|
5754
|
+
_context.n = 1;
|
|
5755
|
+
return getOriginXcmFeeInternal(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
5756
|
+
useRootOrigin: true
|
|
5757
|
+
}));
|
|
5758
|
+
case 1:
|
|
5759
|
+
forced = _context.v;
|
|
5760
|
+
_context.n = 2;
|
|
5761
|
+
return getOriginXcmFeeInternal(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
5762
|
+
useRootOrigin: false
|
|
5763
|
+
}));
|
|
5764
|
+
case 2:
|
|
5765
|
+
real = _context.v;
|
|
5766
|
+
return _context.a(2, _objectSpread2(_objectSpread2({}, forced), {}, {
|
|
5767
|
+
sufficient: real.sufficient
|
|
5768
|
+
}));
|
|
5769
|
+
}
|
|
5770
|
+
}, _callee);
|
|
5771
|
+
}));
|
|
5772
|
+
return function getOriginXcmFee(_x) {
|
|
5773
|
+
return _ref.apply(this, arguments);
|
|
5774
|
+
};
|
|
5775
|
+
}();
|
|
5776
|
+
|
|
5388
5777
|
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
5389
5778
|
return assetCheckEnabled ? assets.findAssetInfo(origin, currency, !sdkCommon.isTLocation(destination) ? destination : null) : null;
|
|
5390
5779
|
};
|
|
@@ -5626,8 +6015,8 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
|
|
|
5626
6015
|
}
|
|
5627
6016
|
return {};
|
|
5628
6017
|
};
|
|
5629
|
-
var
|
|
5630
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
6018
|
+
var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
6019
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref, useRootOrigin) {
|
|
5631
6020
|
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, asset, amount, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason;
|
|
5632
6021
|
return _regenerator().w(function (_context2) {
|
|
5633
6022
|
while (1) switch (_context2.p = _context2.n) {
|
|
@@ -5636,7 +6025,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5636
6025
|
asset = assets.findAssetInfoOrThrow(origin, currency, destination);
|
|
5637
6026
|
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
5638
6027
|
_context2.n = 1;
|
|
5639
|
-
return
|
|
6028
|
+
return getOriginXcmFeeInternal({
|
|
5640
6029
|
api: api,
|
|
5641
6030
|
tx: tx,
|
|
5642
6031
|
origin: origin,
|
|
@@ -5644,7 +6033,8 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5644
6033
|
senderAddress: senderAddress,
|
|
5645
6034
|
feeAsset: feeAsset,
|
|
5646
6035
|
currency: currency,
|
|
5647
|
-
disableFallback: disableFallback
|
|
6036
|
+
disableFallback: disableFallback,
|
|
6037
|
+
useRootOrigin: useRootOrigin
|
|
5648
6038
|
});
|
|
5649
6039
|
case 1:
|
|
5650
6040
|
_yield$getOriginXcmFe = _context2.v;
|
|
@@ -5690,13 +6080,12 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5690
6080
|
case 5:
|
|
5691
6081
|
destFeeRes = _context2.v;
|
|
5692
6082
|
_result = {
|
|
5693
|
-
origin: _objectSpread2(_objectSpread2(_objectSpread2(
|
|
6083
|
+
origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
|
|
5694
6084
|
fee: originFee
|
|
5695
6085
|
}), originFeeType && {
|
|
5696
6086
|
feeType: originFeeType
|
|
5697
|
-
}), sufficientOriginFee !== undefined && {
|
|
5698
|
-
sufficient: sufficientOriginFee
|
|
5699
6087
|
}), {}, {
|
|
6088
|
+
sufficient: sufficientOriginFee,
|
|
5700
6089
|
currency: originCurrency
|
|
5701
6090
|
}, originDryRunError && {
|
|
5702
6091
|
dryRunError: originDryRunError
|
|
@@ -5773,7 +6162,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5773
6162
|
}
|
|
5774
6163
|
}, _callee);
|
|
5775
6164
|
}));
|
|
5776
|
-
return function processHop(
|
|
6165
|
+
return function processHop(_x3) {
|
|
5777
6166
|
return _ref3.apply(this, arguments);
|
|
5778
6167
|
};
|
|
5779
6168
|
}();
|
|
@@ -5939,11 +6328,59 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
5939
6328
|
}
|
|
5940
6329
|
}, _callee2, null, [[3,, 6, 8]]);
|
|
5941
6330
|
}));
|
|
5942
|
-
return function
|
|
6331
|
+
return function getXcmFeeInternal(_x, _x2) {
|
|
5943
6332
|
return _ref2.apply(this, arguments);
|
|
5944
6333
|
};
|
|
5945
6334
|
}();
|
|
5946
6335
|
|
|
6336
|
+
var getXcmFee = /*#__PURE__*/function () {
|
|
6337
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
6338
|
+
var _real$assetHub, _real$bridgeHub;
|
|
6339
|
+
var forced, real;
|
|
6340
|
+
return _regenerator().w(function (_context) {
|
|
6341
|
+
while (1) switch (_context.n) {
|
|
6342
|
+
case 0:
|
|
6343
|
+
_context.n = 1;
|
|
6344
|
+
return getXcmFeeInternal(options, true);
|
|
6345
|
+
case 1:
|
|
6346
|
+
forced = _context.v;
|
|
6347
|
+
_context.n = 2;
|
|
6348
|
+
return getXcmFeeInternal(options, false);
|
|
6349
|
+
case 2:
|
|
6350
|
+
real = _context.v;
|
|
6351
|
+
return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, forced), {}, {
|
|
6352
|
+
origin: _objectSpread2(_objectSpread2({}, forced.origin), {}, {
|
|
6353
|
+
sufficient: real.origin.sufficient
|
|
6354
|
+
}),
|
|
6355
|
+
destination: _objectSpread2(_objectSpread2({}, forced.destination), {}, {
|
|
6356
|
+
sufficient: real.destination.sufficient
|
|
6357
|
+
})
|
|
6358
|
+
}, forced.assetHub ? {
|
|
6359
|
+
assetHub: _objectSpread2(_objectSpread2({}, forced.assetHub), {}, {
|
|
6360
|
+
sufficient: (_real$assetHub = real.assetHub) === null || _real$assetHub === void 0 ? void 0 : _real$assetHub.sufficient
|
|
6361
|
+
})
|
|
6362
|
+
} : {}), forced.bridgeHub ? {
|
|
6363
|
+
bridgeHub: _objectSpread2(_objectSpread2({}, forced.bridgeHub), {}, {
|
|
6364
|
+
sufficient: (_real$bridgeHub = real.bridgeHub) === null || _real$bridgeHub === void 0 ? void 0 : _real$bridgeHub.sufficient
|
|
6365
|
+
})
|
|
6366
|
+
} : {}), {}, {
|
|
6367
|
+
hops: forced.hops.map(function (hop, index) {
|
|
6368
|
+
var _real$hops$index;
|
|
6369
|
+
return _objectSpread2(_objectSpread2({}, hop), {}, {
|
|
6370
|
+
result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
|
|
6371
|
+
sufficient: (_real$hops$index = real.hops[index]) === null || _real$hops$index === void 0 ? void 0 : _real$hops$index.result.sufficient
|
|
6372
|
+
})
|
|
6373
|
+
});
|
|
6374
|
+
})
|
|
6375
|
+
}));
|
|
6376
|
+
}
|
|
6377
|
+
}, _callee);
|
|
6378
|
+
}));
|
|
6379
|
+
return function getXcmFee(_x) {
|
|
6380
|
+
return _ref.apply(this, arguments);
|
|
6381
|
+
};
|
|
6382
|
+
}();
|
|
6383
|
+
|
|
5947
6384
|
var BRIDGE_FEE_DOT = 682395810n; // 0.068239581 DOT
|
|
5948
6385
|
var BRIDGE_FEE_KSM = 12016807000n; // 0.012016807 KSM
|
|
5949
6386
|
var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
@@ -6519,7 +6956,7 @@ var attemptDryRunFee = /*#__PURE__*/function () {
|
|
|
6519
6956
|
modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
|
|
6520
6957
|
amount: padFeeBy(BigInt(currency.amount), -percentage)
|
|
6521
6958
|
}));
|
|
6522
|
-
_t =
|
|
6959
|
+
_t = getOriginXcmFeeInternal;
|
|
6523
6960
|
_t2 = _objectSpread2;
|
|
6524
6961
|
_t3 = _objectSpread2({}, options);
|
|
6525
6962
|
_t4 = {};
|
|
@@ -10636,7 +11073,7 @@ var Moonbeam = /*#__PURE__*/function (_Parachain) {
|
|
|
10636
11073
|
case 3:
|
|
10637
11074
|
location = this.getLocation(assetInfo, scenario);
|
|
10638
11075
|
return _context.a(2, transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
|
|
10639
|
-
asset: createAsset(version, assetInfo.amount, location)
|
|
11076
|
+
asset: createAsset(version, assetInfo.amount, localizeLocation(this.chain, location))
|
|
10640
11077
|
}), 'transfer_assets', 'Unlimited'));
|
|
10641
11078
|
}
|
|
10642
11079
|
}, _callee, this);
|
|
@@ -12371,6 +12808,7 @@ var Builder = function Builder(api) {
|
|
|
12371
12808
|
};
|
|
12372
12809
|
|
|
12373
12810
|
exports.AssetClaimBuilder = AssetClaimBuilder;
|
|
12811
|
+
exports.AssetsPallet = AssetsPallet;
|
|
12374
12812
|
exports.BridgeHaltedError = BridgeHaltedError;
|
|
12375
12813
|
exports.Builder = Builder;
|
|
12376
12814
|
exports.ChainNotSupportedError = ChainNotSupportedError;
|
|
@@ -12436,6 +12874,7 @@ exports.getOriginFeeDetails = getOriginFeeDetails;
|
|
|
12436
12874
|
exports.getOriginFeeDetailsInternal = getOriginFeeDetailsInternal;
|
|
12437
12875
|
exports.getOriginXcmFee = getOriginXcmFee;
|
|
12438
12876
|
exports.getOriginXcmFeeEstimate = getOriginXcmFeeEstimate;
|
|
12877
|
+
exports.getOriginXcmFeeInternal = getOriginXcmFeeInternal;
|
|
12439
12878
|
exports.getParaEthTransferFees = getParaEthTransferFees;
|
|
12440
12879
|
exports.getParaId = getParaId;
|
|
12441
12880
|
exports.getRelayChainOf = getRelayChainOf;
|
|
@@ -12465,6 +12904,7 @@ exports.transferRelayToPara = transferRelayToPara;
|
|
|
12465
12904
|
exports.traverseXcmHops = traverseXcmHops;
|
|
12466
12905
|
exports.validateAddress = validateAddress;
|
|
12467
12906
|
exports.verifyEdOnDestination = verifyEdOnDestination;
|
|
12907
|
+
exports.wrapTxBypass = wrapTxBypass;
|
|
12468
12908
|
Object.keys(assets).forEach(function (k) {
|
|
12469
12909
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
12470
12910
|
enumerable: true,
|