Browse Source

Prettier format

Leszek Wiesner 4 years ago
parent
commit
921337729b
39 changed files with 2612 additions and 2410 deletions
  1. 6 1
      types/.prettierignore
  2. 16 16
      types/src/JoyEnum.ts
  3. 27 26
      types/src/JoyStruct.ts
  4. 102 96
      types/src/common.ts
  5. 2 2
      types/src/content-working-group/ChannelId.ts
  6. 294 262
      types/src/content-working-group/index.ts
  7. 172 169
      types/src/council/index.ts
  8. 20 17
      types/src/discovery.ts
  9. 233 212
      types/src/forum.ts
  10. 205 177
      types/src/hiring/index.ts
  11. 21 63
      types/src/hiring/schemas/role.schema.json
  12. 36 36
      types/src/hiring/schemas/role.schema.typings.ts
  13. 38 39
      types/src/index.ts
  14. 74 69
      types/src/media.ts
  15. 55 55
      types/src/members.ts
  16. 74 63
      types/src/mint/index.ts
  17. 198 182
      types/src/proposals.ts
  18. 58 52
      types/src/recurring-rewards/index.ts
  19. 43 40
      types/src/roles.ts
  20. 117 101
      types/src/stake/index.ts
  21. 1 1
      types/src/versioned-store/ClassId.ts
  22. 90 85
      types/src/versioned-store/EntityCodec.ts
  23. 1 1
      types/src/versioned-store/EntityId.ts
  24. 57 54
      types/src/versioned-store/PropertyType.ts
  25. 19 21
      types/src/versioned-store/PropertyTypeName.ts
  26. 64 50
      types/src/versioned-store/PropertyValue.ts
  27. 106 96
      types/src/versioned-store/index.ts
  28. 56 54
      types/src/versioned-store/permissions/ClassPermissions.ts
  29. 22 19
      types/src/versioned-store/permissions/EntityPermissions.ts
  30. 22 19
      types/src/versioned-store/permissions/PropertyOfClass.ts
  31. 22 20
      types/src/versioned-store/permissions/batching/ParametrizedClassPropertyValue.ts
  32. 26 23
      types/src/versioned-store/permissions/batching/index.ts
  33. 36 20
      types/src/versioned-store/permissions/batching/operation-types.ts
  34. 60 51
      types/src/versioned-store/permissions/batching/operations.ts
  35. 16 12
      types/src/versioned-store/permissions/batching/parametrized-entity.ts
  36. 27 29
      types/src/versioned-store/permissions/batching/parametrized-property-value.ts
  37. 16 16
      types/src/versioned-store/permissions/index.ts
  38. 22 22
      types/src/versioned-store/permissions/reference-constraint.ts
  39. 158 139
      types/src/working-group/index.ts

+ 6 - 1
types/.prettierignore

@@ -1 +1,6 @@
-**
+**/*.js
+**/*.d.ts
+!.eslintrc.js
+hiring/schemas/role.schema.json
+lib/
+build/

+ 16 - 16
types/src/JoyEnum.ts

@@ -1,39 +1,39 @@
-import { Constructor } from '@polkadot/types/types';
-import { Enum } from '@polkadot/types/codec';
-import { EnumConstructor } from '@polkadot/types/codec/Enum';
+import { Constructor } from '@polkadot/types/types'
+import { Enum } from '@polkadot/types/codec'
+import { EnumConstructor } from '@polkadot/types/codec/Enum'
 
 export interface ExtendedEnum<Types extends Record<string, Constructor>> extends Enum {
-  isOfType: (type: keyof Types) => boolean;
-  asType<TypeKey extends keyof Types>(type: TypeKey): InstanceType<Types[TypeKey]>;
-};
+  isOfType: (type: keyof Types) => boolean
+  asType<TypeKey extends keyof Types>(type: TypeKey): InstanceType<Types[TypeKey]>
+}
 
-export interface ExtendedEnumConstructor<Types extends Record<string, Constructor>> extends EnumConstructor<ExtendedEnum<Types>> {
-  create<TypeKey extends keyof Types>(typeKey: TypeKey, value: InstanceType<Types[TypeKey]>): ExtendedEnum<Types>;
+export interface ExtendedEnumConstructor<Types extends Record<string, Constructor>>
+  extends EnumConstructor<ExtendedEnum<Types>> {
+  create<TypeKey extends keyof Types>(typeKey: TypeKey, value: InstanceType<Types[TypeKey]>): ExtendedEnum<Types>
 }
 
 // Helper for creating extended Enum type with TS-compatible isOfType and asType helpers
-export function JoyEnum<Types extends Record<string, Constructor>>(types: Types): ExtendedEnumConstructor<Types>
-{
+export function JoyEnum<Types extends Record<string, Constructor>>(types: Types): ExtendedEnumConstructor<Types> {
   // Unique values check
   if (Object.values(types).some((val, i) => Object.values(types).indexOf(val, i + 1) !== -1)) {
-    throw new Error('Values passed to JoyEnum are not unique. Create an individual class for each value.');
+    throw new Error('Values passed to JoyEnum are not unique. Create an individual class for each value.')
   }
 
   return class JoyEnumObject extends Enum {
     public static create<TypeKey extends keyof Types>(typeKey: TypeKey, value: InstanceType<Types[TypeKey]>) {
-      return new JoyEnumObject({ [typeKey]: value });
+      return new JoyEnumObject({ [typeKey]: value })
     }
     constructor(value?: any, index?: number) {
-      super(types, value, index);
+      super(types, value, index)
     }
     public isOfType(typeKey: keyof Types) {
-      return this.value instanceof types[typeKey];
+      return this.value instanceof types[typeKey]
     }
     public asType<TypeKey extends keyof Types>(typeKey: TypeKey) {
       if (!(this.value instanceof types[typeKey])) {
-        throw new Error(`Enum.asType(${typeKey}) - value is not of type ${typeKey}`);
+        throw new Error(`Enum.asType(${typeKey}) - value is not of type ${typeKey}`)
       }
-      return this.value as InstanceType<Types[TypeKey]>;
+      return this.value as InstanceType<Types[TypeKey]>
     }
   }
 }

+ 27 - 26
types/src/JoyStruct.ts

@@ -1,43 +1,44 @@
-import { Option, Struct, Enum } from '@polkadot/types/codec';
-import { Text, bool as Bool } from '@polkadot/types';
-import { Codec } from '@polkadot/types/types';
+import { Option, Struct, Enum } from '@polkadot/types/codec'
+import { Text, bool as Bool } from '@polkadot/types'
+import { Codec } from '@polkadot/types/types'
 
-export class JoyStruct<T extends {
-  [K: string]: Codec;
-}> extends Struct {
-
-  getField<C extends Codec> (name: keyof T): C {
-    return super.get(name as string) as C;
+export class JoyStruct<
+  T extends {
+    [K: string]: Codec
+  }
+> extends Struct {
+  getField<C extends Codec>(name: keyof T): C {
+    return super.get(name as string) as C
   }
 
-  getString (name: keyof T): string {
-    return this.getField<Text>(name).toString();
+  getString(name: keyof T): string {
+    return this.getField<Text>(name).toString()
   }
 
-  getBoolean (name: keyof T): boolean {
-    return this.getField<Bool>(name).valueOf();
+  getBoolean(name: keyof T): boolean {
+    return this.getField<Bool>(name).valueOf()
   }
 
-  getEnumAsString<EnumValue extends string> (name: keyof T): EnumValue {
-    return this.getField<Enum>(name).toString() as EnumValue;
+  getEnumAsString<EnumValue extends string>(name: keyof T): EnumValue {
+    return this.getField<Enum>(name).toString() as EnumValue
   }
 
-  unwrapOrUndefined<C extends Codec> (name: keyof T): C | undefined {
-    return this.getField<Option<C>>(name).unwrapOr(undefined);
+  unwrapOrUndefined<C extends Codec>(name: keyof T): C | undefined {
+    return this.getField<Option<C>>(name).unwrapOr(undefined)
   }
 
-  getOptionalString (name: keyof T): string | undefined {
-    const text = this.unwrapOrUndefined<Text>(name);
-    return text ? text.toString() : undefined;
+  getOptionalString(name: keyof T): string | undefined {
+    const text = this.unwrapOrUndefined<Text>(name)
+    return text ? text.toString() : undefined
   }
 
-  cloneValues (): T {
-    const objectClone = {} as { [K: string]: Codec };
+  cloneValues(): T {
+    const objectClone = {} as { [K: string]: Codec }
 
     super.forEach((v, k) => {
-      objectClone[k] = v; // shallow copy acceptable ?
-    });
+      objectClone[k] = v // shallow copy acceptable ?
+    })
 
-    return objectClone as T;
+    return objectClone as T
   }
-}
+}

+ 102 - 96
types/src/common.ts

@@ -1,12 +1,12 @@
-import { Struct, Option, Text, bool, Vec, u16, u32, u64, getTypeRegistry, Null } from "@polkadot/types";
-import { BlockNumber, Moment } from '@polkadot/types/interfaces';
-import { Codec } from "@polkadot/types/types";
+import { Struct, Option, Text, bool, Vec, u16, u32, u64, getTypeRegistry, Null } from '@polkadot/types'
+import { BlockNumber, Moment } from '@polkadot/types/interfaces'
+import { Codec } from '@polkadot/types/types'
 // we get 'moment' because it is a dependency of @polkadot/util, via @polkadot/keyring
-import moment from 'moment';
-import { JoyStruct } from './JoyStruct';
-import { JoyEnum } from './JoyEnum';
-export { JoyStruct } from './JoyStruct';
-export { JoyEnum } from './JoyEnum';
+import moment from 'moment'
+import { JoyStruct } from './JoyStruct'
+import { JoyEnum } from './JoyEnum'
+export { JoyStruct } from './JoyStruct'
+export { JoyEnum } from './JoyEnum'
 
 // Treat a BTreeSet as a Vec since it is encoded in the same way
 export class BTreeSet<T extends Codec> extends Vec<T> {}
@@ -19,120 +19,126 @@ export class ThreadId extends u64 {}
 export class PostId extends u64 {}
 
 export type BlockAndTimeType = {
-    block: BlockNumber,
-    time: Moment
-};
+  block: BlockNumber
+  time: Moment
+}
 
 export class BlockAndTime extends Struct {
-    constructor (value?: BlockAndTimeType) {
-        super({
-            block: u32, // BlockNumber
-            time: u64, // Moment
-        }, value);
-    }
-
-    get block (): BlockNumber {
-        return this.get('block') as BlockNumber;
+  constructor(value?: BlockAndTimeType) {
+    super(
+      {
+        block: u32, // BlockNumber
+        time: u64, // Moment
+      },
+      value
+    )
+  }
+
+  get block(): BlockNumber {
+    return this.get('block') as BlockNumber
+  }
+
+  get time(): Moment {
+    return this.get('time') as Moment
+  }
+
+  static newEmpty(): BlockAndTime {
+    return new BlockAndTime({} as BlockAndTime)
+  }
+
+  get momentDate(): moment.Moment {
+    const YEAR_2000_MILLISECONDS = 946684801000
+
+    // overflowing in ~270,000 years
+    const timestamp = this.time.toNumber()
+
+    // TODO: remove once https://github.com/Joystream/joystream/issues/705 is resolved
+    // due to a bug, timestamp can be either in seconds or milliseconds
+    let timestampInMillis = timestamp
+    if (timestamp < YEAR_2000_MILLISECONDS) {
+      // timestamp is in seconds
+      timestampInMillis = timestamp * 1000
     }
 
-    get time (): Moment {
-        return this.get('time') as Moment;
-    }
-
-    static newEmpty (): BlockAndTime {
-        return new BlockAndTime({} as BlockAndTime);
-    }
-
-    get momentDate (): moment.Moment {
-        const YEAR_2000_MILLISECONDS = 946684801000;
-
-        // overflowing in ~270,000 years
-        const timestamp = this.time.toNumber();
-
-        // TODO: remove once https://github.com/Joystream/joystream/issues/705 is resolved
-        // due to a bug, timestamp can be either in seconds or milliseconds
-        let timestampInMillis = timestamp;
-        if (timestamp < YEAR_2000_MILLISECONDS) {
-          // timestamp is in seconds
-          timestampInMillis = timestamp * 1000;
-        }
-
-        return moment(timestampInMillis);
-      }
+    return moment(timestampInMillis)
+  }
 }
 
 export function getTextPropAsString(struct: Struct, fieldName: string): string {
-    return (struct.get(fieldName) as Text).toString();
+  return (struct.get(fieldName) as Text).toString()
 }
 
 export function getBoolPropAsBoolean(struct: Struct, fieldName: string): boolean {
-    return (struct.get(fieldName) as bool).valueOf();
+  return (struct.get(fieldName) as bool).valueOf()
 }
 
 export function getOptionPropOrUndefined<T extends Codec>(struct: Struct, fieldName: string): T | undefined {
-    return (struct.get(fieldName) as Option<T>).unwrapOr(undefined);
+  return (struct.get(fieldName) as Option<T>).unwrapOr(undefined)
 }
 
 export class OptionText extends Option.with(Text) {
-    static none(): OptionText {
-        return new Option(Text, null);
-    }
+  static none(): OptionText {
+    return new Option(Text, null)
+  }
 
-    static some(text: string): OptionText {
-        return new Option(Text, text);
-    }
+  static some(text: string): OptionText {
+    return new Option(Text, text)
+  }
 }
 
 export type InputValidationLengthConstraintType = {
-    min: u16,
-    max_min_diff: u16
-};
+  min: u16
+  max_min_diff: u16
+}
 
 export class InputValidationLengthConstraint extends JoyStruct<InputValidationLengthConstraintType> {
-    constructor (value: InputValidationLengthConstraintType) {
-      super({
+  constructor(value: InputValidationLengthConstraintType) {
+    super(
+      {
         min: u16,
-        max_min_diff: u16
-      }, value);
-    }
-
-    static createWithMaxAllowed() {
-      return new InputValidationLengthConstraint({
-        min: new u16(1),
-        max_min_diff: new u16(65534) // Max allowed without causing u16 overflow
-      })
-    }
-
-    get min (): u16 {
-      return this.getField('min');
-    }
-
-    get max_min_diff (): u16 {
-      return this.getField('max_min_diff');
-    }
-
-    get max (): u16 {
-      return new u16(this.min.add(this.max_min_diff));
-    }
+        max_min_diff: u16,
+      },
+      value
+    )
+  }
+
+  static createWithMaxAllowed() {
+    return new InputValidationLengthConstraint({
+      min: new u16(1),
+      max_min_diff: new u16(65534), // Max allowed without causing u16 overflow
+    })
+  }
+
+  get min(): u16 {
+    return this.getField('min')
+  }
+
+  get max_min_diff(): u16 {
+    return this.getField('max_min_diff')
+  }
+
+  get max(): u16 {
+    return new u16(this.min.add(this.max_min_diff))
+  }
 }
 
 export const WorkingGroupDef = {
-  Storage: Null
-} as const;
-export type WorkingGroupKey = keyof typeof WorkingGroupDef;
-export class WorkingGroup extends JoyEnum(WorkingGroupDef) { };
+  Storage: Null,
+} as const
+export type WorkingGroupKey = keyof typeof WorkingGroupDef
+export class WorkingGroup extends JoyEnum(WorkingGroupDef) {}
 
 export function registerCommonTypes() {
-    const typeRegistry = getTypeRegistry();
-
-    typeRegistry.register({
-      Credential,
-      CredentialSet,
-      BlockAndTime,
-      ThreadId,
-      PostId,
-      InputValidationLengthConstraint,
-      BTreeSet, // Is this even necessary?
-      WorkingGroup
-    });
+  const typeRegistry = getTypeRegistry()
+
+  typeRegistry.register({
+    Credential,
+    CredentialSet,
+    BlockAndTime,
+    ThreadId,
+    PostId,
+    InputValidationLengthConstraint,
+    BTreeSet, // Is this even necessary?
+    WorkingGroup,
+  })
 }

+ 2 - 2
types/src/content-working-group/ChannelId.ts

@@ -1,3 +1,3 @@
-import { ActorId } from '../members';
+import { ActorId } from '../members'
 
-export default class ChannelId extends ActorId {};
+export default class ChannelId extends ActorId {}

+ 294 - 262
types/src/content-working-group/index.ts

@@ -1,206 +1,216 @@
-import { getTypeRegistry, BTreeMap, Enum, bool, u8, u32, Text, GenericAccountId, Null , Option, Vec, u16 } from '@polkadot/types';
-import { BlockNumber, AccountId } from '@polkadot/types/interfaces';
-import { BTreeSet, JoyStruct, OptionText, Credential } from '../common';
-import { ActorId, MemberId } from '../members';
-import { StakeId } from '../stake';
-import { OpeningId, ApplicationId, ApplicationRationingPolicy, StakingPolicy } from '../hiring/index';
-import { RewardRelationshipId } from '../recurring-rewards';
-
-import ChannelId from './ChannelId';
-export { ChannelId };
-export class CuratorId extends ActorId {};
-export class CuratorOpeningId extends OpeningId {};
-export class CuratorApplicationId extends ApplicationId {};
-export class LeadId extends ActorId {};
-export class PrincipalId extends Credential {};
-
-export class OptionalText extends OptionText {};
-
-export type ChannelContentTypeValue =
-  'Video' |
-  'Music' |
-  'Ebook';
-
-export const ChannelContentTypeAllValues: ChannelContentTypeValue[] = [
-  'Video',
-  'Music',
-  'Ebook'
-];
+import {
+  getTypeRegistry,
+  BTreeMap,
+  Enum,
+  bool,
+  u8,
+  u32,
+  Text,
+  GenericAccountId,
+  Null,
+  Option,
+  Vec,
+  u16,
+} from '@polkadot/types'
+import { BlockNumber, AccountId } from '@polkadot/types/interfaces'
+import { BTreeSet, JoyStruct, OptionText, Credential } from '../common'
+import { ActorId, MemberId } from '../members'
+import { StakeId } from '../stake'
+import { OpeningId, ApplicationId, ApplicationRationingPolicy, StakingPolicy } from '../hiring/index'
+import { RewardRelationshipId } from '../recurring-rewards'
+
+import ChannelId from './ChannelId'
+export { ChannelId }
+export class CuratorId extends ActorId {}
+export class CuratorOpeningId extends OpeningId {}
+export class CuratorApplicationId extends ApplicationId {}
+export class LeadId extends ActorId {}
+export class PrincipalId extends Credential {}
+
+export class OptionalText extends OptionText {}
+
+export type ChannelContentTypeValue = 'Video' | 'Music' | 'Ebook'
+
+export const ChannelContentTypeAllValues: ChannelContentTypeValue[] = ['Video', 'Music', 'Ebook']
 
 export class ChannelContentType extends Enum {
-  constructor (value?: ChannelContentTypeValue, index?: number) {
-    super(
-      ChannelContentTypeAllValues,
-      value, index);
+  constructor(value?: ChannelContentTypeValue, index?: number) {
+    super(ChannelContentTypeAllValues, value, index)
   }
-};
+}
 
-export type ChannelPublicationStatusValue =
-  'Public' |
-  'Unlisted';
+export type ChannelPublicationStatusValue = 'Public' | 'Unlisted'
 
-export const ChannelPublicationStatusAllValues: ChannelPublicationStatusValue[] = [
-  'Public',
-  'Unlisted'
-];
+export const ChannelPublicationStatusAllValues: ChannelPublicationStatusValue[] = ['Public', 'Unlisted']
 
 export class ChannelPublicationStatus extends Enum {
-  constructor (value?: ChannelPublicationStatusValue, index?: number) {
-    super(
-      ChannelPublicationStatusAllValues,
-      value, index);
+  constructor(value?: ChannelPublicationStatusValue, index?: number) {
+    super(ChannelPublicationStatusAllValues, value, index)
   }
-};
+}
 
-export type ChannelCurationStatusValue =
-  'Normal' |
-  'Censored';
+export type ChannelCurationStatusValue = 'Normal' | 'Censored'
 
-export const ChannelCurationStatusAllValues: ChannelCurationStatusValue[] = [
-  'Normal',
-  'Censored'
-];
+export const ChannelCurationStatusAllValues: ChannelCurationStatusValue[] = ['Normal', 'Censored']
 
 export class ChannelCurationStatus extends Enum {
-  constructor (value?: ChannelCurationStatusValue, index?: number) {
-    super(
-      ChannelCurationStatusAllValues,
-      value, index);
+  constructor(value?: ChannelCurationStatusValue, index?: number) {
+    super(ChannelCurationStatusAllValues, value, index)
   }
-};
+}
 
 export type IChannel = {
-  verified: bool,
-  handle: Text, // Vec<u8>,
-  title: OptionalText,
-  description: OptionalText,
-  avatar: OptionalText,
-  banner: OptionalText,
-  content: ChannelContentType,
-  owner: MemberId,
-  role_account: AccountId,
-  publication_status: ChannelPublicationStatus,
-  curation_status: ChannelCurationStatus,
-  created: BlockNumber,
-  principal_id: PrincipalId,
-};
+  verified: bool
+  handle: Text // Vec<u8>,
+  title: OptionalText
+  description: OptionalText
+  avatar: OptionalText
+  banner: OptionalText
+  content: ChannelContentType
+  owner: MemberId
+  role_account: AccountId
+  publication_status: ChannelPublicationStatus
+  curation_status: ChannelCurationStatus
+  created: BlockNumber
+  principal_id: PrincipalId
+}
 export class Channel extends JoyStruct<IChannel> {
-  constructor (value?: IChannel) {
-    super({
-      verified: bool,
-      handle: Text, // Vec.with(u8),
-      title: OptionalText,
-      description: OptionalText,
-      avatar: OptionalText,
-      banner: OptionalText,
-      content: ChannelContentType,
-      owner: MemberId,
-      role_account: GenericAccountId,
-      publication_status: ChannelPublicationStatus,
-      curation_status: ChannelCurationStatus,
-      created: u32, // BlockNumber,
-      principal_id: PrincipalId,
-    }, value);
-  }
-};
+  constructor(value?: IChannel) {
+    super(
+      {
+        verified: bool,
+        handle: Text, // Vec.with(u8),
+        title: OptionalText,
+        description: OptionalText,
+        avatar: OptionalText,
+        banner: OptionalText,
+        content: ChannelContentType,
+        owner: MemberId,
+        role_account: GenericAccountId,
+        publication_status: ChannelPublicationStatus,
+        curation_status: ChannelCurationStatus,
+        created: u32, // BlockNumber,
+        principal_id: PrincipalId,
+      },
+      value
+    )
+  }
+}
 
 export class CurationActor extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         Lead: Null,
-        Curator: CuratorId
+        Curator: CuratorId,
       },
-      value, index);
+      value,
+      index
+    )
   }
-};
+}
 
 export class Principal extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         Lead: Null,
         Curator: CuratorId,
-        ChannelOwner: ChannelId
+        ChannelOwner: ChannelId,
       },
-      value, index);
+      value,
+      index
+    )
   }
-};
+}
 
 export type ICuratorRoleStakeProfile = {
-  stake_id: StakeId,
-  termination_unstaking_period: Option<BlockNumber>,
-  exit_unstaking_period: Option<BlockNumber>,
-};
+  stake_id: StakeId
+  termination_unstaking_period: Option<BlockNumber>
+  exit_unstaking_period: Option<BlockNumber>
+}
 export class CuratorRoleStakeProfile extends JoyStruct<ICuratorRoleStakeProfile> {
-  constructor (value?: ICuratorRoleStakeProfile) {
-    super({
-      stake_id: StakeId,
-      termination_unstaking_period: Option.with(u32),
-      exit_unstaking_period: Option.with(u32),
-    }, value);
+  constructor(value?: ICuratorRoleStakeProfile) {
+    super(
+      {
+        stake_id: StakeId,
+        termination_unstaking_period: Option.with(u32),
+        exit_unstaking_period: Option.with(u32),
+      },
+      value
+    )
   }
 
   get stake_id(): StakeId {
     return this.getField<StakeId>('stake_id')
   }
-};
+}
 
 export class CuratorExitInitiationOrigin extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         Lead: Null,
         Curator: Null,
       },
-      value, index);
+      value,
+      index
+    )
   }
 }
 
 export type ICuratorExitSummary = {
-  origin: CuratorExitInitiationOrigin,
-  initiated_at_block_number: BlockNumber,
-  rationale_text: Vec<u8>,
-};
+  origin: CuratorExitInitiationOrigin
+  initiated_at_block_number: BlockNumber
+  rationale_text: Vec<u8>
+}
 export class CuratorExitSummary extends JoyStruct<ICuratorExitSummary> {
-  constructor (value?: ICuratorExitSummary) {
-    super({
-      origin: CuratorExitInitiationOrigin,
-      initiated_at_block_number: u32,
-      rationale_text: Text,
-    }, value);
+  constructor(value?: ICuratorExitSummary) {
+    super(
+      {
+        origin: CuratorExitInitiationOrigin,
+        initiated_at_block_number: u32,
+        rationale_text: Text,
+      },
+      value
+    )
   }
-};
+}
 
 export enum CuratorRoleStakeKeys {
-    Active = 'Active',
-    Unstaking = 'Unstaking',
-    Exited = 'Exited',
+  Active = 'Active',
+  Unstaking = 'Unstaking',
+  Exited = 'Exited',
 }
 export class CuratorRoleStage extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         [CuratorRoleStakeKeys.Active]: Null,
         [CuratorRoleStakeKeys.Unstaking]: CuratorExitSummary,
         [CuratorRoleStakeKeys.Exited]: CuratorExitSummary,
       },
-      value, index);
+      value,
+      index
+    )
   }
