ソースを参照

Merge pull request #687 from mnaamani/pioneer-media-app-fixes

Pioneer media app fixes and types updates
Mokhtar Naamani 4 年 前
コミット
4eb10c322d
72 ファイル変更467 行追加602 行削除
  1. 1 1
      cli/package.json
  2. 1 1
      cli/src/Types.ts
  3. 1 1
      cli/src/commands/council/info.ts
  4. 1 1
      pioneer/package.json
  5. 1 1
      pioneer/packages/apps/src/SideBar/Item.tsx
  6. 1 1
      pioneer/packages/joy-election/src/Applicant.tsx
  7. 1 1
      pioneer/packages/joy-election/src/ApplyForm.tsx
  8. 1 1
      pioneer/packages/joy-election/src/Council.tsx
  9. 1 1
      pioneer/packages/joy-election/src/Dashboard.tsx
  10. 1 1
      pioneer/packages/joy-election/src/SealedVote.tsx
  11. 1 1
      pioneer/packages/joy-election/src/index.tsx
  12. 2 1
      pioneer/packages/joy-forum/src/CategoryList.tsx
  13. 1 1
      pioneer/packages/joy-forum/src/Context.tsx
  14. 2 1
      pioneer/packages/joy-forum/src/EditReply.tsx
  15. 2 1
      pioneer/packages/joy-forum/src/EditThread.tsx
  16. 2 1
      pioneer/packages/joy-forum/src/Moderate.tsx
  17. 2 1
      pioneer/packages/joy-forum/src/ViewThread.tsx
  18. 2 1
      pioneer/packages/joy-forum/src/utils.tsx
  19. 1 1
      pioneer/packages/joy-forum/src/validation.tsx
  20. 5 5
      pioneer/packages/joy-media/src/DiscoveryProvider.tsx
  21. 4 4
      pioneer/packages/joy-media/src/Upload.tsx
  22. 24 4
      pioneer/packages/joy-media/src/common/MediaPlayerWithResolver.tsx
  23. 1 1
      pioneer/packages/joy-media/src/transport.substrate.ts
  24. 1 1
      pioneer/packages/joy-media/src/upload/UploadVideo.tsx
  25. 1 1
      pioneer/packages/joy-members/src/Details.tsx
  26. 1 1
      pioneer/packages/joy-members/src/EditForm.tsx
  27. 1 1
      pioneer/packages/joy-members/src/MemberPreview.tsx
  28. 1 1
      pioneer/packages/joy-proposals/src/Proposal/ProposalDetails.tsx
  29. 1 1
      pioneer/packages/joy-proposals/src/Proposal/discussion/DiscussionPostForm.tsx
  30. 1 1
      pioneer/packages/joy-proposals/src/forms/SetCouncilParamsForm.tsx
  31. 2 3
      pioneer/packages/joy-roles/src/transport.mock.ts
  32. 4 5
      pioneer/packages/joy-roles/src/transport.substrate.ts
  33. 1 1
      pioneer/packages/joy-roles/src/transport.ts
  34. 2 1
      pioneer/packages/joy-storage/src/AvailableRoles/index.tsx
  35. 2 1
      pioneer/packages/joy-storage/src/MyRequests/index.tsx
  36. 2 1
      pioneer/packages/joy-storage/src/index.tsx
  37. 2 1
      pioneer/packages/joy-storage/src/props.ts
  38. 1 1
      pioneer/packages/joy-utils/src/index.ts
  39. 1 1
      pioneer/packages/joy-utils/src/transport/council.ts
  40. 1 1
      pioneer/packages/joy-utils/src/transport/proposals.ts
  41. 1 1
      pioneer/packages/joy-utils/src/types/proposals.ts
  42. 1 1
      tests/network-tests/package.json
  43. 1 1
      tests/network-tests/src/constantinople/tests/impl/electingCouncil.ts
  44. 1 1
      tests/network-tests/src/constantinople/utils/apiWrapper.ts
  45. 1 1
      tests/network-tests/src/constantinople/utils/utils.ts
  46. 2 2
      types/package.json
  47. 2 3
      types/src/bureaucracy/index.ts
  48. 103 0
      types/src/common.ts
  49. 3 0
      types/src/content-working-group/ChannelId.ts
  50. 5 6
      types/src/content-working-group/index.ts
  51. 200 0
      types/src/council/index.ts
  52. 2 36
      types/src/forum.ts
  53. 1 1
      types/src/hiring/index.ts
  54. 24 209
      types/src/index.ts
  55. 13 112
      types/src/media.ts
  56. 1 2
      types/src/members.ts
  57. 1 1
      types/src/mint/index.ts
  58. 4 110
      types/src/proposals.ts
  59. 1 1
      types/src/recurring-rewards/index.ts
  60. 0 3
      types/src/roles.ts
  61. 1 1
      types/src/stake/index.ts
  62. 2 2
      types/src/versioned-store/EntityCodec.ts
  63. 3 30
      types/src/versioned-store/index.ts
  64. 2 3
      types/src/versioned-store/permissions/ClassPermissions.ts
  65. 1 1
      types/src/versioned-store/permissions/EntityPermissions.ts
  66. 2 3
      types/src/versioned-store/permissions/PropertyOfClass.ts
  67. 1 1
      types/src/versioned-store/permissions/batching/ParametrizedClassPropertyValue.ts
  68. 1 2
      types/src/versioned-store/permissions/batching/index.ts
  69. 1 1
      types/src/versioned-store/permissions/batching/operations.ts
  70. 0 4
      types/src/versioned-store/permissions/credentials.ts
  71. 0 3
      types/src/versioned-store/permissions/index.ts
  72. 2 4
      yarn.lock

+ 1 - 1
cli/package.json

