Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a451f7e
add developer-hub and all things related
kianenigma Oct 31, 2023
68a053b
fix some things
kianenigma Oct 31, 2023
f7460d8
small fixes
kianenigma Oct 31, 2023
b785e5c
Create docs.yml
kianenigma Oct 31, 2023
00a0fec
Update docs.yml
kianenigma Oct 31, 2023
50c78b4
fix some warnings
kianenigma Oct 31, 2023
89e00e9
Merge branch 'kiz-developer-hub' of github.com:kianenigma/polkadot-sd…
kianenigma Oct 31, 2023
c91250b
fix some warnings
kianenigma Oct 31, 2023
6d57d2e
fix warns
kianenigma Oct 31, 2023
76f2277
update
kianenigma Nov 1, 2023
08802f8
fix
kianenigma Nov 2, 2023
2ec4541
publish note
kianenigma Nov 2, 2023
a826834
fix
kianenigma Nov 2, 2023
8e2f6b8
Master.into()
kianenigma Nov 2, 2023
df2d645
Merge branch 'master' of github.com:paritytech/polkadot-sdk into kiz-…
liamaharon Nov 3, 2023
58d60cb
fix build
liamaharon Nov 3, 2023
c8f7f1e
default page developer hub
liamaharon Nov 3, 2023
198a3e6
Master.into()
kianenigma Nov 4, 2023
bcdc9d5
add lot of ref docs
kianenigma Nov 4, 2023
4664874
Merge branch 'kiz-developer-hub' of github.com:paritytech/polkadot-sd…
kianenigma Nov 4, 2023
d542ff1
Update substrate/frame/support/procedural/src/pallet/parse/call.rs
kianenigma Nov 4, 2023
2f76ba1
Update developer-hub/src/lib.rs
kianenigma Nov 4, 2023
00ec677
Update developer-hub/src/lib.rs
kianenigma Nov 4, 2023
9b1db8c
Update docs/mermaid/polkadot_sdk.mmd
kianenigma Nov 4, 2023
7dba4f8
Update developer-hub/src/polkadot_sdk/mod.rs
kianenigma Nov 4, 2023
3519a03
Update developer-hub/src/reference_docs/wasm_meta_protocol.rs
kianenigma Nov 4, 2023
0d72dd7
Apply suggestions from code review
kianenigma Nov 4, 2023
9942120
Apply suggestions from code review
kianenigma Nov 4, 2023
60a37a1
Upstream.into()
kianenigma Nov 4, 2023
1896ac7
reword templates page.
kianenigma Nov 4, 2023
30d6ac2
repot homepage
kianenigma Nov 4, 2023
a56d3b1
rework substrate dev section
kianenigma Nov 4, 2023
641ff3a
fix cumulus links
kianenigma Nov 4, 2023
3baa30c
Apply extrinsic-encoding ref doc suggestions
jsdw Nov 7, 2023
9c2b3ea
Apply singed-extensions ref doc suggestion
jsdw Nov 7, 2023
62b69fc
add about build
kianenigma Nov 9, 2023
4c8939b
most of the stuff done in polkadot_sdk mod
kianenigma Nov 9, 2023
7b225e1
Apply suggestions from code review
kianenigma Nov 9, 2023
0f55b9a
Update developer-hub/src/polkadot_sdk/cumulus.rs
kianenigma Nov 9, 2023
d08ab24
Update developer-hub/src/polkadot_sdk/cumulus.rs
kianenigma Nov 9, 2023
b9ee9c1
ready to merge
kianenigma Nov 9, 2023
a873808
merge about half a million comments and conflicts
kianenigma Nov 9, 2023
2d5814b
Master.into()
kianenigma Nov 9, 2023
94eeed6
deprecate tutorial
kianenigma Nov 9, 2023
80d4e9e
add missing glossary
juangirini Nov 10, 2023
24ba435
add pvf to the glossary
juangirini Nov 14, 2023
745c7fd
refactor tutorial to guides
juangirini Nov 14, 2023
d305146
fix fmt
juangirini Nov 14, 2023
1d1e4a0
Merge branch 'master' into kiz-developer-hub
juangirini Nov 14, 2023
74eb750
resolve import conflict
juangirini Nov 14, 2023
36baa71
fix ci
juangirini Nov 14, 2023
8defde9
fix ui tests
juangirini Nov 14, 2023
7c839fe
fix ui test
juangirini Nov 14, 2023
196d1d7
remove unused imports
juangirini Nov 15, 2023
f3b1b5b
Merge branch 'master' into kiz-developer-hub
juangirini Nov 15, 2023
0428686
Merge branch 'kiz-developer-hub' into jg/developer-hub-glossary-ref-docs
juangirini Nov 15, 2023
0235ee4
improve glossary
juangirini Nov 15, 2023
239c3a6
add suggested modifications
juangirini Nov 24, 2023
58fb40f
improve Validators definition
juangirini Nov 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
deprecate tutorial
  • Loading branch information
