PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@polkadot/api-derive/cjs/staking
Просмотр файла: ownExposure.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ownExposures = exports.ownExposure = void 0;
exports._ownExposures = _ownExposures;
const rxjs_1 = require("rxjs");
const index_js_1 = require("../util/index.js");
const util_js_1 = require("./util.js");
function _ownExposures(instanceId, api) {
return (0, index_js_1.memo)(instanceId, (accountId, eras, _withActive, page) => {
const emptyStakingExposure = api.registry.createType('Exposure');
// The reason we don't explicitly make the actual types is for compatibility. If the chain doesn't have the noted type it will fail
// on construction. Therefore we just make an empty option.
const emptyOptionPage = api.registry.createType('Option<Null>');
const emptyOptionMeta = api.registry.createType('Option<Null>');
return eras.length
? (0, rxjs_1.combineLatest)([
// Backwards and forward compat for historical integrity when using `erasHistoricApplyAccount`
api.query.staking.erasStakersClipped
? (0, rxjs_1.combineLatest)(eras.map((e) => api.query.staking.erasStakersClipped(e, accountId)))
: (0, rxjs_1.of)(eras.map((_) => emptyStakingExposure)),
api.query.staking.erasStakers
? (0, rxjs_1.combineLatest)(eras.map((e) => api.query.staking.erasStakers(e, accountId)))
: (0, rxjs_1.of)(eras.map((_) => emptyStakingExposure)),
api.query.staking.erasStakersPaged
? (0, rxjs_1.combineLatest)(eras.map((e) => api.query.staking.erasStakersPaged(e, accountId, page)))
: (0, rxjs_1.of)(eras.map((_) => emptyOptionPage)),
api.query.staking.erasStakersOverview
? (0, rxjs_1.combineLatest)(eras.map((e) => api.query.staking.erasStakersOverview(e, accountId)))
: (0, rxjs_1.of)(eras.map((_) => emptyOptionMeta))
]).pipe((0, rxjs_1.map)(([clp, exp, paged, expMeta]) => eras.map((era, index) => ({ clipped: clp[index], era, exposure: exp[index], exposureMeta: expMeta[index], exposurePaged: paged[index] }))))
: (0, rxjs_1.of)([]);
});
}
exports.ownExposure = (0, index_js_1.firstMemo)((api, accountId, era, page) => api.derive.staking._ownExposures(accountId, [era], true, page || 0));
exports.ownExposures = (0, util_js_1.erasHistoricApplyAccount)('_ownExposures');
Выполнить команду
Для локальной разработки. Не используйте в интернете!