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