@paraspell/sdk 11.14.3 → 11.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +165 -418
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +166 -419
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidParameterError, isConfig, BatchMode, getChainProviders, MissingChainApiError, Parents, Version,
|
|
1
|
+
import { InvalidParameterError, isConfig, InvalidAddressError, BatchMode, getChainProviders, MissingChainApiError, Parents, Version, computeFeeFromDryRun, findNativeAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, ChainNotSupportedError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, padValueBy, isRelayChain, isAssetEqual, createChainClient as createChainClient$1, getBalanceNative as getBalanceNative$1, getBalance, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { blake2b } from '@noble/hashes/blake2';
|
|
4
4
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
@@ -313,7 +313,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'Pendulum'];
|
|
316
|
+
var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'RobonomicsPolkadot', 'Pendulum'];
|
|
317
317
|
// Cache settings
|
|
318
318
|
var DEFAULT_TTL_MS = 60000; // 1 minute
|
|
319
319
|
var MAX_CLIENTS = 100;
|
|
@@ -402,6 +402,11 @@ var _transform = function transform(obj) {
|
|
|
402
402
|
type: key,
|
|
403
403
|
value: value
|
|
404
404
|
};
|
|
405
|
+
} else if (key === 'Substrate') {
|
|
406
|
+
return {
|
|
407
|
+
type: key,
|
|
408
|
+
value: value
|
|
409
|
+
};
|
|
405
410
|
} else if (key === 'OtherReserve') {
|
|
406
411
|
return {
|
|
407
412
|
type: key,
|
|
@@ -414,11 +419,16 @@ var _transform = function transform(obj) {
|
|
|
414
419
|
type: 'polkadot' in value ? 'Polkadot' : 'Kusama'
|
|
415
420
|
}
|
|
416
421
|
};
|
|
417
|
-
} else if (key === 'PalletInstance'
|
|
422
|
+
} else if (key === 'PalletInstance') {
|
|
418
423
|
return {
|
|
419
424
|
type: key,
|
|
420
425
|
value: value
|
|
421
426
|
};
|
|
427
|
+
} else if (key === 'GeneralIndex') {
|
|
428
|
+
return {
|
|
429
|
+
type: key,
|
|
430
|
+
value: BigInt(value)
|
|
431
|
+
};
|
|
422
432
|
} else if (key === 'Ethereum') {
|
|
423
433
|
return {
|
|
424
434
|
type: key,
|
|
@@ -882,18 +892,42 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
882
892
|
value: function accountToUint8a(address) {
|
|
883
893
|
var result = getSs58AddressInfo(address);
|
|
884
894
|
if (!result.isValid) {
|
|
885
|
-
throw new
|
|
895
|
+
throw new InvalidAddressError("Invalid address: ".concat(address));
|
|
886
896
|
}
|
|
887
897
|
return result.publicKey;
|
|
888
898
|
}
|
|
889
899
|
}, {
|
|
890
|
-
key: "
|
|
891
|
-
value: function
|
|
900
|
+
key: "validateSubstrateAddress",
|
|
901
|
+
value: function validateSubstrateAddress(address) {
|
|
902
|
+
var result = getSs58AddressInfo(address);
|
|
903
|
+
return result.isValid;
|
|
904
|
+
}
|
|
905
|
+
}, {
|
|
906
|
+
key: "deserializeExtrinsics",
|
|
907
|
+
value: function deserializeExtrinsics(_ref5) {
|
|
892
908
|
var module = _ref5.module,
|
|
893
909
|
method = _ref5.method,
|
|
894
|
-
|
|
895
|
-
var
|
|
896
|
-
return this.api.getUnsafeApi().tx[module][method](
|
|
910
|
+
params = _ref5.params;
|
|
911
|
+
var transformedParams = _transform(params);
|
|
912
|
+
return this.api.getUnsafeApi().tx[module][method](transformedParams);
|
|
913
|
+
}
|
|
914
|
+
}, {
|
|
915
|
+
key: "queryState",
|
|
916
|
+
value: function queryState(_ref6) {
|
|
917
|
+
var _this$api$getUnsafeAp;
|
|
918
|
+
var module = _ref6.module,
|
|
919
|
+
method = _ref6.method,
|
|
920
|
+
params = _ref6.params;
|
|
921
|
+
return (_this$api$getUnsafeAp = this.api.getUnsafeApi().query[module][method]).getValue.apply(_this$api$getUnsafeAp, _toConsumableArray(params.map(_transform)));
|
|
922
|
+
}
|
|
923
|
+
}, {
|
|
924
|
+
key: "queryRuntimeApi",
|
|
925
|
+
value: function queryRuntimeApi(_ref7) {
|
|
926
|
+
var _this$api$getUnsafeAp2;
|
|
927
|
+
var module = _ref7.module,
|
|
928
|
+
method = _ref7.method,
|
|
929
|
+
params = _ref7.params;
|
|
930
|
+
return (_this$api$getUnsafeAp2 = this.api.getUnsafeApi().apis[module])[method].apply(_this$api$getUnsafeAp2, _toConsumableArray(params.map(_transform)));
|
|
897
931
|
}
|
|
898
932
|
}, {
|
|
899
933
|
key: "callBatchMethod",
|
|
@@ -1065,287 +1099,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1065
1099
|
value: function getEvmStorage(contract, slot) {
|
|
1066
1100
|
return this.api.getUnsafeApi().query.EVM.AccountStorages.getKey(FixedSizeBinary.fromHex(contract), FixedSizeBinary.fromHex(slot));
|
|
1067
1101
|
}
|
|
1068
|
-
}, {
|
|
1069
|
-
key: "getBalanceNative",
|
|
1070
|
-
value: function () {
|
|
1071
|
-
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(address) {
|
|
1072
|
-
var res;
|
|
1073
|
-
return _regenerator().w(function (_context7) {
|
|
1074
|
-
while (1) switch (_context7.n) {
|
|
1075
|
-
case 0:
|
|
1076
|
-
_context7.n = 1;
|
|
1077
|
-
return this.api.getUnsafeApi().query.System.Account.getValue(address);
|
|
1078
|
-
case 1:
|
|
1079
|
-
res = _context7.v;
|
|
1080
|
-
return _context7.a(2, res.data.free);
|
|
1081
|
-
}
|
|
1082
|
-
}, _callee7, this);
|
|
1083
|
-
}));
|
|
1084
|
-
function getBalanceNative(_x10) {
|
|
1085
|
-
return _getBalanceNative.apply(this, arguments);
|
|
1086
|
-
}
|
|
1087
|
-
return getBalanceNative;
|
|
1088
|
-
}()
|
|
1089
|
-
}, {
|
|
1090
|
-
key: "getBalanceForeignPolkadotXcm",
|
|
1091
|
-
value: function () {
|
|
1092
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(chain, address, asset) {
|
|
1093
|
-
var _res, res;
|
|
1094
|
-
return _regenerator().w(function (_context8) {
|
|
1095
|
-
while (1) switch (_context8.n) {
|
|
1096
|
-
case 0:
|
|
1097
|
-
if (!chain.startsWith('Kilt')) {
|
|
1098
|
-
_context8.n = 2;
|
|
1099
|
-
break;
|
|
1100
|
-
}
|
|
1101
|
-
assertHasLocation(asset);
|
|
1102
|
-
_context8.n = 1;
|
|
1103
|
-
return this.api.getUnsafeApi().query.Fungibles.Account.getValue(_transform(asset.location), address);
|
|
1104
|
-
case 1:
|
|
1105
|
-
_res = _context8.v;
|
|
1106
|
-
return _context8.a(2, _res && _res.balance ? BigInt(_res.balance) : 0n);
|
|
1107
|
-
case 2:
|
|
1108
|
-
assertHasId(asset);
|
|
1109
|
-
_context8.n = 3;
|
|
1110
|
-
return this.api.getUnsafeApi().query.Assets.Account.getValue(chain.startsWith('NeuroWeb') ? BigInt(asset.assetId) : asset.assetId, address);
|
|
1111
|
-
case 3:
|
|
1112
|
-
res = _context8.v;
|
|
1113
|
-
return _context8.a(2, res && res.balance ? BigInt(res.balance) : 0n);
|
|
1114
|
-
}
|
|
1115
|
-
}, _callee8, this);
|
|
1116
|
-
}));
|
|
1117
|
-
function getBalanceForeignPolkadotXcm(_x11, _x12, _x13) {
|
|
1118
|
-
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
1119
|
-
}
|
|
1120
|
-
return getBalanceForeignPolkadotXcm;
|
|
1121
|
-
}()
|
|
1122
|
-
}, {
|
|
1123
|
-
key: "getMythosForeignBalance",
|
|
1124
|
-
value: function () {
|
|
1125
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
|
|
1126
|
-
var res;
|
|
1127
|
-
return _regenerator().w(function (_context9) {
|
|
1128
|
-
while (1) switch (_context9.n) {
|
|
1129
|
-
case 0:
|
|
1130
|
-
_context9.n = 1;
|
|
1131
|
-
return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
|
|
1132
|
-
case 1:
|
|
1133
|
-
res = _context9.v;
|
|
1134
|
-
return _context9.a(2, res && res.free ? BigInt(res.free) : 0n);
|
|
1135
|
-
}
|
|
1136
|
-
}, _callee9, this);
|
|
1137
|
-
}));
|
|
1138
|
-
function getMythosForeignBalance(_x14) {
|
|
1139
|
-
return _getMythosForeignBalance.apply(this, arguments);
|
|
1140
|
-
}
|
|
1141
|
-
return getMythosForeignBalance;
|
|
1142
|
-
}()
|
|
1143
|
-
}, {
|
|
1144
|
-
key: "getBalanceForeignAssetsPallet",
|
|
1145
|
-
value: function () {
|
|
1146
|
-
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, location) {
|
|
1147
|
-
var transformedLocation, res;
|
|
1148
|
-
return _regenerator().w(function (_context0) {
|
|
1149
|
-
while (1) switch (_context0.n) {
|
|
1150
|
-
case 0:
|
|
1151
|
-
transformedLocation = _transform(location);
|
|
1152
|
-
_context0.n = 1;
|
|
1153
|
-
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedLocation, address);
|
|
1154
|
-
case 1:
|
|
1155
|
-
res = _context0.v;
|
|
1156
|
-
return _context0.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1157
|
-
}
|
|
1158
|
-
}, _callee0, this);
|
|
1159
|
-
}));
|
|
1160
|
-
function getBalanceForeignAssetsPallet(_x15, _x16) {
|
|
1161
|
-
return _getBalanceForeignAssetsPallet.apply(this, arguments);
|
|
1162
|
-
}
|
|
1163
|
-
return getBalanceForeignAssetsPallet;
|
|
1164
|
-
}()
|
|
1165
|
-
}, {
|
|
1166
|
-
key: "getForeignAssetsByIdBalance",
|
|
1167
|
-
value: function () {
|
|
1168
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address, assetId) {
|
|
1169
|
-
var res;
|
|
1170
|
-
return _regenerator().w(function (_context1) {
|
|
1171
|
-
while (1) switch (_context1.n) {
|
|
1172
|
-
case 0:
|
|
1173
|
-
_context1.n = 1;
|
|
1174
|
-
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
|
|
1175
|
-
case 1:
|
|
1176
|
-
res = _context1.v;
|
|
1177
|
-
return _context1.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1178
|
-
}
|
|
1179
|
-
}, _callee1, this);
|
|
1180
|
-
}));
|
|
1181
|
-
function getForeignAssetsByIdBalance(_x17, _x18) {
|
|
1182
|
-
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
1183
|
-
}
|
|
1184
|
-
return getForeignAssetsByIdBalance;
|
|
1185
|
-
}()
|
|
1186
|
-
}, {
|
|
1187
|
-
key: "getBalanceForeignBifrost",
|
|
1188
|
-
value: function () {
|
|
1189
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, asset) {
|
|
1190
|
-
var currencySelection, transformedParameters, response, accountData;
|
|
1191
|
-
return _regenerator().w(function (_context10) {
|
|
1192
|
-
while (1) switch (_context10.n) {
|
|
1193
|
-
case 0:
|
|
1194
|
-
currencySelection = getChain('BifrostPolkadot').getCurrencySelection(asset);
|
|
1195
|
-
transformedParameters = _transform(currencySelection);
|
|
1196
|
-
_context10.n = 1;
|
|
1197
|
-
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1198
|
-
case 1:
|
|
1199
|
-
response = _context10.v;
|
|
1200
|
-
accountData = response ? response : null;
|
|
1201
|
-
return _context10.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1202
|
-
}
|
|
1203
|
-
}, _callee10, this);
|
|
1204
|
-
}));
|
|
1205
|
-
function getBalanceForeignBifrost(_x19, _x20) {
|
|
1206
|
-
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
1207
|
-
}
|
|
1208
|
-
return getBalanceForeignBifrost;
|
|
1209
|
-
}()
|
|
1210
|
-
}, {
|
|
1211
|
-
key: "getBalanceNativeAcala",
|
|
1212
|
-
value: function () {
|
|
1213
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, symbol) {
|
|
1214
|
-
var transformedParameters, response, accountData;
|
|
1215
|
-
return _regenerator().w(function (_context11) {
|
|
1216
|
-
while (1) switch (_context11.n) {
|
|
1217
|
-
case 0:
|
|
1218
|
-
transformedParameters = _transform({
|
|
1219
|
-
Token: symbol
|
|
1220
|
-
});
|
|
1221
|
-
_context11.n = 1;
|
|
1222
|
-
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1223
|
-
case 1:
|
|
1224
|
-
response = _context11.v;
|
|
1225
|
-
accountData = response ? response : null;
|
|
1226
|
-
return _context11.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1227
|
-
}
|
|
1228
|
-
}, _callee11, this);
|
|
1229
|
-
}));
|
|
1230
|
-
function getBalanceNativeAcala(_x21, _x22) {
|
|
1231
|
-
return _getBalanceNativeAcala.apply(this, arguments);
|
|
1232
|
-
}
|
|
1233
|
-
return getBalanceNativeAcala;
|
|
1234
|
-
}()
|
|
1235
|
-
}, {
|
|
1236
|
-
key: "getBalanceForeignXTokens",
|
|
1237
|
-
value: function () {
|
|
1238
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, address, asset) {
|
|
1239
|
-
var pallet, _response, unsafeApi, collectionId, balance, _response2, response, entry;
|
|
1240
|
-
return _regenerator().w(function (_context12) {
|
|
1241
|
-
while (1) switch (_context12.n) {
|
|
1242
|
-
case 0:
|
|
1243
|
-
pallet = 'Tokens';
|
|
1244
|
-
if (chain === 'Centrifuge' || chain === 'Altair') {
|
|
1245
|
-
pallet = 'OrmlTokens';
|
|
1246
|
-
}
|
|
1247
|
-
if (!(chain === 'Peaq' || chain === 'Manta' || chain === 'Crust' || chain === 'Ajuna')) {
|
|
1248
|
-
_context12.n = 2;
|
|
1249
|
-
break;
|
|
1250
|
-
}
|
|
1251
|
-
assertHasId(asset);
|
|
1252
|
-
_context12.n = 1;
|
|
1253
|
-
return this.api.getUnsafeApi().query.Assets.Account.getValue(chain === 'Manta' || chain === 'Crust' ? BigInt(asset.assetId) : asset.assetId, address);
|
|
1254
|
-
case 1:
|
|
1255
|
-
_response = _context12.v;
|
|
1256
|
-
return _context12.a(2, _response ? BigInt(_response.free.toString()) : 0n);
|
|
1257
|
-
case 2:
|
|
1258
|
-
if (!(chain === 'Unique')) {
|
|
1259
|
-
_context12.n = 5;
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
assertHasLocation(asset);
|
|
1263
|
-
assertHasId(asset);
|
|
1264
|
-
unsafeApi = this.api.getUnsafeApi();
|
|
1265
|
-
_context12.n = 3;
|
|
1266
|
-
return unsafeApi.query.ForeignAssets.ForeignAssetToCollection.getValue(_transform(asset.location));
|
|
1267
|
-
case 3:
|
|
1268
|
-
collectionId = _context12.v;
|
|
1269
|
-
_context12.n = 4;
|
|
1270
|
-
return unsafeApi.apis.UniqueApi.balance(collectionId, {
|
|
1271
|
-
type: 'Substrate',
|
|
1272
|
-
value: address
|
|
1273
|
-
}, asset.assetId);
|
|
1274
|
-
case 4:
|
|
1275
|
-
balance = _context12.v;
|
|
1276
|
-
return _context12.a(2, balance.success ? BigInt(balance.value) : 0n);
|
|
1277
|
-
case 5:
|
|
1278
|
-
if (!(chain === 'Hydration')) {
|
|
1279
|
-
_context12.n = 7;
|
|
1280
|
-
break;
|
|
1281
|
-
}
|
|
1282
|
-
assertHasId(asset);
|
|
1283
|
-
_context12.n = 6;
|
|
1284
|
-
return this.api.getUnsafeApi().apis.CurrenciesApi.account(asset.assetId, address);
|
|
1285
|
-
case 6:
|
|
1286
|
-
_response2 = _context12.v;
|
|
1287
|
-
return _context12.a(2, _response2 ? BigInt(_response2.free.toString()) : 0n);
|
|
1288
|
-
case 7:
|
|
1289
|
-
_context12.n = 8;
|
|
1290
|
-
return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
|
|
1291
|
-
case 8:
|
|
1292
|
-
response = _context12.v;
|
|
1293
|
-
entry = response.find(function (_ref6) {
|
|
1294
|
-
var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$symbol3, _asset$assetId2;
|
|
1295
|
-
var keyArgs = _ref6.keyArgs;
|
|
1296
|
-
var _keyArgs = _slicedToArray(keyArgs, 2);
|
|
1297
|
-
_keyArgs[0];
|
|
1298
|
-
var assetItem = _keyArgs[1];
|
|
1299
|
-
return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.type && assetItem.value.type.toString().toLowerCase() === ((_asset$symbol3 = asset.symbol) === null || _asset$symbol3 === void 0 ? void 0 : _asset$symbol3.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
1300
|
-
});
|
|
1301
|
-
return _context12.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
|
|
1302
|
-
}
|
|
1303
|
-
}, _callee12, this);
|
|
1304
|
-
}));
|
|
1305
|
-
function getBalanceForeignXTokens(_x23, _x24, _x25) {
|
|
1306
|
-
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1307
|
-
}
|
|
1308
|
-
return getBalanceForeignXTokens;
|
|
1309
|
-
}()
|
|
1310
|
-
}, {
|
|
1311
|
-
key: "getBalanceAssetsPallet",
|
|
1312
|
-
value: function () {
|
|
1313
|
-
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(address, assetId) {
|
|
1314
|
-
var response;
|
|
1315
|
-
return _regenerator().w(function (_context13) {
|
|
1316
|
-
while (1) switch (_context13.n) {
|
|
1317
|
-
case 0:
|
|
1318
|
-
_context13.n = 1;
|
|
1319
|
-
return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
|
|
1320
|
-
case 1:
|
|
1321
|
-
response = _context13.v;
|
|
1322
|
-
return _context13.a(2, BigInt(response === undefined ? 0 : response.balance));
|
|
1323
|
-
}
|
|
1324
|
-
}, _callee13, this);
|
|
1325
|
-
}));
|
|
1326
|
-
function getBalanceAssetsPallet(_x26, _x27) {
|
|
1327
|
-
return _getBalanceAssetsPallet.apply(this, arguments);
|
|
1328
|
-
}
|
|
1329
|
-
return getBalanceAssetsPallet;
|
|
1330
|
-
}()
|
|
1331
1102
|
}, {
|
|
1332
1103
|
key: "getFromRpc",
|
|
1333
1104
|
value: function () {
|
|
1334
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1105
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(module, method, key) {
|
|
1335
1106
|
var toSS58, value;
|
|
1336
|
-
return _regenerator().w(function (
|
|
1337
|
-
while (1) switch (
|
|
1107
|
+
return _regenerator().w(function (_context7) {
|
|
1108
|
+
while (1) switch (_context7.n) {
|
|
1338
1109
|
case 0:
|
|
1339
1110
|
toSS58 = AccountId().dec;
|
|
1340
|
-
|
|
1111
|
+
_context7.n = 1;
|
|
1341
1112
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? toSS58(key) : key]);
|
|
1342
1113
|
case 1:
|
|
1343
|
-
value =
|
|
1344
|
-
return
|
|
1114
|
+
value = _context7.v;
|
|
1115
|
+
return _context7.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1345
1116
|
}
|
|
1346
|
-
},
|
|
1117
|
+
}, _callee7, this);
|
|
1347
1118
|
}));
|
|
1348
|
-
function getFromRpc(
|
|
1119
|
+
function getFromRpc(_x10, _x11, _x12) {
|
|
1349
1120
|
return _getFromRpc.apply(this, arguments);
|
|
1350
1121
|
}
|
|
1351
1122
|
return getFromRpc;
|
|
@@ -1358,20 +1129,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1358
1129
|
}, {
|
|
1359
1130
|
key: "createApiForChain",
|
|
1360
1131
|
value: function () {
|
|
1361
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1132
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(chain) {
|
|
1362
1133
|
var api;
|
|
1363
|
-
return _regenerator().w(function (
|
|
1364
|
-
while (1) switch (
|
|
1134
|
+
return _regenerator().w(function (_context8) {
|
|
1135
|
+
while (1) switch (_context8.n) {
|
|
1365
1136
|
case 0:
|
|
1366
1137
|
api = new PapiApi();
|
|
1367
|
-
|
|
1138
|
+
_context8.n = 1;
|
|
1368
1139
|
return api.init(chain);
|
|
1369
1140
|
case 1:
|
|
1370
|
-
return
|
|
1141
|
+
return _context8.a(2, api);
|
|
1371
1142
|
}
|
|
1372
|
-
},
|
|
1143
|
+
}, _callee8);
|
|
1373
1144
|
}));
|
|
1374
|
-
function createApiForChain(
|
|
1145
|
+
function createApiForChain(_x13) {
|
|
1375
1146
|
return _createApiForChain.apply(this, arguments);
|
|
1376
1147
|
}
|
|
1377
1148
|
return createApiForChain;
|
|
@@ -1379,16 +1150,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1379
1150
|
}, {
|
|
1380
1151
|
key: "getDryRunCall",
|
|
1381
1152
|
value: function () {
|
|
1382
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1153
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
|
|
1383
1154
|
var _this = this;
|
|
1384
1155
|
var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, usedAsset, usedSymbol, actualWeight, weight, forwardedXcms, destParaId, nativeAsset, hasLocation, xcmFee, executionFee, fee, _t2;
|
|
1385
|
-
return _regenerator().w(function (
|
|
1386
|
-
while (1) switch (
|
|
1156
|
+
return _regenerator().w(function (_context0) {
|
|
1157
|
+
while (1) switch (_context0.n) {
|
|
1387
1158
|
case 0:
|
|
1388
1159
|
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1389
1160
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1390
1161
|
if (supportsDryRunApi) {
|
|
1391
|
-
|
|
1162
|
+
_context0.n = 1;
|
|
1392
1163
|
break;
|
|
1393
1164
|
}
|
|
1394
1165
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
@@ -1404,38 +1175,38 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1404
1175
|
}
|
|
1405
1176
|
};
|
|
1406
1177
|
if (!useRootOrigin) {
|
|
1407
|
-
|
|
1178
|
+
_context0.n = 3;
|
|
1408
1179
|
break;
|
|
1409
1180
|
}
|
|
1410
|
-
|
|
1181
|
+
_context0.n = 2;
|
|
1411
1182
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1412
1183
|
api: this
|
|
1413
1184
|
}), bypassOptions);
|
|
1414
1185
|
case 2:
|
|
1415
|
-
_t2 =
|
|
1416
|
-
|
|
1186
|
+
_t2 = _context0.v;
|
|
1187
|
+
_context0.n = 4;
|
|
1417
1188
|
break;
|
|
1418
1189
|
case 3:
|
|
1419
1190
|
_t2 = tx;
|
|
1420
1191
|
case 4:
|
|
1421
1192
|
resolvedTx = _t2;
|
|
1422
1193
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1423
|
-
var
|
|
1424
|
-
var _this$api$
|
|
1194
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(includeVersion) {
|
|
1195
|
+
var _this$api$getUnsafeAp3;
|
|
1425
1196
|
var callArgs;
|
|
1426
|
-
return _regenerator().w(function (
|
|
1427
|
-
while (1) switch (
|
|
1197
|
+
return _regenerator().w(function (_context9) {
|
|
1198
|
+
while (1) switch (_context9.n) {
|
|
1428
1199
|
case 0:
|
|
1429
1200
|
callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1430
1201
|
if (includeVersion) {
|
|
1431
1202
|
callArgs.push(DEFAULT_XCM_VERSION);
|
|
1432
1203
|
}
|
|
1433
|
-
return
|
|
1204
|
+
return _context9.a(2, (_this$api$getUnsafeAp3 = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp3, callArgs));
|
|
1434
1205
|
}
|
|
1435
|
-
},
|
|
1206
|
+
}, _callee9);
|
|
1436
1207
|
}));
|
|
1437
|
-
return function performDryRunCall(
|
|
1438
|
-
return
|
|
1208
|
+
return function performDryRunCall(_x15) {
|
|
1209
|
+
return _ref8.apply(this, arguments);
|
|
1439
1210
|
};
|
|
1440
1211
|
}();
|
|
1441
1212
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
@@ -1464,7 +1235,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1464
1235
|
return result;
|
|
1465
1236
|
};
|
|
1466
1237
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1467
|
-
var _obj$value,
|
|
1238
|
+
var _obj$value, _ref9, _result$value6;
|
|
1468
1239
|
var obj = findFailureObjectFromResult(result);
|
|
1469
1240
|
if (obj !== null && obj !== void 0 && obj.type && obj !== null && obj !== void 0 && (_obj$value = obj.value) !== null && _obj$value !== void 0 && (_obj$value = _obj$value.error) !== null && _obj$value !== void 0 && _obj$value.type) {
|
|
1470
1241
|
return {
|
|
@@ -1478,31 +1249,31 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1478
1249
|
};
|
|
1479
1250
|
}
|
|
1480
1251
|
return {
|
|
1481
|
-
failureReason: JSON.stringify((
|
|
1252
|
+
failureReason: JSON.stringify((_ref9 = (_result$value6 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value6 !== void 0 ? _result$value6 : result) !== null && _ref9 !== void 0 ? _ref9 : 'Unknown error structure', replaceBigInt)
|
|
1482
1253
|
};
|
|
1483
1254
|
};
|
|
1484
1255
|
failureOutputReason = {
|
|
1485
1256
|
failureReason: ''
|
|
1486
1257
|
};
|
|
1487
|
-
|
|
1258
|
+
_context0.n = 5;
|
|
1488
1259
|
return performDryRunCall(false);
|
|
1489
1260
|
case 5:
|
|
1490
|
-
result =
|
|
1261
|
+
result = _context0.v;
|
|
1491
1262
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1492
1263
|
if (isSuccess) {
|
|
1493
|
-
|
|
1264
|
+
_context0.n = 7;
|
|
1494
1265
|
break;
|
|
1495
1266
|
}
|
|
1496
1267
|
initialFailureReason = extractFailureReasonFromResult(result);
|
|
1497
1268
|
failureOutputReason = initialFailureReason;
|
|
1498
1269
|
if (!(initialFailureReason.failureReason === 'VersionedConversionFailed')) {
|
|
1499
|
-
|
|
1270
|
+
_context0.n = 7;
|
|
1500
1271
|
break;
|
|
1501
1272
|
}
|
|
1502
|
-
|
|
1273
|
+
_context0.n = 6;
|
|
1503
1274
|
return performDryRunCall(true);
|
|
1504
1275
|
case 6:
|
|
1505
|
-
result =
|
|
1276
|
+
result = _context0.v;
|
|
1506
1277
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1507
1278
|
if (!isSuccess) {
|
|
1508
1279
|
failureOutputReason = extractFailureReasonFromResult(result);
|
|
@@ -1516,10 +1287,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1516
1287
|
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
|
|
1517
1288
|
usedSymbol = usedAsset.symbol;
|
|
1518
1289
|
if (isSuccess) {
|
|
1519
|
-
|
|
1290
|
+
_context0.n = 8;
|
|
1520
1291
|
break;
|
|
1521
1292
|
}
|
|
1522
|
-
return
|
|
1293
|
+
return _context0.a(2, Promise.resolve({
|
|
1523
1294
|
success: false,
|
|
1524
1295
|
failureReason: failureOutputReason.failureReason,
|
|
1525
1296
|
failureSubReason: failureOutputReason.failureSubReason,
|
|
@@ -1537,18 +1308,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1537
1308
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1538
1309
|
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
1539
1310
|
if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum'))) {
|
|
1540
|
-
|
|
1311
|
+
_context0.n = 10;
|
|
1541
1312
|
break;
|
|
1542
1313
|
}
|
|
1543
|
-
|
|
1314
|
+
_context0.n = 9;
|
|
1544
1315
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
1545
1316
|
case 9:
|
|
1546
|
-
xcmFee =
|
|
1317
|
+
xcmFee = _context0.v;
|
|
1547
1318
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1548
|
-
|
|
1319
|
+
_context0.n = 10;
|
|
1549
1320
|
break;
|
|
1550
1321
|
}
|
|
1551
|
-
return
|
|
1322
|
+
return _context0.a(2, Promise.resolve({
|
|
1552
1323
|
success: true,
|
|
1553
1324
|
fee: xcmFee,
|
|
1554
1325
|
currency: usedSymbol,
|
|
@@ -1558,12 +1329,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1558
1329
|
destParaId: destParaId
|
|
1559
1330
|
}));
|
|
1560
1331
|
case 10:
|
|
1561
|
-
|
|
1332
|
+
_context0.n = 11;
|
|
1562
1333
|
return this.calculateTransactionFee(tx, address);
|
|
1563
1334
|
case 11:
|
|
1564
|
-
executionFee =
|
|
1335
|
+
executionFee = _context0.v;
|
|
1565
1336
|
fee = computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
|
|
1566
|
-
return
|
|
1337
|
+
return _context0.a(2, Promise.resolve({
|
|
1567
1338
|
success: true,
|
|
1568
1339
|
fee: fee,
|
|
1569
1340
|
currency: usedSymbol,
|
|
@@ -1573,9 +1344,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1573
1344
|
destParaId: destParaId
|
|
1574
1345
|
}));
|
|
1575
1346
|
}
|
|
1576
|
-
},
|
|
1347
|
+
}, _callee0, this);
|
|
1577
1348
|
}));
|
|
1578
|
-
function getDryRunCall(
|
|
1349
|
+
function getDryRunCall(_x14) {
|
|
1579
1350
|
return _getDryRunCall.apply(this, arguments);
|
|
1580
1351
|
}
|
|
1581
1352
|
return getDryRunCall;
|
|
@@ -1583,24 +1354,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1583
1354
|
}, {
|
|
1584
1355
|
key: "getXcmWeight",
|
|
1585
1356
|
value: function () {
|
|
1586
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1357
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(xcm) {
|
|
1587
1358
|
var weightResult, _weightResult$value, ref_time, proof_size;
|
|
1588
|
-
return _regenerator().w(function (
|
|
1589
|
-
while (1) switch (
|
|
1359
|
+
return _regenerator().w(function (_context1) {
|
|
1360
|
+
while (1) switch (_context1.n) {
|
|
1590
1361
|
case 0:
|
|
1591
|
-
|
|
1362
|
+
_context1.n = 1;
|
|
1592
1363
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1593
1364
|
case 1:
|
|
1594
|
-
weightResult =
|
|
1365
|
+
weightResult = _context1.v;
|
|
1595
1366
|
_weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
|
|
1596
|
-
return
|
|
1367
|
+
return _context1.a(2, {
|
|
1597
1368
|
refTime: ref_time,
|
|
1598
1369
|
proofSize: proof_size
|
|
1599
1370
|
});
|
|
1600
1371
|
}
|
|
1601
|
-
},
|
|
1372
|
+
}, _callee1, this);
|
|
1602
1373
|
}));
|
|
1603
|
-
function getXcmWeight(
|
|
1374
|
+
function getXcmWeight(_x16) {
|
|
1604
1375
|
return _getXcmWeight.apply(this, arguments);
|
|
1605
1376
|
}
|
|
1606
1377
|
return getXcmWeight;
|
|
@@ -1608,7 +1379,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1608
1379
|
}, {
|
|
1609
1380
|
key: "getXcmPaymentApiFee",
|
|
1610
1381
|
value: function () {
|
|
1611
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1382
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, localXcm, forwardedXcm, asset) {
|
|
1612
1383
|
var _deliveryFeeRes$value, _deliveryFeeRes$value2;
|
|
1613
1384
|
var transformXcm,
|
|
1614
1385
|
transformedXcm,
|
|
@@ -1621,37 +1392,37 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1621
1392
|
nativeAsset,
|
|
1622
1393
|
deliveryFee,
|
|
1623
1394
|
res,
|
|
1624
|
-
|
|
1395
|
+
_args10 = arguments,
|
|
1625
1396
|
_t3,
|
|
1626
1397
|
_t4;
|
|
1627
|
-
return _regenerator().w(function (
|
|
1628
|
-
while (1) switch (
|
|
1398
|
+
return _regenerator().w(function (_context10) {
|
|
1399
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1629
1400
|
case 0:
|
|
1630
|
-
transformXcm =
|
|
1401
|
+
transformXcm = _args10.length > 4 && _args10[4] !== undefined ? _args10[4] : false;
|
|
1631
1402
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1632
|
-
|
|
1403
|
+
_context10.n = 1;
|
|
1633
1404
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1634
1405
|
case 1:
|
|
1635
|
-
weight =
|
|
1406
|
+
weight = _context10.v;
|
|
1636
1407
|
assertHasLocation(asset);
|
|
1637
1408
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1638
1409
|
transformedAssetLoc = _transform(assetLocalizedLoc);
|
|
1639
|
-
|
|
1410
|
+
_context10.n = 2;
|
|
1640
1411
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
|
|
1641
1412
|
type: Version.V4,
|
|
1642
1413
|
value: transformedAssetLoc
|
|
1643
1414
|
});
|
|
1644
1415
|
case 2:
|
|
1645
|
-
execFeeRes =
|
|
1416
|
+
execFeeRes = _context10.v;
|
|
1646
1417
|
if (!(forwardedXcm.length > 0)) {
|
|
1647
|
-
|
|
1418
|
+
_context10.n = 4;
|
|
1648
1419
|
break;
|
|
1649
1420
|
}
|
|
1650
|
-
|
|
1421
|
+
_context10.n = 3;
|
|
1651
1422
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_delivery_fees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
1652
1423
|
case 3:
|
|
1653
|
-
_t3 =
|
|
1654
|
-
|
|
1424
|
+
_t3 = _context10.v;
|
|
1425
|
+
_context10.n = 5;
|
|
1655
1426
|
break;
|
|
1656
1427
|
case 4:
|
|
1657
1428
|
_t3 = undefined;
|
|
@@ -1660,36 +1431,36 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1660
1431
|
deliveryFeeResolved = (deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value = deliveryFeeRes.value) === null || _deliveryFeeRes$value === void 0 ? void 0 : _deliveryFeeRes$value.value.length) > 0 ? deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value2 = deliveryFeeRes.value) === null || _deliveryFeeRes$value2 === void 0 ? void 0 : _deliveryFeeRes$value2.value[0].fun.value : 0n;
|
|
1661
1432
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1662
1433
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
1663
|
-
|
|
1434
|
+
_context10.n = 6;
|
|
1664
1435
|
break;
|
|
1665
1436
|
}
|
|
1666
1437
|
deliveryFee = deliveryFeeResolved;
|
|
1667
|
-
|
|
1438
|
+
_context10.n = 9;
|
|
1668
1439
|
break;
|
|
1669
1440
|
case 6:
|
|
1670
|
-
|
|
1441
|
+
_context10.p = 6;
|
|
1671
1442
|
assertHasLocation(nativeAsset);
|
|
1672
|
-
|
|
1443
|
+
_context10.n = 7;
|
|
1673
1444
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1674
1445
|
case 7:
|
|
1675
|
-
res =
|
|
1446
|
+
res = _context10.v;
|
|
1676
1447
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
1677
|
-
|
|
1448
|
+
_context10.n = 9;
|
|
1678
1449
|
break;
|
|
1679
1450
|
case 8:
|
|
1680
|
-
|
|
1681
|
-
_t4 =
|
|
1451
|
+
_context10.p = 8;
|
|
1452
|
+
_t4 = _context10.v;
|
|
1682
1453
|
if (_t4 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t4.message)) {
|
|
1683
1454
|
deliveryFee = 0n;
|
|
1684
1455
|
} else {
|
|
1685
1456
|
deliveryFee = 0n;
|
|
1686
1457
|
}
|
|
1687
1458
|
case 9:
|
|
1688
|
-
return
|
|
1459
|
+
return _context10.a(2, execFeeRes.value + deliveryFee);
|
|
1689
1460
|
}
|
|
1690
|
-
},
|
|
1461
|
+
}, _callee10, this, [[6, 8]]);
|
|
1691
1462
|
}));
|
|
1692
|
-
function getXcmPaymentApiFee(
|
|
1463
|
+
function getXcmPaymentApiFee(_x17, _x18, _x19, _x20) {
|
|
1693
1464
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1694
1465
|
}
|
|
1695
1466
|
return getXcmPaymentApiFee;
|
|
@@ -1697,33 +1468,33 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1697
1468
|
}, {
|
|
1698
1469
|
key: "getDryRunXcm",
|
|
1699
1470
|
value: function () {
|
|
1700
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1701
|
-
var
|
|
1471
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(_ref0) {
|
|
1472
|
+
var _ref1, _processAssetsDeposit, _ref10, _ref11, _ref12, _ref13, _ref14;
|
|
1702
1473
|
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, symbol, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1703
|
-
return _regenerator().w(function (
|
|
1704
|
-
while (1) switch (
|
|
1474
|
+
return _regenerator().w(function (_context11) {
|
|
1475
|
+
while (1) switch (_context11.n) {
|
|
1705
1476
|
case 0:
|
|
1706
|
-
originLocation =
|
|
1477
|
+
originLocation = _ref0.originLocation, xcm = _ref0.xcm, chain = _ref0.chain, origin = _ref0.origin, asset = _ref0.asset, feeAsset = _ref0.feeAsset, originFee = _ref0.originFee, amount = _ref0.amount;
|
|
1707
1478
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1708
1479
|
if (supportsDryRunApi) {
|
|
1709
|
-
|
|
1480
|
+
_context11.n = 1;
|
|
1710
1481
|
break;
|
|
1711
1482
|
}
|
|
1712
1483
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
1713
1484
|
case 1:
|
|
1714
1485
|
transformedOriginLocation = _transform(originLocation);
|
|
1715
|
-
|
|
1486
|
+
_context11.n = 2;
|
|
1716
1487
|
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1717
1488
|
case 2:
|
|
1718
|
-
result =
|
|
1489
|
+
result = _context11.v;
|
|
1719
1490
|
symbol = asset.symbol;
|
|
1720
1491
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1721
1492
|
if (isSuccess) {
|
|
1722
|
-
|
|
1493
|
+
_context11.n = 3;
|
|
1723
1494
|
break;
|
|
1724
1495
|
}
|
|
1725
1496
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1726
|
-
return
|
|
1497
|
+
return _context11.a(2, {
|
|
1727
1498
|
success: false,
|
|
1728
1499
|
failureReason: failureReason,
|
|
1729
1500
|
currency: symbol,
|
|
@@ -1738,18 +1509,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1738
1509
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1739
1510
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1740
1511
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1741
|
-
|
|
1512
|
+
_context11.n = 5;
|
|
1742
1513
|
break;
|
|
1743
1514
|
}
|
|
1744
|
-
|
|
1515
|
+
_context11.n = 4;
|
|
1745
1516
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1746
1517
|
case 4:
|
|
1747
|
-
_fee =
|
|
1518
|
+
_fee = _context11.v;
|
|
1748
1519
|
if (!(typeof _fee === 'bigint')) {
|
|
1749
|
-
|
|
1520
|
+
_context11.n = 5;
|
|
1750
1521
|
break;
|
|
1751
1522
|
}
|
|
1752
|
-
return
|
|
1523
|
+
return _context11.a(2, {
|
|
1753
1524
|
success: true,
|
|
1754
1525
|
fee: _fee,
|
|
1755
1526
|
currency: symbol,
|
|
@@ -1763,13 +1534,13 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1763
1534
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1764
1535
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1765
1536
|
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
|
|
1766
|
-
feeAssetFeeEvent = (
|
|
1537
|
+
feeAssetFeeEvent = (_ref1 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1767
1538
|
return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
|
|
1768
|
-
}) : undefined) !== null &&
|
|
1539
|
+
}) : undefined) !== null && _ref1 !== void 0 ? _ref1 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1769
1540
|
return event.type === 'Tokens' && event.value.type === 'Deposited';
|
|
1770
1541
|
}) : undefined;
|
|
1771
1542
|
processedAssetsAmount = chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount, 'Assets', 'Deposited', true) : (_processAssetsDeposit = processAssetsDepositedEvents(emitted, amount, 'Balances', 'Minted', false)) !== null && _processAssetsDeposit !== void 0 ? _processAssetsDeposit : processAssetsDepositedEvents(emitted, amount, 'Balances', 'Issued', false);
|
|
1772
|
-
feeEvent = (
|
|
1543
|
+
feeEvent = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_ref14 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
|
|
1773
1544
|
//
|
|
1774
1545
|
processedAssetsAmount !== undefined ? {
|
|
1775
1546
|
type: 'Assets',
|
|
@@ -1779,30 +1550,30 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1779
1550
|
amount: processedAssetsAmount
|
|
1780
1551
|
}
|
|
1781
1552
|
}
|
|
1782
|
-
} : undefined) !== null &&
|
|
1553
|
+
} : undefined) !== null && _ref14 !== void 0 ? _ref14 :
|
|
1783
1554
|
//
|
|
1784
1555
|
chain === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1785
1556
|
return event.type === 'Balances' && event.value.type === 'Issued';
|
|
1786
|
-
}) : undefined) !== null &&
|
|
1557
|
+
}) : undefined) !== null && _ref13 !== void 0 ? _ref13 :
|
|
1787
1558
|
//
|
|
1788
1559
|
origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
|
|
1789
1560
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1790
|
-
}) : undefined) !== null &&
|
|
1561
|
+
}) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
|
|
1791
1562
|
// Prefer to Minted event
|
|
1792
1563
|
reversedEvents.find(function (event) {
|
|
1793
1564
|
return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
|
|
1794
|
-
})) !== null &&
|
|
1565
|
+
})) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1795
1566
|
// Fallback an Issued event
|
|
1796
1567
|
reversedEvents.find(function (event) {
|
|
1797
1568
|
return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
|
|
1798
|
-
})) !== null &&
|
|
1569
|
+
})) !== null && _ref10 !== void 0 ? _ref10 : reversedEvents.find(function (event) {
|
|
1799
1570
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1800
1571
|
});
|
|
1801
1572
|
if (feeEvent) {
|
|
1802
|
-
|
|
1573
|
+
_context11.n = 6;
|
|
1803
1574
|
break;
|
|
1804
1575
|
}
|
|
1805
|
-
return
|
|
1576
|
+
return _context11.a(2, Promise.resolve({
|
|
1806
1577
|
success: false,
|
|
1807
1578
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1808
1579
|
currency: symbol,
|
|
@@ -1814,7 +1585,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1814
1585
|
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1815
1586
|
}
|
|
1816
1587
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
|
|
1817
|
-
return
|
|
1588
|
+
return _context11.a(2, Promise.resolve({
|
|
1818
1589
|
success: true,
|
|
1819
1590
|
fee: processedFee,
|
|
1820
1591
|
currency: symbol,
|
|
@@ -1824,9 +1595,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1824
1595
|
destParaId: destParaId
|
|
1825
1596
|
}));
|
|
1826
1597
|
}
|
|
1827
|
-
},
|
|
1598
|
+
}, _callee11, this);
|
|
1828
1599
|
}));
|
|
1829
|
-
function getDryRunXcm(
|
|
1600
|
+
function getDryRunXcm(_x21) {
|
|
1830
1601
|
return _getDryRunXcm.apply(this, arguments);
|
|
1831
1602
|
}
|
|
1832
1603
|
return getDryRunXcm;
|
|
@@ -1834,18 +1605,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1834
1605
|
}, {
|
|
1835
1606
|
key: "getBridgeStatus",
|
|
1836
1607
|
value: function () {
|
|
1837
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1608
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
1838
1609
|
var outboundOperatingMode;
|
|
1839
|
-
return _regenerator().w(function (
|
|
1840
|
-
while (1) switch (
|
|
1610
|
+
return _regenerator().w(function (_context12) {
|
|
1611
|
+
while (1) switch (_context12.n) {
|
|
1841
1612
|
case 0:
|
|
1842
|
-
|
|
1613
|
+
_context12.n = 1;
|
|
1843
1614
|
return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1844
1615
|
case 1:
|
|
1845
|
-
outboundOperatingMode =
|
|
1846
|
-
return
|
|
1616
|
+
outboundOperatingMode = _context12.v;
|
|
1617
|
+
return _context12.a(2, outboundOperatingMode.type);
|
|
1847
1618
|
}
|
|
1848
|
-
},
|
|
1619
|
+
}, _callee12, this);
|
|
1849
1620
|
}));
|
|
1850
1621
|
function getBridgeStatus() {
|
|
1851
1622
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1885,30 +1656,6 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1885
1656
|
}
|
|
1886
1657
|
return Promise.resolve();
|
|
1887
1658
|
}
|
|
1888
|
-
}, {
|
|
1889
|
-
key: "convertLocationToAccount",
|
|
1890
|
-
value: function () {
|
|
1891
|
-
var _convertLocationToAccount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(location) {
|
|
1892
|
-
var res;
|
|
1893
|
-
return _regenerator().w(function (_context22) {
|
|
1894
|
-
while (1) switch (_context22.n) {
|
|
1895
|
-
case 0:
|
|
1896
|
-
_context22.n = 1;
|
|
1897
|
-
return this.api.getUnsafeApi().apis.LocationToAccountApi.convert_location({
|
|
1898
|
-
type: Version.V4,
|
|
1899
|
-
value: _transform(location)
|
|
1900
|
-
});
|
|
1901
|
-
case 1:
|
|
1902
|
-
res = _context22.v;
|
|
1903
|
-
return _context22.a(2, res.success ? res.value : undefined);
|
|
1904
|
-
}
|
|
1905
|
-
}, _callee22, this);
|
|
1906
|
-
}));
|
|
1907
|
-
function convertLocationToAccount(_x40) {
|
|
1908
|
-
return _convertLocationToAccount.apply(this, arguments);
|
|
1909
|
-
}
|
|
1910
|
-
return convertLocationToAccount;
|
|
1911
|
-
}()
|
|
1912
1659
|
}]);
|
|
1913
1660
|
}();
|
|
1914
1661
|
|
|
@@ -1954,13 +1701,13 @@ var getBalanceNative = createPapiApiCall(getBalanceNative$1);
|
|
|
1954
1701
|
*
|
|
1955
1702
|
* @returns The balance of the foreign asset as a bigint, or null if not found.
|
|
1956
1703
|
*/
|
|
1957
|
-
var getBalanceForeign = createPapiApiCall(
|
|
1704
|
+
var getBalanceForeign = createPapiApiCall(getBalance);
|
|
1958
1705
|
/**
|
|
1959
1706
|
* Retrieves the asset balance for a given account on a specified chain.
|
|
1960
1707
|
*
|
|
1961
1708
|
* @returns The asset balance as a bigint.
|
|
1962
1709
|
*/
|
|
1963
|
-
var getAssetBalance = createPapiApiCall(
|
|
1710
|
+
var getAssetBalance = createPapiApiCall(getBalance);
|
|
1964
1711
|
/**
|
|
1965
1712
|
* Claims assets from a parachain.
|
|
1966
1713
|
*
|
|
@@ -2098,12 +1845,12 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
2098
1845
|
key: "build",
|
|
2099
1846
|
value: (function () {
|
|
2100
1847
|
var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
2101
|
-
var _this$_options, from, to, address;
|
|
1848
|
+
var _this$_options, from, to, address, api;
|
|
2102
1849
|
return _regenerator().w(function (_context) {
|
|
2103
1850
|
while (1) switch (_context.n) {
|
|
2104
1851
|
case 0:
|
|
2105
|
-
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address;
|
|
2106
|
-
validateAddress(address, to);
|
|
1852
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address, api = _this$_options.api;
|
|
1853
|
+
validateAddress(api, address, to);
|
|
2107
1854
|
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
2108
1855
|
_context.n = 1;
|
|
2109
1856
|
break;
|