mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
Introduce Polkadot-Sdk developer_hub (#2102)
This PR introduces the new crate `developer_hub` into the polkadot-sdk repo. The vision for the developer-hub crate is detailed in [this document](https://docs.google.com/document/d/1XLLkFNE8v8HLvZpI2rzsa8N2IN1FcKntc8q-Sc4xBAk/edit?usp=sharing). <img width="1128" alt="Screenshot 2023-11-02 at 10 45 48" src="https://github.com/paritytech/polkadot-sdk/assets/5588131/1e12b60f-fef5-42c4-8503-a3ba234077c3"> Other than adding the new crate, it also does the following: * Remove the `substrate` crate, as there is now a unique umbrella crate for multiple things in `developer_hub::polkadot_sdk`. * (backport candidate) A minor change to `frame-support` macros that allows `T::RuntimeOrigin` to also be acceptable as the origin type. * (backport candidate) A minor change to `frame-system` that allows us to deposit events at genesis because now the real genesis config is generated via wasm, and we can safely assume `cfg!(feature = "std")` means only testing. related to #62. * (backport candidate) Introduces a small `read_events_for_pallet` to `frame_system` for easier event reading in tests. * From https://github.com/paritytech/polkadot-sdk-docs/issues/31, it takes action on improving the `pallet::call` docs. * From https://github.com/paritytech/polkadot-sdk-docs/issues/31, it takes action on improving the `UncheckedExtrinsic` docs. ## Way Forward First, a version of this is deployed temporarily [here](https://blog.kianenigma.nl/polkadot-sdk/developer_hub/index.html). I will keep it up to date on a daily basis. ### This Pull Request I see two ways forward: 1. We acknowledge that everything in `developer-hub` is going to be WIP, and merge this asap. We should not yet use links to this crate anywhere. 2. We make this be the feature branch, make PRs against this, and either gradually backport it, or only merge to master once it is done. I am personally in favor of option 1. If we stick to option 2, we need a better way to deploy a staging version of this to gh-pages. ### Issue Tracking The main issues related to the future of `developer_hub` are: - https://github.com/paritytech/polkadot-sdk-docs/issues/31 - https://github.com/paritytech/polkadot-sdk-docs/issues/4 - https://github.com/paritytech/polkadot-sdk-docs/issues/26 - https://github.com/paritytech/polkadot-sdk-docs/issues/32 - https://github.com/paritytech/polkadot-sdk-docs/issues/36 ### After This Pull Request - [ ] create a redirect for https://paritytech.github.io/polkadot-sdk/master/substrate/ - [x] analytics - [ ] link checker - [ ] the matter of publishing, and how all of these relative links for when we do, that is still an open question. There is section on this in the landing page. - [ ] updated https://paritytech.github.io/ --------- Co-authored-by: Liam Aharon <liam.aharon@hotmail.com> Co-authored-by: Juan Girini <juangirini@gmail.com> Co-authored-by: bader y <ibnbassem@gmail.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This commit is contained in:
@@ -1018,6 +1018,7 @@ impl_ensure_origin_with_arg_ignoring_arg! {
|
||||
{}
|
||||
}
|
||||
|
||||
#[docify::export]
|
||||
/// Ensure that the origin `o` represents a signed extrinsic (i.e. transaction).
|
||||
/// Returns `Ok` with the account that signed the extrinsic or an `Err` otherwise.
|
||||
pub fn ensure_signed<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<AccountId, BadOrigin>
|
||||
@@ -1372,6 +1373,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// NOTE: Events not registered at the genesis block and quietly omitted.
|
||||
pub fn deposit_event_indexed(topics: &[T::Hash], event: T::RuntimeEvent) {
|
||||
let block_number = Self::block_number();
|
||||
|
||||
// Don't populate events on genesis.
|
||||
if block_number.is_zero() {
|
||||
return
|
||||
@@ -1555,12 +1557,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// NOTE: Events not registered at the genesis block and quietly omitted.
|
||||
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
|
||||
pub fn events() -> Vec<EventRecord<T::RuntimeEvent, T::Hash>> {
|
||||
debug_assert!(
|
||||
!Self::block_number().is_zero(),
|
||||
"events not registered at the genesis block"
|
||||
);
|
||||
// Dereferencing the events here is fine since we are not in the
|
||||
// memory-restricted runtime.
|
||||
// Dereferencing the events here is fine since we are not in the memory-restricted runtime.
|
||||
Self::read_events_no_consensus().map(|e| *e).collect()
|
||||
}
|
||||
|
||||
@@ -1581,6 +1578,21 @@ impl<T: Config> Pallet<T> {
|
||||
Events::<T>::stream_iter()
|
||||
}
|
||||
|
||||
/// Read and return the events of a specific pallet, as denoted by `E`.
|
||||
///
|
||||
/// This is useful for a pallet that wishes to read only the events it has deposited into
|
||||
/// `frame_system` using the standard `fn deposit_event`.
|
||||
pub fn read_events_for_pallet<E>() -> Vec<E>
|
||||
where
|
||||
T::RuntimeEvent: TryInto<E>,
|
||||
{
|
||||
Events::<T>::get()
|
||||
.into_iter()
|
||||
.map(|er| er.event)
|
||||
.filter_map(|e| e.try_into().ok())
|
||||
.collect::<_>()
|
||||
}
|
||||
|
||||
/// Set the block number to something in particular. Can be used as an alternative to
|
||||
/// `initialize` for tests that don't need to bother with the other environment entries.
|
||||
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
|
||||
|
||||
Reference in New Issue
Block a user