Procházet zdrojové kódy

content-dir: simplify types from events

Mokhtar Naamani před 4 roky
rodič
revize
6c4822dc1d

+ 2 - 3
runtime-modules/content/src/lib.rs

@@ -1313,9 +1313,8 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn not_implemented() -> Result<(), Error<T>> {
-        ensure!(false, Error::<T>::FeatureNotImplemented);
-        Ok(())
+    fn not_implemented() -> DispatchResult {
+        Err(Error::<T>::FeatureNotImplemented.into())
     }
 }
 

+ 3 - 3
runtime-modules/content/src/tests/mock.rs

@@ -20,8 +20,8 @@ use common::storage::StorageSystem;
 pub type CuratorId = <Test as ContentActorAuthenticator>::CuratorId;
 pub type CuratorGroupId = <Test as ContentActorAuthenticator>::CuratorGroupId;
 pub type MemberId = <Test as MembershipTypes>::MemberId;
-pub type ChannelId = <Test as StorageOwnership>::ChannelId;
-pub type DAOId = <Test as StorageOwnership>::DAOId;
+// pub type ChannelId = <Test as StorageOwnership>::ChannelId;
+// pub type DAOId = <Test as StorageOwnership>::DAOId;
 
 /// Origins
 
@@ -43,7 +43,7 @@ pub const FIRST_CURATOR_ID: CuratorId = 1;
 pub const SECOND_CURATOR_ID: CuratorId = 2;
 
 pub const FIRST_CURATOR_GROUP_ID: CuratorGroupId = 1;
-pub const SECOND_CURATOR_GROUP_ID: CuratorGroupId = 2;
+// pub const SECOND_CURATOR_GROUP_ID: CuratorGroupId = 2;
 
 pub const FIRST_MEMBER_ID: MemberId = 1;
 pub const SECOND_MEMBER_ID: MemberId = 2;

+ 3 - 4
runtime-modules/storage/src/data_directory.rs

@@ -279,9 +279,8 @@ decl_event! {
     pub enum Event<T> where
         StorageObjectOwner = ObjectOwner<T>,
         StorageProviderId = StorageProviderId<T>,
-        Content = Vec<ContentParameters<ContentId<T>, DataObjectTypeId<T>>>,
         ContentId = ContentId<T>,
-        ContentIds = Vec<ContentId<T>>,
+        ContentParameters = ContentParameters<ContentId<T>, DataObjectTypeId<T>>,
         VoucherLimit = u64,
         UploadingStatus = bool
     {
@@ -289,13 +288,13 @@ decl_event! {
         /// Params:
         /// - Content parameters representation.
         /// - StorageObjectOwner enum.
-        ContentAdded(Content, StorageObjectOwner),
+        ContentAdded(Vec<ContentParameters>, StorageObjectOwner),
 
         /// Emits on content removal.
         /// Params:
         /// - Content parameters representation.
         /// - StorageObjectOwner enum.
-        ContentRemoved(ContentIds, StorageObjectOwner),
+        ContentRemoved(Vec<ContentId>, StorageObjectOwner),
 
         /// Emits when the storage provider accepts a content.
         /// Params:

+ 3 - 11
types/src/storage.ts

@@ -1,4 +1,4 @@
-import { Option, Vec, BTreeMap, u64, bool, Text, Null, Bytes } from '@polkadot/types'
+import { BTreeMap, u64, bool, Text, Null, Bytes } from '@polkadot/types'
 import { BlockAndTime, JoyEnum, JoyStructDecorated, Hash, ChannelId, DAOId, WorkingGroup } from './common'
 import { MemberId } from './members'
 import { StorageProviderId } from './working-group' // this should be in discovery really
@@ -26,13 +26,9 @@ export class ContentId extends Hash {
   }
 }
 
-export class ContentIds extends Vec.with(ContentId) {}
 export class DataObjectTypeId extends u64 {}
 export class DataObjectStorageRelationshipId extends u64 {}
 
-export class VecContentId extends Vec.with(ContentId) {}
-export class OptionVecContentId extends Option.with(VecContentId) {}
-
 export const LiaisonJudgementDef = {
   Pending: Null,
   Accepted: Null,
@@ -61,8 +57,6 @@ export class ContentParameters extends JoyStructDecorated({
   }
 }
 
-export class Content extends Vec.with(ContentParameters) {}
-
 export class DataObject extends JoyStructDecorated({
   owner: StorageObjectOwner,
   added_at: BlockAndTime,
@@ -100,14 +94,12 @@ export class Voucher extends JoyStructDecorated({
   objects_used: u64,
 }) {}
 
+// These types names only in the data_directory Events, do they really need a type name alias?
 export class VoucherLimit extends u64 {}
 export class UploadingStatus extends bool {}
 
-// Add 'Voucher' ? used as extrinsic parameter..
-
 export const mediaTypes: RegistryTypes = {
   ContentId,
-  ContentIds,
   LiaisonJudgement,
   DataObject,
   DataObjectStorageRelationshipId,
@@ -117,7 +109,7 @@ export const mediaTypes: RegistryTypes = {
   DataObjectsMap,
   ContentParameters,
   StorageObjectOwner,
-  Content,
+  ObjectOwner: StorageObjectOwner,
   Voucher,
   VoucherLimit,
   UploadingStatus,