"use strict";
// Copyright 2017-2020 @polkadot/types 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 util_crypto_1 = require("@polkadot/util-crypto");
const create_1 = require("../../codec/create");
const Struct_1 = __importDefault(require("../../codec/Struct"));
/**
 * @name Block
 * @description
 * A block encoded with header and extrinsics
 */
class Block extends Struct_1.default {
    constructor(registry, value) {
        super(registry, {
            header: 'Header',
            extrinsics: 'Vec<Extrinsic>'
        }, value);
    }
    /**
     * @description Encodes a content [[Hash]] for the block
     */
    get contentHash() {
        return create_1.createType(this.registry, 'Hash', util_crypto_1.blake2AsU8a(this.toU8a(), 256));
    }
    /**
     * @description The [[Extrinsic]] contained in the block
     */
    get extrinsics() {
        return this.get('extrinsics');
    }
    /**
     * @description Block/header [[Hash]]
     */
    get hash() {
        return this.header.hash;
    }
    /**
     * @description The [[Header]] of the block
     */
    get header() {
        return this.get('header');
    }
}
exports.default = Block;
