Consistency in exposing header hashes (#546)
* Consistency in exposing header hashes * Cleanup comments
This commit is contained in:
+17
-10
@@ -30,23 +30,30 @@ export default class Block extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Extrinsics]] conatined in the block
|
||||
* @description Encodes a content [[Hash]] for the block
|
||||
*/
|
||||
get extrinsics (): Extrinsics {
|
||||
return this.get('extrinsics') as Extrinsics;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Coinvenience getter, encoded the [[Hash]] for the block
|
||||
*/
|
||||
get hash (): Hash {
|
||||
get contentHash (): Hash {
|
||||
return new Hash(
|
||||
blake2AsU8a(this.toU8a(), 256)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Header]] in the block
|
||||
* @description The [[Extrinsics]] contained in the block
|
||||
*/
|
||||
get extrinsics (): Extrinsics {
|
||||
return this.get('extrinsics') as Extrinsics;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Block/header [[Hash]]
|
||||
*/
|
||||
get hash (): Hash {
|
||||
return this.header.hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Header]] of the block
|
||||
*/
|
||||
get header (): Header {
|
||||
return this.get('header') as Header;
|
||||
|
||||
@@ -6,6 +6,7 @@ import { AnyU8a } from './types';
|
||||
|
||||
import Struct from './codec/Struct';
|
||||
import Block, { BlockValue } from './Block';
|
||||
import Hash from './Hash';
|
||||
import Justification from './Justification';
|
||||
|
||||
type SignedBlockValue = {
|
||||
@@ -33,6 +34,13 @@ export default class SignedBlock extends Struct {
|
||||
return this.get('block') as Block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Block/header [[Hash]]
|
||||
*/
|
||||
get hash (): Hash {
|
||||
return this.block.hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Justification]]
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user