UNPKG

933 BJavaScriptView Raw
1import { Struct } from '@polkadot/types-codec';
2/**
3 * @name GenericBlock
4 * @description
5 * A block encoded with header and extrinsics
6 */
7export class GenericBlock extends Struct {
8 constructor(registry, value) {
9 super(registry, {
10 header: 'Header',
11 // eslint-disable-next-line sort-keys
12 extrinsics: 'Vec<Extrinsic>'
13 }, value);
14 }
15 /**
16 * @description Encodes a content [[Hash]] for the block
17 */
18 get contentHash() {
19 return this.registry.hash(this.toU8a());
20 }
21 /**
22 * @description The [[Extrinsic]] contained in the block
23 */
24 get extrinsics() {
25 return this.getT('extrinsics');
26 }
27 /**
28 * @description Block/header [[Hash]]
29 */
30 get hash() {
31 return this.header.hash;
32 }
33 /**
34 * @description The [[Header]] of the block
35 */
36 get header() {
37 return this.getT('header');
38 }
39}