@paraspell/sdk-core 10.4.2 → 10.4.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/dist/index.cjs +171 -117
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +171 -117
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -6707,6 +6707,22 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6707
6707
|
}]);
|
|
6708
6708
|
}(ParachainNode);
|
|
6709
6709
|
|
|
6710
|
+
var createExecuteCall = function createExecuteCall(
|
|
6711
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6712
|
+
xcm, maxWeight) {
|
|
6713
|
+
return {
|
|
6714
|
+
module: 'PolkadotXcm',
|
|
6715
|
+
method: 'execute',
|
|
6716
|
+
parameters: {
|
|
6717
|
+
message: xcm,
|
|
6718
|
+
max_weight: {
|
|
6719
|
+
ref_time: maxWeight.refTime,
|
|
6720
|
+
proof_size: maxWeight.proofSize
|
|
6721
|
+
}
|
|
6722
|
+
}
|
|
6723
|
+
};
|
|
6724
|
+
};
|
|
6725
|
+
|
|
6710
6726
|
var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight, originExecutionFee, destExecutionFee) {
|
|
6711
6727
|
var api = input.api,
|
|
6712
6728
|
_input$version = input.version,
|
|
@@ -6804,15 +6820,15 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight,
|
|
|
6804
6820
|
return api.callTxMethod(call);
|
|
6805
6821
|
};
|
|
6806
6822
|
|
|
6807
|
-
var createExecuteXcm = function createExecuteXcm(input,
|
|
6823
|
+
var createExecuteXcm = function createExecuteXcm(input, executionFee, version) {
|
|
6824
|
+
var _feeAsset$multiLocati;
|
|
6808
6825
|
var api = input.api,
|
|
6809
|
-
_input$version = input.version,
|
|
6810
|
-
version = _input$version === void 0 ? exports.Version.V4 : _input$version,
|
|
6811
6826
|
asset = input.asset,
|
|
6812
6827
|
scenario = input.scenario,
|
|
6813
6828
|
destination = input.destination,
|
|
6814
6829
|
paraIdTo = input.paraIdTo,
|
|
6815
|
-
address = input.address
|
|
6830
|
+
address = input.address,
|
|
6831
|
+
feeAsset = input.feeAsset;
|
|
6816
6832
|
var dest = createDestination(scenario, version, destination, paraIdTo);
|
|
6817
6833
|
var beneficiary = createBeneficiary({
|
|
6818
6834
|
api: api,
|
|
@@ -6822,77 +6838,74 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
|
|
|
6822
6838
|
version: version,
|
|
6823
6839
|
paraId: paraIdTo
|
|
6824
6840
|
});
|
|
6825
|
-
if (!asset.multiLocation) {
|
|
6826
|
-
throw new
|
|
6841
|
+
if (!asset.multiLocation || feeAsset && !feeAsset.multiLocation) {
|
|
6842
|
+
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6827
6843
|
}
|
|
6828
|
-
var
|
|
6844
|
+
var assetML = transformMultiLocation(asset.multiLocation);
|
|
6845
|
+
var feeML = transformMultiLocation((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : asset.multiLocation);
|
|
6846
|
+
var sameFeeAsset = feeAsset && assets.isAssetEqual(asset, feeAsset);
|
|
6829
6847
|
var amountWithoutFee = BigInt(asset.amount) - executionFee;
|
|
6830
|
-
var
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6848
|
+
var xcm = [{
|
|
6849
|
+
WithdrawAsset: [{
|
|
6850
|
+
id: assetML,
|
|
6851
|
+
fun: {
|
|
6852
|
+
Fungible: BigInt(asset.amount)
|
|
6853
|
+
}
|
|
6854
|
+
}].concat(_toConsumableArray(!sameFeeAsset && feeAsset !== null && feeAsset !== void 0 && feeAsset.multiLocation ? [{
|
|
6855
|
+
id: transformMultiLocation(feeAsset.multiLocation),
|
|
6856
|
+
fun: {
|
|
6857
|
+
Fungible: executionFee
|
|
6858
|
+
}
|
|
6859
|
+
}] : []))
|
|
6860
|
+
}, {
|
|
6861
|
+
BuyExecution: {
|
|
6862
|
+
fees: {
|
|
6863
|
+
id: feeML,
|
|
6864
|
+
fun: {
|
|
6865
|
+
Fungible: executionFee
|
|
6866
|
+
}
|
|
6867
|
+
},
|
|
6868
|
+
weight_limit: {
|
|
6869
|
+
Limited: {
|
|
6870
|
+
ref_time: 150n,
|
|
6871
|
+
proof_size: 0n
|
|
6872
|
+
}
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6875
|
+
}, {
|
|
6876
|
+
DepositReserveAsset: {
|
|
6877
|
+
assets: {
|
|
6878
|
+
Definite: [{
|
|
6879
|
+
id: assetML,
|
|
6837
6880
|
fun: {
|
|
6838
|
-
Fungible: BigInt(asset.amount)
|
|
6881
|
+
Fungible: sameFeeAsset ? amountWithoutFee : BigInt(asset.amount)
|
|
6839
6882
|
}
|
|
6840
6883
|
}]
|
|
6841
|
-
},
|
|
6884
|
+
},
|
|
6885
|
+
dest: dest,
|
|
6886
|
+
xcm: [{
|
|
6842
6887
|
BuyExecution: {
|
|
6843
6888
|
fees: {
|
|
6844
|
-
id:
|
|
6889
|
+
id: asset.multiLocation,
|
|
6845
6890
|
fun: {
|
|
6846
|
-
Fungible: executionFee
|
|
6891
|
+
Fungible: sameFeeAsset ? amountWithoutFee - executionFee : BigInt(asset.amount)
|
|
6847
6892
|
}
|
|
6848
6893
|
},
|
|
6849
|
-
weight_limit:
|
|
6850
|
-
Limited: {
|
|
6851
|
-
ref_time: 150n,
|
|
6852
|
-
proof_size: 0n
|
|
6853
|
-
}
|
|
6854
|
-
}
|
|
6894
|
+
weight_limit: 'Unlimited'
|
|
6855
6895
|
}
|
|
6856
6896
|
}, {
|
|
6857
|
-
|
|
6897
|
+
DepositAsset: {
|
|
6858
6898
|
assets: {
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
fun: {
|
|
6862
|
-
Fungible: amountWithoutFee
|
|
6863
|
-
}
|
|
6864
|
-
}]
|
|
6865
|
-
},
|
|
6866
|
-
dest: dest,
|
|
6867
|
-
xcm: [{
|
|
6868
|
-
BuyExecution: {
|
|
6869
|
-
fees: {
|
|
6870
|
-
id: asset.multiLocation,
|
|
6871
|
-
fun: {
|
|
6872
|
-
Fungible: amountWithoutFee - executionFee
|
|
6873
|
-
}
|
|
6874
|
-
},
|
|
6875
|
-
weight_limit: 'Unlimited'
|
|
6876
|
-
}
|
|
6877
|
-
}, {
|
|
6878
|
-
DepositAsset: {
|
|
6879
|
-
assets: {
|
|
6880
|
-
Wild: {
|
|
6881
|
-
AllCounted: 1
|
|
6882
|
-
}
|
|
6883
|
-
},
|
|
6884
|
-
beneficiary: beneficiary
|
|
6899
|
+
Wild: {
|
|
6900
|
+
AllCounted: 1
|
|
6885
6901
|
}
|
|
6886
|
-
}
|
|
6902
|
+
},
|
|
6903
|
+
beneficiary: beneficiary
|
|
6887
6904
|
}
|
|
6888
|
-
}]
|
|
6889
|
-
max_weight: {
|
|
6890
|
-
ref_time: weight.refTime,
|
|
6891
|
-
proof_size: weight.proofSize
|
|
6892
|
-
}
|
|
6905
|
+
}]
|
|
6893
6906
|
}
|
|
6894
|
-
};
|
|
6895
|
-
return
|
|
6907
|
+
}];
|
|
6908
|
+
return addXcmVersionHeader(xcm, version);
|
|
6896
6909
|
};
|
|
6897
6910
|
|
|
6898
6911
|
var handleToAhTeleport = /*#__PURE__*/function () {
|
|
@@ -7254,11 +7267,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7254
7267
|
key: "handleExecuteTransfer",
|
|
7255
7268
|
value: function () {
|
|
7256
7269
|
var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
|
|
7257
|
-
var api, senderAddress, asset, feeAsset, decimals, multiplier, base, scaledMultiplier, MIN_FEE,
|
|
7270
|
+
var api, senderAddress, asset, feeAsset, _input$version4, version, decimals, multiplier, base, scaledMultiplier, MIN_FEE, call, dryRunResult, paddedFee, xcm, weight;
|
|
7258
7271
|
return _regenerator().w(function (_context3) {
|
|
7259
7272
|
while (1) switch (_context3.n) {
|
|
7260
7273
|
case 0:
|
|
7261
|
-
api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset;
|
|
7274
|
+
api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset, _input$version4 = input.version, version = _input$version4 === void 0 ? exports.Version.V4 : _input$version4;
|
|
7262
7275
|
if (senderAddress) {
|
|
7263
7276
|
_context3.n = 1;
|
|
7264
7277
|
break;
|
|
@@ -7271,11 +7284,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7271
7284
|
base = BigInt(Math.pow(10, decimals));
|
|
7272
7285
|
scaledMultiplier = BigInt(Math.floor(multiplier * Math.pow(10, decimals)));
|
|
7273
7286
|
MIN_FEE = base * scaledMultiplier / BigInt(Math.pow(10, decimals));
|
|
7274
|
-
|
|
7287
|
+
call = createExecuteCall(createExecuteXcm(input, MIN_FEE, version), MAX_WEIGHT);
|
|
7275
7288
|
_context3.n = 2;
|
|
7276
7289
|
return api.getDryRunCall({
|
|
7277
7290
|
node: this.node,
|
|
7278
|
-
tx:
|
|
7291
|
+
tx: api.callTxMethod(call),
|
|
7279
7292
|
address: senderAddress,
|
|
7280
7293
|
isFeeAsset: !!feeAsset
|
|
7281
7294
|
});
|
|
@@ -7287,14 +7300,13 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7287
7300
|
}
|
|
7288
7301
|
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
7289
7302
|
case 3:
|
|
7290
|
-
if (dryRunResult.weight) {
|
|
7291
|
-
_context3.n = 4;
|
|
7292
|
-
break;
|
|
7293
|
-
}
|
|
7294
|
-
throw new DryRunFailedError('weight not found');
|
|
7295
|
-
case 4:
|
|
7296
7303
|
paddedFee = dryRunResult.fee * 120n / 100n;
|
|
7297
|
-
|
|
7304
|
+
xcm = createExecuteXcm(input, paddedFee, version);
|
|
7305
|
+
_context3.n = 4;
|
|
7306
|
+
return api.getXcmWeight(xcm);
|
|
7307
|
+
case 4:
|
|
7308
|
+
weight = _context3.v;
|
|
7309
|
+
return _context3.a(2, createExecuteCall(createExecuteXcm(input, paddedFee, version), weight));
|
|
7298
7310
|
}
|
|
7299
7311
|
}, _callee3, this);
|
|
7300
7312
|
}));
|
|
@@ -7305,54 +7317,96 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7305
7317
|
}()
|
|
7306
7318
|
}, {
|
|
7307
7319
|
key: "transferPolkadotXCM",
|
|
7308
|
-
value: function
|
|
7309
|
-
var
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7320
|
+
value: function () {
|
|
7321
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(input) {
|
|
7322
|
+
var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
|
|
7323
|
+
return _regenerator().w(function (_context4) {
|
|
7324
|
+
while (1) switch (_context4.n) {
|
|
7325
|
+
case 0:
|
|
7326
|
+
api = input.api, scenario = input.scenario, asset = input.asset, destination = input.destination, feeAsset = input.feeAsset, overriddenAsset = input.overriddenAsset;
|
|
7327
|
+
if (!feeAsset) {
|
|
7328
|
+
_context4.n = 4;
|
|
7329
|
+
break;
|
|
7330
|
+
}
|
|
7331
|
+
if (!overriddenAsset) {
|
|
7332
|
+
_context4.n = 1;
|
|
7333
|
+
break;
|
|
7334
|
+
}
|
|
7335
|
+
throw new assets.InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
|
|
7336
|
+
case 1:
|
|
7337
|
+
if (!(assets.normalizeSymbol(asset.symbol) === assets.normalizeSymbol('KSM'))) {
|
|
7338
|
+
_context4.n = 2;
|
|
7339
|
+
break;
|
|
7340
|
+
}
|
|
7341
|
+
return _context4.a(2, this.handleLocalReserveTransfer(input));
|
|
7342
|
+
case 2:
|
|
7343
|
+
isNativeAsset = asset.symbol === this.getNativeAssetSymbol();
|
|
7344
|
+
if (isNativeAsset) {
|
|
7345
|
+
_context4.n = 4;
|
|
7346
|
+
break;
|
|
7347
|
+
}
|
|
7348
|
+
_t = api;
|
|
7349
|
+
_context4.n = 3;
|
|
7350
|
+
return this.handleExecuteTransfer(input);
|
|
7351
|
+
case 3:
|
|
7352
|
+
_t2 = _context4.v;
|
|
7353
|
+
return _context4.a(2, _t.callTxMethod.call(_t, _t2));
|
|
7354
|
+
case 4:
|
|
7355
|
+
if (!(destination === 'AssetHubKusama')) {
|
|
7356
|
+
_context4.n = 5;
|
|
7357
|
+
break;
|
|
7358
|
+
}
|
|
7359
|
+
return _context4.a(2, this.handleBridgeTransfer(input, 'Kusama'));
|
|
7360
|
+
case 5:
|
|
7361
|
+
if (!(destination === 'Ethereum')) {
|
|
7362
|
+
_context4.n = 6;
|
|
7363
|
+
break;
|
|
7364
|
+
}
|
|
7365
|
+
return _context4.a(2, this.handleEthBridgeTransfer(input));
|
|
7366
|
+
case 6:
|
|
7367
|
+
if (!(destination === 'Mythos')) {
|
|
7368
|
+
_context4.n = 7;
|
|
7369
|
+
break;
|
|
7370
|
+
}
|
|
7371
|
+
return _context4.a(2, this.handleMythosTransfer(input));
|
|
7372
|
+
case 7:
|
|
7373
|
+
isEthereumAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
|
|
7374
|
+
if (!(destination === 'BifrostPolkadot' && isEthereumAsset)) {
|
|
7375
|
+
_context4.n = 8;
|
|
7376
|
+
break;
|
|
7377
|
+
}
|
|
7378
|
+
return _context4.a(2, this.handleLocalReserveTransfer(input));
|
|
7379
|
+
case 8:
|
|
7380
|
+
if (!isEthereumAsset) {
|
|
7381
|
+
_context4.n = 9;
|
|
7382
|
+
break;
|
|
7383
|
+
}
|
|
7384
|
+
return _context4.a(2, this.handleLocalReserveTransfer(input, true));
|
|
7385
|
+
case 9:
|
|
7386
|
+
isSystemNode = !sdkCommon.isTMultiLocation(destination) && SYSTEM_NODES_POLKADOT.includes(destination);
|
|
7387
|
+
if (!(scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset) && destination !== 'Hydration' && destination !== 'Polimec' && destination !== 'Moonbeam' && destination !== 'BifrostPolkadot' && destination !== 'PeoplePolkadot' && destination !== 'Ajuna' && !isSystemNode)) {
|
|
7388
|
+
_context4.n = 10;
|
|
7389
|
+
break;
|
|
7390
|
+
}
|
|
7391
|
+
throw new ScenarioNotSupportedError(this.node, scenario, 'Some Parachains do not have a reserve for DOT on AssetHub. This can also include multihop transfers that have AssetHub as a hop chain and the call contains DOT. Chains that do not have a DOT reserve on AssetHub are not allowed to transfer DOT to it or through it because this transfer will result in asset loss.');
|
|
7392
|
+
case 10:
|
|
7393
|
+
if (!(scenario === 'ParaToPara' && asset.symbol === 'KSM' && !assets.isForeignAsset(asset))) {
|
|
7394
|
+
_context4.n = 11;
|
|
7395
|
+
break;
|
|
7396
|
+
}
|
|
7397
|
+
throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
|
|
7398
|
+
case 11:
|
|
7399
|
+
method = this.getMethod(scenario, destination);
|
|
7400
|
+
modifiedInput = this.patchInput(input);
|
|
7401
|
+
return _context4.a(2, PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, method, 'Unlimited'));
|
|
7402
|
+
}
|
|
7403
|
+
}, _callee4, this);
|
|
7404
|
+
}));
|
|
7405
|
+
function transferPolkadotXCM(_x4) {
|
|
7406
|
+
return _transferPolkadotXCM.apply(this, arguments);
|
|
7351
7407
|
}
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, method, 'Unlimited'));
|
|
7355
|
-
}
|
|
7408
|
+
return transferPolkadotXCM;
|
|
7409
|
+
}()
|
|
7356
7410
|
}, {
|
|
7357
7411
|
key: "getRelayToParaOverrides",
|
|
7358
7412
|
value: function getRelayToParaOverrides() {
|
package/dist/index.d.ts
CHANGED
|
@@ -938,6 +938,7 @@ interface IPolkadotApi<TApi, TRes> {
|
|
|
938
938
|
getMethod(tx: TRes): string;
|
|
939
939
|
calculateTransactionFee(tx: TRes, address: string): Promise<bigint>;
|
|
940
940
|
quoteAhPrice(fromMl: TMultiLocation, toMl: TMultiLocation, amountIn: bigint, includeFee?: boolean): Promise<bigint | undefined>;
|
|
941
|
+
getXcmWeight(xcm: any): Promise<TWeight>;
|
|
941
942
|
getBalanceNative(address: string): Promise<bigint>;
|
|
942
943
|
getBalanceNativeAcala(address: string, symbol: string): Promise<bigint>;
|
|
943
944
|
getBalanceForeignPolkadotXcm(address: string, id?: string): Promise<bigint>;
|
package/dist/index.mjs
CHANGED
|
@@ -6708,6 +6708,22 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6708
6708
|
}]);
|
|
6709
6709
|
}(ParachainNode);
|
|
6710
6710
|
|
|
6711
|
+
var createExecuteCall = function createExecuteCall(
|
|
6712
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6713
|
+
xcm, maxWeight) {
|
|
6714
|
+
return {
|
|
6715
|
+
module: 'PolkadotXcm',
|
|
6716
|
+
method: 'execute',
|
|
6717
|
+
parameters: {
|
|
6718
|
+
message: xcm,
|
|
6719
|
+
max_weight: {
|
|
6720
|
+
ref_time: maxWeight.refTime,
|
|
6721
|
+
proof_size: maxWeight.proofSize
|
|
6722
|
+
}
|
|
6723
|
+
}
|
|
6724
|
+
};
|
|
6725
|
+
};
|
|
6726
|
+
|
|
6711
6727
|
var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight, originExecutionFee, destExecutionFee) {
|
|
6712
6728
|
var api = input.api,
|
|
6713
6729
|
_input$version = input.version,
|
|
@@ -6805,15 +6821,15 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight,
|
|
|
6805
6821
|
return api.callTxMethod(call);
|
|
6806
6822
|
};
|
|
6807
6823
|
|
|
6808
|
-
var createExecuteXcm = function createExecuteXcm(input,
|
|
6824
|
+
var createExecuteXcm = function createExecuteXcm(input, executionFee, version) {
|
|
6825
|
+
var _feeAsset$multiLocati;
|
|
6809
6826
|
var api = input.api,
|
|
6810
|
-
_input$version = input.version,
|
|
6811
|
-
version = _input$version === void 0 ? Version.V4 : _input$version,
|
|
6812
6827
|
asset = input.asset,
|
|
6813
6828
|
scenario = input.scenario,
|
|
6814
6829
|
destination = input.destination,
|
|
6815
6830
|
paraIdTo = input.paraIdTo,
|
|
6816
|
-
address = input.address
|
|
6831
|
+
address = input.address,
|
|
6832
|
+
feeAsset = input.feeAsset;
|
|
6817
6833
|
var dest = createDestination(scenario, version, destination, paraIdTo);
|
|
6818
6834
|
var beneficiary = createBeneficiary({
|
|
6819
6835
|
api: api,
|
|
@@ -6823,77 +6839,74 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
|
|
|
6823
6839
|
version: version,
|
|
6824
6840
|
paraId: paraIdTo
|
|
6825
6841
|
});
|
|
6826
|
-
if (!asset.multiLocation) {
|
|
6827
|
-
throw new
|
|
6842
|
+
if (!asset.multiLocation || feeAsset && !feeAsset.multiLocation) {
|
|
6843
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6828
6844
|
}
|
|
6829
|
-
var
|
|
6845
|
+
var assetML = transformMultiLocation(asset.multiLocation);
|
|
6846
|
+
var feeML = transformMultiLocation((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : asset.multiLocation);
|
|
6847
|
+
var sameFeeAsset = feeAsset && isAssetEqual(asset, feeAsset);
|
|
6830
6848
|
var amountWithoutFee = BigInt(asset.amount) - executionFee;
|
|
6831
|
-
var
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6849
|
+
var xcm = [{
|
|
6850
|
+
WithdrawAsset: [{
|
|
6851
|
+
id: assetML,
|
|
6852
|
+
fun: {
|
|
6853
|
+
Fungible: BigInt(asset.amount)
|
|
6854
|
+
}
|
|
6855
|
+
}].concat(_toConsumableArray(!sameFeeAsset && feeAsset !== null && feeAsset !== void 0 && feeAsset.multiLocation ? [{
|
|
6856
|
+
id: transformMultiLocation(feeAsset.multiLocation),
|
|
6857
|
+
fun: {
|
|
6858
|
+
Fungible: executionFee
|
|
6859
|
+
}
|
|
6860
|
+
}] : []))
|
|
6861
|
+
}, {
|
|
6862
|
+
BuyExecution: {
|
|
6863
|
+
fees: {
|
|
6864
|
+
id: feeML,
|
|
6865
|
+
fun: {
|
|
6866
|
+
Fungible: executionFee
|
|
6867
|
+
}
|
|
6868
|
+
},
|
|
6869
|
+
weight_limit: {
|
|
6870
|
+
Limited: {
|
|
6871
|
+
ref_time: 150n,
|
|
6872
|
+
proof_size: 0n
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6875
|
+
}
|
|
6876
|
+
}, {
|
|
6877
|
+
DepositReserveAsset: {
|
|
6878
|
+
assets: {
|
|
6879
|
+
Definite: [{
|
|
6880
|
+
id: assetML,
|
|
6838
6881
|
fun: {
|
|
6839
|
-
Fungible: BigInt(asset.amount)
|
|
6882
|
+
Fungible: sameFeeAsset ? amountWithoutFee : BigInt(asset.amount)
|
|
6840
6883
|
}
|
|
6841
6884
|
}]
|
|
6842
|
-
},
|
|
6885
|
+
},
|
|
6886
|
+
dest: dest,
|
|
6887
|
+
xcm: [{
|
|
6843
6888
|
BuyExecution: {
|
|
6844
6889
|
fees: {
|
|
6845
|
-
id:
|
|
6890
|
+
id: asset.multiLocation,
|
|
6846
6891
|
fun: {
|
|
6847
|
-
Fungible: executionFee
|
|
6892
|
+
Fungible: sameFeeAsset ? amountWithoutFee - executionFee : BigInt(asset.amount)
|
|
6848
6893
|
}
|
|
6849
6894
|
},
|
|
6850
|
-
weight_limit:
|
|
6851
|
-
Limited: {
|
|
6852
|
-
ref_time: 150n,
|
|
6853
|
-
proof_size: 0n
|
|
6854
|
-
}
|
|
6855
|
-
}
|
|
6895
|
+
weight_limit: 'Unlimited'
|
|
6856
6896
|
}
|
|
6857
6897
|
}, {
|
|
6858
|
-
|
|
6898
|
+
DepositAsset: {
|
|
6859
6899
|
assets: {
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
fun: {
|
|
6863
|
-
Fungible: amountWithoutFee
|
|
6864
|
-
}
|
|
6865
|
-
}]
|
|
6866
|
-
},
|
|
6867
|
-
dest: dest,
|
|
6868
|
-
xcm: [{
|
|
6869
|
-
BuyExecution: {
|
|
6870
|
-
fees: {
|
|
6871
|
-
id: asset.multiLocation,
|
|
6872
|
-
fun: {
|
|
6873
|
-
Fungible: amountWithoutFee - executionFee
|
|
6874
|
-
}
|
|
6875
|
-
},
|
|
6876
|
-
weight_limit: 'Unlimited'
|
|
6877
|
-
}
|
|
6878
|
-
}, {
|
|
6879
|
-
DepositAsset: {
|
|
6880
|
-
assets: {
|
|
6881
|
-
Wild: {
|
|
6882
|
-
AllCounted: 1
|
|
6883
|
-
}
|
|
6884
|
-
},
|
|
6885
|
-
beneficiary: beneficiary
|
|
6900
|
+
Wild: {
|
|
6901
|
+
AllCounted: 1
|
|
6886
6902
|
}
|
|
6887
|
-
}
|
|
6903
|
+
},
|
|
6904
|
+
beneficiary: beneficiary
|
|
6888
6905
|
}
|
|
6889
|
-
}]
|
|
6890
|
-
max_weight: {
|
|
6891
|
-
ref_time: weight.refTime,
|
|
6892
|
-
proof_size: weight.proofSize
|
|
6893
|
-
}
|
|
6906
|
+
}]
|
|
6894
6907
|
}
|
|
6895
|
-
};
|
|
6896
|
-
return
|
|
6908
|
+
}];
|
|
6909
|
+
return addXcmVersionHeader(xcm, version);
|
|
6897
6910
|
};
|
|
6898
6911
|
|
|
6899
6912
|
var handleToAhTeleport = /*#__PURE__*/function () {
|
|
@@ -7255,11 +7268,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7255
7268
|
key: "handleExecuteTransfer",
|
|
7256
7269
|
value: function () {
|
|
7257
7270
|
var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
|
|
7258
|
-
var api, senderAddress, asset, feeAsset, decimals, multiplier, base, scaledMultiplier, MIN_FEE,
|
|
7271
|
+
var api, senderAddress, asset, feeAsset, _input$version4, version, decimals, multiplier, base, scaledMultiplier, MIN_FEE, call, dryRunResult, paddedFee, xcm, weight;
|
|
7259
7272
|
return _regenerator().w(function (_context3) {
|
|
7260
7273
|
while (1) switch (_context3.n) {
|
|
7261
7274
|
case 0:
|
|
7262
|
-
api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset;
|
|
7275
|
+
api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset, _input$version4 = input.version, version = _input$version4 === void 0 ? Version.V4 : _input$version4;
|
|
7263
7276
|
if (senderAddress) {
|
|
7264
7277
|
_context3.n = 1;
|
|
7265
7278
|
break;
|
|
@@ -7272,11 +7285,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7272
7285
|
base = BigInt(Math.pow(10, decimals));
|
|
7273
7286
|
scaledMultiplier = BigInt(Math.floor(multiplier * Math.pow(10, decimals)));
|
|
7274
7287
|
MIN_FEE = base * scaledMultiplier / BigInt(Math.pow(10, decimals));
|
|
7275
|
-
|
|
7288
|
+
call = createExecuteCall(createExecuteXcm(input, MIN_FEE, version), MAX_WEIGHT);
|
|
7276
7289
|
_context3.n = 2;
|
|
7277
7290
|
return api.getDryRunCall({
|
|
7278
7291
|
node: this.node,
|
|
7279
|
-
tx:
|
|
7292
|
+
tx: api.callTxMethod(call),
|
|
7280
7293
|
address: senderAddress,
|
|
7281
7294
|
isFeeAsset: !!feeAsset
|
|
7282
7295
|
});
|
|
@@ -7288,14 +7301,13 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7288
7301
|
}
|
|
7289
7302
|
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
7290
7303
|
case 3:
|
|
7291
|
-
if (dryRunResult.weight) {
|
|
7292
|
-
_context3.n = 4;
|
|
7293
|
-
break;
|
|
7294
|
-
}
|
|
7295
|
-
throw new DryRunFailedError('weight not found');
|
|
7296
|
-
case 4:
|
|
7297
7304
|
paddedFee = dryRunResult.fee * 120n / 100n;
|
|
7298
|
-
|
|
7305
|
+
xcm = createExecuteXcm(input, paddedFee, version);
|
|
7306
|
+
_context3.n = 4;
|
|
7307
|
+
return api.getXcmWeight(xcm);
|
|
7308
|
+
case 4:
|
|
7309
|
+
weight = _context3.v;
|
|
7310
|
+
return _context3.a(2, createExecuteCall(createExecuteXcm(input, paddedFee, version), weight));
|
|
7299
7311
|
}
|
|
7300
7312
|
}, _callee3, this);
|
|
7301
7313
|
}));
|
|
@@ -7306,54 +7318,96 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7306
7318
|
}()
|
|
7307
7319
|
}, {
|
|
7308
7320
|
key: "transferPolkadotXCM",
|
|
7309
|
-
value: function
|
|
7310
|
-
var
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7321
|
+
value: function () {
|
|
7322
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(input) {
|
|
7323
|
+
var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
|
|
7324
|
+
return _regenerator().w(function (_context4) {
|
|
7325
|
+
while (1) switch (_context4.n) {
|
|
7326
|
+
case 0:
|
|
7327
|
+
api = input.api, scenario = input.scenario, asset = input.asset, destination = input.destination, feeAsset = input.feeAsset, overriddenAsset = input.overriddenAsset;
|
|
7328
|
+
if (!feeAsset) {
|
|
7329
|
+
_context4.n = 4;
|
|
7330
|
+
break;
|
|
7331
|
+
}
|
|
7332
|
+
if (!overriddenAsset) {
|
|
7333
|
+
_context4.n = 1;
|
|
7334
|
+
break;
|
|
7335
|
+
}
|
|
7336
|
+
throw new InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
|
|
7337
|
+
case 1:
|
|
7338
|
+
if (!(normalizeSymbol(asset.symbol) === normalizeSymbol('KSM'))) {
|
|
7339
|
+
_context4.n = 2;
|
|
7340
|
+
break;
|
|
7341
|
+
}
|
|
7342
|
+
return _context4.a(2, this.handleLocalReserveTransfer(input));
|
|
7343
|
+
case 2:
|
|
7344
|
+
isNativeAsset = asset.symbol === this.getNativeAssetSymbol();
|
|
7345
|
+
if (isNativeAsset) {
|
|
7346
|
+
_context4.n = 4;
|
|
7347
|
+
break;
|
|
7348
|
+
}
|
|
7349
|
+
_t = api;
|
|
7350
|
+
_context4.n = 3;
|
|
7351
|
+
return this.handleExecuteTransfer(input);
|
|
7352
|
+
case 3:
|
|
7353
|
+
_t2 = _context4.v;
|
|
7354
|
+
return _context4.a(2, _t.callTxMethod.call(_t, _t2));
|
|
7355
|
+
case 4:
|
|
7356
|
+
if (!(destination === 'AssetHubKusama')) {
|
|
7357
|
+
_context4.n = 5;
|
|
7358
|
+
break;
|
|
7359
|
+
}
|
|
7360
|
+
return _context4.a(2, this.handleBridgeTransfer(input, 'Kusama'));
|
|
7361
|
+
case 5:
|
|
7362
|
+
if (!(destination === 'Ethereum')) {
|
|
7363
|
+
_context4.n = 6;
|
|
7364
|
+
break;
|
|
7365
|
+
}
|
|
7366
|
+
return _context4.a(2, this.handleEthBridgeTransfer(input));
|
|
7367
|
+
case 6:
|
|
7368
|
+
if (!(destination === 'Mythos')) {
|
|
7369
|
+
_context4.n = 7;
|
|
7370
|
+
break;
|
|
7371
|
+
}
|
|
7372
|
+
return _context4.a(2, this.handleMythosTransfer(input));
|
|
7373
|
+
case 7:
|
|
7374
|
+
isEthereumAsset = asset.multiLocation && findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
|
|
7375
|
+
if (!(destination === 'BifrostPolkadot' && isEthereumAsset)) {
|
|
7376
|
+
_context4.n = 8;
|
|
7377
|
+
break;
|
|
7378
|
+
}
|
|
7379
|
+
return _context4.a(2, this.handleLocalReserveTransfer(input));
|
|
7380
|
+
case 8:
|
|
7381
|
+
if (!isEthereumAsset) {
|
|
7382
|
+
_context4.n = 9;
|
|
7383
|
+
break;
|
|
7384
|
+
}
|
|
7385
|
+
return _context4.a(2, this.handleLocalReserveTransfer(input, true));
|
|
7386
|
+
case 9:
|
|
7387
|
+
isSystemNode = !isTMultiLocation(destination) && SYSTEM_NODES_POLKADOT.includes(destination);
|
|
7388
|
+
if (!(scenario === 'ParaToPara' && asset.symbol === 'DOT' && !isForeignAsset(asset) && destination !== 'Hydration' && destination !== 'Polimec' && destination !== 'Moonbeam' && destination !== 'BifrostPolkadot' && destination !== 'PeoplePolkadot' && destination !== 'Ajuna' && !isSystemNode)) {
|
|
7389
|
+
_context4.n = 10;
|
|
7390
|
+
break;
|
|
7391
|
+
}
|
|
7392
|
+
throw new ScenarioNotSupportedError(this.node, scenario, 'Some Parachains do not have a reserve for DOT on AssetHub. This can also include multihop transfers that have AssetHub as a hop chain and the call contains DOT. Chains that do not have a DOT reserve on AssetHub are not allowed to transfer DOT to it or through it because this transfer will result in asset loss.');
|
|
7393
|
+
case 10:
|
|
7394
|
+
if (!(scenario === 'ParaToPara' && asset.symbol === 'KSM' && !isForeignAsset(asset))) {
|
|
7395
|
+
_context4.n = 11;
|
|
7396
|
+
break;
|
|
7397
|
+
}
|
|
7398
|
+
throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
|
|
7399
|
+
case 11:
|
|
7400
|
+
method = this.getMethod(scenario, destination);
|
|
7401
|
+
modifiedInput = this.patchInput(input);
|
|
7402
|
+
return _context4.a(2, PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, method, 'Unlimited'));
|
|
7403
|
+
}
|
|
7404
|
+
}, _callee4, this);
|
|
7405
|
+
}));
|
|
7406
|
+
function transferPolkadotXCM(_x4) {
|
|
7407
|
+
return _transferPolkadotXCM.apply(this, arguments);
|
|
7352
7408
|
}
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, method, 'Unlimited'));
|
|
7356
|
-
}
|
|
7409
|
+
return transferPolkadotXCM;
|
|
7410
|
+
}()
|
|
7357
7411
|
}, {
|
|
7358
7412
|
key: "getRelayToParaOverrides",
|
|
7359
7413
|
value: function getRelayToParaOverrides() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.3",
|
|
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": "^1.8.0",
|
|
27
27
|
"@scure/base": "^1.2.6",
|
|
28
28
|
"viem": "^2.30.5",
|
|
29
|
-
"@paraspell/
|
|
30
|
-
"@paraspell/
|
|
31
|
-
"@paraspell/
|
|
29
|
+
"@paraspell/pallets": "10.4.3",
|
|
30
|
+
"@paraspell/assets": "10.4.3",
|
|
31
|
+
"@paraspell/sdk-common": "10.4.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|