Browse Source

storage-node-v2: Removed media.ts from types.

- refactored DataObject
Shamil Gadelshin 3 years ago
parent
commit
a928437bd3

File diff suppressed because it is too large
+ 1 - 2
types/augment-codec/all.ts


File diff suppressed because it is too large
+ 0 - 0
types/augment-codec/augment-types.ts


+ 2 - 31
types/augment/all/defs.json

@@ -552,35 +552,6 @@
         "identity": "IPNSIdentity",
         "expires_at": "u32"
     },
-    "ContentId": "[u8;32]",
-    "LiaisonJudgement": {
-        "_enum": [
-            "Pending",
-            "Accepted",
-            "Rejected"
-        ]
-    },
-    "DataObject": {
-        "owner": "MemberId",
-        "added_at": "BlockAndTime",
-        "type_id": "DataObjectTypeId",
-        "size": "u64",
-        "liaison": "StorageProviderId",
-        "liaison_judgement": "LiaisonJudgement",
-        "ipfs_content_id": "Text"
-    },
-    "DataObjectStorageRelationshipId": "u64",
-    "DataObjectStorageRelationship": {
-        "content_id": "ContentId",
-        "storage_provider": "StorageProviderId",
-        "ready": "bool"
-    },
-    "DataObjectTypeId": "u64",
-    "DataObjectType": {
-        "description": "Text",
-        "active": "bool"
-    },
-    "DataObjectsMap": "BTreeMap<ContentId,DataObject>",
     "ProposalId": "u32",
     "ProposalStatus": {
         "_enum": {
@@ -1008,7 +979,7 @@
         "prize": "u128"
     },
     "Bag": {
-        "objects": "BTreeMap<DataObjectId,StorageDataObject>",
+        "objects": "BTreeMap<DataObjectId,DataObject>",
         "stored_by": "StorageBucketIdSet",
         "distributed_by": "Vec<DistributionBucketId>",
         "deletion_prize": "Option<u128>"
@@ -1071,7 +1042,7 @@
             "StorageWorker": "WorkerId"
         }
     },
