Skip to content

Commit

Permalink
More Proof of Existence Fixes (#2111)
Browse files Browse the repository at this point in the history
* Update use-macros-in-a-custom-pallet.md

* more fix

* make work with runtime with weights

* fix dead link
  • Loading branch information
shawntabrizi authored Jan 21, 2024
1 parent 4f08f21 commit 5423bee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion content/md/en/docs/build/build-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ This option is primarily used for faster compile time when you don't need to upd

## Where to go next

- [Wasm-builder README](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/utils/wasm-builder/README.md)
- [Wasm-builder source](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/utils/wasm-builder/src/lib.rs)
- [Rust compilation options](https://doc.rust-lang.org/cargo/commands/cargo-build.html#compilation-options)
- [Discussion: Removing the native runtime](https://github.com/paritytech/substrate/issues/10579)
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,18 @@ Therefore, the first step is to remove some files and content from the files in
#[pallet::storage] // <-- Step 5. code block will replace this.
#[pallet::call] // <-- Step 6. code block will replace this.
}

pub mod weights {
// Placeholder struct for the pallet weights
pub struct SubstrateWeight<T>(core::marker::PhantomData<T>);
}
```

You now have a framework that includes placeholders for _events_, _errors_, _storage_, and _callable functions_.

> NOTE: Pallet weights are outside the scope of this tutorial. If you want to learn more about weights, you can read our documentation [here](/reference/how-to-guides/weights/).

1. Save your changes.

## Configure the pallet to emit events
Expand All @@ -143,6 +151,9 @@ To define the `Config` trait for the proof-of-existence pallet:
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Pallets use weights to measure the complexity of the callable functions.
/// Configuring weights is outside the scope of this tutorial, so we will leave it empty for now.
type WeightInfo;
}
```

Expand Down Expand Up @@ -302,7 +313,7 @@ To implement this logic in the proof-of-existence pallet:

1. Save your changes and close the file.

1. Check that your code compiles by running the following command:
1. Check that your pallet compiles by running the following command:

```bash
cargo check -p pallet-template
Expand Down

0 comments on commit 5423bee

Please sign in to comment.