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