-};
+}
 
 export type ICuratorInduction = {
-  lead: LeadId,
-  curator_application_id: CuratorApplicationId,
-  at_block: BlockNumber,
-};
+  lead: LeadId
+  curator_application_id: CuratorApplicationId
+  at_block: BlockNumber
+}
 export class CuratorInduction extends JoyStruct<ICuratorInduction> {
-  constructor (value?: ICuratorInduction) {
-    super({
-      lead: LeadId,
-      curator_application_id: CuratorApplicationId,
-      at_block: u32,
-    }, value);
+  constructor(value?: ICuratorInduction) {
+    super(
+      {
+        lead: LeadId,
+        curator_application_id: CuratorApplicationId,
+        at_block: u32,
+      },
+      value
+    )
   }
 
   get lead(): LeadId {
@@ -213,32 +223,35 @@ export class CuratorInduction extends JoyStruct<ICuratorInduction> {
 
   // Helper for working-group compatibility
   get worker_application_id(): CuratorApplicationId {
-    return this.curator_application_id;
+    return this.curator_application_id
   }
 
   get at_block(): u32 {
     return this.getField<u32>('at_block')
   }
-};
+}
 
 export type ICurator = {
-  role_account: AccountId,
-  reward_relationship: Option<RewardRelationshipId>,
-  role_stake_profile: Option<CuratorRoleStakeProfile>,
-  stage: CuratorRoleStage,
-  induction: CuratorInduction,
-  principal_id: PrincipalId,
-};
+  role_account: AccountId
+  reward_relationship: Option<RewardRelationshipId>
+  role_stake_profile: Option<CuratorRoleStakeProfile>
+  stage: CuratorRoleStage
+  induction: CuratorInduction
+  principal_id: PrincipalId
+}
 export class Curator extends JoyStruct<ICurator> {
-  constructor (value?: ICurator) {
-    super({
-      role_account: GenericAccountId,
-      reward_relationship: Option.with(RewardRelationshipId),
-      role_stake_profile: Option.with(CuratorRoleStakeProfile),
-      stage: CuratorRoleStage,
-      induction: CuratorInduction,
-      principal_id: PrincipalId,
-    }, value);
+  constructor(value?: ICurator) {
+    super(
+      {
+        role_account: GenericAccountId,
+        reward_relationship: Option.with(RewardRelationshipId),
+        role_stake_profile: Option.with(CuratorRoleStakeProfile),
+        stage: CuratorRoleStage,
+        induction: CuratorInduction,
+        principal_id: PrincipalId,
+      },
+      value
+    )
   }
 
   get role_account(): GenericAccountId {
@@ -247,7 +260,7 @@ export class Curator extends JoyStruct<ICurator> {
 
   // Helper for working-group compatibility
   get role_account_id(): GenericAccountId {
-    return this.role_account;
+    return this.role_account
   }
 
   get reward_relationship(): Option<RewardRelationshipId> {
@@ -271,24 +284,27 @@ export class Curator extends JoyStruct<ICurator> {
   }
 
   get is_active(): boolean {
-    return (this.stage.type == CuratorRoleStakeKeys.Active)
+    return this.stage.type == CuratorRoleStakeKeys.Active
   }
-};
+}
 
 export type ICuratorApplication = {
-  role_account: AccountId,
-  curator_opening_id: CuratorOpeningId,
-  member_id: MemberId,
-  application_id: ApplicationId,
-};
+  role_account: AccountId
+  curator_opening_id: CuratorOpeningId
+  member_id: MemberId
+  application_id: ApplicationId
+}
 export class CuratorApplication extends JoyStruct<ICuratorApplication> {
-  constructor (value?: ICuratorApplication) {
-    super({
-      role_account: GenericAccountId,
-      curator_opening_id: CuratorOpeningId,
-      member_id: MemberId,
-      application_id: ApplicationId,
-    }, value);
+  constructor(value?: ICuratorApplication) {
+    super(
+      {
+        role_account: GenericAccountId,
+        curator_opening_id: CuratorOpeningId,
+        member_id: MemberId,
+        application_id: ApplicationId,
+      },
+      value
+    )
   }
 
   get role_account(): GenericAccountId {
@@ -297,7 +313,7 @@ export class CuratorApplication extends JoyStruct<ICuratorApplication> {
 
   // Helper for working-group compatibility
   get role_account_id(): GenericAccountId {
-    return this.role_account;
+    return this.role_account
   }
 
   get curator_opening_id(): CuratorOpeningId {
@@ -306,7 +322,7 @@ export class CuratorApplication extends JoyStruct<ICuratorApplication> {
 
   // Helper for working-group compatibility
   get opening_id(): CuratorOpeningId {
-    return this.curator_opening_id;
+    return this.curator_opening_id
   }
 
   get member_id(): MemberId {
@@ -316,62 +332,70 @@ export class CuratorApplication extends JoyStruct<ICuratorApplication> {
   get application_id(): ApplicationId {
     return this.getField<ApplicationId>('application_id')
   }
-};
+}
 
 export type ISlashableTerms = {
-    max_count: u16,
-    max_percent_pts_per_time: u16,
-};
+  max_count: u16
+  max_percent_pts_per_time: u16
+}
 export class SlashableTerms extends JoyStruct<ISlashableTerms> {
-  constructor (value?: ISlashableTerms) {
-    super({
-      max_count: u16,
-      max_percent_pts_per_time: u16,
-    }, value);
+  constructor(value?: ISlashableTerms) {
+    super(
+      {
+        max_count: u16,
+        max_percent_pts_per_time: u16,
+      },
+      value
+    )
   }
-};
+}
 
 export class SlashingTerms extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         Unslashable: Null,
         Slashable: SlashableTerms,
       },
-      value, index);
+      value,
+      index
+    )
   }
-};
+}
 
 export type IOpeningPolicyCommitment = {
-  application_rationing_policy: Option<ApplicationRationingPolicy>,
-  max_review_period_length: BlockNumber,
-  application_staking_policy: Option<StakingPolicy>,
-  role_staking_policy: Option<StakingPolicy>,
-  role_slashing_terms: SlashingTerms,
-  fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>,
-  fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>,
-  fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>,
-  terminate_curator_application_stake_unstaking_period: Option<BlockNumber>,
-  terminate_curator_role_stake_unstaking_period: Option<BlockNumber>,
-  exit_curator_role_application_stake_unstaking_period: Option<BlockNumber>,
-  exit_curator_role_stake_unstaking_period: Option<BlockNumber>,
-};
+  application_rationing_policy: Option<ApplicationRationingPolicy>
+  max_review_period_length: BlockNumber
+  application_staking_policy: Option<StakingPolicy>
+  role_staking_policy: Option<StakingPolicy>
+  role_slashing_terms: SlashingTerms
+  fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>
+  fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>
+  fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>
+  terminate_curator_application_stake_unstaking_period: Option<BlockNumber>
+  terminate_curator_role_stake_unstaking_period: Option<BlockNumber>
+  exit_curator_role_application_stake_unstaking_period: Option<BlockNumber>
+  exit_curator_role_stake_unstaking_period: Option<BlockNumber>
+}
 export class OpeningPolicyCommitment extends JoyStruct<IOpeningPolicyCommitment> {
-  constructor (value?: IOpeningPolicyCommitment) {
-    super({
-      application_rationing_policy: Option.with(ApplicationRationingPolicy),
-      max_review_period_length: u32, // BlockNumber,
-      application_staking_policy: Option.with(StakingPolicy),
-      role_staking_policy: Option.with(StakingPolicy),
-      role_slashing_terms: SlashingTerms,
-      fill_opening_successful_applicant_application_stake_unstaking_period: Option.with(u32),
-      fill_opening_failed_applicant_application_stake_unstaking_period: Option.with(u32),
-      fill_opening_failed_applicant_role_stake_unstaking_period: Option.with(u32),
-      terminate_curator_application_stake_unstaking_period: Option.with(u32),
-      terminate_curator_role_stake_unstaking_period: Option.with(u32),
-      exit_curator_role_application_stake_unstaking_period: Option.with(u32),
-      exit_curator_role_stake_unstaking_period: Option.with(u32),
-    }, value);
+  constructor(value?: IOpeningPolicyCommitment) {
+    super(
+      {
+        application_rationing_policy: Option.with(ApplicationRationingPolicy),
+        max_review_period_length: u32, // BlockNumber,
+        application_staking_policy: Option.with(StakingPolicy),
+        role_staking_policy: Option.with(StakingPolicy),
+        role_slashing_terms: SlashingTerms,
+        fill_opening_successful_applicant_application_stake_unstaking_period: Option.with(u32),
+        fill_opening_failed_applicant_application_stake_unstaking_period: Option.with(u32),
+        fill_opening_failed_applicant_role_stake_unstaking_period: Option.with(u32),
+        terminate_curator_application_stake_unstaking_period: Option.with(u32),
+        terminate_curator_role_stake_unstaking_period: Option.with(u32),
+        exit_curator_role_application_stake_unstaking_period: Option.with(u32),
+        exit_curator_role_stake_unstaking_period: Option.with(u32),
+      },
+      value
+    )
   }
 
   get application_rationing_policy(): Option<ApplicationRationingPolicy> {
@@ -421,21 +445,24 @@ export class OpeningPolicyCommitment extends JoyStruct<IOpeningPolicyCommitment>
   get exit_curator_role_stake_unstaking_period(): Option<u32> {
     return this.getField<Option<u32>>('exit_curator_role_stake_unstaking_period')
   }
-};
+}
 
 // Not entierly sure that using BTreeSet will work correctly when reading/decoding this type from chain state
 export type ICuratorOpening = {
-  opening_id: OpeningId,
-  curator_applications: BTreeSet<CuratorApplicationId>,
-  policy_commitment: OpeningPolicyCommitment,
-};
+  opening_id: OpeningId
+  curator_applications: BTreeSet<CuratorApplicationId>
+  policy_commitment: OpeningPolicyCommitment
+}
 export class CuratorOpening extends JoyStruct<ICuratorOpening> {
-  constructor (value?: ICuratorOpening) {
-    super({
-      opening_id: OpeningId,
-      curator_applications: BTreeSet.with(CuratorApplicationId),
-      policy_commitment: OpeningPolicyCommitment,
-    }, value);
+  constructor(value?: ICuratorOpening) {
+    super(
+      {
+        opening_id: OpeningId,
+        curator_applications: BTreeSet.with(CuratorApplicationId),
+        policy_commitment: OpeningPolicyCommitment,
+      },
+      value
+    )
   }
 
   get opening_id(): OpeningId {
@@ -444,47 +471,54 @@ export class CuratorOpening extends JoyStruct<ICuratorOpening> {
 
   // Helper for working-group compatibility
   get hiring_opening_id(): OpeningId {
-    return this.opening_id;
+    return this.opening_id
   }
-};
+}
 
 export type IExitedLeadRole = {
-  initiated_at_block_number: BlockNumber,
-};
+  initiated_at_block_number: BlockNumber
+}
 export class ExitedLeadRole extends JoyStruct<IExitedLeadRole> {
-  constructor (value?: IExitedLeadRole) {
-    super({
-      initiated_at_block_number: u32,
-    }, value);
+  constructor(value?: IExitedLeadRole) {
+    super(
+      {
+        initiated_at_block_number: u32,
+      },
+      value
+    )
   }
-
-};
+}
 
 export class LeadRoleState extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         Active: Null,
         Exited: ExitedLeadRole,
       },
-      value, index);
+      value,
+      index
+    )
   }
 }
 
 export type ILead = {
-  role_account: AccountId,
-  reward_relationship: Option<RewardRelationshipId>,
-  inducted: BlockNumber,
-  stage: LeadRoleState,
-};
+  role_account: AccountId
+  reward_relationship: Option<RewardRelationshipId>
+  inducted: BlockNumber
+  stage: LeadRoleState
+}
 export class Lead extends JoyStruct<ILead> {
-  constructor (value?: ILead) {
-    super({
-      role_account: GenericAccountId,
-      reward_relationship: Option.with(RewardRelationshipId),
-      inducted: u32,
-      stage: LeadRoleState,
-    }, value);
+  constructor(value?: ILead) {
+    super(
+      {
+        role_account: GenericAccountId,
+        reward_relationship: Option.with(RewardRelationshipId),
+        inducted: u32,
+        stage: LeadRoleState,
+      },
+      value
+    )
   }
 
   get role_account(): GenericAccountId {
@@ -493,7 +527,7 @@ export class Lead extends JoyStruct<ILead> {
 
   // Helper for working-group compatibility
   get role_account_id(): GenericAccountId {
-    return this.role_account;
+    return this.role_account
   }
 
   get reward_relationship(): Option<RewardRelationshipId> {
@@ -503,30 +537,28 @@ export class Lead extends JoyStruct<ILead> {
   get stage(): LeadRoleState {
     return this.getField('stage')
   }
-};
+}
 
 export class WorkingGroupUnstaker extends Enum {
-  constructor (value?: any, index?: number) {
+  constructor(value?: any, index?: number) {
     super(
       {
         Lead: LeadId,
         Curator: CuratorId,
       },
-      value, index);
+      value,
+      index
+    )
   }
 }
 
 export class CuratorApplicationIdToCuratorIdMap extends BTreeMap<ApplicationId, CuratorId> {
-  constructor (value?: any) {
-    super(
-      ApplicationId,
-      CuratorId,
-      value,
-    );
+  constructor(value?: any) {
+    super(ApplicationId, CuratorId, value)
   }
 }
 
-export function registerContentWorkingGroupTypes () {
+export function registerContentWorkingGroupTypes() {
   try {
     getTypeRegistry().register({
       ChannelId: 'u64',
@@ -549,9 +581,9 @@ export function registerContentWorkingGroupTypes () {
       Principal,
       WorkingGroupUnstaker,
       CuratorApplicationIdToCuratorIdMap,
-      CuratorApplicationIdSet: Vec.with(CuratorApplicationId)
-    });
+      CuratorApplicationIdSet: Vec.with(CuratorApplicationId),
+    })
   } catch (err) {
-    console.error('Failed to register custom types of content working group module', err);
+    console.error('Failed to register custom types of content working group module', err)
   }
 }

+ 172 - 169
types/src/council/index.ts

@@ -1,200 +1,203 @@
-import { Enum, Option } from "@polkadot/types/codec";
-import { getTypeRegistry, Struct, Vec } from "@polkadot/types";
-import { BlockNumber, AccountId, Balance, Hash } from "@polkadot/types/interfaces";
-import { u32 } from "@polkadot/types/primitive";
-import { MemberId } from "../members";
+import { Enum, Option } from '@polkadot/types/codec'
+import { getTypeRegistry, Struct, Vec } from '@polkadot/types'
+import { BlockNumber, AccountId, Balance, Hash } from '@polkadot/types/interfaces'
+import { u32 } from '@polkadot/types/primitive'
+import { MemberId } from '../members'
 
 export type TransferableStake = {
-    seat: Balance;
-    backing: Balance;
-};
+  seat: Balance
+  backing: Balance
+}
 
 export type ElectionStake = {
-    new: Balance;
-    transferred: Balance;
-};
+  new: Balance
+  transferred: Balance
+}
 
 export class Backer extends Struct {
-    constructor(value?: any) {
-      super(
-        {
-          member: "AccountId",
-          stake: "Balance"
-        },
-        value
-      );
-    }
-
-    get member(): MemberId {
-      return this.get("member") as MemberId;
-    }
-
-    get stake(): Balance {
-      return this.get("stake") as Balance;
-    }
+  constructor(value?: any) {
+    super(
+      {
+        member: 'AccountId',
+        stake: 'Balance',
+      },
+      value
+    )
+  }
+
+  get member(): MemberId {
+    return this.get('member') as MemberId
+  }
+
+  get stake(): Balance {
+    return this.get('stake') as Balance
+  }
 }
 
 export class Backers extends Vec.with(Backer) {}
 export class Seat extends Struct {
-    constructor(value?: any) {
-      super(
-        {
-          member: "AccountId",
-          stake: "Balance",
-          backers: Backers
-        },
-        value
-      );
-    }
-
-    get member(): AccountId {
-      return this.get("member") as AccountId;
-    }
-
-    get stake(): Balance {
-      return this.get("stake") as Balance;
-    }
-
-    get backers(): Backers {
-      return this.get("backers") as Backers;
-    }
+  constructor(value?: any) {
+    super(
+      {
+        member: 'AccountId',
+        stake: 'Balance',
+        backers: Backers,
+      },
+      value
+    )
+  }
+
+  get member(): AccountId {
+    return this.get('member') as AccountId
+  }
+
+  get stake(): Balance {
+    return this.get('stake') as Balance
+  }
+
+  get backers(): Backers {
+    return this.get('backers') as Backers
+  }
 }
 
 export class Seats extends Vec.with(Seat) {}
 
 export type SealedVote = {
-    voter: AccountId;
-    commitment: Hash;
-    stake: ElectionStake;
-    vote: Option<AccountId>;
-};
+  voter: AccountId
+  commitment: Hash
+  stake: ElectionStake
+  vote: Option<AccountId>
+}
 
 export class Announcing extends u32 {}
 export class Voting extends u32 {}
 export class Revealing extends u32 {}
 
 export class ElectionStage extends Enum {
-    constructor(value?: any, index?: number) {
-        super({
-            Announcing,
-            Voting,
-            Revealing
-        }, value, index);
-    }
-
-    /** Create a new Announcing stage. */
-    static Announcing(endsAt: BlockNumber | number): ElectionStage {
-      return this.newElectionStage("Announcing", endsAt);
-    }
-
-    /** Create a new Voting stage. */
-    static Voting(endsAt: BlockNumber | number): ElectionStage {
-      return this.newElectionStage("Voting", endsAt);
-    }
-
-    /** Create a new Revealing stage. */
-    static Revealing(endsAt: BlockNumber | number): ElectionStage {
-      return this.newElectionStage("Revealing", endsAt);
-    }
-
-    static newElectionStage(stageName: string, endsAt: BlockNumber | number) {
-      return new ElectionStage({ [stageName]: endsAt });
-    }
+  constructor(value?: any, index?: number) {
+    super(
+      {
+        Announcing,
+        Voting,
+        Revealing,
+      },
+      value,
+      index
+    )
+  }
+
+  /** Create a new Announcing stage. */
+  static Announcing(endsAt: BlockNumber | number): ElectionStage {
+    return this.newElectionStage('Announcing', endsAt)
+  }
+
+  /** Create a new Voting stage. */
+  static Voting(endsAt: BlockNumber | number): ElectionStage {
+    return this.newElectionStage('Voting', endsAt)
+  }
+
+  /** Create a new Revealing stage. */
+  static Revealing(endsAt: BlockNumber | number): ElectionStage {
+    return this.newElectionStage('Revealing', endsAt)
+  }
+
+  static newElectionStage(stageName: string, endsAt: BlockNumber | number) {
+    return new ElectionStage({ [stageName]: endsAt })
+  }
 }
 
-export type AnyElectionStage = Announcing | Voting | Revealing;
+export type AnyElectionStage = Announcing | Voting | Revealing
 
 export type IElectionParameters = {
-    announcing_period: BlockNumber;
-    voting_period: BlockNumber;
-    revealing_period: BlockNumber;
-    council_size: u32;
-    candidacy_limit: u32;
-    new_term_duration: BlockNumber;
-    min_council_stake: Balance;
-    min_voting_stake: Balance;
-};
+  announcing_period: BlockNumber
+  voting_period: BlockNumber
+  revealing_period: BlockNumber
+  council_size: u32
+  candidacy_limit: u32
+  new_term_duration: BlockNumber
+  min_council_stake: Balance
+  min_voting_stake: Balance
+}
 
 export class ElectionParameters extends Struct {
-    constructor(value?: any) {
-      super(
-        {
-          announcing_period: "BlockNumber",
-          voting_period: "BlockNumber",
-          revealing_period: "BlockNumber",
-          council_size: "u32",
-          candidacy_limit: "u32",
-          new_term_duration: "BlockNumber",
-          min_council_stake: "Balance",
-          min_voting_stake: "Balance"
-        },
-        value
-      );
-    }
-    get announcing_period () {
-      return this.get('announcing_period') as BlockNumber;
-    }
-    get voting_period () {
-      return this.get('voting_period') as BlockNumber;
-    }
-    get revealing_period () {
-      return this.get('revealing_period') as BlockNumber;
-    }
-    get council_size () {
-      return this.get('council_size') as u32;
-    }
-    get candidacy_limit () {
-      return this.get('candidacy_limit') as u32;
-    }
-    get new_term_duration () {
-      return this.get('new_term_duration') as BlockNumber;
-    }
-    get min_council_stake () {
-      return this.get('min_council_stake') as Balance;
-    }
-    get min_voting_stake () {
-      return this.get('min_voting_stake') as Balance;
-    }
+  constructor(value?: any) {
+    super(
+      {
+        announcing_period: 'BlockNumber',
+        voting_period: 'BlockNumber',
+        revealing_period: 'BlockNumber',
+        council_size: 'u32',
+        candidacy_limit: 'u32',
+        new_term_duration: 'BlockNumber',
+        min_council_stake: 'Balance',
+        min_voting_stake: 'Balance',
+      },
+      value
+    )
+  }
+  get announcing_period() {
+    return this.get('announcing_period') as BlockNumber
+  }
+  get voting_period() {
+    return this.get('voting_period') as BlockNumber
+  }
+  get revealing_period() {
+    return this.get('revealing_period') as BlockNumber
+  }
+  get council_size() {
+    return this.get('council_size') as u32
+  }
+  get candidacy_limit() {
+    return this.get('candidacy_limit') as u32
+  }
+  get new_term_duration() {
+    return this.get('new_term_duration') as BlockNumber
+  }
+  get min_council_stake() {
+    return this.get('min_council_stake') as Balance
+  }
+  get min_voting_stake() {
+    return this.get('min_voting_stake') as Balance
+  }
 }
 
-
 // TODO Refactor: split this function and move to corresponding modules: election and proposals.
 export function registerCouncilAndElectionTypes() {
-    try {
-        const typeRegistry = getTypeRegistry();
-
-        typeRegistry.register({
-            ElectionStage,
-            ElectionStake: {
-                new: "Balance",
-                transferred: "Balance"
-            },
-            SealedVote: {
-                voter: "AccountId",
-                commitment: "Hash",
-                stake: "ElectionStake",
-                vote: "Option<AccountId>"
-            },
-            TransferableStake: {
-                seat: "Balance",
-                backing: "Balance"
-            },
-            ElectionParameters: {
-                announcing_period: "BlockNumber",
-                voting_period: "BlockNumber",
-                revealing_period: "BlockNumber",
-                council_size: "u32",
-                candidacy_limit: "u32",
-                new_term_duration: "BlockNumber",
-                min_council_stake: "Balance",
-                min_voting_stake: "Balance"
-            },
-            Seat,
-            Seats,
-            Backer,
-            Backers,
-        });
-    } catch (err) {
-        console.error("Failed to register custom types for council and election modules", err);
-    }
-}
+  try {
+    const typeRegistry = getTypeRegistry()
+
+    typeRegistry.register({
+      ElectionStage,
+      ElectionStake: {
+        new: 'Balance',
+        transferred: 'Balance',
+      },
+      SealedVote: {
+        voter: 'AccountId',
+        commitment: 'Hash',
+        stake: 'ElectionStake',
+        vote: 'Option<AccountId>',
+      },
+      TransferableStake: {
+        seat: 'Balance',
+        backing: 'Balance',
+      },
+      ElectionParameters: {
+        announcing_period: 'BlockNumber',
+        voting_period: 'BlockNumber',
+        revealing_period: 'BlockNumber',
+        council_size: 'u32',
+        candidacy_limit: 'u32',
+        new_term_duration: 'BlockNumber',
+        min_council_stake: 'Balance',
+        min_voting_stake: 'Balance',
+      },
+      Seat,
+      Seats,
+      Backer,
+      Backers,
+    })
+  } catch (err) {
+    console.error('Failed to register custom types for council and election modules', err)
+  }
+}

+ 20 - 17
types/src/discovery.ts

