lib.rs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Ensure we're `no_std` when compiling for Wasm.
  2. #![cfg_attr(not(feature = "std"), no_std)]
  3. pub mod constraints;
  4. pub mod council;
  5. pub mod currency;
  6. pub mod membership;
  7. pub mod storage;
  8. pub mod working_group;
  9. use codec::{Codec, Decode, Encode};
  10. #[cfg(feature = "std")]
  11. use serde::{Deserialize, Serialize};
  12. use frame_support::traits::LockIdentifier;
  13. use frame_support::Parameter;
  14. pub use membership::{ActorId, MemberId, MembershipTypes, StakingAccountValidator};
  15. use sp_arithmetic::traits::BaseArithmetic;
  16. use sp_runtime::traits::{MaybeSerialize, Member};
  17. use sp_std::collections::btree_set::BTreeSet;
  18. use sp_std::vec::Vec;
  19. /// HTTP Url string
  20. pub type Url = Vec<u8>;
  21. pub type AssetUrls = Vec<Url>;
  22. /// Generic trait for strorage ownership dependent pallets.
  23. pub trait StorageOwnership {
  24. /// Channel id representation.
  25. type ChannelId: Parameter
  26. + Member
  27. + BaseArithmetic
  28. + Codec
  29. + Default
  30. + Copy
  31. + MaybeSerialize
  32. + Ord
  33. + PartialEq;
  34. /// Content id representation.
  35. type ContentId: Parameter + Member + Codec + Default + Copy + MaybeSerialize + Ord + PartialEq;
  36. /// Data object type id.
  37. type DataObjectTypeId: Parameter
  38. + Member
  39. + BaseArithmetic
  40. + Codec
  41. + Default
  42. + Copy
  43. + MaybeSerialize
  44. + Ord
  45. + PartialEq;
  46. }
  47. /// Defines time in both block number and substrate time abstraction.
  48. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  49. #[derive(Clone, Encode, Decode, PartialEq, Eq, Debug, Default)]
  50. pub struct BlockAndTime<BlockNumber, Moment> {
  51. /// Defines chain block
  52. pub block: BlockNumber,
  53. /// Defines time
  54. pub time: Moment,
  55. }
  56. /// Parameters for the 'Funding Request' proposal.
  57. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  58. #[derive(Encode, Decode, Clone, PartialEq, Debug, Eq)]
  59. pub struct FundingRequestParameters<Balance, AccountId> {
  60. /// Single reciever account of funding request
  61. pub account: AccountId,
  62. /// Amount of funds the account will recieve
  63. pub amount: Balance,
  64. }
  65. /// Kind of Balance for `Update Working Group Budget`.
  66. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  67. #[derive(Encode, Decode, Clone, Copy, PartialEq, Debug, Eq)]
  68. pub enum BalanceKind {
  69. /// Increasing Working Group budget decreasing Council budget
  70. Positive,
  71. /// Decreasing Working Group budget increasing Council budget
  72. Negative,
  73. }
  74. /// Gathers current block and time information for the runtime.
  75. /// If this function is used inside a config() at genesis the timestamp will be 0
  76. /// because the timestamp is actually produced by validators.
  77. pub fn current_block_time<T: frame_system::Trait + pallet_timestamp::Trait>(
  78. ) -> BlockAndTime<T::BlockNumber, T::Moment> {
  79. BlockAndTime {
  80. block: <frame_system::Module<T>>::block_number(),
  81. time: <pallet_timestamp::Module<T>>::now(),
  82. }
  83. }
  84. /// Provides allowed locks combination for the accounts.
  85. pub trait AllowedLockCombinationProvider {
  86. /// Return allowed locks combination set.
  87. fn get_allowed_lock_combinations() -> BTreeSet<(LockIdentifier, LockIdentifier)>;
  88. }