@@ -8,7 +8,7 @@
   },
   "bugs": "https://github.com/Joystream/substrate-runtime-joystream/issues",
   "dependencies": {
-    "@joystream/types": "^0.10.0",
+    "@joystream/types": "./types",
     "@oclif/command": "^1.5.19",
     "@oclif/config": "^1.14.0",
     "@oclif/plugin-help": "^2.2.3",

+ 1 - 1
cli/src/Types.ts

@@ -1,5 +1,5 @@
 import BN from 'bn.js';
-import { ElectionStage, Seat } from '@joystream/types/';
+import { ElectionStage, Seat } from '@joystream/types/lib/council';
 import { Option } from '@polkadot/types';
 import { BlockNumber, Balance, AccountId } from '@polkadot/types/interfaces';
 import { DerivedBalances } from '@polkadot/api-derive/types';

+ 1 - 1
cli/src/commands/council/info.ts

@@ -1,4 +1,4 @@
-import { ElectionStage } from '@joystream/types/';
+import { ElectionStage } from '@joystream/types/lib/council';
 import { formatNumber, formatBalance } from '@polkadot/util';
 import { BlockNumber } from '@polkadot/types/interfaces';
 import { CouncilInfoObj, NameValueObj } from '../../Types';

+ 1 - 1
pioneer/package.json

@@ -82,6 +82,6 @@
     "node-sass": "^4.13.0",
     "sass-loader": "^8.0.0",
     "style-loader": "^1.0.0",
-    "@joystream/types": "^0.10.0"
+    "@joystream/types": "./types"
   }
 }

+ 1 - 1
pioneer/packages/apps/src/SideBar/Item.tsx

@@ -20,7 +20,7 @@ import { Option } from '@polkadot/types';
 import translate from '../translate';
 
 import { queryToProp } from '@polkadot/joy-utils/index';
