"use strict";
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const method_1 = __importDefault(require("./create/method"));
const param_1 = __importDefault(require("./create/param"));
// NOTE Order is the same as in Rust
const getHeader = {
    description: 'Retrieves the header for a specific block',
    params: [
        param_1.default('hash', 'BlockHash', { isOptional: true })
    ],
    type: 'Header'
};
const getBlock = {
    description: 'Get header and body of a relay chain block',
    params: [
        param_1.default('hash', 'BlockHash', { isOptional: true })
    ],
    type: 'SignedBlock'
};
const getBlockHash = {
    description: 'Get the block hash for a specific block',
    params: [
        param_1.default('blockNumber', 'BlockNumber', { isOptional: true })
    ],
    type: 'BlockHash'
};
const getFinalizedHead = {
    description: 'Get hash of the last finalized block in the canon chain',
    params: [],
    type: 'BlockHash'
};
const subscribeNewHeads = {
    description: 'Retrieves the best header via subscription',
    params: [],
    // NOTE These still has the aliassed version, compatible with 1.x
    pubsub: [
        'newHead',
        'subscribeNewHead',
        'unsubscribeNewHead'
    ],
    type: 'Header'
};
const subscribeFinalizedHeads = {
    description: 'Retrieves the best finalized header via subscription',
    params: [],
    pubsub: [
        'finalizedHead',
        'subscribeFinalizedHeads',
        'unsubscribeFinalizedHeads'
    ],
    type: 'Header'
};
const section = 'chain';
/**
 * @summary Calls to retrieve chain data.
 */
exports.default = {
    isDeprecated: false,
    isHidden: false,
    description: 'Retrieval of chain data',
    section,
    methods: {
        getBlock: method_1.default(section, 'getBlock', getBlock),
        getBlockHash: method_1.default(section, 'getBlockHash', getBlockHash),
        getFinalizedHead: method_1.default(section, 'getFinalizedHead', getFinalizedHead),
        getHeader: method_1.default(section, 'getHeader', getHeader),
        subscribeFinalizedHeads: method_1.default(section, 'subscribeFinalizedHeads', subscribeFinalizedHeads),
        subscribeNewHeads: method_1.default(section, 'subscribeNewHeads', subscribeNewHeads)
    }
};