kianenigma committed Nov 9, 2023
commit 94eeed60830808c3e1d1c8043c49cd6af20b18ce
2 changes: 1 addition & 1 deletion developer-hub/src/guides/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Polkadot SDK. They common user-journeys that are traversed in the Polkadot ecosystem.

/// Write your first simple pallet, learning the most most basic features of FRAME along the way.
pub mod writing_your_first_pallet;
pub mod your_first_pallet;

/// Writing your first real [runtime](`crate::reference_docs::wasm_meta_protocol`), and successfully
/// compiling it to [WASM](crate::polkadot_sdk::substrate#wasm-build).
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! # Currency Pallet
//!
//! By the end of this tutorial, you will write a small FRAME pallet (see
//! By the end of this guide, you will write a small FRAME pallet (see
//! [`crate::polkadot_sdk::frame_runtime`]) that is capable of handling a simple crypto-currency.
//! This pallet will:
//!
Expand All @@ -9,14 +9,14 @@
//! 2. Allow any user that owns tokens to transfer them to others.
//! 3. Track the total issuance of all tokens at all times.
//!
//! > This tutorial will build a currency pallet from scratch using only the lowest primitives of
//! > This guide will build a currency pallet from scratch using only the lowest primitives of
//! > FRAME, and is mainly intended for education, not *applicability*. For example, almost all
//! > FRAME-based runtimes use various techniques to re-use a currency pallet instead of writing
//! > one. Further advance FRAME related topics are discussed in [`crate::reference_docs`].
//!
//! ## Topics Covered
//!
//! The following FRAME topics are covered in this tutorial. See the documentation of the
//! The following FRAME topics are covered in this guide. See the documentation of the
//! associated items to know more.
//!
//! - [Storage](frame::pallet_macros::storage)
Expand All @@ -28,7 +28,7 @@
//!
//! ## Writing Your First Pallet
//!
//! You should have studied the following modules as a prelude to this tutorial:
//! You should have studied the following modules as a prelude to this guide:
//!
//! - [`crate::reference_docs::blockchain_state_machines`]
//! - [`crate::reference_docs::trait_based_programming`]
Expand All @@ -42,7 +42,7 @@
//! [`pallet::config`](frame::pallet_macros::config) and
//! [`pallet::pallet`](frame::pallet_macros::pallet) are both mandatory parts of any pallet. Refer
//! to the documentation of each to get an overview of what they do.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", shell_pallet)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", shell_pallet)]
//!
//! ### Storage
//!
Expand All @@ -51,19 +51,19 @@
//! One should be a mapping from account-ids to a balance type, and one value that is the total
//! issuance.
//
// For the rest of this tutorial, we will opt for a balance type of u128.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", Balance)]
// For the rest of this guide, we will opt for a balance type of u128.
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Balance)]
//!
//! The definition of these two storage items, based on [`frame::pallet_macros::storage`] details,
//! is as follows:
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", TotalIssuance)]
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", Balances)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", TotalIssuance)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Balances)]
//!
//! ### Dispatchables
//!
//! Next, we will define the dispatchable functions. As per [`frame::pallet_macros::call`], these
//! will be defined as normal `fn`s attached to `struct Pallet`.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", impl_pallet)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", impl_pallet)]
//!
//! The logic of the functions is self-explanatory. Instead, we will focus on the FRAME-related
//! details:
Expand Down Expand Up @@ -102,14 +102,14 @@
//! How we handle error in the above snippets is fairly rudimentary. Let's look at how this can be
//! improved. First, we can use [`frame::prelude::ensure`] to express the error slightly better.
//! This macro will call `.into()` under the hood.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", transfer_better)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", transfer_better)]
//!
//! Moreover, you will learn in the [Safe Defensive Programming
//! section](crate::reference_docs::safe_defensive_programming) that it is always recommended to use
//! safe arithmetic operations in your runtime. By using [`frame::traits::CheckedSub`], we can not
//! only take a step in that direction, but also improve the error handing and make it slightly more
//! ergonomic.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", transfer_better_checked)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", transfer_better_checked)]
//!
//! This is more or less all the logic that there is this basic currency pallet!
//!
Expand All @@ -120,7 +120,7 @@
//! through [`frame::runtime::prelude::construct_runtime`]. All runtimes also have to include
//! [`frame::prelude::frame_system`]. So we expect to see a runtime with two pallet, `frame_system`
//! and the one we just wrote.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", runtime)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", runtime)]
//!
//! > [`frame::pallet_macros::derive_impl`] is a FRAME feature that enables developers to have
//! > defaults for associated types.
Expand Down Expand Up @@ -157,7 +157,7 @@
//! to learn is that all of your pallet testing code should be wrapped in
//! [`frame::testing_prelude::TestState`]. This is a type that provides access to an in-memory state
//! to be used in our tests.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", first_test)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", first_test)]
//!
//! In the first test, we simply assert that there is no total issuance, and no balance associated
//! with account `1`. Then, we mint some balance into `1`, and re-check.
Expand All @@ -183,16 +183,16 @@
//!
//! Let's see how we can implement a better test setup using this pattern. First, we define a
//! `struct StateBuilder`.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", StateBuilder)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", StateBuilder)]
//!
//! This struct is meant to contain the same list of accounts and balances that we want to have at
//! the beginning of each block. We hardcoded this to `let accounts = vec![(1, 100), (2, 100)];` so
//! far. Then, if desired, we attach a default value for this struct.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", default_state_builder)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", default_state_builder)]
//!
//! Like any other builder pattern, we attach functions to the type to mutate its internal
//! properties.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", impl_state_builder_add)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", impl_state_builder_add)]
//!
//! Finally --the useful part-- we write our own custom `build_and_execute` function on
//! this type. This function will do multiple things:
Expand All @@ -204,23 +204,23 @@
//! after each test. For example, in this test, we do some additional checking about the
//! correctness of the `TotalIssuance`. We leave it up to you as an exercise to learn why the
//! assertion should always hold, and how it is checked.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", impl_state_builder_build)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", impl_state_builder_build)]
//!
//! We can write tests that specifically check the initial state, and making sure our `StateBuilder`
//! is working exactly as intended.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", state_builder_works)]
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", state_builder_add_balance)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", state_builder_works)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", state_builder_add_balance)]
//!
//! ### More Tests
//!
//! Now that we have a more ergonomic test setup, let's see how a well written test for transfer and
//! mint would look like.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", transfer_works)]
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", mint_works)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", transfer_works)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", mint_works)]
//!
//! It is always a good idea to build a mental model where you write *at least* one test for each
//! "success path" of a dispatchable, and one test for each "failure path", such as:
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", transfer_from_non_existent_fails)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", transfer_from_non_existent_fails)]
//!
//! We leave it up to you to write a test that triggers to `InsufficientBalance` error.
//!
Expand Down Expand Up @@ -249,8 +249,8 @@
//! With the explanation out of the way, let's see how these components can be added. Both follow a
//! fairly familiar syntax: normal Rust enums, with an extra `#[frame::event/error]` attribute
//! attached.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", Event)]
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", Error)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Event)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Error)]
//!
//! One slightly custom part of this is the `#[pallet::generate_deposit(pub(super) fn
//! deposit_event)]` part. Without going into too much detail, in order for a pallet to emit events
Expand All @@ -264,22 +264,22 @@
//!
//! 2. But, doing this conversion and storing is too much to expect each pallet to define. FRAME
//! provides a default way of storing events, and this is what `pallet::generate_deposit` is doing.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", config_v2)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", config_v2)]
//!
//! > These `Runtime*` types are better explained in
//! > [`crate::reference_docs::frame_composite_enums`].
//!
//! Then, we can rewrite the `transfer` dispatchable as such:
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", transfer_v2)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", transfer_v2)]
//!
//! Then, notice how now we would need to provide this `type RuntimeEvent` in our test runtime
//! setup.
#![doc = docify::embed!("./src/tutorial/currency_simple/mod.rs", runtime_v2)]
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", runtime_v2)]
//!
//! In this snippet, the actual `RuntimeEvent` type (right hand side of `type RuntimeEvent =
//! RuntimeEvent`) is generated by `construct_runtime`. An interesting way to inspect this type is
//! to see its definition in rust-docs:
//! [`crate::tutorial::currency_simple::pallet_v2::tests::runtime_v2::RuntimeEvent`].
//! [`crate::guides::your_first_pallet::pallet_v2::tests::runtime_v2::RuntimeEvent`].
//!
//!
//!
Expand Down Expand Up @@ -411,15 +411,15 @@ pub mod pallet {

#[cfg(any(test, doc))]
pub(crate) mod tests {
use crate::tutorial::currency_simple::pallet::*;
use crate::guides::your_first_pallet::pallet::*;
use frame::testing_prelude::*;

#[docify::export]
mod runtime {
use super::*;
// we need to reference our `mod pallet` as an identifier to pass to
// `construct_runtime`.
use crate::tutorial::currency_simple::pallet as pallet_currency;
use crate::guides::your_first_pallet::pallet as pallet_currency;

construct_runtime!(
pub struct Runtime {
Expand Down Expand Up @@ -689,7 +689,7 @@ pub mod pallet_v2 {
#[docify::export]
pub mod runtime_v2 {
use super::*;
use crate::tutorial::currency_simple::pallet_v2 as pallet_currency;
use crate::guides::your_first_pallet::pallet_v2 as pallet_currency;

construct_runtime!(
pub struct Runtime {
Expand Down
9 changes: 3 additions & 6 deletions developer-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@
/// how one can contribute to it.
pub mod meta_contributing;

/// In-depth guides about the most common components of the Polkadot SDK. They are slightly more
/// high level and broad than reference docs.
pub mod guides;
/// An introduction to the Polkadot SDK. Read this module to learn about the structure of the SDK,
/// the tools that are provided as a part of it, and to gain a high level understanding of each.
pub mod polkadot_sdk;
/// Reference documents covering in-depth topics across the Polkadot SDK. It is suggested to read
/// these on-demand, while you are going through the [`guides`] or other content.
pub mod reference_docs;
/// In-depth guides about the most common components of the Polkadot SDK. They are slightly more
/// high level and broad than reference docs.
pub mod guides;

// TODO: Deprecated, should remove
pub mod tutorial;
2 changes: 1 addition & 1 deletion developer-hub/src/meta_contributing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
//!
//! To build this crate properly, with with right HTML headers injected, run:
//!
//! ```
//! ```no_compile
//! RUSTDOCFLAGS="--html-in-header $(pwd)/developer-hub/headers/toc.html" cargo doc -p developer-hub
//! ```
//!
Expand Down
12 changes: 7 additions & 5 deletions developer-hub/src/polkadot_sdk/cumulus.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! # Cumulus
//!
//! Substrate provides a framework ([FRAME]) through which a blockchain node and runtime can easily be
//! created. Cumulus aims to extend the same approach to creation of Polkadot parachains.
//! Substrate provides a framework ([FRAME]) through which a blockchain node and runtime can easily
//! be created. Cumulus aims to extend the same approach to creation of Polkadot parachains.
//!
//! > Cumulus clouds are shaped sort of like dots; together they form a system that is intricate,
//! > beautiful and functional.
Expand All @@ -14,7 +14,8 @@
//!
//! #### Cumulus Pallets
//!
//! A parachain runtime should use a number of pallets that are provided by Cumulus and Substrate. Notably:
//! A parachain runtime should use a number of pallets that are provided by Cumulus and Substrate.
//! Notably:
//!
//! - [`frame-system`](frame::prelude::frame_system), like all FRAME-based runtimes.
//! - [`cumulus_pallet_parachain_system`]
Expand Down Expand Up @@ -82,9 +83,8 @@ mod tests {
type OnSystemEvent = ();
type SelfParaId = parachain_info::Pallet<Runtime>;
type OutboundXcmpMessageSource = ();
type DmpMessageHandler = ();
type ReservedDmpWeight = ();
type XcmpMessageHandler = ();
type ReservedDmpWeight = ();
type ReservedXcmpWeight = ();
type CheckAssociatedRelayNumber =
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
Expand All @@ -94,6 +94,8 @@ mod tests {
1,
1,
>;
type WeightInfo = ();
type DmpQueue = frame::traits::EnqueueWithOrigin<(), sp_core::ConstU8<0>>;
}

impl parachain_info::Config for Runtime {}
Expand Down
11 changes: 5 additions & 6 deletions developer-hub/src/polkadot_sdk/frame_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@
//! a valid Runtime form the point of view of a Substrate client (see
//! [`crate::reference_docs::wasm_meta_protocol`]). Notable examples are:
//!
//! * writing a runtime in pure Rust, as done in [this
//! template](https://github.com/JoshOrndorff/frameless-node-template).
//! * writing a runtime in AssemblyScript,as explored in [this
//! project](https://github.com/LimeChain/subsembly).
//! * writing a runtime in pure Rust, as done in [this template](https://github.com/JoshOrndorff/frameless-node-template).
//! * writing a runtime in AssemblyScript,as explored in [this project](https://github.com/LimeChain/subsembly).

#[cfg(test)]
mod tests {
Expand Down Expand Up @@ -142,7 +140,8 @@ mod tests {
/// This will be callable by external users, and has two u32s as a parameter.
pub fn some_dispatchable(
_origin: OriginFor<T>,
_param: u32, _other_para: u32
_param: u32,
_other_para: u32,
) -> DispatchResult {
Ok(())
}
Expand All @@ -157,7 +156,7 @@ mod tests {
use super::pallet as pallet_example;
use frame::{prelude::*, testing_prelude::*};

/// The major macro that amalgamates pallets into `struct Runtime`
// The major macro that amalgamates pallets into `struct Runtime`
construct_runtime!(
pub struct Runtime {
System: frame_system,
Expand Down
4 changes: 0 additions & 4 deletions developer-hub/src/polkadot_sdk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
//! runtimes are located under the
//! [`polkadot-fellows/runtimes`](https://github.com/polkadot-fellows/runtimes) repository.
//!
//! > [`polkadot`] module contains useful links to further learn about Polkadot, **but is in general
//! > not part of the SDK**, as it is rarely used by developers who wish to build on top of
//! > Polkadot.
//!
//! ### Summary
//!
//! The following diagram summarizes how some of the components of Polkadot SDK work together:
Expand Down
8 changes: 0 additions & 8 deletions developer-hub/src/tutorial/mod.rs

This file was deleted.