-import { ElectionStage } from '@joystream/types/';
+import { ElectionStage } from '@joystream/types/council';
 import { councilSidebarName } from '@polkadot/apps-routing/joy-election';
 
 interface Props extends I18nProps {

+ 1 - 1
pioneer/packages/joy-election/src/Applicant.tsx

@@ -11,7 +11,7 @@ import CandidatePreview from './CandidatePreview';
 
 import translate from './translate';
 import { calcTotalStake } from '@polkadot/joy-utils/index';
-import { Stake } from '@joystream/types/';
+import { Stake } from '@joystream/types/council';
 
 type Props = ApiProps & I18nProps & {
   index: number;

+ 1 - 1
pioneer/packages/joy-election/src/ApplyForm.tsx

@@ -10,7 +10,7 @@ import { Balance } from '@polkadot/types/interfaces';
 import translate from './translate';
 import TxButton from '@polkadot/joy-utils/TxButton';
 import InputStake from '@polkadot/joy-utils/InputStake';
-import { Stake } from '@joystream/types/';
+import { Stake } from '@joystream/types/council';
 import { calcTotalStake, ZERO } from '@polkadot/joy-utils/index';
 import { MyAddressProps, withOnlyMembers } from '@polkadot/joy-utils/MyAccount';
 

+ 1 - 1
pioneer/packages/joy-election/src/Council.tsx

@@ -8,7 +8,7 @@ import { formatBalance } from '@polkadot/util';
 import CouncilCandidate from './CandidatePreview';
 
 import { calcBackersStake } from '@polkadot/joy-utils/index';
-import { Seat } from '@joystream/types/';
+import { Seat } from '@joystream/types/council';
 import translate from './translate';
 import Section from '@polkadot/joy-utils/Section';
 

+ 1 - 1
pioneer/packages/joy-election/src/Dashboard.tsx

@@ -11,7 +11,7 @@ import { formatNumber, formatBalance } from '@polkadot/util';
 
 import Section from '@polkadot/joy-utils/Section';
 import { queryToProp } from '@polkadot/joy-utils/index';
-import { ElectionStage, Seat } from '@joystream/types/';
+import { ElectionStage, Seat } from '@joystream/types/council';
 import translate from './translate';
 
 type Props = ApiProps & I18nProps & {

+ 1 - 1
pioneer/packages/joy-election/src/SealedVote.tsx

@@ -10,7 +10,7 @@ import { formatBalance } from '@polkadot/util';
 
 import translate from './translate';
 import { calcTotalStake } from '@polkadot/joy-utils/index';
-import { SealedVote } from '@joystream/types/';
+import { SealedVote } from '@joystream/types/council';
 import AddressMini from '@polkadot/react-components/AddressMiniJoy';
 import CandidatePreview from './CandidatePreview';
 import { findVoteByHash } from './myVotesStore';

+ 1 - 1
pioneer/packages/joy-election/src/index.tsx

@@ -18,7 +18,7 @@ import Applicants from './Applicants';
 import Votes from './Votes';
 import Reveals from './Reveals';
 import { queryToProp } from '@polkadot/joy-utils/index';
-import { Seat } from '@joystream/types/';
+import { Seat } from '@joystream/types/council';
 
 // define out internal types
 type Props = AppProps & ApiProps & I18nProps & {

+ 2 - 1
pioneer/packages/joy-forum/src/CategoryList.tsx

@@ -7,7 +7,8 @@ import orderBy from 'lodash/orderBy';
 import BN from 'bn.js';
 
 import { Option, bool } from '@polkadot/types';
-import { CategoryId, Category, ThreadId, Thread } from '@joystream/types/forum';
+import { ThreadId } from '@joystream/types/common';
+import { CategoryId, Category, Thread } from '@joystream/types/forum';
 import { ViewThread } from './ViewThread';
 import { MutedSpan } from '@polkadot/joy-utils/MutedText';
 import { UrlHasIdProps, CategoryCrumbs, Pagination, ThreadsPerPage } from './utils';

+ 1 - 1
pioneer/packages/joy-forum/src/Context.tsx

@@ -3,7 +3,7 @@
 
 import React, { useReducer, createContext, useContext } from 'react';
 import { Category, Thread, Reply, ModerationAction } from '@joystream/types/forum';
-import { BlockAndTime } from '@joystream/types/media';
+import { BlockAndTime } from '@joystream/types/common';
 import { Option, Text, GenericAccountId } from '@polkadot/types';
 
 type CategoryId = number;

+ 2 - 1
pioneer/packages/joy-forum/src/EditReply.tsx

@@ -10,7 +10,8 @@ import { withMulti } from '@polkadot/react-api/with';
 
 import * as JoyForms from '@polkadot/joy-utils/forms';
 import { Text } from '@polkadot/types';
-import { PostId, Post, ThreadId } from '@joystream/types/forum';
+import { PostId, ThreadId } from '@joystream/types/common';
+import { Post } from '@joystream/types/forum';
 import { withOnlyMembers } from '@polkadot/joy-utils/MyAccount';
 import Section from '@polkadot/joy-utils/Section';
 import { useMyAccount } from '@polkadot/joy-utils/MyAccountContext';

+ 2 - 1
pioneer/packages/joy-forum/src/EditThread.tsx

@@ -12,7 +12,8 @@ import { withMulti } from '@polkadot/react-api/with';
 
 import * as JoyForms from '@polkadot/joy-utils/forms';
 import { Text } from '@polkadot/types';
-import { ThreadId, Thread, CategoryId } from '@joystream/types/forum';
+import { ThreadId } from '@joystream/types/common';
+import { Thread, CategoryId } from '@joystream/types/forum';
 import { withOnlyMembers } from '@polkadot/joy-utils/MyAccount';
 import Section from '@polkadot/joy-utils/Section';
 import { useMyAccount } from '@polkadot/joy-utils/MyAccountContext';

+ 2 - 1
pioneer/packages/joy-forum/src/Moderate.tsx

@@ -9,7 +9,8 @@ import { withMulti } from '@polkadot/react-api/with';
 
 import * as JoyForms from '@polkadot/joy-utils/forms';
 import { Text } from '@polkadot/types';
-import { ReplyId, ThreadId } from '@joystream/types/forum';
+import { ThreadId } from '@joystream/types/common';
+import { ReplyId } from '@joystream/types/forum';
 import Section from '@polkadot/joy-utils/Section';
 import { withOnlyForumSudo } from './ForumSudo';
 import { ValidationProps, withPostModerationValidation } from './validation';

+ 2 - 1
pioneer/packages/joy-forum/src/ViewThread.tsx

@@ -5,7 +5,8 @@ import { Table, Button, Label } from 'semantic-ui-react';
 import { History } from 'history';
 import BN from 'bn.js';
 
-import { Category, Thread, ThreadId, Post, PostId } from '@joystream/types/forum';
+import { ThreadId, PostId } from '@joystream/types/common';
+import { Category, Thread, Post } from '@joystream/types/forum';
 import { Pagination, RepliesPerPage, CategoryCrumbs } from './utils';
 import { ViewReply } from './ViewReply';
 import { Moderate } from './Moderate';

+ 2 - 1
pioneer/packages/joy-forum/src/utils.tsx

@@ -2,7 +2,8 @@ import React from 'react';
 import { Link } from 'react-router-dom';
 import { Pagination as SuiPagination } from 'semantic-ui-react';
 
-import { Category, CategoryId, Thread, ThreadId } from '@joystream/types/forum';
+import { ThreadId } from '@joystream/types/common';
+import { Category, CategoryId, Thread } from '@joystream/types/forum';
 import { withForumCalls } from './calls';
 import { withMulti } from '@polkadot/react-api';
 

+ 1 - 1
pioneer/packages/joy-forum/src/validation.tsx

@@ -1,6 +1,6 @@
 import React from 'react';
 import { withMulti } from '@polkadot/react-api/with';
-import { InputValidationLengthConstraint } from '@joystream/types/forum';
+import { InputValidationLengthConstraint } from '@joystream/types/common';
 import { withForumCalls } from './calls';
 import { componentName } from '@polkadot/joy-utils/react/helpers';
 

+ 5 - 5
pioneer/packages/joy-media/src/DiscoveryProvider.tsx

@@ -2,7 +2,7 @@ import React, { useState, useEffect, useContext, createContext } from 'react';
 import { Message } from 'semantic-ui-react';
 import axios, { CancelToken } from 'axios';
 
-import { AccountId } from '@polkadot/types/interfaces';
+import { StorageProviderId } from '@joystream/types/bureaucracy';
 import { Vec } from '@polkadot/types';
 import { Url } from '@joystream/types/discovery';
 import ApiContext from '@polkadot/react-api/ApiContext';
@@ -15,8 +15,8 @@ export type BootstrapNodes = {
 };
 
 export type DiscoveryProvider = {
-  resolveAssetEndpoint: (provider: AccountId, contentId?: string, cancelToken?: CancelToken) => Promise<string>;
-  reportUnreachable: (provider: AccountId) => void;
+  resolveAssetEndpoint: (provider: StorageProviderId, contentId?: string, cancelToken?: CancelToken) => Promise<string>;
+  reportUnreachable: (provider: StorageProviderId) => void;
 };
 
 export type DiscoveryProviderProps = {
@@ -41,7 +41,7 @@ type ProviderStats = {
 function newDiscoveryProvider ({ bootstrapNodes }: BootstrapNodes): DiscoveryProvider {
   const stats: Map<string, ProviderStats> = new Map();
 
-  const resolveAssetEndpoint = async (storageProvider: AccountId, contentId?: string, cancelToken?: CancelToken) => {
+  const resolveAssetEndpoint = async (storageProvider: StorageProviderId, contentId?: string, cancelToken?: CancelToken) => {
     const providerKey = storageProvider.toString();
 
     let stat = stats.get(providerKey);
@@ -98,7 +98,7 @@ function newDiscoveryProvider ({ bootstrapNodes }: BootstrapNodes): DiscoveryPro
     throw new Error('Resolving failed.');
   };
 
-  const reportUnreachable = (provider: AccountId) => {
+  const reportUnreachable = (provider: StorageProviderId) => {
     const key = provider.toString();
     const stat = stats.get(key);
     if (stat) {

+ 4 - 4
pioneer/packages/joy-media/src/Upload.tsx

@@ -11,7 +11,6 @@ import { SubmittableResult } from '@polkadot/api';
 import { Option } from '@polkadot/types/codec';
 import { withMulti, withApi } from '@polkadot/react-api';
 import { formatNumber } from '@polkadot/util';
-import { AccountId } from '@polkadot/types/interfaces';
 
 import translate from './translate';
 import { fileNameWoExt } from './utils';
@@ -24,6 +23,7 @@ import { ChannelId } from '@joystream/types/content-working-group';
 import { EditVideoView } from './upload/EditVideo.view';
 import { JoyInfo } from '@polkadot/joy-utils/JoyStatus';
 import { IterableFile } from './IterableFile';
+import { StorageProviderId } from '@joystream/types/bureaucracy';
 
 const MAX_FILE_SIZE_MB = 500;
 const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
@@ -107,8 +107,8 @@ class Component extends React.PureComponent<Props, State> {
   private resetForm = () => {
     const { cancelSource } = this.state;
     this.setState({
-      cancelSource,
-      ...defaultState()
+      ...defaultState(),
+      cancelSource
     });
   }
 
@@ -285,7 +285,7 @@ class Component extends React.PureComponent<Props, State> {
     }
   }
 
-  private uploadFileTo = async (storageProvider: AccountId) => {
+  private uploadFileTo = async (storageProvider: StorageProviderId) => {
     const { file, newContentId, cancelSource } = this.state;
     if (!file || !file.size) {
       this.setState({

+ 24 - 4
pioneer/packages/joy-media/src/common/MediaPlayerWithResolver.tsx

@@ -6,7 +6,7 @@ import { ApiProps } from '@polkadot/react-api/types';
 import { I18nProps } from '@polkadot/react-components/types';
 import { withMulti } from '@polkadot/react-api/with';
 import { Option } from '@polkadot/types/codec';
-import { AccountId } from '@polkadot/types/interfaces';
+import { StorageProviderId, Worker } from '@joystream/types/bureaucracy';
 
 import translate from '../translate';
 import { DiscoveryProviderProps, withDiscoveryProvider } from '../DiscoveryProvider';
@@ -14,6 +14,7 @@ import { DataObjectStorageRelationshipId, DataObjectStorageRelationship } from '
 import { Message } from 'semantic-ui-react';
 import { MediaPlayerView, RequiredMediaPlayerProps } from './MediaPlayerView';
 import { JoyInfo } from '@polkadot/joy-utils/JoyStatus';
+import { MultipleLinkedMapEntry } from '@polkadot/joy-utils/index';
 
 type Props = ApiProps & I18nProps & DiscoveryProviderProps & RequiredMediaPlayerProps;
 
@@ -29,6 +30,23 @@ function InnerComponent (props: Props) {
   const [contentType, setContentType] = useState<string>();
   const [cancelSource, setCancelSource] = useState<CancelTokenSource>(newCancelSource());
 
+  const getActiveStorageProviderIds = async (): Promise<StorageProviderId[]> => {
+    const nextId = await api.query.storageBureaucracy.nextWorkerId() as StorageProviderId;
+    // This is chain specfic, but if next id is still 0, it means no workers have been added,
+    // so the workerById is empty
+    if (nextId.eq(0)) {
+      return [];
+    }
+
+    const workers = new MultipleLinkedMapEntry<StorageProviderId, Worker>(
+      StorageProviderId,
+      Worker,
+      await api.query.storageBureaucracy.workerById()
+    );
+
+    return workers.linked_keys;
+  };
+
   const resolveAsset = async () => {
     setError(undefined);
     setCancelSource(newCancelSource());
@@ -37,6 +55,7 @@ function InnerComponent (props: Props) {
 
     const allRelationships: Option<DataObjectStorageRelationship>[] = await Promise.all(rids.map((id) => api.query.dataObjectStorageRegistry.relationships(id))) as any;
 
+    // Providers that have signalled onchain that they have the asset
     let readyProviders = allRelationships.filter(r => r.isSome).map(r => r.unwrap())
       .filter(r => r.ready)
       .map(r => r.storage_provider);
@@ -49,10 +68,11 @@ function InnerComponent (props: Props) {
       return;
     }
 
-    // filter out providers no longer in actors list
-    const stakedActors = await api.query.actors.actorAccountIds() as unknown as AccountId[];
+    // filter out providers no longer active - relationships of providers that have left
+    // are not pruned onchain.
+    const activeProviders = await getActiveStorageProviderIds();
+    readyProviders = _.intersectionBy(activeProviders, readyProviders, provider => provider.toString());
 
-    readyProviders = _.intersectionBy(stakedActors, readyProviders, provider => provider.toString());
     console.log(`Found ${readyProviders.length} providers ready to serve content: ${readyProviders}`);
 
     // shuffle to spread the load

+ 1 - 1
pioneer/packages/joy-media/src/transport.substrate.ts

@@ -1,7 +1,7 @@
 import BN from 'bn.js';
 import { MediaTransport, ChannelValidationConstraints } from './transport';
 import { ClassId, Class, EntityId, Entity, ClassName } from '@joystream/types/versioned-store';
-import { InputValidationLengthConstraint } from '@joystream/types/forum';
+import { InputValidationLengthConstraint } from '@joystream/types/common';
 import { PlainEntity, EntityCodecResolver } from '@joystream/types/versioned-store/EntityCodec';
 import { MusicTrackType } from './schemas/music/MusicTrack';
 import { MusicAlbumType } from './schemas/music/MusicAlbum';

+ 1 - 1
pioneer/packages/joy-media/src/upload/UploadVideo.tsx

@@ -14,7 +14,7 @@ import { MediaDropdownOptions } from '../common/MediaDropdownOptions';
 import { FormTabs } from '../common/FormTabs';
 import { ChannelId } from '@joystream/types/content-working-group';
 import { ChannelEntity } from '../entities/ChannelEntity';
-import { Credential } from '@joystream/types/versioned-store/permissions/credentials';
+import { Credential } from '@joystream/types/common';
 import { Class, VecClassPropertyValue } from '@joystream/types/versioned-store';
 import { TxCallback } from '@polkadot/react-components/Status/types';
 import { SubmittableResult } from '@polkadot/api';

+ 1 - 1
pioneer/packages/joy-members/src/Details.tsx

@@ -14,7 +14,7 @@ import { formatNumber } from '@polkadot/util';
 import translate from './translate';
 import { MemberId, Profile, EntryMethod, Paid, Screening, Genesis, SubscriptionId } from '@joystream/types/members';
 import { queryMembershipToProp } from './utils';
-import { Seat } from '@joystream/types/';
+import { Seat } from '@joystream/types/council';
 import { nonEmptyStr, queryToProp } from '@polkadot/joy-utils/index';
 import { MyAccountProps, withMyAccount } from '@polkadot/joy-utils/MyAccount';
 

+ 1 - 1
pioneer/packages/joy-members/src/EditForm.tsx

@@ -10,7 +10,7 @@ import TxButton from '@polkadot/joy-utils/TxButton';
 import * as JoyForms from '@polkadot/joy-utils/forms';
 import { SubmittableResult } from '@polkadot/api';
 import { MemberId, UserInfo, Profile, PaidTermId, PaidMembershipTerms } from '@joystream/types/members';
-import { OptionText } from '@joystream/types/';
+import { OptionText } from '@joystream/types/common';
 import { MyAccountProps, withMyAccount } from '@polkadot/joy-utils/MyAccount';
 import { queryMembershipToProp } from './utils';
 import { withCalls } from '@polkadot/react-api/index';

+ 1 - 1
pioneer/packages/joy-members/src/MemberPreview.tsx

@@ -11,7 +11,7 @@ import IdentityIcon from '@polkadot/react-components/IdentityIcon';
 import translate from './translate';
 import { MemberId, Profile } from '@joystream/types/members';
 import { queryMembershipToProp } from './utils';
-import { Seat } from '@joystream/types/';
+import { Seat } from '@joystream/types/council';
 import { nonEmptyStr, queryToProp } from '@polkadot/joy-utils/index';
 import { FlexCenter } from '@polkadot/joy-utils/FlexCenter';
 import { MutedSpan } from '@polkadot/joy-utils/MutedText';

+ 1 - 1
pioneer/packages/joy-proposals/src/Proposal/ProposalDetails.tsx

@@ -13,7 +13,7 @@ import './Proposal.css';
 import { ProposalId, ProposalDecisionStatuses, ApprovedProposalStatuses, ExecutionFailedStatus } from '@joystream/types/proposals';
 import { BlockNumber } from '@polkadot/types/interfaces';
 import { MemberId } from '@joystream/types/members';
-import { Seat } from '@joystream/types/';
+import { Seat } from '@joystream/types/council';
 import { PromiseComponent } from '@polkadot/joy-utils/react/components';
 import ProposalDiscussion from './discussion/ProposalDiscussion';
 

+ 1 - 1
pioneer/packages/joy-proposals/src/Proposal/discussion/DiscussionPostForm.tsx

@@ -8,7 +8,7 @@ import { SubmittableResult } from '@polkadot/api';
 import { Button } from 'semantic-ui-react';
 import { TxFailedCallback, TxCallback } from '@polkadot/react-components/Status/types';
 import { ParsedPost, DiscussionContraints } from '@polkadot/joy-utils/types/proposals';
-import { ThreadId } from '@joystream/types/forum';
+import { ThreadId } from '@joystream/types/common';
 import { MemberId } from '@joystream/types/members';
 
 type OuterProps = {

+ 1 - 1
pioneer/packages/joy-proposals/src/forms/SetCouncilParamsForm.tsx

@@ -19,7 +19,7 @@ import { createType } from '@polkadot/types';
 import './forms.css';
 import { useTransport, usePromise } from '@polkadot/joy-utils/react/hooks';
 import _ from 'lodash';
-import { ElectionParameters } from '@joystream/types/proposals';
+import { ElectionParameters } from '@joystream/types/council';
 import { PromiseComponent } from '@polkadot/joy-utils/react/components';
 
 type FormValues = GenericFormValues & {

+ 2 - 3
pioneer/packages/joy-roles/src/transport.mock.ts

@@ -5,8 +5,8 @@ import { Option, Text, u32, u128, GenericAccountId } from '@polkadot/types';
 import { Subscribable, Transport as TransportBase } from '@polkadot/joy-utils/index';
 
 import { ITransport } from './transport';
-
-import { Actor, Role } from '@joystream/types/roles';
+import { IProfile, MemberId, Role } from '@joystream/types/members';
+import { Actor } from '@joystream/types/roles';
 import {
   Opening,
   AcceptingApplications,
@@ -14,7 +14,6 @@ import {
   ApplicationRationingPolicy,
   StakingPolicy
 } from '@joystream/types/hiring';
-import { IProfile, MemberId } from '@joystream/types/members';
 
 import { WorkingGroupMembership, StorageAndDistributionMembership, GroupLeadStatus } from './tabs/WorkingGroup';
 import { CuratorId } from '@joystream/types/content-working-group';

+ 4 - 5
pioneer/packages/joy-roles/src/transport.substrate.ts

@@ -14,7 +14,6 @@ import { APIQueryCache, MultipleLinkedMapEntry, SingleLinkedMapEntry, Subscribab
 import { ITransport } from './transport';
 import { GroupMember } from './elements';
 
-import { Role } from '@joystream/types/roles';
 import {
   Curator, CuratorId,
   CuratorApplication, CuratorApplicationId,
@@ -31,7 +30,7 @@ import {
 import { Application, Opening } from '@joystream/types/hiring';
 import { Stake, StakeId } from '@joystream/types/stake';
 import { Recipient, RewardRelationship, RewardRelationshipId } from '@joystream/types/recurring-rewards';
-import { ActorInRole, Profile, MemberId, Role as MemberRole, RoleKeys, ActorId } from '@joystream/types/members';
+import { ActorInRole, Profile, MemberId, Role, RoleKeys, ActorId } from '@joystream/types/members';
 import { createAccount, generateSeed } from '@polkadot/joy-utils/accounts';
 
 import { WorkingGroupMembership, StorageAndDistributionMembership, GroupLeadStatus } from './tabs/WorkingGroup';
@@ -154,7 +153,7 @@ export class Transport extends TransportBase implements ITransport {
     return recipient.value.total_reward_received;
   }
 
-  protected async memberIdFromRoleAndActorId (role: MemberRole, id: ActorId): Promise<MemberId> {
+  protected async memberIdFromRoleAndActorId (role: Role, id: ActorId): Promise<MemberId> {
     const memberId = (
       await this.cachedApi.query.members.membershipIdByActorInRole(
         new ActorInRole({
@@ -169,14 +168,14 @@ export class Transport extends TransportBase implements ITransport {
 
   protected memberIdFromCuratorId (curatorId: CuratorId): Promise<MemberId> {
     return this.memberIdFromRoleAndActorId(
-      new MemberRole(RoleKeys.Curator),
+      new Role(RoleKeys.Curator),
       curatorId
     );
   }
 
   protected memberIdFromLeadId (leadId: LeadId): Promise<MemberId> {
     return this.memberIdFromRoleAndActorId(
-      new MemberRole(RoleKeys.CuratorLead),
+      new Role(RoleKeys.CuratorLead),
       leadId
     );
   }

+ 1 - 1
pioneer/packages/joy-roles/src/transport.ts

@@ -1,7 +1,7 @@
 import { Subscribable } from '@polkadot/joy-utils/index';
 import { Balance } from '@polkadot/types/interfaces';
 
-import { Role } from '@joystream/types/roles';
+import { Role } from '@joystream/types/members';
 
 import { WorkingGroupMembership, StorageAndDistributionMembership, GroupLeadStatus } from './tabs/WorkingGroup';
 import { WorkingGroupOpening } from './tabs/Opportunities';

+ 2 - 1
pioneer/packages/joy-storage/src/AvailableRoles/index.tsx

@@ -1,7 +1,8 @@
 import React from 'react';
 import { BareProps } from '@polkadot/react-components/types';
 import { ComponentProps } from '../props';
-import { Role, RoleParameters } from '@joystream/types/roles';
+import { Role } from '@joystream/types/members';
+import { RoleParameters } from '@joystream/types/roles';
 import { Option } from '@polkadot/types';
 import { AccountId } from '@polkadot/types/interfaces';
 import { withCalls } from '@polkadot/react-api/index';

+ 2 - 1
pioneer/packages/joy-storage/src/MyRequests/index.tsx

@@ -3,7 +3,8 @@ import { Table } from 'semantic-ui-react';
 import { BareProps, CallProps } from '@polkadot/react-api/types';
 import { MyAccountProps, withOnlyMembers } from '@polkadot/joy-utils/MyAccount';
 import { withCalls, withMulti } from '@polkadot/react-api/index';
-import { Request, Role, RoleParameters } from '@joystream/types/roles';
+import { Role } from '@joystream/types/members';
+import { Request, RoleParameters } from '@joystream/types/roles';
 import { Option } from '@polkadot/types';
 import { AccountId, Balance } from '@polkadot/types/interfaces';
 import TxButton from '@polkadot/joy-utils/TxButton';

+ 2 - 1
pioneer/packages/joy-storage/src/index.tsx

@@ -2,7 +2,8 @@ import { AppProps, I18nProps } from '@polkadot/react-components/types';
 import { ApiProps } from '@polkadot/react-api/types';
 import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
 import { ComponentProps } from './props';
-import { Request, Role } from '@joystream/types/roles';
+import { Role } from '@joystream/types/members';
+import { Request } from '@joystream/types/roles';
 
 import React from 'react';
 import { Route, Switch } from 'react-router';

+ 2 - 1
pioneer/packages/joy-storage/src/props.ts

@@ -1,4 +1,5 @@
-import { Request, Role } from '@joystream/types/roles';
+import { Role } from '@joystream/types/members';
+import { Request } from '@joystream/types/roles';
 
 export type ComponentProps = {
   actorAccountIds: Array<string>;

+ 1 - 1
pioneer/packages/joy-utils/src/index.ts

@@ -7,7 +7,7 @@ import keyring from '@polkadot/ui-keyring';
 // Joystream Stake utils
 // --------------------------------------
 
-import { Stake, Backer } from '@joystream/types/';
+import { Stake, Backer } from '@joystream/types/council';
 
 // Substrate/Polkadot API utils
 // --------------------------------------

+ 1 - 1
pioneer/packages/joy-utils/src/transport/council.ts

@@ -1,6 +1,6 @@
 import { ParsedMember } from '../types/members';
 import BaseTransport from './base';
-import { Seats, ElectionParameters } from '@joystream/types/proposals';
+import { Seats, ElectionParameters } from '@joystream/types/council';
 import { MemberId, Profile } from '@joystream/types/members';
 import { u32, Vec } from '@polkadot/types/';
 import { Balance, BlockNumber } from '@polkadot/types/interfaces';

+ 1 - 1
pioneer/packages/joy-utils/src/transport/proposals.ts

@@ -12,7 +12,7 @@ import { ParsedMember } from '../types/members';
 
 import BaseTransport from './base';
 
-import { ThreadId, PostId } from '@joystream/types/forum';
+import { ThreadId, PostId } from '@joystream/types/common';
 import { Proposal, ProposalId, VoteKind, DiscussionThread, DiscussionPost } from '@joystream/types/proposals';
 import { MemberId } from '@joystream/types/members';
 import { u32, u64 } from '@polkadot/types/';

+ 1 - 1
pioneer/packages/joy-utils/src/types/proposals.ts

@@ -1,6 +1,6 @@
 import { ProposalId, VoteKind } from '@joystream/types/proposals';
 import { MemberId, Profile } from '@joystream/types/members';
-import { ThreadId, PostId } from '@joystream/types/forum';
+import { ThreadId, PostId } from '@joystream/types/common';
 import { ParsedMember } from './members';
 
 export const ProposalTypes = [

+ 1 - 1
tests/network-tests/package.json

@@ -10,7 +10,7 @@
     "prettier": "prettier --write ./src"
   },
   "dependencies": {
-    "@constantinople/types@npm:@joystream/types": "^0.10.0",
+    "@constantinople/types": "./types",
     "@polkadot/api": "^0.96.1",
     "@polkadot/keyring": "^1.7.0-beta.5",
     "@rome/types@npm:@joystream/types": "^0.7.0",

+ 1 - 1
tests/network-tests/src/constantinople/tests/impl/electingCouncil.ts

@@ -2,7 +2,7 @@ import { KeyringPair } from '@polkadot/keyring/types';
 import { ApiWrapper } from '../../utils/apiWrapper';
 import { Keyring } from '@polkadot/api';
 import BN from 'bn.js';
-import { Seat } from '@constantinople/types';
+import { Seat } from '@constantinople/types/lib/council';
 import { assert } from 'chai';
 import { v4 as uuid } from 'uuid';
 import { Utils } from '../../utils/utils';

+ 1 - 1
tests/network-tests/src/constantinople/utils/apiWrapper.ts

@@ -6,7 +6,7 @@ import { UserInfo, PaidMembershipTerms, MemberId } from '@constantinople/types/l
 import { Mint, MintId } from '@constantinople/types/lib/mint';
 import { Lead, LeadId } from '@constantinople/types/lib/content-working-group';
 import { RoleParameters } from '@constantinople/types/lib/roles';
-import { Seat } from '@constantinople/types';
+import { Seat } from '@constantinople/types/lib/council';
 import { Balance, EventRecord, AccountId, BlockNumber, BalanceOf } from '@polkadot/types/interfaces';
 import BN from 'bn.js';
 import { SubmittableExtrinsic } from '@polkadot/api/types';

+ 1 - 1
tests/network-tests/src/constantinople/utils/utils.ts

@@ -4,7 +4,7 @@ import { blake2AsHex } from '@polkadot/util-crypto';
 import BN from 'bn.js';
 import fs from 'fs';
 import { decodeAddress } from '@polkadot/keyring';
-import { Seat } from '@constantinople/types';
+import { Seat } from '@constantinople/types/lib/council';
 
 export class Utils {
   private static LENGTH_ADDRESS = 32 + 1; // publicKey + prefix

+ 2 - 2
types/package.json

@@ -1,7 +1,7 @@
 {
   "name": "@joystream/types",
-  "version": "0.10.0",
-  "description": "Types for Joystream Substrate Runtime 6.15.0",
+  "version": "0.11.0",
+  "description": "Types for Joystream Substrate Runtime - nicaea release",
   "main": "lib/index.js",
   "scripts": {
     "prepublish": "npm run build",

+ 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,

+ 103 - 0
types/src/common.ts

@@ -0,0 +1,103 @@
+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> {}
+
+export class Credential extends u64 {}
+export class CredentialSet extends Vec.with(Credential) {} // BtreeSet ?
+
+// 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({
+      Credential,
+      CredentialSet,
+      BlockAndTime,
+      ThreadId,
+      PostId,
+      InputValidationLengthConstraint,
+      BTreeSet // Is this even necessary?
+    });
+}

+ 3 - 0
types/src/content-working-group/ChannelId.ts

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

+ 5 - 6
types/src/content-working-group/index.ts

@@ -1,21 +1,20 @@
 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, OptionText, Credential } 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 {};
+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 Option.with(Text) {};
+export class OptionalText extends OptionText {};
 
 export type ChannelContentTypeValue =
   'Video' |

+ 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();
 }

+ 13 - 112
types/src/media.ts

@@ -1,6 +1,8 @@
 import { Enum, Struct, Option, Vec as Vector, H256 } from '@polkadot/types';
-import { getTypeRegistry, u32, u64, bool, Text, GenericAccountId } from '@polkadot/types';
-import { BlockNumber, Moment, AccountId } from '@polkadot/types/interfaces';
+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';
@@ -28,52 +30,9 @@ export class ContentId extends H256 {
 
 export class DataObjectTypeId extends u64 {}
 export class DataObjectStorageRelationshipId extends u64 {}
-export class SchemaId extends u64 {}
-export class DownloadSessionId 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);
-  }
-}
-
-// TODO rename to Draft to Unlisted
-export type ContentVisibilityKey = 'Draft' | 'Public';
-
-export class ContentVisibility extends Enum {
-  constructor (value?: ContentVisibilityKey) {
-    super([
-      'Draft',
-      'Public'
-    ], value);
-  }
-}
 
 export class VecContentId extends Vector.with(ContentId) {}
-
 export class OptionVecContentId extends Option.with(VecContentId) {}
-export class OptionSchemaId extends Option.with(SchemaId) {}
-export class OptionContentVisibility extends Option.with(ContentVisibility) {}
 export type LiaisonJudgementKey = 'Pending' | 'Accepted' | 'Rejected';
 
 export class LiaisonJudgement extends Enum {
@@ -89,18 +48,18 @@ export class LiaisonJudgement extends Enum {
 export class DataObject extends Struct {
   constructor (value?: any) {
     super({
-      owner: GenericAccountId,
+      owner: MemberId,
       added_at: BlockAndTime,
       type_id: DataObjectTypeId,
       size: u64,
-      liaison: GenericAccountId,
+      liaison: StorageProviderId,
       liaison_judgement: LiaisonJudgement,
       ipfs_content_id: Text,
     }, value);
   }
 
-  get owner (): AccountId {
-    return this.get('owner') as AccountId;
+  get owner (): MemberId {
+    return this.get('owner') as MemberId;
   }
 
   get added_at (): BlockAndTime {
@@ -116,8 +75,8 @@ export class DataObject extends Struct {
     return this.get('size') as u64;
   }
 
-  get liaison (): AccountId {
-    return this.get('liaison') as AccountId;
+  get liaison (): StorageProviderId {
+    return this.get('liaison') as StorageProviderId;
   }
 
   get liaison_judgement (): LiaisonJudgement {
@@ -133,7 +92,7 @@ export class DataObjectStorageRelationship extends Struct {
   constructor (value?: any) {
     super({
       content_id: ContentId,
-      storage_provider: GenericAccountId,
+      storage_provider: StorageProviderId,
       ready: bool
     }, value);
   }
@@ -142,8 +101,8 @@ export class DataObjectStorageRelationship extends Struct {
     return this.get('content_id') as ContentId;
   }
 
-  get storage_provider (): AccountId {
-    return this.get('storage_provider') as AccountId;
+  get storage_provider (): StorageProviderId {
+    return this.get('storage_provider') as StorageProviderId;
   }
 
   get ready (): bool {
@@ -168,76 +127,18 @@ export class DataObjectType extends Struct {
   }
 }
 
-export type DownloadStateKey = 'Started' | 'Ended';
-
-export class DownloadState extends Enum {
-  constructor (value?: DownloadStateKey) {
-    super([
-      'Started',
-      'Ended'
-    ], value);
-  }
-}
-
-export class DownloadSession extends Struct {
-  constructor (value?: any) {
-    super({
-      content_id: ContentId,
-      consumer: GenericAccountId,
-      distributor: GenericAccountId,
-      initiated_at_block: u32, // BlockNumber,
-      initiated_at_time: u64, // Moment
-      state: DownloadState,
-      transmitted_bytes: u64
-    }, value);
-  }
-
-  get content_id (): ContentId {
-    return this.get('content_id') as ContentId;
-  }
-
-  get consumer (): AccountId {
-    return this.get('consumer') as AccountId;
-  }
-
-  get distributor (): AccountId {
-    return this.get('distributor') as AccountId;
-  }
-
-  get initiated_at_block (): BlockNumber {
-    return this.get('initiated_at_block') as BlockNumber;
-  }
-
-  get initiated_at_time (): Moment {
-    return this.get('initiated_at_time') as Moment;
-  }
-
-  get state (): DownloadState {
-    return this.get('state') as DownloadState;
-  }
-
-  get transmitted_bytes (): u64 {
-    return this.get('transmitted_bytes') as u64;
-  }
-}
-
 export function registerMediaTypes () {
   try {
     getTypeRegistry().register({
       '::ContentId': ContentId,
       '::DataObjectTypeId': DataObjectTypeId,
-      // SchemaId, // This isn't required? (its what caused issue with type mismatch in permissions module!)
       ContentId,
-      ContentVisibility,
       LiaisonJudgement,
       DataObject,
       DataObjectStorageRelationshipId,
       DataObjectStorageRelationship,
       DataObjectTypeId,
       DataObjectType,
-      DownloadState,
-      DownloadSessionId,
-      DownloadSession
     });
   } catch (err) {
     console.error('Failed to register custom types of media module', err);

+ 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 {};

+ 2 - 2
types/src/versioned-store/EntityCodec.ts

@@ -1,11 +1,11 @@
 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 { Class, Entity, VecClassPropertyValue, ClassPropertyValue, EntityId, ClassId, unifyPropName } from '.';
 import PropertyTypeName from './PropertyTypeName';
-import { ChannelId } from '../content-working-group';
+import ChannelId from '../content-working-group/ChannelId';
 
 /**
  * Convert a Substrate value to a plain JavaScript value of a corresponding type

+ 3 - 30
types/src/versioned-store/index.ts

@@ -1,10 +1,10 @@
 import { getTypeRegistry, u16, Text, bool as Bool } from '@polkadot/types';
 import { Vec as Vector } from '@polkadot/types/codec';
-import { JoyStruct } from '../JoyStruct';
+import { JoyStruct } from '../common';
+import EntityId from './EntityId';
+import ClassId from './ClassId';
 import PropertyType from './PropertyType';
 import PropertyValue from './PropertyValue';
-import ClassId from './ClassId';
-import EntityId from './EntityId';
 import { camelCase, upperFirst } from 'lodash'
 
 export {
@@ -14,32 +14,6 @@ export {
   PropertyValue
 }
 
-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 PropertyTsType = {
   prop_type: PropertyType,
   required: Bool,
@@ -224,7 +198,6 @@ export function unifyPropName(propName: string): string {
 export function registerVersionedStoreTypes () {
   try {
     getTypeRegistry().register({
-      InputValidationLengthConstraint,
       ClassId: 'u64',
       EntityId: 'u64',
       Class,

+ 2 - 3
types/src/versioned-store/permissions/ClassPermissions.ts

@@ -1,9 +1,8 @@
-import { JoyStruct } from '../../JoyStruct';
 import { u32, bool } from '@polkadot/types';
+import { BlockNumber } from '@polkadot/types/interfaces';
+import { JoyStruct, CredentialSet } from '../../common';
 import EntityPermissions from './EntityPermissions';
-import { CredentialSet } from './credentials';
 import { ReferenceConstraint } from './reference-constraint';
-import { BlockNumber } from '@polkadot/types/interfaces';
 
 type IClassPermissions = {
     entity_permissions: EntityPermissions,

+ 1 - 1
types/src/versioned-store/permissions/EntityPermissions.ts

@@ -1,6 +1,6 @@
 import { JoyStruct } from '../../JoyStruct';
 import { bool } from '@polkadot/types';
-import { CredentialSet } from './credentials';
+import { CredentialSet } from '../../common';
 
 type IEntityPermissions = {
     update: CredentialSet,

+ 2 - 3
types/src/versioned-store/permissions/PropertyOfClass.ts

@@ -1,7 +1,6 @@
-import { JoyStruct } from '../../JoyStruct';
-import ClassId from '../ClassId';
 import { u16 } from '@polkadot/types';
-
+import { JoyStruct } from '../../common';
+import ClassId from '../ClassId';
 
 type IPropertyOfClass = {
     class_id: ClassId,

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

@@ -1,6 +1,6 @@
 
 import { ParametrizedPropertyValue } from './parametrized-property-value';
-import { JoyStruct } from '../../../JoyStruct';
+import { JoyStruct } from '../../../common';
 import { u16 } from '@polkadot/types';
 
 type IParametrizedClassPropertyValue = {

+ 1 - 2
types/src/versioned-store/permissions/batching/index.ts

@@ -1,7 +1,6 @@
-import { JoyStruct } from '../../../JoyStruct';
+import { JoyStruct, Credential } from '../../../common';
 import { OperationType } from './operation-types';
 import { bool, Option } from '@polkadot/types';
-import { Credential } from '../credentials';
 
 type IOperation = {
     with_credential: Option<Credential>,

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

@@ -1,5 +1,5 @@
 import ClassId from "../../ClassId";
-import { JoyStruct } from '../../../JoyStruct';
+import { JoyStruct } from '../../../common';
 import { ParametrizedEntity } from "./parametrized-entity";
 import { Vec, u16 } from "@polkadot/types";
 import ParametrizedClassPropertyValue from "./ParametrizedClassPropertyValue";

+ 0 - 4
types/src/versioned-store/permissions/credentials.ts

@@ -1,4 +0,0 @@
-import { u64, Vec } from '@polkadot/types';
-
-export class Credential extends u64 {}
-export class CredentialSet extends Vec.with(Credential) {} // BtreeSet ?

+ 0 - 3
types/src/versioned-store/permissions/index.ts

@@ -1,6 +1,5 @@
 import { getTypeRegistry } from '@polkadot/types';
 
-import { Credential, CredentialSet } from './credentials';
 import EntityPermissions from './EntityPermissions';
 import { ReferenceConstraint} from './reference-constraint';
 import ClassPermissionsType from './ClassPermissions';
@@ -9,8 +8,6 @@ import { Operation } from './batching/';
 export function registerVersionedStorePermissionsTypes () {
     try {
       getTypeRegistry().register({
-        Credential,
-        CredentialSet,
         EntityPermissions,
         ReferenceConstraint,
         ClassPermissionsType,

+ 2 - 4
yarn.lock

@@ -1355,10 +1355,8 @@
     exec-sh "^0.3.2"
     minimist "^1.2.0"
 
-"@constantinople/types@npm:@joystream/types@^0.10.0":
-  version "0.10.0"
-  resolved "https://registry.yarnpkg.com/@joystream/types/-/types-0.10.0.tgz#7e98ef221410b26a7d952cfc3d1c03d28395ad69"
-  integrity sha512-RDZizqGKWGYpLR5PnUWM4aGa7InpWNh2Txlr7Al3ROFYOHoyQf62/omPfEz29F6scwlFxysOdmEfQaLeVRaUxA==
+"@constantinople/types@./types", "@joystream/types@./types":
+  version "0.11.0"
   dependencies:
     "@polkadot/types" "^0.96.1"
     "@types/vfile" "^4.0.0"