Skip to content
Merged
754 changes: 703 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 12 additions & 18 deletions runtime-modules/content-directory/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
[package]
name = 'substrate-content-directory-module'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename it to 'pallet-content-directory'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here 0e4cfb1

version = '1.0.1'
version = '3.0.0'
authors = ['Joystream contributors']
edition = '2018'

[dependencies]
hex-literal = '0.1.0'
codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] }
rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
timestamp = { package = 'srml-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
# https://users.rust-lang.org/t/failure-derive-compilation-error/39062
quote = '<=1.0.2'
codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
rstd = { package = 'sp-std', 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'}
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a common format for dependencies: single line based similar to parity's format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 0e4cfb1

[dependencies.serde]
features = ['derive']
optional = true
version = '1.0.101'

[dev-dependencies]
runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}

[features]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you sort feature-definitions similar to dependencies order: it's easier to check them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, 0e4cfb1

default = ['std']
std = [
'serde',
'codec/std',
'rstd/std',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename rstd to sp-std - similar to the new format in the Substrate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 0e4cfb1

'runtime-io/std',
'runtime-primitives/std',
'srml-support/std',
'sp-arithmetic/std',
'sp-runtime/std',
'frame-support/std',
'system/std',
'timestamp/std',
]
10 changes: 5 additions & 5 deletions runtime-modules/content-directory/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<T: Trait> Class<T> {
}

/// Ensure `schema_id` is a valid index of `Class` schemas vector
pub fn ensure_schema_id_exists(&self, schema_id: SchemaId) -> dispatch::Result {
pub fn ensure_schema_id_exists(&self, schema_id: SchemaId) -> DispatchResult {
ensure!(
schema_id < self.schemas.len() as SchemaId,
ERROR_UNKNOWN_CLASS_SCHEMA_ID
Expand All @@ -177,7 +177,7 @@ impl<T: Trait> Class<T> {
}

/// Ensure `Schema`s limit per `Class` not reached
pub fn ensure_schemas_limit_not_reached(&self) -> dispatch::Result {
pub fn ensure_schemas_limit_not_reached(&self) -> DispatchResult {
ensure!(
(self.schemas.len() as MaxNumber) < T::MaxNumberOfSchemasPerClass::get(),
ERROR_CLASS_SCHEMAS_LIMIT_REACHED
Expand All @@ -189,7 +189,7 @@ impl<T: Trait> Class<T> {
pub fn ensure_properties_limit_not_reached(
&self,
new_properties: &[Property<T>],
) -> dispatch::Result {
) -> DispatchResult {
ensure!(
T::MaxNumberOfPropertiesPerSchema::get()
>= (self.properties.len() + new_properties.len()) as MaxNumber,
Expand All @@ -199,7 +199,7 @@ impl<T: Trait> Class<T> {
}

/// Ensure `Class` specific entities limit not reached
pub fn ensure_maximum_entities_count_limit_not_reached(&self) -> dispatch::Result {
pub fn ensure_maximum_entities_count_limit_not_reached(&self) -> DispatchResult {
ensure!(
self.current_number_of_entities < self.maximum_entities_count,
ERROR_MAX_NUMBER_OF_ENTITIES_PER_CLASS_LIMIT_REACHED
Expand Down Expand Up @@ -232,7 +232,7 @@ impl<T: Trait> Class<T> {
}

/// Ensure property values were not locked on `Class` level
pub fn ensure_property_values_unlocked(&self) -> dispatch::Result {
pub fn ensure_property_values_unlocked(&self) -> DispatchResult {
ensure!(
!self
.get_permissions_ref()
Expand Down
8 changes: 4 additions & 4 deletions runtime-modules/content-directory/src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<T: Trait> Entity<T> {
}

/// Ensure `Schema` under given id is not added to given `Entity` yet
pub fn ensure_schema_id_is_not_added(&self, schema_id: SchemaId) -> dispatch::Result {
pub fn ensure_schema_id_is_not_added(&self, schema_id: SchemaId) -> DispatchResult {
let schema_not_added = !self.supported_schemas.contains(&schema_id);
ensure!(schema_not_added, ERROR_SCHEMA_ALREADY_ADDED_TO_THE_ENTITY);
Ok(())
Expand All @@ -114,7 +114,7 @@ impl<T: Trait> Entity<T> {
pub fn ensure_property_values_are_not_added(
&self,
property_values: &BTreeMap<PropertyId, InputPropertyValue<T>>,
) -> dispatch::Result {
) -> DispatchResult {
ensure!(
property_values
.keys()
Expand All @@ -141,7 +141,7 @@ impl<T: Trait> Entity<T> {
}

/// Ensure any `InputPropertyValue` from external entity does not point to the given `Entity`
pub fn ensure_rc_is_zero(&self) -> dispatch::Result {
pub fn ensure_rc_is_zero(&self) -> DispatchResult {
ensure!(
self.reference_counter.is_total_equal_to_zero(),
ERROR_ENTITY_RC_DOES_NOT_EQUAL_TO_ZERO
Expand All @@ -150,7 +150,7 @@ impl<T: Trait> Entity<T> {
}

/// Ensure any inbound `InputPropertyValue` with `same_owner` flag set points to the given `Entity`
pub fn ensure_inbound_same_owner_rc_is_zero(&self) -> dispatch::Result {
pub fn ensure_inbound_same_owner_rc_is_zero(&self) -> DispatchResult {
ensure!(
self.reference_counter.is_same_owner_equal_to_zero(),
ERROR_ENTITY_SAME_OWNER_RC_DOES_NOT_EQUAL_TO_ZERO
Expand Down
2 changes: 1 addition & 1 deletion runtime-modules/content-directory/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl InputValidationLengthConstraint {
len: usize,
too_short_msg: &'static str,
too_long_msg: &'static str,
) -> dispatch::Result {
) -> DispatchResult {
let length = len as u16;
if length < self.min {
Err(too_short_msg)
Expand Down
Loading