lib.rs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Ensure we're `no_std` when compiling for Wasm.
  2. #![cfg_attr(not(feature = "std"), no_std)]
  3. #![recursion_limit = "256"]
  4. use core::hash::Hash;
  5. use core::ops::AddAssign;
  6. use codec::{Codec, Decode, Encode};
  7. use frame_support::storage::IterableStorageMap;
  8. use frame_support::{
  9. decl_event, decl_module, decl_storage,
  10. dispatch::{DispatchError, DispatchResult},
  11. ensure,
  12. traits::Get,
  13. Parameter,
  14. };
  15. #[cfg(feature = "std")]
  16. pub use serde::{Deserialize, Serialize};
  17. use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
  18. use sp_runtime::traits::{MaybeSerializeDeserialize, Member};
  19. use sp_std::borrow::ToOwned;
  20. use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
  21. use sp_std::vec;
  22. use sp_std::vec::Vec;
  23. use system::ensure_signed;
  24. /// Module configuration trait for this Substrate module.
  25. pub trait Trait: system::Trait + ActorAuthenticator + Clone {
  26. /// The overarching event type.
  27. type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
  28. /// Type of identifier for Videos
  29. type VideoId: Parameter
  30. + Member
  31. + BaseArithmetic
  32. + Codec
  33. + Default
  34. + Copy
  35. + Clone
  36. + Hash
  37. + MaybeSerializeDeserialize
  38. + Eq
  39. + PartialEq
  40. + Ord;
  41. /// Type of identifier for Channels
  42. type ChannelId: Parameter
  43. + Member
  44. + BaseArithmetic
  45. + Codec
  46. + Default
  47. + Copy
  48. + Clone
  49. + Hash
  50. + MaybeSerializeDeserialize
  51. + Eq
  52. + PartialEq
  53. + Ord;
  54. // Security/configuration constraints
  55. /// The maximum number of curators per group constraint
  56. type MaxNumberOfCuratorsPerGroup: Get<MaxNumber>;
  57. }
  58. decl_storage! {
  59. trait Store for Module<T: Trait> as Content {
  60. }
  61. }
  62. decl_module! {
  63. pub struct Module<T: Trait> for enum Call where origin: T::Origin {
  64. /// Predefined errors
  65. type Error = Error<T>;
  66. /// Initializing events
  67. fn deposit_event() = default;
  68. }
  69. }
  70. impl<T: Trait> Module<T> {
  71. }
  72. decl_event!(
  73. pub enum Event<T>
  74. where
  75. CuratorGroupId = <T as ActorAuthenticator>::CuratorGroupId,
  76. CuratorId = <T as ActorAuthenticator>::CuratorId,
  77. {
  78. }
  79. );
  80. decl_error! {
  81. /// Content directory errors
  82. pub enum Error for Module<T: Trait> {
  83. }
  84. }