Browse Source

storage-node-v2: Add ‘storage bucket’ type.

Shamil Gadelshin 3 years ago
parent
commit
3b2ead8295

+ 2 - 2
storage-node-v2/src/services/runtime/extrinsics.ts

@@ -11,8 +11,8 @@ export async function createStorageBucket(
   account: KeyringPair,
   invitedWorker: number | null = null,
   allowedNewBags = true,
-  sizeLimit = 0,
-  objectsLimit = 0
+  sizeLimit: number = 0,
+  objectsLimit: number = 0
 ): Promise<boolean> {
   return await extrinsicWrapper(() => {
     const invitedWorkerValue = api.createType('Option<WorkerId>', invitedWorker)

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


+ 1 - 1
types/augment-codec/augment-api-query.ts

@@ -960,7 +960,7 @@ declare module '@polkadot/api/types/storage' {
       /**
        * Blacklisted data object hashes.
        **/
-      blacklist: AugmentedQuery<ApiType, (arg: ContentId | string | Uint8Array) => Observable<ITuple<[]>>, [ContentId]>;
+      blacklist: AugmentedQuery<ApiType, (arg: ContentId | string) => Observable<ITuple<[]>>, [ContentId]>;
       /**
        * Blacklist collection counter.
        **/

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


+ 17 - 5
types/augment/all/defs.json

@@ -552,7 +552,7 @@
         "identity": "IPNSIdentity",
         "expires_at": "u32"
     },
-    "ContentId": "[u8;32]",
+    "ContentId": "Text",
     "LiaisonJudgement": {
         "_enum": [
             "Pending",
@@ -571,7 +571,7 @@
     },
     "DataObjectStorageRelationshipId": "u64",
     "DataObjectStorageRelationship": {
-        "content_id": "ContentId",
+        "content_id": "Hash",
         "storage_provider": "StorageProviderId",
         "ready": "bool"
     },
@@ -580,7 +580,7 @@
         "description": "Text",
         "active": "bool"
     },
-    "DataObjectsMap": "BTreeMap<ContentId,DataObject>",
+    "DataObjectsMap": "BTreeMap<[u8;32],DataObject>",
     "ProposalId": "u32",
     "ProposalStatus": {
         "_enum": {
@@ -996,7 +996,12 @@
     },
     "DynamicBag": "u64",
     "StaticBag": "u64",
-    "StorageBucket": "u64",
+    "StorageBucket": {
+        "operator_status": "StorageBucketOperatorStatus",
+        "accepting_new_bags": "bool",
+        "voucher": "Voucher",
+        "metadata": "Text"
+    },
     "StaticBagId": {
         "_enum": [
             "Council",
@@ -1033,5 +1038,12 @@
     },
     "StorageBucketIdSet": "BTreeSet<StorageBucketId>",
     "DataObjectIdSet": "BTreeSet<DataObjectId>",
-    "ContentIdSet": "BTreeSet<Text>"
+    "ContentIdSet": "BTreeSet<ContentId>",
+    "StorageBucketOperatorStatus": {
+        "_enum": {
+            "Missing": "Null",
+            "InvitedStorageWorker": "u64",
+            "StorageWorker": "u64"
+        }
+    }
 }

+ 19 - 5
types/augment/all/types.ts

@@ -286,10 +286,10 @@ export interface ClassPermissionsType extends Null {}
 export interface ClassPropertyValue extends Null {}
 
 /** @name ContentId */
-export interface ContentId extends U8aFixed {}
+export interface ContentId extends Text {}
 
 /** @name ContentIdSet */
-export interface ContentIdSet extends BTreeSet<Text> {}
+export interface ContentIdSet extends BTreeSet<ContentId> {}
 
 /** @name CreateEntityOperation */
 export interface CreateEntityOperation extends Struct {
@@ -417,11 +417,11 @@ export interface DataObjectId extends u64 {}
 export interface DataObjectIdSet extends BTreeSet<DataObjectId> {}
 
 /** @name DataObjectsMap */
-export interface DataObjectsMap extends BTreeMap<ContentId, DataObject> {}
+export interface DataObjectsMap extends BTreeMap<U8aFixed, DataObject> {}
 
 /** @name DataObjectStorageRelationship */
 export interface DataObjectStorageRelationship extends Struct {
-  readonly content_id: ContentId;
+  readonly content_id: Hash;
   readonly storage_provider: StorageProviderId;
   readonly ready: bool;
 }
@@ -1255,7 +1255,12 @@ export interface StaticBagId extends Enum {
 export interface Status extends bool {}
 
 /** @name StorageBucket */
-export interface StorageBucket extends u64 {}
+export interface StorageBucket extends Struct {
+  readonly operator_status: StorageBucketOperatorStatus;
+  readonly accepting_new_bags: bool;
+  readonly voucher: Voucher;
+  readonly metadata: Text;
+}
 
 /** @name StorageBucketId */
 export interface StorageBucketId extends u64 {}
@@ -1263,6 +1268,15 @@ export interface StorageBucketId extends u64 {}
 /** @name StorageBucketIdSet */
 export interface StorageBucketIdSet extends BTreeSet<StorageBucketId> {}
 
+/** @name StorageBucketOperatorStatus */
+export interface StorageBucketOperatorStatus extends Enum {
+  readonly isMissing: boolean;
+  readonly isInvitedStorageWorker: boolean;
+  readonly asInvitedStorageWorker: u64;
+  readonly isStorageWorker: boolean;
+  readonly asStorageWorker: u64;
+}
+
 /** @name StorageBucketsPerBagValueConstraint */
 export interface StorageBucketsPerBagValueConstraint extends Struct {
   readonly min: u64;

+ 1 - 1
types/augment/augment-api-query.ts

@@ -960,7 +960,7 @@ declare module '@polkadot/api/types/storage' {
       /**
        * Blacklisted data object hashes.
        **/
-      blacklist: AugmentedQuery<ApiType, (arg: ContentId | string | Uint8Array) => Observable<ITuple<[]>>, [ContentId]>;
+      blacklist: AugmentedQuery<ApiType, (arg: ContentId | string) => Observable<ITuple<[]>>, [ContentId]>;
       /**
        * Blacklist collection counter.
        **/

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


+ 28 - 3
types/src/storage.ts

@@ -1,4 +1,4 @@
-import { Null, u64, Text, Vec, GenericAccountId as AccountId, BTreeSet } from '@polkadot/types'
+import { Null, u64, Text, Vec, bool, GenericAccountId as AccountId, BTreeSet } from '@polkadot/types'
 import { RegistryTypes } from '@polkadot/types/types'
 import { JoyBTreeSet, JoyEnum, JoyStructDecorated } from './common'
 
@@ -21,9 +21,9 @@ export class StorageBucketsPerBagValueConstraint
 export class DynamicBagId extends u64 {}
 export class DynamicBag extends u64 {}
 export class StaticBag extends u64 {}
-export class StorageBucket extends u64 {}
 //
 
+
 export type DynamicBagCreationPolicyType = {
   numberOfStorageBuckets: u64
 }
@@ -76,6 +76,30 @@ export class Voucher
   })
   implements VoucherType {}
 
+export const StorageBucketOperatorStatusDef = {
+    Missing: Null,
+    InvitedStorageWorker: u64,
+    StorageWorker: u64
+} as const
+export type StorageBucketOperatorStatusKey = keyof typeof StorageBucketOperatorStatusDef
+export class StorageBucketOperatorStatus extends JoyEnum(StorageBucketOperatorStatusDef) {}
+
+export type StorageBucketType = {
+    operator_status: StorageBucketOperatorStatus,
+    accepting_new_bags: bool,
+    voucher: Voucher,
+    metadata: Text,
+}
+
+export class StorageBucket
+    extends JoyStructDecorated({
+        operator_status: StorageBucketOperatorStatus,
+        accepting_new_bags: bool,
+        voucher: Voucher,
+        metadata: Text,
+    })
+    implements StorageBucketType {}
+
 export class StorageBucketIdSet extends JoyBTreeSet(StorageBucketId) {}
 
 export class DataObjectIdSet extends JoyBTreeSet(DataObjectId) {}
@@ -131,6 +155,7 @@ export const storageTypes: RegistryTypes = {
   StorageBucketIdSet,
   DataObjectIdSet,
   ContentIdSet,
-  ContentId
+  ContentId,
+  StorageBucketOperatorStatus
 }
 export default storageTypes

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