Browse Source

types: refactor fixing circular dependencies

Mokhtar Naamani 4 years ago
parent
commit
1365864318

+ 2 - 3
types/src/bureaucracy/index.ts

@@ -1,12 +1,11 @@
 import { getTypeRegistry, Bytes, BTreeMap, Option, Enum } from '@polkadot/types';
 import { u16, Null } from '@polkadot/types/primitive';
 import { AccountId, BlockNumber } from '@polkadot/types/interfaces';
+import { BTreeSet, JoyStruct } from '../common';
 import { MemberId, ActorId } from '../members';
-import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring';
 import { RewardRelationshipId } from '../recurring-rewards';
 import { StakeId } from '../stake';
-import { JoyStruct } from '../JoyStruct';
-import { BTreeSet } from '../';
+import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring';
 
 export type ILead = {
   member_id: MemberId,

+ 98 - 0
types/src/common.ts

@@ -0,0 +1,98 @@
+import { Struct, Option, Text, bool, Vec, u16, u32, u64, getTypeRegistry } from "@polkadot/types";
+import { BlockNumber, Moment } from '@polkadot/types/interfaces';
+import { Codec } from "@polkadot/types/types";
+import { JoyStruct } from './JoyStruct';
+export { JoyStruct } from './JoyStruct';
+
+// Treat a BTreeSet as a Vec since it is encoded in the same way
+export class BTreeSet<T extends Codec> extends Vec<T> {}
+
+// common types between Forum and Proposal Discussions modules
+export class ThreadId extends u64 {}
+export class PostId extends u64 {}
+
+export type BlockAndTimeType = {
+    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;
+    }
+
+    get time (): Moment {
+        return this.get('time') as Moment;
+    }
+
+    static newEmpty (): BlockAndTime {
+        return new BlockAndTime({} as BlockAndTime);
+    }
+}
+
+export function getTextPropAsString(struct: Struct, fieldName: string): string {
+    return (struct.get(fieldName) as Text).toString();
+}
+
+export function getBoolPropAsBoolean(struct: Struct, fieldName: string): boolean {
+    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);
+}
+
+export class OptionText extends Option.with(Text) {
+    static none(): OptionText {
+        return new Option(Text, null);
+    }
+
+    static some(text: string): OptionText {
+        return new Option(Text, text);
+    }
+}
+
+export type InputValidationLengthConstraintType = {
+    min: u16,
+    max_min_diff: u16
+};
+
+export class InputValidationLengthConstraint extends JoyStruct<InputValidationLengthConstraintType> {
+    constructor (value: InputValidationLengthConstraintType) {
+      super({
+        min: u16,
+        max_min_diff: u16
+      }, value);
+    }
+
+    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 function registerCommonTypes() {
+    const typeRegistry = getTypeRegistry();
+
+    typeRegistry.register({
+      BlockAndTime,
+      ThreadId,
+      PostId,
+      InputValidationLengthConstraint,
+      BTreeSet // Is this even necessary?
+    });
+}

+ 2 - 3
types/src/content-working-group/index.ts

@@ -1,12 +1,11 @@
 import { getTypeRegistry, BTreeMap, Enum, bool, u8, u32, u128, Text, GenericAccountId, Null , Option, Vec, u16 } from '@polkadot/types';
 import { BlockNumber, AccountId, Balance } from '@polkadot/types/interfaces';
+import { BTreeSet, JoyStruct } from '../common';
 import { ActorId, MemberId } from '../members';
+import { StakeId } from '../stake';
 import { OpeningId, ApplicationId, ApplicationRationingPolicy, StakingPolicy } from '../hiring/index';
 import { Credential } from '../versioned-store/permissions/credentials';
 import { RewardRelationshipId } from '../recurring-rewards';
-import { StakeId } from '../stake';
-import { JoyStruct } from '../JoyStruct';
-import { BTreeSet } from '../';
 
 export class ChannelId extends ActorId {};
 export class CuratorId extends ActorId {};

+ 200 - 0
types/src/council/index.ts

@@ -0,0 +1,200 @@
+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;
+};
+
+export type Stake = {
+    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;
+    }
+}
+
+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;
+    }
+}
+
+export class Seats extends Vec.with(Seat) {}
+
+export type SealedVote = {
+    voter: AccountId;
+    commitment: Hash;
+    stake: Stake;
+    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 });
+    }
+}
+
+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;
+};
+
+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;
+    }
+}
+
+
+// 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);
+    }
+}

+ 2 - 36
types/src/forum.ts

@@ -1,9 +1,7 @@
-import { getTypeRegistry, bool, u16, u32, u64, Text, Option, Vec as Vector} from '@polkadot/types';
+import { getTypeRegistry, bool, u32, u64, Text, Option, Vec as Vector} from '@polkadot/types';
 import { AccountId } from '@polkadot/types/interfaces';
 import { GenericAccountId } from '@polkadot/types';
