Browse Source

content-directory: NewAsset::Urls

Mokhtar Naamani 4 years ago
parent
commit
59a7b3ca3f

+ 4 - 0
runtime-modules/common/src/lib.rs

@@ -14,6 +14,7 @@ use serde::{Deserialize, Serialize};
 use frame_support::Parameter;
 use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerialize, Member};
+use sp_std::vec::Vec;
 
 /// Member id type alias
 pub type MemberId<T> = <T as MembershipTypes>::MemberId;
@@ -21,6 +22,9 @@ pub type MemberId<T> = <T as MembershipTypes>::MemberId;
 /// Actor id type alias
 pub type ActorId<T> = <T as MembershipTypes>::ActorId;
 
+/// HTTP Url string
+pub type Url = Vec<u8>;
+
 /// Generic trait for membership dependent pallets.
 pub trait MembershipTypes: system::Trait {
     /// Describes the common type for the members.

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

@@ -31,7 +31,7 @@ use system::ensure_signed;
 pub use common::storage::{ContentParameters, StorageSystem};
 pub use common::{
     currency::{BalanceOf, GovernanceCurrency},
-    MembershipTypes, StorageOwnership,
+    MembershipTypes, StorageOwnership, Url,
 };
 
 pub(crate) type ContentId<T> = <T as StorageOwnership>::ContentId;
@@ -114,8 +114,8 @@ pub trait Trait:
 pub enum NewAsset<ContentParameters> {
     /// Upload to the storage system
     Upload(ContentParameters),
-    /// A url string pointing at an asset
-    Uri(Vec<u8>),
+    /// Multiple url strings pointing at an asset
+    Urls(Vec<Url>),
 }
 
 /// The owner of a channel, is the authorized "actor" that can update

+ 2 - 1
runtime-modules/service-discovery/Cargo.toml

@@ -12,6 +12,7 @@ frame-support = { package = 'frame-support', default-features = false, git = 'ht
 system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
+common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 [dev-dependencies]
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
@@ -23,7 +24,6 @@ stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
 recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'}
-common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 [features]
 default = ['std']
@@ -35,4 +35,5 @@ std = [
 	'system/std',
 	'sp-runtime/std',
 	'working-group/std',
+	'common/std'
 ]

+ 2 - 3
runtime-modules/service-discovery/src/lib.rs

@@ -23,6 +23,8 @@ mod mock;
 mod tests;
 
 use codec::{Decode, Encode};
+use common::Url;
+
 #[cfg(feature = "std")]
 use serde::{Deserialize, Serialize};
 
@@ -45,9 +47,6 @@ use system::ensure_root;
 /// base58 encoded IPNS identity multihash codec
 pub type IPNSIdentity = Vec<u8>;
 
-/// HTTP Url string to a discovery service endpoint
-pub type Url = Vec<u8>;
-
 // The storage working group instance alias.
 pub(crate) type StorageWorkingGroupInstance = working_group::Instance2;
 

+ 3 - 0
types/src/common.ts

@@ -44,6 +44,8 @@ export function JoyBTreeSet<V extends UInt>(valType: Constructor<V>): Constructo
   }
 }
 
+export class Url extends Text {}
+
 export class ChannelId extends u64 {}
 export class DAOId extends u64 {}
 
@@ -151,6 +153,7 @@ export const commonTypes: RegistryTypes = {
   LookupSource,
   ChannelId,
   DAOId,
+  Url,
 }
 
 export default commonTypes

+ 3 - 3
types/src/content/index.ts

@@ -1,7 +1,7 @@
-import { Text, Vec, Option, Tuple } from '@polkadot/types'
+import { Vec, Option, Tuple } from '@polkadot/types'
 import { bool, u64, u32, u128, Null, Bytes } from '@polkadot/types/primitive'
 import { MemberId } from '../members'
-import { JoyStructDecorated, JoyEnum, ChannelId, JoyBTreeSet, DAOId } from '../common'
+import { JoyStructDecorated, JoyEnum, ChannelId, JoyBTreeSet, DAOId, Url } from '../common'
 import { ContentParameters } from '../storage'
 
 export class CuratorId extends u64 {}
@@ -165,7 +165,7 @@ export class PersonActor extends JoyEnum({
 
 export class NewAsset extends JoyEnum({
   Upload: ContentParameters,
-  Uri: Text,
+  Urls: Vec.with(Url),
 }) {}
 
 export const contentDirectoryTypes = {

+ 1 - 3
types/src/discovery.ts

@@ -1,9 +1,8 @@
-import { Text, u32 } from '@polkadot/types'
+import { u32, Text } from '@polkadot/types'
 import { RegistryTypes } from '@polkadot/types/types'
 import { JoyStructDecorated } from './common'
 
 export class IPNSIdentity extends Text {}
-export class Url extends Text {}
 
 export class ServiceProviderRecord extends JoyStructDecorated({
   identity: IPNSIdentity,
@@ -11,7 +10,6 @@ export class ServiceProviderRecord extends JoyStructDecorated({
 }) {}
 
 export const discoveryTypes: RegistryTypes = {
-  Url,
   IPNSIdentity,
   ServiceProviderRecord,
 }