@paraspell/sdk-core 10.5.2 → 10.6.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 +204 -92
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +205 -94
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -720,6 +720,11 @@ var assertAddressIsString = function assertAddressIsString(address) {
|
|
|
720
720
|
throw new InvalidParameterError('Multi-Location address is not supported for XCM fee calculation.');
|
|
721
721
|
}
|
|
722
722
|
};
|
|
723
|
+
var assertHasLocation = function assertHasLocation(asset) {
|
|
724
|
+
if (!asset.multiLocation) {
|
|
725
|
+
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is missing multi-location"));
|
|
726
|
+
}
|
|
727
|
+
};
|
|
723
728
|
|
|
724
729
|
var AssetHubPolkadot$1 = {
|
|
725
730
|
name: "AssetHub",
|
|
@@ -3436,8 +3441,9 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
3436
3441
|
};
|
|
3437
3442
|
}();
|
|
3438
3443
|
|
|
3439
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, messageId) {
|
|
3444
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, messageId, feeAmount) {
|
|
3440
3445
|
var api = _ref.api,
|
|
3446
|
+
destination = _ref.destination,
|
|
3441
3447
|
address = _ref.address,
|
|
3442
3448
|
asset = _ref.asset,
|
|
3443
3449
|
scenario = _ref.scenario,
|
|
@@ -3447,9 +3453,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
|
|
|
3447
3453
|
if (!assets.isForeignAsset(asset)) {
|
|
3448
3454
|
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
3449
3455
|
}
|
|
3450
|
-
|
|
3451
|
-
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
3452
|
-
}
|
|
3456
|
+
assertHasLocation(asset);
|
|
3453
3457
|
if (!senderAddress) {
|
|
3454
3458
|
throw new InvalidParameterError("Please provide senderAddress");
|
|
3455
3459
|
}
|
|
@@ -3471,7 +3475,41 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
|
|
|
3471
3475
|
}]
|
|
3472
3476
|
};
|
|
3473
3477
|
return _defineProperty({}, version, [{
|
|
3474
|
-
SetAppendix: [{
|
|
3478
|
+
SetAppendix: [origin === 'Mythos' ? {
|
|
3479
|
+
DepositReserveAsset: {
|
|
3480
|
+
assets: {
|
|
3481
|
+
Wild: 'All'
|
|
3482
|
+
},
|
|
3483
|
+
dest: createDestination(scenario, version, destination, getParaId(origin), undefined, sdkCommon.Parents.ONE),
|
|
3484
|
+
xcm: [{
|
|
3485
|
+
BuyExecution: {
|
|
3486
|
+
fees: {
|
|
3487
|
+
id: {
|
|
3488
|
+
parents: sdkCommon.Parents.ZERO,
|
|
3489
|
+
interior: 'Here'
|
|
3490
|
+
},
|
|
3491
|
+
fun: {
|
|
3492
|
+
Fungible: feeAmount
|
|
3493
|
+
}
|
|
3494
|
+
},
|
|
3495
|
+
weight_limit: 'Unlimited'
|
|
3496
|
+
}
|
|
3497
|
+
}, {
|
|
3498
|
+
DepositAsset: {
|
|
3499
|
+
assets: {
|
|
3500
|
+
Wild: 'All'
|
|
3501
|
+
},
|
|
3502
|
+
beneficiary: createBeneficiaryMultiLocation({
|
|
3503
|
+
api: api,
|
|
3504
|
+
scenario: scenario,
|
|
3505
|
+
pallet: 'PolkadotXcm',
|
|
3506
|
+
recipientAddress: address,
|
|
3507
|
+
version: version
|
|
3508
|
+
})
|
|
3509
|
+
}
|
|
3510
|
+
}]
|
|
3511
|
+
}
|
|
3512
|
+
} : {
|
|
3475
3513
|
DepositAsset: {
|
|
3476
3514
|
assets: {
|
|
3477
3515
|
Wild: 'All'
|
|
@@ -3738,6 +3776,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3738
3776
|
messageId = _context.v;
|
|
3739
3777
|
customXcm = createCustomXcmOnDest({
|
|
3740
3778
|
api: api,
|
|
3779
|
+
destination: to,
|
|
3741
3780
|
address: address,
|
|
3742
3781
|
scenario: 'ParaToPara',
|
|
3743
3782
|
senderAddress: senderAddress,
|
|
@@ -5258,7 +5297,7 @@ var validateDestination = function validateDestination(origin, destination) {
|
|
|
5258
5297
|
if (sdkCommon.isRelayChain(origin) && !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination) && origin !== destination) {
|
|
5259
5298
|
throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
5260
5299
|
}
|
|
5261
|
-
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam'];
|
|
5300
|
+
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
|
|
5262
5301
|
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
5263
5302
|
throw new IncompatibleNodesError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
5264
5303
|
}
|
|
@@ -5850,7 +5889,7 @@ var send = /*#__PURE__*/function () {
|
|
|
5850
5889
|
});
|
|
5851
5890
|
finalVersion = selectXcmVersion(version, originVersion, destVersion);
|
|
5852
5891
|
normalizedAsset = finalAsset.multiLocation ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
|
|
5853
|
-
|
|
5892
|
+
multiLocation: assets.normalizeMultiLocation(finalAsset.multiLocation, finalVersion)
|
|
5854
5893
|
}) : finalAsset;
|
|
5855
5894
|
return _context.a(2, getNode(origin).transfer({
|
|
5856
5895
|
api: api,
|
|
@@ -6164,41 +6203,36 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6164
6203
|
while (1) switch (_context2.n) {
|
|
6165
6204
|
case 0:
|
|
6166
6205
|
api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAsset, paraIdTo = input.paraIdTo;
|
|
6167
|
-
|
|
6168
|
-
_context2.n = 1;
|
|
6169
|
-
break;
|
|
6170
|
-
}
|
|
6171
|
-
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6172
|
-
case 1:
|
|
6206
|
+
assertHasLocation(asset);
|
|
6173
6207
|
if (!(senderAddress === undefined)) {
|
|
6174
|
-
_context2.n =
|
|
6208
|
+
_context2.n = 1;
|
|
6175
6209
|
break;
|
|
6176
6210
|
}
|
|
6177
6211
|
throw new InvalidParameterError('Sender address is required for transfers to Ethereum');
|
|
6178
|
-
case
|
|
6212
|
+
case 1:
|
|
6179
6213
|
if (!sdkCommon.isTMultiLocation(address)) {
|
|
6180
|
-
_context2.n =
|
|
6214
|
+
_context2.n = 2;
|
|
6181
6215
|
break;
|
|
6182
6216
|
}
|
|
6183
6217
|
throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
|
|
6184
|
-
case
|
|
6218
|
+
case 2:
|
|
6185
6219
|
ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
|
|
6186
6220
|
PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
|
|
6187
6221
|
// Pad by 25%
|
|
6188
6222
|
AH_EXECUTION_FEE_PADDED = ASSET_HUB_EXECUTION_FEE * 125n / 100n; // Perform a dry run AH -> dest to calculate the BuyExecution amount
|
|
6189
|
-
_context2.n =
|
|
6223
|
+
_context2.n = 3;
|
|
6190
6224
|
return Builder(api.clone()).from('AssetHubPolkadot').to(destination).currency({
|
|
6191
6225
|
symbol: 'DOT',
|
|
6192
6226
|
amount: AH_EXECUTION_FEE_PADDED
|
|
6193
6227
|
}).address(address).senderAddress(senderAddress).dryRun();
|
|
6194
|
-
case
|
|
6228
|
+
case 3:
|
|
6195
6229
|
dryRunResult = _context2.v;
|
|
6196
6230
|
if (dryRunResult.origin.success) {
|
|
6197
|
-
_context2.n =
|
|
6231
|
+
_context2.n = 4;
|
|
6198
6232
|
break;
|
|
6199
6233
|
}
|
|
6200
6234
|
throw new DryRunFailedError(dryRunResult.origin.failureReason);
|
|
6201
|
-
case
|
|
6235
|
+
case 4:
|
|
6202
6236
|
// Pad fee by 50%
|
|
6203
6237
|
dryRunFeePadded = BigInt(dryRunResult.origin.fee) * 3n / 2n;
|
|
6204
6238
|
dest = createDestination(scenario, version, destination, paraIdTo);
|
|
@@ -6313,32 +6347,27 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6313
6347
|
}
|
|
6314
6348
|
throw new BridgeHaltedError();
|
|
6315
6349
|
case 2:
|
|
6316
|
-
|
|
6317
|
-
_context3.n = 3;
|
|
6318
|
-
break;
|
|
6319
|
-
}
|
|
6320
|
-
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6321
|
-
case 3:
|
|
6350
|
+
assertHasLocation(asset);
|
|
6322
6351
|
if (!(senderAddress === undefined)) {
|
|
6323
|
-
_context3.n =
|
|
6352
|
+
_context3.n = 3;
|
|
6324
6353
|
break;
|
|
6325
6354
|
}
|
|
6326
6355
|
throw new InvalidParameterError('Sender address is required for transfers to Ethereum');
|
|
6327
|
-
case
|
|
6356
|
+
case 3:
|
|
6328
6357
|
if (!sdkCommon.isTMultiLocation(address)) {
|
|
6329
|
-
_context3.n =
|
|
6358
|
+
_context3.n = 4;
|
|
6330
6359
|
break;
|
|
6331
6360
|
}
|
|
6332
6361
|
throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
|
|
6333
|
-
case
|
|
6362
|
+
case 4:
|
|
6334
6363
|
ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
|
|
6335
|
-
_context3.n =
|
|
6364
|
+
_context3.n = 5;
|
|
6336
6365
|
return api.createApiForNode('AssetHubPolkadot');
|
|
6337
|
-
case
|
|
6366
|
+
case 5:
|
|
6338
6367
|
ahApi = _context3.v;
|
|
6339
|
-
_context3.n =
|
|
6368
|
+
_context3.n = 6;
|
|
6340
6369
|
return getParaEthTransferFees(ahApi);
|
|
6341
|
-
case
|
|
6370
|
+
case 6:
|
|
6342
6371
|
_yield$getParaEthTran = _context3.v;
|
|
6343
6372
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
6344
6373
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
@@ -6347,13 +6376,13 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6347
6376
|
fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : (bridgeFee + executionFee).toString();
|
|
6348
6377
|
ethAsset = assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
|
|
6349
6378
|
if (ethAsset) {
|
|
6350
|
-
_context3.n =
|
|
6379
|
+
_context3.n = 7;
|
|
6351
6380
|
break;
|
|
6352
6381
|
}
|
|
6353
6382
|
throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
|
|
6354
|
-
case
|
|
6383
|
+
case 7:
|
|
6355
6384
|
if (!useOnlyDepositInstruction) {
|
|
6356
|
-
_context3.n =
|
|
6385
|
+
_context3.n = 8;
|
|
6357
6386
|
break;
|
|
6358
6387
|
}
|
|
6359
6388
|
customXcmOnDest = addXcmVersionHeader([{
|
|
@@ -6372,21 +6401,21 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6372
6401
|
})
|
|
6373
6402
|
}
|
|
6374
6403
|
}], version);
|
|
6375
|
-
_context3.n =
|
|
6404
|
+
_context3.n = 11;
|
|
6376
6405
|
break;
|
|
6377
|
-
case
|
|
6406
|
+
case 8:
|
|
6378
6407
|
if (ethAsset.assetId) {
|
|
6379
|
-
_context3.n =
|
|
6408
|
+
_context3.n = 9;
|
|
6380
6409
|
break;
|
|
6381
6410
|
}
|
|
6382
6411
|
throw new assets.InvalidCurrencyError("Ethereum asset ".concat(JSON.stringify(ethAsset), " has no assetId"));
|
|
6383
|
-
case
|
|
6384
|
-
_context3.n =
|
|
6412
|
+
case 9:
|
|
6413
|
+
_context3.n = 10;
|
|
6385
6414
|
return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
|
|
6386
|
-
case
|
|
6415
|
+
case 10:
|
|
6387
6416
|
messageId = _context3.v;
|
|
6388
6417
|
customXcmOnDest = createCustomXcmOnDest(input, this.node, messageId);
|
|
6389
|
-
case
|
|
6418
|
+
case 11:
|
|
6390
6419
|
call = {
|
|
6391
6420
|
module: 'PolkadotXcm',
|
|
6392
6421
|
method: 'transfer_assets_using_type_and_then',
|
|
@@ -6722,9 +6751,7 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight,
|
|
|
6722
6751
|
version: version,
|
|
6723
6752
|
paraId: paraIdTo
|
|
6724
6753
|
});
|
|
6725
|
-
|
|
6726
|
-
throw new InvalidParameterError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6727
|
-
}
|
|
6754
|
+
assertHasLocation(asset);
|
|
6728
6755
|
var transformedMultiLocation = transformMultiLocation(asset.multiLocation);
|
|
6729
6756
|
var call = {
|
|
6730
6757
|
module: 'PolkadotXcm',
|
|
@@ -7017,9 +7044,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7017
7044
|
if (!assets.isForeignAsset(asset)) {
|
|
7018
7045
|
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
7019
7046
|
}
|
|
7020
|
-
|
|
7021
|
-
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
7022
|
-
}
|
|
7047
|
+
assertHasLocation(asset);
|
|
7023
7048
|
var PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
|
|
7024
7049
|
var call = {
|
|
7025
7050
|
module: 'PolkadotXcm',
|
|
@@ -7110,15 +7135,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7110
7135
|
}
|
|
7111
7136
|
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
7112
7137
|
case 5:
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
break;
|
|
7116
|
-
}
|
|
7117
|
-
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
7118
|
-
case 6:
|
|
7119
|
-
_context.n = 7;
|
|
7138
|
+
assertHasLocation(asset);
|
|
7139
|
+
_context.n = 6;
|
|
7120
7140
|
return generateMessageId(api, senderAddress, getParaId(this.node), JSON.stringify(asset.multiLocation), address, asset.amount);
|
|
7121
|
-
case
|
|
7141
|
+
case 6:
|
|
7122
7142
|
messageId = _context.v;
|
|
7123
7143
|
multiLocation = asset.symbol === this.getNativeAssetSymbol() ? DOT_MULTILOCATION : asset.multiLocation;
|
|
7124
7144
|
call = {
|
|
@@ -7185,18 +7205,13 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7185
7205
|
}
|
|
7186
7206
|
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
7187
7207
|
case 3:
|
|
7188
|
-
|
|
7189
|
-
_context2.n = 4;
|
|
7190
|
-
break;
|
|
7191
|
-
}
|
|
7192
|
-
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
7193
|
-
case 4:
|
|
7208
|
+
assertHasLocation(asset);
|
|
7194
7209
|
if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === assets.getNativeAssetSymbol('Kusama'))) {
|
|
7195
|
-
_context2.n =
|
|
7210
|
+
_context2.n = 4;
|
|
7196
7211
|
break;
|
|
7197
7212
|
}
|
|
7198
7213
|
return _context2.a(2, this.handleEthBridgeNativeTransfer(input));
|
|
7199
|
-
case
|
|
7214
|
+
case 4:
|
|
7200
7215
|
modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
7201
7216
|
destLocation: createDestination(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, sdkCommon.Parents.TWO),
|
|
7202
7217
|
beneficiaryLocation: createBeneficiary({
|
|
@@ -8173,7 +8188,7 @@ var createTypeAndThenDest = function createTypeAndThenDest(destination, scenario
|
|
|
8173
8188
|
})
|
|
8174
8189
|
};
|
|
8175
8190
|
};
|
|
8176
|
-
var createTypeAndThenTransfer = function createTypeAndThenTransfer(_ref, version) {
|
|
8191
|
+
var createTypeAndThenTransfer$1 = function createTypeAndThenTransfer(_ref, version) {
|
|
8177
8192
|
var api = _ref.api,
|
|
8178
8193
|
asset = _ref.asset,
|
|
8179
8194
|
address = _ref.address,
|
|
@@ -8262,7 +8277,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8262
8277
|
_context.n = 1;
|
|
8263
8278
|
break;
|
|
8264
8279
|
}
|
|
8265
|
-
_call = createTypeAndThenTransfer(input, version);
|
|
8280
|
+
_call = createTypeAndThenTransfer$1(input, version);
|
|
8266
8281
|
return _context.a(2, api.callTxMethod(_call));
|
|
8267
8282
|
case 1:
|
|
8268
8283
|
if (!(scenario === 'ParaToPara' && (destination === 'AssetHubPolkadot' || destination === 'Hydration'))) {
|
|
@@ -8277,7 +8292,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8277
8292
|
}
|
|
8278
8293
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
8279
8294
|
case 3:
|
|
8280
|
-
call = createTypeAndThenTransfer(input, version, 'Teleport');
|
|
8295
|
+
call = createTypeAndThenTransfer$1(input, version, 'Teleport');
|
|
8281
8296
|
return _context.a(2, api.callTxMethod(call));
|
|
8282
8297
|
}
|
|
8283
8298
|
}, _callee, this);
|
|
@@ -8292,7 +8307,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8292
8307
|
value: function transferRelayToPara(options) {
|
|
8293
8308
|
var _options$version = options.version,
|
|
8294
8309
|
version = _options$version === void 0 ? this.version : _options$version;
|
|
8295
|
-
var call = createTypeAndThenTransfer(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8310
|
+
var call = createTypeAndThenTransfer$1(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8296
8311
|
scenario: 'RelayToPara'
|
|
8297
8312
|
}), version, 'Teleport');
|
|
8298
8313
|
return call;
|
|
@@ -8386,7 +8401,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8386
8401
|
version = _options$version === void 0 ? this.version : _options$version;
|
|
8387
8402
|
var symbol = asset.symbol.toUpperCase();
|
|
8388
8403
|
if (symbol === 'DOT') {
|
|
8389
|
-
var call = createTypeAndThenTransfer(options, version);
|
|
8404
|
+
var call = createTypeAndThenTransfer$1(options, version);
|
|
8390
8405
|
return Promise.resolve(api.callTxMethod(call));
|
|
8391
8406
|
}
|
|
8392
8407
|
if ((symbol === 'USDC' || symbol === 'USDT') && !sdkCommon.hasJunction(asset.multiLocation, 'Parachain', getParaId('AssetHubPolkadot'))) {
|
|
@@ -8695,9 +8710,7 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8695
8710
|
}
|
|
8696
8711
|
}
|
|
8697
8712
|
};
|
|
8698
|
-
|
|
8699
|
-
throw new assets.InvalidCurrencyError('throw new InvalidCurrencyError(`Asset ${JSON.stringify(asset)} has no assetId`)');
|
|
8700
|
-
}
|
|
8713
|
+
assertHasLocation(asset);
|
|
8701
8714
|
return asset.multiLocation;
|
|
8702
8715
|
}
|
|
8703
8716
|
}, {
|
|
@@ -8767,9 +8780,7 @@ var Moonriver = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8767
8780
|
}
|
|
8768
8781
|
}
|
|
8769
8782
|
};
|
|
8770
|
-
|
|
8771
|
-
throw new assets.InvalidCurrencyError('throw new InvalidCurrencyError(`Asset ${JSON.stringify(asset)} has no multiLocation`)');
|
|
8772
|
-
}
|
|
8783
|
+
assertHasLocation(asset);
|
|
8773
8784
|
return asset.multiLocation;
|
|
8774
8785
|
}
|
|
8775
8786
|
}, {
|
|
@@ -8800,6 +8811,94 @@ var Moonriver = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8800
8811
|
}]);
|
|
8801
8812
|
}(ParachainNode);
|
|
8802
8813
|
|
|
8814
|
+
var createTypeAndThenTransfer = /*#__PURE__*/function () {
|
|
8815
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, node, version) {
|
|
8816
|
+
var api, scenario, asset, currency, senderAddress, address, destination, messageId, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, feeConverted, nativeMythAmount, nativeMythBalance;
|
|
8817
|
+
return _regenerator().w(function (_context) {
|
|
8818
|
+
while (1) switch (_context.n) {
|
|
8819
|
+
case 0:
|
|
8820
|
+
api = options.api, scenario = options.scenario, asset = options.asset, currency = options.currency, senderAddress = options.senderAddress, address = options.address, destination = options.destination;
|
|
8821
|
+
assertHasLocation(asset);
|
|
8822
|
+
assertAddressIsString(address);
|
|
8823
|
+
if (senderAddress) {
|
|
8824
|
+
_context.n = 1;
|
|
8825
|
+
break;
|
|
8826
|
+
}
|
|
8827
|
+
throw new assets.InvalidCurrencyError("Sender address is required for Mythos transfer");
|
|
8828
|
+
case 1:
|
|
8829
|
+
if (!(!assets.isForeignAsset(asset) || !asset.assetId)) {
|
|
8830
|
+
_context.n = 2;
|
|
8831
|
+
break;
|
|
8832
|
+
}
|
|
8833
|
+
throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, sdkCommon.replaceBigInt), " is not a foreign asset"));
|
|
8834
|
+
case 2:
|
|
8835
|
+
_context.n = 3;
|
|
8836
|
+
return generateMessageId(api, senderAddress, getParaId(node), asset.assetId, address, asset.amount);
|
|
8837
|
+
case 3:
|
|
8838
|
+
messageId = _context.v;
|
|
8839
|
+
ahApi = api.clone();
|
|
8840
|
+
_context.n = 4;
|
|
8841
|
+
return ahApi.init('AssetHubPolkadot');
|
|
8842
|
+
case 4:
|
|
8843
|
+
_context.n = 5;
|
|
8844
|
+
return getParaEthTransferFees(ahApi);
|
|
8845
|
+
case 5:
|
|
8846
|
+
_yield$getParaEthTran = _context.v;
|
|
8847
|
+
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
8848
|
+
bridgeFee = _yield$getParaEthTran2[0];
|
|
8849
|
+
ahExecutionFee = _yield$getParaEthTran2[1];
|
|
8850
|
+
_context.n = 6;
|
|
8851
|
+
return ahApi.quoteAhPrice(DOT_MULTILOCATION, assets.getNativeAssets(node)[0].multiLocation, bridgeFee + ahExecutionFee);
|
|
8852
|
+
case 6:
|
|
8853
|
+
feeConverted = _context.v;
|
|
8854
|
+
if (feeConverted) {
|
|
8855
|
+
_context.n = 7;
|
|
8856
|
+
break;
|
|
8857
|
+
}
|
|
8858
|
+
throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
|
|
8859
|
+
case 7:
|
|
8860
|
+
nativeMythAmount = padFeeBy(feeConverted, 10);
|
|
8861
|
+
_context.n = 8;
|
|
8862
|
+
return getAssetBalanceInternal({
|
|
8863
|
+
api: api,
|
|
8864
|
+
address: senderAddress,
|
|
8865
|
+
node: node,
|
|
8866
|
+
currency: currency
|
|
8867
|
+
});
|
|
8868
|
+
case 8:
|
|
8869
|
+
nativeMythBalance = _context.v;
|
|
8870
|
+
if (!(nativeMythBalance - nativeMythAmount < 0)) {
|
|
8871
|
+
_context.n = 9;
|
|
8872
|
+
break;
|
|
8873
|
+
}
|
|
8874
|
+
throw new assets.InvalidCurrencyError("Insufficient balance. Fee: ".concat(nativeMythAmount, ", Amount: ").concat(asset.amount));
|
|
8875
|
+
case 9:
|
|
8876
|
+
return _context.a(2, {
|
|
8877
|
+
module: 'PolkadotXcm',
|
|
8878
|
+
method: 'transfer_assets_using_type_and_then',
|
|
8879
|
+
parameters: {
|
|
8880
|
+
dest: createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
|
|
8881
|
+
assets: _defineProperty({}, version, [createMultiAsset(version, nativeMythAmount, {
|
|
8882
|
+
parents: sdkCommon.Parents.ZERO,
|
|
8883
|
+
interior: 'Here'
|
|
8884
|
+
}), createMultiAsset(version, asset.amount, asset.multiLocation)]),
|
|
8885
|
+
assets_transfer_type: 'DestinationReserve',
|
|
8886
|
+
remote_fees_id: _defineProperty({}, version, {
|
|
8887
|
+
parents: sdkCommon.Parents.ZERO,
|
|
8888
|
+
interior: 'Here'
|
|
8889
|
+
}),
|
|
8890
|
+
fees_transfer_type: 'Teleport',
|
|
8891
|
+
custom_xcm_on_dest: createCustomXcmOnDest(options, node, messageId, nativeMythAmount),
|
|
8892
|
+
weight_limit: 'Unlimited'
|
|
8893
|
+
}
|
|
8894
|
+
});
|
|
8895
|
+
}
|
|
8896
|
+
}, _callee);
|
|
8897
|
+
}));
|
|
8898
|
+
return function createTypeAndThenTransfer(_x, _x2, _x3) {
|
|
8899
|
+
return _ref.apply(this, arguments);
|
|
8900
|
+
};
|
|
8901
|
+
}();
|
|
8803
8902
|
var Mythos = /*#__PURE__*/function (_ParachainNode) {
|
|
8804
8903
|
function Mythos() {
|
|
8805
8904
|
_classCallCheck(this, Mythos);
|
|
@@ -8824,27 +8923,38 @@ var Mythos = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8824
8923
|
}, {
|
|
8825
8924
|
key: "transferPolkadotXCM",
|
|
8826
8925
|
value: function () {
|
|
8827
|
-
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
8828
|
-
var destination, defaultTx;
|
|
8829
|
-
return _regenerator().w(function (
|
|
8830
|
-
while (1) switch (
|
|
8926
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
8927
|
+
var api, destination, defaultTx, _t, _t2;
|
|
8928
|
+
return _regenerator().w(function (_context2) {
|
|
8929
|
+
while (1) switch (_context2.n) {
|
|
8831
8930
|
case 0:
|
|
8832
|
-
destination = input.destination;
|
|
8833
|
-
|
|
8931
|
+
api = input.api, destination = input.destination;
|
|
8932
|
+
_context2.n = 1;
|
|
8834
8933
|
return this.createTx(input);
|
|
8835
8934
|
case 1:
|
|
8836
|
-
defaultTx =
|
|
8935
|
+
defaultTx = _context2.v;
|
|
8837
8936
|
if (!(destination === 'AssetHubPolkadot')) {
|
|
8838
|
-
|
|
8937
|
+
_context2.n = 2;
|
|
8839
8938
|
break;
|
|
8840
8939
|
}
|
|
8841
|
-
return
|
|
8940
|
+
return _context2.a(2, handleToAhTeleport('Mythos', input, defaultTx));
|
|
8842
8941
|
case 2:
|
|
8843
|
-
|
|
8942
|
+
if (!(destination == 'Ethereum')) {
|
|
8943
|
+
_context2.n = 4;
|
|
8944
|
+
break;
|
|
8945
|
+
}
|
|
8946
|
+
_t = api;
|
|
8947
|
+
_context2.n = 3;
|
|
8948
|
+
return createTypeAndThenTransfer(input, this.node, this.version);
|
|
8949
|
+
case 3:
|
|
8950
|
+
_t2 = _context2.v;
|
|
8951
|
+
return _context2.a(2, _t.callTxMethod.call(_t, _t2));
|
|
8952
|
+
case 4:
|
|
8953
|
+
return _context2.a(2, defaultTx);
|
|
8844
8954
|
}
|
|
8845
|
-
},
|
|
8955
|
+
}, _callee2, this);
|
|
8846
8956
|
}));
|
|
8847
|
-
function transferPolkadotXCM(
|
|
8957
|
+
function transferPolkadotXCM(_x4) {
|
|
8848
8958
|
return _transferPolkadotXCM.apply(this, arguments);
|
|
8849
8959
|
}
|
|
8850
8960
|
return transferPolkadotXCM;
|
|
@@ -10187,11 +10297,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
10187
10297
|
key: "getTransferInfo",
|
|
10188
10298
|
value: (function () {
|
|
10189
10299
|
var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
10190
|
-
var _this$_options9, from, to, address, currency, senderAddress, feeAsset, tx;
|
|
10300
|
+
var _this$_options9, from, to, address, currency, ahAddress, senderAddress, feeAsset, tx;
|
|
10191
10301
|
return _regenerator().w(function (_context0) {
|
|
10192
10302
|
while (1) switch (_context0.n) {
|
|
10193
10303
|
case 0:
|
|
10194
|
-
_this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
|
|
10304
|
+
_this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, ahAddress = _this$_options9.ahAddress, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
|
|
10195
10305
|
assertToIsString(to);
|
|
10196
10306
|
assertAddressIsString(address);
|
|
10197
10307
|
_context0.n = 1;
|
|
@@ -10205,6 +10315,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
10205
10315
|
destination: to,
|
|
10206
10316
|
address: address,
|
|
10207
10317
|
senderAddress: senderAddress,
|
|
10318
|
+
ahAddress: ahAddress,
|
|
10208
10319
|
currency: currency,
|
|
10209
10320
|
feeAsset: feeAsset
|
|
10210
10321
|
}));
|
|
@@ -10268,6 +10379,7 @@ exports.TransferToAhNotSupported = TransferToAhNotSupported;
|
|
|
10268
10379
|
exports.UnableToComputeError = UnableToComputeError;
|
|
10269
10380
|
exports.addXcmVersionHeader = addXcmVersionHeader;
|
|
10270
10381
|
exports.assertAddressIsString = assertAddressIsString;
|
|
10382
|
+
exports.assertHasLocation = assertHasLocation;
|
|
10271
10383
|
exports.assertToIsString = assertToIsString;
|
|
10272
10384
|
exports.blake2b256 = blake2b256;
|
|
10273
10385
|
exports.blake2b512 = blake2b512;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _paraspell_sdk_common from '@paraspell/sdk-common';
|
|
|
2
2
|
import { TMultiLocation, TNodeDotKsmWithRelayChains, TNodeWithRelayChains, Version, TNodePolkadotKusama, TNode, TJunction, TEcosystemType, TJunctions } from '@paraspell/sdk-common';
|
|
3
3
|
export * from '@paraspell/sdk-common';
|
|
4
4
|
import * as _paraspell_assets from '@paraspell/assets';
|
|
5
|
-
import { TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAsset, TMultiAsset, TMultiAssetWithFee, TCurrencyCore, TAmount } from '@paraspell/assets';
|
|
5
|
+
import { TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAsset, TMultiAsset, TMultiAssetWithFee, TCurrencyCore, TAmount, TAssetWithLocation } from '@paraspell/assets';
|
|
6
6
|
export * from '@paraspell/assets';
|
|
7
7
|
import { TPallet } from '@paraspell/pallets';
|
|
8
8
|
export * from '@paraspell/pallets';
|
|
@@ -1736,6 +1736,7 @@ declare const addXcmVersionHeader: <T, V extends Version>(obj: T, version: V) =>
|
|
|
1736
1736
|
|
|
1737
1737
|
declare const assertToIsString: (to: TDestination, overrideMsg?: string) => asserts to is Exclude<TDestination, TMultiLocation>;
|
|
1738
1738
|
declare const assertAddressIsString: (address: TAddress) => asserts address is Exclude<TAddress, TMultiLocation>;
|
|
1739
|
+
declare const assertHasLocation: (asset: TAsset) => asserts asset is TAssetWithLocation;
|
|
1739
1740
|
|
|
1740
1741
|
declare const createApiInstanceForNode: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, node: TNodeDotKsmWithRelayChains) => Promise<TApi>;
|
|
1741
1742
|
|
|
@@ -1785,5 +1786,5 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
|
|
|
1785
1786
|
*/
|
|
1786
1787
|
declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
|
|
1787
1788
|
|
|
1788
|
-
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
|
1789
|
+
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertHasLocation, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
|
1789
1790
|
export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2';
|
|
2
|
-
import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset,
|
|
2
|
+
import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAsset, isTMultiAsset, getExistentialDeposit, getExistentialDepositOrThrow, isAssetEqual, findAssetOnDestOrThrow, normalizeSymbol, isSymbolMatch, hasDryRunSupport, hasSupportForAsset, extractMultiAssetLoc, isSymbolSpecifier, normalizeMultiLocation, getAssetId, getNativeAssets } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, createPublicClient, http, getContract } from 'viem';
|
|
@@ -721,6 +721,11 @@ var assertAddressIsString = function assertAddressIsString(address) {
|
|
|
721
721
|
throw new InvalidParameterError('Multi-Location address is not supported for XCM fee calculation.');
|
|
722
722
|
}
|
|
723
723
|
};
|
|
724
|
+
var assertHasLocation = function assertHasLocation(asset) {
|
|
725
|
+
if (!asset.multiLocation) {
|
|
726
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is missing multi-location"));
|
|
727
|
+
}
|
|
728
|
+
};
|
|
724
729
|
|
|
725
730
|
var AssetHubPolkadot$1 = {
|
|
726
731
|
name: "AssetHub",
|
|
@@ -3437,8 +3442,9 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
3437
3442
|
};
|
|
3438
3443
|
}();
|
|
3439
3444
|
|
|
3440
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, messageId) {
|
|
3445
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, messageId, feeAmount) {
|
|
3441
3446
|
var api = _ref.api,
|
|
3447
|
+
destination = _ref.destination,
|
|
3442
3448
|
address = _ref.address,
|
|
3443
3449
|
asset = _ref.asset,
|
|
3444
3450
|
scenario = _ref.scenario,
|
|
@@ -3448,9 +3454,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
|
|
|
3448
3454
|
if (!isForeignAsset(asset)) {
|
|
3449
3455
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
3450
3456
|
}
|
|
3451
|
-
|
|
3452
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
3453
|
-
}
|
|
3457
|
+
assertHasLocation(asset);
|
|
3454
3458
|
if (!senderAddress) {
|
|
3455
3459
|
throw new InvalidParameterError("Please provide senderAddress");
|
|
3456
3460
|
}
|
|
@@ -3472,7 +3476,41 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, origin, message
|
|
|
3472
3476
|
}]
|
|
3473
3477
|
};
|
|
3474
3478
|
return _defineProperty({}, version, [{
|
|
3475
|
-
SetAppendix: [{
|
|
3479
|
+
SetAppendix: [origin === 'Mythos' ? {
|
|
3480
|
+
DepositReserveAsset: {
|
|
3481
|
+
assets: {
|
|
3482
|
+
Wild: 'All'
|
|
3483
|
+
},
|
|
3484
|
+
dest: createDestination(scenario, version, destination, getParaId(origin), undefined, Parents.ONE),
|
|
3485
|
+
xcm: [{
|
|
3486
|
+
BuyExecution: {
|
|
3487
|
+
fees: {
|
|
3488
|
+
id: {
|
|
3489
|
+
parents: Parents.ZERO,
|
|
3490
|
+
interior: 'Here'
|
|
3491
|
+
},
|
|
3492
|
+
fun: {
|
|
3493
|
+
Fungible: feeAmount
|
|
3494
|
+
}
|
|
3495
|
+
},
|
|
3496
|
+
weight_limit: 'Unlimited'
|
|
3497
|
+
}
|
|
3498
|
+
}, {
|
|
3499
|
+
DepositAsset: {
|
|
3500
|
+
assets: {
|
|
3501
|
+
Wild: 'All'
|
|
3502
|
+
},
|
|
3503
|
+
beneficiary: createBeneficiaryMultiLocation({
|
|
3504
|
+
api: api,
|
|
3505
|
+
scenario: scenario,
|
|
3506
|
+
pallet: 'PolkadotXcm',
|
|
3507
|
+
recipientAddress: address,
|
|
3508
|
+
version: version
|
|
3509
|
+
})
|
|
3510
|
+
}
|
|
3511
|
+
}]
|
|
3512
|
+
}
|
|
3513
|
+
} : {
|
|
3476
3514
|
DepositAsset: {
|
|
3477
3515
|
assets: {
|
|
3478
3516
|
Wild: 'All'
|
|
@@ -3739,6 +3777,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3739
3777
|
messageId = _context.v;
|
|
3740
3778
|
customXcm = createCustomXcmOnDest({
|
|
3741
3779
|
api: api,
|
|
3780
|
+
destination: to,
|
|
3742
3781
|
address: address,
|
|
3743
3782
|
scenario: 'ParaToPara',
|
|
3744
3783
|
senderAddress: senderAddress,
|
|
@@ -5259,7 +5298,7 @@ var validateDestination = function validateDestination(origin, destination) {
|
|
|
5259
5298
|
if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
5260
5299
|
throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
5261
5300
|
}
|
|
5262
|
-
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam'];
|
|
5301
|
+
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
|
|
5263
5302
|
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
5264
5303
|
throw new IncompatibleNodesError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
5265
5304
|
}
|
|
@@ -5851,7 +5890,7 @@ var send = /*#__PURE__*/function () {
|
|
|
5851
5890
|
});
|
|
5852
5891
|
finalVersion = selectXcmVersion(version, originVersion, destVersion);
|
|
5853
5892
|
normalizedAsset = finalAsset.multiLocation ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
|
|
5854
|
-
|
|
5893
|
+
multiLocation: normalizeMultiLocation(finalAsset.multiLocation, finalVersion)
|
|
5855
5894
|
}) : finalAsset;
|
|
5856
5895
|
return _context.a(2, getNode(origin).transfer({
|
|
5857
5896
|
api: api,
|
|
@@ -6165,41 +6204,36 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6165
6204
|
while (1) switch (_context2.n) {
|
|
6166
6205
|
case 0:
|
|
6167
6206
|
api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress, feeAsset = input.feeAsset, paraIdTo = input.paraIdTo;
|
|
6168
|
-
|
|
6169
|
-
_context2.n = 1;
|
|
6170
|
-
break;
|
|
6171
|
-
}
|
|
6172
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6173
|
-
case 1:
|
|
6207
|
+
assertHasLocation(asset);
|
|
6174
6208
|
if (!(senderAddress === undefined)) {
|
|
6175
|
-
_context2.n =
|
|
6209
|
+
_context2.n = 1;
|
|
6176
6210
|
break;
|
|
6177
6211
|
}
|
|
6178
6212
|
throw new InvalidParameterError('Sender address is required for transfers to Ethereum');
|
|
6179
|
-
case
|
|
6213
|
+
case 1:
|
|
6180
6214
|
if (!isTMultiLocation(address)) {
|
|
6181
|
-
_context2.n =
|
|
6215
|
+
_context2.n = 2;
|
|
6182
6216
|
break;
|
|
6183
6217
|
}
|
|
6184
6218
|
throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
|
|
6185
|
-
case
|
|
6219
|
+
case 2:
|
|
6186
6220
|
ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
|
|
6187
6221
|
PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
|
|
6188
6222
|
// Pad by 25%
|
|
6189
6223
|
AH_EXECUTION_FEE_PADDED = ASSET_HUB_EXECUTION_FEE * 125n / 100n; // Perform a dry run AH -> dest to calculate the BuyExecution amount
|
|
6190
|
-
_context2.n =
|
|
6224
|
+
_context2.n = 3;
|
|
6191
6225
|
return Builder(api.clone()).from('AssetHubPolkadot').to(destination).currency({
|
|
6192
6226
|
symbol: 'DOT',
|
|
6193
6227
|
amount: AH_EXECUTION_FEE_PADDED
|
|
6194
6228
|
}).address(address).senderAddress(senderAddress).dryRun();
|
|
6195
|
-
case
|
|
6229
|
+
case 3:
|
|
6196
6230
|
dryRunResult = _context2.v;
|
|
6197
6231
|
if (dryRunResult.origin.success) {
|
|
6198
|
-
_context2.n =
|
|
6232
|
+
_context2.n = 4;
|
|
6199
6233
|
break;
|
|
6200
6234
|
}
|
|
6201
6235
|
throw new DryRunFailedError(dryRunResult.origin.failureReason);
|
|
6202
|
-
case
|
|
6236
|
+
case 4:
|
|
6203
6237
|
// Pad fee by 50%
|
|
6204
6238
|
dryRunFeePadded = BigInt(dryRunResult.origin.fee) * 3n / 2n;
|
|
6205
6239
|
dest = createDestination(scenario, version, destination, paraIdTo);
|
|
@@ -6314,32 +6348,27 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6314
6348
|
}
|
|
6315
6349
|
throw new BridgeHaltedError();
|
|
6316
6350
|
case 2:
|
|
6317
|
-
|
|
6318
|
-
_context3.n = 3;
|
|
6319
|
-
break;
|
|
6320
|
-
}
|
|
6321
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6322
|
-
case 3:
|
|
6351
|
+
assertHasLocation(asset);
|
|
6323
6352
|
if (!(senderAddress === undefined)) {
|
|
6324
|
-
_context3.n =
|
|
6353
|
+
_context3.n = 3;
|
|
6325
6354
|
break;
|
|
6326
6355
|
}
|
|
6327
6356
|
throw new InvalidParameterError('Sender address is required for transfers to Ethereum');
|
|
6328
|
-
case
|
|
6357
|
+
case 3:
|
|
6329
6358
|
if (!isTMultiLocation(address)) {
|
|
6330
|
-
_context3.n =
|
|
6359
|
+
_context3.n = 4;
|
|
6331
6360
|
break;
|
|
6332
6361
|
}
|
|
6333
6362
|
throw new InvalidParameterError('Multi-location address is not supported for Ethereum transfers');
|
|
6334
|
-
case
|
|
6363
|
+
case 4:
|
|
6335
6364
|
ethMultiAsset = createMultiAsset(version, asset.amount, asset.multiLocation);
|
|
6336
|
-
_context3.n =
|
|
6365
|
+
_context3.n = 5;
|
|
6337
6366
|
return api.createApiForNode('AssetHubPolkadot');
|
|
6338
|
-
case
|
|
6367
|
+
case 5:
|
|
6339
6368
|
ahApi = _context3.v;
|
|
6340
|
-
_context3.n =
|
|
6369
|
+
_context3.n = 6;
|
|
6341
6370
|
return getParaEthTransferFees(ahApi);
|
|
6342
|
-
case
|
|
6371
|
+
case 6:
|
|
6343
6372
|
_yield$getParaEthTran = _context3.v;
|
|
6344
6373
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
6345
6374
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
@@ -6348,13 +6377,13 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6348
6377
|
fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : (bridgeFee + executionFee).toString();
|
|
6349
6378
|
ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
|
|
6350
6379
|
if (ethAsset) {
|
|
6351
|
-
_context3.n =
|
|
6380
|
+
_context3.n = 7;
|
|
6352
6381
|
break;
|
|
6353
6382
|
}
|
|
6354
6383
|
throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
|
|
6355
|
-
case
|
|
6384
|
+
case 7:
|
|
6356
6385
|
if (!useOnlyDepositInstruction) {
|
|
6357
|
-
_context3.n =
|
|
6386
|
+
_context3.n = 8;
|
|
6358
6387
|
break;
|
|
6359
6388
|
}
|
|
6360
6389
|
customXcmOnDest = addXcmVersionHeader([{
|
|
@@ -6373,21 +6402,21 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6373
6402
|
})
|
|
6374
6403
|
}
|
|
6375
6404
|
}], version);
|
|
6376
|
-
_context3.n =
|
|
6405
|
+
_context3.n = 11;
|
|
6377
6406
|
break;
|
|
6378
|
-
case
|
|
6407
|
+
case 8:
|
|
6379
6408
|
if (ethAsset.assetId) {
|
|
6380
|
-
_context3.n =
|
|
6409
|
+
_context3.n = 9;
|
|
6381
6410
|
break;
|
|
6382
6411
|
}
|
|
6383
6412
|
throw new InvalidCurrencyError("Ethereum asset ".concat(JSON.stringify(ethAsset), " has no assetId"));
|
|
6384
|
-
case
|
|
6385
|
-
_context3.n =
|
|
6413
|
+
case 9:
|
|
6414
|
+
_context3.n = 10;
|
|
6386
6415
|
return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
|
|
6387
|
-
case
|
|
6416
|
+
case 10:
|
|
6388
6417
|
messageId = _context3.v;
|
|
6389
6418
|
customXcmOnDest = createCustomXcmOnDest(input, this.node, messageId);
|
|
6390
|
-
case
|
|
6419
|
+
case 11:
|
|
6391
6420
|
call = {
|
|
6392
6421
|
module: 'PolkadotXcm',
|
|
6393
6422
|
method: 'transfer_assets_using_type_and_then',
|
|
@@ -6723,9 +6752,7 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight,
|
|
|
6723
6752
|
version: version,
|
|
6724
6753
|
paraId: paraIdTo
|
|
6725
6754
|
});
|
|
6726
|
-
|
|
6727
|
-
throw new InvalidParameterError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
6728
|
-
}
|
|
6755
|
+
assertHasLocation(asset);
|
|
6729
6756
|
var transformedMultiLocation = transformMultiLocation(asset.multiLocation);
|
|
6730
6757
|
var call = {
|
|
6731
6758
|
module: 'PolkadotXcm',
|
|
@@ -7018,9 +7045,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7018
7045
|
if (!isForeignAsset(asset)) {
|
|
7019
7046
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
7020
7047
|
}
|
|
7021
|
-
|
|
7022
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
7023
|
-
}
|
|
7048
|
+
assertHasLocation(asset);
|
|
7024
7049
|
var PARA_TO_PARA_FEE_DOT = 500000000n; // 0.5 DOT
|
|
7025
7050
|
var call = {
|
|
7026
7051
|
module: 'PolkadotXcm',
|
|
@@ -7111,15 +7136,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7111
7136
|
}
|
|
7112
7137
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
7113
7138
|
case 5:
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
break;
|
|
7117
|
-
}
|
|
7118
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
7119
|
-
case 6:
|
|
7120
|
-
_context.n = 7;
|
|
7139
|
+
assertHasLocation(asset);
|
|
7140
|
+
_context.n = 6;
|
|
7121
7141
|
return generateMessageId(api, senderAddress, getParaId(this.node), JSON.stringify(asset.multiLocation), address, asset.amount);
|
|
7122
|
-
case
|
|
7142
|
+
case 6:
|
|
7123
7143
|
messageId = _context.v;
|
|
7124
7144
|
multiLocation = asset.symbol === this.getNativeAssetSymbol() ? DOT_MULTILOCATION : asset.multiLocation;
|
|
7125
7145
|
call = {
|
|
@@ -7186,18 +7206,13 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
7186
7206
|
}
|
|
7187
7207
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
7188
7208
|
case 3:
|
|
7189
|
-
|
|
7190
|
-
_context2.n = 4;
|
|
7191
|
-
break;
|
|
7192
|
-
}
|
|
7193
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
7194
|
-
case 4:
|
|
7209
|
+
assertHasLocation(asset);
|
|
7195
7210
|
if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === getNativeAssetSymbol('Kusama'))) {
|
|
7196
|
-
_context2.n =
|
|
7211
|
+
_context2.n = 4;
|
|
7197
7212
|
break;
|
|
7198
7213
|
}
|
|
7199
7214
|
return _context2.a(2, this.handleEthBridgeNativeTransfer(input));
|
|
7200
|
-
case
|
|
7215
|
+
case 4:
|
|
7201
7216
|
modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
7202
7217
|
destLocation: createDestination(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
|
|
7203
7218
|
beneficiaryLocation: createBeneficiary({
|
|
@@ -8174,7 +8189,7 @@ var createTypeAndThenDest = function createTypeAndThenDest(destination, scenario
|
|
|
8174
8189
|
})
|
|
8175
8190
|
};
|
|
8176
8191
|
};
|
|
8177
|
-
var createTypeAndThenTransfer = function createTypeAndThenTransfer(_ref, version) {
|
|
8192
|
+
var createTypeAndThenTransfer$1 = function createTypeAndThenTransfer(_ref, version) {
|
|
8178
8193
|
var api = _ref.api,
|
|
8179
8194
|
asset = _ref.asset,
|
|
8180
8195
|
address = _ref.address,
|
|
@@ -8263,7 +8278,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8263
8278
|
_context.n = 1;
|
|
8264
8279
|
break;
|
|
8265
8280
|
}
|
|
8266
|
-
_call = createTypeAndThenTransfer(input, version);
|
|
8281
|
+
_call = createTypeAndThenTransfer$1(input, version);
|
|
8267
8282
|
return _context.a(2, api.callTxMethod(_call));
|
|
8268
8283
|
case 1:
|
|
8269
8284
|
if (!(scenario === 'ParaToPara' && (destination === 'AssetHubPolkadot' || destination === 'Hydration'))) {
|
|
@@ -8278,7 +8293,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8278
8293
|
}
|
|
8279
8294
|
throw new ScenarioNotSupportedError(this.node, scenario);
|
|
8280
8295
|
case 3:
|
|
8281
|
-
call = createTypeAndThenTransfer(input, version, 'Teleport');
|
|
8296
|
+
call = createTypeAndThenTransfer$1(input, version, 'Teleport');
|
|
8282
8297
|
return _context.a(2, api.callTxMethod(call));
|
|
8283
8298
|
}
|
|
8284
8299
|
}, _callee, this);
|
|
@@ -8293,7 +8308,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8293
8308
|
value: function transferRelayToPara(options) {
|
|
8294
8309
|
var _options$version = options.version,
|
|
8295
8310
|
version = _options$version === void 0 ? this.version : _options$version;
|
|
8296
|
-
var call = createTypeAndThenTransfer(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8311
|
+
var call = createTypeAndThenTransfer$1(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8297
8312
|
scenario: 'RelayToPara'
|
|
8298
8313
|
}), version, 'Teleport');
|
|
8299
8314
|
return call;
|
|
@@ -8387,7 +8402,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8387
8402
|
version = _options$version === void 0 ? this.version : _options$version;
|
|
8388
8403
|
var symbol = asset.symbol.toUpperCase();
|
|
8389
8404
|
if (symbol === 'DOT') {
|
|
8390
|
-
var call = createTypeAndThenTransfer(options, version);
|
|
8405
|
+
var call = createTypeAndThenTransfer$1(options, version);
|
|
8391
8406
|
return Promise.resolve(api.callTxMethod(call));
|
|
8392
8407
|
}
|
|
8393
8408
|
if ((symbol === 'USDC' || symbol === 'USDT') && !hasJunction(asset.multiLocation, 'Parachain', getParaId('AssetHubPolkadot'))) {
|
|
@@ -8696,9 +8711,7 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8696
8711
|
}
|
|
8697
8712
|
}
|
|
8698
8713
|
};
|
|
8699
|
-
|
|
8700
|
-
throw new InvalidCurrencyError('throw new InvalidCurrencyError(`Asset ${JSON.stringify(asset)} has no assetId`)');
|
|
8701
|
-
}
|
|
8714
|
+
assertHasLocation(asset);
|
|
8702
8715
|
return asset.multiLocation;
|
|
8703
8716
|
}
|
|
8704
8717
|
}, {
|
|
@@ -8768,9 +8781,7 @@ var Moonriver = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8768
8781
|
}
|
|
8769
8782
|
}
|
|
8770
8783
|
};
|
|
8771
|
-
|
|
8772
|
-
throw new InvalidCurrencyError('throw new InvalidCurrencyError(`Asset ${JSON.stringify(asset)} has no multiLocation`)');
|
|
8773
|
-
}
|
|
8784
|
+
assertHasLocation(asset);
|
|
8774
8785
|
return asset.multiLocation;
|
|
8775
8786
|
}
|
|
8776
8787
|
}, {
|
|
@@ -8801,6 +8812,94 @@ var Moonriver = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8801
8812
|
}]);
|
|
8802
8813
|
}(ParachainNode);
|
|
8803
8814
|
|
|
8815
|
+
var createTypeAndThenTransfer = /*#__PURE__*/function () {
|
|
8816
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, node, version) {
|
|
8817
|
+
var api, scenario, asset, currency, senderAddress, address, destination, messageId, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, feeConverted, nativeMythAmount, nativeMythBalance;
|
|
8818
|
+
return _regenerator().w(function (_context) {
|
|
8819
|
+
while (1) switch (_context.n) {
|
|
8820
|
+
case 0:
|
|
8821
|
+
api = options.api, scenario = options.scenario, asset = options.asset, currency = options.currency, senderAddress = options.senderAddress, address = options.address, destination = options.destination;
|
|
8822
|
+
assertHasLocation(asset);
|
|
8823
|
+
assertAddressIsString(address);
|
|
8824
|
+
if (senderAddress) {
|
|
8825
|
+
_context.n = 1;
|
|
8826
|
+
break;
|
|
8827
|
+
}
|
|
8828
|
+
throw new InvalidCurrencyError("Sender address is required for Mythos transfer");
|
|
8829
|
+
case 1:
|
|
8830
|
+
if (!(!isForeignAsset(asset) || !asset.assetId)) {
|
|
8831
|
+
_context.n = 2;
|
|
8832
|
+
break;
|
|
8833
|
+
}
|
|
8834
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, replaceBigInt), " is not a foreign asset"));
|
|
8835
|
+
case 2:
|
|
8836
|
+
_context.n = 3;
|
|
8837
|
+
return generateMessageId(api, senderAddress, getParaId(node), asset.assetId, address, asset.amount);
|
|
8838
|
+
case 3:
|
|
8839
|
+
messageId = _context.v;
|
|
8840
|
+
ahApi = api.clone();
|
|
8841
|
+
_context.n = 4;
|
|
8842
|
+
return ahApi.init('AssetHubPolkadot');
|
|
8843
|
+
case 4:
|
|
8844
|
+
_context.n = 5;
|
|
8845
|
+
return getParaEthTransferFees(ahApi);
|
|
8846
|
+
case 5:
|
|
8847
|
+
_yield$getParaEthTran = _context.v;
|
|
8848
|
+
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
8849
|
+
bridgeFee = _yield$getParaEthTran2[0];
|
|
8850
|
+
ahExecutionFee = _yield$getParaEthTran2[1];
|
|
8851
|
+
_context.n = 6;
|
|
8852
|
+
return ahApi.quoteAhPrice(DOT_MULTILOCATION, getNativeAssets(node)[0].multiLocation, bridgeFee + ahExecutionFee);
|
|
8853
|
+
case 6:
|
|
8854
|
+
feeConverted = _context.v;
|
|
8855
|
+
if (feeConverted) {
|
|
8856
|
+
_context.n = 7;
|
|
8857
|
+
break;
|
|
8858
|
+
}
|
|
8859
|
+
throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
|
|
8860
|
+
case 7:
|
|
8861
|
+
nativeMythAmount = padFeeBy(feeConverted, 10);
|
|
8862
|
+
_context.n = 8;
|
|
8863
|
+
return getAssetBalanceInternal({
|
|
8864
|
+
api: api,
|
|
8865
|
+
address: senderAddress,
|
|
8866
|
+
node: node,
|
|
8867
|
+
currency: currency
|
|
8868
|
+
});
|
|
8869
|
+
case 8:
|
|
8870
|
+
nativeMythBalance = _context.v;
|
|
8871
|
+
if (!(nativeMythBalance - nativeMythAmount < 0)) {
|
|
8872
|
+
_context.n = 9;
|
|
8873
|
+
break;
|
|
8874
|
+
}
|
|
8875
|
+
throw new InvalidCurrencyError("Insufficient balance. Fee: ".concat(nativeMythAmount, ", Amount: ").concat(asset.amount));
|
|
8876
|
+
case 9:
|
|
8877
|
+
return _context.a(2, {
|
|
8878
|
+
module: 'PolkadotXcm',
|
|
8879
|
+
method: 'transfer_assets_using_type_and_then',
|
|
8880
|
+
parameters: {
|
|
8881
|
+
dest: createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
|
|
8882
|
+
assets: _defineProperty({}, version, [createMultiAsset(version, nativeMythAmount, {
|
|
8883
|
+
parents: Parents.ZERO,
|
|
8884
|
+
interior: 'Here'
|
|
8885
|
+
}), createMultiAsset(version, asset.amount, asset.multiLocation)]),
|
|
8886
|
+
assets_transfer_type: 'DestinationReserve',
|
|
8887
|
+
remote_fees_id: _defineProperty({}, version, {
|
|
8888
|
+
parents: Parents.ZERO,
|
|
8889
|
+
interior: 'Here'
|
|
8890
|
+
}),
|
|
8891
|
+
fees_transfer_type: 'Teleport',
|
|
8892
|
+
custom_xcm_on_dest: createCustomXcmOnDest(options, node, messageId, nativeMythAmount),
|
|
8893
|
+
weight_limit: 'Unlimited'
|
|
8894
|
+
}
|
|
8895
|
+
});
|
|
8896
|
+
}
|
|
8897
|
+
}, _callee);
|
|
8898
|
+
}));
|
|
8899
|
+
return function createTypeAndThenTransfer(_x, _x2, _x3) {
|
|
8900
|
+
return _ref.apply(this, arguments);
|
|
8901
|
+
};
|
|
8902
|
+
}();
|
|
8804
8903
|
var Mythos = /*#__PURE__*/function (_ParachainNode) {
|
|
8805
8904
|
function Mythos() {
|
|
8806
8905
|
_classCallCheck(this, Mythos);
|
|
@@ -8825,27 +8924,38 @@ var Mythos = /*#__PURE__*/function (_ParachainNode) {
|
|
|
8825
8924
|
}, {
|
|
8826
8925
|
key: "transferPolkadotXCM",
|
|
8827
8926
|
value: function () {
|
|
8828
|
-
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
8829
|
-
var destination, defaultTx;
|
|
8830
|
-
return _regenerator().w(function (
|
|
8831
|
-
while (1) switch (
|
|
8927
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
8928
|
+
var api, destination, defaultTx, _t, _t2;
|
|
8929
|
+
return _regenerator().w(function (_context2) {
|
|
8930
|
+
while (1) switch (_context2.n) {
|
|
8832
8931
|
case 0:
|
|
8833
|
-
destination = input.destination;
|
|
8834
|
-
|
|
8932
|
+
api = input.api, destination = input.destination;
|
|
8933
|
+
_context2.n = 1;
|
|
8835
8934
|
return this.createTx(input);
|
|
8836
8935
|
case 1:
|
|
8837
|
-
defaultTx =
|
|
8936
|
+
defaultTx = _context2.v;
|
|
8838
8937
|
if (!(destination === 'AssetHubPolkadot')) {
|
|
8839
|
-
|
|
8938
|
+
_context2.n = 2;
|
|
8840
8939
|
break;
|
|
8841
8940
|
}
|
|
8842
|
-
return
|
|
8941
|
+
return _context2.a(2, handleToAhTeleport('Mythos', input, defaultTx));
|
|
8843
8942
|
case 2:
|
|
8844
|
-
|
|
8943
|
+
if (!(destination == 'Ethereum')) {
|
|
8944
|
+
_context2.n = 4;
|
|
8945
|
+
break;
|
|
8946
|
+
}
|
|
8947
|
+
_t = api;
|
|
8948
|
+
_context2.n = 3;
|
|
8949
|
+
return createTypeAndThenTransfer(input, this.node, this.version);
|
|
8950
|
+
case 3:
|
|
8951
|
+
_t2 = _context2.v;
|
|
8952
|
+
return _context2.a(2, _t.callTxMethod.call(_t, _t2));
|
|
8953
|
+
case 4:
|
|
8954
|
+
return _context2.a(2, defaultTx);
|
|
8845
8955
|
}
|
|
8846
|
-
},
|
|
8956
|
+
}, _callee2, this);
|
|
8847
8957
|
}));
|
|
8848
|
-
function transferPolkadotXCM(
|
|
8958
|
+
function transferPolkadotXCM(_x4) {
|
|
8849
8959
|
return _transferPolkadotXCM.apply(this, arguments);
|
|
8850
8960
|
}
|
|
8851
8961
|
return transferPolkadotXCM;
|
|
@@ -10188,11 +10298,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
10188
10298
|
key: "getTransferInfo",
|
|
10189
10299
|
value: (function () {
|
|
10190
10300
|
var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
10191
|
-
var _this$_options9, from, to, address, currency, senderAddress, feeAsset, tx;
|
|
10301
|
+
var _this$_options9, from, to, address, currency, ahAddress, senderAddress, feeAsset, tx;
|
|
10192
10302
|
return _regenerator().w(function (_context0) {
|
|
10193
10303
|
while (1) switch (_context0.n) {
|
|
10194
10304
|
case 0:
|
|
10195
|
-
_this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
|
|
10305
|
+
_this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, ahAddress = _this$_options9.ahAddress, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
|
|
10196
10306
|
assertToIsString(to);
|
|
10197
10307
|
assertAddressIsString(address);
|
|
10198
10308
|
_context0.n = 1;
|
|
@@ -10206,6 +10316,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
10206
10316
|
destination: to,
|
|
10207
10317
|
address: address,
|
|
10208
10318
|
senderAddress: senderAddress,
|
|
10319
|
+
ahAddress: ahAddress,
|
|
10209
10320
|
currency: currency,
|
|
10210
10321
|
feeAsset: feeAsset
|
|
10211
10322
|
}));
|
|
@@ -10250,4 +10361,4 @@ var Builder = function Builder(api) {
|
|
|
10250
10361
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
10251
10362
|
};
|
|
10252
10363
|
|
|
10253
|
-
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
|
10364
|
+
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertHasLocation, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0",
|
|
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/assets": "10.
|
|
30
|
-
"@paraspell/pallets": "10.
|
|
31
|
-
"@paraspell/sdk-common": "10.
|
|
29
|
+
"@paraspell/assets": "10.6.0",
|
|
30
|
+
"@paraspell/pallets": "10.6.0",
|
|
31
|
+
"@paraspell/sdk-common": "10.6.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|