Status type (#256)

This commit is contained in:
Jaco Greeff
2018-10-12 09:35:23 +02:00
committed by GitHub
parent 0f64f90d40
commit 5975e237e3
3 changed files with 71 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
// Copyright 2017-2018 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Base from './codec/Base';
// Implements a type that does not contain anything (apart from `null`)
export default class Null extends Base<null> {
constructor () {
super(null);
}
byteLength (): number {
return 0;
}
fromJSON (input: any): Null {
return this;
}
fromU8a (input: Uint8Array): Null {
return this;
}
toJSON (): any {
return null;
}
toU8a (isBare?: boolean): Uint8Array {
return new Uint8Array();
}
toString (): string {
return '';
}
}
+32
View File
@@ -0,0 +1,32 @@
// Copyright 2017-2018 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import EnumType from './codec/EnumType';
import Vector from './codec/Vector';
import Hash from './Hash';
import Null from './Null';
import Text from './Text';
export class Broadcast extends Vector.with(Text) {
}
export class Dropped extends Null {
}
export class Finalised extends Hash {
}
export class Usurped extends Hash {
}
export default class Status extends EnumType<Finalised | Usurped | Broadcast | Dropped> {
constructor (index?: number) {
super([
Finalised,
Usurped,
Broadcast,
Dropped
], index);
}
}
+3
View File
@@ -42,6 +42,8 @@ export { default as MethodIndex } from './MethodIndex';
export { default as MisbehaviorReport } from './MisbehaviorReport';
export { default as Moment } from './Moment';
export { default as NewAccountOutcome } from './NewAccountOutcome';
// NOTE only used internally atm
// export { default as Null } from './Null';
// NOTE Nonce is renamed to Index
export { default as Index } from './Nonce';
export { default as Origin } from './Origin';
@@ -56,6 +58,7 @@ export { default as ReferendumIndex } from './ReferendumIndex';
export { default as RuntimeVersion } from './RuntimeVersion';
export { default as Signature } from './Signature';
export { default as SignedBlock } from './SignedBlock';
export { default as Status } from './Status';
export { default as StorageChangeSet } from './StorageChangeSet';
export { default as StorageData } from './StorageData';
export { default as StorageKey } from './StorageKey';