"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 here is the same as in the Rust code
const call = {
    description: 'Perform a call to a builtin on the chain',
    params: [
        param_1.default('method', 'Text'),
        param_1.default('data', 'Bytes'),
        param_1.default('at', 'BlockHash', { isOptional: true })
    ],
    type: 'Bytes'
};
const KEY_QUERY_PARAMS = [
    param_1.default('key', 'StorageKey'),
    param_1.default('at', 'BlockHash', { isOptional: true })
];
const getKeys = {
    description: 'Retrieves the keys with a certain prefix',
    params: KEY_QUERY_PARAMS,
    type: 'Vec<StorageKey>'
};
const getStorage = {
    description: 'Retrieves the storage for a key',
    params: KEY_QUERY_PARAMS,
    type: 'StorageData'
};
const getStorageHash = {
    description: 'Retrieves the storage hash',
    params: KEY_QUERY_PARAMS,
    type: 'Hash'
};
const getStorageSize = {
    description: 'Retrieves the storage size',
    params: KEY_QUERY_PARAMS,
    type: 'u64'
};
const CHILD_QUERY_PARAMS = [
    param_1.default('childStorageKey', 'StorageKey'),
    param_1.default('childDefinition', 'StorageKey'),
    param_1.default('childType', 'u32'),
    param_1.default('key', 'StorageKey'),
    param_1.default('at', 'BlockHash', { isOptional: true })
];
const getChildKeys = {
    description: 'Retrieves the keys with prefix of a specific child storage',
    params: CHILD_QUERY_PARAMS,
    type: 'Vec<StorageKey>'
};
const getChildStorage = {
    description: 'Retrieves the child storage for a key',
    params: CHILD_QUERY_PARAMS,
    type: 'StorageData'
};
const getChildStorageHash = {
    description: 'Retrieves the child storage hash',
    params: CHILD_QUERY_PARAMS,
    type: 'Hash'
};
const getChildStorageSize = {
    description: 'Retrieves the child storage size',
    params: CHILD_QUERY_PARAMS,
    type: 'u64'
};
const getMetadata = {
    description: 'Returns the runtime metadata',
    params: [
        param_1.default('at', 'BlockHash', { isOptional: true })
    ],
    // This is not part of InterfaceTypes
    type: 'Metadata'
};
const getRuntimeVersion = {
    description: 'Get the runtime version',
    params: [
        param_1.default('at', 'BlockHash', { isOptional: true })
    ],
    type: 'RuntimeVersion'
};
const queryStorage = {
    description: 'Query historical storage entries (by key) starting from a start block',
    params: [
        param_1.default('keys', 'Vec<StorageKey>'),
        param_1.default('startBlock', 'Hash'),
        param_1.default('at', 'BlockHash', { isOptional: true })
    ],
    type: 'Vec<StorageChangeSet>'
};
const subscribeRuntimeVersion = {
    description: 'Retrieves the runtime version via subscription',
    params: [],
    pubsub: [
        'runtimeVersion',
        'subscribeRuntimeVersion',
        'unsubscribeRuntimeVersion'
    ],
    type: 'RuntimeVersion'
};
const subscribeStorage = {
    description: 'Subscribes to storage changes for the provided keys',
    params: [
        param_1.default('keys', 'Vec<StorageKey>')
    ],
    pubsub: [
        'storage',
        'subscribeStorage',
        'unsubscribeStorage'
    ],
    type: 'StorageChangeSet'
};
const section = 'state';
/**
 * @summary Query the state and state storage.
 */
exports.default = {
    isDeprecated: false,
    isHidden: false,
    description: 'Query of state',
    section,
    methods: {
        call: method_1.default(section, 'call', call),
        getChildKeys: method_1.default(section, 'getChildKeys', getChildKeys),
        getChildStorage: method_1.default(section, 'getChildStorage', getChildStorage),
        getChildStorageHash: method_1.default(section, 'getChildStorageHash', getChildStorageHash),
        getChildStorageSize: method_1.default(section, 'getChildStorageSize', getChildStorageSize),
        getKeys: method_1.default(section, 'getKeys', getKeys),
        getMetadata: method_1.default(section, 'getMetadata', getMetadata),
        getRuntimeVersion: method_1.default(section, 'getRuntimeVersion', getRuntimeVersion),
        getStorage: method_1.default(section, 'getStorage', getStorage),
        getStorageHash: method_1.default(section, 'getStorageHash', getStorageHash),
        getStorageSize: method_1.default(section, 'getStorageSize', getStorageSize),
        queryStorage: method_1.default(section, 'queryStorage', queryStorage),
        subscribeRuntimeVersion: method_1.default(section, 'subscribeRuntimeVersion', subscribeRuntimeVersion),
        subscribeStorage: method_1.default(section, 'subscribeStorage', subscribeStorage)
    }
};