@@ -1,36 +1,39 @@
-import { Struct } from '@polkadot/types/codec';
-import { getTypeRegistry, Text, u32 } from '@polkadot/types';
-import { BlockNumber } from '@polkadot/types/interfaces';
+import { Struct } from '@polkadot/types/codec'
+import { getTypeRegistry, Text, u32 } from '@polkadot/types'
+import { BlockNumber } from '@polkadot/types/interfaces'
 
 export class IPNSIdentity extends Text {}
 export class Url extends Text {}
 
 export class AccountInfo extends Struct {
-  constructor (value?: any) {
-    super({
-      identity: IPNSIdentity,
-      expires_at: u32 // BlockNumber
-    }, value);
+  constructor(value?: any) {
+    super(
+      {
+        identity: IPNSIdentity,
+        expires_at: u32, // BlockNumber
+      },
+      value
+    )
   }
 
-  get identity (): IPNSIdentity {
-    return this.get('identity') as IPNSIdentity;
+  get identity(): IPNSIdentity {
+    return this.get('identity') as IPNSIdentity
   }
 
-  get expires_at (): BlockNumber {
-    return this.get('expires_at') as BlockNumber;
+  get expires_at(): BlockNumber {
+    return this.get('expires_at') as BlockNumber
   }
 }
 
-export function registerDiscoveryTypes () {
+export function registerDiscoveryTypes() {
   try {
-    const typeRegistry = getTypeRegistry();
+    const typeRegistry = getTypeRegistry()
     typeRegistry.register({
       Url,
       IPNSIdentity,
-      AccountInfo
-    });
+      AccountInfo,
+    })
   } catch (err) {
-    console.error('Failed to register custom types of discovery module', err);
+    console.error('Failed to register custom types of discovery module', err)
   }
 }

+ 233 - 212
types/src/forum.ts

@@ -1,54 +1,60 @@
-import { getTypeRegistry, bool, u32, u64, Text, Option, Vec as Vector, GenericAccountId } from '@polkadot/types';
-import { AccountId } from '@polkadot/types/interfaces';
-import { BlockAndTime, JoyStruct, ThreadId, PostId } from './common';
+import { getTypeRegistry, bool, u32, u64, Text, Option, Vec as Vector, GenericAccountId } from '@polkadot/types'
+import { AccountId } from '@polkadot/types/interfaces'
+import { BlockAndTime, JoyStruct, ThreadId, PostId } from './common'
 
 export type ModerationActionType = {
-  moderated_at: BlockAndTime,
-  moderator_id: AccountId,
+  moderated_at: BlockAndTime
+  moderator_id: AccountId
   rationale: Text
-};
+}
 
 export class ModerationAction extends JoyStruct<ModerationActionType> {
-  constructor (value: ModerationActionType) {
-    super({
-      moderated_at: BlockAndTime,
-      moderator_id: GenericAccountId,
-      rationale: Text
-    }, value);
+  constructor(value: ModerationActionType) {
+    super(
+      {
+        moderated_at: BlockAndTime,
+        moderator_id: GenericAccountId,
+        rationale: Text,
+      },
+      value
+    )
   }
 
-  get moderated_at (): BlockAndTime {
-    return this.getField('moderated_at');
+  get moderated_at(): BlockAndTime {
+    return this.getField('moderated_at')
   }
 
-  get moderator_id (): AccountId {
-    return this.getField('moderator_id');
+  get moderator_id(): AccountId {
+    return this.getField('moderator_id')
   }
 
-  get rationale (): string {
-    return this.getString('rationale');
+  get rationale(): string {
+    return this.getString('rationale')
   }
 }
 
 export type PostTextChangeType = {
-  expired_at: BlockAndTime,
+  expired_at: BlockAndTime
   text: Text
-};
+}
 
 export class PostTextChange extends JoyStruct<PostTextChangeType> {
-  constructor (value: PostTextChangeType) {
-    super({
-      expired_at: BlockAndTime,
-      text: Text
-    }, value);
+  constructor(value: PostTextChangeType) {
+    super(
+      {
+        expired_at: BlockAndTime,
+        text: Text,
+      },
+      value
+    )
   }
 
-  get expired_at (): BlockAndTime {
-    return this.getField('expired_at');
+  get expired_at(): BlockAndTime {
+    return this.getField('expired_at')
   }
 
-  get text (): string {
-    return this.getString('text');
+  get text(): string {
+    return this.getString('text')
   }
 }
 
@@ -68,318 +74,333 @@ export class ReplyId extends u64 {}
 export class VecReplyId extends Vector.with(ReplyId) {}
 
 export type ChildPositionInParentCategoryType = {
-  parent_id: CategoryId,
+  parent_id: CategoryId
   child_nr_in_parent_category: u32
-};
+}
 
 export class ChildPositionInParentCategory extends JoyStruct<ChildPositionInParentCategoryType> {
-  constructor (value: ChildPositionInParentCategoryType) {
-    super({
-      parent_id: CategoryId,
-      child_nr_in_parent_category: u32
-    }, value);
+  constructor(value: ChildPositionInParentCategoryType) {
+    super(
+      {
+        parent_id: CategoryId,
+        child_nr_in_parent_category: u32,
+      },
+      value
+    )
   }
 
-  get parent_id (): CategoryId {
-    return this.getField('parent_id');
+  get parent_id(): CategoryId {
+    return this.getField('parent_id')
   }
 
-  get child_nr_in_parent_category (): u32 {
-    return this.getField('child_nr_in_parent_category');
+  get child_nr_in_parent_category(): u32 {
+    return this.getField('child_nr_in_parent_category')
   }
 }
 
 export class OptionChildPositionInParentCategory extends Option.with(ChildPositionInParentCategory) {}
 
 export type CategoryType = {
-  id: CategoryId,
-  title: Text,
-  description: Text,
-  created_at: BlockAndTime,
-  deleted: bool,
-  archived: bool,
-  num_direct_subcategories: u32,
-  num_direct_unmoderated_threads: u32,
-  num_direct_moderated_threads: u32,
-  position_in_parent_category: OptionChildPositionInParentCategory,
+  id: CategoryId
+  title: Text
+  description: Text
+  created_at: BlockAndTime
+  deleted: bool
+  archived: bool
+  num_direct_subcategories: u32
+  num_direct_unmoderated_threads: u32
+  num_direct_moderated_threads: u32
+  position_in_parent_category: OptionChildPositionInParentCategory
   moderator_id: AccountId
-};
+}
 
 export class Category extends JoyStruct<CategoryType> {
-  constructor (value: CategoryType) {
-    super({
-      id: CategoryId,
-      title: Text,
-      description: Text,
-      created_at: BlockAndTime,
-      deleted: bool,
-      archived: bool,
-      num_direct_subcategories: u32,
-      num_direct_unmoderated_threads: u32,
-      num_direct_moderated_threads: u32,
-      position_in_parent_category: OptionChildPositionInParentCategory,
-      moderator_id: GenericAccountId
-    }, value);
+  constructor(value: CategoryType) {
+    super(
+      {
+        id: CategoryId,
+        title: Text,
+        description: Text,
+        created_at: BlockAndTime,
+        deleted: bool,
+        archived: bool,
+        num_direct_subcategories: u32,
+        num_direct_unmoderated_threads: u32,
+        num_direct_moderated_threads: u32,
+        position_in_parent_category: OptionChildPositionInParentCategory,
+        moderator_id: GenericAccountId,
+      },
+      value
+    )
   }
 
-  static newEmpty (): Category {
-    return new Category({} as CategoryType);
+  static newEmpty(): Category {
+    return new Category({} as CategoryType)
   }
 
-  get id (): CategoryId {
-    return this.getField('id');
+  get id(): CategoryId {
+    return this.getField('id')
   }
 
-  get title (): string {
-    return this.getString('title');
+  get title(): string {
+    return this.getString('title')
   }
 
-  get description (): string {
-    return this.getString('description');
+  get description(): string {
+    return this.getString('description')
   }
 
-  get created_at (): BlockAndTime {
-    return this.getField('created_at');
+  get created_at(): BlockAndTime {
+    return this.getField('created_at')
   }
 
-  get deleted (): boolean {
-    return this.getBoolean('deleted');
+  get deleted(): boolean {
+    return this.getBoolean('deleted')
   }
 
-  get archived (): boolean {
-    return this.getBoolean('archived');
+  get archived(): boolean {
+    return this.getBoolean('archived')
   }
 
-  get num_direct_subcategories (): u32 {
-    return this.getField('num_direct_subcategories');
+  get num_direct_subcategories(): u32 {
+    return this.getField('num_direct_subcategories')
   }
 
-  get num_direct_unmoderated_threads (): u32 {
-    return this.getField('num_direct_unmoderated_threads');
+  get num_direct_unmoderated_threads(): u32 {
+    return this.getField('num_direct_unmoderated_threads')
   }
 
-  get num_direct_moderated_threads (): u32 {
-    return this.getField('num_direct_moderated_threads');
+  get num_direct_moderated_threads(): u32 {
+    return this.getField('num_direct_moderated_threads')
   }
 
-  get num_threads_created (): u32 {
-    return new u32(this.num_direct_unmoderated_threads.add(this.num_direct_moderated_threads));
+  get num_threads_created(): u32 {
+    return new u32(this.num_direct_unmoderated_threads.add(this.num_direct_moderated_threads))
   }
 
-  get hasSubcategories (): boolean {
-    return !this.num_direct_subcategories.isZero();
+  get hasSubcategories(): boolean {
+    return !this.num_direct_subcategories.isZero()
   }
 
-  get hasUnmoderatedThreads (): boolean {
-    return !this.num_direct_unmoderated_threads.isZero();
+  get hasUnmoderatedThreads(): boolean {
+    return !this.num_direct_unmoderated_threads.isZero()
   }
 
-  get position_in_parent_category (): Option<ChildPositionInParentCategory> {
-    return this.getField('position_in_parent_category');
+  get position_in_parent_category(): Option<ChildPositionInParentCategory> {
+    return this.getField('position_in_parent_category')
   }
 
-  get parent_id (): CategoryId | undefined {
-    const pos = this.position_in_parent_category;
-    return pos.isSome ? pos.unwrap().parent_id : undefined;
+  get parent_id(): CategoryId | undefined {
+    const pos = this.position_in_parent_category
+    return pos.isSome ? pos.unwrap().parent_id : undefined
   }
 
-  get isRoot (): boolean {
-    return this.parent_id === undefined;
+  get isRoot(): boolean {
+    return this.parent_id === undefined
   }
 
-  get nr_in_parent (): u32 | undefined {
-    const pos = this.position_in_parent_category;
-    return pos.isSome ? pos.unwrap().child_nr_in_parent_category : undefined;
+  get nr_in_parent(): u32 | undefined {
+    const pos = this.position_in_parent_category
+    return pos.isSome ? pos.unwrap().child_nr_in_parent_category : undefined
   }
 
-  get moderator_id (): AccountId {
-    return this.getField('moderator_id');
+  get moderator_id(): AccountId {
+    return this.getField('moderator_id')
   }
 }
 
 export type ThreadType = {
-  id: ThreadId,
-  title: Text,
-  category_id: CategoryId,
-  nr_in_category: u32,
-  moderation: OptionModerationAction,
-  num_unmoderated_posts: u32,
-  num_moderated_posts: u32,
-  created_at: BlockAndTime,
+  id: ThreadId
+  title: Text
+  category_id: CategoryId
+  nr_in_category: u32
+  moderation: OptionModerationAction
+  num_unmoderated_posts: u32
+  num_moderated_posts: u32
+  created_at: BlockAndTime
   author_id: AccountId
-};
+}
 
 export class Thread extends JoyStruct<ThreadType> {
-  constructor (value: ThreadType) {
-    super({
-      id: ThreadId,
-      title: Text,
-      category_id: CategoryId,
-      nr_in_category: u32,
-      moderation: OptionModerationAction,
-      num_unmoderated_posts: u32,
-      num_moderated_posts: u32,
-      created_at: BlockAndTime,
-      author_id: GenericAccountId
-    }, value);
+  constructor(value: ThreadType) {
+    super(
+      {
+        id: ThreadId,
+        title: Text,
+        category_id: CategoryId,
+        nr_in_category: u32,
+        moderation: OptionModerationAction,
+        num_unmoderated_posts: u32,
+        num_moderated_posts: u32,
+        created_at: BlockAndTime,
+        author_id: GenericAccountId,
+      },
+      value
+    )
   }
 
-  static newEmpty (): Thread {
-    return new Thread({} as ThreadType);
+  static newEmpty(): Thread {
+    return new Thread({} as ThreadType)
   }
 
-  get id (): ThreadId {
-    return this.getField('id');
+  get id(): ThreadId {
+    return this.getField('id')
   }
 
-  get title (): string {
-    return this.getString('title');
+  get title(): string {
+    return this.getString('title')
   }
 
-  get category_id (): CategoryId {
-    return this.getField('category_id');
+  get category_id(): CategoryId {
+    return this.getField('category_id')
   }
 
-  get nr_in_category (): u32 {
-    return this.getField('nr_in_category');
+  get nr_in_category(): u32 {
+    return this.getField('nr_in_category')
   }
 
-  get moderation (): ModerationAction | undefined {
-    return this.unwrapOrUndefined('moderation');
+  get moderation(): ModerationAction | undefined {
+    return this.unwrapOrUndefined('moderation')
   }
 
-  get moderated (): boolean {
-    return this.moderation !== undefined;
+  get moderated(): boolean {
+    return this.moderation !== undefined
   }
 
-  get num_unmoderated_posts (): u32 {
-    return this.getField('num_unmoderated_posts');
+  get num_unmoderated_posts(): u32 {
+    return this.getField('num_unmoderated_posts')
   }
 
-  get num_moderated_posts (): u32 {
-    return this.getField('num_moderated_posts');
+  get num_moderated_posts(): u32 {
+    return this.getField('num_moderated_posts')
   }
 
-  get num_posts_ever_created (): u32 {
-    return new u32(this.num_unmoderated_posts.add(this.num_moderated_posts));
+  get num_posts_ever_created(): u32 {
+    return new u32(this.num_unmoderated_posts.add(this.num_moderated_posts))
   }
 
-  get created_at (): BlockAndTime {
-    return this.getField('created_at');
+  get created_at(): BlockAndTime {
+    return this.getField('created_at')
   }
 
-  get author_id (): AccountId {
-    return this.getField('author_id');
+  get author_id(): AccountId {
+    return this.getField('author_id')
   }
 }
 
 export type PostType = {
-  id: PostId,
-  thread_id: ThreadId,
-  nr_in_thread: u32,
-  current_text: Text,
-  moderation: OptionModerationAction,
-  text_change_history: VecPostTextChange,
-  created_at: BlockAndTime,
+  id: PostId
+  thread_id: ThreadId
+  nr_in_thread: u32
+  current_text: Text
+  moderation: OptionModerationAction
+  text_change_history: VecPostTextChange
+  created_at: BlockAndTime
   author_id: AccountId
-};
+}
 
 // TODO deprectated: replaced w/ Post
 export class Post extends JoyStruct<PostType> {
-  constructor (value: PostType) {
-    super({
-      id: PostId,
-      thread_id: ThreadId,
-      nr_in_thread: u32,
-      current_text: Text,
-      moderation: OptionModerationAction,
-      text_change_history: VecPostTextChange,
-      created_at: BlockAndTime,
-      author_id: GenericAccountId
-    }, value);
+  constructor(value: PostType) {
+    super(
+      {
+        id: PostId,
+        thread_id: ThreadId,
+        nr_in_thread: u32,
+        current_text: Text,
+        moderation: OptionModerationAction,
+        text_change_history: VecPostTextChange,
+        created_at: BlockAndTime,
+        author_id: GenericAccountId,
+      },
+      value
+    )
   }
 
-  static newEmpty (): Post {
-    return new Post({} as PostType);
+  static newEmpty(): Post {
+    return new Post({} as PostType)
   }
 
-  get id (): PostId {
-    return this.getField('id');
+  get id(): PostId {
+    return this.getField('id')
   }
 
-  get thread_id (): ThreadId {
-    return this.getField('thread_id');
+  get thread_id(): ThreadId {
+    return this.getField('thread_id')
   }
 
-  get nr_in_thread (): u32 {
-    return this.getField('nr_in_thread');
+  get nr_in_thread(): u32 {
+    return this.getField('nr_in_thread')
   }
 
-  get current_text (): string {
-    return this.getString('current_text');
+  get current_text(): string {
+    return this.getString('current_text')
   }
 
-  get moderation (): ModerationAction | undefined {
-    return this.unwrapOrUndefined('moderation');
+  get moderation(): ModerationAction | undefined {
+    return this.unwrapOrUndefined('moderation')
   }
 
-  get moderated (): boolean {
-    return this.moderation !== undefined;
+  get moderated(): boolean {
+    return this.moderation !== undefined
   }
 
-  get text_change_history (): VecPostTextChange {
-    return this.getField('text_change_history');
+  get text_change_history(): VecPostTextChange {
+    return this.getField('text_change_history')
   }
 
-  get created_at (): BlockAndTime {
-    return this.getField('created_at');
+  get created_at(): BlockAndTime {
+    return this.getField('created_at')
   }
 
-  get author_id (): AccountId {
-    return this.getField('author_id');
+  get author_id(): AccountId {
+    return this.getField('author_id')
   }
 }
 
 export type ReplyType = {
-  owner: AccountId,
-  thread_id: ThreadId,
-  text: Text,
+  owner: AccountId
+  thread_id: ThreadId
+  text: Text
   moderation: OptionModerationAction
-};
+}
 
 // TODO deprectated: replaced w/ Post
 export class Reply extends JoyStruct<ReplyType> {
-  constructor (value: ReplyType) {
-    super({
-      owner: GenericAccountId,
-      thread_id: ThreadId,
-      text: Text,
-      moderation: OptionModerationAction
-    }, value);
+  constructor(value: ReplyType) {
+    super(
+      {
+        owner: GenericAccountId,
+        thread_id: ThreadId,
+        text: Text,
+        moderation: OptionModerationAction,
+      },
+      value
+    )
   }
 
-  get owner (): AccountId {
-    return this.getField('owner');
+  get owner(): AccountId {
+    return this.getField('owner')
   }
 
-  get thread_id (): ThreadId {
-    return this.getField('thread_id');
+  get thread_id(): ThreadId {
+    return this.getField('thread_id')
   }
 
-  get text (): string {
-    return this.getString('text');
+  get text(): string {
+    return this.getString('text')
   }
 
-  get moderation (): ModerationAction | undefined {
-    return this.unwrapOrUndefined('moderation');
+  get moderation(): ModerationAction | undefined {
+    return this.unwrapOrUndefined('moderation')
   }
 
-  get moderated (): boolean {
-    return this.moderation !== undefined;
+  get moderated(): boolean {
+    return this.moderation !== undefined
   }
 }
 
-export function registerForumTypes () {
+export function registerForumTypes() {
   try {
     getTypeRegistry().register({
       PostTextChange,
@@ -390,9 +411,9 @@ export function registerForumTypes () {
       Thread,
       Post,
       ReplyId,
-      Reply
-    });
+      Reply,
+    })
   } catch (err) {
-    console.error('Failed to register custom types of forum module', err);
+    console.error('Failed to register custom types of forum module', err)
   }
 }

+ 205 - 177
types/src/hiring/index.ts

@@ -1,8 +1,8 @@
-import { getTypeRegistry, Null, u128, u64, u32, Vec, Option, Text } from '@polkadot/types';
-import { Enum } from '@polkadot/types/codec';
-import { BlockNumber, Balance } from '@polkadot/types/interfaces';
-import { JoyStruct, JoyEnum } from '../common';
-import { StakeId } from '../stake';
+import { getTypeRegistry, Null, u128, u64, u32, Vec, Option, Text } from '@polkadot/types'
+import { Enum } from '@polkadot/types/codec'
+import { BlockNumber, Balance } from '@polkadot/types/interfaces'
+import { JoyStruct, JoyEnum } from '../common'
+import { StakeId } from '../stake'
 
 import { GenericJoyStreamRoleSchema } from './schemas/role.schema.typings'
 
@@ -10,24 +10,23 @@ import ajv from 'ajv'
 
 import * as role_schema_json from './schemas/role.schema.json'
 
-export class ApplicationId extends u64 { };
-export class OpeningId extends u64 { };
-
-export class CurrentBlock extends Null { };
-export class ExactBlock extends u32 { }; // BlockNumber
+export class ApplicationId extends u64 {}
+export class OpeningId extends u64 {}
 
+export class CurrentBlock extends Null {}
+export class ExactBlock extends u32 {} // BlockNumber
 
 export const ActivateOpeningAtDef = {
   CurrentBlock,
   ExactBlock,
-} as const;
+} as const
 export const ActivateOpeningAtKeys: { [k in keyof typeof ActivateOpeningAtDef]: k } = {
   CurrentBlock: 'CurrentBlock',
-  ExactBlock: 'ExactBlock'
-} as const;
-export type ActivateOpeningAtKey = keyof typeof ActivateOpeningAtDef;
+  ExactBlock: 'ExactBlock',
+} as const
+export type ActivateOpeningAtKey = keyof typeof ActivateOpeningAtDef
 // TODO: Replace with JoyEnum
-export class ActivateOpeningAt extends Enum.with(ActivateOpeningAtDef) { }
+export class ActivateOpeningAt extends Enum.with(ActivateOpeningAtDef) {}
 
 export enum ApplicationDeactivationCauseKeys {
   External = 'External',
@@ -51,47 +50,55 @@ export class ApplicationDeactivationCause extends Enum {
         ApplicationDeactivationCauseKeys.ReviewPeriodExpired,
         ApplicationDeactivationCauseKeys.OpeningFilled,
       ],
-      value, index);
+      value,
+      index
+    )
   }
-};
+}
 
 export type UnstakingApplicationStageType = {
-  deactivation_initiated: BlockNumber,
+  deactivation_initiated: BlockNumber
   cause: ApplicationDeactivationCause
-};
+}
 export class UnstakingApplicationStage extends JoyStruct<UnstakingApplicationStageType> {
   constructor(value?: UnstakingApplicationStageType) {
-    super({
-      deactivation_initiated: u32, // BlockNumber
-      cause: ApplicationDeactivationCause,
-    }, value);
+    super(
+      {
+        deactivation_initiated: u32, // BlockNumber
+        cause: ApplicationDeactivationCause,
+      },
+      value
+    )
   }
 
   get cause(): ApplicationDeactivationCause {
     return this.getField<ApplicationDeactivationCause>('cause')
   }
-};
+}
 
 export type InactiveApplicationStageType = {
-  deactivation_initiated: BlockNumber,
-  deactivated: BlockNumber,
+  deactivation_initiated: BlockNumber
+  deactivated: BlockNumber
   cause: ApplicationDeactivationCause
-};
+}
 export class InactiveApplicationStage extends JoyStruct<InactiveApplicationStageType> {
   constructor(value?: InactiveApplicationStageType) {
-    super({
-      deactivation_initiated: u32, // BlockNumber
-      deactivated: u32,
-      cause: ApplicationDeactivationCause,
-    }, value);
+    super(
+      {
+        deactivation_initiated: u32, // BlockNumber
+        deactivated: u32,
+        cause: ApplicationDeactivationCause,
+      },
+      value
+    )
   }
 
   get cause(): ApplicationDeactivationCause {
     return this.getField<ApplicationDeactivationCause>('cause')
   }
-};
+}
 
-export class ActiveApplicationStage extends Null { };
+export class ActiveApplicationStage extends Null {}
 
 // TODO: Find usages and replace with "JoyEnum-standard"
 export enum ApplicationStageKeys {
@@ -102,38 +109,44 @@ export enum ApplicationStageKeys {
 export class ApplicationStage extends JoyEnum({
   Active: ActiveApplicationStage,
   Unstaking: UnstakingApplicationStage,
-  Inactive: InactiveApplicationStage
-} as const) { };
+  Inactive: InactiveApplicationStage,
+} as const) {}
 
 export type IApplicationRationingPolicy = {
-  max_active_applicants: u32,
-};
+  max_active_applicants: u32
+}
 export class ApplicationRationingPolicy extends JoyStruct<IApplicationRationingPolicy> {
   constructor(value?: IApplicationRationingPolicy) {
-    super({
-      max_active_applicants: u32,
-    }, value);
+    super(
+      {
+        max_active_applicants: u32,
+      },
+      value
+    )
   }
 
   get max_active_applicants(): u32 {
     return this.getField<u32>('max_active_applicants')
   }
-};
+}
 
 export type WaitingToBeingOpeningStageVariantType = {
-  begins_at_block: BlockNumber,
-};
+  begins_at_block: BlockNumber
+}
 export class WaitingToBeingOpeningStageVariant extends JoyStruct<WaitingToBeingOpeningStageVariantType> {
   constructor(value?: WaitingToBeingOpeningStageVariantType) {
-    super({
-      begins_at_block: u32,
-    }, value);
+    super(
+      {
+        begins_at_block: u32,
+      },
+      value
+    )
   }
 
   get begins_at_block(): BlockNumber {
     return this.getField<BlockNumber>('begins_at_block')
   }
-};
+}
 
 // TODO: Find usages and replace them with JoyEnum helpers
 export enum OpeningDeactivationCauseKeys {
@@ -144,45 +157,51 @@ export enum OpeningDeactivationCauseKeys {
   Filled = 'Filled',
 }
 
-class OpeningDeactivationCause_CancelledBeforeActivation extends Null { };
-class OpeningDeactivationCause_CancelledAcceptingApplications extends Null { };
-class OpeningDeactivationCause_CancelledInReviewPeriod extends Null { };
-class OpeningDeactivationCause_ReviewPeriodExpired extends Null { };
-class OpeningDeactivationCause_Filled extends Null { };
+class OpeningDeactivationCause_CancelledBeforeActivation extends Null {}
+class OpeningDeactivationCause_CancelledAcceptingApplications extends Null {}
+class OpeningDeactivationCause_CancelledInReviewPeriod extends Null {}
+class OpeningDeactivationCause_ReviewPeriodExpired extends Null {}
+class OpeningDeactivationCause_Filled extends Null {}
 
 export class OpeningDeactivationCause extends JoyEnum({
-  'CancelledBeforeActivation': OpeningDeactivationCause_CancelledBeforeActivation,
-  'CancelledAcceptingApplications': OpeningDeactivationCause_CancelledAcceptingApplications,
-  'CancelledInReviewPeriod': OpeningDeactivationCause_CancelledInReviewPeriod,
-  'ReviewPeriodExpired': OpeningDeactivationCause_ReviewPeriodExpired,
-  'Filled': OpeningDeactivationCause_Filled,
-} as const) { };
+  CancelledBeforeActivation: OpeningDeactivationCause_CancelledBeforeActivation,
+  CancelledAcceptingApplications: OpeningDeactivationCause_CancelledAcceptingApplications,
+  CancelledInReviewPeriod: OpeningDeactivationCause_CancelledInReviewPeriod,
+  ReviewPeriodExpired: OpeningDeactivationCause_ReviewPeriodExpired,
+  Filled: OpeningDeactivationCause_Filled,
+} as const) {}
 
 export type IAcceptingApplications = {
-  started_accepting_applicants_at_block: BlockNumber,
-};
+  started_accepting_applicants_at_block: BlockNumber
+}
 export class AcceptingApplications extends JoyStruct<IAcceptingApplications> {
   constructor(value?: IAcceptingApplications) {
-    super({
-      started_accepting_applicants_at_block: u32,
-    }, value);
+    super(
+      {
+        started_accepting_applicants_at_block: u32,
+      },
+      value
+    )
   }
 
   get started_accepting_applicants_at_block(): BlockNumber {
     return this.getField<BlockNumber>('started_accepting_applicants_at_block')
   }
-};
+}
 
 export type IReviewPeriod = {
-  started_accepting_applicants_at_block: BlockNumber,
-  started_review_period_at_block: BlockNumber,
-};
+  started_accepting_applicants_at_block: BlockNumber
+  started_review_period_at_block: BlockNumber
+}
 export class ReviewPeriod extends JoyStruct<IReviewPeriod> {
   constructor(value?: IReviewPeriod) {
-    super({
-      started_accepting_applicants_at_block: u32,
-      started_review_period_at_block: u32,
-    }, value);
+    super(
+      {
+        started_accepting_applicants_at_block: u32,
+        started_review_period_at_block: u32,
+      },
+      value
+    )
   }
 
   get started_accepting_applicants_at_block(): BlockNumber {
@@ -192,22 +211,25 @@ export class ReviewPeriod extends JoyStruct<IReviewPeriod> {
   get started_review_period_at_block(): BlockNumber {
     return this.getField<BlockNumber>('started_review_period_at_block')
   }
-};
+}
 
 export type IDeactivated = {
-  cause: OpeningDeactivationCause,
-  deactivated_at_block: BlockNumber,
-  started_accepting_applicants_at_block: BlockNumber,
-  started_review_period_at_block: Option<BlockNumber>,
-};
+  cause: OpeningDeactivationCause
+  deactivated_at_block: BlockNumber
+  started_accepting_applicants_at_block: BlockNumber
+  started_review_period_at_block: Option<BlockNumber>
+}
 export class Deactivated extends JoyStruct<IDeactivated> {
   constructor(value?: IDeactivated) {
-    super({
-      cause: OpeningDeactivationCause,
-      deactivated_at_block: u32,
-      started_accepting_applicants_at_block: u32,
-      started_review_period_at_block: Option.with(u32),
-    }, value);
+    super(
+      {
+        cause: OpeningDeactivationCause,
+        deactivated_at_block: u32,
+        started_accepting_applicants_at_block: u32,
+        started_review_period_at_block: Option.with(u32),
+      },
+      value
+    )
   }
 
   get cause(): OpeningDeactivationCause {
@@ -225,33 +247,36 @@ export class Deactivated extends JoyStruct<IDeactivated> {
   get started_review_period_at_block(): BlockNumber {
     return this.getField<BlockNumber>('started_review_period_at_block')
   }
-};
+}
 
 export const ActiveOpeningStageDef = {
   AcceptingApplications: AcceptingApplications,
   ReviewPeriod: ReviewPeriod,
-  Deactivated: Deactivated
-} as const;
-export type ActiveOpeningStageKey = keyof typeof ActiveOpeningStageDef;
+  Deactivated: Deactivated,
+} as const
+export type ActiveOpeningStageKey = keyof typeof ActiveOpeningStageDef
 
-export class ActiveOpeningStage extends JoyEnum(ActiveOpeningStageDef) { }
+export class ActiveOpeningStage extends JoyEnum(ActiveOpeningStageDef) {}
 
 export type ActiveOpeningStageVariantType = {
-  stage: ActiveOpeningStage,
-  applications_added: Vec<ApplicationId>,//BTreeSet<ApplicationId>,
-  active_application_count: u32,
-  unstaking_application_count: u32,
-  deactivated_application_count: u32,
+  stage: ActiveOpeningStage
+  applications_added: Vec<ApplicationId> //BTreeSet<ApplicationId>,
+  active_application_count: u32
+  unstaking_application_count: u32
+  deactivated_application_count: u32
 }
 export class ActiveOpeningStageVariant extends JoyStruct<ActiveOpeningStageVariantType> {
   constructor(value?: ActiveOpeningStageVariantType) {
-    super({
-      stage: ActiveOpeningStage,
-      applications_added: Vec.with(ApplicationId),//BTreeSet<ApplicationId>,
-      active_application_count: u32,
-      unstaking_application_count: u32,
-      deactivated_application_count: u32,
-    }, value);
+    super(
+      {
+        stage: ActiveOpeningStage,
+        applications_added: Vec.with(ApplicationId), //BTreeSet<ApplicationId>,
+        active_application_count: u32,
+        unstaking_application_count: u32,
+        deactivated_application_count: u32,
+      },
+      value
+    )
   }
 
   get stage(): ActiveOpeningStage {
@@ -259,7 +284,7 @@ export class ActiveOpeningStageVariant extends JoyStruct<ActiveOpeningStageVaria
   }
 
   get is_active(): boolean {
-    return this.stage.isOfType('AcceptingApplications');
+    return this.stage.isOfType('AcceptingApplications')
   }
 }
 
@@ -270,9 +295,9 @@ export enum OpeningStageKeys {
 }
 
 export class OpeningStage extends JoyEnum({
-  'WaitingToBegin': WaitingToBeingOpeningStageVariant,
-  'Active': ActiveOpeningStageVariant
-} as const) { };
+  WaitingToBegin: WaitingToBeingOpeningStageVariant,
+  Active: ActiveOpeningStageVariant,
+} as const) {}
 
 export enum StakingAmountLimitModeKeys {
   AtLeast = 'AtLeast',
@@ -281,29 +306,27 @@ export enum StakingAmountLimitModeKeys {
 
 export class StakingAmountLimitMode extends Enum {
   constructor(value?: any, index?: number) {
-    super(
-      [
-        StakingAmountLimitModeKeys.AtLeast,
-        StakingAmountLimitModeKeys.Exact,
-      ],
-      value, index);
+    super([StakingAmountLimitModeKeys.AtLeast, StakingAmountLimitModeKeys.Exact], value, index)
   }
-};
+}
 
 export type IStakingPolicy = {
-  amount: Balance,
-  amount_mode: StakingAmountLimitMode,
-  crowded_out_unstaking_period_length: Option<BlockNumber>,
-  review_period_expired_unstaking_period_length: Option<BlockNumber>,
-};
+  amount: Balance
+  amount_mode: StakingAmountLimitMode
+  crowded_out_unstaking_period_length: Option<BlockNumber>
+  review_period_expired_unstaking_period_length: Option<BlockNumber>
+}
 export class StakingPolicy extends JoyStruct<IStakingPolicy> {
   constructor(value?: IStakingPolicy) {
-    super({
-      amount: u128,
-      amount_mode: StakingAmountLimitMode,
-      crowded_out_unstaking_period_length: Option.with(u32),
-      review_period_expired_unstaking_period_length: Option.with(u32),
-    }, value);
+    super(
+      {
+        amount: u128,
+        amount_mode: StakingAmountLimitMode,
+        crowded_out_unstaking_period_length: Option.with(u32),
+        review_period_expired_unstaking_period_length: Option.with(u32),
+      },
+      value
+    )
   }
 
   get amount(): u128 {
@@ -321,47 +344,49 @@ export class StakingPolicy extends JoyStruct<IStakingPolicy> {
   get review_period_expired_unstaking_period_length(): Option<u32> {
     return this.getField<Option<u32>>('review_period_expired_unstaking_period_length')
   }
-
-};
-export const schemaValidator: ajv.ValidateFunction = new ajv({ allErrors: true }).compile(role_schema_json);
+}
+export const schemaValidator: ajv.ValidateFunction = new ajv({ allErrors: true }).compile(role_schema_json)
 
 const OpeningHRTFallback: GenericJoyStreamRoleSchema = {
   version: 1,
-  headline: "Unknown",
+  headline: 'Unknown',
   job: {
-    title: "Unknown",
-    description: "Unknown"
+    title: 'Unknown',
+    description: 'Unknown',
   },
   application: {},
-  reward: "Unknown",
+  reward: 'Unknown',
   creator: {
     membership: {
-      handle: "Unknown"
-    }
-  }
-};
+      handle: 'Unknown',
+    },
+  },
+}
 
 export type IOpening = {
-  created: BlockNumber,
-  stage: OpeningStage,
-  max_review_period_length: BlockNumber,
-  application_rationing_policy: Option<ApplicationRationingPolicy>,
-  application_staking_policy: Option<StakingPolicy>,
-  role_staking_policy: Option<StakingPolicy>,
-  human_readable_text: Text, // Vec<u8>,
-};
+  created: BlockNumber
+  stage: OpeningStage
+  max_review_period_length: BlockNumber
+  application_rationing_policy: Option<ApplicationRationingPolicy>
+  application_staking_policy: Option<StakingPolicy>
+  role_staking_policy: Option<StakingPolicy>
+  human_readable_text: Text // Vec<u8>,
+}
 
 export class Opening extends JoyStruct<IOpening> {
   constructor(value?: IOpening) {
-    super({
-      created: u32,
-      stage: OpeningStage,
-      max_review_period_length: u32,
-      application_rationing_policy: Option.with(ApplicationRationingPolicy),
-      application_staking_policy: Option.with(StakingPolicy),
-      role_staking_policy: Option.with(StakingPolicy),
-      human_readable_text: Text, // Vec.with(u8),
-    }, value);
+    super(
+      {
+        created: u32,
+        stage: OpeningStage,
+        max_review_period_length: u32,
+        application_rationing_policy: Option.with(ApplicationRationingPolicy),
+        application_staking_policy: Option.with(StakingPolicy),
+        role_staking_policy: Option.with(StakingPolicy),
+        human_readable_text: Text, // Vec.with(u8),
+      },
+      value
+    )
   }
 
   parse_human_readable_text(): GenericJoyStreamRoleSchema | string | undefined {
@@ -376,24 +401,24 @@ export class Opening extends JoyStruct<IOpening> {
     try {
       const obj = JSON.parse(str)
       if (schemaValidator(obj) === true) {
-        return obj as unknown as GenericJoyStreamRoleSchema
+        return (obj as unknown) as GenericJoyStreamRoleSchema
       }
-      console.log("parse_human_readable_text JSON schema validation failed:", schemaValidator.errors);
+      console.log('parse_human_readable_text JSON schema validation failed:', schemaValidator.errors)
     } catch (e) {
-      console.log("parse_human_readable_text JSON schema validation failed:", e.toString())
+      console.log('parse_human_readable_text JSON schema validation failed:', e.toString())
     }
 
     return str
   }
 
   parse_human_readable_text_with_fallback(): GenericJoyStreamRoleSchema {
-    const hrt = this.parse_human_readable_text();
+    const hrt = this.parse_human_readable_text()
 
     if (typeof hrt !== 'object') {
-      return OpeningHRTFallback;
+      return OpeningHRTFallback
     }
 
-    return hrt;
+    return hrt
   }
 
   get created(): BlockNumber {
@@ -421,7 +446,7 @@ export class Opening extends JoyStruct<IOpening> {
   }
 
   get human_readable_text(): Text {
-    return this.getField<Text>('human_readable_text');
+    return this.getField<Text>('human_readable_text')
   }
 
   get max_applicants(): number {
@@ -441,31 +466,34 @@ export class Opening extends JoyStruct<IOpening> {
         return (this.stage.value as ActiveOpeningStageVariant).is_active
     }
 
-	  return false
+    return false
   }
 }
 
 export type IApplication = {
-  opening_id: OpeningId,
-  application_index_in_opening: u32,
-  add_to_opening_in_block: BlockNumber,
-  active_role_staking_id: Option<StakeId>,
-  active_application_staking_id: Option<StakeId>,
-  stage: ApplicationStage,
-  human_readable_text: Text,
+  opening_id: OpeningId
+  application_index_in_opening: u32
+  add_to_opening_in_block: BlockNumber
+  active_role_staking_id: Option<StakeId>
+  active_application_staking_id: Option<StakeId>
+  stage: ApplicationStage
+  human_readable_text: Text
 }
 
 export class Application extends JoyStruct<IApplication> {
   constructor(value?: IOpening) {
-    super({
-      opening_id: OpeningId,
-      application_index_in_opening: u32,
-      add_to_opening_in_block: u32,
-      active_role_staking_id: Option.with(StakeId),
-      active_application_staking_id: Option.with(StakeId),
-      stage: ApplicationStage,
-      human_readable_text: Text,
-    }, value);
+    super(
+      {
+        opening_id: OpeningId,
+        application_index_in_opening: u32,
+        add_to_opening_in_block: u32,
+        active_role_staking_id: Option.with(StakeId),
+        active_application_staking_id: Option.with(StakeId),
+        stage: ApplicationStage,
+        human_readable_text: Text,
+      },
+      value
+    )
   }
 
   get stage(): ApplicationStage {
@@ -498,8 +526,8 @@ export function registerHiringTypes() {
       OpeningStage,
       StakingPolicy,
       Opening,
-    });
+    })
   } catch (err) {
-    console.error('Failed to register custom types of hiring module', err);
+    console.error('Failed to register custom types of hiring module', err)
   }
 }

+ 21 - 63
types/src/hiring/schemas/role.schema.json

@@ -9,57 +9,39 @@
       "type": "string",
       "title": "Field title",
       "default": "",
-      "examples": [
-        "About you"
-      ],
+      "examples": ["About you"],
       "pattern": "^(.*)$"
     }
   },
-  "required": [
-    "version",
-    "headline",
-    "job",
-    "reward",
-    "creator",
-    "application"
-  ],
+  "required": ["version", "headline", "job", "reward", "creator", "application"],
   "properties": {
     "version": {
       "$id": "#/properties/version",
       "type": "integer",
       "title": "Schema version",
       "default": 0,
-      "examples": [
-        1
-      ]
+      "examples": [1]
     },
     "headline": {
       "$id": "#/properties/headline",
       "type": "string",
       "title": "Headline",
       "default": "",
-      "examples": [
-        "help us curate awesome content"
-      ],
+      "examples": ["help us curate awesome content"],
       "pattern": "^(.*)$"
     },
     "job": {
       "$id": "#/properties/job",
       "type": "object",
       "title": "Job specifics",
-      "required": [
-        "title",
-        "description"
-      ],
+      "required": ["title", "description"],
       "properties": {
         "title": {
           "$id": "#/properties/job/properties/title",
           "type": "string",
           "title": "Job title",
           "default": "",
-          "examples": [
-            "Content curator"
-          ],
+          "examples": ["Content curator"],
           "pattern": "^(.*)$"
         },
         "description": {
@@ -67,9 +49,7 @@
           "type": "string",
           "title": "Job description; expects HTML",
           "default": "",
-          "examples": [
-            "<p>Lorem ipsum</p>"
-          ]
+          "examples": ["<p>Lorem ipsum</p>"]
         }
       }
     },
@@ -86,10 +66,7 @@
             "$id": "#/properties/application/properties/sections/items",
             "type": "object",
             "title": "Question section",
-            "required": [
-              "title",
-              "questions"
-            ],
+            "required": ["title", "questions"],
             "properties": {
               "title": {
                 "$ref": "#/properties/application/title"
@@ -102,25 +79,18 @@
                   "$id": "#/properties/application/properties/sections/items/properties/questions/items",
                   "type": "object",
                   "title": "Question field",
-                  "required": [
-                    "title",
-                    "type"
-                  ],
+                  "required": ["title", "type"],
                   "properties": {
                     "title": {
                       "$ref": "#/properties/application/title"
                     },
                     "type": {
-      "$id": "#/properties/application/properties/questions/items/type",
-      "type": "string",
-      "title": "Question field type",
-      "default": "",
-      "examples": [
-        "text",
-		"text area"
-      ],
-      "pattern": "^(text|text area)$"
-
+                      "$id": "#/properties/application/properties/questions/items/type",
+                      "type": "string",
+                      "title": "Question field type",
+                      "default": "",
+                      "examples": ["text", "text area"],
+                      "pattern": "^(text|text area)$"
                     }
                   }
                 }
@@ -135,35 +105,27 @@
       "type": "string",
       "title": "The Reward Schema",
       "default": "",
-      "examples": [
-        "10 JOY per block"
-      ],
+      "examples": ["10 JOY per block"],
       "pattern": "^(.*)$"
     },
     "creator": {
       "$id": "#/properties/creator",
       "type": "object",
       "title": "Creator details",
-      "required": [
-        "membership"
-      ],
+      "required": ["membership"],
       "properties": {
         "membership": {
           "$id": "#/properties/creator/properties/membership",
           "type": "object",
           "title": "Entry in membership moduke",
-          "required": [
-            "handle"
-          ],
+          "required": ["handle"],
           "properties": {
             "handle": {
               "$id": "#/properties/creator/properties/membership/properties/handle",
               "type": "string",
               "title": "Handle or username",
               "default": "",
-              "examples": [
-                "5EV1NJUMouHKdNSXsArFyrryQDCixL7N1RTSivKM3rVJkwi5"
-              ],
+              "examples": ["5EV1NJUMouHKdNSXsArFyrryQDCixL7N1RTSivKM3rVJkwi5"],
               "pattern": "^(.*)$"
             }
           }
@@ -174,9 +136,7 @@
       "$id": "#/properties/process",
       "type": "object",
       "title": "Hiring process",
-      "required": [
-        "details"
-      ],
+      "required": ["details"],
       "properties": {
         "details": {
           "$id": "#/properties/process/properties/details",
@@ -187,9 +147,7 @@
             "type": "string",
             "title": "The Items Schema",
             "default": "",
-            "examples": [
-              "A"
-            ],
+            "examples": ["A"],
             "pattern": "^(.*)$"
           }
         }

+ 36 - 36
types/src/hiring/schemas/role.schema.typings.ts

@@ -5,56 +5,56 @@
  * and run json-schema-to-typescript to regenerate this file.
  */
 
-export type SchemaVersion = number;
-export type Headline = string;
-export type JobTitle = string;
-export type JobDescriptionExpectsHTML = string;
-export type QuestionFieldType = string;
-export type QuestionsFields = QuestionField[];
-export type QuestionSections = QuestionSection[];
-export type TheRewardSchema = string;
-export type HandleOrUsername = string;
-export type TheItemsSchema = string;
-export type AdditionalRolehiringProcessDetails = TheItemsSchema[];
+export type SchemaVersion = number
+export type Headline = string
+export type JobTitle = string
+export type JobDescriptionExpectsHTML = string
+export type QuestionFieldType = string
+export type QuestionsFields = QuestionField[]
+export type QuestionSections = QuestionSection[]
+export type TheRewardSchema = string
+export type HandleOrUsername = string
+export type TheItemsSchema = string
+export type AdditionalRolehiringProcessDetails = TheItemsSchema[]
 
 export interface GenericJoyStreamRoleSchema {
-  version: SchemaVersion;
-  headline: Headline;
-  job: JobSpecifics;
-  application: ApplicationDetails;
-  reward: TheRewardSchema;
-  creator: CreatorDetails;
-  process?: HiringProcess;
-  [k: string]: any;
+  version: SchemaVersion
+  headline: Headline
+  job: JobSpecifics
+  application: ApplicationDetails
+  reward: TheRewardSchema
+  creator: CreatorDetails
+  process?: HiringProcess
+  [k: string]: any
 }
 export interface JobSpecifics {
-  title: JobTitle;
-  description: JobDescriptionExpectsHTML;
-  [k: string]: any;
+  title: JobTitle
+  description: JobDescriptionExpectsHTML
+  [k: string]: any
 }
 export interface ApplicationDetails {
-  sections?: QuestionSections;
-  [k: string]: any;
+  sections?: QuestionSections
+  [k: string]: any
 }
 export interface QuestionSection {
-  title: any;
-  questions: QuestionsFields;
-  [k: string]: any;
+  title: any
+  questions: QuestionsFields
+  [k: string]: any
 }
 export interface QuestionField {
-  title: any;
-  type: QuestionFieldType;
-  [k: string]: any;
+  title: any
+  type: QuestionFieldType
+  [k: string]: any
 }
 export interface CreatorDetails {
-  membership: EntryInMembershipModuke;
-  [k: string]: any;
+  membership: EntryInMembershipModuke
+  [k: string]: any
 }
 export interface EntryInMembershipModuke {
-  handle: HandleOrUsername;
-  [k: string]: any;
+  handle: HandleOrUsername
+  [k: string]: any
 }
 export interface HiringProcess {
-  details: AdditionalRolehiringProcessDetails;
-  [k: string]: any;
+  details: AdditionalRolehiringProcessDetails
+  [k: string]: any
 }

+ 38 - 39
types/src/index.ts

@@ -1,22 +1,21 @@
+import { getTypeRegistry } from '@polkadot/types'
 
-import { getTypeRegistry } from "@polkadot/types";
-
-import * as common from "./common";
-import * as members from "./members";
-import * as council from "./council";
-import * as roles from "./roles";
-import * as forum from "./forum";
-import * as stake from "./stake";
-import * as mint from "./mint";
-import * as recurringRewards from "./recurring-rewards";
-import * as hiring from "./hiring";
-import * as versionedStore from "./versioned-store";
-import * as versionedStorePermissions from "./versioned-store/permissions";
-import * as contentWorkingGroup from "./content-working-group";
-import * as workingGroup from "./working-group";
-import * as discovery from "./discovery";
-import * as media from "./media";
-import * as proposals from "./proposals";
+import * as common from './common'
+import * as members from './members'
+import * as council from './council'
+import * as roles from './roles'
+import * as forum from './forum'
+import * as stake from './stake'
+import * as mint from './mint'
+import * as recurringRewards from './recurring-rewards'
+import * as hiring from './hiring'
+import * as versionedStore from './versioned-store'
+import * as versionedStorePermissions from './versioned-store/permissions'
+import * as contentWorkingGroup from './content-working-group'
+import * as workingGroup from './working-group'
+import * as discovery from './discovery'
+import * as media from './media'
+import * as proposals from './proposals'
 
 export {
   common,
@@ -34,30 +33,30 @@ export {
   workingGroup,
   discovery,
   media,
-  proposals
-};
+  proposals,
+}
 
 export function registerJoystreamTypes() {
-  const typeRegistry = getTypeRegistry();
+  const typeRegistry = getTypeRegistry()
 
   typeRegistry.register({
-    MemoText: "Text", // for the memo module
-  });
+    MemoText: 'Text', // for the memo module
+  })
 
-  common.registerCommonTypes();
-  members.registerMembershipTypes();
-  council.registerCouncilAndElectionTypes();
-  roles.registerRolesTypes();
-  forum.registerForumTypes();
-  stake.registerStakeTypes();
-  mint.registerMintTypes();
-  recurringRewards.registerRecurringRewardsTypes();
-  hiring.registerHiringTypes();
-  versionedStore.registerVersionedStoreTypes();
-  versionedStorePermissions.registerVersionedStorePermissionsTypes();
-  contentWorkingGroup.registerContentWorkingGroupTypes();
-  workingGroup.registerWorkingGroupTypes();
-  discovery.registerDiscoveryTypes();
-  media.registerMediaTypes();
-  proposals.registerProposalTypes();
+  common.registerCommonTypes()
+  members.registerMembershipTypes()
+  council.registerCouncilAndElectionTypes()
+  roles.registerRolesTypes()
+  forum.registerForumTypes()
+  stake.registerStakeTypes()
+  mint.registerMintTypes()
+  recurringRewards.registerRecurringRewardsTypes()
+  hiring.registerHiringTypes()
+  versionedStore.registerVersionedStoreTypes()
+  versionedStorePermissions.registerVersionedStorePermissionsTypes()
+  contentWorkingGroup.registerContentWorkingGroupTypes()
+  workingGroup.registerWorkingGroupTypes()
+  discovery.registerDiscoveryTypes()
+  media.registerMediaTypes()
+  proposals.registerProposalTypes()
 }

+ 74 - 69
types/src/media.ts

@@ -1,29 +1,29 @@
-import { Enum, Struct, Option, Vec as Vector, H256, BTreeMap , getTypeRegistry, u64, bool, Text } from '@polkadot/types';
-import { BlockAndTime } from './common';
-import { MemberId } from './members';
-import { StorageProviderId } from './working-group'; // this should be in discovery really
+import { Enum, Struct, Option, Vec as Vector, H256, BTreeMap, getTypeRegistry, u64, bool, Text } from '@polkadot/types'
+import { BlockAndTime } from './common'
+import { MemberId } from './members'
+import { StorageProviderId } from './working-group' // this should be in discovery really
 
-import { randomAsU8a } from '@polkadot/util-crypto';
-import { encodeAddress, decodeAddress } from '@polkadot/keyring';
+import { randomAsU8a } from '@polkadot/util-crypto'
+import { encodeAddress, decodeAddress } from '@polkadot/keyring'
 // import { u8aToString, stringToU8a } from '@polkadot/util';
 
 export class ContentId extends H256 {
-  static generate (): ContentId {
+  static generate(): ContentId {
     // randomAsU8a uses https://www.npmjs.com/package/tweetnacl#random-bytes-generation
-    return new ContentId(randomAsU8a());
+    return new ContentId(randomAsU8a())
   }
 
-  static decode (contentId: string): ContentId {
-    return new ContentId(decodeAddress(contentId));
+  static decode(contentId: string): ContentId {
+    return new ContentId(decodeAddress(contentId))
   }
 
-  static encode (contentId: Uint8Array): string {
+  static encode(contentId: Uint8Array): string {
     // console.log('contentId:', Buffer.from(contentId).toString('hex'))
-    return encodeAddress(contentId);
+    return encodeAddress(contentId)
   }
 
-  encode (): string {
-    return ContentId.encode(this);
+  encode(): string {
+    return ContentId.encode(this)
   }
 }
 
@@ -32,103 +32,108 @@ export class DataObjectStorageRelationshipId extends u64 {}
 
 export class VecContentId extends Vector.with(ContentId) {}
 export class OptionVecContentId extends Option.with(VecContentId) {}
-export type LiaisonJudgementKey = 'Pending' | 'Accepted' | 'Rejected';
+export type LiaisonJudgementKey = 'Pending' | 'Accepted' | 'Rejected'
 
 export class LiaisonJudgement extends Enum {
-  constructor (value?: LiaisonJudgementKey) {
-    super([
-      'Pending',
-      'Accepted',
-      'Rejected'
-    ], value);
+  constructor(value?: LiaisonJudgementKey) {
+    super(['Pending', 'Accepted', 'Rejected'], value)
   }
 }
 
 export class DataObject extends Struct {
-  constructor (value?: any) {
-    super({
-      owner: MemberId,
-      added_at: BlockAndTime,
-      type_id: DataObjectTypeId,
-      size: u64,
-      liaison: StorageProviderId,
-      liaison_judgement: LiaisonJudgement,
-      ipfs_content_id: Text,
-    }, value);
+  constructor(value?: any) {
+    super(
+      {
+        owner: MemberId,
+        added_at: BlockAndTime,
+        type_id: DataObjectTypeId,
+        size: u64,
+        liaison: StorageProviderId,
+        liaison_judgement: LiaisonJudgement,
+        ipfs_content_id: Text,
+      },
+      value
+    )
   }
 
-  get owner (): MemberId {
-    return this.get('owner') as MemberId;
+  get owner(): MemberId {
+    return this.get('owner') as MemberId
   }
 
-  get added_at (): BlockAndTime {
-    return this.get('added_at') as BlockAndTime;
+  get added_at(): BlockAndTime {
+    return this.get('added_at') as BlockAndTime
   }
 
-  get type_id (): DataObjectTypeId {
-    return this.get('type_id') as DataObjectTypeId;
+  get type_id(): DataObjectTypeId {
+    return this.get('type_id') as DataObjectTypeId
   }
 
   /** Actually it's 'size', but 'size' is already reserved by a parent class. */
-  get size_in_bytes (): u64 {
-    return this.get('size') as u64;
+  get size_in_bytes(): u64 {
+    return this.get('size') as u64
   }
 
-  get liaison (): StorageProviderId {
-    return this.get('liaison') as StorageProviderId;
+  get liaison(): StorageProviderId {
+    return this.get('liaison') as StorageProviderId
   }
 
-  get liaison_judgement (): LiaisonJudgement {
-    return this.get('liaison_judgement') as LiaisonJudgement;
+  get liaison_judgement(): LiaisonJudgement {
+    return this.get('liaison_judgement') as LiaisonJudgement
   }
 
-  get ipfs_content_id () : Text {
+  get ipfs_content_id(): Text {
     return this.get('ipfs_content_id') as Text
   }
 }
 
 export class DataObjectStorageRelationship extends Struct {
-  constructor (value?: any) {
-    super({
-      content_id: ContentId,
-      storage_provider: StorageProviderId,
-      ready: bool
-    }, value);
+  constructor(value?: any) {
+    super(
+      {
+        content_id: ContentId,
+        storage_provider: StorageProviderId,
+        ready: bool,
+      },
+      value
+    )
   }
 
-  get content_id (): ContentId {
-    return this.get('content_id') as ContentId;
+  get content_id(): ContentId {
+    return this.get('content_id') as ContentId
   }
 
-  get storage_provider (): StorageProviderId {
-    return this.get('storage_provider') as StorageProviderId;
+  get storage_provider(): StorageProviderId {
+    return this.get('storage_provider') as StorageProviderId
   }
 
-  get ready (): bool {
-    return this.get('ready') as bool;
+  get ready(): bool {
+    return this.get('ready') as bool
   }
 }
 
 export class DataObjectType extends Struct {
-  constructor (value?: any) {
-    super({
-      description: Text,
-      active: bool
-    }, value);
+  constructor(value?: any) {
+    super(
+      {
+        description: Text,
+        active: bool,
+      },
+      value
+    )
   }
 
-  get description (): Text {
-    return this.get('description') as Text;
+  get description(): Text {
+    return this.get('description') as Text
   }
 
-  get active (): bool {
-    return this.get('active') as bool;
+  get active(): bool {
+    return this.get('active') as bool
   }
 }
 
 export class DataObjectsMap extends BTreeMap.with(ContentId, DataObject) {}
 
-export function registerMediaTypes () {
+export function registerMediaTypes() {
   try {
     getTypeRegistry().register({
       ContentId,
@@ -138,9 +143,9 @@ export function registerMediaTypes () {
       DataObjectStorageRelationship,
       DataObjectTypeId,
       DataObjectType,
-      DataObjectsMap
-    });
+      DataObjectsMap,
+    })
   } catch (err) {
-    console.error('Failed to register custom types of media module', err);
+    console.error('Failed to register custom types of media module', err)
   }
 }

+ 55 - 55
types/src/members.ts

@@ -11,10 +11,10 @@ import {
   Text,
   GenericAccountId,
   Vec,
-} from "@polkadot/types";
-import { BlockNumber, Moment, BalanceOf } from "@polkadot/types/interfaces";
-import { OptionText, JoyStruct } from "./common";
-import AccountId from "@polkadot/types/primitive/Generic/AccountId";
+} from '@polkadot/types'
+import { BlockNumber, Moment, BalanceOf } from '@polkadot/types/interfaces'
+import { OptionText, JoyStruct } from './common'
+import AccountId from '@polkadot/types/primitive/Generic/AccountId'
 
 export class MemberId extends u64 {}
 export class PaidTermId extends u64 {}
@@ -34,20 +34,20 @@ export class EntryMethod extends Enum {
       },
       value,
       index
-    );
+    )
   }
 }
 
 export enum RoleKeys {
-  StorageProvider = "StorageProvider",
-  ChannelOwner = "ChannelOwner",
-  CuratorLead = "CuratorLead",
-  Curator = "Curator",
+  StorageProvider = 'StorageProvider',
+  ChannelOwner = 'ChannelOwner',
+  CuratorLead = 'CuratorLead',
+  Curator = 'Curator',
 }
 
 export class Role extends Enum {
   constructor(value?: any, index?: number) {
-    super([RoleKeys.StorageProvider, RoleKeys.ChannelOwner, RoleKeys.CuratorLead, RoleKeys.Curator], value, index);
+    super([RoleKeys.StorageProvider, RoleKeys.ChannelOwner, RoleKeys.CuratorLead, RoleKeys.Curator], value, index)
   }
 }
 
@@ -59,39 +59,39 @@ export class ActorInRole extends Struct {
         actor_id: ActorId,
       },
       value
-    );
+    )
   }
 
   get role(): Role {
-    return this.get("role") as Role;
+    return this.get('role') as Role
   }
 
   get actor_id(): ActorId {
-    return this.get("actor_id") as ActorId;
+    return this.get('actor_id') as ActorId
   }
 
   get isContentLead(): boolean {
-    return this.role.eq(RoleKeys.CuratorLead);
+    return this.role.eq(RoleKeys.CuratorLead)
   }
 
   get isCurator(): boolean {
-    return this.role.eq(RoleKeys.Curator);
+    return this.role.eq(RoleKeys.Curator)
   }
 }
 
 export type IProfile = {
-  handle: Text;
-  avatar_uri: Text;
-  about: Text;
-  registered_at_block: BlockNumber;
-  registered_at_time: Moment;
-  entry: EntryMethod;
-  suspended: bool;
-  subscription: Option<SubscriptionId>;
-  root_account: AccountId;
-  controller_account: AccountId;
-  roles: Vec<ActorInRole>;
-};
+  handle: Text
+  avatar_uri: Text
+  about: Text
+  registered_at_block: BlockNumber
+  registered_at_time: Moment
+  entry: EntryMethod
+  suspended: bool
+  subscription: Option<SubscriptionId>
+  root_account: AccountId
+  controller_account: AccountId
+  roles: Vec<ActorInRole>
+}
 export class Profile extends JoyStruct<IProfile> {
   constructor(value?: IProfile) {
     super(
@@ -109,51 +109,51 @@ export class Profile extends JoyStruct<IProfile> {
         roles: Vec.with(ActorInRole),
       },
       value
-    );
+    )
   }
 
   get handle(): Text {
-    return this.get("handle") as Text;
+    return this.get('handle') as Text
   }
 
   get avatar_uri(): Text {
-    return this.get("avatar_uri") as Text;
+    return this.get('avatar_uri') as Text
   }
 
   get about(): Text {
-    return this.get("about") as Text;
+    return this.get('about') as Text
   }
 
   get registered_at_block(): u32 {
-    return this.get("registered_at_block") as u32;
+    return this.get('registered_at_block') as u32
   }
 
   get registered_at_time(): u64 {
-    return this.get("registered_at_time") as u64;
+    return this.get('registered_at_time') as u64
   }
 
   get entry(): EntryMethod {
-    return this.get("entry") as EntryMethod;
+    return this.get('entry') as EntryMethod
   }
 
   get suspended(): bool {
-    return this.get("suspended") as bool;
+    return this.get('suspended') as bool
   }
 
   get subscription(): Option<SubscriptionId> {
-    return this.get("subscription") as Option<SubscriptionId>;
+    return this.get('subscription') as Option<SubscriptionId>
   }
 
   get root_account(): AccountId {
-    return this.get("root_account") as AccountId;
+    return this.get('root_account') as AccountId
   }
 
   get controller_account(): AccountId {
-    return this.get("controller_account") as AccountId;
+    return this.get('controller_account') as AccountId
   }
 
   get roles(): Vec<ActorInRole> {
-    return this.get("roles") as Vec<ActorInRole>;
+    return this.get('roles') as Vec<ActorInRole>
   }
 }
 
@@ -166,15 +166,15 @@ export class UserInfo extends Struct {
         about: OptionText,
       },
       value
-    );
+    )
   }
 }
 
 export type CheckedUserInfo = {
-  handle: Text;
-  avatar_uri: Text;
-  about: Text;
-};
+  handle: Text
+  avatar_uri: Text
+  about: Text
+}
 
 export class PaidMembershipTerms extends Struct {
   constructor(value?: any) {
@@ -184,21 +184,21 @@ export class PaidMembershipTerms extends Struct {
         text: Text,
       },
       value
-    );
+    )
   }
 
   get fee(): BalanceOf {
-    return this.get("fee") as BalanceOf;
+    return this.get('fee') as BalanceOf
   }
 
   get text(): Text {
-    return this.get("text") as Text;
+    return this.get('text') as Text
   }
 }
 
 export function registerMembershipTypes() {
   try {
-    const typeRegistry = getTypeRegistry();
+    const typeRegistry = getTypeRegistry()
     typeRegistry.register({
       EntryMethod,
       MemberId,
@@ -207,19 +207,19 @@ export function registerMembershipTypes() {
       Profile,
       UserInfo,
       CheckedUserInfo: {
-        handle: "Text",
-        avatar_uri: "Text",
-        about: "Text",
+        handle: 'Text',
+        avatar_uri: 'Text',
+        about: 'Text',
       },
       PaidMembershipTerms: {
-        fee: "BalanceOf",
-        text: "Text",
+        fee: 'BalanceOf',
+        text: 'Text',
       },
       Role,
       ActorId,
       ActorInRole,
-    });
+    })
   } catch (err) {
-    console.error("Failed to register custom types of membership module", err);
+    console.error('Failed to register custom types of membership module', err)
   }
 }

+ 74 - 63
types/src/mint/index.ts

@@ -1,78 +1,89 @@
-import { getTypeRegistry, u32, u64, u128, Option, Enum} from '@polkadot/types';
-import { Balance, BlockNumber } from '@polkadot/types/interfaces';
-import { JoyStruct } from '../common';
+import { getTypeRegistry, u32, u64, u128, Option, Enum } from '@polkadot/types'
+import { Balance, BlockNumber } from '@polkadot/types/interfaces'
+import { JoyStruct } from '../common'
 
-export class MintId extends u64 {};
+export class MintId extends u64 {}
 
-export class Setting extends u128 {};
-export class Adding extends u128 {};
-export class Reducing extends u128 {};
+export class Setting extends u128 {}
+export class Adding extends u128 {}
+export class Reducing extends u128 {}
 
 export class AdjustCapacityBy extends Enum {
-    constructor (value?: any, index?: number) {
-        super(
-          {
-            Setting,
-            Adding,
-            Reducing
-          },
-          value, index);
-      }
-};
+  constructor(value?: any, index?: number) {
+    super(
+      {
+        Setting,
+        Adding,
+        Reducing,
+      },
+      value,
+      index
+    )
+  }
+}
 
 export type IAdjustOnInterval = {
-    block_interval: BlockNumber,
-    adjustment_type: AdjustCapacityBy,
-};
+  block_interval: BlockNumber
+  adjustment_type: AdjustCapacityBy
+}
 export class AdjustOnInterval extends JoyStruct<IAdjustOnInterval> {
-    constructor (value?: IAdjustOnInterval) {
-        super({
-            block_interval: u32,
-            adjustment_type: AdjustCapacityBy,
-        }, value);
-    }
-};
+  constructor(value?: IAdjustOnInterval) {
+    super(
+      {
+        block_interval: u32,
+        adjustment_type: AdjustCapacityBy,
+      },
+      value
+    )
+  }
+}
 
 export type INextAdjustment = {
-    adjustment: AdjustOnInterval,
-    at_block: BlockNumber,
-};
+  adjustment: AdjustOnInterval
+  at_block: BlockNumber
+}
 export class NextAdjustment extends JoyStruct<INextAdjustment> {
-    constructor (value?: INextAdjustment) {
-        super({
-            adjustment: AdjustOnInterval,
-            at_block: u32,
-        }, value);
-    }
-};
+  constructor(value?: INextAdjustment) {
+    super(
+      {
+        adjustment: AdjustOnInterval,
+        at_block: u32,
+      },
+      value
+    )
+  }
+}
 
 export type IMint = {
-    capacity: Balance,
-    next_adjustment: Option<NextAdjustment>,
-    created_at: BlockNumber,
-    total_minted: Balance,
-};
+  capacity: Balance
+  next_adjustment: Option<NextAdjustment>
+  created_at: BlockNumber
+  total_minted: Balance
+}
 export class Mint extends JoyStruct<IMint> {
-    constructor (value?: IMint) {
-        super({
-            capacity: u128,
-            next_adjustment: Option.with(NextAdjustment),
-            created_at: u32,
-            total_minted: u128,
-        }, value);
-    }
-};
+  constructor(value?: IMint) {
+    super(
+      {
+        capacity: u128,
+        next_adjustment: Option.with(NextAdjustment),
+        created_at: u32,
+        total_minted: u128,
+      },
+      value
+    )
+  }
+}
 
-export function registerMintTypes () {
-    try {
-      getTypeRegistry().register({
-        MintId: 'u64',
-        Mint,
-        MintBalanceOf: 'Balance',
-        BalanceOfMint: 'Balance',
-        'minting::BalanceOf': 'Balance'
-      });
-    } catch (err) {
-      console.error('Failed to register custom types of mint module', err);
-    }
+export function registerMintTypes() {
+  try {
+    getTypeRegistry().register({
+      MintId: 'u64',
+      Mint,
+      MintBalanceOf: 'Balance',
+      BalanceOfMint: 'Balance',
+      'minting::BalanceOf': 'Balance',
+    })
+  } catch (err) {
+    console.error('Failed to register custom types of mint module', err)
+  }
 }

+ 198 - 182
types/src/proposals.ts

@@ -1,164 +1,177 @@
-import { Text, u32, Enum, getTypeRegistry, Tuple, GenericAccountId, u8, Vec, Option, Struct, Null, Bytes } from "@polkadot/types";
-import { bool } from "@polkadot/types/primitive";
-import { BlockNumber, Balance } from "@polkadot/types/interfaces";
-import AccountId from "@polkadot/types/primitive/Generic/AccountId";
-import { ThreadId, JoyStruct, WorkingGroup } from "./common";
-import { MemberId } from "./members";
-import { RoleParameters } from "./roles";
-import { StakeId } from "./stake";
-import { ElectionParameters } from "./council";
-import { ActivateOpeningAt, OpeningId, ApplicationId } from "./hiring";
-import { WorkingGroupOpeningPolicyCommitment, WorkerId, RewardPolicy } from "./working-group";
+import {
+  Text,
+  u32,
+  Enum,
+  getTypeRegistry,
+  Tuple,
+  GenericAccountId,
+  u8,
+  Vec,
+  Option,
+  Struct,
+  Null,
+  Bytes,
+} from '@polkadot/types'
+import { bool } from '@polkadot/types/primitive'
+import { BlockNumber, Balance } from '@polkadot/types/interfaces'
+import AccountId from '@polkadot/types/primitive/Generic/AccountId'
+import { ThreadId, JoyStruct, WorkingGroup } from './common'
+import { MemberId } from './members'
+import { RoleParameters } from './roles'
+import { StakeId } from './stake'
+import { ElectionParameters } from './council'
+import { ActivateOpeningAt, OpeningId, ApplicationId } from './hiring'
+import { WorkingGroupOpeningPolicyCommitment, WorkerId, RewardPolicy } from './working-group'
 
 export type IVotingResults = {
-  abstensions: u32;
-  approvals: u32;
-  rejections: u32;
-  slashes: u32;
-};
+  abstensions: u32
+  approvals: u32
+  rejections: u32
+  slashes: u32
+}
 
 export class VotingResults extends Struct {
   constructor(value?: any) {
     super(
       {
-        abstensions: "u32",
-        approvals: "u32",
-        rejections: "u32",
-        slashes: "u32"
+        abstensions: 'u32',
+        approvals: 'u32',
+        rejections: 'u32',
+        slashes: 'u32',
       },
       value
-    );
+    )
   }
 }
 
 export type ProposalParametersType = {
   // During this period, votes can be accepted
-  votingPeriod: BlockNumber;
+  votingPeriod: BlockNumber
 
   /* A pause before execution of the approved proposal. Zero means approved proposal would be
      executed immediately. */
-  gracePeriod: BlockNumber;
+  gracePeriod: BlockNumber
 
   // Quorum percentage of approving voters required to pass the proposal.
-  approvalQuorumPercentage: u32;
+  approvalQuorumPercentage: u32
 
   // Approval votes percentage threshold to pass the proposal.
-  approvalThresholdPercentage: u32;
+  approvalThresholdPercentage: u32
 
   // Quorum percentage of voters required to slash the proposal.
-  slashingQuorumPercentage: u32;
+  slashingQuorumPercentage: u32
 
   // Slashing votes percentage threshold to slash the proposal.
-  slashingThresholdPercentage: u32;
+  slashingThresholdPercentage: u32
 
   // Proposal stake
-  requiredStake: Balance;
-};
+  requiredStake: Balance
+}
 
 class ProposalParameters extends Struct {
   constructor(value?: any) {
     super(
       {
         // During this period, votes can be accepted
-        votingPeriod: "BlockNumber",
+        votingPeriod: 'BlockNumber',
 
         /* A pause before execution of the approved proposal. Zero means approved proposal would be
      executed immediately. */
-        gracePeriod: "BlockNumber",
+        gracePeriod: 'BlockNumber',
 
         // Quorum percentage of approving voters required to pass the proposal.
-        approvalQuorumPercentage: "u32",
+        approvalQuorumPercentage: 'u32',
 
         // Approval votes percentage threshold to pass the proposal.
-        approvalThresholdPercentage: "u32",
+        approvalThresholdPercentage: 'u32',
 
         // Quorum percentage of voters required to slash the proposal.
-        slashingQuorumPercentage: "u32",
+        slashingQuorumPercentage: 'u32',
 
         // Slashing votes percentage threshold to slash the proposal.
-        slashingThresholdPercentage: "u32",
+        slashingThresholdPercentage: 'u32',
 
         // Proposal stake
-        requiredStake: "Option<Balance>"
+        requiredStake: 'Option<Balance>',
       },
       value
-    );
+    )
   }
 
   // During this period, votes can be accepted
   get votingPeriod(): BlockNumber {
-    return this.get("votingPeriod") as BlockNumber;
+    return this.get('votingPeriod') as BlockNumber
   }
 
   /* A pause before execution of the approved proposal. Zero means approved proposal would be
      executed immediately. */
   get gracePeriod(): BlockNumber {
-    return this.get("gracePeriod") as BlockNumber;
+    return this.get('gracePeriod') as BlockNumber
   }
 
   // Quorum percentage of approving voters required to pass the proposal.
   get approvalQuorumPercentage(): u32 {
-    return this.get("approvalQuorumPercentage") as u32;
+    return this.get('approvalQuorumPercentage') as u32
   }
 
   // Approval votes percentage threshold to pass the proposal.
   get approvalThresholdPercentage(): u32 {
-    return this.get("approvalThresholdPercentage") as u32;
+    return this.get('approvalThresholdPercentage') as u32
   }
 
   // Quorum percentage of voters required to slash the proposal.
   get slashingQuorumPercentage(): u32 {
-    return this.get("slashingQuorumPercentage") as u32;
+    return this.get('slashingQuorumPercentage') as u32
   }
 
   // Slashing votes percentage threshold to slash the proposal.
   get slashingThresholdPercentage(): u32 {
-    return this.get("slashingThresholdPercentage") as u32;
+    return this.get('slashingThresholdPercentage') as u32
   }
 
   // Proposal stake
   get requiredStake(): Option<Balance> {
-    return this.get("requiredStake") as Option<Balance>;
+    return this.get('requiredStake') as Option<Balance>
   }
 }
 
 export type IProposal = {
-  parameters: ProposalParameters;
-  proposerId: MemberId;
-  title: Text;
-  description: Text;
-  createdAt: BlockNumber;
-  status: ProposalStatus;
-  votingResults: VotingResults;
-};
+  parameters: ProposalParameters
+  proposerId: MemberId
+  title: Text
+  description: Text
+  createdAt: BlockNumber
+  status: ProposalStatus
+  votingResults: VotingResults
+}
 
 export const IProposalStatus: { [key: string]: string } = {
-  Active: "Active",
-  Canceled: "Canceled",
-  Expired: "Expired",
-  Approved: "Approved",
-  Rejected: "Rejected",
-  Vetoed: "Vetoed",
-  PendingExecution: "PendingExecution",
-  Executed: "Executed",
-  ExecutionFailed: "ExecutionFailed",
-  Finalized: "Finalized",
-  Slashed: "Slashed"
-};
+  Active: 'Active',
+  Canceled: 'Canceled',
+  Expired: 'Expired',
+  Approved: 'Approved',
+  Rejected: 'Rejected',
+  Vetoed: 'Vetoed',
+  PendingExecution: 'PendingExecution',
+  Executed: 'Executed',
+  ExecutionFailed: 'ExecutionFailed',
+  Finalized: 'Finalized',
+  Slashed: 'Slashed',
+}
 
 export type IActiveStake = {
-  stake_id: StakeId;
-  source_account_id: AccountId;
-};
+  stake_id: StakeId
+  source_account_id: AccountId
+}
 export class ActiveStake extends JoyStruct<IActiveStake> {
   constructor(value?: IActiveStake) {
     super(
       {
         stakeId: StakeId,
-        sourceAccountId: GenericAccountId
+        sourceAccountId: GenericAccountId,
       },
       value
-    );
+    )
   }
 }
 
@@ -166,53 +179,61 @@ export class ExecutionFailedStatus extends Struct {
   constructor(value?: any) {
     super(
       {
-        error: "Vec<u8>",
+        error: 'Vec<u8>',
       },
       value
-    );
+    )
   }
 
   get error() {
-    return this.get('error') as Vec<u8>;
+    return this.get('error') as Vec<u8>
   }
 }
 
 class ExecutionFailed extends ExecutionFailedStatus {}
 
-export type ApprovedProposalStatuses = "PendingExecution" | "Executed" | "ExecutionFailed";
+export type ApprovedProposalStatuses = 'PendingExecution' | 'Executed' | 'ExecutionFailed'
 
 export class ApprovedProposalStatus extends Enum {
   constructor(value?: any, index?: number) {
-    super({
-      PendingExecution: Null,
-      Executed: Null,
-      ExecutionFailed
-    }, value, index);
+    super(
+      {
+        PendingExecution: Null,
+        Executed: Null,
+        ExecutionFailed,
+      },
+      value,
+      index
+    )
   }
 }
-export class Approved extends ApprovedProposalStatus {};
+export class Approved extends ApprovedProposalStatus {}
 
-export type ProposalDecisionStatuses = "Canceled" | "Vetoed" | "Rejected" | "Slashed" | "Expired" | "Approved";
+export type ProposalDecisionStatuses = 'Canceled' | 'Vetoed' | 'Rejected' | 'Slashed' | 'Expired' | 'Approved'
 
 export class ProposalDecisionStatus extends Enum {
   constructor(value?: any, index?: number) {
-    super({
-      Canceled: Null,
-      Vetoed: Null,
-      Rejected: Null,
-      Slashed: Null,
-      Expired: Null,
-      Approved
-    }, value, index);
+    super(
+      {
+        Canceled: Null,
+        Vetoed: Null,
+        Rejected: Null,
+        Slashed: Null,
+        Expired: Null,
+        Approved,
+      },
+      value,
+      index
+    )
   }
 }
 
 export type IFinalizationData = {
-  proposalStatus: ProposalDecisionStatus;
-  finalizedAt: BlockNumber;
-  encodedUnstakingErrorDueToBrokenRuntime: Option<Vec<u8>>;
-  stakeDataAfterUnstakingError: Option<ActiveStake>;
-};
+  proposalStatus: ProposalDecisionStatus
+  finalizedAt: BlockNumber
+  encodedUnstakingErrorDueToBrokenRuntime: Option<Vec<u8>>
+  stakeDataAfterUnstakingError: Option<ActiveStake>
+}
 
 export class FinalizationData extends JoyStruct<IFinalizationData> {
   constructor(value?: IFinalizationData) {
@@ -221,10 +242,10 @@ export class FinalizationData extends JoyStruct<IFinalizationData> {
         proposalStatus: ProposalDecisionStatus,
         finalizedAt: u32,
         encodedUnstakingErrorDueToBrokenRuntime: Option.with(Vec.with(u8)),
-        stakeDataAfterUnstakingError: Option.with(ActiveStake)
+        stakeDataAfterUnstakingError: Option.with(ActiveStake),
       },
       value
-    );
+    )
   }
 }
 
@@ -236,40 +257,35 @@ export class ProposalStatus extends Enum {
     super(
       {
         Active,
-        Finalized
+        Finalized,
       },
       value,
       index
-    );
+    )
   }
 }
 
-export const VoteKinds = [
-  "Approve",
-  "Reject",
-  "Slash",
-  "Abstain"
-] as const;
+export const VoteKinds = ['Approve', 'Reject', 'Slash', 'Abstain'] as const
 
 export class VoteKind extends Enum {
   constructor(value?: any, index?: number) {
-    super(["Approve", "Reject", "Slash", "Abstain"], value, index);
+    super(['Approve', 'Reject', 'Slash', 'Abstain'], value, index)
   }
 }
 
-export type ProposalVotes = [MemberId, VoteKind][];
+export type ProposalVotes = [MemberId, VoteKind][]
 
 export class ProposalId extends u32 {}
 
 export class SpendingParams extends Tuple {
   constructor(value?: any) {
-    super(["Balance", "AccountId"], value);
+    super(['Balance', 'AccountId'], value)
   }
 }
 
 class SetLeadParams extends Tuple {
   constructor(value?: any) {
-    super([MemberId, AccountId], value);
+    super([MemberId, AccountId], value)
   }
 }
 
@@ -292,44 +308,44 @@ export class Proposal extends Struct {
         description: Text,
 
         // When it was created.
-        createdAt: "BlockNumber",
+        createdAt: 'BlockNumber',
 
         /// Current proposal status
         status: ProposalStatus,
 
         /// Curring voting result for the proposal
-        votingResults: VotingResults
+        votingResults: VotingResults,
       },
       value
-    );
+    )
   }
 
   get parameters(): ProposalParameters {
-    return this.get("parameters") as ProposalParameters;
+    return this.get('parameters') as ProposalParameters
   }
 
   get proposerId(): MemberId {
-    return this.get("proposerId") as MemberId;
+    return this.get('proposerId') as MemberId
   }
 
   get title(): Text {
-    return this.get("description") as Text;
+    return this.get('description') as Text
   }
 
   get description(): Text {
-    return this.get("description") as Text;
+    return this.get('description') as Text
   }
 
   get createdAt(): BlockNumber {
-    return this.get("createdAt") as BlockNumber;
+    return this.get('createdAt') as BlockNumber
   }
 
   get status(): ProposalStatus {
-    return this.get("status") as ProposalStatus;
+    return this.get('status') as ProposalStatus
   }
 
   get votingResults(): VotingResults {
-    return this.get("votingResults") as VotingResults;
+    return this.get('votingResults') as VotingResults
   }
 }
 
@@ -338,43 +354,43 @@ export class ThreadCounter extends Struct {
     super(
       {
         author_id: MemberId,
-        counter: "u32"
+        counter: 'u32',
       },
       value
-    );
+    )
   }
 
   get author_id(): MemberId {
-    return this.get("author_id") as MemberId;
+    return this.get('author_id') as MemberId
   }
 
   get counter(): u32 {
-    return this.get("counter") as u32;
+    return this.get('counter') as u32
   }
 }
 
 export class DiscussionThread extends Struct {
   constructor(value?: any) {
     super(
-    {
-      title: Bytes,
-      'created_at': "BlockNumber",
-      'author_id': MemberId
-    },
-    value
-    );
+      {
+        title: Bytes,
+        created_at: 'BlockNumber',
+        author_id: MemberId,
+      },
+      value
+    )
   }
 
   get title(): Bytes {
-	  return this.get('title') as Bytes;
+    return this.get('title') as Bytes
   }
 
   get created_at(): BlockNumber {
-	  return this.get('created_ad') as BlockNumber;
+    return this.get('created_ad') as BlockNumber
   }
 
   get author_id(): MemberId {
-	  return this.get('author_id') as MemberId;
+    return this.get('author_id') as MemberId
   }
 }
 
@@ -384,9 +400,9 @@ export class DiscussionPost extends Struct {
       {
         text: Bytes,
         /// When post was added.
-        created_at: "BlockNumber",
+        created_at: 'BlockNumber',
         /// When post was updated last time.
-        updated_at: "BlockNumber",
+        updated_at: 'BlockNumber',
         /// Author of the post.
         author_id: MemberId,
         /// Parent thread id for this post
@@ -395,40 +411,40 @@ export class DiscussionPost extends Struct {
         edition_number: u32,
       },
       value
-    );
+    )
   }
 
   get text(): Bytes {
-    return this.get('text') as Bytes;
+    return this.get('text') as Bytes
   }
 
   get created_at(): BlockNumber {
-    return this.get('created_at') as BlockNumber;
+    return this.get('created_at') as BlockNumber
   }
 
   get updated_at(): BlockNumber {
-    return this.get('updated_at') as BlockNumber;
+    return this.get('updated_at') as BlockNumber
   }
 
   get author_id(): MemberId {
-    return this.get('author_id') as MemberId;
+    return this.get('author_id') as MemberId
   }
 
   get thread_id(): ThreadId {
-    return this.get('thread_id') as ThreadId;
+    return this.get('thread_id') as ThreadId
   }
 
   get edition_number(): u32 {
-    return this.get('edition_number') as u32;
+    return this.get('edition_number') as u32
   }
 }
 
 export type IAddOpeningParameters = {
-  activate_at: ActivateOpeningAt;
-  commitment: WorkingGroupOpeningPolicyCommitment;
-  human_readable_text: Bytes;
-  working_group: WorkingGroup;
-};
+  activate_at: ActivateOpeningAt
+  commitment: WorkingGroupOpeningPolicyCommitment
+  human_readable_text: Bytes
+  working_group: WorkingGroup
+}
 
 export class AddOpeningParameters extends JoyStruct<IAddOpeningParameters> {
   constructor(value?: IAddOpeningParameters) {
@@ -437,34 +453,34 @@ export class AddOpeningParameters extends JoyStruct<IAddOpeningParameters> {
         activate_at: ActivateOpeningAt,
         commitment: WorkingGroupOpeningPolicyCommitment,
         human_readable_text: Bytes,
-        working_group: WorkingGroup
+        working_group: WorkingGroup,
       },
       value
-    );
+    )
   }
 
   get activate_at(): ActivateOpeningAt {
-    return this.getField<ActivateOpeningAt>('activate_at');
+    return this.getField<ActivateOpeningAt>('activate_at')
   }
 
   get commitment(): WorkingGroupOpeningPolicyCommitment {
-    return this.getField<WorkingGroupOpeningPolicyCommitment>('commitment');
+    return this.getField<WorkingGroupOpeningPolicyCommitment>('commitment')
   }
 
   get human_readable_text(): Bytes {
-    return this.getField<Bytes>('human_readable_text');
+    return this.getField<Bytes>('human_readable_text')
   }
 
   get working_group(): WorkingGroup {
-    return this.getField<WorkingGroup>('working_group');
+    return this.getField<WorkingGroup>('working_group')
   }
 }
 
 export type IFillOpeningParameters = {
-  opening_id: OpeningId;
-  successful_application_id: ApplicationId;
-  reward_policy: Option<RewardPolicy>;
-  working_group: WorkingGroup;
+  opening_id: OpeningId
+  successful_application_id: ApplicationId
+  reward_policy: Option<RewardPolicy>
+  working_group: WorkingGroup
 }
 
 export class FillOpeningParameters extends JoyStruct<IFillOpeningParameters> {
@@ -477,31 +493,31 @@ export class FillOpeningParameters extends JoyStruct<IFillOpeningParameters> {
         working_group: WorkingGroup,
       },
       value
-    );
+    )
   }
 
   get opening_id(): OpeningId {
-    return this.getField<OpeningId>('opening_id');
+    return this.getField<OpeningId>('opening_id')
   }
 
   get successful_application_id(): ApplicationId {
-    return this.getField<ApplicationId>('successful_application_id');
+    return this.getField<ApplicationId>('successful_application_id')
   }
 
   get reward_policy(): Option<RewardPolicy> {
-    return this.getField<Option<RewardPolicy>>('reward_policy');
+    return this.getField<Option<RewardPolicy>>('reward_policy')
   }
 
   get working_group(): WorkingGroup {
-    return this.getField<WorkingGroup>('working_group');
+    return this.getField<WorkingGroup>('working_group')
   }
 }
 
 export type ITerminateRoleParameters = {
-  worker_id: WorkerId;
-  rationale: Bytes;
-  slash: bool;
-  working_group: WorkingGroup;
+  worker_id: WorkerId
+  rationale: Bytes
+  slash: bool
+  working_group: WorkingGroup
 }
 
 export class TerminateRoleParameters extends JoyStruct<ITerminateRoleParameters> {
@@ -514,23 +530,23 @@ export class TerminateRoleParameters extends JoyStruct<ITerminateRoleParameters>
         working_group: WorkingGroup,
       },
       value
