Rework uniqTypes without duplication (#1316)

* Rework uniqTypes without  duplication

* Extra info for vX -> v7 conversion

* Add vX to naming

* Rework unwrap return

* Ignore gathering unique for v0

* Fix getUniq for V0 (well, def. throw-away, but anyway...)

* compareMap cleanup

* Cleanup author extraction

* Add modules via Struct.with (Metadata)

* Revert "Add modules via Struct.with (Metadata)"

This reverts commit 0666c3014cf840fb4ab26a5231cdf67dbe977bd7.

* Consistency in injected vs defined classes (Metadata)

* Add isTrue/isFalse to Bool

* Meta PlainType/MapType in registry

* Fix wrong v6 imports

* Extract storage modifier

* Split additional Metadata classes into interfaces

* Minor cleanups in type naming

* Static json renames

* Convert most V0 classes to interfaces

* Additional meta classes to interfaces

* No classes for Metadata V0 & V1 anymore

* Rename json imports

* Base cleanups

* Add polkadot static
This commit is contained in:
Jaco Greeff
2019-08-18 15:01:21 +02:00
committed by GitHub
parent b685b29e8c
commit c7c76f6edb
75 changed files with 12231 additions and 7922 deletions
+10 -12
View File
@@ -19,34 +19,32 @@ const _Header: Constructor<Header> = Struct.with(runtimeTypes.types.Header);
export default class HeaderExtended extends _Header {
private _author?: AccountId;
public constructor (header: Header | null = null, sessionValidators: AccountId[] = []) {
public constructor (header?: Header, sessionValidators?: AccountId[]) {
super(header);
if (!header || !header.digest || !sessionValidators.length) {
return;
}
this._author = this.extractAuthor(sessionValidators);
}
const [pitem] = header.digest.logsWith('PreRuntime');
private extractAuthor (sessionValidators: AccountId[] = []): AccountId | undefined {
const [pitem] = this.digest.logsWith('PreRuntime');
// extract from the substrate 2.0 PreRuntime digest
if (pitem) {
const [engine, data] = pitem.asPreRuntime;
if (engine.isBabe || engine.isAura) {
this._author = engine.extractAuthor(data, sessionValidators);
}
return engine.extractAuthor(data, sessionValidators);
} else {
const [citem] = header.digest.logsWith('Consensus');
const [citem] = this.digest.logsWith('Consensus');
// extract author from the consensus (substrate 1.0, digest)
if (citem) {
const [engine, data] = citem.asConsensus;
if (engine.isAura) {
this._author = engine.extractAuthor(data, sessionValidators);
}
return engine.extractAuthor(data, sessionValidators);
}
}
return undefined;
}
/**