-import { BlockAndTime } from './media';
-
-import { JoyStruct } from './JoyStruct';
+import { BlockAndTime, JoyStruct, ThreadId, PostId } from './common';
 
 export type ModerationActionType = {
   moderated_at: BlockAndTime,
@@ -63,42 +61,13 @@ export class CategoryId extends u64 {}
 export class OptionCategoryId extends Option.with(CategoryId) {}
 export class VecCategoryId extends Vector.with(CategoryId) {}
 
-export class ThreadId extends u64 {}
 export class VecThreadId extends Vector.with(ThreadId) {}
-
-export class PostId extends u64 {}
 export class VecPostId extends Vector.with(PostId) {}
 
 // TODO deprectated: replaced w/ PostId
 export class ReplyId extends u64 {}
 export class VecReplyId extends Vector.with(ReplyId) {}
 
-export type InputValidationLengthConstraintType = {
-  min: u16,
-  max_min_diff: u16
-};
-
-export class InputValidationLengthConstraint extends JoyStruct<InputValidationLengthConstraintType> {
-  constructor (value: InputValidationLengthConstraintType) {
-    super({
-      min: u16,
-      max_min_diff: u16
-    }, value);
-  }
-
-  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 type ChildPositionInParentCategoryType = {
   parent_id: CategoryId,
   child_nr_in_parent_category: u32
@@ -416,13 +385,10 @@ export function registerForumTypes () {
     getTypeRegistry().register({
       PostTextChange,
       ModerationAction,
-      InputValidationLengthConstraint,
       ChildPositionInParentCategory,
       CategoryId,
       Category,
-      ThreadId,
       Thread,
-      PostId,
       Post,
       ReplyId,
       Reply

+ 1 - 1
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 } from '../common';
 import { StakeId } from '../stake';
-import { JoyStruct } from '../JoyStruct';
 
 import { GenericJoyStreamRoleSchema } from './schemas/role.schema.typings'
 

+ 24 - 209
types/src/index.ts

@@ -1,229 +1,44 @@
-import { Enum, Option, Struct, Vec } from "@polkadot/types/codec";
-import { getTypeRegistry, Text } from "@polkadot/types";
-import { BlockNumber, AccountId, Balance, Hash } from "@polkadot/types/interfaces";
-import { u32, bool } from "@polkadot/types/primitive";
-import { Codec } from "@polkadot/types/types";
 
-import { registerForumTypes } from "./forum";
-import { registerMediaTypes } from "./media";
+import { getTypeRegistry } from "@polkadot/types";
+
+import { registerCommonTypes } from "./common";
 import { registerMembershipTypes } from "./members";
+import { registerCouncilAndElectionTypes } from "./council";
 import { registerRolesTypes } from "./roles";
-import { registerDiscoveryTypes } from "./discovery";
-import { registerHiringTypes } from "./hiring";
-import { registerVersionedStoreTypes } from "./versioned-store";
-import { registerVersionedStorePermissionsTypes } from "./versioned-store/permissions";
+import { registerForumTypes } from "./forum";
 import { registerStakeTypes } from "./stake";
 import { registerMintTypes } from "./mint";
 import { registerRecurringRewardsTypes } from "./recurring-rewards";
+import { registerHiringTypes } from "./hiring";
+import { registerVersionedStoreTypes } from "./versioned-store";
+import { registerVersionedStorePermissionsTypes } from "./versioned-store/permissions";
 import { registerContentWorkingGroupTypes } from "./content-working-group";
-import { registerProposalTypes, ProposalStatus } from "./proposals";
-
-export function getTextPropAsString(struct: Struct, fieldName: string): string {
-  return (struct.get(fieldName) as Text).toString();
-}
-
-export function getBoolPropAsBoolean(struct: Struct, fieldName: string): boolean {
-  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);
-}
-
-export class OptionText extends Option.with(Text) {
-  static none(): OptionText {
-    return new Option(Text, null);
-  }
-
-  static some(text: string): OptionText {
-    return new Option(Text, text);
-  }
-}
-
-export type TransferableStake = {
-  seat: Balance;
-  backing: Balance;
-};
-
-export type Stake = {
-  new: Balance;
-  transferred: Balance;
-};
-
-export type Backer = {
-  member: AccountId;
-  stake: Balance;
-};
-
-export type Seat = {
-  member: AccountId;
-  stake: Balance;
-  backers: Backer[];
-};
-
-export type SealedVote = {
-  voter: AccountId;
-  commitment: Hash;
-  stake: Stake;
-  vote: Option<AccountId>;
-};
-
-export type ProposalVote = {
-  voter: AccountId;
-  kind: VoteKind;
-};
-
-export type TallyResult = {
-  proposal_id: u32;
-  abstentions: u32;
-  approvals: u32;
-  rejections: u32;
-  slashes: u32;
-  status: ProposalStatus;
-  finalized_at: BlockNumber;
-};
-
-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 });
-  }
-}
-
-export type AnyElectionStage = Announcing | Voting | Revealing;
-
-export const VoteKinds: { [key: string]: string } = {
-  Abstain: "Abstain",
-  Approve: "Approve",
-  Reject: "Reject",
-  Slash: "Slash"
-};
-
-export class VoteKind extends Enum {
-  constructor(value?: any) {
-    super(["Abstain", "Approve", "Reject", "Slash"], value);
-  }
-}
-
-export type ProposalVotes = [AccountId, VoteKind][];
-
-// Treat a BTreeSet as a Vec since it is encoded in the same way.
-export class BTreeSet<T extends Codec> extends Vec<T> {}
+import { registerBureaucracyTypes } from "./bureaucracy";
+import { registerDiscoveryTypes } from "./discovery";
+import { registerMediaTypes } from "./media";
+import { registerProposalTypes } from "./proposals";
 