-    );
+    )
   }
 
   get worker_id(): WorkerId {
-    return this.getField<WorkerId>('worker_id');
+    return this.getField<WorkerId>('worker_id')
   }
 
   get rationale(): Bytes {
-    return this.getField<Bytes>('rationale');
+    return this.getField<Bytes>('rationale')
   }
 
   get slash(): bool {
-    return this.getField<bool>('slash');
+    return this.getField<bool>('slash')
   }
 
   get working_group(): WorkingGroup {
-    return this.getField<WorkingGroup>('working_group');
+    return this.getField<WorkingGroup>('working_group')
   }
 }
 
@@ -538,27 +554,27 @@ export class ProposalDetails extends Enum {
   constructor(value?: any, index?: number) {
     super(
       {
-        Text: "Text",
-        RuntimeUpgrade: "Vec<u8>",
+        Text: 'Text',
+        RuntimeUpgrade: 'Vec<u8>',
         SetElectionParameters: ElectionParameters,
         Spending: SpendingParams,
         SetLead: SetLead,
-        SetContentWorkingGroupMintCapacity: "Balance",
-        EvictStorageProvider: "AccountId",
-        SetValidatorCount: "u32",
+        SetContentWorkingGroupMintCapacity: 'Balance',
+        EvictStorageProvider: 'AccountId',
+        SetValidatorCount: 'u32',
         SetStorageRoleParameters: RoleParameters,
         AddWorkingGroupLeaderOpening: AddOpeningParameters,
         BeginReviewWorkingGroupLeaderApplication: Tuple.with([OpeningId, WorkingGroup]),
         FillWorkingGroupLeaderOpening: FillOpeningParameters,
-        SetWorkingGroupMintCapacity: Tuple.with(["Balance", WorkingGroup]),
-        DecreaseWorkingGroupLeaderStake: Tuple.with([WorkerId, "Balance", WorkingGroup]),
-        SlashWorkingGroupLeaderStake: Tuple.with([WorkerId, "Balance", WorkingGroup]),
-        SetWorkingGroupLeaderReward: Tuple.with([WorkerId, "Balance", WorkingGroup]),
+        SetWorkingGroupMintCapacity: Tuple.with(['Balance', WorkingGroup]),
+        DecreaseWorkingGroupLeaderStake: Tuple.with([WorkerId, 'Balance', WorkingGroup]),
+        SlashWorkingGroupLeaderStake: Tuple.with([WorkerId, 'Balance', WorkingGroup]),
+        SetWorkingGroupLeaderReward: Tuple.with([WorkerId, 'Balance', WorkingGroup]),
         TerminateWorkingGroupLeaderRole: TerminateRoleParameters,
       },
       value,
       index
-    );
+    )
   }
 }
 
