primitives.rs 3.9 KB

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