-// TODO Refactor: split this function and move to corresponding modules: election and proposals.
-function registerElectionAndProposalTypes() {
-  try {
-    const typeRegistry = getTypeRegistry();
-    // Is this enough?
-    typeRegistry.register({
-      BTreeSet
-    });
+export function registerJoystreamTypes() {
+  const typeRegistry = getTypeRegistry();
 
-    typeRegistry.register({
-      MemoText: "Text"
-    });
-    // Register parametrized enum ElectionStage:
-    typeRegistry.register({
-      ElectionStage
-    });
-    typeRegistry.register({
-      ProposalStatus,
-      VoteKind
-    });
-    typeRegistry.register({
-      ElectionStake: {
-        new: "Balance",
-        transferred: "Balance"
-      },
-      SealedVote: {
-        voter: "AccountId",
-        commitment: "Hash",
-        stake: "ElectionStake",
-        vote: "Option<AccountId>"
-      },
-      TransferableStake: {
-        seat: "Balance",
-        backing: "Balance"
-      },
-      RuntimeUpgradeProposal: {
-        id: "u32",
-        proposer: "AccountId",
-        stake: "Balance",
-        name: "Text",
-        description: "Text",
-        wasm_hash: "Hash",
-        proposed_at: "BlockNumber",
-        status: "ProposalStatus"
-      },
-      "TallyResult<BlockNumber>": {
-        proposal_id: "u32",
-        abstentions: "u32",
-        approvals: "u32",
-        rejections: "u32",
-        slashes: "u32",
-        status: "ProposalStatus",
-        finalized_at: "BlockNumber"
-      },
-      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"
-      }
-    });
-  } catch (err) {
-    console.error("Failed to register custom types of Joystream node", err);
-  }
-}
+  typeRegistry.register({
+    MemoText: "Text", // for the memo module
+  });
 
-export function registerJoystreamTypes() {
+  registerCommonTypes();
   registerMembershipTypes();
+  registerCouncilAndElectionTypes();
   registerRolesTypes();
-  registerMediaTypes();
   registerForumTypes();
-  registerElectionAndProposalTypes();
-  registerDiscoveryTypes();
-  registerVersionedStoreTypes();
-  registerVersionedStorePermissionsTypes();
   registerStakeTypes();
   registerMintTypes();
   registerRecurringRewardsTypes();
   registerHiringTypes();
+  registerVersionedStoreTypes();
+  registerVersionedStorePermissionsTypes();
   registerContentWorkingGroupTypes();
+  registerBureaucracyTypes();
+  registerDiscoveryTypes();
+  registerMediaTypes();
   registerProposalTypes();
-  require("./bureaucracy").registerBureaucracyTypes();
 }

+ 3 - 29
types/src/media.ts

@@ -1,8 +1,8 @@
 import { Enum, Struct, Option, Vec as Vector, H256 } from '@polkadot/types';
-import { getTypeRegistry, u32, u64, bool, Text } from '@polkadot/types';
-import { BlockNumber, Moment } from '@polkadot/types/interfaces';
-import { StorageProviderId } from './bureaucracy';
+import { getTypeRegistry, u64, bool, Text } from '@polkadot/types';
+import { BlockAndTime } from './common';
 import { MemberId } from './members';
+import { StorageProviderId } from './bureaucracy'; // this should be in discovery really
 
 import { randomAsU8a } from '@polkadot/util-crypto';
 import { encodeAddress, decodeAddress } from '@polkadot/keyring';