-    "StorageDataObject": {
+    "DataObject": {
         "accepted": "bool",
         "deletion_prize": "u128",
         "size": "u64"

+ 4 - 46
types/augment/all/types.ts

@@ -1,7 +1,7 @@
 // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
 /* eslint-disable */
 
-import type { BTreeMap, BTreeSet, Bytes, Enum, GenericAccountId, Null, Option, Struct, Text, U8aFixed, Vec, bool, i16, i32, i64, u128, u16, u32, u64 } from '@polkadot/types';
+import type { BTreeMap, BTreeSet, Bytes, Enum, GenericAccountId, Null, Option, Struct, Text, Vec, bool, i16, i32, i64, u128, u16, u32, u64 } from '@polkadot/types';
 import type { ITuple } from '@polkadot/types/types';
 import type { AccountId, Balance, Hash } from '@polkadot/types/interfaces/runtime';
 
@@ -160,7 +160,7 @@ export interface Backers extends Vec<Backer> {}
 
 /** @name Bag */
 export interface Bag extends Struct {
-  readonly objects: BTreeMap<DataObjectId, StorageDataObject>;
+  readonly objects: BTreeMap<DataObjectId, DataObject>;
   readonly stored_by: StorageBucketIdSet;
   readonly distributed_by: Vec<DistributionBucketId>;
   readonly deletion_prize: Option<u128>;
@@ -298,9 +298,6 @@ export interface ClassPermissionsType extends Null {}
 /** @name ClassPropertyValue */
 export interface ClassPropertyValue extends Null {}
 
-/** @name ContentId */
-export interface ContentId extends U8aFixed {}
-
 /** @name ContentIdSet */
 export interface ContentIdSet extends BTreeSet<Cid> {}
 
@@ -410,12 +407,8 @@ export interface CuratorRoleStakeProfile extends Struct {
 
 /** @name DataObject */
 export interface DataObject extends Struct {
-  readonly owner: MemberId;
-  readonly added_at: BlockAndTime;
-  readonly type_id: DataObjectTypeId;
-  readonly liaison: StorageProviderId;
-  readonly liaison_judgement: LiaisonJudgement;
-  readonly ipfs_content_id: Text;
+  readonly accepted: bool;
+  readonly deletion_prize: u128;
 }
 
 /** @name DataObjectCreationParameters */
@@ -429,28 +422,6 @@ export interface DataObjectId extends u64 {}
 /** @name DataObjectIdSet */
 export interface DataObjectIdSet extends BTreeSet<DataObjectId> {}
 
-/** @name DataObjectsMap */
-export interface DataObjectsMap extends BTreeMap<ContentId, DataObject> {}
-
-/** @name DataObjectStorageRelationship */
-export interface DataObjectStorageRelationship extends Struct {
-  readonly content_id: ContentId;
-  readonly storage_provider: StorageProviderId;
-  readonly ready: bool;
-}
-
-/** @name DataObjectStorageRelationshipId */
-export interface DataObjectStorageRelationshipId extends u64 {}
-
-/** @name DataObjectType */
-export interface DataObjectType extends Struct {
-  readonly description: Text;
-  readonly active: bool;
-}
-
-/** @name DataObjectTypeId */
-export interface DataObjectTypeId extends u64 {}
-
 /** @name Deactivated */
 export interface Deactivated extends Struct {
   readonly cause: OpeningDeactivationCause;
@@ -729,13 +700,6 @@ export interface LeadRoleState extends Enum {
   readonly asExited: ExitedLeadRole;
 }
 
-/** @name LiaisonJudgement */
-export interface LiaisonJudgement extends Enum {
-  readonly isPending: boolean;
-  readonly isAccepted: boolean;
-  readonly isRejected: boolean;
-}
-
 /** @name LookupSource */
 export interface LookupSource extends AccountId {}
 
@@ -1337,12 +1301,6 @@ export interface StorageBucketsPerBagValueConstraint extends Struct {
   readonly max_min_diff: u64;
 }
 
-/** @name StorageDataObject */
-export interface StorageDataObject extends Struct {
-  readonly accepted: bool;
-  readonly deletion_prize: u128;
-}
-
 /** @name StorageProviderId */
 export interface StorageProviderId extends u64 {}
 

File diff suppressed because it is too large
+ 0 - 0
types/augment/augment-types.ts


+ 0 - 1
types/src/common.ts

@@ -104,7 +104,6 @@ export class InputValidationLengthConstraint extends JoyStructDecorated({ min: u
 }
 
 export const WorkingGroupDef = {
-  Forum: Null,
   Storage: Null,
   Content: Null,
 } as const

+ 0 - 3
types/src/index.ts

@@ -11,7 +11,6 @@ import hiring from './hiring'
 import contentWorkingGroup from './content-working-group'
 import workingGroup from './working-group'
 import discovery from './discovery'
-import media from './media'
 import proposals from './proposals'
 import contentDirectory from './content-directory'
 import storage from './storage'
@@ -35,7 +34,6 @@ export {
   contentWorkingGroup,
   workingGroup,
   discovery,
-  media,
   proposals,
   contentDirectory,
   storage,
@@ -54,7 +52,6 @@ export const types: RegistryTypes = {
   ...contentWorkingGroup,
   ...workingGroup,
   ...discovery,
-  ...media,
   ...proposals,
   ...contentDirectory,
   ...storage,

+ 0 - 82
types/src/media.ts

@@ -1,82 +0,0 @@
-import { Option, Vec as Vector, BTreeMap, u64, bool, Text, Null } from '@polkadot/types'
-import { BlockAndTime, JoyEnum, JoyStructDecorated, Hash } from './common'
-import { MemberId } from './members'
-import { StorageProviderId } from './working-group' // this should be in discovery really
-import { randomAsU8a } from '@polkadot/util-crypto'
-import { encodeAddress, decodeAddress } from '@polkadot/keyring'
-import { RegistryTypes, Registry } from '@polkadot/types/types'
-
-export class ContentId extends Hash {
-  static generate(registry: Registry): ContentId {
-    // randomAsU8a uses https://www.npmjs.com/package/tweetnacl#random-bytes-generation
-    return new ContentId(registry, randomAsU8a())
-  }
-
-  static decode(registry: Registry, contentId: string): ContentId {
-    return new ContentId(registry, decodeAddress(contentId))
-  }
-
-  static encode(contentId: Uint8Array): string {
-    // console.log('contentId:', Buffer.from(contentId).toString('hex'))
-    return encodeAddress(contentId)
-  }
-
-  encode(): string {
-    return ContentId.encode(this)
-  }
-}
-
-export class DataObjectTypeId extends u64 {}
-export class DataObjectStorageRelationshipId extends u64 {}
-
-export class VecContentId extends Vector.with(ContentId) {}
-export class OptionVecContentId extends Option.with(VecContentId) {}
-
-export const LiaisonJudgementDef = {
-  Pending: Null,
-  Accepted: Null,
-  Rejected: Null,
-} as const
-export type LiaisonJudgementKey = keyof typeof LiaisonJudgementDef
-export class LiaisonJudgement extends JoyEnum(LiaisonJudgementDef) {}
-
-export class DataObject extends JoyStructDecorated({
-  owner: MemberId,
-  added_at: BlockAndTime,
-  type_id: DataObjectTypeId,
-  size: u64,
-  liaison: StorageProviderId,
-  liaison_judgement: LiaisonJudgement,
-  ipfs_content_id: Text,
-}) {
-  /** Actually it's 'size', but 'size' is already reserved by a parent class. */
-  get size_in_bytes(): u64 {
-    return this.get('size') as u64
-  }
-}
-
-export class DataObjectStorageRelationship extends JoyStructDecorated({
-  content_id: ContentId,
-  storage_provider: StorageProviderId,
-  ready: bool,
-}) {}
-
-export class DataObjectType extends JoyStructDecorated({
-  description: Text,
-  active: bool,
-}) {}
-
-export class DataObjectsMap extends BTreeMap.with(ContentId, DataObject) {}
-
-export const mediaTypes: RegistryTypes = {
-  ContentId,
-  LiaisonJudgement,
-  DataObject,
-  DataObjectStorageRelationshipId,
-  DataObjectStorageRelationship,
-  DataObjectTypeId,
-  DataObjectType,
-  DataObjectsMap,
-}
-
-export default mediaTypes

+ 0 - 2
types/src/scripts/generateAugmentCodec.ts

@@ -20,7 +20,6 @@ import hiring from '../hiring'
 import contentWorkingGroup from '../content-working-group'
 import workingGroup from '../working-group'
 import discovery from '../discovery'
-import media from '../media'
 import proposals from '../proposals'
 import contentDirectory from '../content-directory'
 import storage from '../storage'
@@ -43,7 +42,6 @@ const typesByModule = {
   'content-working-group': contentWorkingGroup,
   'working-group': workingGroup,
   'discovery': discovery,
-  'media': media,
   'proposals': proposals,
   'content-directory': contentDirectory,
   'storage': storage,

+ 6 - 7
types/src/storage.ts

@@ -19,20 +19,19 @@ export class StorageBucketsPerBagValueConstraint
   })
   implements IStorageBucketsPerBagValueConstraint {}
 
-export type IStorageDataObject = {
+export type IDataObject = {
   accepted: bool
   deletion_prize: BalanceOf
   size: u64
 }
 
-// DataObject from the storage pallet. Changed due to the types conflict resolution.
-export class StorageDataObject
+export class DataObject
   extends JoyStructDecorated({
     accepted: bool,
     deletion_prize: BalanceOf,
     size: u64,
   })
-  implements IStorageDataObject {}
+  implements IDataObject {}
 
 export class DataObjectIdSet extends JoyBTreeSet(DataObjectId) {}
 export class DistributionBucketId extends u64 {}
@@ -55,7 +54,7 @@ export class DynamicBagDeletionPrize
 export class DynamicBagDeletionPrizeRecord extends DynamicBagDeletionPrize {}
 
 export type IBag = {
-  objects: BTreeMap<DataObjectId, StorageDataObject>
+  objects: BTreeMap<DataObjectId, DataObject>
   stored_by: StorageBucketIdSet
   distributed_by: DistributionBucketSet
   deletion_prize: Option<BalanceOf>
@@ -63,7 +62,7 @@ export type IBag = {
 
 export class Bag
   extends JoyStructDecorated({
-    objects: BTreeMap.with(DataObjectId, StorageDataObject),
+    objects: BTreeMap.with(DataObjectId, DataObject),
     stored_by: StorageBucketIdSet,
     distributed_by: DistributionBucketSet,
     deletion_prize: Option.with(BalanceOf),
@@ -237,7 +236,7 @@ export const storageTypes: RegistryTypes = {
   ContentIdSet,
   Cid,
   StorageBucketOperatorStatus,
-  StorageDataObject,
+  DataObject,
   DistributionBucketId,
   DistributionBucketFamilyId,
   DistributionBucket,

Some files were not shown because too many files changed in this diff