primitives.rs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //! Low-level types used throughout the Substrate code.
  2. #![warn(missing_docs)]
  3. #![cfg_attr(not(feature = "std"), no_std)]
  4. use sp_runtime::{
  5. traits::{IdentifyAccount, Verify},
  6. MultiSignature,
  7. };
  8. /// Priority for a transaction. Additive. Higher is better.
  9. pub type TransactionPriority = u64;
  10. /// Alias for ContentId, used in various places.
  11. pub type ContentId = sp_core::H256;
  12. /// Alias for DAOId, used in various places.
  13. pub type DAOId = u64;
  14. /// Alias for DataObjectTypeId, used in various places.
  15. pub type DataObjectTypeId = u64;
  16. /// An index to a block.
  17. pub type BlockNumber = u32;
  18. /// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
  19. pub type Signature = MultiSignature;
  20. /// Some way of identifying an account on the chain. We intentionally make it equivalent
  21. /// to the public key of our transaction signing scheme.
  22. pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
  23. /// The type for looking up accounts. We don't expect more than 4 billion of them, but you
  24. /// never know...
  25. pub type AccountIndex = u32;
  26. /// Balance of an account.
  27. pub type Balance = u128;
  28. /// Index of a transaction in the chain.
  29. pub type Index = u32;
  30. /// A hash of some data used by the chain.
  31. pub type Hash = sp_core::H256;
  32. /// Moment type
  33. pub type Moment = u64;
  34. /// Content Directory Channel identifier.
  35. pub type ChannelId = u64;
  36. /// Content Directory Channel Category identifier.
  37. pub type ChannelCategoryId = u64;
  38. /// Content Directory Video identifier.
  39. pub type VideoId = u64;
  40. /// Content Directory Video Category identifier.
  41. pub type VideoCategoryId = u64;
  42. /// Content Directory Playlist identifier.
  43. pub type PlaylistId = u64;
  44. /// Content Directory Person identifier.
  45. pub type PersonId = u64;
  46. /// Content Directory Series identifier.
  47. pub type SeriesId = u64;
  48. /// Content Directory Channel transfer request identifier.
  49. pub type ChannelOwnershipTransferRequestId = u64;
  50. /// Represents a thread identifier for both Forum and Proposals Discussion
  51. ///
  52. /// Note: Both modules expose type names ThreadId and PostId (which are defined on their Trait) and
  53. /// used in state storage and dispatchable method's argument types,
  54. /// and are therefore part of the public API/metadata of the runtime.
  55. /// In the current version the polkadot-js/api that is used and is compatible with the runtime,
  56. /// the type registry has flat namespace and its not possible
  57. /// to register identically named types from different modules, separately. And so we MUST configure
  58. /// the underlying types to be identicaly to avoid issues with encoding/decoding these types on the client side.
  59. pub type ThreadId = u64;
  60. /// Represents a post identifier for both Forum and Proposals Discussion
  61. ///
  62. /// See the Note about ThreadId
  63. pub type PostId = u64;
  64. /// Represent an actor in membership group, which is the same in the working groups.
  65. pub type ActorId = u64;
  66. /// Represent an member in membership group, which is the same in the working groups.
  67. pub type MemberId = u64;
  68. /// App-specific crypto used for reporting equivocation/misbehavior in BABE and
  69. /// GRANDPA. Any rewards for misbehavior reporting will be paid out to this
  70. /// account.
  71. pub mod report {
  72. use super::{Signature, Verify};
  73. use frame_system::offchain::AppCrypto;
  74. use sp_core::crypto::{key_types, KeyTypeId};
  75. /// Key type for the reporting module. Used for reporting BABE and GRANDPA
  76. /// equivocations.
  77. pub const KEY_TYPE: KeyTypeId = key_types::REPORTING;
  78. mod app {
  79. use sp_application_crypto::{app_crypto, sr25519};
  80. app_crypto!(sr25519, super::KEY_TYPE);
  81. }
  82. /// Identity of the equivocation/misbehavior reporter.
  83. pub type ReporterId = app::Public;
  84. /// An `AppCrypto` type to allow submitting signed transactions using the reporting
  85. /// application key as signer.
  86. pub struct ReporterAppCrypto;
  87. impl AppCrypto<<Signature as Verify>::Signer, Signature> for ReporterAppCrypto {
  88. type RuntimeAppPublic = ReporterId;
  89. type GenericSignature = sp_core::sr25519::Signature;
  90. type GenericPublic = sp_core::sr25519::Public;
  91. }
  92. }