@@ -31,32 +31,6 @@ export class ContentId extends H256 {
 export class DataObjectTypeId extends u64 {}
 export class DataObjectStorageRelationshipId extends u64 {}
 
-export type BlockAndTimeType = {
-  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;
-  }
-
-  get time (): Moment {
-    return this.get('time') as Moment;
-  }
-
-  static newEmpty (): BlockAndTime {
-    return new BlockAndTime({} as BlockAndTime);
-  }
-}
-
 export class VecContentId extends Vector.with(ContentId) {}
 export class OptionVecContentId extends Option.with(VecContentId) {}
 export type LiaisonJudgementKey = 'Pending' | 'Accepted' | 'Rejected';

+ 1 - 2
types/src/members.ts

@@ -13,9 +13,8 @@ import {
   Vec,
 } from "@polkadot/types";
 import { BlockNumber, Moment, BalanceOf } from "@polkadot/types/interfaces";
-import { OptionText } from "./index";
+import { OptionText, JoyStruct } from "./common";
 import AccountId from "@polkadot/types/primitive/Generic/AccountId";
-import { JoyStruct } from "./JoyStruct";
 
 export class MemberId extends u64 {}
 export class PaidTermId extends u64 {}

+ 1 - 1
types/src/mint/index.ts

@@ -1,6 +1,6 @@
 import { getTypeRegistry, u32, u64, u128, Option, Enum} from '@polkadot/types';
 import { Balance, BlockNumber } from '@polkadot/types/interfaces';
-import { JoyStruct } from '../JoyStruct';
+import { JoyStruct } from '../common';
 
 export class MintId extends u64 {};
 

+ 4 - 110
types/src/proposals.ts

@@ -1,12 +1,11 @@
 import { Text, u32, Enum, getTypeRegistry, Tuple, GenericAccountId, u8, Vec, Option, Struct, Null, Bytes } from "@polkadot/types";
 import { BlockNumber, Balance } from "@polkadot/types/interfaces";
-import { MemberId } from "./members";
-import { ThreadId } from "./forum";
-import { StakeId } from "./stake";
 import AccountId from "@polkadot/types/primitive/Generic/AccountId";
-import { JoyStruct } from "./JoyStruct";
-
+import { ThreadId, JoyStruct } from "./common";
+import { MemberId } from "./members";
 import { RoleParameters } from "./roles";
+import { StakeId } from "./stake";
+import { ElectionParameters } from "./council";
 
 export type IVotingResults = {
   abstensions: u32;
@@ -259,59 +258,6 @@ export type ProposalVotes = [MemberId, VoteKind][];
 
 export class ProposalId extends u32 {}
 
-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;
-};
-
-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;
-  }
-}
-
 export class SpendingParams extends Tuple {
   constructor(value?: any) {
     super(["Balance", "AccountId"], value);
@@ -404,54 +350,6 @@ export class Proposal extends Struct {
   }
 }
 
-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;
-  }
-}
-
-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;
-  }
-}
-
-export class Seats extends Vec.with(Seat) {}
-
 export class ThreadCounter extends Struct {
   constructor(value?: any) {
     super(
@@ -553,10 +451,6 @@ export function registerProposalTypes() {
       VotingResults,
       ProposalParameters,
       VoteKind,
-      Seat,
-      Seats,
-      Backer,
-      Backers,
       ThreadCounter,
       DiscussionThread,
       DiscussionPost

+ 1 - 1
types/src/recurring-rewards/index.ts

@@ -1,6 +1,6 @@
 import { getTypeRegistry, u32, u64, u128, Option, GenericAccountId } from '@polkadot/types';
 import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
-import { JoyStruct } from '../JoyStruct';
+import { JoyStruct } from '../common';
 import { MintId } from '../mint';
 
 export class RecipientId extends u64 {};

+ 0 - 3
types/src/roles.ts

@@ -3,9 +3,6 @@ import { getTypeRegistry, u32, u128, GenericAccountId } from '@polkadot/types';
 import { BlockNumber, AccountId, Balance } from '@polkadot/types/interfaces';
 import { MemberId, Role } from './members';
 
-// re-export Role
-export { Role } from './members';
-
 export class Actor extends Struct {
   constructor (value?: any) {
     super({

+ 1 - 1
types/src/stake/index.ts

@@ -1,5 +1,5 @@
 import { getTypeRegistry, u32, u64, u128, Enum, Null, BTreeMap, bool } from '@polkadot/types';
-import { JoyStruct } from '../JoyStruct';
+import { JoyStruct } from '../common';
 import { BlockNumber, Balance } from '@polkadot/types/interfaces';
 
 export class StakeId extends u64 {};

+ 1 - 1
yarn.lock

@@ -1356,7 +1356,7 @@
     minimist "^1.2.0"
 
 "@constantinople/types@./types", "@joystream/types@./types":
-  version "0.10.0"
+  version "0.11.0"
   dependencies:
     "@polkadot/types" "^0.96.1"
     "@types/vfile" "^4.0.0"