@@ -579,9 +595,9 @@ export function registerProposalTypes() {
       DiscussionPost,
       AddOpeningParameters,
       FillOpeningParameters,
-      TerminateRoleParameters
-    });
+      TerminateRoleParameters,
+    })
   } catch (err) {
-    console.error("Failed to register custom types of proposals module", err);
+    console.error('Failed to register custom types of proposals module', err)
   }
 }

+ 58 - 52
types/src/recurring-rewards/index.ts

@@ -1,21 +1,24 @@
-import { getTypeRegistry, u64, u128, Option } from '@polkadot/types';
-import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
-import { JoyStruct } from '../common';
-import { MintId } from '../mint';
+import { getTypeRegistry, u64, u128, Option } from '@polkadot/types'
+import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces'
+import { JoyStruct } from '../common'
+import { MintId } from '../mint'
 
-export class RecipientId extends u64 {};
-export class RewardRelationshipId extends u64 {};
+export class RecipientId extends u64 {}
+export class RewardRelationshipId extends u64 {}
 
 export type IRecipient = {
-  total_reward_received: Balance,
-  total_reward_missed: Balance,
-};
+  total_reward_received: Balance
+  total_reward_missed: Balance
+}
 export class Recipient extends JoyStruct<IRecipient> {
-  constructor (value?: IRecipient) {
-    super({
-      total_reward_received: u128,
-      total_reward_missed: u128,
-    }, value);
+  constructor(value?: IRecipient) {
+    super(
+      {
+        total_reward_received: u128,
+        total_reward_missed: u128,
+      },
+      value
+    )
   }
 
   get total_reward_received(): u128 {
@@ -25,30 +28,33 @@ export class Recipient extends JoyStruct<IRecipient> {
   get total_reward_missed(): u128 {
     return this.getField<u128>('total_reward_missed')
   }
-};
+}
 
 export type IRewardRelationship = {
-  recipient: RecipientId,
-  mint_id: MintId,
-  account: AccountId,
-  amount_per_payout: Balance,
-  next_payment_at_block: Option<BlockNumber>,
-  payout_interval: Option<BlockNumber>,
-  total_reward_received: Balance,
-  total_reward_missed: Balance,
-};
+  recipient: RecipientId
+  mint_id: MintId
+  account: AccountId
+  amount_per_payout: Balance
+  next_payment_at_block: Option<BlockNumber>
+  payout_interval: Option<BlockNumber>
+  total_reward_received: Balance
+  total_reward_missed: Balance
+}
 export class RewardRelationship extends JoyStruct<IRewardRelationship> {
-  constructor (value?: IRecipient) {
-    super({
-      recipient: RecipientId,
-      mint_id: MintId,
-      account: 'AccountId',
-      amount_per_payout: 'Balance',
-      next_payment_at_block: Option.with('BlockNumber'),
-      payout_interval: Option.with('BlockNumber'),
-      total_reward_received: 'Balance',
-      total_reward_missed: 'Balance',
-    }, value);
+  constructor(value?: IRecipient) {
+    super(
+      {
+        recipient: RecipientId,
+        mint_id: MintId,
+        account: 'AccountId',
+        amount_per_payout: 'Balance',
+        next_payment_at_block: Option.with('BlockNumber'),
+        payout_interval: Option.with('BlockNumber'),
+        total_reward_received: 'Balance',
+        total_reward_missed: 'Balance',
+      },
+      value
+    )
   }
 
   get recipient(): RecipientId {
@@ -56,35 +62,35 @@ export class RewardRelationship extends JoyStruct<IRewardRelationship> {
   }
 
   get total_reward_received(): Balance {
-    return this.getField<Balance>('total_reward_received');
+    return this.getField<Balance>('total_reward_received')
   }
 
   get total_reward_missed(): Balance {
-    return this.getField<Balance>('total_reward_missed');
+    return this.getField<Balance>('total_reward_missed')
   }
 
   get amount_per_payout(): Balance {
-    return this.getField<Balance>('amount_per_payout');
+    return this.getField<Balance>('amount_per_payout')
   }
 
   get payout_interval(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('payout_interval');
+    return this.getField<Option<BlockNumber>>('payout_interval')
   }
 
   get next_payment_at_block(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('next_payment_at_block');
+    return this.getField<Option<BlockNumber>>('next_payment_at_block')
   }
-};
+}
 
-export function registerRecurringRewardsTypes () {
-    try {
-      getTypeRegistry().register({
-        RecipientId: 'u64',
-        RewardRelationshipId: 'u64',
-        Recipient,
-        RewardRelationship
-      });
-    } catch (err) {
-      console.error('Failed to register custom types of recurring rewards module', err);
-    }
+export function registerRecurringRewardsTypes() {
+  try {
+    getTypeRegistry().register({
+      RecipientId: 'u64',
+      RewardRelationshipId: 'u64',
+      Recipient,
+      RewardRelationship,
+    })
+  } catch (err) {
+    console.error('Failed to register custom types of recurring rewards module', err)
+  }
 }

+ 43 - 40
types/src/roles.ts

@@ -1,64 +1,67 @@
-import { Struct } from '@polkadot/types/codec';
-import { getTypeRegistry, u32, u128 } from '@polkadot/types';
-import { BlockNumber, Balance } from '@polkadot/types/interfaces';
+import { Struct } from '@polkadot/types/codec'
+import { getTypeRegistry, u32, u128 } from '@polkadot/types'
+import { BlockNumber, Balance } from '@polkadot/types/interfaces'
 
 // We only need this type for historic reasons to read old proposal state
 // that was related to the now defunct actors module
 export class RoleParameters extends Struct {
-  constructor (value?: any) {
-    super({
-      min_stake:  u128, // Balance,
-      min_actors: u32,
-      max_actors: u32,
-      reward: u128, // Balance,
-      reward_period: u32, // BlockNumber,
-      bonding_period: u32, // BlockNumber,
-      unbonding_period: u32, // BlockNumber,
-      min_service_period: u32, // BlockNumber,
-      startup_grace_period: u32, // BlockNumber,
-      entry_request_fee: u128, // Balance
-    }, value);
+  constructor(value?: any) {
+    super(
+      {
+        min_stake: u128, // Balance,
+        min_actors: u32,
+        max_actors: u32,
+        reward: u128, // Balance,
+        reward_period: u32, // BlockNumber,
+        bonding_period: u32, // BlockNumber,
+        unbonding_period: u32, // BlockNumber,
+        min_service_period: u32, // BlockNumber,
+        startup_grace_period: u32, // BlockNumber,
+        entry_request_fee: u128, // Balance
+      },
+      value
+    )
   }
 
-  get min_stake (): Balance {
-    return this.get('min_stake') as Balance;
+  get min_stake(): Balance {
+    return this.get('min_stake') as Balance
   }
-  get max_actors (): u32 {
-    return this.get('max_actors') as u32;
+  get max_actors(): u32 {
+    return this.get('max_actors') as u32
   }
-  get min_actors (): u32 {
-    return this.get('min_actors') as u32;
+  get min_actors(): u32 {
+    return this.get('min_actors') as u32
   }
-  get reward (): Balance {
-    return this.get('reward') as Balance;
+  get reward(): Balance {
+    return this.get('reward') as Balance
   }
-  get reward_period (): BlockNumber {
-    return this.get('reward_period') as BlockNumber;
+  get reward_period(): BlockNumber {
+    return this.get('reward_period') as BlockNumber
   }
-  get unbonding_period (): BlockNumber {
-    return this.get('unbonding_period') as BlockNumber;
+  get unbonding_period(): BlockNumber {
+    return this.get('unbonding_period') as BlockNumber
   }
-  get bonding_period (): BlockNumber {
-    return this.get('bonding_period') as BlockNumber;
+  get bonding_period(): BlockNumber {
+    return this.get('bonding_period') as BlockNumber
   }
-  get min_service_period (): BlockNumber {
-    return this.get('min_service_period') as BlockNumber;
+  get min_service_period(): BlockNumber {
+    return this.get('min_service_period') as BlockNumber
   }
-  get startup_grace_period (): BlockNumber {
-    return this.get('startup_grace_period') as BlockNumber;
+  get startup_grace_period(): BlockNumber {
+    return this.get('startup_grace_period') as BlockNumber
   }
-  get entry_request_fee (): Balance {
-    return this.get('entry_request_fee') as Balance;
+  get entry_request_fee(): Balance {
+    return this.get('entry_request_fee') as Balance
   }
 }
 
-export function registerRolesTypes () {
+export function registerRolesTypes() {
   try {
-    const typeRegistry = getTypeRegistry();
+    const typeRegistry = getTypeRegistry()
     typeRegistry.register({
       RoleParameters,
-    });
+    })
   } catch (err) {
-    console.error('Failed to register custom types of roles module', err);
+    console.error('Failed to register custom types of roles module', err)
   }
 }

+ 117 - 101
types/src/stake/index.ts

@@ -1,128 +1,144 @@
-import { getTypeRegistry, u32, u64, u128, Enum, Null, BTreeMap, bool } from '@polkadot/types';
-import { JoyStruct } from '../common';
-import { BlockNumber, Balance } from '@polkadot/types/interfaces';
+import { getTypeRegistry, u32, u64, u128, Enum, Null, BTreeMap, bool } from '@polkadot/types'
+import { JoyStruct } from '../common'
+import { BlockNumber, Balance } from '@polkadot/types/interfaces'
 
-export class StakeId extends u64 {};
-export class SlashId extends u64 {};
+export class StakeId extends u64 {}
+export class SlashId extends u64 {}
 
 export type ISlash = {
-    started_at_block: BlockNumber,
-    is_active: bool,
-    blocks_remaining_in_active_period_for_slashing: BlockNumber,
-    slash_amount: Balance,
-};
+  started_at_block: BlockNumber
+  is_active: bool
+  blocks_remaining_in_active_period_for_slashing: BlockNumber
+  slash_amount: Balance
+}
 export class Slash extends JoyStruct<ISlash> {
-    constructor (value?: ISlash) {
-        super({
-            started_at_block: u32,
-            is_active: bool,
-            blocks_remaining_in_active_period_for_slashing: u32,
-            slash_amount: u128,
-        }, value);
-    }
-};
+  constructor(value?: ISlash) {
+    super(
+      {
+        started_at_block: u32,
+        is_active: bool,
+        blocks_remaining_in_active_period_for_slashing: u32,
+        slash_amount: u128,
+      },
+      value
+    )
+  }
+}
 
 export type IUnstakingState = {
-    started_at_block: BlockNumber,
-    is_active: bool,
-    blocks_remaining_in_active_period_for_unstaking: BlockNumber,
-};
+  started_at_block: BlockNumber
+  is_active: bool
+  blocks_remaining_in_active_period_for_unstaking: BlockNumber
+}
 export class UnstakingState extends JoyStruct<IUnstakingState> {
-    constructor (value?: IUnstakingState) {
-        super({
-            started_at_block: u32,
-            is_active: bool,
-            blocks_remaining_in_active_period_for_unstaking: u32,
-        }, value);
-    }
-};
+  constructor(value?: IUnstakingState) {
+    super(
+      {
+        started_at_block: u32,
+        is_active: bool,
+        blocks_remaining_in_active_period_for_unstaking: u32,
+      },
+      value
+    )
+  }
+}
 
-export class Normal extends Null {};
-export class Unstaking extends UnstakingState {};
+export class Normal extends Null {}
+export class Unstaking extends UnstakingState {}
 export class StakedStatus extends Enum {
-    constructor (value?: any, index?: number) {
-        super(
-          {
-            Normal,
-            Unstaking
-          },
-          value, index);
-    }
-};
+  constructor(value?: any, index?: number) {
+    super(
+      {
+        Normal,
+        Unstaking,
+      },
+      value,
+      index
+    )
+  }
+}
 
 export type IStakedState = {
-    staked_amount: Balance,
-    staked_status: StakedStatus,
-    next_slash_id: SlashId,
-    ongoing_slashes: BTreeMap<SlashId, Slash>,
-};
+  staked_amount: Balance
+  staked_status: StakedStatus
+  next_slash_id: SlashId
+  ongoing_slashes: BTreeMap<SlashId, Slash>
+}
 export class StakedState extends JoyStruct<IStakedState> {
-    constructor (value?: IStakedState) {
-        super({
-            staked_amount: u128,
-            staked_status: StakedStatus,
-            next_slash_id: SlashId,
-            ongoing_slashes: BTreeMap.with(SlashId, Slash),
-        }, value);
-    }
+  constructor(value?: IStakedState) {
+    super(
+      {
+        staked_amount: u128,
+        staked_status: StakedStatus,
+        next_slash_id: SlashId,
+        ongoing_slashes: BTreeMap.with(SlashId, Slash),
+      },
+      value
+    )
+  }
 
-    get staked_amount(): u128 {
-      return this.getField<u128>('staked_amount')
-    }
-};
+  get staked_amount(): u128 {
+    return this.getField<u128>('staked_amount')
+  }
+}
 
-export class NotStaked extends Null {};
-export class Staked extends StakedState {};
+export class NotStaked extends Null {}
+export class Staked extends StakedState {}
 
 export class StakingStatus extends Enum {
-    constructor (value?: any, index?: number) {
-        super(
-          {
-            NotStaked,
-            Staked,
-          },
-          value, index);
-    }
-};
+  constructor(value?: any, index?: number) {
+    super(
+      {
+        NotStaked,
+        Staked,
+      },
+      value,
+      index
+    )
+  }
+}
 
 export type IStake = {
-    created: BlockNumber,
-    staking_status: StakingStatus
-};
+  created: BlockNumber
+  staking_status: StakingStatus
+}
 
 export class Stake extends JoyStruct<IStake> {
-    constructor (value?: IStake) {
-        super({
-            created: u32,
-            staking_status: StakingStatus
-        }, value);
-    }
+  constructor(value?: IStake) {
+    super(
+      {
+        created: u32,
+        staking_status: StakingStatus,
+      },
+      value
+    )
+  }
 
-    get created(): u32 {
-      return this.getField<u32>('created')
-    }
-
-    get staking_status(): StakingStatus {
-      return this.getField<StakingStatus>('staking_status')
-    }
+  get created(): u32 {
+    return this.getField<u32>('created')
+  }
 
-    get value(): Balance {
-      switch (this.staking_status.type) {
-        case "Staked":
-          return (this.staking_status.value as Staked).staked_amount
-      }
+  get staking_status(): StakingStatus {
+    return this.getField<StakingStatus>('staking_status')
+  }
 
-      return new u128(0)
+  get value(): Balance {
+    switch (this.staking_status.type) {
+      case 'Staked':
+        return (this.staking_status.value as Staked).staked_amount
     }
+
+    return new u128(0)
+  }
 }
 
-export function registerStakeTypes () {
-    try {
-      getTypeRegistry().register({
-        StakeId: 'u64',
-        Stake,
-      });
-    } catch (err) {
-      console.error('Failed to register custom types of stake module', err);
-    }
+export function registerStakeTypes() {
+  try {
+    getTypeRegistry().register({
+      StakeId: 'u64',
+      Stake,
+    })
+  } catch (err) {
+    console.error('Failed to register custom types of stake module', err)
+  }
 }

+ 1 - 1
types/src/versioned-store/ClassId.ts

@@ -1,3 +1,3 @@
-import { u64 } from '@polkadot/types';
+import { u64 } from '@polkadot/types'
 
 export default class ClassId extends u64 {}

+ 90 - 85
types/src/versioned-store/EntityCodec.ts

@@ -1,34 +1,34 @@
-import BN from 'bn.js';
-import { Text, bool, Vec, u16 } from '@polkadot/types';
-import { Codec } from '@polkadot/types/types';
-import { Class, Entity, VecClassPropertyValue, ClassPropertyValue, EntityId, ClassId, unifyPropName } from '.';
-import * as PV from './PropertyValue';
-import { PropertyValue } from './PropertyValue';
-import { PropertyTypeName } from './PropertyTypeName';
-import ChannelId from '../content-working-group/ChannelId';
+import BN from 'bn.js'
+import { Text, bool, Vec, u16 } from '@polkadot/types'
+import { Codec } from '@polkadot/types/types'
+import { Class, Entity, VecClassPropertyValue, ClassPropertyValue, EntityId, ClassId, unifyPropName } from '.'
+import * as PV from './PropertyValue'
+import { PropertyValue } from './PropertyValue'
+import { PropertyTypeName } from './PropertyTypeName'
+import ChannelId from '../content-working-group/ChannelId'
 
 /**
  * Convert a Substrate value to a plain JavaScript value of a corresponding type
  * like string, number, boolean, etc.
  */
-function substrateToPlain<T> (x: Codec): T | undefined {
-  let res: any = undefined;
+function substrateToPlain<T>(x: Codec): T | undefined {
+  let res: any = undefined
 
   if (x instanceof PV.None) {
-    res = undefined;
+    res = undefined
   } else if (x instanceof Text) {
-    res = (x as Text).toString();
+    res = (x as Text).toString()
   } else if (x instanceof BN) {
-    res = (x as BN).toNumber();
+    res = (x as BN).toNumber()
   } else if (x instanceof bool) {
-    res = (x as bool).valueOf();
+    res = (x as bool).valueOf()
   } else if (x instanceof Vec) {
-    res = x.map(y => substrateToPlain(y));
+    res = x.map((y) => substrateToPlain(y))
   } else if (typeof x !== 'undefined' && x !== null) {
-    res = x.toString();
+    res = x.toString()
   }
 
-  return res;
+  return res
 }
 
 /**
@@ -41,7 +41,6 @@ function substrateToPlain<T> (x: Codec): T | undefined {
  * @throws Error
  */
 function plainToSubstrate(propType: string, value: any): PropertyValue {
-
   const ok = (typeEnum: PV.PropertyValueEnum) => {
     return new PropertyValue({ [propType]: typeEnum })
   }
@@ -69,7 +68,7 @@ function plainToSubstrate(propType: string, value: any): PropertyValue {
     // This condition was never met (spotted by linter), because "typeof value" can be 'undefined'
     // (a string), but not actually undefined. Changing it to 'undefined' would change this function's behavior though
     // and that may lead to unexpected consequences.
-    return [ value ]
+    return [value]
   }
 
   const valueAsBoolArr = (): boolean[] => {
@@ -81,31 +80,49 @@ function plainToSubstrate(propType: string, value: any): PropertyValue {
   }
 
   switch (propType) {
-
     // Primitives:
 
-    case 'None':        return ok(new PV.None())
-    case 'Bool':        return ok(new PV.Bool(valueAsBool()))
-    case 'Uint16':      return ok(new PV.Uint16(value as string))
-    case 'Uint32':      return ok(new PV.Uint32(value as string))
-    case 'Uint64':      return ok(new PV.Uint64(value as string))
-    case 'Int16':       return ok(new PV.Int16(value as string))
-    case 'Int32':       return ok(new PV.Int32(value as string))
-    case 'Int64':       return ok(new PV.Int64(value as string))
-    case 'Text':        return ok(new PV.Text(value as string))
-    case 'Internal':    return ok(new PV.Internal(value as string))
+    case 'None':
+      return ok(new PV.None())
+    case 'Bool':
+      return ok(new PV.Bool(valueAsBool()))
+    case 'Uint16':
+      return ok(new PV.Uint16(value as string))
+    case 'Uint32':
+      return ok(new PV.Uint32(value as string))
+    case 'Uint64':
+      return ok(new PV.Uint64(value as string))
+    case 'Int16':
+      return ok(new PV.Int16(value as string))
+    case 'Int32':
+      return ok(new PV.Int32(value as string))
+    case 'Int64':
+      return ok(new PV.Int64(value as string))
+    case 'Text':
+      return ok(new PV.Text(value as string))
+    case 'Internal':
+      return ok(new PV.Internal(value as string))
 
     // Vectors:
 
-    case 'BoolVec':     return ok(new PV.BoolVec(valueAsBoolArr()))
-    case 'Uint16Vec':   return ok(new PV.Uint16Vec(valueAsStrArr()))
-    case 'Uint32Vec':   return ok(new PV.Uint32Vec(valueAsStrArr()))
-    case 'Uint64Vec':   return ok(new PV.Uint64Vec(valueAsStrArr()))
-    case 'Int16Vec':    return ok(new PV.Int16Vec(valueAsStrArr()))
-    case 'Int32Vec':    return ok(new PV.Int32Vec(valueAsStrArr()))
-    case 'Int64Vec':    return ok(new PV.Int64Vec(valueAsStrArr()))
-    case 'TextVec':     return ok(new PV.TextVec(valueAsStrArr()))
-    case 'InternalVec': return ok(new PV.InternalVec(valueAsArr()))
+    case 'BoolVec':
+      return ok(new PV.BoolVec(valueAsBoolArr()))
+    case 'Uint16Vec':
+      return ok(new PV.Uint16Vec(valueAsStrArr()))
+    case 'Uint32Vec':
+      return ok(new PV.Uint32Vec(valueAsStrArr()))
+    case 'Uint64Vec':
+      return ok(new PV.Uint64Vec(valueAsStrArr()))
+    case 'Int16Vec':
+      return ok(new PV.Int16Vec(valueAsStrArr()))
+    case 'Int32Vec':
+      return ok(new PV.Int32Vec(valueAsStrArr()))
+    case 'Int64Vec':
+      return ok(new PV.Int64Vec(valueAsStrArr()))
+    case 'TextVec':
+      return ok(new PV.TextVec(valueAsStrArr()))
+    case 'InternalVec':
+      return ok(new PV.InternalVec(valueAsArr()))
 
     default: {
       throw new Error(`Unknown property type name: ${propType}`)
@@ -117,11 +134,11 @@ interface HasTypeField {
   type: string
 }
 
-export function isInternalProp (field: HasTypeField): boolean {
+export function isInternalProp(field: HasTypeField): boolean {
   return field.type === 'Internal'
 }
 
-export function isInternalVecProp (field: HasTypeField): boolean {
+export function isInternalVecProp(field: HasTypeField): boolean {
   return field.type === 'InternalVec'
 }
 
@@ -155,47 +172,41 @@ export interface ToPlainObjectProps {
 }
 
 export abstract class EntityCodec<T extends PlainEntity> {
-
   private propNameToMetaMap: Map<string, PropMeta> = new Map()
   private propIndexToNameMap: Map<number, string> = new Map()
 
-  public constructor (entityClass: Class) {
+  public constructor(entityClass: Class) {
     entityClass.properties.map((p, index) => {
-      const propName = unifyPropName(p.name.toString());
-      const propMeta = { index, type: p.prop_type.type.toString() };
-      this.propNameToMetaMap.set(propName, propMeta);
-      this.propIndexToNameMap.set(index, propName);
+      const propName = unifyPropName(p.name.toString())
+      const propMeta = { index, type: p.prop_type.type.toString() }
+      this.propNameToMetaMap.set(propName, propMeta)
+      this.propIndexToNameMap.set(index, propName)
     })
   }
 
-  inClassIndexOfProp (propName: string): number | undefined {
+  inClassIndexOfProp(propName: string): number | undefined {
     return this.propNameToMetaMap.get(propName)?.index
   }
 
   /**
    * Converts an entity of Substrate codec type to a plain JS object.
    */
-  async toPlainObject (entity: Entity, props: ToPlainObjectProps = {}): Promise<T | undefined> {
-
-    const {
-      loadInternals,
-      loadEntityById,
-      loadChannelById
-    } = props || {}
+  async toPlainObject(entity: Entity, props: ToPlainObjectProps = {}): Promise<T | undefined> {
+    const { loadInternals, loadEntityById, loadChannelById } = props || {}
 
     const res: PlainEntity = {
       classId: entity.class_id.toNumber(),
-      inClassSchemaIndexes: entity.in_class_schema_indexes.map(x => x.toNumber()),
-      id: entity.id.toNumber()
+      inClassSchemaIndexes: entity.in_class_schema_indexes.map((x) => x.toNumber()),
+      id: entity.id.toNumber(),
     }
 
     if (!entity.in_class_schema_indexes.toArray().length) {
-		throw new Error(`No schema support exists for entity! Entity id: ${res.id}`);
-	}
+      throw new Error(`No schema support exists for entity! Entity id: ${res.id}`)
+    }
 
     for (const v of entity.entity_values) {
-      const propIdx = v.in_class_index.toNumber();
-      const propName = this.propIndexToNameMap.get(propIdx);
+      const propIdx = v.in_class_index.toNumber()
+      const propName = this.propIndexToNameMap.get(propIdx)
 
       if (propName) {
         const propValue = v.value.value
@@ -203,15 +214,9 @@ export abstract class EntityCodec<T extends PlainEntity> {
 
         // Load a referred internal entity:
         if (loadInternals) {
-          if (
-            propValue instanceof PV.Internal &&
-            typeof loadEntityById === 'function'
-          ) {
+          if (propValue instanceof PV.Internal && typeof loadEntityById === 'function') {
             convertedValue = await loadEntityById(propValue as EntityId)
-          } else if (
-            propName === 'channelId' &&
-            typeof loadChannelById === 'function'
-          ) {
+          } else if (propName === 'channelId' && typeof loadChannelById === 'function') {
             res.channel = await loadChannelById(propValue as ChannelId)
           }
         }
@@ -233,19 +238,18 @@ export abstract class EntityCodec<T extends PlainEntity> {
    * that can be passed to the extrinsic `update_entity_property_values`
    * of Substrate runtime module `substrate-versioned-store`.
    */
-  toSubstrateUpdate (updatedProps: Partial<{ [propName: string]: any }>): VecClassPropertyValue {
-
+  toSubstrateUpdate(updatedProps: Partial<{ [propName: string]: any }>): VecClassPropertyValue {
     // TODO check required fields! save prop metadata in constructor?
 
     // console.log('propNameToMetaMap propNameToMetaMap', this.propNameToMetaMap)
     // console.log('toSubstrateUpdate updatedProps', updatedProps)
 
-    const res = new VecClassPropertyValue();
-    Object.keys(updatedProps).map(propName => {
-      const meta = this.propNameToMetaMap.get(propName);
+    const res = new VecClassPropertyValue()
+    Object.keys(updatedProps).map((propName) => {
+      const meta = this.propNameToMetaMap.get(propName)
       if (meta) {
-        const propType = meta.type as PropertyTypeName;
-        const plainValue = (updatedProps as any)[propName];
+        const propType = meta.type as PropertyTypeName
+        const plainValue = (updatedProps as any)[propName]
 
         let codecValue: PropertyValue | undefined
         try {
@@ -255,14 +259,16 @@ export abstract class EntityCodec<T extends PlainEntity> {
         }
 
         if (codecValue) {
-          res.push(new ClassPropertyValue({
-            in_class_index: new u16(meta.index),
-            value: codecValue
-          }))
+          res.push(
+            new ClassPropertyValue({
+              in_class_index: new u16(meta.index),
+              value: codecValue,
+            })
+          )
         }
       }
-    });
-    return res;
+    })
+    return res
   }
 }
 
@@ -270,11 +276,10 @@ export abstract class EntityCodec<T extends PlainEntity> {
 export class AnyEntityCodec extends EntityCodec<any> {}
 
 export class EntityCodecResolver {
-
   private codecByClassIdMap = new Map<string, AnyEntityCodec>()
 
-  constructor (classes: Class[]) {
-    classes.forEach(c => {
+  constructor(classes: Class[]) {
+    classes.forEach((c) => {
       this.codecByClassIdMap.set(c.id.toString(), new AnyEntityCodec(c))
     })
   }

+ 1 - 1
types/src/versioned-store/EntityId.ts

@@ -1,3 +1,3 @@
-import { u64 } from '@polkadot/types';
+import { u64 } from '@polkadot/types'
 
 export default class EntityId extends u64 {}

+ 57 - 54
types/src/versioned-store/PropertyType.ts

@@ -1,6 +1,6 @@
-import { u16, Null } from '@polkadot/types';
-import { Enum, Tuple } from '@polkadot/types/codec';
-import ClassId from './ClassId';
+import { u16, Null } from '@polkadot/types'
+import { Enum, Tuple } from '@polkadot/types/codec'
+import ClassId from './ClassId'
 
 export class None extends Null {}
 
@@ -27,75 +27,78 @@ export class Int32Vec extends u16 {}
 export class Int64Vec extends u16 {}
 
 export class TextVec extends Tuple.with([u16, u16]) {
-  static newTypesafe (maxItems: u16 | number, maxTextLength: u16 | number) {
-    return new this([ maxItems, maxTextLength ]);
+  static newTypesafe(maxItems: u16 | number, maxTextLength: u16 | number) {
+    return new this([maxItems, maxTextLength])
   }
 }
 
 export class InternalVec extends Tuple.with([u16, ClassId]) {
-  static newTypesafe (maxItems: u16 | number, classId: ClassId | number) {
-    return new this([ maxItems, classId ]);
+  static newTypesafe(maxItems: u16 | number, classId: ClassId | number) {
+    return new this([maxItems, classId])
   }
 }
 
 export type PropertyTypeEnum =
-  None |
+  | None
 
   // Single values:
-  Bool |
-  Uint16 |
-  Uint32 |
-  Uint64 |
-  Int16 |
-  Int32 |
-  Int64 |
-  Text |
-  Internal |
+  | Bool
+  | Uint16
+  | Uint32
+  | Uint64
+  | Int16
+  | Int32
+  | Int64
+  | Text
+  | Internal
 
   // Vectors:
-  BoolVec |
-  Uint16Vec |
-  Uint32Vec |
-  Uint64Vec |
-  Int16Vec |
-  Int32Vec |
-  Int64Vec |
-  TextVec |
-  InternalVec
-;
+  | BoolVec
+  | Uint16Vec
+  | Uint32Vec
+  | Uint64Vec
+  | Int16Vec
+  | Int32Vec
+  | Int64Vec
+  | TextVec
+  | InternalVec
 
 type PropertyTypeEnumValue = {
-  [typeName: string]: PropertyTypeEnum;
-};
+  [typeName: string]: PropertyTypeEnum
+}
 
 export class PropertyType extends Enum {
-  constructor (value?: PropertyTypeEnumValue, index?: number) {
-    super({
-      None,
+  constructor(value?: PropertyTypeEnumValue, index?: number) {
+    super(
+      {
+        None,
 
-      // Single values:
-      Bool,
-      Uint16,
-      Uint32,
-      Uint64,
-      Int16,
-      Int32,
-      Int64,
-      Text,
-      Internal,
+        // Single values:
+        Bool,
+        Uint16,
+        Uint32,
+        Uint64,
+        Int16,
+        Int32,
+        Int64,
+        Text,
+        Internal,
 
-      // Vectors:
-      BoolVec,
-      Uint16Vec,
-      Uint32Vec,
-      Uint64Vec,
-      Int16Vec,
-      Int32Vec,
-      Int64Vec,
-      TextVec,
-      InternalVec
-    }, value, index);
+        // Vectors:
+        BoolVec,
+        Uint16Vec,
+        Uint32Vec,
+        Uint64Vec,
+        Int16Vec,
+        Int32Vec,
+        Int64Vec,
+        TextVec,
+        InternalVec,
+      },
+      value,
+      index
+    )
   }
 }
 
-export default PropertyType;
+export default PropertyType

+ 19 - 21
types/src/versioned-store/PropertyTypeName.ts

@@ -1,24 +1,22 @@
 export type PropertyTypeName =
-  'None' |
-  'Bool' |
-  'Uint16' |
-  'Uint32' |
-  'Uint64' |
-  'Int16' |
-  'Int32' |
-  'Int64' |
-  'Text' |
-  'Internal' |
+  | 'None'
+  | 'Bool'
+  | 'Uint16'
+  | 'Uint32'
+  | 'Uint64'
+  | 'Int16'
+  | 'Int32'
+  | 'Int64'
+  | 'Text'
+  | 'Internal'
 
   // Vectors:
-
-  'BoolVec' |
-  'Uint16Vec' |
-  'Uint32Vec' |
-  'Uint64Vec' |
-  'Int16Vec' |
-  'Int32Vec' |
-  'Int64Vec' |
-  'TextVec' |
-  'InternalVec'
-;
+  | 'BoolVec'
+  | 'Uint16Vec'
+  | 'Uint32Vec'
+  | 'Uint64Vec'
+  | 'Int16Vec'
+  | 'Int32Vec'
+  | 'Int64Vec'
+  | 'TextVec'
+  | 'InternalVec'

+ 64 - 50
types/src/versioned-store/PropertyValue.ts

@@ -1,6 +1,17 @@
-import { Vec as Vector, Text as PolkaText, bool as PolkaBool, Null, u16, u32, u64, i16, i32, i64 } from '@polkadot/types';
-import { Enum } from '@polkadot/types/codec';
-import EntityId from './EntityId';
+import {
+  Vec as Vector,
+  Text as PolkaText,
+  bool as PolkaBool,
+  Null,
+  u16,
+  u32,
+  u64,
+  i16,
+  i32,
+  i64,
+} from '@polkadot/types'
+import { Enum } from '@polkadot/types/codec'
+import EntityId from './EntityId'
 
 export class None extends Null {}
 
@@ -30,63 +41,66 @@ export class TextVec extends Vector.with(PolkaText) {}
 export class InternalVec extends Vector.with(EntityId) {}
 
 export type PropertyValueEnum =
-  None |
+  | None
 
   // Single values:
-  Bool |
-  Uint16 |
-  Uint32 |
-  Uint64 |
-  Int16 |
-  Int32 |
-  Int64 |
-  Text |
-  Internal |
+  | Bool
+  | Uint16
+  | Uint32
+  | Uint64
+  | Int16
+  | Int32
+  | Int64
+  | Text
+  | Internal
 
   // Vectors:
-  BoolVec |
-  Uint16Vec |
-  Uint32Vec |
-  Uint64Vec |
-  Int16Vec |
-  Int32Vec |
-  Int64Vec |
-  TextVec |
-  InternalVec
-;
+  | BoolVec
+  | Uint16Vec
+  | Uint32Vec
+  | Uint64Vec
+  | Int16Vec
+  | Int32Vec
+  | Int64Vec
+  | TextVec
+  | InternalVec
 
 export type PropertyValueEnumValue = {
-  [typeName: string]: PropertyValueEnum;
-};
+  [typeName: string]: PropertyValueEnum
+}
 
 export class PropertyValue extends Enum {
-  constructor (value?: PropertyValueEnumValue, index?: number) {
-    super({
-      None,
+  constructor(value?: PropertyValueEnumValue, index?: number) {
+    super(
+      {
+        None,
 
-      // Single values:
-      Bool,
-      Uint16,
-      Uint32,
-      Uint64,
-      Int16,
-      Int32,
-      Int64,
-      Text,
-      Internal,
+        // Single values:
+        Bool,
+        Uint16,
+        Uint32,
+        Uint64,
+        Int16,
+        Int32,
+        Int64,
+        Text,
+        Internal,
 
-      // Vectors:
-      BoolVec,
-      Uint16Vec,
-      Uint32Vec,
-      Uint64Vec,
-      Int16Vec,
-      Int32Vec,
-      Int64Vec,
-      TextVec,
-      InternalVec
-    }, value, index);
+        // Vectors:
+        BoolVec,
+        Uint16Vec,
+        Uint32Vec,
+        Uint64Vec,
+        Int16Vec,
+        Int32Vec,
+        Int64Vec,
+        TextVec,
+        InternalVec,
+      },
+      value,
+      index
+    )
   }
 }
 
-export default PropertyValue;
+export default PropertyValue

+ 106 - 96
types/src/versioned-store/index.ts

@@ -1,50 +1,48 @@
-import { getTypeRegistry, u16, Text, bool as Bool } from '@polkadot/types';
-import { Vec as Vector } from '@polkadot/types/codec';
-import { JoyStruct } from '../common';
-import EntityId from './EntityId';
-import ClassId from './ClassId';
-import PropertyType from './PropertyType';
-import PropertyValue from './PropertyValue';
+import { getTypeRegistry, u16, Text, bool as Bool } from '@polkadot/types'
+import { Vec as Vector } from '@polkadot/types/codec'
+import { JoyStruct } from '../common'
+import EntityId from './EntityId'
+import ClassId from './ClassId'
+import PropertyType from './PropertyType'
+import PropertyValue from './PropertyValue'
 import { camelCase, upperFirst } from 'lodash'
 
-export {
-  ClassId,
-  EntityId,
-  PropertyType,
-  PropertyValue
-}
+export { ClassId, EntityId, PropertyType, PropertyValue }
 
 export type PropertyTsType = {
-  prop_type: PropertyType,
-  required: Bool,
-  name: Text,
+  prop_type: PropertyType
+  required: Bool
+  name: Text
   description: Text
-};
+}
 
 export class Property extends JoyStruct<PropertyTsType> {
-  constructor (value: PropertyTsType) {
-    super({
-      prop_type: PropertyType,
-      required: Bool,
-      name: Text,
-      description: Text
-    }, value);
+  constructor(value: PropertyTsType) {
+    super(
+      {
+        prop_type: PropertyType,
+        required: Bool,
+        name: Text,
+        description: Text,
+      },
+      value
+    )
   }
 
-  get prop_type (): PropertyType {
-    return this.getField('prop_type');
+  get prop_type(): PropertyType {
+    return this.getField('prop_type')
   }
 
-  get required (): boolean {
-    return this.getBoolean('required');
+  get required(): boolean {
+    return this.getBoolean('required')
   }
 
-  get name (): string {
-    return this.getString('name');
+  get name(): string {
+    return this.getString('name')
   }
 
-  get description (): string {
-    return this.getString('description');
+  get description(): string {
+    return this.getString('description')
   }
 }
 
@@ -54,118 +52,130 @@ export class VecU16 extends Vector.with(u16) {}
 
 export type ClassSchemaType = {
   properties: VecU16
-};
+}
 
 export class ClassSchema extends JoyStruct<ClassSchemaType> {
-  constructor (value: ClassSchemaType) {
-    super({
-      properties: VecU16
-    }, value);
+  constructor(value: ClassSchemaType) {
+    super(
+      {
+        properties: VecU16,
+      },
+      value
+    )
   }
 
-  get properties (): VecU16 {
-    return this.getField('properties');
+  get properties(): VecU16 {
+    return this.getField('properties')
   }
 }
 
 export class VecClassSchema extends Vector.with(ClassSchema) {}
 
 export type ClassPropertyValueType = {
-  in_class_index: u16,
+  in_class_index: u16
   value: PropertyValue
-};
+}
 
 export class ClassPropertyValue extends JoyStruct<ClassPropertyValueType> {
-  constructor (value: ClassPropertyValueType) {
-    super({
-      in_class_index: u16,
-      value: PropertyValue
-    }, value);
+  constructor(value: ClassPropertyValueType) {
+    super(
+      {
+        in_class_index: u16,
+        value: PropertyValue,
+      },
+      value
+    )
   }
 
-  get in_class_index (): u16 {
-    return this.getField('in_class_index');
+  get in_class_index(): u16 {
+    return this.getField('in_class_index')
   }
 
-  get value (): PropertyValue {
-    return this.getField('value');
+  get value(): PropertyValue {
+    return this.getField('value')
   }
 }
 
 export class VecClassPropertyValue extends Vector.with(ClassPropertyValue) {}
 
 export type ClassType = {
-  id: ClassId,
-  properties: VecProperty,
-  schemas: VecClassSchema,
-  name: Text,
+  id: ClassId
+  properties: VecProperty
+  schemas: VecClassSchema
+  name: Text
   description: Text
-};
+}
 
 export class Class extends JoyStruct<ClassType> {
-  constructor (value: ClassType) {
-    super({
-      id: ClassId,
-      properties: VecProperty,
-      schemas: VecClassSchema,
-      name: Text,
-      description: Text
-    }, value);
+  constructor(value: ClassType) {
+    super(
+      {
+        id: ClassId,
+        properties: VecProperty,
+        schemas: VecClassSchema,
+        name: Text,
+        description: Text,
+      },
+      value
+    )
   }
 
-  get id (): ClassId {
-    return this.getField('id');
+  get id(): ClassId {
+    return this.getField('id')
   }
 
-  get properties (): VecProperty {
-    return this.getField('properties');
+  get properties(): VecProperty {
+    return this.getField('properties')
   }
 
-  get schemas (): VecClassSchema {
-    return this.getField('schemas');
+  get schemas(): VecClassSchema {
+    return this.getField('schemas')
   }
 
-  get name (): string {
-    return this.getString('name');
+  get name(): string {
+    return this.getString('name')
   }
 
-  get description (): string {
-    return this.getString('description');
+  get description(): string {
+    return this.getString('description')
   }
 }
 
 export type EntityType = {
-  id: EntityId,
-  class_id: ClassId,
-  in_class_schema_indexes: VecU16,
+  id: EntityId
+  class_id: ClassId
+  in_class_schema_indexes: VecU16
   values: VecClassPropertyValue
-};
+}
 
 export class Entity extends JoyStruct<EntityType> {
-  constructor (value: EntityType) {
-    super({
-      id: EntityId,
-      class_id: ClassId,
-      in_class_schema_indexes: VecU16,
-      values: VecClassPropertyValue
-    }, value);
+  constructor(value: EntityType) {
+    super(
+      {
+        id: EntityId,
+        class_id: ClassId,
+        in_class_schema_indexes: VecU16,
+        values: VecClassPropertyValue,
+      },
+      value
+    )
   }
 
-  get id (): EntityId {
-    return this.getField('id');
+  get id(): EntityId {
+    return this.getField('id')
   }
 
-  get class_id (): ClassId {
-    return this.getField('class_id');
+  get class_id(): ClassId {
+    return this.getField('class_id')
   }
 
-  get in_class_schema_indexes (): VecU16 {
-    return this.getField('in_class_schema_indexes');
+  get in_class_schema_indexes(): VecU16 {
+    return this.getField('in_class_schema_indexes')
   }
 
   /** NOTE: Renamed to `entity_values` because `values` is already in use. */
-  get entity_values (): VecClassPropertyValue {
-    return this.getField('values');
+  get entity_values(): VecClassPropertyValue {
+    return this.getField('values')
   }
 }
 
@@ -195,7 +205,7 @@ export function unifyPropName(propName: string): string {
   return camelCase(propName)
 }
 
-export function registerVersionedStoreTypes () {
+export function registerVersionedStoreTypes() {
   try {
     getTypeRegistry().register({
       ClassId: 'u64',
@@ -206,9 +216,9 @@ export function registerVersionedStoreTypes () {
       Property,
       PropertyType,
       PropertyValue,
-      ClassPropertyValue
-    });
+      ClassPropertyValue,
+    })
   } catch (err) {
-    console.error('Failed to register custom types of Versioned Store module', err);
+    console.error('Failed to register custom types of Versioned Store module', err)
   }
 }

+ 56 - 54
types/src/versioned-store/permissions/ClassPermissions.ts

@@ -1,58 +1,60 @@
-import { u32, bool } from '@polkadot/types';
-import { BlockNumber } from '@polkadot/types/interfaces';
-import { JoyStruct, CredentialSet } from '../../common';
-import EntityPermissions from './EntityPermissions';
-import { ReferenceConstraint } from './reference-constraint';
+import { u32, bool } from '@polkadot/types'
+import { BlockNumber } from '@polkadot/types/interfaces'
+import { JoyStruct, CredentialSet } from '../../common'
+import EntityPermissions from './EntityPermissions'
+import { ReferenceConstraint } from './reference-constraint'
 
 type IClassPermissions = {
-    entity_permissions: EntityPermissions,
-    entities_can_be_created: bool,
-    add_schemas: CredentialSet,
-    create_entities: CredentialSet,
-    reference_constraint: ReferenceConstraint,
-    admins: CredentialSet,
-    last_permissions_update: BlockNumber,
-};
+  entity_permissions: EntityPermissions
+  entities_can_be_created: bool
+  add_schemas: CredentialSet
+  create_entities: CredentialSet
+  reference_constraint: ReferenceConstraint
+  admins: CredentialSet
+  last_permissions_update: BlockNumber
+}
 
 export default class ClassPermissionsType extends JoyStruct<IClassPermissions> {
-    constructor (value: IClassPermissions) {
-        super({
-            entity_permissions: EntityPermissions,
-            entities_can_be_created: bool,
-            add_schemas: CredentialSet,
-            create_entities: CredentialSet,
-            reference_constraint: ReferenceConstraint,
-            admins: CredentialSet,
-            last_permissions_update: u32, // BlockNumber,
-        }, value);
-    }
-
-
-    get entity_permissions() : EntityPermissions {
-        return this.getField('entity_permissions');
-    }
-
-    get entities_can_be_created() : bool {
-        return this.getField('entities_can_be_created');
-    }
-
-    get add_schemas() : CredentialSet {
-        return this.getField('add_schemas');
-    }
-
-    get create_entities() : CredentialSet {
-        return this.getField('create_entities');
-    }
-
-    get reference_constraint() : ReferenceConstraint {
-        return this.getField('reference_constraint');
-    }
-
-    get admins () : CredentialSet {
-        return this.getField('admins');
-    }
-
-    get last_permissions_update() : u32 {
-        return this.getField('last_permissions_update');
-    }
-}
+  constructor(value: IClassPermissions) {
+    super(
+      {
+        entity_permissions: EntityPermissions,
+        entities_can_be_created: bool,
+        add_schemas: CredentialSet,
+        create_entities: CredentialSet,
+        reference_constraint: ReferenceConstraint,
+        admins: CredentialSet,
+        last_permissions_update: u32, // BlockNumber,
+      },
+      value
+    )
+  }
+
+  get entity_permissions(): EntityPermissions {
+    return this.getField('entity_permissions')
+  }
+
+  get entities_can_be_created(): bool {
+    return this.getField('entities_can_be_created')
+  }
+
+  get add_schemas(): CredentialSet {
+    return this.getField('add_schemas')
+  }
+
+  get create_entities(): CredentialSet {
+    return this.getField('create_entities')
+  }
+
+  get reference_constraint(): ReferenceConstraint {
+    return this.getField('reference_constraint')
+  }
+
+  get admins(): CredentialSet {
+    return this.getField('admins')
+  }
+
+  get last_permissions_update(): u32 {
+    return this.getField('last_permissions_update')
+  }
+}

+ 22 - 19
types/src/versioned-store/permissions/EntityPermissions.ts

@@ -1,25 +1,28 @@
-import { JoyStruct } from '../../JoyStruct';
-import { bool } from '@polkadot/types';
-import { CredentialSet } from '../../common';
+import { JoyStruct } from '../../JoyStruct'
+import { bool } from '@polkadot/types'
+import { CredentialSet } from '../../common'
 
 type IEntityPermissions = {
-    update: CredentialSet,
-    maintainer_has_all_permissions: bool
-};
+  update: CredentialSet
+  maintainer_has_all_permissions: bool
+}
 
 export default class EntityPermissions extends JoyStruct<IEntityPermissions> {
-    constructor (value: IEntityPermissions) {
-        super({
-            update: CredentialSet,
-            maintainer_has_all_permissions: bool
-        }, value);
-    }
+  constructor(value: IEntityPermissions) {
+    super(
+      {
+        update: CredentialSet,
+        maintainer_has_all_permissions: bool,
+      },
+      value
+    )
+  }
 
-    get update () : CredentialSet {
-        return this.getField('update');
-    }
+  get update(): CredentialSet {
+    return this.getField('update')
+  }
 
-    get maintainer_has_all_permissions() : bool {
-        return this.getField('maintainer_has_all_permissions');
-    }
-}
+  get maintainer_has_all_permissions(): bool {
+    return this.getField('maintainer_has_all_permissions')
+  }
+}

+ 22 - 19
types/src/versioned-store/permissions/PropertyOfClass.ts

@@ -1,25 +1,28 @@
-import { u16 } from '@polkadot/types';
-import { JoyStruct } from '../../common';
-import ClassId from '../ClassId';
+import { u16 } from '@polkadot/types'
+import { JoyStruct } from '../../common'
+import ClassId from '../ClassId'
 
 type IPropertyOfClass = {
-    class_id: ClassId,
-    property_index: u16
-};
+  class_id: ClassId
+  property_index: u16
+}
 
 export default class PropertyOfClass extends JoyStruct<IPropertyOfClass> {
-    constructor (value: IPropertyOfClass) {
-        super({
-            class_id: ClassId,
-            property_index: u16
-        }, value);
-    }
+  constructor(value: IPropertyOfClass) {
+    super(
+      {
+        class_id: ClassId,
+        property_index: u16,
+      },
+      value
+    )
+  }
 
-    get class_id () : ClassId {
-        return this.getField('class_id');
-    }
+  get class_id(): ClassId {
+    return this.getField('class_id')
+  }
 
-    get property_index() : u16 {
-        return this.getField('property_index');
-    }
-}
+  get property_index(): u16 {
+    return this.getField('property_index')
+  }
+}

+ 22 - 20
types/src/versioned-store/permissions/batching/ParametrizedClassPropertyValue.ts

@@ -1,26 +1,28 @@
-
-import { ParametrizedPropertyValue } from './parametrized-property-value';
-import { JoyStruct } from '../../../common';
-import { u16 } from '@polkadot/types';
+import { ParametrizedPropertyValue } from './parametrized-property-value'
+import { JoyStruct } from '../../../common'
+import { u16 } from '@polkadot/types'
 
 type IParametrizedClassPropertyValue = {
-    in_class_index: u16,
-    value: ParametrizedPropertyValue
-};
+  in_class_index: u16
+  value: ParametrizedPropertyValue
+}
 
 export default class ParametrizedClassPropertyValue extends JoyStruct<IParametrizedClassPropertyValue> {
-    constructor (value: IParametrizedClassPropertyValue) {
-        super({
-            in_class_index: u16,
-            value: ParametrizedPropertyValue
-        }, value);
-    }
+  constructor(value: IParametrizedClassPropertyValue) {
+    super(
+      {
+        in_class_index: u16,
+        value: ParametrizedPropertyValue,
+      },
+      value
+    )
+  }
 
-    get in_class_index() : u16 {
-        return this.getField('in_class_index');
-    }
+  get in_class_index(): u16 {
+    return this.getField('in_class_index')
+  }
 
-    get value() : ParametrizedPropertyValue {
-        return this.getField('value');
-    }
-}
+  get value(): ParametrizedPropertyValue {
+    return this.getField('value')
+  }
+}

+ 26 - 23
types/src/versioned-store/permissions/batching/index.ts

@@ -1,31 +1,34 @@
-import { JoyStruct, Credential } from '../../../common';
-import { OperationType } from './operation-types';
-import { bool, Option } from '@polkadot/types';
+import { JoyStruct, Credential } from '../../../common'
+import { OperationType } from './operation-types'
+import { bool, Option } from '@polkadot/types'
 
 type IOperation = {
-    with_credential: Option<Credential>,
-    as_entity_maintainer: bool,
-    operation_type: OperationType,
+  with_credential: Option<Credential>
+  as_entity_maintainer: bool
+  operation_type: OperationType
 }
 
 export class Operation extends JoyStruct<IOperation> {
-    constructor (value: IOperation) {
-        super({
-            with_credential: Option.with(Credential),
-            as_entity_maintainer: bool,
-            operation_type: OperationType,
-        }, value);
-    }
+  constructor(value: IOperation) {
+    super(
+      {
+        with_credential: Option.with(Credential),
+        as_entity_maintainer: bool,
+        operation_type: OperationType,
+      },
+      value
+    )
+  }
 
-    get with_credential () : Option<Credential> {
-        return this.getField('with_credential');
-    }
+  get with_credential(): Option<Credential> {
+    return this.getField('with_credential')
+  }
 
-    get as_entity_maintainer () : bool {
-        return this.getField('as_entity_maintainer');
-    }
+  get as_entity_maintainer(): bool {
+    return this.getField('as_entity_maintainer')
+  }
 
-    get operation_type () : OperationType {
-        return this.getField('operation_type');
-    }
-}
+  get operation_type(): OperationType {
+    return this.getField('operation_type')
+  }
+}

+ 36 - 20
types/src/versioned-store/permissions/batching/operation-types.ts

@@ -1,46 +1,62 @@
-import { Enum, u16 } from '@polkadot/types';
-import { CreateEntityOperation, UpdatePropertyValuesOperation, AddSchemaSupportToEntityOperation, ParameterizedClassPropertyValues } from './operations'
-import ClassId from '../../ClassId';
-import { ParametrizedEntity } from './parametrized-entity';
+import { Enum, u16 } from '@polkadot/types'
+import {
+  CreateEntityOperation,
+  UpdatePropertyValuesOperation,
+  AddSchemaSupportToEntityOperation,
+  ParameterizedClassPropertyValues,
+} from './operations'
+import ClassId from '../../ClassId'
+import { ParametrizedEntity } from './parametrized-entity'
 
 export class CreateEntity extends CreateEntityOperation {}
 export class UpdatePropertyValues extends UpdatePropertyValuesOperation {}
 export class AddSchemaSupportToEntity extends AddSchemaSupportToEntityOperation {}
 
-export type OperationTypeVariant = CreateEntity | UpdatePropertyValues | AddSchemaSupportToEntity;
+export type OperationTypeVariant = CreateEntity | UpdatePropertyValues | AddSchemaSupportToEntity
 
 type OperationTypeVariantValue = {
-    [typeName: string]: OperationTypeVariant;
-};
+  [typeName: string]: OperationTypeVariant
+}
 
 export class OperationType extends Enum {
-  constructor (value?: OperationTypeVariantValue, index?: number) {
-    super({
+  constructor(value?: OperationTypeVariantValue, index?: number) {
+    super(
+      {
         CreateEntity,
         UpdatePropertyValues,
         AddSchemaSupportToEntity,
-    }, value, index);
+      },
+      value,
+      index
+    )
   }
 
-  static CreateEntity (class_id: ClassId) : OperationType {
-    const value = new CreateEntity({class_id});
-    return new OperationType({'CreateEntity': value });
+  static CreateEntity(class_id: ClassId): OperationType {
+    const value = new CreateEntity({ class_id })
+    return new OperationType({ CreateEntity: value })
   }
 
-  static UpdatePropertyValues (entity_id: ParametrizedEntity, parametrized_property_values: ParameterizedClassPropertyValues) : OperationType {
+  static UpdatePropertyValues(
+    entity_id: ParametrizedEntity,
+    parametrized_property_values: ParameterizedClassPropertyValues
+  ): OperationType {
     const value = new UpdatePropertyValues({
       entity_id,
       parametrized_property_values,
-    });
-    return new OperationType({'UpdatePropertyValues': value});
+    })
+    return new OperationType({ UpdatePropertyValues: value })
   }
 
-  static AddSchemaSupportToEntity (entity_id: ParametrizedEntity, schema_id: u16, parametrized_property_values: ParameterizedClassPropertyValues) : OperationType {
+  static AddSchemaSupportToEntity(
+    entity_id: ParametrizedEntity,
+    schema_id: u16,
+    parametrized_property_values: ParameterizedClassPropertyValues
+  ): OperationType {
     const value = new AddSchemaSupportToEntity({
       entity_id,
       schema_id,
-      parametrized_property_values
-    });
-    return new OperationType({'AddSchemaSupportToEntity': value});
+      parametrized_property_values,
+    })
+    return new OperationType({ AddSchemaSupportToEntity: value })
   }
 }

+ 60 - 51
types/src/versioned-store/permissions/batching/operations.ts

@@ -1,74 +1,83 @@
-import ClassId from "../../ClassId";
-import { JoyStruct } from '../../../common';
-import { ParametrizedEntity } from "./parametrized-entity";
-import { Vec, u16 } from "@polkadot/types";
-import ParametrizedClassPropertyValue from "./ParametrizedClassPropertyValue";
+import ClassId from '../../ClassId'
+import { JoyStruct } from '../../../common'
+import { ParametrizedEntity } from './parametrized-entity'
+import { Vec, u16 } from '@polkadot/types'
+import ParametrizedClassPropertyValue from './ParametrizedClassPropertyValue'
 
 // TODO Rename to ParametrizedClassPropertyValue
 export class ParameterizedClassPropertyValues extends Vec.with(ParametrizedClassPropertyValue) {}
 
 export type ICreateEntityOperation = {
-    class_id: ClassId,
-};
+  class_id: ClassId
+}
 
 export type IUpdatePropertyValuesOperation = {
-    entity_id: ParametrizedEntity,
-    parametrized_property_values: ParameterizedClassPropertyValues
-};
+  entity_id: ParametrizedEntity
+  parametrized_property_values: ParameterizedClassPropertyValues
+}
 
 export type IAddSchemaSupportToEntityOperation = {
-    entity_id: ParametrizedEntity,
-    schema_id: u16,
-    parametrized_property_values: ParameterizedClassPropertyValues
-};
+  entity_id: ParametrizedEntity
+  schema_id: u16
+  parametrized_property_values: ParameterizedClassPropertyValues
+}
 
 export class CreateEntityOperation extends JoyStruct<ICreateEntityOperation> {
-    constructor (value: ICreateEntityOperation) {
-        super({
-            class_id: ClassId,
-        }, value);
-    }
+  constructor(value: ICreateEntityOperation) {
+    super(
+      {
+        class_id: ClassId,
+      },
+      value
+    )
+  }
 
-    get class_id () : ClassId {
-        return this.getField('class_id');
-    }
+  get class_id(): ClassId {
+    return this.getField('class_id')
+  }
 }
 
 export class UpdatePropertyValuesOperation extends JoyStruct<IUpdatePropertyValuesOperation> {
-    constructor (value: IUpdatePropertyValuesOperation) {
-        super({
-            entity_id: ParametrizedEntity,
-            parametrized_property_values: ParameterizedClassPropertyValues
-        }, value);
-    }
+  constructor(value: IUpdatePropertyValuesOperation) {
+    super(
+      {
+        entity_id: ParametrizedEntity,
+        parametrized_property_values: ParameterizedClassPropertyValues,
+      },
+      value
+    )
+  }
 
-    get entity_id() : ParametrizedEntity {
-        return this.getField('entity_id');
-    }
+  get entity_id(): ParametrizedEntity {
+    return this.getField('entity_id')
+  }
 
-    get property_values() : ParameterizedClassPropertyValues {
-        return this.getField('parametrized_property_values');
-    }
+  get property_values(): ParameterizedClassPropertyValues {
+    return this.getField('parametrized_property_values')
+  }
 }
 
 export class AddSchemaSupportToEntityOperation extends JoyStruct<IAddSchemaSupportToEntityOperation> {
-    constructor (value: IAddSchemaSupportToEntityOperation) {
-        super({
-            entity_id: ParametrizedEntity,
-            schema_id: u16,
-            parametrized_property_values: ParameterizedClassPropertyValues
-        }, value);
-    }
+  constructor(value: IAddSchemaSupportToEntityOperation) {
+    super(
+      {
+        entity_id: ParametrizedEntity,
+        schema_id: u16,
+        parametrized_property_values: ParameterizedClassPropertyValues,
+      },
+      value
+    )
+  }
 
-    get entity_id() : ParametrizedEntity {
-        return this.getField('entity_id');
-    }
+  get entity_id(): ParametrizedEntity {
+    return this.getField('entity_id')
+  }
 
-    get property_values() : ParameterizedClassPropertyValues {
-        return this.getField('parametrized_property_values');
-    }
+  get property_values(): ParameterizedClassPropertyValues {
+    return this.getField('parametrized_property_values')
+  }
 
-    get schema_id() : u16 {
-        return this.getField('schema_id');
-    }
-}
+  get schema_id(): u16 {
+    return this.getField('schema_id')
+  }
+}

+ 16 - 12
types/src/versioned-store/permissions/batching/parametrized-entity.ts

@@ -1,28 +1,32 @@
-import { Enum, u32 } from '@polkadot/types';
-import EntityId from '../../EntityId';
+import { Enum, u32 } from '@polkadot/types'
+import EntityId from '../../EntityId'
 
 export class InternalEntityJustAdded extends u32 {}
 export class ExistingEntity extends EntityId {}
 
-export type ParametrizedEntityVariant = InternalEntityJustAdded | ExistingEntity;
+export type ParametrizedEntityVariant = InternalEntityJustAdded | ExistingEntity
 
 type ParametrizedEntityValue = {
-    [typeName: string]: ParametrizedEntityVariant;
-};
+  [typeName: string]: ParametrizedEntityVariant
+}
 
 export class ParametrizedEntity extends Enum {
-  constructor (value?: ParametrizedEntityValue, index?: number) {
-    super({
+  constructor(value?: ParametrizedEntityValue, index?: number) {
+    super(
+      {
         InternalEntityJustAdded,
         ExistingEntity,
-    }, value, index);
+      },
+      value,
+      index
+    )
   }
 
-  static InternalEntityJustAdded (index: u32) : ParametrizedEntity {
-    return new ParametrizedEntity({'InternalEntityJustAdded': new InternalEntityJustAdded(index)});
+  static InternalEntityJustAdded(index: u32): ParametrizedEntity {
+    return new ParametrizedEntity({ InternalEntityJustAdded: new InternalEntityJustAdded(index) })
   }
 
-  static ExistingEntity (entity_id: EntityId) : ParametrizedEntity {
-    return new ParametrizedEntity({'ExistingEntity': new ExistingEntity(entity_id)});
+  static ExistingEntity(entity_id: EntityId): ParametrizedEntity {
+    return new ParametrizedEntity({ ExistingEntity: new ExistingEntity(entity_id) })
   }
 }

+ 27 - 29
types/src/versioned-store/permissions/batching/parametrized-property-value.ts

@@ -1,41 +1,39 @@
-import { Enum, u32, Vec } from '@polkadot/types';
-import { PropertyValue as VersionedStorePropertyValue, PropertyValueEnumValue } from '../../PropertyValue';
-import { ParametrizedEntity } from './parametrized-entity';
+import { Enum, u32, Vec } from '@polkadot/types'
+import { PropertyValue as VersionedStorePropertyValue, PropertyValueEnumValue } from '../../PropertyValue'
+import { ParametrizedEntity } from './parametrized-entity'
 
 export class PropertyValue extends VersionedStorePropertyValue {}
 export class InternalEntityJustAdded extends u32 {}
 export class InternalEntityVec extends Vec.with(ParametrizedEntity) {}
 
-export type ParametrizedPropertyValueVariant = PropertyValue | InternalEntityJustAdded | InternalEntityVec;
+export type ParametrizedPropertyValueVariant = PropertyValue | InternalEntityJustAdded | InternalEntityVec
 
 type ParametrizedPropertyValueType = {
-    [typeName: string]: ParametrizedPropertyValueVariant;
-};
+  [typeName: string]: ParametrizedPropertyValueVariant
+}
 
 export class ParametrizedPropertyValue extends Enum {
-    constructor (value?: ParametrizedPropertyValueType, index?: number) {
-        super({
-            PropertyValue,
-            InternalEntityJustAdded,
-            InternalEntityVec,
-        }, value, index);
-    }
+  constructor(value?: ParametrizedPropertyValueType, index?: number) {
+    super(
+      {
+        PropertyValue,
+        InternalEntityJustAdded,
+        InternalEntityVec,
+      },
+      value,
+      index
+    )
+  }
 
-    static PropertyValue(value: PropertyValueEnumValue) : ParametrizedPropertyValue {
-        return new ParametrizedPropertyValue({'PropertyValue': new VersionedStorePropertyValue(
-            value
-        )});
-    }
+  static PropertyValue(value: PropertyValueEnumValue): ParametrizedPropertyValue {
+    return new ParametrizedPropertyValue({ PropertyValue: new VersionedStorePropertyValue(value) })
+  }
 
-    static InternalEntityJustAdded(index: number | u32) : ParametrizedPropertyValue {
-        return new ParametrizedPropertyValue({'InternalEntityJustAdded': new InternalEntityJustAdded(
-            index
-        )});
-    }
+  static InternalEntityJustAdded(index: number | u32): ParametrizedPropertyValue {
+    return new ParametrizedPropertyValue({ InternalEntityJustAdded: new InternalEntityJustAdded(index) })
+  }
 
-    static InternalEntityVec(entities: ParametrizedEntity[] | Vec<ParametrizedEntity>) : ParametrizedPropertyValue {
-        return new ParametrizedPropertyValue({'InternalEntityVec': new InternalEntityVec(
-            entities
-        )});
-    }
-}
+  static InternalEntityVec(entities: ParametrizedEntity[] | Vec<ParametrizedEntity>): ParametrizedPropertyValue {
+    return new ParametrizedPropertyValue({ InternalEntityVec: new InternalEntityVec(entities) })
+  }
+}

+ 16 - 16
types/src/versioned-store/permissions/index.ts

@@ -1,19 +1,19 @@
-import { getTypeRegistry } from '@polkadot/types';
+import { getTypeRegistry } from '@polkadot/types'
 
-import EntityPermissions from './EntityPermissions';
-import { ReferenceConstraint} from './reference-constraint';
-import ClassPermissionsType from './ClassPermissions';
-import { Operation } from './batching/';
+import EntityPermissions from './EntityPermissions'
+import { ReferenceConstraint } from './reference-constraint'
+import ClassPermissionsType from './ClassPermissions'
+import { Operation } from './batching/'
 
-export function registerVersionedStorePermissionsTypes () {
-    try {
-      getTypeRegistry().register({
-        EntityPermissions,
-        ReferenceConstraint,
-        ClassPermissionsType,
-        Operation,
-      });
-    } catch (err) {
-      console.error('Failed to register custom types of versioned store module', err);
-    }
+export function registerVersionedStorePermissionsTypes() {
+  try {
+    getTypeRegistry().register({
+      EntityPermissions,
+      ReferenceConstraint,
+      ClassPermissionsType,
+      Operation,
+    })
+  } catch (err) {
+    console.error('Failed to register custom types of versioned store module', err)
   }
+}

+ 22 - 22
types/src/versioned-store/permissions/reference-constraint.ts

@@ -1,38 +1,38 @@
-import { Enum, Null, Vec } from '@polkadot/types';
-import PropertyOfClass from './PropertyOfClass';
+import { Enum, Null, Vec } from '@polkadot/types'
+import PropertyOfClass from './PropertyOfClass'
 
 export class NoReferencingAllowed extends Null {}
 export class NoConstraint extends Null {}
 export class Restricted extends Vec.with(PropertyOfClass) {} // BtreeSet ?
 
-export type ReferenceConstraintVariant =
-  NoReferencingAllowed |
-  NoConstraint |
-  Restricted
-;
+export type ReferenceConstraintVariant = NoReferencingAllowed | NoConstraint | Restricted
 
 export type ReferenceConstraintValue = {
-    [typeName: string]: ReferenceConstraintVariant;
-};
+  [typeName: string]: ReferenceConstraintVariant
+}
 
 export class ReferenceConstraint extends Enum {
-  constructor (value?: ReferenceConstraintValue, index?: number) {
-    super({
-      NoReferencingAllowed,
-      NoConstraint,
-      Restricted,
-    }, value, index);
+  constructor(value?: ReferenceConstraintValue, index?: number) {
+    super(
+      {
+        NoReferencingAllowed,
+        NoConstraint,
+        Restricted,
+      },
+      value,
+      index
+    )
   }
 
-  static NoReferencingAllowed () : ReferenceConstraint {
-    return new ReferenceConstraint({'NoReferencingAllowed': new NoReferencingAllowed()});
+  static NoReferencingAllowed(): ReferenceConstraint {
+    return new ReferenceConstraint({ NoReferencingAllowed: new NoReferencingAllowed() })
   }
 
-  static NoConstraint () : ReferenceConstraint {
-    return new ReferenceConstraint({'NoConstraint': new NoConstraint()});
+  static NoConstraint(): ReferenceConstraint {
+    return new ReferenceConstraint({ NoConstraint: new NoConstraint() })
   }
 
-  static Restricted (restrictions: Vec<PropertyOfClass>) : ReferenceConstraint {
-    return new ReferenceConstraint({'Restricted': new Restricted(restrictions)});
+  static Restricted(restrictions: Vec<PropertyOfClass>): ReferenceConstraint {
+    return new ReferenceConstraint({ Restricted: new Restricted(restrictions) })
   }
-}
+}

+ 158 - 139
types/src/working-group/index.ts

@@ -1,166 +1,177 @@
-import { getTypeRegistry, Bytes, BTreeMap, Option} from '@polkadot/types';
-import { u16, Null } from '@polkadot/types/primitive';
-import { AccountId, BlockNumber, Balance } from '@polkadot/types/interfaces';
-import { BTreeSet, JoyStruct } from '../common';
-import { MemberId, ActorId } from '../members';
-import { RewardRelationshipId } from '../recurring-rewards';
-import { StakeId } from '../stake';
-import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring';
-import { JoyEnum } from '../JoyEnum';
-
-export class RationaleText extends Bytes { };
+import { getTypeRegistry, Bytes, BTreeMap, Option } from '@polkadot/types'
+import { u16, Null } from '@polkadot/types/primitive'
+import { AccountId, BlockNumber, Balance } from '@polkadot/types/interfaces'
+import { BTreeSet, JoyStruct } from '../common'
+import { MemberId, ActorId } from '../members'
+import { RewardRelationshipId } from '../recurring-rewards'
+import { StakeId } from '../stake'
+import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring'
+import { JoyEnum } from '../JoyEnum'
+
+export class RationaleText extends Bytes {}
 
 export type IApplication = {
-  role_account_id: AccountId,
-  opening_id: OpeningId,
-  member_id: MemberId,
+  role_account_id: AccountId
+  opening_id: OpeningId
+  member_id: MemberId
   application_id: ApplicationId
-};
+}
 
 // This type is also defined in /hiring (and those are incosistent), but here
 // it is beeing registered as "ApplicationOf" (which is an alias used by the runtime working-group module),
 // so it shouldn't cause any conflicts
 export class Application extends JoyStruct<IApplication> {
-  constructor (value?: IApplication) {
-    super({
-      role_account_id: "AccountId",
-      opening_id: OpeningId,
-      member_id: MemberId,
-      application_id: ApplicationId
-    }, value);
+  constructor(value?: IApplication) {
+    super(
+      {
+        role_account_id: 'AccountId',
+        opening_id: OpeningId,
+        member_id: MemberId,
+        application_id: ApplicationId,
+      },
+      value
+    )
   }
 
   get role_account_id(): AccountId {
-    return this.getField<AccountId>('role_account_id');
+    return this.getField<AccountId>('role_account_id')
   }
 
   get opening_id(): OpeningId {
-    return this.getField<OpeningId>('opening_id');
+    return this.getField<OpeningId>('opening_id')
   }
 
   get member_id(): MemberId {
-    return this.getField<MemberId>('member_id');
+    return this.getField<MemberId>('member_id')
   }
 
   get application_id(): ApplicationId {
-    return this.getField<ApplicationId>('application_id');
+    return this.getField<ApplicationId>('application_id')
   }
 }
 
-export class WorkerId extends ActorId { };
-
-export class StorageProviderId extends WorkerId { };
+export class WorkerId extends ActorId {}
 
-export class ApplicationIdSet extends BTreeSet.with(ApplicationId) { };
+export class StorageProviderId extends WorkerId {}
 
-export class ApplicationIdToWorkerIdMap extends BTreeMap.with(ApplicationId, WorkerId) { };
+export class ApplicationIdSet extends BTreeSet.with(ApplicationId) {}
 
+export class ApplicationIdToWorkerIdMap extends BTreeMap.with(ApplicationId, WorkerId) {}
 
 export type IRoleStakeProfile = {
-  stake_id: StakeId,
-  termination_unstaking_period: Option<BlockNumber>,
-  exit_unstaking_period: Option<BlockNumber>,
-};
+  stake_id: StakeId
+  termination_unstaking_period: Option<BlockNumber>
+  exit_unstaking_period: Option<BlockNumber>
+}
 
 export class RoleStakeProfile extends JoyStruct<IRoleStakeProfile> {
-  constructor (value?: IRoleStakeProfile) {
-    super({
-      stake_id: StakeId,
-      termination_unstaking_period: "Option<BlockNumber>",
-      exit_unstaking_period: "Option<BlockNumber>"
-    }, value);
+  constructor(value?: IRoleStakeProfile) {
+    super(
+      {
+        stake_id: StakeId,
+        termination_unstaking_period: 'Option<BlockNumber>',
+        exit_unstaking_period: 'Option<BlockNumber>',
+      },
+      value
+    )
   }
 
   get stake_id(): StakeId {
-    return this.getField<StakeId>('stake_id');
+    return this.getField<StakeId>('stake_id')
   }
 
   get termination_unstaking_period(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('termination_unstaking_period');
+    return this.getField<Option<BlockNumber>>('termination_unstaking_period')
   }
 
   get exit_unstaking_period(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('exit_unstaking_period');
+    return this.getField<Option<BlockNumber>>('exit_unstaking_period')
   }
 }
 
 export type IWorker = {
-  member_id: MemberId,
-  role_account_id: AccountId,
-  reward_relationship: Option<RewardRelationshipId>,
-  role_stake_profile: Option<RoleStakeProfile>,
+  member_id: MemberId
+  role_account_id: AccountId
+  reward_relationship: Option<RewardRelationshipId>
+  role_stake_profile: Option<RoleStakeProfile>
 }
 
 export class Worker extends JoyStruct<IWorker> {
-  constructor (value?: IWorker) {
-    super({
-      member_id: MemberId,
-      role_account_id: "AccountId",
-      reward_relationship: Option.with(RewardRelationshipId),
-      role_stake_profile: Option.with(RoleStakeProfile),
-    }, value);
+  constructor(value?: IWorker) {
+    super(
+      {
+        member_id: MemberId,
+        role_account_id: 'AccountId',
+        reward_relationship: Option.with(RewardRelationshipId),
+        role_stake_profile: Option.with(RoleStakeProfile),
+      },
+      value
+    )
   }
 
   get member_id(): MemberId {
-    return this.getField<MemberId>('member_id');
+    return this.getField<MemberId>('member_id')
   }
 
   get role_account_id(): AccountId {
-    return this.getField<AccountId>('role_account_id');
+    return this.getField<AccountId>('role_account_id')
   }
 
   get reward_relationship(): Option<RewardRelationshipId> {
-    return this.getField<Option<RewardRelationshipId>>('reward_relationship');
+    return this.getField<Option<RewardRelationshipId>>('reward_relationship')
   }
 
   get role_stake_profile(): Option<RoleStakeProfile> {
-    return this.getField<Option<RoleStakeProfile>>('role_stake_profile');
+    return this.getField<Option<RoleStakeProfile>>('role_stake_profile')
   }
 
   get is_active(): boolean {
-    return !this.isEmpty;
+    return !this.isEmpty
   }
 }
 
 export type ISlashableTerms = {
-  max_count: u16,
-  max_percent_pts_per_time: u16,
-};
+  max_count: u16
+  max_percent_pts_per_time: u16
+}
 
 // This type is also defined in /content-working-group, but currently both those definitions are identical
 // (I added this defininition here too, because techinicaly those are 2 different types in the runtime.
 // Later the definition in /content-working-group will be removed and we can just register this type here)
 export class SlashableTerms extends JoyStruct<ISlashableTerms> {
-  constructor (value?: ISlashableTerms) {
-    super({
-      max_count: u16,
-      max_percent_pts_per_time: u16,
-    }, value);
+  constructor(value?: ISlashableTerms) {
+    super(
+      {
+        max_count: u16,
+        max_percent_pts_per_time: u16,
+      },
+      value
+    )
   }
-};
+}
 
-export class UnslashableTerms extends Null { };
+export class UnslashableTerms extends Null {}
 
 // This type is also defined in /content-working-group (as above)
 export class SlashingTerms extends JoyEnum({
   Unslashable: UnslashableTerms,
-  Slashable: SlashableTerms
-} as const) { };
+  Slashable: SlashableTerms,
+} as const) {}
 
 export type IWorkingGroupOpeningPolicyCommitment = {
-  application_rationing_policy: Option<ApplicationRationingPolicy>,
-  max_review_period_length: BlockNumber,
-  application_staking_policy: Option<StakingPolicy>,
-  role_staking_policy: Option<StakingPolicy>,
-  role_slashing_terms: SlashingTerms,
-  fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>,
-  fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>,
-  fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>,
-  terminate_application_stake_unstaking_period: Option<BlockNumber>,
-  terminate_role_stake_unstaking_period: Option<BlockNumber>,
-  exit_role_application_stake_unstaking_period: Option<BlockNumber>,
-  exit_role_stake_unstaking_period: Option<BlockNumber>,
-};
+  application_rationing_policy: Option<ApplicationRationingPolicy>
+  max_review_period_length: BlockNumber
+  application_staking_policy: Option<StakingPolicy>
+  role_staking_policy: Option<StakingPolicy>
+  role_slashing_terms: SlashingTerms
+  fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>
+  fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>
+  fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>
+  terminate_application_stake_unstaking_period: Option<BlockNumber>
+  terminate_role_stake_unstaking_period: Option<BlockNumber>
+  exit_role_application_stake_unstaking_period: Option<BlockNumber>
+  exit_role_stake_unstaking_period: Option<BlockNumber>
+}
 
 // This type represents OpeningPolicyCommitment defined inside the runtime's working-grpup module.
 // The only difference between this and the one defined in /content-working-group is in the names of some fields.
@@ -174,21 +185,24 @@ export type IWorkingGroupOpeningPolicyCommitment = {
 // very fragile atm and any change to this type in working-group module could result in "unsolvable" inconsistencies
 // (this won't be an issue after CWG gets refactored to use the working-grpup module too)
 export class WorkingGroupOpeningPolicyCommitment extends JoyStruct<IWorkingGroupOpeningPolicyCommitment> {
-  constructor (value?: WorkingGroupOpeningPolicyCommitment) {
-    super({
-      application_rationing_policy: Option.with(ApplicationRationingPolicy),
-      max_review_period_length: "BlockNumber",
-      application_staking_policy: Option.with(StakingPolicy),
-      role_staking_policy: Option.with(StakingPolicy),
-      role_slashing_terms: SlashingTerms,
-      fill_opening_successful_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
-      fill_opening_failed_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
-      fill_opening_failed_applicant_role_stake_unstaking_period: "Option<BlockNumber>",
-      terminate_application_stake_unstaking_period: "Option<BlockNumber>",
-      terminate_role_stake_unstaking_period: "Option<BlockNumber>",
-      exit_role_application_stake_unstaking_period: "Option<BlockNumber>",
-      exit_role_stake_unstaking_period: "Option<BlockNumber>",
-    }, value);
+  constructor(value?: WorkingGroupOpeningPolicyCommitment) {
+    super(
+      {
+        application_rationing_policy: Option.with(ApplicationRationingPolicy),
+        max_review_period_length: 'BlockNumber',
+        application_staking_policy: Option.with(StakingPolicy),
+        role_staking_policy: Option.with(StakingPolicy),
+        role_slashing_terms: SlashingTerms,
+        fill_opening_successful_applicant_application_stake_unstaking_period: 'Option<BlockNumber>',
+        fill_opening_failed_applicant_application_stake_unstaking_period: 'Option<BlockNumber>',
+        fill_opening_failed_applicant_role_stake_unstaking_period: 'Option<BlockNumber>',
+        terminate_application_stake_unstaking_period: 'Option<BlockNumber>',
+        terminate_role_stake_unstaking_period: 'Option<BlockNumber>',
+        exit_role_application_stake_unstaking_period: 'Option<BlockNumber>',
+        exit_role_stake_unstaking_period: 'Option<BlockNumber>',
+      },
+      value
+    )
   }
 
   get application_rationing_policy(): Option<ApplicationRationingPolicy> {
@@ -238,22 +252,21 @@ export class WorkingGroupOpeningPolicyCommitment extends JoyStruct<IWorkingGroup
   get exit_role_stake_unstaking_period(): Option<BlockNumber> {
     return this.getField<Option<BlockNumber>>('exit_role_stake_unstaking_period')
   }
-};
-
+}
 
-export class OpeningType_Leader extends Null { };
-export class OpeningType_Worker extends Null { };
+export class OpeningType_Leader extends Null {}
+export class OpeningType_Worker extends Null {}
 export const OpeningTypeDef = {
   Leader: OpeningType_Leader,
-  Worker: OpeningType_Worker
-} as const;
-export type OpeningTypeKey = keyof typeof OpeningTypeDef;
-export class OpeningType extends JoyEnum(OpeningTypeDef) { };
+  Worker: OpeningType_Worker,
+} as const
+export type OpeningTypeKey = keyof typeof OpeningTypeDef
+export class OpeningType extends JoyEnum(OpeningTypeDef) {}
 
 export type IOpening = {
-  hiring_opening_id: OpeningId,
-  applications: BTreeSet<ApplicationId>,
-  policy_commitment: WorkingGroupOpeningPolicyCommitment,
+  hiring_opening_id: OpeningId
+  applications: BTreeSet<ApplicationId>
+  policy_commitment: WorkingGroupOpeningPolicyCommitment
   opening_type: OpeningType
 }
 
@@ -261,57 +274,63 @@ export type IOpening = {
 // it is beeing registered as "OpeningOf" (which is an alias used by the runtime working-group module),
 // so it shouldn't cause any conflicts
 export class Opening extends JoyStruct<IOpening> {
-  constructor (value?: IWorker) {
-    super({
-      hiring_opening_id: OpeningId,
-      applications: BTreeSet.with(ApplicationId),
-      policy_commitment: WorkingGroupOpeningPolicyCommitment,
-      opening_type: OpeningType
-    }, value);
+  constructor(value?: IWorker) {
+    super(
+      {
+        hiring_opening_id: OpeningId,
+        applications: BTreeSet.with(ApplicationId),
+        policy_commitment: WorkingGroupOpeningPolicyCommitment,
+        opening_type: OpeningType,
+      },
+      value
+    )
   }
 
   get hiring_opening_id(): OpeningId {
-    return this.getField<OpeningId>('hiring_opening_id');
+    return this.getField<OpeningId>('hiring_opening_id')
   }
 
   get applications(): BTreeSet<ApplicationId> {
-    return this.getField<BTreeSet<ApplicationId>>('applications');
+    return this.getField<BTreeSet<ApplicationId>>('applications')
   }
 
   get policy_commitment(): WorkingGroupOpeningPolicyCommitment {
-    return this.getField<WorkingGroupOpeningPolicyCommitment>('policy_commitment');
+    return this.getField<WorkingGroupOpeningPolicyCommitment>('policy_commitment')
   }
 
   get opening_type(): OpeningType {
-    return this.getField<OpeningType>('opening_type');
+    return this.getField<OpeningType>('opening_type')
   }
 }
 
 // Also defined in "content-working-group" runtime module, but those definitions are the consistent
 export type IRewardPolicy = {
-  amount_per_payout: Balance,
-  next_payment_at_block: BlockNumber,
-  payout_interval: Option<BlockNumber>,
-};
+  amount_per_payout: Balance
+  next_payment_at_block: BlockNumber
+  payout_interval: Option<BlockNumber>
+}
 
 export class RewardPolicy extends JoyStruct<IRewardPolicy> {
-  constructor (value?: IRewardPolicy) {
-    super({
-      amount_per_payout: 'Balance',
-      next_payment_at_block: 'BlockNumber',
-      payout_interval: 'Option<BlockNumber>',
-    }, value);
+  constructor(value?: IRewardPolicy) {
+    super(
+      {
+        amount_per_payout: 'Balance',
+        next_payment_at_block: 'BlockNumber',
+        payout_interval: 'Option<BlockNumber>',
+      },
+      value
+    )
   }
   get amount_per_payout(): Balance {
-    return this.getField<Balance>('amount_per_payout');
+    return this.getField<Balance>('amount_per_payout')
   }
   get next_payment_at_block(): BlockNumber {
-    return this.getField<BlockNumber>('next_payment_at_block');
+    return this.getField<BlockNumber>('next_payment_at_block')
   }
   get payout_interval(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('payout_interval');
+    return this.getField<Option<BlockNumber>>('payout_interval')
   }
-};
+}
 
 export function registerWorkingGroupTypes() {
   try {
@@ -329,9 +348,9 @@ export function registerWorkingGroupTypes() {
       HiringApplicationId: ApplicationId,
       RewardPolicy,
       'working_group::OpeningId': OpeningId,
-      'working_group::WorkerId': WorkerId
-    });
+      'working_group::WorkerId': WorkerId,
+    })
   } catch (err) {
-    console.error('Failed to register custom types of working-group module', err);
+    console.error('Failed to register custom types of working-group module', err)
   }
 }