"use strict";
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const util_1 = require("../util");
/**
 * @name bestNumberFinalized
 * @returns A BlockNumber
 * @description Get the latest finalized block number.
 * @example
 * <BR>
 *
 * ```javascript
 * api.derive.chain.bestNumberFinalized((blockNumber) => {
 *   console.log(`the current finalized block is #${blockNumber}`);
 * });
 * ```
 */
function bestNumberFinalized(api) {
    return util_1.memo(() => api.rpc.chain.subscribeFinalizedHeads().pipe(operators_1.map((header) => header.number.unwrap())));
}
exports.bestNumberFinalized = bestNumberFinalized;
