@polkadot/react-query
Version:
A collection of RxJs React components the Polkadot JS API
39 lines (33 loc) • 1.22 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = BondedDisplay;
var _react = _interopRequireDefault(require("react"));
var _reactHooks = require("@polkadot/react-hooks");
var _FormatBalance = _interopRequireDefault(require("./FormatBalance"));
// Copyright 2017-2020 @polkadot/react-query authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
function BondedDisplay({
children,
className,
label,
params
}) {
const {
api
} = (0, _reactHooks.useApi)();
const controllerId = (0, _reactHooks.useCall)(api.query.staking.bonded, [params], {
transform: value => value.unwrapOr(null)
});
const stakingLedger = (0, _reactHooks.useCall)(controllerId && api.query.staking.ledger, [controllerId], {
transform: value => value.unwrapOr(null)
});
return _react.default.createElement(_FormatBalance.default, {
className: className,
label: label,
value: stakingLedger === null || stakingLedger === void 0 ? void 0 : stakingLedger.active
}, children);
}