fix: Complete snowbridge pezpallet rebrand and critical bug fixes

- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs)
- pallet/ directories → pezpallet/ (4 locations)
- Fixed pezpallet.rs self-include recursion bug
- Fixed sc-chain-spec hardcoded crate name in derive macro
- Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API)
- Added BizinikiwiConfig type alias for zombienet tests
- Deleted obsolete session state files

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
2025-12-16 09:57:23 +03:00
parent 7fce5a2472
commit 90fd044766
3019 changed files with 41780 additions and 24101 deletions
+110
View File
@@ -0,0 +1,110 @@
# Rebrand İlerleme Listesi
**Başlangıç:** 2025-12-15
**Toplam Crate:** 76 (REBRAND_MAP'ten)
## Durum Açıklamaları
- ⏳ Bekliyor
- 🔍 Taranıyor
- 🔧 Düzeltiliyor
- ✅ Tamamlandı (cargo check passed)
- ❌ Hatalı
---
## İlerleme Tablosu
| # | Eski İsim | Yeni İsim | Durum | Notlar |
|---|-----------|-----------|-------|--------|
| 1 | asset-test-utils | asset-test-pezutils | ✅ | Temiz, cargo check passed |
| 2 | chain-spec-guide-runtime | pez-chain-spec-guide-runtime | ✅ | Temiz, cargo check passed |
| 3 | equivocation-detector | pez-equivocation-detector | ✅ | Temiz, cargo check passed |
| 4 | erasure-coding-fuzzer | pez-erasure-coding-fuzzer | ✅ | İsim düzeltildi, cargo check passed |
| 5 | ethereum-standards | pez-ethereum-standards | ✅ | Temiz, cargo check passed |
| 6 | finality-relay | pez-finality-relay | ✅ | Temiz + bridges→pezbridges dizin rebrand |
| 7 | fork-tree | pez-fork-tree | ✅ | Temiz, cargo check passed |
| 8 | generate-bags | pez-generate-bags | ✅ | Temiz, cargo check passed |
| 9 | kitchensink-runtime | pez-kitchensink-runtime | ⏳ | |
| 10 | messages-relay | pez-messages-relay | ⏳ | |
| 11 | minimal-template-node | pez-minimal-template-node | ⏳ | |
| 12 | minimal-template-runtime | pez-minimal-template-runtime | ⏳ | |
| 13 | node-bench | pez-node-bench | ⏳ | |
| 14 | node-primitives | pez-node-primitives | ⏳ | |
| 15 | node-rpc | pez-node-rpc | ⏳ | |
| 16 | node-runtime-generate-bags | pez-node-runtime-generate-bags | ⏳ | |
| 17 | node-template-release | pez-node-template-release | ⏳ | |
| 18 | node-testing | pez-node-testing | ⏳ | |
| 19 | penpal-emulated-chain | pez-penpal-emulated-chain | ⏳ | |
| 20 | penpal-runtime | pez-penpal-runtime | ⏳ | |
| 21 | remote-ext-tests-bags-list | pez-remote-ext-tests-bags-list | ⏳ | |
| 22 | revive-dev-node | pez-revive-dev-node | ⏳ | |
| 23 | revive-dev-runtime | pez-revive-dev-runtime | ⏳ | |
| 24 | slot-range-helper | pez-slot-range-helper | ⏳ | |
| 25 | solochain-template-node | pez-solochain-template-node | ⏳ | |
| 26 | solochain-template-runtime | pez-solochain-template-runtime | ⏳ | |
| 27 | subkey | pez-subkey | ⏳ | |
| 28 | template-zombienet-tests | pez-template-zombienet-tests | ⏳ | |
| 29 | test-runtime-constants | peztest-runtime-constants | ⏳ | |
| 30 | tracing-gum | pez-tracing-gum | ⏳ | |
| 31 | tracing-gum-proc-macro | pez-tracing-gum-proc-macro | ⏳ | |
| 32 | bp-header-chain | bp-header-pez-chain | ⏳ | |
| 33 | bp-runtime | pezbp-runtime | ⏳ | |
| 34 | bridge-hub-pezkuwichain-emulated-chain | pezbridge-hub-pezkuwichain-emulated-chain | ⏳ | |
| 35 | bridge-hub-pezkuwichain-integration-tests | pezbridge-hub-pezkuwichain-integration-tests | ⏳ | |
| 36 | bridge-hub-pezkuwichain-runtime | pezbridge-hub-pezkuwichain-runtime | ⏳ | |
| 37 | bridge-hub-test-utils | pezbridge-hub-test-utils | ⏳ | |
| 38 | bridge-hub-zagros-emulated-chain | pezbridge-hub-zagros-emulated-chain | ⏳ | |
| 39 | bridge-hub-zagros-integration-tests | pezbridge-hub-zagros-integration-tests | ⏳ | |
| 40 | bridge-hub-zagros-runtime | pezbridge-hub-zagros-runtime | ⏳ | |
| 41 | bridge-runtime-common | pezbridge-runtime-common | ⏳ | |
| 42 | mmr-gadget | pezmmr-gadget | ⏳ | |
| 43 | mmr-rpc | pezmmr-rpc | ⏳ | |
| 44 | snowbridge-beacon-primitives | pezsnowbridge-beacon-primitives | ⏳ | |
| 45 | snowbridge-core | pezsnowbridge-core | ⏳ | |
| 46 | snowbridge-ethereum | pezsnowbridge-ethereum | ⏳ | |
| 47 | snowbridge-inbound-queue-primitives | pezsnowbridge-inbound-queue-primitives | ⏳ | |
| 48 | snowbridge-merkle-tree | pezsnowbridge-merkle-tree | ⏳ | |
| 49 | snowbridge-outbound-queue-primitives | pezsnowbridge-outbound-queue-primitives | ⏳ | |
| 50 | snowbridge-outbound-queue-runtime-api | pezsnowbridge-outbound-queue-runtime-api | ⏳ | |
| 51 | snowbridge-outbound-queue-v2-runtime-api | pezsnowbridge-outbound-queue-v2-runtime-api | ⏳ | |
| 52 | snowbridge-pezpallet-ethereum-client | pezsnowbridge-pezpallet-ethereum-client | ⏳ | |
| 53 | snowbridge-pezpallet-ethereum-client-fixtures | pezsnowbridge-pezpallet-ethereum-client-fixtures | ⏳ | |
| 54 | snowbridge-pezpallet-inbound-queue | pezsnowbridge-pezpallet-inbound-queue | ⏳ | |
| 55 | snowbridge-pezpallet-inbound-queue-fixtures | pezsnowbridge-pezpallet-inbound-queue-fixtures | ⏳ | |
| 56 | snowbridge-pezpallet-inbound-queue-v2 | pezsnowbridge-pezpallet-inbound-queue-v2 | ⏳ | |
| 57 | snowbridge-pezpallet-inbound-queue-v2-fixtures | pezsnowbridge-pezpallet-inbound-queue-v2-fixtures | ⏳ | |
| 58 | snowbridge-pezpallet-outbound-queue | pezsnowbridge-pezpallet-outbound-queue | ⏳ | |
| 59 | snowbridge-pezpallet-outbound-queue-v2 | pezsnowbridge-pezpallet-outbound-queue-v2 | ⏳ | |
| 60 | snowbridge-pezpallet-system | pezsnowbridge-pezpallet-system | ⏳ | |
| 61 | snowbridge-pezpallet-system-frontend | pezsnowbridge-pezpallet-system-frontend | ⏳ | |
| 62 | snowbridge-pezpallet-system-v2 | pezsnowbridge-pezpallet-system-v2 | ⏳ | |
| 63 | snowbridge-runtime-common | pezsnowbridge-runtime-common | ⏳ | |
| 64 | snowbridge-runtime-test-common | pezsnowbridge-runtime-test-common | ⏳ | |
| 65 | snowbridge-system-runtime-api | pezsnowbridge-system-runtime-api | ⏳ | |
| 66 | snowbridge-system-v2-runtime-api | pezsnowbridge-system-v2-runtime-api | ⏳ | |
| 67 | snowbridge-test-utils | pezsnowbridge-test-utils | ⏳ | |
| 68 | snowbridge-verification-primitives | pezsnowbridge-verification-primitives | ⏳ | |
| 69 | xcm-docs | xcm-pez-docs | ⏳ | |
| 70 | xcm-emulator | xcm-pez-emulator | ⏳ | |
| 71 | xcm-executor-integration-tests | xcm-pez-executor-integration-tests | ⏳ | |
| 72 | xcm-procedural | xcm-pez-procedural | ⏳ | |
| 73 | xcm-runtime-apis | xcm-runtime-pezapis | ⏳ | |
| 74 | xcm-simulator | xcm-pez-simulator | ⏳ | |
| 75 | xcm-simulator-example | xcm-pez-simulator-example | ⏳ | |
| 76 | xcm-simulator-fuzzer | xcm-pez-simulator-fuzzer | ⏳ | |
---
## İstatistikler
- **Tamamlanan:** 0/76
- **Devam Eden:** 0/76
- **Bekleyen:** 76/76
---
## Log
### 2025-12-15
- İlerleme listesi oluşturuldu
- scan_old_words.py scripti hazırlandı
+1 -1
View File
@@ -34,7 +34,7 @@ All branches must follow these naming patterns:
| --- | --- | --- |
| `feature/<name>` | New features | `feature/parliamentary-nft-voting` |
| `fix/<name>` | Bug fixes | `fix/presale-overflow-check` |
| `pallet/<name>` | Pallet-specific changes | `pallet/welati-liquid-democracy` |
| `pezpallet/<name>` | Pezpallet-specific changes | `pezpallet/welati-liquid-democracy` |
| `runtime/<name>` | Runtime configuration changes | `runtime/xcm-v5-upgrade` |
| `docs/<name>` | Documentation updates | `docs/token-economics` |
| `ci/<name>` | CI/CD changes | `ci/benchmark-workflow` |
+27 -27
View File
@@ -7,7 +7,7 @@ These crates are used by external developers and need thorough documentation. Th
development.
- [Documentation Guidelines](#documentation-guidelines)
- [General/Non-Pallet Crates](#generalnon-pezpallet-crates)
- [General/Non-Pezpallet Crates](#generalnon-pezpallet-crates)
- [What to Document?](#what-to-document)
- [Rust Docs vs. Code Comments](#rust-docs-vs-code-comments)
- [How to Document?](#how-to-document)
@@ -16,8 +16,8 @@ development.
- [Other Guidelines](#other-guidelines)
- [Document Through Code](#document-through-code)
- [Formatting Matters](#formatting-matters)
- [Pallet Crates](#pezpallet-crates)
- [Top Level Pallet Docs (`lib.rs`)](#top-level-pezpallet-docs-librs)
- [Pezpallet Crates](#pezpallet-crates)
- [Top Level Pezpallet Docs (`lib.rs`)](#top-level-pezpallet-docs-librs)
- [Pezkuwi and Bizinikiwi](#pezkuwi-and-bizinikiwi)
- [Dispatchables](#dispatchables)
- [Storage Items](#storage-items)
@@ -25,7 +25,7 @@ development.
---
## General/Non-Pallet Crates
## General/Non-Pezpallet Crates
First, consider the case for all such crates, except for those that are pallets.
@@ -203,49 +203,49 @@ properly do this.
---
## Pallet Crates
## Pezpallet Crates
The guidelines so far have been general in nature, and are applicable to crates that are pallets and crates that are not
pallets.
The following is relevant to how to document parts of a crate that is a pallet. See
The following is relevant to how to document parts of a crate that is a pezpallet. See
[`pezpallet-fast-unstake`](../../bizinikiwi/pezframe/fast-unstake/src/lib.rs) as one example of adhering these guidelines.
---
### Top Level Pallet Docs (`lib.rs`)
### Top Level Pezpallet Docs (`lib.rs`)
For the top-level pallet docs, consider the following template:
For the top-level pezpallet docs, consider the following template:
```
//! # <Pallet Name>
//! # <Pezpallet Name>
//!
//! <single-liner about the pallet>.
//! <single-liner about the pezpallet>.
//!
//! ## Pallet API
//! ## Pezpallet API
//!
//! <Reminder: inside the [`pallet`] module, a template that leads the reader to the relevant items is auto-generated. There is no need to repeat
//! things like "See Config trait for ...", which are generated inside [`pallet`] here anyways. You can use the line below as-is:>
//! <Reminder: inside the [`pezpallet`] module, a template that leads the reader to the relevant items is auto-generated. There is no need to repeat
//! things like "See Config trait for ...", which are generated inside [`pezpallet`] here anyways. You can use the line below as-is:>
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes, including its
//! See the [`pezpallet`] module for more information about the interfaces this pezpallet exposes, including its
//! configuration trait, dispatchables, storage items, events and errors.
//!
//! ## Overview
//!
//! <should be high-level details that are relevant to the most broad audience>
//!
//! <The audience here is potentially non-coders who just want to know what this pallet does, not how it does it>
//! <The audience here is potentially non-coders who just want to know what this pezpallet does, not how it does it>
//!
//! <potentially a few paragraphs, focus on what external folks should know about the pallet>
//! <potentially a few paragraphs, focus on what external folks should know about the pezpallet>
//!
//! ### Example
//!
//! <Your pallet must have a few tests that cover important user journeys. Use https://crates.io/crates/docify to
//! <Your pezpallet must have a few tests that cover important user journeys. Use https://crates.io/crates/docify to
//! reuse these as examples.>
//!
//! <The audience of this is those who want to know how this pallet works, to the extent of being able to build
//! something on top of it, like a DApp or another pallet. In some cases, you might want to add an example of how to
//! use this pallet in other pallets.>
//! <The audience of this is those who want to know how this pezpallet works, to the extent of being able to build
//! something on top of it, like a DApp or another pezpallet. In some cases, you might want to add an example of how to
//! use this pezpallet in other pallets.>
//!
//! This section can most often be left as-is.
//!
@@ -253,16 +253,16 @@ For the top-level pallet docs, consider the following template:
//!
//! <The format of this section is up to you, but we suggest the Design-oriented approach that follows>
//!
//! <The audience of this would be your future self, or anyone who wants to gain a deep understanding of how the pallet
//! <The audience of this would be your future self, or anyone who wants to gain a deep understanding of how the pezpallet
//! works so that they can eventually propose optimizations to it>
//!
//! ### Design Goals (optional)
//!
//! <Describe your goals with the pallet design.>
//! <Describe your goals with the pezpallet design.>
//!
//! ### Design (optional)
//!
//! <Describe how you've reached those goals. This should describe the storage layout of your pallet and what was your
//! <Describe how you've reached those goals. This should describe the storage layout of your pezpallet and what was your
//! approach in designing it that way.>
//!
//! ### Terminology (optional)
@@ -285,7 +285,7 @@ and beyond are flexible.
#### Pezkuwi and Bizinikiwi
Optionally, in order to demonstrate the relation between the two, you can start the pallet documentation with:
Optionally, in order to demonstrate the relation between the two, you can start the pezpallet documentation with:
```
//! > Made with *Bizinikiwi*, for *Pezkuwi*.
@@ -301,7 +301,7 @@ Optionally, in order to demonstrate the relation between the two, you can start
### Dispatchables
For each dispatchable (`fn` item inside `#[pallet::call]`), consider the following template:
For each dispatchable (`fn` item inside `#[pezpallet::call]`), consider the following template:
```
/// <One-liner explaining what the dispatchable does>
@@ -337,8 +337,8 @@ because ...`). Recall that this is not relevant information to external people,
2. Consider explaining the crypto-economics of how a deposit is being taken in return of the storage being used.
3. Consider explaining why it is safe for the storage item to be unbounded, if `#[pallet::unbounded]` or
`#[pallet::without_storage_info]` is being used.
3. Consider explaining why it is safe for the storage item to be unbounded, if `#[pezpallet::unbounded]` or
`#[pezpallet::without_storage_info]` is being used.
---
+2 -2
View File
@@ -8,7 +8,7 @@
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Pallet change (changes to custom pallets in `/pezkuwi/pallets/`)
- [ ] Pezpallet change (changes to custom pallets in `/pezkuwi/pallets/`)
- [ ] Runtime change (changes to runtime configuration)
- [ ] XCM/Cross-chain change
- [ ] Documentation update
@@ -70,5 +70,5 @@ N/A
**For Reviewers:**
- Check that tests cover the changes adequately
- Verify no regressions in existing functionality
- For pallet changes: review weight calculations
- For pezpallet changes: review weight calculations
- For XCM changes: verify cross-chain compatibility
+1 -1
View File
@@ -38,6 +38,6 @@ the default branch.
The regex in cmd.yml is: `^(\/cmd )([-\/\s\w.=:]+)$` accepts only alphanumeric, space, "-", "/", "=", ":", "." chars.
`/cmd bench --runtime bridge-hub-zagros --pallet=pallet_name`
`/cmd bench --runtime bridge-hub-zagros --pezpallet=pallet_name`
`/cmd prdoc --audience runtime_dev runtime_user --bump patch --force`
`/cmd update-ui --image=docker.io/paritytech/ci-unified:bullseye-1.77.0-2024-04-10-v202407161507 --clean`
+5 -5
View File
@@ -22,7 +22,7 @@ Options:
providing template runtimes. Also devs using pallets, FRAME etc directly. These are people who
care about the protocol (WASM), not the meta-protocol (client).
- `runtime_user`: Anyone using the runtime. Can be front-end devs reading the state, exchanges
listening for events, libraries that have hard-coded pallet indices etc. Anything that would
listening for events, libraries that have hard-coded pezpallet indices etc. Anything that would
result in an observable change to the runtime behaviour must be marked with this.
- `node_dev`: Those who build around the client side code. Alternative client builders, SMOLDOT,
those who consume RPCs. These are people who are oblivious to the runtime changes. They only care
@@ -88,11 +88,11 @@ For example when you modified two crates and record the changes:
crates:
- name: frame-example
bump: major
- name: frame-example-pallet
- name: frame-example-pezpallet
bump: minor
```
It means that downstream code using `frame-example-pallet` is still guaranteed to work as before,
It means that downstream code using `frame-example-pezpallet` is still guaranteed to work as before,
while code using `frame-example` might break.
### Dependencies
@@ -114,12 +114,12 @@ crates:
- name: frame-example
bump: major
validate: false
- name: frame-example-pallet
- name: frame-example-pezpallet
bump: minor
```
By putting `validate: false` for `frame-example`, the version bump is ignored by the tooling. For
`frame-example-pallet` the version bump is still validated by the CI check.
`frame-example-pezpallet` the version bump is still validated by the CI check.
### Backporting PRs
+5 -5
View File
@@ -33,7 +33,7 @@ To generate weights for all pallets in a particular runtime(s), run the followin
For Bizinikiwi pallets (supports sub-modules too):
```sh
/cmd bench --runtime dev --pallet pallet_asset_conversion_ops
/cmd bench --runtime dev --pezpallet pallet_asset_conversion_ops
```
> **📝 Note**: The action is not being run right-away, it will be queued and run in the next available runner.
@@ -50,13 +50,13 @@ For Bizinikiwi pallets (supports sub-modules too):
This way it runs all possible runtimes for the specified pallets, if it finds them in the runtime
```sh
/cmd bench --pallet pallet_balances pallet_xcm_benchmarks::generic pallet_xcm_benchmarks::fungible
/cmd bench --pezpallet pallet_balances pallet_xcm_benchmarks::generic pallet_xcm_benchmarks::fungible
```
If you want to run all specific pallet(s) for specific runtime(s), you can do it like this:
If you want to run all specific pezpallet(s) for specific runtime(s), you can do it like this:
```sh
/cmd bench --runtime bridge-hub-pezkuwi --pallet pallet_xcm_benchmarks::generic pallet_xcm_benchmarks::fungible
/cmd bench --runtime bridge-hub-pezkuwi --pezpallet pallet_xcm_benchmarks::generic pallet_xcm_benchmarks::fungible
```
> **💡Hint #1** : Sometimes when you run too many commands, or they keep failing and you're rerunning them again,
@@ -64,7 +64,7 @@ If you want to run all specific pallet(s) for specific runtime(s), you can do it
> /cmd commands.
```sh
/cmd bench --runtime kusama pezkuwi --pallet=pallet_balances --clean
/cmd bench --runtime kusama pezkuwi --pezpallet=pallet_balances --clean
```
> **💡Hint #2** : If you have questions or need help, feel free to tag @paritytech/opstooling (in github comments)
+6 -6
View File
@@ -25,10 +25,10 @@ Welcome to Pezkuwi Network - a next-generation blockchain ecosystem built on Biz
Pezkuwi Network aims to provide a secure, consistent, and scalable blockchain infrastructure that enables:
- **Decentralized Governance** through the Welati pallet
- **Decentralized Governance** through the Welati pezpallet
- **Identity & Citizenship** via zero-knowledge KYC verification
- **Community-Driven Economics** with dual-token system
- **Education Platform** through Perwerde pallet
- **Education Platform** through Perwerde pezpallet
- **Trust-Based Networking** with reputation scoring
### 1.2. Core Features
@@ -39,7 +39,7 @@ Pezkuwi Network aims to provide a secure, consistent, and scalable blockchain in
| **Asset Hub** | PEZ (ID:1) and wHEZ (ID:2) tokens at genesis | ✅ Complete |
| **Identity Bootstrap** | Founder citizenship with IdentityKyc initialization | ✅ Complete |
| **Validator Infrastructure** | TNPoS consensus with configurable validator sets | ✅ Complete |
| **Treasury System** | PezTreasury pallet with 5B PEZ initial supply | ✅ Complete |
| **Treasury System** | PezTreasury pezpallet with 5B PEZ initial supply | ✅ Complete |
| **Synthetic Halving** | 48-month halving mechanism for reward distribution | ✅ Complete |
### 1.3. Network Architecture
@@ -139,7 +139,7 @@ Pezkuwi Network aims to provide a secure, consistent, and scalable blockchain in
| Category | Percentage | Amount (PEZ) | Vesting/Lock |
| --- | --- | --- | --- |
| Treasury (Governance) | 20.25% | 1,012,500,000 | Governance controlled |
| Presale | 1.875% | 93,750,000 | Presale pallet managed |
| Presale | 1.875% | 93,750,000 | Presale pezpallet managed |
| Founder | 1.875% | 93,750,000 | 4-year vesting |
| Validator/Nominator Rewards | 76.00% | 3,800,000,000 | Synthetic halving distribution |
@@ -197,7 +197,7 @@ fn calculate_epoch_reward(current_month: u32) -> u128 {
Pezkuwi Network includes 12 custom pallets:
| # | Pallet | Purpose | Benchmarks |
| # | Pezpallet | Purpose | Benchmarks |
| --- | --- | --- | --- |
| 1 | pezpallet-presale | Token launch platform | ✅ Complete |
| 2 | pezpallet-identity-kyc | KYC verification (6 extrinsics) | ✅ Complete |
@@ -266,7 +266,7 @@ identity_kyc: IdentityKycConfig {
| Relay Chain HEZ genesis distribution | ✅ Complete |
| Bridge Hub Parachain ID fix (1013→1002) | ✅ Complete |
| Dev preset compile tests | ✅ Complete |
| All custom pallet benchmarks | ✅ Complete |
| All custom pezpallet benchmarks | ✅ Complete |
| Weight generation (real values) | ✅ Complete |
### 5.2. Phase 2: Testnet Presets (In Progress)
+127
View File
@@ -0,0 +1,127 @@
import os
import sys
# HARİÇ TUTULACAK KLASÖRLER
EXCLUDE_DIRS = {'crate_placeholders', '.git', 'target', 'node_modules', '__pycache__'}
# Düzeltilecek Kalıplar ve Yerine Geçecek Değerler
# Tekrar eden önekleri temizler.
REPLACEMENT_MAP = {
"pezpez": "pez",
"Pezpez": "Pez",
"PEZPEZ": "PEZ",
"PeZPeZ": "PeZ",
"pezPez": "pez",
"PEZpez": "PEZ",
}
def is_path_excluded(path):
"""Verilen yolun yasaklı bir klasörün içinde olup olmadığını kontrol eder."""
parts = path.split(os.sep)
return any(excluded in parts for excluded in EXCLUDE_DIRS)
def fix_double_prefix(text):
"""Metin içindeki çift PEZ öneklerini tek PEZ önekiyle değiştirir."""
for old_prefix, new_prefix in REPLACEMENT_MAP.items():
text = text.replace(old_prefix, new_prefix)
return text
def process_content_updates(root_dir):
"""Belirtilen dizin altındaki tüm hedef dosyaların içeriğini günceller."""
# Sadece .rs ve .toml gibi kod dosyalarını hedefleyelim.
TARGET_EXTENSIONS = ('.rs', '.toml', '.md', '.txt', '.yml', '.yaml', '.json', '.py')
print("--- Adım 1: Dosya İçeriklerinde Çift Önek Düzeltme ---")
for dirpath, dirnames, filenames in os.walk(root_dir, topdown=True):
dirnames[:] = [d for d in dirnames if d not in EXCLUDE_DIRS]
if is_path_excluded(dirpath):
continue
for filename in filenames:
if filename.endswith(TARGET_EXTENSIONS) or filename == 'Cargo.lock':
filepath = os.path.join(dirpath, filename)
if os.path.basename(filepath) == os.path.basename(sys.argv[0]):
continue
try:
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
original_content = content
content = fix_double_prefix(content)
if content != original_content:
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
print(f" [İÇERİK DÜZELTİLDİ] Dosya içeriği: {filepath}")
except Exception as e:
print(f" [HATA] İçerik düzeltilirken: {filepath} -> {e}")
def rename_pezpez_paths(root_dir):
"""Dosya ve klasör adlarında geçen 'pezpez' önekini 'pez' olarak düzeltir (bottom-up)."""
# 2. Klasör İsimlerini Düzelt (topdown=False, en alttan yukarı güvenli işlem)
print("\n--- Adım 2: Klasör İsimlerinin Düzeltilmesi (pezpez -> pez) ---")
for dirpath, dirnames, filenames in os.walk(root_dir, topdown=False):
if any(excluded in dirpath.split(os.sep) for excluded in EXCLUDE_DIRS):
continue
dirname = os.path.basename(dirpath)
original_dirname = dirname
new_dirname = fix_double_prefix(dirname)
if new_dirname != original_dirname:
old_path = dirpath
new_path = os.path.join(os.path.dirname(dirpath), new_dirname)
if os.path.exists(old_path) and not os.path.exists(new_path):
try:
os.rename(old_path, new_path)
print(f" [RENAME-DIR] {original_dirname} -> {new_dirname}")
except OSError as e:
print(f" [HATA] Klasör adlandırılamadı {original_dirname}: {e}")
# 3. Dosya İsimlerini Düzelt (topdown=True, kökten aşağı)
print("\n--- Adım 3: Dosya İsimlerinin Düzeltilmesi (pezpez -> pez) ---")
for dirpath, dirnames, filenames in os.walk(root_dir, topdown=True):
dirnames[:] = [d for d in dirnames if d not in EXCLUDE_DIRS]
if is_path_excluded(dirpath):
continue
for filename in filenames:
original_filename = filename
new_filename = fix_double_prefix(filename)
if new_filename != original_filename:
old_path = os.path.join(dirpath, original_filename)
new_path = os.path.join(dirpath, new_filename)
if os.path.exists(old_path) and not os.path.exists(new_path):
try:
os.rename(old_path, new_path)
print(f" [RENAME-FILE] {original_filename} -> {new_filename}")
except OSError as e:
print(f" [HATA] Dosya adlandırılamadı {original_filename}: {e}")
def main():
root_dir = os.getcwd()
print("==================================================")
print(f"🔧 PEZPEZ DÜZELTME (İçerik ve Ad) İşlemi Başlatılıyor...")
print(f"⚠️ Çalışma Dizini: {root_dir}")
print("==================================================")
# Önce içerikleri düzelt (dosya yolları değişmeden)
process_content_updates(root_dir)
# Ardından dosya ve klasör adlarını düzelt
rename_pezpez_paths(root_dir)
print("\n✅ PEZPEZ Düzeltme işlemi tamamlandı.")
if __name__ == "__main__":
main()
+96
View File
@@ -0,0 +1,96 @@
import os
import sys
# HARİÇ TUTULACAK KLASÖRLER
EXCLUDE_DIRS = {'crate_placeholders', '.git', 'target', 'node_modules', '__pycache__'}
# Yeniden adlandırma haritası (Basit: sadece 'pallet'in önüne 'pez' ekle)
RENAME_MAP = {
# Tireli (kebab-case) isimlendirmeler için
"pallet-": "pezpallet-",
# Alt çizgili (snake_case) isimlendirmeler için
"pallet_": "pezpallet_",
}
# Not: Bu betik, 'Pallet-' veya 'PALLET-' gibi büyük harf varyasyonlarını dosya sisteminde
# (çoğunlukla küçük harf veya tireli kullanılan) adreslemeyebilir, ancak en yaygın olanları hedefler.
def is_path_excluded(path):
"""Verilen yolun yasaklı bir klasörün içinde olup olmadığını kontrol eder."""
parts = path.split(os.sep)
return any(excluded in parts for excluded in EXCLUDE_DIRS)
def rename_paths(root_dir):
"""
Dosya ve klasör adlarında geçen 'pallet' önekini 'pezpallet' olarak değiştirir.
Bottom-up (en alttan yukarı) yaklaşımıyla klasör adlarını güvenli bir şekilde değiştirir.
"""
# Adım 1: Dosya İsimlerini Düzelt (topdown=True, kökten aşağı)
print("--- Adım 1: Dosya İsimlerinin Güncellenmesi (pallet -> pezpallet) ---")
for dirpath, dirnames, filenames in os.walk(root_dir, topdown=True):
# Yasaklı klasörleri atla
dirnames[:] = [d for d in dirnames if d not in EXCLUDE_DIRS]
if any(excluded in dirpath.split(os.sep) for excluded in EXCLUDE_DIRS):
continue
for filename in filenames:
original_filename = filename
new_filename = filename
for old_prefix, new_prefix in RENAME_MAP.items():
if old_prefix in new_filename:
# Basit string değiştirme, pez yaratma riskini taşıyoruz.
new_filename = new_filename.replace(old_prefix, new_prefix)
if new_filename != original_filename:
old_path = os.path.join(dirpath, original_filename)
new_path = os.path.join(dirpath, new_filename)
if os.path.exists(old_path) and not os.path.exists(new_path):
try:
os.rename(old_path, new_path)
print(f" [RENAME-FILE] {original_filename} -> {new_filename}")
except OSError as e:
print(f" [HATA] Dosya adlandırılamadı {original_filename}: {e}")
# Adım 2: Klasör İsimlerini Düzelt (topdown=False, en alttan yukarı güvenli işlem)
print("\n--- Adım 2: Klasör İsimlerinin Güncellenmesi (pallet -> pezpallet) ---")
for dirpath, dirnames, filenames in os.walk(root_dir, topdown=False):
if any(excluded in dirpath.split(os.sep) for excluded in EXCLUDE_DIRS):
continue
dirname = os.path.basename(dirpath)
original_dirname = dirname
new_dirname = dirname
for old_prefix, new_prefix in RENAME_MAP.items():
if old_prefix in new_dirname:
new_dirname = new_dirname.replace(old_prefix, new_prefix)
if new_dirname != original_dirname:
old_path = dirpath
new_path = os.path.join(os.path.dirname(dirpath), new_dirname)
if os.path.exists(old_path) and not os.path.exists(new_path):
try:
os.rename(old_path, new_path)
print(f" [RENAME-DIR] {original_dirname} -> {new_dirname}")
except OSError as e:
print(f" [HATA] Klasör adlandırılamadı {original_dirname}: {e}")
def main():
root_dir = os.getcwd()
print("==================================================")
print(f"🗂️ Dosya Adı Düzeltme İşlemi Başlatılıyor (pallet -> pezpallet)...")
print(f"⚠️ Çalışma Dizini: {root_dir}")
print("==================================================")
rename_paths(root_dir)
print("\n✅ Dosya Adları Düzeltme işlemi tamamlandı.")
if __name__ == "__main__":
main()
+5 -5
View File
@@ -1,4 +1,4 @@
# Pezkuwi SDK - Runtime Pallet Mapping
# Pezkuwi SDK - Runtime Pezpallet Mapping
**Generated:** 2025-12-08
**Purpose:** Complete inventory of all pallets across production runtimes
@@ -497,7 +497,7 @@
## Custom Pallets Distribution Table
| Pallet Name | Asset Hub PZ | Asset Hub ZG | People PZ | People ZG | PZ Relay | Test Runtimes | Benchmarks |
| Pezpallet Name | Asset Hub PZ | Asset Hub ZG | People PZ | People ZG | PZ Relay | Test Runtimes | Benchmarks |
| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **pezpallet-pez-treasury** | ✓ | | | | | | ✅ |
| **pezpallet-presale** | ✓ | | | | | | ✅ |
@@ -515,7 +515,7 @@
| **teyrchain-info** | ✓ | ✓ | ✓ | ✓ | | ✓ | ❌ |
**Legend:**
- ✓ = Pallet is included in this runtime
- ✓ = Pezpallet is included in this runtime
- ✅ = Has benchmarks configured
- ❌ = No benchmarks
- Empty = Not included
@@ -606,13 +606,13 @@
- **Location:** `/home/mamostehp/Pezkuwi-SDK/pezcumulus/teyrchains/pezpallets/teyrchain-info`
- **Runtime:** All teyrchain runtimes
- **Purpose:** Provides teyrchain ID information
- **Benchmarks:** ❌ No (infrastructure pallet)
- **Benchmarks:** ❌ No (infrastructure pezpallet)
---
## Architecture Notes
### 🎯 Strategic Pallet Placement
### 🎯 Strategic Pezpallet Placement
1. **Asset Hub PezkuwiChain** - Economic Layer
- PEZ treasury and presale management
@@ -1,6 +1,6 @@
[package]
name = "pezkuwi-sdk-docs-first-pezpallet"
description = "A simple pallet created for the pezkuwi-sdk-docs guides"
description = "A simple pezpallet created for the pezkuwi-sdk-docs guides"
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
@@ -20,43 +20,43 @@
#![cfg_attr(not(feature = "std"), no_std)]
#[docify::export]
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod shell_pallet {
use frame::prelude::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
#[frame::pallet(dev_mode)]
pub mod pallet {
#[frame::pezpallet(dev_mode)]
pub mod pezpallet {
use frame::prelude::*;
#[docify::export]
pub type Balance = u128;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export]
/// Single storage item, of type `Balance`.
#[pallet::storage]
#[pezpallet::storage]
pub type TotalIssuance<T: Config> = StorageValue<_, Balance>;
#[docify::export]
/// A mapping from `T::AccountId` to `Balance`
#[pallet::storage]
#[pezpallet::storage]
pub type Balances<T: Config> = StorageMap<_, _, T::AccountId, Balance>;
#[docify::export(impl_pallet)]
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// An unsafe mint that can be called by anyone. Not a great idea.
pub fn mint_unsafe(
origin: T::RuntimeOrigin,
@@ -98,7 +98,7 @@ pub mod pallet {
}
#[allow(unused)]
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
#[docify::export]
pub fn transfer_better(
origin: T::RuntimeOrigin,
@@ -134,7 +134,7 @@ pub mod pallet {
#[cfg(any(test, doc))]
pub(crate) mod tests {
use crate::pallet::*;
use crate::pezpallet::*;
#[docify::export(testing_prelude)]
use frame::testing_prelude::*;
@@ -148,10 +148,10 @@ pub mod pallet {
// tests { .. }`
mod runtime {
use super::*;
// we need to reference our `mod pallet` as an identifier to pass to
// we need to reference our `mod pezpallet` as an identifier to pass to
// `construct_runtime`.
// YOU HAVE TO CHANGE THIS LINE BASED ON YOUR TEMPLATE
use crate::pallet as pezpallet_currency;
use crate::pezpallet as pezpallet_currency;
construct_runtime!(
pub enum Runtime {
@@ -164,12 +164,12 @@ pub mod pallet {
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Block = MockBlock<Runtime>;
// within pallet we just said `<T as pezframe_system::Config>::AccountId`, now we
// within pezpallet we just said `<T as pezframe_system::Config>::AccountId`, now we
// finally specified it.
type AccountId = u64;
}
// our simple pallet has nothing to be configured.
// our simple pezpallet has nothing to be configured.
impl pezpallet_currency::Config for Runtime {}
}
@@ -246,7 +246,7 @@ pub mod pallet {
assert_eq!(TotalIssuance::<Runtime>::get(), None);
// mint some funds into Alice's account.
assert_ok!(Pallet::<Runtime>::mint_unsafe(
assert_ok!(Pezpallet::<Runtime>::mint_unsafe(
RuntimeOrigin::signed(ALICE),
ALICE,
100
@@ -295,14 +295,14 @@ pub mod pallet {
fn mint_works() {
StateBuilder::default().build_and_execute(|| {
// given the initial state, when:
assert_ok!(Pallet::<Runtime>::mint_unsafe(RuntimeOrigin::signed(ALICE), BOB, 100));
assert_ok!(Pezpallet::<Runtime>::mint_unsafe(RuntimeOrigin::signed(ALICE), BOB, 100));
// then:
assert_eq!(Balances::<Runtime>::get(&BOB), Some(200));
assert_eq!(TotalIssuance::<Runtime>::get(), Some(300));
// given:
assert_ok!(Pallet::<Runtime>::mint_unsafe(
assert_ok!(Pezpallet::<Runtime>::mint_unsafe(
RuntimeOrigin::signed(ALICE),
CHARLIE,
100
@@ -319,7 +319,7 @@ pub mod pallet {
fn transfer_works() {
StateBuilder::default().build_and_execute(|| {
// given the initial state, when:
assert_ok!(Pallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
assert_ok!(Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
// then:
assert_eq!(Balances::<Runtime>::get(&ALICE), Some(50));
@@ -327,7 +327,7 @@ pub mod pallet {
assert_eq!(TotalIssuance::<Runtime>::get(), Some(200));
// when:
assert_ok!(Pallet::<Runtime>::transfer(RuntimeOrigin::signed(BOB), ALICE, 50));
assert_ok!(Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(BOB), ALICE, 50));
// then:
assert_eq!(Balances::<Runtime>::get(&ALICE), Some(100));
@@ -342,7 +342,7 @@ pub mod pallet {
StateBuilder::default().build_and_execute(|| {
// given the initial state, when:
assert_err!(
Pallet::<Runtime>::transfer(RuntimeOrigin::signed(CHARLIE), ALICE, 10),
Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(CHARLIE), ALICE, 10),
"NonExistentAccount"
);
@@ -356,13 +356,13 @@ pub mod pallet {
}
}
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_v2 {
use super::pallet::Balance;
use super::pezpallet::Balance;
use frame::prelude::*;
#[docify::export(config_v2)]
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type of the runtime.
#[allow(deprecated)]
@@ -371,17 +371,17 @@ pub mod pezpallet_v2 {
+ TryInto<Event<Self>>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::storage]
#[pezpallet::storage]
pub type Balances<T: Config> = StorageMap<_, _, T::AccountId, Balance>;
#[pallet::storage]
#[pezpallet::storage]
pub type TotalIssuance<T: Config> = StorageValue<_, Balance>;
#[docify::export]
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Account does not exist.
NonExistentAccount,
@@ -390,15 +390,15 @@ pub mod pezpallet_v2 {
}
#[docify::export]
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A transfer succeeded.
Transferred { from: T::AccountId, to: T::AccountId, amount: Balance },
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[docify::export(transfer_v2)]
pub fn transfer(
origin: T::RuntimeOrigin,
@@ -424,7 +424,7 @@ pub mod pezpallet_v2 {
#[cfg(any(test, doc))]
pub mod tests {
use super::{super::pallet::tests::StateBuilder, *};
use super::{super::pezpallet::tests::StateBuilder, *};
use frame::testing_prelude::*;
const ALICE: u64 = 1;
const BOB: u64 = 2;
@@ -463,7 +463,7 @@ pub mod pezpallet_v2 {
System::set_block_number(ALICE);
// given the initial state, when:
assert_ok!(Pallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
assert_ok!(Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
// then:
assert_eq!(Balances::<Runtime>::get(&ALICE), Some(50));
@@ -31,7 +31,7 @@ pezpallet-transaction-payment-rpc-runtime-api = { workspace = true }
# other pezkuwi-sdk-deps
pezsp-keyring = { workspace = true }
# local pallet templates
# local pezpallet templates
first-pezpallet = { workspace = true }
docify = { workspace = true }
@@ -53,7 +53,7 @@ construct_runtime!(
Sudo: pezpallet_sudo,
TransactionPayment: pezpallet_transaction_payment,
// Our local pallet
// Our local pezpallet
FirstPallet: our_first_pallet,
}
);
@@ -285,7 +285,7 @@ impl_runtime_apis! {
}
}
/// Just a handy re-definition of some types based on what is already provided to the pallet
/// Just a handy re-definition of some types based on what is already provided to the pezpallet
/// configs.
pub mod interface {
use super::Runtime;
@@ -66,7 +66,7 @@
//!
//! ### UMP signals
//!
//! UMP signals are now enabled by default in the `teyrchain-system` pallet and are used for
//! UMP signals are now enabled by default in the `teyrchain-system` pezpallet and are used for
//! elastic scaling. You can find more technical details about UMP signals and their usage for
//! elastic scaling
//! [here](https://github.com/polkadot-fellows/RFCs/blob/main/text/0103-introduce-core-index-commitment.md).
@@ -68,7 +68,7 @@
//! ```ignore
//! const RELAY_PARENT_OFFSET = 2;
//! ```
//! 2. Pass this constant to the `teyrchain-system` pallet.
//! 2. Pass this constant to the `teyrchain-system` pezpallet.
//!
//! ```ignore
//! impl pezcumulus_pezpallet_teyrchain_system::Config for Runtime {
+2 -2
View File
@@ -5,7 +5,7 @@
//!
//! The main user-journey covered by these guides is:
//!
//! * [`your_first_pallet`], where you learn what a FRAME pallet is, and write your first
//! * [`your_first_pallet`], where you learn what a FRAME pezpallet is, and write your first
//! application logic.
//! * [`your_first_runtime`], where you learn how to compile your pallets into a WASM runtime.
//! * [`your_first_node`], where you learn how to run the said runtime in a node.
@@ -20,7 +20,7 @@
//!
//! Other guides are related to other miscellaneous topics and are listed as modules below.
/// Write your first simple pallet, learning the most most basic features of FRAME along the way.
/// Write your first simple pezpallet, learning the most most basic features of FRAME along the way.
pub mod your_first_pallet;
/// Write your first real [runtime](`crate::reference_docs::wasm_meta_protocol`),
+97 -97
View File
@@ -1,20 +1,20 @@
//! # Currency Pallet
//! # Currency Pezpallet
//!
//! By the end of this guide, you will have written a small FRAME pallet (see
//! By the end of this guide, you will have written a small FRAME pezpallet (see
//! [`crate::pezkuwi_sdk::frame_runtime`]) that is capable of handling a simple crypto-currency.
//! This pallet will:
//! This pezpallet will:
//!
//! 1. Allow anyone to mint new tokens into accounts (which is obviously not a great idea for a real
//! system).
//! 2. Allow any user that owns tokens to transfer them to others.
//! 3. Track the total issuance of all tokens at all times.
//!
//! > This guide will build a currency pallet from scratch using only the lowest primitives of
//! > This guide will build a currency pezpallet 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
//! > FRAME-based runtimes use various techniques to re-use a currency pezpallet instead of writing
//! > one. Further advanced FRAME related topics are discussed in [`crate::reference_docs`].
//!
//! ## Writing Your First Pallet
//! ## Writing Your First Pezpallet
//!
//! To get started, clone one of the templates mentioned in [`crate::pezkuwi_sdk::templates`]. We
//! recommend using the `pezkuwi-sdk-minimal-template`. You might need to change small parts of
@@ -33,23 +33,23 @@
//!
//! The following FRAME topics are covered in this guide:
//!
//! - [`pallet::storage`]
//! - [`pallet::call`]
//! - [`pallet::event`]
//! - [`pallet::error`]
//! - Basics of testing a pallet
//! - [`pezpallet::storage`]
//! - [`pezpallet::call`]
//! - [`pezpallet::event`]
//! - [`pezpallet::error`]
//! - Basics of testing a pezpallet
//! - [Constructing a runtime](frame::runtime::prelude::construct_runtime)
//!
//! ### Shell Pallet
//! ### Shell Pezpallet
//!
//! Consider the following as a "shell pallet". We continue building the rest of this pallet based
//! Consider the following as a "shell pezpallet". We continue building the rest of this pezpallet based
//! on this template.
//!
//! [`pallet::config`] and [`pallet::pallet`] are both mandatory parts of any
//! pallet. Refer to the documentation of each to get an overview of what they do.
//! [`pezpallet::config`] and [`pezpallet::pezpallet`] are both mandatory parts of any
//! pezpallet. Refer to the documentation of each to get an overview of what they do.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", shell_pallet)]
//!
//! All of the code that follows in this guide should live inside of the `mod pallet`.
//! All of the code that follows in this guide should live inside of the `mod pezpallet`.
//!
//! ### Storage
//!
@@ -59,18 +59,18 @@
//! issuance.
//!
//! > For the rest of this guide, we will opt for a balance type of `u128`. For the sake of
//! > simplicity, we are hardcoding this type. In a real pallet is best practice to define it as a
//! > simplicity, we are hardcoding this type. In a real pezpallet is best practice to define it as a
//! > generic bounded type in the `Config` trait, and then specify it in the implementation.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", Balance)]
//!
//! The definition of these two storage items, based on [`pallet::storage`] details, is as follows:
//! The definition of these two storage items, based on [`pezpallet::storage`] details, is as follows:
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", TotalIssuance)]
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", Balances)]
//!
//! ### Dispatchables
//!
//! Next, we will define the dispatchable functions. As per [`pallet::call`], these will be defined
//! as normal `fn`s attached to `struct Pallet`.
//! Next, we will define the dispatchable functions. As per [`pezpallet::call`], these will be defined
//! as normal `fn`s attached to `struct Pezpallet`.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", impl_pallet)]
//!
//! The logic of these functions is self-explanatory. Instead, we will focus on the FRAME-related
@@ -101,7 +101,7 @@
//!
//! - Why are all `get` and `mutate` functions returning an `Option`? This is the default behavior
//! of FRAME storage APIs. You can learn more about how to override this by looking into
//! [`pallet::storage`], and [`frame::prelude::ValueQuery`]/[`frame::prelude::OptionQuery`]
//! [`pezpallet::storage`], and [`frame::prelude::ValueQuery`]/[`frame::prelude::OptionQuery`]
//!
//! ### Improving Errors
//!
@@ -117,54 +117,54 @@
//! ergonomic.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", transfer_better_checked)]
//!
//! This is more or less all the logic that there is in this basic currency pallet!
//! This is more or less all the logic that there is in this basic currency pezpallet!
//!
//! ### Your First (Test) Runtime
//!
//! The typical testing code of a pallet lives in a module that imports some preludes useful for
//! The typical testing code of a pezpallet lives in a module that imports some preludes useful for
//! testing, similar to:
//!
//! ```
//! pub mod pallet {
//! // snip -- actually pallet code.
//! pub mod pezpallet {
//! // snip -- actually pezpallet code.
//! }
//!
//! #[cfg(test)]
//! mod tests {
//! // bring in the testing prelude of frame
//! use frame::testing_prelude::*;
//! // bring in all pallet items
//! use super::pallet::*;
//! // bring in all pezpallet items
//! use super::pezpallet::*;
//!
//! // snip -- rest of the testing code.
//! }
//! ```
//!
//! Next, we create a "test runtime" in order to test our pallet. Recall from
//! Next, we create a "test runtime" in order to test our pezpallet. Recall from
//! [`crate::pezkuwi_sdk::frame_runtime`] that a runtime is a collection of pallets, expressed
//! through [`frame::runtime::prelude::construct_runtime`]. All runtimes also have to include
//! [`frame::prelude::pezframe_system`]. So we expect to see a runtime with two pallet, `pezframe_system`
//! [`frame::prelude::pezframe_system`]. So we expect to see a runtime with two pezpallet, `pezframe_system`
//! and the one we just wrote.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", runtime)]
//!
//! > [`frame::pezpallet_macros::derive_impl`] is a FRAME feature that enables developers to have
//! > defaults for associated types.
//!
//! Recall that within our pallet, (almost) all blocks of code are generic over `<T: Config>`. And,
//! Recall that within our pezpallet, (almost) all blocks of code are generic over `<T: Config>`. And,
//! because `trait Config: pezframe_system::Config`, we can get access to all items in `Config` (or
//! `pezframe_system::Config`) using `T::NameOfItem`. This is all within the boundaries of how
//! Rust traits and generics work. If unfamiliar with this pattern, read
//! [`crate::reference_docs::trait_based_programming`] before going further.
//!
//! Crucially, a typical FRAME runtime contains a `struct Runtime`. The main role of this `struct`
//! is to implement the `trait Config` of all pallets. That is, anywhere within your pallet code
//! is to implement the `trait Config` of all pallets. That is, anywhere within your pezpallet code
//! where you see `<T: Config>` (read: *"some type `T` that implements `Config`"*), in the runtime,
//! it can be replaced with `<Runtime>`, because `Runtime` implements `Config` of all pallets, as we
//! see above.
//!
//! Another way to think about this is that within a pallet, a lot of types are "unknown" and, we
//! Another way to think about this is that within a pezpallet, a lot of types are "unknown" and, we
//! only know that they will be provided at some later point. For example, when you write
//! `T::AccountId` (which is short for `<T as pezframe_system::Config>::AccountId`) in your pallet,
//! `T::AccountId` (which is short for `<T as pezframe_system::Config>::AccountId`) in your pezpallet,
//! you are in fact saying "*Some type `AccountId` that will be known later*". That "later" is in
//! fact when you specify these types when you implement all `Config` traits for `Runtime`.
//!
@@ -178,8 +178,8 @@
//!
//! ### Your First Test
//!
//! The above is all you need to execute the dispatchables of your pallet. The last thing you need
//! to learn is that all of your pallet testing code should be wrapped in
//! The above is all you need to execute the dispatchables of your pezpallet. The last thing you need
//! to learn is that all of your pezpallet 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!("./packages/guides/first-pezpallet/src/lib.rs", first_test)]
@@ -189,12 +189,12 @@
//!
//! As noted above, the `T::AccountId` is now `u64`. Moreover, `Runtime` is replacing `<T: Config>`.
//! This is why for example you see `Balances::<Runtime>::get(..)`. Finally, notice that the
//! dispatchables are simply functions that can be called on top of the `Pallet` struct.
//! dispatchables are simply functions that can be called on top of the `Pezpallet` struct.
//!
//! Congratulations! You have written your first pallet and tested it! Next, we learn a few optional
//! steps to improve our pallet.
//! Congratulations! You have written your first pezpallet and tested it! Next, we learn a few optional
//! steps to improve our pezpallet.
//!
//! ## Improving the Currency Pallet
//! ## Improving the Currency Pezpallet
//!
//! ### Better Test Setup
//!
@@ -249,7 +249,7 @@
//!
//! ### Event and Error
//!
//! Our pallet is mainly missing two parts that are common in most FRAME pallets: Events, and
//! Our pezpallet is mainly missing two parts that are common in most FRAME pallets: Events, and
//! Errors. First, let's understand what each is.
//!
//! - **Error**: The static string-based error scheme we used so far is good for readability, but it
@@ -259,10 +259,10 @@
//! by one character. FRAME errors are exactly a solution to maintain readability, whilst fixing
//! the drawbacks mentioned. In short, we use an enum to represent different variants of our
//! error. These variants are then mapped in an efficient way (using only `u8` indices) to
//! [`pezsp_runtime::DispatchError::Module`]. Read more about this in [`pallet::error`].
//! [`pezsp_runtime::DispatchError::Module`]. Read more about this in [`pezpallet::error`].
//!
//! - **Event**: Events are akin to the return type of dispatchables. They are mostly data blobs
//! emitted by the runtime to let outside world know what is happening inside the pallet. Since
//! emitted by the runtime to let outside world know what is happening inside the pezpallet. Since
//! otherwise, the outside world does not have an easy access to the state changes. They should
//! represent what happened at the end of a dispatch operation. Therefore, the convention is to
//! use passive tense for event names (eg. `SomethingHappened`). This allows other sub-systems or
@@ -270,23 +270,23 @@
//! needing to re-execute the whole state transition function.
//!
//! 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 extra [`pallet::event`] and [`pallet::error`]
//! fairly familiar syntax: normal Rust enums, with extra [`pezpallet::event`] and [`pezpallet::error`]
//! attributes attached.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", Event)]
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", Error)]
//!
//! One slightly custom part of this is the [`pallet::generate_deposit`] part. Without going into
//! too much detail, in order for a pallet to emit events to the rest of the system, it needs to do
//! One slightly custom part of this is the [`pezpallet::generate_deposit`] part. Without going into
//! too much detail, in order for a pezpallet to emit events to the rest of the system, it needs to do
//! two things:
//!
//! 1. Declare a type in its `Config` that refers to the overarching event type of the runtime. In
//! short, by doing this, the pallet is expressing an important bound: `type RuntimeEvent:
//! short, by doing this, the pezpallet is expressing an important bound: `type RuntimeEvent:
//! From<Event<Self>>`. Read: a `RuntimeEvent` exists, and it can be created from the local `enum
//! Event` of this pallet. This enables the pallet to convert its `Event` into `RuntimeEvent`, and
//! Event` of this pezpallet. This enables the pezpallet to convert its `Event` into `RuntimeEvent`, and
//! store it where needed.
//!
//! 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
//! 2. But, doing this conversion and storing is too much to expect each pezpallet to define. FRAME
//! provides a default way of storing events, and this is what [`pezpallet::generate_deposit`] is
//! doing.
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", config_v2)]
//!
@@ -315,56 +315,56 @@
//! - [`crate::reference_docs::defensive_programming`].
//! - [`crate::reference_docs::frame_origin`].
//! - [`crate::reference_docs::frame_runtime_types`].
//! - The pallet we wrote in this guide was using `dev_mode`, learn more in [`pallet::config`].
//! - Learn more about the individual pallet items/macros, such as event and errors and call, in
//! - The pezpallet we wrote in this guide was using `dev_mode`, learn more in [`pezpallet::config`].
//! - Learn more about the individual pezpallet items/macros, such as event and errors and call, in
//! [`frame::pezpallet_macros`].
//!
//! [`pallet::storage`]: pezframe_support::pezpallet_macros::storage
//! [`pallet::call`]: pezframe_support::pezpallet_macros::call
//! [`pallet::event`]: pezframe_support::pezpallet_macros::event
//! [`pallet::error`]: pezframe_support::pezpallet_macros::error
//! [`pallet::pallet`]: pezframe_support::pallet
//! [`pallet::config`]: pezframe_support::pezpallet_macros::config
//! [`pallet::generate_deposit`]: pezframe_support::pezpallet_macros::generate_deposit
//! [`pezpallet::storage`]: pezframe_support::pezpallet_macros::storage
//! [`pezpallet::call`]: pezframe_support::pezpallet_macros::call
//! [`pezpallet::event`]: pezframe_support::pezpallet_macros::event
//! [`pezpallet::error`]: pezframe_support::pezpallet_macros::error
//! [`pezpallet::pezpallet`]: pezframe_support::pezpallet
//! [`pezpallet::config`]: pezframe_support::pezpallet_macros::config
//! [`pezpallet::generate_deposit`]: pezframe_support::pezpallet_macros::generate_deposit
#[docify::export]
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod shell_pallet {
use frame::prelude::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
}
#[frame::pallet(dev_mode)]
pub mod pallet {
#[frame::pezpallet(dev_mode)]
pub mod pezpallet {
use frame::prelude::*;
#[docify::export]
pub type Balance = u128;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export]
/// Single storage item, of type `Balance`.
#[pallet::storage]
#[pezpallet::storage]
pub type TotalIssuance<T: Config> = StorageValue<_, Balance>;
#[docify::export]
/// A mapping from `T::AccountId` to `Balance`
#[pallet::storage]
#[pezpallet::storage]
pub type Balances<T: Config> = StorageMap<_, _, T::AccountId, Balance>;
#[docify::export(impl_pallet)]
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// An unsafe mint that can be called by anyone. Not a great idea.
pub fn mint_unsafe(
origin: T::RuntimeOrigin,
@@ -406,7 +406,7 @@ pub mod pallet {
}
#[allow(unused)]
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
#[docify::export]
pub fn transfer_better(
origin: T::RuntimeOrigin,
@@ -442,7 +442,7 @@ pub mod pallet {
#[cfg(any(test, doc))]
pub(crate) mod tests {
use crate::guides::your_first_pallet::pallet::*;
use crate::guides::your_first_pallet::pezpallet::*;
#[docify::export(testing_prelude)]
use frame::testing_prelude::*;
@@ -456,10 +456,10 @@ pub mod pallet {
// tests { .. }`
mod runtime {
use super::*;
// we need to reference our `mod pallet` as an identifier to pass to
// we need to reference our `mod pezpallet` as an identifier to pass to
// `construct_runtime`.
// YOU HAVE TO CHANGE THIS LINE BASED ON YOUR TEMPLATE
use crate::guides::your_first_pallet::pallet as pezpallet_currency;
use crate::guides::your_first_pallet::pezpallet as pezpallet_currency;
construct_runtime!(
pub enum Runtime {
@@ -472,12 +472,12 @@ pub mod pallet {
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Block = MockBlock<Runtime>;
// within pallet we just said `<T as pezframe_system::Config>::AccountId`, now we
// within pezpallet we just said `<T as pezframe_system::Config>::AccountId`, now we
// finally specified it.
type AccountId = u64;
}
// our simple pallet has nothing to be configured.
// our simple pezpallet has nothing to be configured.
impl pezpallet_currency::Config for Runtime {}
}
@@ -554,7 +554,7 @@ pub mod pallet {
assert_eq!(TotalIssuance::<Runtime>::get(), None);
// mint some funds into Alice's account.
assert_ok!(Pallet::<Runtime>::mint_unsafe(
assert_ok!(Pezpallet::<Runtime>::mint_unsafe(
RuntimeOrigin::signed(ALICE),
ALICE,
100
@@ -603,14 +603,14 @@ pub mod pallet {
fn mint_works() {
StateBuilder::default().build_and_execute(|| {
// given the initial state, when:
assert_ok!(Pallet::<Runtime>::mint_unsafe(RuntimeOrigin::signed(ALICE), BOB, 100));
assert_ok!(Pezpallet::<Runtime>::mint_unsafe(RuntimeOrigin::signed(ALICE), BOB, 100));
// then:
assert_eq!(Balances::<Runtime>::get(&BOB), Some(200));
assert_eq!(TotalIssuance::<Runtime>::get(), Some(300));
// given:
assert_ok!(Pallet::<Runtime>::mint_unsafe(
assert_ok!(Pezpallet::<Runtime>::mint_unsafe(
RuntimeOrigin::signed(ALICE),
CHARLIE,
100
@@ -627,7 +627,7 @@ pub mod pallet {
fn transfer_works() {
StateBuilder::default().build_and_execute(|| {
// given the initial state, when:
assert_ok!(Pallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
assert_ok!(Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
// then:
assert_eq!(Balances::<Runtime>::get(&ALICE), Some(50));
@@ -635,7 +635,7 @@ pub mod pallet {
assert_eq!(TotalIssuance::<Runtime>::get(), Some(200));
// when:
assert_ok!(Pallet::<Runtime>::transfer(RuntimeOrigin::signed(BOB), ALICE, 50));
assert_ok!(Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(BOB), ALICE, 50));
// then:
assert_eq!(Balances::<Runtime>::get(&ALICE), Some(100));
@@ -650,7 +650,7 @@ pub mod pallet {
StateBuilder::default().build_and_execute(|| {
// given the initial state, when:
assert_err!(
Pallet::<Runtime>::transfer(RuntimeOrigin::signed(CHARLIE), ALICE, 10),
Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(CHARLIE), ALICE, 10),
"NonExistentAccount"
);
@@ -664,13 +664,13 @@ pub mod pallet {
}
}
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_v2 {
use super::pallet::Balance;
use super::pezpallet::Balance;
use frame::prelude::*;
#[docify::export(config_v2)]
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type of the runtime.
#[allow(deprecated)]
@@ -679,17 +679,17 @@ pub mod pezpallet_v2 {
+ TryInto<Event<Self>>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::storage]
#[pezpallet::storage]
pub type Balances<T: Config> = StorageMap<_, _, T::AccountId, Balance>;
#[pallet::storage]
#[pezpallet::storage]
pub type TotalIssuance<T: Config> = StorageValue<_, Balance>;
#[docify::export]
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Account does not exist.
NonExistentAccount,
@@ -698,15 +698,15 @@ pub mod pezpallet_v2 {
}
#[docify::export]
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A transfer succeeded.
Transferred { from: T::AccountId, to: T::AccountId, amount: Balance },
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[docify::export(transfer_v2)]
pub fn transfer(
origin: T::RuntimeOrigin,
@@ -732,7 +732,7 @@ pub mod pezpallet_v2 {
#[cfg(any(test, doc))]
pub mod tests {
use super::{super::pallet::tests::StateBuilder, *};
use super::{super::pezpallet::tests::StateBuilder, *};
use frame::testing_prelude::*;
const ALICE: u64 = 1;
const BOB: u64 = 2;
@@ -771,7 +771,7 @@ pub mod pezpallet_v2 {
System::set_block_number(ALICE);
// given the initial state, when:
assert_ok!(Pallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
assert_ok!(Pezpallet::<Runtime>::transfer(RuntimeOrigin::signed(ALICE), BOB, 50));
// then:
assert_eq!(Balances::<Runtime>::get(&ALICE), Some(50));
+6 -6
View File
@@ -1,13 +1,13 @@
//! # Your first Runtime
//!
//! This guide will walk you through the steps to add your pallet to a runtime.
//! This guide will walk you through the steps to add your pezpallet to a runtime.
//!
//! The good news is, in [`crate::guides::your_first_pallet`], we have already created a _test_
//! runtime that was used for testing, and a real runtime is not that much different!
//!
//! ## Setup
//!
//! A runtime shares a few similar setup requirements as with a pallet:
//! A runtime shares a few similar setup requirements as with a pezpallet:
//!
//! * importing [`frame`], [`codec`], and [`scale_info`] crates.
//! * following the [`std` feature-gating](crate::pezkuwi_sdk::bizinikiwi#wasm-build) pattern.
@@ -50,8 +50,8 @@
#![doc = docify::embed!("./packages/guides/first-runtime/src/lib.rs", config_impls)]
//!
//! Notice how we use [`frame::pezpallet_macros::derive_impl`] to provide "default" configuration items
//! for each pallet. Feel free to dive into the definition of each default prelude (eg.
//! [`frame::prelude::pezframe_system::pallet::config_preludes`]) to learn more which types are exactly
//! for each pezpallet. Feel free to dive into the definition of each default prelude (eg.
//! [`frame::prelude::pezframe_system::pezpallet::config_preludes`]) to learn more which types are exactly
//! used.
//!
//! Recall that in test runtime in [`crate::guides::your_first_pallet`], we provided `type AccountId
@@ -164,10 +164,10 @@
//! [`crate::reference_docs::frame_runtime_upgrades_and_migrations`].
//! 4. Learn more about adding and implementing runtime apis in
//! [`crate::reference_docs::custom_runtime_api_rpc`].
//! 5. To see a complete example of a runtime+pallet that is similar to this guide, please see
//! 5. To see a complete example of a runtime+pezpallet that is similar to this guide, please see
//! [`crate::pezkuwi_sdk::templates`].
//!
//! [`SolochainDefaultConfig`]: struct@pezframe_system::pallet::config_preludes::SolochainDefaultConfig
//! [`SolochainDefaultConfig`]: struct@pezframe_system::pezpallet::config_preludes::SolochainDefaultConfig
#[cfg(test)]
mod tests {
+9 -9
View File
@@ -72,7 +72,7 @@
//! For more details see the [latest documenting
//! guidelines](https://github.com/pezkuwichain/pezkuwi-sdk/blob/master/docs/contributor/DOCUMENTATION_GUIDELINES.md).
//!
//! #### Example: Explaining `#[pallet::call]`
//! #### Example: Explaining `#[pezpallet::call]`
//!
//! <details>
//! <summary>
@@ -82,15 +82,15 @@
//!
//!
//! ```
//! #[frame::pallet(dev_mode)]
//! pub mod pallet {
//! #[frame::pezpallet(dev_mode)]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! #[pallet::call]
//! impl<T: Config> Pallet<T> {
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! #[pezpallet::call]
//! impl<T: Config> Pezpallet<T> {
//! pub fn a_simple_call(origin: OriginFor<T>, data: u32) -> DispatchResult {
//! ensure!(data > 10, "SomeStaticString");
//! todo!();
@@ -101,7 +101,7 @@
//!
//! * Before even getting started, what is with all of this `<T: Config>`? We link to
//! [`crate::reference_docs::trait_based_programming`].
//! * First, the name. Why is this called `pallet::call`? This goes back to `enum Call`, which is
//! * First, the name. Why is this called `pezpallet::call`? This goes back to `enum Call`, which is
//! explained in [`crate::reference_docs::frame_runtime_types`]. Build on top of this!
//! * Then, what is `origin`? Just an account id? [`crate::reference_docs::frame_origin`].
//! * Then, what is `DispatchResult`? Why is this called *dispatch*? Probably something that can be
+36 -36
View File
@@ -29,23 +29,23 @@
//!
//! ## Pallets
//!
//! A pallet is a unit of encapsulated logic. It has a clearly defined responsibility and can be
//! A pezpallet is a unit of encapsulated logic. It has a clearly defined responsibility and can be
//! linked to other pallets. In order to be reusable, pallets shipped with FRAME strive to only care
//! about its own responsibilities and make as few assumptions about the general runtime as
//! possible. A pallet is analogous to a _module_ in the runtime.
//! possible. A pezpallet is analogous to a _module_ in the runtime.
//!
//! A pallet is defined as a `mod pallet` wrapped by the [`frame::pallet`] macro. Within this macro,
//! pallet components/parts can be defined. Most notable of these parts are:
//! A pezpallet is defined as a `mod pezpallet` wrapped by the [`frame::pezpallet`] macro. Within this macro,
//! pezpallet components/parts can be defined. Most notable of these parts are:
//!
//! - [Config](frame::pezpallet_macros::config), allowing a pallet to make itself configurable and
//! - [Config](frame::pezpallet_macros::config), allowing a pezpallet to make itself configurable and
//! generic over types, values and such.
//! - [Storage](frame::pezpallet_macros::storage), allowing a pallet to define onchain storage.
//! - [Dispatchable function](frame::pezpallet_macros::call), allowing a pallet to define extrinsics
//! - [Storage](frame::pezpallet_macros::storage), allowing a pezpallet to define onchain storage.
//! - [Dispatchable function](frame::pezpallet_macros::call), allowing a pezpallet to define extrinsics
//! that are callable by end users, from the outer world.
//! - [Events](frame::pezpallet_macros::event), allowing a pallet to emit events.
//! - [Errors](frame::pezpallet_macros::error), allowing a pallet to emit well-formed errors.
//! - [Events](frame::pezpallet_macros::event), allowing a pezpallet to emit events.
//! - [Errors](frame::pezpallet_macros::error), allowing a pezpallet to emit well-formed errors.
//!
//! Some of these pallet components resemble the building blocks of a smart contract. While both
//! Some of these pezpallet components resemble the building blocks of a smart contract. While both
//! models are programming state transition functions of blockchains, there are crucial differences
//! between the two. See [`crate::reference_docs::runtime_vs_smart_contract`] for more.
//!
@@ -54,12 +54,12 @@
//!
//! ### Example
//!
//! The following example showcases a minimal pallet.
#![doc = docify::embed!("src/pezkuwi_sdk/frame_runtime.rs", pallet)]
//! The following example showcases a minimal pezpallet.
#![doc = docify::embed!("src/pezkuwi_sdk/frame_runtime.rs", pezpallet)]
//!
//! ## Runtime
//!
//! A runtime is a collection of pallets that are amalgamated together. Each pallet typically has
//! A runtime is a collection of pallets that are amalgamated together. Each pezpallet typically has
//! some configurations (exposed as a `trait Config`) that needs to be *specified* in the runtime.
//! This is done with [`frame::runtime::prelude::construct_runtime`].
//!
@@ -69,8 +69,8 @@
//!
//! ### Example
//!
//! The following example shows a (test) runtime that is composing the pallet demonstrated above,
//! next to the [`frame::prelude::pezframe_system`] pallet, into a runtime.
//! The following example shows a (test) runtime that is composing the pezpallet demonstrated above,
//! next to the [`frame::prelude::pezframe_system`] pezpallet, into a runtime.
#![doc = docify::embed!("src/pezkuwi_sdk/frame_runtime.rs", runtime)]
//!
//! ## More Examples
@@ -88,21 +88,21 @@
//! * 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).
/// A FRAME based pallet. This `mod` is the entry point for everything else. All
/// `#[pallet::xxx]` macros must be defined in this `mod`. Although, frame also provides an
/// A FRAME based pezpallet. This `mod` is the entry point for everything else. All
/// `#[pezpallet::xxx]` macros must be defined in this `mod`. Although, frame also provides an
/// experimental feature to break these parts into different `mod`s. See [`pezpallet_examples`] for
/// more.
#[docify::export]
#[frame::pallet(dev_mode)]
pub mod pallet {
#[frame::pezpallet(dev_mode)]
pub mod pezpallet {
use frame::prelude::*;
/// The configuration trait of a pallet. Mandatory. Allows a pallet to receive types at a
/// later point from the runtime that wishes to contain it. It allows the pallet to be
/// The configuration trait of a pezpallet. Mandatory. Allows a pezpallet to receive types at a
/// later point from the runtime that wishes to contain it. It allows the pezpallet to be
/// parameterized over both types and values.
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// A type that is not known now, but the runtime that will contain this pallet will
/// A type that is not known now, but the runtime that will contain this pezpallet will
/// know it later, therefore we define it here as an associated type.
#[allow(deprecated)]
type RuntimeEvent: IsType<<Self as pezframe_system::Config>::RuntimeEvent> + From<Event<Self>>;
@@ -115,25 +115,25 @@ pub mod pallet {
const ANOTHER_VALUE_PARAMETER: u32;
}
/// A mandatory struct in each pallet. All functions callable by external users (aka.
/// A mandatory struct in each pezpallet. All functions callable by external users (aka.
/// transactions) must be attached to this type (see [`frame::pezpallet_macros::call`]). For
/// convenience, internal (private) functions can also be attached to this type.
#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(PhantomData<T>);
/// The events that this pallet can emit.
#[pallet::event]
/// The events that this pezpallet can emit.
#[pezpallet::event]
pub enum Event<T: Config> {}
/// A storage item that this pallet contains. This will be part of the state root trie
/// A storage item that this pezpallet contains. This will be part of the state root trie
/// of the blockchain.
#[pallet::storage]
#[pezpallet::storage]
pub type Value<T> = StorageValue<Value = u32>;
/// All *dispatchable* call functions (aka. transactions) are attached to `Pallet` in a
/// All *dispatchable* call functions (aka. transactions) are attached to `Pezpallet` in a
/// `impl` block.
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// This will be callable by external users, and has two u32s as a parameter.
pub fn some_dispatchable(
_origin: OriginFor<T>,
@@ -145,12 +145,12 @@ pub mod pallet {
}
}
/// A simple runtime that contains the above pallet and `pezframe_system`, the mandatory pallet of
/// A simple runtime that contains the above pezpallet and `pezframe_system`, the mandatory pezpallet of
/// all runtimes. This runtime is for testing, but it shares a lot of similarities with a *real*
/// runtime.
#[docify::export]
pub mod runtime {
use super::pallet as pezpallet_example;
use super::pezpallet as pezpallet_example;
use frame::{prelude::*, testing_prelude::*};
// The major macro that amalgamates pallets into `enum Runtime`
@@ -161,7 +161,7 @@ pub mod runtime {
}
);
// These `impl` blocks specify the parameters of each pallet's `trait Config`.
// These `impl` blocks specify the parameters of each pezpallet's `trait Config`.
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Block = MockBlock<Self>;
+1 -1
View File
@@ -81,7 +81,7 @@ mod tests {
impl pezcumulus_pezpallet_teyrchain_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = teyrchain_info::Pallet<Runtime>;
type SelfParaId = teyrchain_info::Pezpallet<Runtime>;
type OutboundXcmpMessageSource = ();
type XcmpMessageHandler = ();
type ReservedDmpWeight = ();
+1 -1
View File
@@ -36,7 +36,7 @@
//! Its main components are:
//! - [`xcm`](::xcm): The definition of the basic types and instructions.
//! - [`xcm_executor`]: An implementation of the virtual machine to execute instructions.
//! - [`pezpallet_xcm`]: A FRAME pallet for interacting with the executor.
//! - [`pezpallet_xcm`]: A FRAME pezpallet for interacting with the executor.
//! - [`xcm_builder`]: A collection of types to configure the executor.
//! - [`xcm_pez_simulator`]: A playground for trying out different XCM programs and executor
//! configurations.
@@ -20,18 +20,18 @@
//! Each of the formats is explained in [_chain-spec-format_][`pezsc_chain_spec#chain-spec-formats`].
//!
//!
//! # `GenesisConfig` for `pallet`
//! # `GenesisConfig` for `pezpallet`
//!
//! Every frame pallet may have its initial state which is defined by the `GenesisConfig` internal
//! struct. It is a regular Rust struct, annotated with the [`pallet::genesis_config`] attribute.
//! Every frame pezpallet may have its initial state which is defined by the `GenesisConfig` internal
//! struct. It is a regular Rust struct, annotated with the [`pezpallet::genesis_config`] attribute.
#![doc = docify::embed!("./src/reference_docs/chain_spec_runtime/src/pallets.rs", pezpallet_bar_GenesisConfig)]
//!
//! The struct shall be defined within the pallet `mod`, as in the following code:
//! The struct shall be defined within the pezpallet `mod`, as in the following code:
#![doc = docify::embed!("./src/reference_docs/chain_spec_runtime/src/pallets.rs", pezpallet_bar)]
//!
//! The initial state conveyed in the `GenesisConfig` struct is transformed into state storage
//! items by means of the [`BuildGenesisConfig`] trait, which shall be implemented for the pallet's
//! `GenesisConfig` struct. The [`pallet::genesis_build`] attribute shall be attached to the `impl`
//! items by means of the [`BuildGenesisConfig`] trait, which shall be implemented for the pezpallet's
//! `GenesisConfig` struct. The [`pezpallet::genesis_build`] attribute shall be attached to the `impl`
//! block:
#![doc = docify::embed!("./src/reference_docs/chain_spec_runtime/src/pallets.rs", pezpallet_bar_build)]
//!
@@ -51,7 +51,7 @@
//!
//! # `GenesisConfig` for `runtimes`
//!
//! The runtime genesis config struct consists of configs for every pallet. For the [_demonstration
//! The runtime genesis config struct consists of configs for every pezpallet. For the [_demonstration
//! runtime_][`pez_chain_spec_guide_runtime`] used in this guide, it consists of `SystemConfig`,
//! `BarConfig`, and `FooConfig`. This structure was automatically generated by a macro and it can
//! be sneak-peeked here: [`RuntimeGenesisConfig`]. For further reading on generated runtime
@@ -189,8 +189,8 @@
//! [`impl_runtime_apis`]: frame::runtime::prelude::impl_runtime_apis
//! [`build_state`]: pezframe_support::genesis_builder_helper::build_state
//! [`get_preset`]: pezframe_support::genesis_builder_helper::get_preset
//! [`pallet::genesis_build`]: pezframe_support::pezpallet_macros::genesis_build
//! [`pallet::genesis_config`]: pezframe_support::pezpallet_macros::genesis_config
//! [`pezpallet::genesis_build`]: pezframe_support::pezpallet_macros::genesis_build
//! [`pezpallet::genesis_config`]: pezframe_support::pezpallet_macros::genesis_config
//! [`build_struct_json_patch`]: pezframe_support::build_struct_json_patch
//! [`BuildGenesisConfig`]: pezframe_support::traits::BuildGenesisConfig
//! [`serde`]: https://serde.rs/field-attrs.html
@@ -21,28 +21,28 @@ use alloc::vec::Vec;
use frame::prelude::*;
#[docify::export]
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_bar {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::storage]
#[pezpallet::storage]
pub(super) type InitialAccount<T: Config> = StorageValue<Value = T::AccountId>;
/// Simple `GenesisConfig`.
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(DefaultNoBound)]
#[docify::export(pezpallet_bar_GenesisConfig)]
pub struct GenesisConfig<T: Config> {
pub initial_account: Option<T::AccountId>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
#[docify::export(pezpallet_bar_build)]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
/// The storage building function that presents a direct mapping of the initial config
@@ -94,24 +94,24 @@ pub enum FooEnum {
}
#[docify::export]
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_foo {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::storage]
#[pezpallet::storage]
pub type ProcessedEnumValue<T> = StorageValue<Value = u64>;
#[pallet::storage]
#[pezpallet::storage]
pub type SomeInteger<T> = StorageValue<Value = u32>;
/// The more sophisticated structure for conveying initial state.
#[docify::export(pezpallet_foo_GenesisConfig)]
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub some_integer: u32,
@@ -121,7 +121,7 @@ pub mod pezpallet_foo {
pub _phantom: PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
#[docify::export(pezpallet_foo_build)]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
/// The build method that indirectly maps an initial config values into the storage items.
@@ -67,15 +67,15 @@ mod runtime {
)]
pub struct Runtime;
/// Mandatory system pallet that should always be included in a FRAME runtime.
/// Mandatory system pezpallet that should always be included in a FRAME runtime.
#[runtime::pezpallet_index(0)]
pub type System = pezframe_system;
/// Sample pallet 1
/// Sample pezpallet 1
#[runtime::pezpallet_index(1)]
pub type Bar = pezpallet_bar;
/// Sample pallet 2
/// Sample pezpallet 2
#[runtime::pezpallet_index(2)]
pub type Foo = pezpallet_foo;
}
@@ -84,7 +84,7 @@ parameter_types! {
pub const Version: RuntimeVersion = VERSION;
}
/// Implements the types required for the system pallet.
/// Implements the types required for the system pezpallet.
#[derive_impl(pezframe_system::config_preludes::SolochainDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Block = Block;
@@ -214,7 +214,7 @@
//!
//! #### Bob's Overflowed Balance
//!
//! **Bob's** balance exceeds the `Balance` type on the `EduChain`. Because the pallet developer did
//! **Bob's** balance exceeds the `Balance` type on the `EduChain`. Because the pezpallet developer did
//! not handle the calculation to add to Bob's balance with any regard to this overflow, **Bob's**
//! balance is now essentially `0`, the operation **wrapped**.
//!
@@ -247,7 +247,7 @@
//!
//! A `u8` parameter, called `proposals_count`, represents the type for counting the number of
//! proposals on-chain. Every time a new proposal is added to the system, this number increases.
//! With the proposal pallet's high usage, it has reached `u8::MAX`s limit of 255, causing
//! With the proposal pezpallet's high usage, it has reached `u8::MAX`s limit of 255, causing
//! `proposals_count` to go to 0. Unfortunately, this results in new proposals overwriting old ones,
//! effectively erasing any notion of past proposals!
//!
@@ -276,7 +276,7 @@
//! authoring, consensus, or other protocol-level dependencies, going through with an action may
//! actually cause harm to the network, and thus stalling would be the better option.
//!
//! Take the example of the BABE pallet ([`pezpallet_babe`]), which doesn't allow for a validator to
//! Take the example of the BABE pezpallet ([`pezpallet_babe`]), which doesn't allow for a validator to
//! participate if it is disabled (see: [`frame::traits::DisabledValidators`]):
//!
//! ```ignore
@@ -155,7 +155,7 @@
//!
//! A call can be anything that implements [`Encode`][frame::deps::codec::Encode]. In FRAME-based
//! runtimes, a call is represented as an enum of enums, where the outer enum represents the FRAME
//! pallet being called, and the inner enum represents the call being made within that pallet, and
//! pezpallet being called, and the inner enum represents the call being made within that pezpallet, and
//! any arguments to it. Read more about the call enum
//! [here][crate::reference_docs::frame_runtime_types].
//!
@@ -172,15 +172,15 @@
//! )
//! ```
//!
//! - `pezpallet_index` is a single byte denoting the index of the pallet that we are calling into, and
//! - `pezpallet_index` is a single byte denoting the index of the pezpallet that we are calling into, and
//! is what the tag of the outermost enum will encode to.
//! - `call_index` is a single byte denoting the index of the call that we are making the pallet,
//! - `call_index` is a single byte denoting the index of the call that we are making the pezpallet,
//! and is what the tag of the inner enum will encode to.
//! - `call_args` are the SCALE encoded bytes for each of the arguments that the call expects, and
//! are typically provided as values to the inner enum.
//!
//! Information about the pallets that exist for a chain (including their indexes), the calls
//! available in each pallet (including their indexes), and the arguments required for each call can
//! available in each pezpallet (including their indexes), and the arguments required for each call can
//! be found in the metadata for the chain. For V15 metadata, this information [is
//! here][frame::deps::pezframe_support::__private::metadata::v15::PalletMetadata].
//!
@@ -219,7 +219,7 @@
//! in the [Checkable](pezsp_runtime::traits::Checkable) implementation of
//! [UncheckedExtrinsic](pezsp_runtime::generic::UncheckedExtrinsic). Therefore, it is up to each
//! extension to define the format of the payload it will try to check and authorize the right
//! origin type. For an example, look into the [authorization example pallet
//! origin type. For an example, look into the [authorization example pezpallet
//! extensions](pezpallet_example_authorization_tx_extension::extensions)
//!
//! # Example Encoding
@@ -245,7 +245,7 @@ pub mod call_data {
}
// An inner enum represents the calls within
// a specific pallet. "PalletA" has one call,
// a specific pezpallet. "PalletA" has one call,
// "Foo".
#[derive(Encode, Decode, Clone)]
pub enum PalletACall {
@@ -47,7 +47,7 @@
//! the 20ms. In a benchmarked environment, it can examine the transactions for their upper bound,
//! and include the ones that are known to fit based on the worst case.
//!
//! The benchmarking code can be written as a part of FRAME pallet, using the macros provided in
//! The benchmarking code can be written as a part of FRAME pezpallet, using the macros provided in
//! [`pezframe_benchmarking`]. See any of the existing pallets in `pezkuwi-sdk`, or the pallets in our
//! [`crate::pezkuwi_sdk::templates`] for examples.
//!
@@ -72,12 +72,12 @@
//! If this block of code is to be benchmarked, then the benchmarking code must be written such that
//! it captures the worst case.
//!
//! ## Gluing Pallet Benchmarking with Runtime
//! ## Gluing Pezpallet Benchmarking with Runtime
//!
//! FRAME pallets are mandated to provide their own benchmarking code. Runtimes contain the
//! boilerplate needed to run these benchmarking (see [Running Benchmarks
//! below](#running-benchmarks)). The outcome of running these benchmarks are meant to be fed back
//! into the pallet via a conventional `trait WeightInfo` on `Config`:
//! into the pezpallet via a conventional `trait WeightInfo` on `Config`:
#![doc = docify::embed!("src/reference_docs/pezframe_benchmarking_weight.rs", WeightInfo)]
//!
//! Then, individual functions of this trait are the final values that we assigned to the
@@ -130,9 +130,9 @@
//! [PolkaVM]: https://github.com/koute/polkavm
//! [JAM]: https://graypaper.com
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
#[allow(unused_variables, unreachable_code, unused, clippy::diverging_sub_expression)]
pub mod pallet {
pub mod pezpallet {
use frame::prelude::*;
#[docify::export]
@@ -140,18 +140,18 @@ pub mod pallet {
fn simple_transfer() -> Weight;
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
type WeightInfo: WeightInfo;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[docify::export]
#[pallet::weight(10_000)]
#[pezpallet::weight(10_000)]
pub fn simple_transfer(
origin: OriginFor<T>,
destination: T::AccountId,
@@ -167,7 +167,7 @@ pub mod pallet {
}
#[docify::export]
#[pallet::weight(T::WeightInfo::simple_transfer())]
#[pezpallet::weight(T::WeightInfo::simple_transfer())]
pub fn simple_transfer_2(
origin: OriginFor<T>,
destination: T::AccountId,
@@ -184,7 +184,7 @@ pub mod pallet {
#[docify::export]
// This is the worst-case, pre-dispatch weight.
#[pallet::weight(T::WeightInfo::simple_transfer())]
#[pezpallet::weight(T::WeightInfo::simple_transfer())]
pub fn simple_transfer_3(
origin: OriginFor<T>,
destination: T::AccountId,
+13 -13
View File
@@ -17,15 +17,15 @@
//! }
//! ```
//!
//! within the pallet, if you want to use the standard `println!`, it needs to be wrapped in
//! within the pezpallet, if you want to use the standard `println!`, it needs to be wrapped in
//! [`pezsp_std::if_std`]. Of course, this means that this print code is only available to you in the
//! `std` compiler flag, and never present in a wasm build.
//!
//! ```
//! // somewhere in your pallet. This is not a real pallet code.
//! mod pallet {
//! struct Pallet;
//! impl Pallet {
//! // somewhere in your pezpallet. This is not a real pezpallet code.
//! mod pezpallet {
//! struct Pezpallet;
//! impl Pezpallet {
//! fn print() {
//! pezsp_std::if_std! {
//! println!("Hello, world!");
@@ -42,9 +42,9 @@
//! 1. `log-level`, signifying how important it is.
//! 2. `log-target`, signifying to which component it belongs.
//!
//! Add log statements to your pallet as such:
//! Add log statements to your pezpallet as such:
//!
//! You can add the log crate to the `Cargo.toml` of the pallet.
//! You can add the log crate to the `Cargo.toml` of the pezpallet.
//!
//! ```text
//! #[dependencies]
@@ -59,14 +59,14 @@
//!
//! More conveniently, the `frame` umbrella crate re-exports the log crate as [`frame::log`].
//!
//! Then, the pallet can use this crate to emit log statements. In this statement, we use the info
//! Then, the pezpallet can use this crate to emit log statements. In this statement, we use the info
//! level, and the target is `pezpallet-example`.
//!
//! ```
//! mod pallet {
//! struct Pallet;
//! mod pezpallet {
//! struct Pezpallet;
//!
//! impl Pallet {
//! impl Pezpallet {
//! fn logs() {
//! frame::log::info!(target: "pezpallet-example", "Hello, world!");
//! }
@@ -81,7 +81,7 @@
//! // in your test
//! fn it_also_prints() {
//! pezsp_api::init_runtime_logger();
//! // call into your pallet, and now it will print `log` statements.
//! // call into your pezpallet, and now it will print `log` statements.
//! }
//! ```
//!
@@ -107,7 +107,7 @@
//! ## Log Target Prefixing
//!
//! Many [`crate::pezkuwi_sdk::frame_runtime`] pallets emit logs with log target `runtime::<name of
//! pallet>`, for example `runtime::system`. This then allows one to run a node with a wasm blob
//! pezpallet>`, for example `runtime::system`. This then allows one to run a node with a wasm blob
//! compiled with `LOG_TARGET=runtime=debug`, which enables the log target of all pallets who's log
//! target starts with `runtime`.
//!
@@ -58,18 +58,18 @@
//! [`frame::pezpallet_macros::hooks`].
//!
//! ```
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! use frame::prelude::*;
//!
//! #[pallet::config]
//! #[pezpallet::config]
//! pub trait Config: pezframe_system::Config {}
//!
//! #[pallet::pallet]
//! pub struct Pallet<T>(_);
//! #[pezpallet::pezpallet]
//! pub struct Pezpallet<T>(_);
//!
//! #[pallet::hooks]
//! impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
//! #[pezpallet::hooks]
//! impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
//! fn offchain_worker(block_number: BlockNumberFor<T>) {
//! // ...
//! }
+32 -32
View File
@@ -31,7 +31,7 @@
//!
//! ## Context
//!
//! First, let's look at where the `origin` type is encountered in a typical pallet. The `origin:
//! First, let's look at where the `origin` type is encountered in a typical pezpallet. The `origin:
//! OriginFor<T>` has to be the first argument of any given callable extrinsic in FRAME:
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", call_simple)]
//!
@@ -44,12 +44,12 @@
//! amalgamated at the runtime level. Read [`crate::reference_docs::frame_runtime_types`] to
//! familiarize yourself with these types.
//!
//! To understand this better, we will next create a pallet with a custom origin, which will add a
//! To understand this better, we will next create a pezpallet with a custom origin, which will add a
//! new variant to `RuntimeOrigin`.
//!
//! ## Adding Custom Pallet Origin to the Runtime
//! ## Adding Custom Pezpallet Origin to the Runtime
//!
//! For example, given a pallet that defines the following custom origin:
//! For example, given a pezpallet that defines the following custom origin:
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", custom_origin)]
//!
//! And a runtime with the following pallets:
@@ -57,7 +57,7 @@
//!
//! The type [`crate::reference_docs::frame_origin::runtime_for_origin::RuntimeOrigin`] is expanded.
//! This `RuntimeOrigin` contains a variant for the [`pezframe_system::RawOrigin`] and the custom
//! origin of the pallet.
//! origin of the pezpallet.
//!
//! > Notice how the [`pezframe_system::ensure_signed`] is nothing more than a `match` statement. If
//! > you want to know where the actual origin of an extrinsic is set (and the signature
@@ -67,30 +67,30 @@
//!
//! ## Asserting on a Custom Internal Origin
//!
//! In order to assert on a custom origin that is defined within your pallet, we need a way to first
//! In order to assert on a custom origin that is defined within your pezpallet, we need a way to first
//! convert the `<T as pezframe_system::Config>::RuntimeOrigin` into the local `enum Origin` of the
//! current pallet. This is a common process that is explained in
//! current pezpallet. This is a common process that is explained in
//! [`crate::reference_docs::frame_runtime_types#
//! adding-further-constraints-to-runtime-composite-enums`].
//!
//! We use the same process here to express that `RuntimeOrigin` has a number of additional bounds,
//! as follows.
//!
//! 1. Defining a custom `RuntimeOrigin` with further bounds in the pallet.
//! 1. Defining a custom `RuntimeOrigin` with further bounds in the pezpallet.
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", custom_origin_bound)]
//!
//! 2. Using it in the pallet.
//! 2. Using it in the pezpallet.
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", custom_origin_usage)]
//!
//! ## Asserting on a Custom External Origin
//!
//! Very often, a pallet wants to have a parameterized origin that is **NOT** defined within the
//! pallet. In other words, a pallet wants to delegate an origin check to something that is
//! Very often, a pezpallet wants to have a parameterized origin that is **NOT** defined within the
//! pezpallet. In other words, a pezpallet wants to delegate an origin check to something that is
//! specified later at the runtime level. Like many other parameterizations in FRAME, this implies
//! adding a new associated type to `trait Config`.
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", external_origin_def)]
//!
//! Then, within the pallet, we can simply use this "unknown" origin check type:
//! Then, within the pezpallet, we can simply use this "unknown" origin check type:
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", external_origin_usage)]
//!
//! Finally, at the runtime, any implementation of [`frame::traits::EnsureOrigin`] can be passed.
@@ -112,7 +112,7 @@
//! ## Obtaining Abstract Origins
//!
//! So far we have learned that FRAME pallets can assert on custom and abstract origin types,
//! whether they are defined within the pallet or not. But how can we obtain these abstract origins?
//! whether they are defined within the pezpallet or not. But how can we obtain these abstract origins?
//!
//! > All extrinsics that come from the outer world can generally only be obtained as either
//! > `signed` or `none` origin.
@@ -130,19 +130,19 @@
use frame::prelude::*;
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_for_origin {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(call_simple)]
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn do_something(_origin: OriginFor<T>) -> DispatchResult {
// ^^^^^^^^^^^^^^^^^^^^^
todo!();
@@ -150,23 +150,23 @@ pub mod pezpallet_for_origin {
}
}
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_with_custom_origin {
use super::*;
#[docify::export(custom_origin_bound)]
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
type RuntimeOrigin: From<<Self as pezframe_system::Config>::RuntimeOrigin>
+ Into<Result<Origin, <Self as Config>::RuntimeOrigin>>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(custom_origin)]
/// A dummy custom origin.
#[pallet::origin]
#[pezpallet::origin]
#[derive(
PartialEq,
Eq,
@@ -186,8 +186,8 @@ pub mod pezpallet_with_custom_origin {
}
#[docify::export(custom_origin_usage)]
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn only_validators(origin: OriginFor<T>) -> DispatchResult {
// first, we convert from `<T as pezframe_system::Config>::RuntimeOrigin` to `<T as
// Config>::RuntimeOrigin`
@@ -225,21 +225,21 @@ pub mod runtime_for_origin {
}
}
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_with_external_origin {
use super::*;
#[docify::export(external_origin_def)]
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
type ExternalOrigin: EnsureOrigin<Self::RuntimeOrigin>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(external_origin_usage)]
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn externally_checked_ext(origin: OriginFor<T>) -> DispatchResult {
T::ExternalOrigin::ensure_origin(origin)?;
todo!();
@@ -1,32 +1,32 @@
//! # FRAME Pallet Coupling
//! # FRAME Pezpallet Coupling
//!
//! This reference document explains how FRAME pallets can be combined to interact together.
//!
//! It is suggested to re-read [`crate::pezkuwi_sdk::frame_runtime`], notably the information
//! around [`frame::pezpallet_macros::config`]. Recall that:
//!
//! > Configuration trait of a pallet: It allows a pallet to receive types at a later
//! > point from the runtime that wishes to contain it. It allows the pallet to be parameterized
//! > Configuration trait of a pezpallet: It allows a pezpallet to receive types at a later
//! > point from the runtime that wishes to contain it. It allows the pezpallet to be parameterized
//! > over both types and values.
//!
//! ## Context, Background
//!
//! FRAME pallets, as per described in [`crate::pezkuwi_sdk::frame_runtime`] are:
//!
//! > A pallet is a unit of encapsulated logic. It has a clearly defined responsibility and can be
//! > A pezpallet is a unit of encapsulated logic. It has a clearly defined responsibility and can be
//! linked to other pallets.
//!
//! That is to say:
//!
//! * *encapsulated*: Ideally, a FRAME pallet contains encapsulated logic which has clear
//! boundaries. It is generally a bad idea to build a single monolithic pallet that does multiple
//! * *encapsulated*: Ideally, a FRAME pezpallet contains encapsulated logic which has clear
//! boundaries. It is generally a bad idea to build a single monolithic pezpallet that does multiple
//! things, such as handling currencies, identities and staking all at the same time.
//! * *linked to other pallets*: But, adhering extensively to the above also hinders the ability to
//! write useful applications. Pallets often need to work with each other, communicate and use
//! each other's functionalities.
//!
//! The broad principle that allows pallets to be linked together is the same way through which a
//! pallet uses its `Config` trait to receive types and values from the runtime that contains it.
//! pezpallet uses its `Config` trait to receive types and values from the runtime that contains it.
//!
//! There are generally two ways to achieve this:
//!
@@ -63,7 +63,7 @@
//!
//! ## Example
//!
//! Consider the following example, in which `pezpallet-foo` needs another pallet to provide the block
//! Consider the following example, in which `pezpallet-foo` needs another pezpallet to provide the block
//! author to it, and `pezpallet-author` which has access to this information.
#![doc = docify::embed!("./src/reference_docs/frame_pallet_coupling.rs", pezpallet_foo)]
#![doc = docify::embed!("./src/reference_docs/frame_pallet_coupling.rs", pezpallet_author)]
@@ -71,16 +71,16 @@
//! ### Tight Coupling Pallets
//!
//! To tightly couple `pezpallet-foo` and `pezpallet-author`, we use Rust's supertrait system. When a
//! pallet makes its own `trait Config` be bounded by another pallet's `trait Config`, it is
//! pezpallet makes its own `trait Config` be bounded by another pezpallet's `trait Config`, it is
//! expressing two things:
//!
//! 1. That it can only exist in a runtime if the other pallet is also present.
//! 2. That it can use the other pallet's functionality.
//! 1. That it can only exist in a runtime if the other pezpallet is also present.
//! 2. That it can use the other pezpallet's functionality.
//!
//! `pezpallet-foo`'s `Config` would then look like:
#![doc = docify::embed!("./src/reference_docs/frame_pallet_coupling.rs", tight_config)]
//!
//! And `pezpallet-foo` can use the method exposed by `pezpallet_author::Pallet` directly:
//! And `pezpallet-foo` can use the method exposed by `pezpallet_author::Pezpallet` directly:
#![doc = docify::embed!("./src/reference_docs/frame_pallet_coupling.rs", tight_usage)]
//!
//!
@@ -120,9 +120,9 @@
//!
//! ## Frame System
//!
//! With the above information in context, we can conclude that **`pezframe_system` is a special pallet
//! that is tightly coupled with every other pallet**. This is because it provides the fundamental
//! system functionality that every pallet needs, such as some types like
//! With the above information in context, we can conclude that **`pezframe_system` is a special pezpallet
//! that is tightly coupled with every other pezpallet**. This is because it provides the fundamental
//! system functionality that every pezpallet needs, such as some types like
//! [`frame::prelude::pezframe_system::Config::AccountId`],
//! [`frame::prelude::pezframe_system::Config::Hash`], and some functionality such as block number,
//! etc.
@@ -132,18 +132,18 @@
//! To recap, consider the following rules of thumb:
//!
//! * In all cases, try and break down big pallets apart with clear boundaries of responsibility. In
//! general, it is easier to argue about multiple pallet if they only communicate together via a
//! general, it is easier to argue about multiple pezpallet if they only communicate together via a
//! known trait, rather than having access to all of each others public items, such as storage and
//! dispatchables.
//! * If a group of pallets is meant to work together, but is not foreseen to be generalized, or
//! used by others, consider tightly coupling pallets, *if it simplifies the development*.
//! * If a pallet needs a functionality provided by another pallet, but multiple implementations can
//! * If a pezpallet needs a functionality provided by another pezpallet, but multiple implementations can
//! be foreseen, consider loosely coupling pallets.
//!
//! For example, all pallets in `pezkuwi-sdk` that needed to work with currencies could have been
//! tightly coupled with [`pezpallet_balances`]. But, `pezkuwi-sdk` also provides [`pezpallet_assets`]
//! (and more implementations by the community), therefore all pallets use traits to loosely couple
//! with balances or assets pallet. More on this in [`crate::reference_docs::frame_tokens`].
//! with balances or assets pezpallet. More on this in [`crate::reference_docs::frame_tokens`].
//!
//! ## Further References
//!
@@ -158,17 +158,17 @@
use frame::prelude::*;
#[docify::export]
#[frame::pallet]
#[frame::pezpallet]
pub mod pezpallet_foo {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
fn do_stuff_with_author() {
// needs block author here
}
@@ -176,41 +176,41 @@ pub mod pezpallet_foo {
}
#[docify::export]
#[frame::pallet]
#[frame::pezpallet]
pub mod pezpallet_author {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
pub fn author() -> T::AccountId {
todo!("somehow has access to the block author and can return it here")
}
}
}
#[frame::pallet]
#[frame::pezpallet]
pub mod pezpallet_foo_tight {
use super::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(tight_config)]
/// This pallet can only live in a runtime that has both `pezframe_system` and `pezpallet_author`.
#[pallet::config]
/// This pezpallet can only live in a runtime that has both `pezframe_system` and `pezpallet_author`.
#[pezpallet::config]
pub trait Config: pezframe_system::Config + pezpallet_author::Config {}
#[docify::export(tight_usage)]
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
// anywhere in `pezpallet-foo`, we can call into `pezpallet-author` directly, namely because
// `T: pezpallet_author::Config`
fn do_stuff_with_author() {
let _ = pezpallet_author::Pallet::<T>::author();
let _ = pezpallet_author::Pezpallet::<T>::author();
}
}
}
@@ -221,23 +221,23 @@ pub trait AuthorProvider<AccountId> {
fn author() -> AccountId;
}
#[frame::pallet]
#[frame::pezpallet]
pub mod pezpallet_foo_loose {
use super::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(loose_config)]
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// This pallet relies on the existence of something that implements [`AuthorProvider`],
/// This pezpallet relies on the existence of something that implements [`AuthorProvider`],
/// which may or may not be `pezpallet-author`.
type AuthorProvider: AuthorProvider<Self::AccountId>;
}
#[docify::export(loose_usage)]
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
fn do_stuff_with_author() {
let _ = T::AuthorProvider::author();
}
@@ -245,9 +245,9 @@ pub mod pezpallet_foo_loose {
}
#[docify::export(pezpallet_author_provider)]
impl<T: pezpallet_author::Config> AuthorProvider<T::AccountId> for pezpallet_author::Pallet<T> {
impl<T: pezpallet_author::Config> AuthorProvider<T::AccountId> for pezpallet_author::Pezpallet<T> {
fn author() -> T::AccountId {
pezpallet_author::Pallet::<T>::author()
pezpallet_author::Pezpallet::<T>::author()
}
}
@@ -269,7 +269,7 @@ impl<AccountId> AuthorProvider<AccountId> for () {
pub mod runtime {
use super::*;
use pezcumulus_pezpallet_aura_ext::pallet;
use pezcumulus_pezpallet_aura_ext::pezpallet;
use frame::{runtime::prelude::*, testing_prelude::*};
construct_runtime!(
@@ -289,7 +289,7 @@ pub mod runtime {
#[docify::export(runtime_author_provider)]
impl pezpallet_foo_loose::Config for Runtime {
type AuthorProvider = pezpallet_author::Pallet<Runtime>;
type AuthorProvider = pezpallet_author::Pezpallet<Runtime>;
// which is also equivalent to
// type AuthorProvider = PalletAuthor;
}
@@ -0,0 +1,296 @@
//! # FRAME Pezpallet Coupling
//!
//! This reference document explains how FRAME pezpallets can be combined to interact together.
//!
//! It is suggested to re-read [`crate::pezkuwi_sdk::frame_runtime`], notably the information
//! around [`frame::pezpallet_macros::config`]. Recall that:
//!
//! > Configuration trait of a pezpallet: It allows a pezpallet to receive types at a later
//! > point from the runtime that wishes to contain it. It allows the pezpallet to be parameterized
//! > over both types and values.
//!
//! ## Context, Background
//!
//! FRAME pezpallets, as per described in [`crate::pezkuwi_sdk::frame_runtime`] are:
//!
//! > A pezpallet is a unit of encapsulated logic. It has a clearly defined responsibility and can be
//! linked to other pezpallets.
//!
//! That is to say:
//!
//! * *encapsulated*: Ideally, a FRAME pezpallet contains encapsulated logic which has clear
//! boundaries. It is generally a bad idea to build a single monolithic pezpallet that does multiple
//! things, such as handling currencies, identities and staking all at the same time.
//! * *linked to other pezpallets*: But, adhering extensively to the above also hinders the ability to
//! write useful applications. Pezpallets often need to work with each other, communicate and use
//! each other's functionalities.
//!
//! The broad principle that allows pezpallets to be linked together is the same way through which a
//! pezpallet uses its `Config` trait to receive types and values from the runtime that contains it.
//!
//! There are generally two ways to achieve this:
//!
//! 1. Tight coupling pezpallets.
//! 2. Loose coupling pezpallets.
//!
//! To explain the difference between the two, consider two pezpallets, `A` and `B`. In both cases, `A`
//! wants to use some functionality exposed by `B`.
//!
//! When tightly coupling pezpallets, `A` can only exist in a runtime if `B` is also present in the
//! same runtime. That is, `A` is expressing that can only work if `B` is present.
//!
//! This translates to the following Rust code:
//!
//! ```
//! trait Pezpallet_B_Config {}
//! trait Pezpallet_A_Config: Pezpallet_B_Config {}
//! ```
//!
//! Contrary, when pezpallets are loosely coupled, `A` expresses that some functionality, expressed via
//! a trait `F`, needs to be fulfilled. This trait is then implemented by `B`, and the two pezpallets
//! are linked together at the runtime level. This means that `A` only relies on the implementation
//! of `F`, which may be `B`, or another implementation of `F`.
//!
//! This translates to the following Rust code:
//!
//! ```
//! trait F {}
//! trait Pezpallet_A_Config {
//! type F: F;
//! }
//! // Pezpallet_B will implement and fulfill `F`.
//! ```
//!
//! ## Example
//!
//! Consider the following example, in which `pezpallet-foo` needs another pezpallet to provide the block
//! author to it, and `pezpallet-author` which has access to this information.
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", pezpallet_foo)]
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", pezpallet_author)]
//!
//! ### Tight Coupling Pezpallets
//!
//! To tightly couple `pezpallet-foo` and `pezpallet-author`, we use Rust's supertrait system. When a
//! pezpallet makes its own `trait Config` be bounded by another pezpallet's `trait Config`, it is
//! expressing two things:
//!
//! 1. That it can only exist in a runtime if the other pezpallet is also present.
//! 2. That it can use the other pezpallet's functionality.
//!
//! `pezpallet-foo`'s `Config` would then look like:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", tight_config)]
//!
//! And `pezpallet-foo` can use the method exposed by `pezpallet_author::Pezpallet` directly:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", tight_usage)]
//!
//!
//! ### Loosely Coupling Pezpallets
//!
//! If `pezpallet-foo` wants to *not* rely on `pezpallet-author` directly, it can leverage its
//! `Config`'s associated types. First, we need a trait to express the functionality that
//! `pezpallet-foo` wants to obtain:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", AuthorProvider)]
//!
//! > We sometimes refer to such traits that help two pezpallets interact as "glue traits".
//!
//! Next, `pezpallet-foo` states that it needs this trait to be provided to it, at the runtime level,
//! via an associated type:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", loose_config)]
//!
//! Then, `pezpallet-foo` can use this trait to obtain the block author, without knowing where it comes
//! from:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", loose_usage)]
//!
//! Then, if `pezpallet-author` implements this glue-trait:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", pezpallet_author_provider)]
//!
//! And upon the creation of the runtime, the two pezpallets are linked together as such:
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", runtime_author_provider)]
//!
//! Crucially, when using loose coupling, we gain the flexibility of providing different
//! implementations of `AuthorProvider`, such that different users of a `pezpallet-foo` can use
//! different ones, without any code change being needed. For example, in the code snippets of this
//! module, you can find [`OtherAuthorProvider`], which is an alternative implementation of
//! [`AuthorProvider`].
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", other_author_provider)]
//!
//! A common pattern in pezkuwi-sdk is to provide an implementation of such glu traits for the unit
//! type as a "default/test behavior".
#![doc = docify::embed!("./src/reference_docs/frame_pezpallet_coupling.rs", unit_author_provider)]
//!
//! ## Frame System
//!
//! With the above information in context, we can conclude that **`pezframe_system` is a special pezpallet
//! that is tightly coupled with every other pezpallet**. This is because it provides the fundamental
//! system functionality that every pezpallet needs, such as some types like
//! [`frame::prelude::pezframe_system::Config::AccountId`],
//! [`frame::prelude::pezframe_system::Config::Hash`], and some functionality such as block number,
//! etc.
//!
//! ## Recap
//!
//! To recap, consider the following rules of thumb:
//!
//! * In all cases, try and break down big pezpallets apart with clear boundaries of responsibility. In
//! general, it is easier to argue about multiple pezpallet if they only communicate together via a
//! known trait, rather than having access to all of each others public items, such as storage and
//! dispatchables.
//! * If a group of pezpallets is meant to work together, but is not foreseen to be generalized, or
//! used by others, consider tightly coupling pezpallets, *if it simplifies the development*.
//! * If a pezpallet needs a functionality provided by another pezpallet, but multiple implementations can
//! be foreseen, consider loosely coupling pezpallets.
//!
//! For example, all pezpallets in `pezkuwi-sdk` that needed to work with currencies could have been
//! tightly coupled with [`pezpallet_balances`]. But, `pezkuwi-sdk` also provides [`pezpallet_assets`]
//! (and more implementations by the community), therefore all pezpallets use traits to loosely couple
//! with balances or assets pezpallet. More on this in [`crate::reference_docs::frame_tokens`].
//!
//! ## Further References
//!
//! - <https://www.youtube.com/watch?v=0eNGZpNkJk4>
//! - <https://exchange.pezkuwichain.app/questions/922/pezpallet-loose-couplingtight-coupling-and-missing-traits>
//!
//! [`AuthorProvider`]: crate::reference_docs::frame_pezpallet_coupling::AuthorProvider
//! [`OtherAuthorProvider`]: crate::reference_docs::frame_pezpallet_coupling::OtherAuthorProvider
#![allow(unused)]
use frame::prelude::*;
#[docify::export]
#[frame::pezpallet]
pub mod pezpallet_foo {
use super::*;
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
impl<T: Config> Pezpallet<T> {
fn do_stuff_with_author() {
// needs block author here
}
}
}
#[docify::export]
#[frame::pezpallet]
pub mod pezpallet_author {
use super::*;
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
impl<T: Config> Pezpallet<T> {
pub fn author() -> T::AccountId {
todo!("somehow has access to the block author and can return it here")
}
}
}
#[frame::pezpallet]
pub mod pezpallet_foo_tight {
use super::*;
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(tight_config)]
/// This pezpallet can only live in a runtime that has both `pezframe_system` and `pezpallet_author`.
#[pezpallet::config]
pub trait Config: pezframe_system::Config + pezpallet_author::Config {}
#[docify::export(tight_usage)]
impl<T: Config> Pezpallet<T> {
// anywhere in `pezpallet-foo`, we can call into `pezpallet-author` directly, namely because
// `T: pezpallet_author::Config`
fn do_stuff_with_author() {
let _ = pezpallet_author::Pezpallet::<T>::author();
}
}
}
#[docify::export]
/// Abstraction over "something that can provide the block author".
pub trait AuthorProvider<AccountId> {
fn author() -> AccountId;
}
#[frame::pezpallet]
pub mod pezpallet_foo_loose {
use super::*;
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[docify::export(loose_config)]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// This pezpallet relies on the existence of something that implements [`AuthorProvider`],
/// which may or may not be `pezpallet-author`.
type AuthorProvider: AuthorProvider<Self::AccountId>;
}
#[docify::export(loose_usage)]
impl<T: Config> Pezpallet<T> {
fn do_stuff_with_author() {
let _ = T::AuthorProvider::author();
}
}
}
#[docify::export(pezpallet_author_provider)]
impl<T: pezpallet_author::Config> AuthorProvider<T::AccountId> for pezpallet_author::Pezpallet<T> {
fn author() -> T::AccountId {
pezpallet_author::Pezpallet::<T>::author()
}
}
pub struct OtherAuthorProvider;
#[docify::export(other_author_provider)]
impl<AccountId> AuthorProvider<AccountId> for OtherAuthorProvider {
fn author() -> AccountId {
todo!("somehow get the block author here")
}
}
#[docify::export(unit_author_provider)]
impl<AccountId> AuthorProvider<AccountId> for () {
fn author() -> AccountId {
todo!("somehow get the block author here")
}
}
pub mod runtime {
use super::*;
use pezcumulus_pezpallet_aura_ext::pezpallet;
use frame::{runtime::prelude::*, testing_prelude::*};
construct_runtime!(
pub struct Runtime {
System: pezframe_system,
PezpalletFoo: pezpallet_foo_loose,
PezpalletAuthor: pezpallet_author,
}
);
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Block = MockBlock<Self>;
}
impl pezpallet_author::Config for Runtime {}
#[docify::export(runtime_author_provider)]
impl pezpallet_foo_loose::Config for Runtime {
type AuthorProvider = pezpallet_author::Pezpallet<Runtime>;
// which is also equivalent to
// type AuthorProvider = PezpalletAuthor;
}
}
@@ -13,7 +13,7 @@
//!
//! Many types within a FRAME runtime follow the following structure:
//!
//! * Each individual pallet defines a type, for example `Foo`.
//! * Each individual pezpallet defines a type, for example `Foo`.
//! * At the runtime level, these types are amalgamated into a single type, for example
//! `RuntimeFoo`.
//!
@@ -38,9 +38,9 @@
//! Let's explore how each of these affect the [`RuntimeCall`], [`RuntimeOrigin`] and
//! [`RuntimeGenesisConfig`] generated in [`runtime`] respectively.
//!
//! As observed, [`RuntimeCall`] has 3 variants, one for each pallet and one for `pezframe_system`. If
//! As observed, [`RuntimeCall`] has 3 variants, one for each pezpallet and one for `pezframe_system`. If
//! you explore further, you will soon realize that each variant is merely a pointer to the `Call`
//! type in each pallet, for example [`pezpallet_foo::Call`].
//! type in each pezpallet, for example [`pezpallet_foo::Call`].
//!
//! [`RuntimeOrigin`]'s [`OriginCaller`] has two variants, one for system, and one for `pezpallet_foo`
//! which utilized [`frame::pezpallet_macros::origin`].
@@ -57,7 +57,7 @@
//!
//! ### Adding Further Constraints to Runtime Composite Enums
//!
//! This section explores a common scenario where a pallet has access to one of these runtime
//! This section explores a common scenario where a pezpallet has access to one of these runtime
//! composite enums, but it wishes to further specify it by adding more trait bounds to it.
//!
//! Let's take the example of `RuntimeCall`. This is an associated type in
@@ -70,14 +70,14 @@
//! [`pezframe_system::Config::RuntimeCall`] are specifying:
#![doc = docify::embed!("../../bizinikiwi/pezframe/system/src/lib.rs", system_runtime_call)]
//!
//! So, when at a given pallet, one accesses `<T as pezframe_system::Config>::RuntimeCall`, the type is
//! So, when at a given pezpallet, one accesses `<T as pezframe_system::Config>::RuntimeCall`, the type is
//! extremely opaque from the perspective of the Rust compiler.
//!
//! How can a pallet access the `RuntimeCall` type with further constraints? For example, each
//! pallet has its own `enum Call`, and knows that its local `Call` is a part of `RuntimeCall`,
//! How can a pezpallet access the `RuntimeCall` type with further constraints? For example, each
//! pezpallet has its own `enum Call`, and knows that its local `Call` is a part of `RuntimeCall`,
//! therefore there should be a `impl From<Call<_>> for RuntimeCall`.
//!
//! The only way to express this using Rust's associated types is for the pallet to **define its own
//! The only way to express this using Rust's associated types is for the pezpallet to **define its own
//! associated type `RuntimeCall`, and further specify what it thinks `RuntimeCall` should be**.
//!
//! In this case, we will want to assert the existence of [`frame::traits::IsSubType`], which is
@@ -89,7 +89,7 @@
#![doc = docify::embed!("./src/reference_docs/frame_runtime_types.rs", pezpallet_with_specific_runtime_call_impl)]
//!
//! > In other words, the degree of specificity that [`pezframe_system::Config::RuntimeCall`] has is
//! > not enough for the pallet to work with. Therefore, the pallet has to define its own associated
//! > not enough for the pezpallet to work with. Therefore, the pezpallet has to define its own associated
//! > type representing `RuntimeCall`.
//!
//! Another way to look at this is:
@@ -98,7 +98,7 @@
//! are two different representations of the same concrete type that is only known when the runtime
//! is being constructed.
//!
//! Now, within this pallet, this new `RuntimeCall` can be used, and it can use its new trait
//! Now, within this pezpallet, this new `RuntimeCall` can be used, and it can use its new trait
//! bounds, such as being [`frame::traits::IsSubType`]:
#![doc = docify::embed!("./src/reference_docs/frame_runtime_types.rs", custom_runtime_call_usages)]
//!
@@ -123,7 +123,7 @@
//!
//! A number of type aliases are generated by the `construct_runtime` which are also noteworthy:
//!
//! * [`runtime::PalletFoo`] is an alias to [`pezpallet_foo::Pallet`]. Same for `PalletBar`, and
//! * [`runtime::PalletFoo`] is an alias to [`pezpallet_foo::Pezpallet`]. Same for `PalletBar`, and
//! `System`
//! * [`runtime::AllPalletsWithSystem`] is an alias for a tuple of all of the above. This type is
//! important to FRAME internals such as `executive`, as it implements traits such as
@@ -145,7 +145,7 @@
//! [`runtime`]: crate::reference_docs::frame_runtime_types::runtime
//! [`pezpallet_foo`]: crate::reference_docs::frame_runtime_types::pezpallet_foo
//! [`pezpallet_foo::Call`]: crate::reference_docs::frame_runtime_types::pezpallet_foo::Call
//! [`pezpallet_foo::Pallet`]: crate::reference_docs::frame_runtime_types::pezpallet_foo::Pallet
//! [`pezpallet_foo::Pezpallet`]: crate::reference_docs::frame_runtime_types::pezpallet_foo::Pezpallet
//! [`pezpallet_bar`]: crate::reference_docs::frame_runtime_types::pezpallet_bar
//! [`pezpallet_bar::GenesisConfig`]: crate::reference_docs::frame_runtime_types::pezpallet_bar::GenesisConfig
//! [`RuntimeEvent`]: crate::reference_docs::frame_runtime_types::runtime::RuntimeEvent
@@ -160,14 +160,14 @@
use frame::prelude::*;
#[docify::export]
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_foo {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::origin]
#[pezpallet::origin]
#[derive(
PartialEq,
Eq,
@@ -184,11 +184,11 @@ pub mod pezpallet_foo {
B,
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn foo(_origin: OriginFor<T>) -> DispatchResult {
todo!();
}
@@ -200,29 +200,29 @@ pub mod pezpallet_foo {
}
#[docify::export]
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_bar {
use super::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub initial_account: Option<T::AccountId>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn bar(_origin: OriginFor<T>) -> DispatchResult {
todo!();
}
@@ -251,41 +251,41 @@ pub mod runtime {
impl pezpallet_bar::Config for Runtime {}
}
#[frame::pallet(dev_mode)]
#[frame::pezpallet(dev_mode)]
pub mod pezpallet_with_specific_runtime_call {
use super::*;
use frame::traits::IsSubType;
#[docify::export(custom_runtime_call)]
/// A pallet that wants to further narrow down what `RuntimeCall` is.
#[pallet::config]
/// A pezpallet that wants to further narrow down what `RuntimeCall` is.
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
type RuntimeCall: IsSubType<Call<Self>>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
// note that this pallet needs some `call` to have a `enum Call`.
#[pallet::call]
impl<T: Config> Pallet<T> {
// note that this pezpallet needs some `call` to have a `enum Call`.
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn foo(_origin: OriginFor<T>) -> DispatchResult {
todo!();
}
}
#[docify::export(custom_runtime_call_usages)]
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
fn _do_something_useful_with_runtime_call(call: <T as Config>::RuntimeCall) {
// check if the runtime call given is of this pallet's variant.
// check if the runtime call given is of this pezpallet's variant.
let _maybe_my_call: Option<&Call<T>> = call.is_sub_type();
todo!();
}
}
#[docify::export(assert_equality)]
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn integrity_test() {
use core::any::TypeId;
assert_eq!(
@@ -39,11 +39,11 @@
//!
//! Self-contained pieces of logic that execute after a runtime upgrade are called "Migrations".
//!
//! The typical use case of a migration is to 'migrate' pallet storage from one layout to another,
//! The typical use case of a migration is to 'migrate' pezpallet storage from one layout to another,
//! for example when the encoding of a storage item is changed. However, they can also execute
//! arbitrary logic such as:
//!
//! - Calling arbitrary pallet methods.
//! - Calling arbitrary pezpallet methods.
//! - Mutating arbitrary on-chain state.
//! - Cleaning up some old storage items that are no longer needed.
//!
@@ -54,13 +54,13 @@
//! - Are suitable for migrations which are guaranteed to not exceed the block weight.
//! - Are simply implementations of [`OnRuntimeUpgrade`].
//!
//! To learn best practices for writing single block pallet storage migrations, see the
//! [Single Block Migration Example Pallet](pezpallet_example_single_block_migrations).
//! To learn best practices for writing single block pezpallet storage migrations, see the
//! [Single Block Migration Example Pezpallet](pezpallet_example_single_block_migrations).
//!
//! ### Scheduling the Single Block Migrations to Run Next Runtime Upgrade
//!
//! Schedule migrations to run next runtime upgrade passing them as a parameter to your
//! [`Config`](pezframe_system) pallet:
//! [`Config`](pezframe_system) pezpallet:
//!
//! ```ignore
//! /// Tuple of migrations (structs that implement `OnRuntimeUpgrade`)
@@ -8,16 +8,16 @@
//! Let's begin by starting to store a `NewType` in a storage item:
//!
//! ```compile_fail
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! pub struct NewType(u32);
//
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Something<T> = StorageValue<_, NewType>;
//! }
//! ```
@@ -32,17 +32,17 @@
//! This implies the following set of traits that need to be derived for a type to be stored in
//! `frame` storage:
//! ```rust
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! #[derive(codec::Encode, codec::Decode, codec::MaxEncodedLen, scale_info::TypeInfo)]
//! pub struct NewType(u32);
//!
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Something<T> = StorageValue<_, NewType>;
//! }
//! ```
@@ -50,17 +50,17 @@
//! Next, let's look at how this will differ if we are to store a type that is derived from `T` in
//! storage, such as [`frame::prelude::BlockNumberFor`]:
//! ```compile_fail
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! #[derive(codec::Encode, codec::Decode, codec::MaxEncodedLen, scale_info::TypeInfo)]
//! pub struct NewType<T: Config>(BlockNumberFor<T>);
//!
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Something<T: Config> = StorageValue<_, NewType<T>>;
//! }
//! ```
@@ -84,18 +84,18 @@
//! attribute to `NewType`. This additional macro will instruct the `derive` to skip the bound on
//! `T`.
//! ```rust
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! #[derive(codec::Encode, codec::Decode, codec::MaxEncodedLen, scale_info::TypeInfo)]
//! #[scale_info(skip_type_params(T))]
//! pub struct NewType<T: Config>(BlockNumberFor<T>);
//!
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Something<T: Config> = StorageValue<_, NewType<T>>;
//! }
//! ```
@@ -104,18 +104,18 @@
//! must also implement `Default`. This should be as simple as adding `derive(Default)` to it,
//! right?
//! ```compile_fail
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! #[derive(codec::Encode, codec::Decode, codec::MaxEncodedLen, scale_info::TypeInfo, Default)]
//! #[scale_info(skip_type_params(T))]
//! pub struct NewType<T: Config>(BlockNumberFor<T>);
//!
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Something<T: Config> = StorageValue<_, NewType<T>, ValueQuery>;
//! }
//! ```
@@ -142,13 +142,13 @@
//!
//! We can fix the following example by using [`frame::prelude::DefaultNoBound`].
//! ```rust
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! # use frame::prelude::*;
//! # #[pallet::config]
//! # #[pezpallet::config]
//! # pub trait Config: pezframe_system::Config {}
//! # #[pallet::pallet]
//! # pub struct Pallet<T>(_);
//! # #[pezpallet::pezpallet]
//! # pub struct Pezpallet<T>(_);
//! #[derive(
//! codec::Encode,
//! codec::Decode,
@@ -159,7 +159,7 @@
//! #[scale_info(skip_type_params(T))]
//! pub struct NewType<T:Config>(BlockNumberFor<T>);
//!
//! #[pallet::storage]
//! #[pezpallet::storage]
//! pub type Something<T: Config> = StorageValue<_, NewType<T>, ValueQuery>;
//! }
//! ```
@@ -167,26 +167,26 @@
//! Finally, if a custom type that is provided through `Config` is to be stored in the storage, it
//! is subject to the same trait requirements. The following does not work:
//! ```compile_fail
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! use frame::prelude::*;
//! #[pallet::config]
//! #[pezpallet::config]
//! pub trait Config: pezframe_system::Config {
//! type CustomType;
//! }
//! #[pallet::pallet]
//! pub struct Pallet<T>(_);
//! #[pallet::storage]
//! #[pezpallet::pezpallet]
//! pub struct Pezpallet<T>(_);
//! #[pezpallet::storage]
//! pub type Something<T: Config> = StorageValue<_, T::CustomType>;
//! }
//! ```
//!
//! But adding the right trait bounds will fix it.
//! ```rust
//! #[frame::pallet]
//! pub mod pallet {
//! #[frame::pezpallet]
//! pub mod pezpallet {
//! use frame::prelude::*;
//! #[pallet::config]
//! #[pezpallet::config]
//! pub trait Config: pezframe_system::Config {
//! type CustomType: codec::FullCodec
//! + codec::MaxEncodedLen
@@ -194,9 +194,9 @@
//! + Debug
//! + Default;
//! }
//! #[pallet::pallet]
//! pub struct Pallet<T>(_);
//! #[pallet::storage]
//! #[pezpallet::pezpallet]
//! pub struct Pezpallet<T>(_);
//! #[pezpallet::storage]
//! pub type Something<T: Config> = StorageValue<_, T::CustomType>;
//! }
//! ```
+10 -10
View File
@@ -36,7 +36,7 @@
//! You may then write custom pallets that interact with [`pezpallet_balances`]. The fastest way to
//! get started with that is by
//! [tightly coupling](crate::reference_docs::frame_pallet_coupling#tight-coupling-pallets) your
//! custom pallet to [`pezpallet_balances`].
//! custom pezpallet to [`pezpallet_balances`].
//!
//! However, to keep pallets flexible and modular, it is often preferred to
//! [loosely couple](crate::reference_docs::frame_pallet_coupling#loosely--coupling-pallets).
@@ -70,18 +70,18 @@
//! The distinction between traits and trait implementations is helpful because it allows pallets
//! and other logic to be generic over their dependencies, avoiding tight coupling.
//!
//! To illustrate this with an example let's consider [`pezpallet_preimage`]. This pallet takes a
//! To illustrate this with an example let's consider [`pezpallet_preimage`]. This pezpallet takes a
//! deposit in exchange for storing a preimage for later use. A naive implementation of the
//! pallet may use [`pezpallet_balances`] in a tightly coupled manner, directly calling methods
//! on the pallet to reserve and unreserve deposits. This approach works well,
//! until someone has a use case requiring that an asset from a different pallet such as
//! pezpallet may use [`pezpallet_balances`] in a tightly coupled manner, directly calling methods
//! on the pezpallet to reserve and unreserve deposits. This approach works well,
//! until someone has a use case requiring that an asset from a different pezpallet such as
//! [`pezpallet_assets`] is used for the deposit. Rather than tightly coupling [`pezpallet_preimage`] to
//! [`pezpallet_balances`], [`pezpallet_assets`], and every other token-handling pallet, a user
//! could possibly specify that [`pezpallet_preimage`] does not specify a concrete pallet as a
//! [`pezpallet_balances`], [`pezpallet_assets`], and every other token-handling pezpallet, a user
//! could possibly specify that [`pezpallet_preimage`] does not specify a concrete pezpallet as a
//! dependency, but instead accepts any dependency which implements the
//! [`currency::ReservableCurrency`](`pezframe_support::traits::tokens::currency::ReservableCurrency`)
//! trait, namely via its [`Config::Currency`](`pezpallet_preimage::pallet::Config::Currency`)
//! associated type. This allows [`pezpallet_preimage`] to support any arbitrary pallet implementing
//! trait, namely via its [`Config::Currency`](`pezpallet_preimage::pezpallet::Config::Currency`)
//! associated type. This allows [`pezpallet_preimage`] to support any arbitrary pezpallet implementing
//! this trait, without needing any knowledge of what those pallets may be or requiring changes to
//! support new pallets which may be written in the future.
//!
@@ -115,7 +115,7 @@
//! ## Non-Fungible Tokens in FRAME
//!
//! [`pezpallet_nfts`] is recommended to use for all NFT use cases in FRAME.
//! See the crate documentation for more info about this pallet.
//! See the crate documentation for more info about this pezpallet.
//!
//! [`pezpallet_uniques`] is deprecated and should not be used.
//!
+2 -2
View File
@@ -66,14 +66,14 @@
//! included into a block and leads to some action. This includes user-initiated transactions as
//! well as inherents which are placed into the block by the block-builder.
//!
//! #### Pallet
//! #### Pezpallet
//!
//! Similar to software modules in traditional programming, [FRAME](frame) pallets in Bizinikiwi are
//! modular components that encapsulate distinct functionalities or business logic. Just as
//! libraries or modules are used to build and extend the capabilities of a software application,
//! pallets are the foundational building blocks for constructing a blockchain's runtime with frame.
//! They enable the creation of customizable and upgradeable networks, offering a composable
//! framework for a Bizinikiwi-based blockchain. Each pallet can be thought of as a plug-and-play
//! framework for a Bizinikiwi-based blockchain. Each pezpallet can be thought of as a plug-and-play
//! module, enhancing the blockchain's functionality in a cohesive and integrated manner.
//!
//! #### Full Node
+1 -1
View File
@@ -60,7 +60,7 @@ pub mod defensive_programming;
/// `RuntimeCall`.
pub mod frame_runtime_types;
/// Learn about how to make a pallet/runtime that is fee-less and instead uses another mechanism to
/// Learn about how to make a pezpallet/runtime that is fee-less and instead uses another mechanism to
/// control usage and sybil attacks.
pub mod fee_less_runtime;
+3 -3
View File
@@ -120,7 +120,7 @@
//!
//! In practice, the majority of the implementation of any consensus engine is in the node side, but
//! the runtime also typically needs to expose a custom runtime-api to enable the particular
//! consensus engine to work, and that particular runtime-api is implemented by a pallet
//! consensus engine to work, and that particular runtime-api is implemented by a pezpallet
//! corresponding to that consensus engine.
//!
//! For example, taking a snippet from [`pez_solochain_template_runtime`], the runtime has to provide
@@ -187,7 +187,7 @@
//! The list of checks may evolve in the future and for now only few rules are implemented:
//! * runtimes must define a type for [`pezcumulus-pezpallet-teyrchain-system`], which is recommended to
//! be named as `TeyrchainSystem`.
//! * runtimes must define a type for [`pezframe-system`] pallet, which is recommended to be named as
//! * runtimes must define a type for [`pezframe-system`] pezpallet, which is recommended to be named as
//! `System`. The configured [`block number`] here will be used by Omni Node to configure AURA
//! accordingly.
//!
@@ -198,4 +198,4 @@
//! [`chain-spec-builder`]: https://crates.io/crates/pezstaging-chain-spec-builder
//! [`pezcumulus-pezpallet-teyrchain-system`]: https://docs.rs/pezcumulus-pezpallet-parachain-system/latest/pezcumulus_pezpallet_parachain_system/
//! [`pezframe-system`]: https://docs.rs/pezframe-system/latest/pezframe_system/
//! [`block number`]: https://docs.rs/pezframe-system/latest/pezframe_system/pallet/storage_types/struct.Number.html
//! [`block number`]: https://docs.rs/pezframe-system/latest/pezframe_system/pezpallet/storage_types/struct.Number.html
@@ -9,8 +9,8 @@
//! section.
//! Moreover, we use the [`frame::traits::Get`].
//!
//! First, imagine we are writing a FRAME pallet. We represent this pallet with a `struct Pallet`,
//! and this pallet wants to implement the functionalities of that pallet, for example a simple
//! First, imagine we are writing a FRAME pezpallet. We represent this pezpallet with a `struct Pezpallet`,
//! and this pezpallet wants to implement the functionalities of that pezpallet, for example a simple
//! `transfer` function. For the sake of education, we are interested in having a `MinTransfer`
//! amount, expressed as a [`frame::traits::Get`], which will dictate what is the minimum amount
//! that can be transferred.
@@ -26,10 +26,10 @@
//! In a broad sense, there are two avenues in exposing configurability:
//!
//! 1. For *values* that need to be generic, for example `MinTransfer`, we attach them to the
//! `Pallet` struct as fields:
//! `Pezpallet` struct as fields:
//!
//! ```
//! struct Pallet {
//! struct Pezpallet {
//! min_transfer: u128,
//! }
//! ```
@@ -38,7 +38,7 @@
//! as:
//!
//! ```
//! struct Pallet<AccountId> {
//! struct Pezpallet<AccountId> {
//! min_transfer: u128,
//! _marker: std::marker::PhantomData<AccountId>,
//! }
@@ -48,13 +48,13 @@
//! use *types* to declare both *values* and *types* as generic. This is the essence of why the
//! `Get` trait exists.
//!
//! This would bring us to the second iteration of the pallet, which would look like:
//! This would bring us to the second iteration of the pezpallet, which would look like:
#![doc = docify::embed!("./src/reference_docs/trait_based_programming.rs", generic)]
//!
//! In this example, we managed to make all 3 of our types generic. Taking the example of the
//! `AccountId`, one should read the above as following:
//!
//! > The `Pallet` does not know what type `AccountId` concretely is, but it knows that it is
//! > The `Pezpallet` does not know what type `AccountId` concretely is, but it knows that it is
//! > something that adheres to being `From<[u8; 32]>`.
//!
//! This method would work, but it suffers from two downsides:
@@ -117,13 +117,13 @@ use frame::traits::Get;
#[docify::export]
mod basic {
struct Pallet;
struct Pezpallet;
type AccountId = frame::deps::pezsp_runtime::AccountId32;
type Balance = u128;
type MinTransfer = frame::traits::ConstU128<10>;
impl Pallet {
impl Pezpallet {
fn transfer(_from: AccountId, _to: AccountId, _amount: Balance) {
todo!()
}
@@ -134,11 +134,11 @@ mod basic {
mod generic {
use super::*;
struct Pallet<AccountId, Balance, MinTransfer> {
struct Pezpallet<AccountId, Balance, MinTransfer> {
_marker: std::marker::PhantomData<(AccountId, Balance, MinTransfer)>,
}
impl<AccountId, Balance, MinTransfer> Pallet<AccountId, Balance, MinTransfer>
impl<AccountId, Balance, MinTransfer> Pezpallet<AccountId, Balance, MinTransfer>
where
Balance: frame::traits::AtLeast32BitUnsigned,
MinTransfer: frame::traits::Get<Balance>,
@@ -161,8 +161,8 @@ mod trait_based {
type MinTransfer: frame::traits::Get<Self::Balance>;
}
struct Pallet<T: Config>(std::marker::PhantomData<T>);
impl<T: Config> Pallet<T> {
struct Pezpallet<T: Config>(std::marker::PhantomData<T>);
impl<T: Config> Pezpallet<T> {
fn transfer(_from: T::AccountId, _to: T::AccountId, amount: T::Balance) {
assert!(amount >= T::MinTransfer::get());
unimplemented!();
@@ -183,8 +183,8 @@ mod with_system {
type MinTransfer: frame::traits::Get<Self::Balance>;
}
pub struct Pallet<T: Config>(std::marker::PhantomData<T>);
impl<T: Config> Pallet<T> {
pub struct Pezpallet<T: Config>(std::marker::PhantomData<T>);
impl<T: Config> Pezpallet<T> {
fn transfer(_from: T::AccountId, _to: T::AccountId, amount: T::Balance) {
assert!(amount >= T::MinTransfer::get());
unimplemented!();
@@ -213,8 +213,8 @@ mod fully_qualified_complicated {
type Currency: CurrencyTrait;
}
struct Pallet<T: Config>(std::marker::PhantomData<T>);
impl<T: Config> Pallet<T> {
struct Pezpallet<T: Config>(std::marker::PhantomData<T>);
impl<T: Config> Pezpallet<T> {
fn transfer(
_from: T::AccountId,
_to: T::AccountId,
+4 -4
View File
@@ -142,7 +142,7 @@ PezkuwiChain is a decentralized system of nodes (Validators, Nominators, Full No
---
## 9. Governance Model & 10. Security
Governance is managed on-chain via the `welati` pallet, allowing PEZ holders to propose, vote on, and enact changes. Security is multi-layered, leveraging Rust's memory safety, the battle-tested framework, forkless upgrades, and the economic and social disincentives for bad actors provided by TNPoS.
Governance is managed on-chain via the `welati` pezpallet, allowing PEZ holders to propose, vote on, and enact changes. Security is multi-layered, leveraging Rust's memory safety, the battle-tested framework, forkless upgrades, and the economic and social disincentives for bad actors provided by TNPoS.
---
## 11. Roadmap & 12. Use Cases
@@ -205,13 +205,13 @@ The project operates under the Kurdistan Talent Institute License. It is a utili
- **FRAME:** The framework used for building blockchain runtimes with modular pallets.
- **HEZ:** The native inflationary token of PezkuwiChain, used for staking, transaction fees, and network security.
- **NPoS (Nominated Proof-of-Stake):** The consensus mechanism where nominators elect validators.
- **Pallet:** A modular component in the Bizinikiwi runtime that provides specific functionality.
- **Pezpallet:** A modular component in the Bizinikiwi runtime that provides specific functionality.
- **PEZ:** The fixed-supply governance token of PezkuwiChain (5 billion total), used for governance and rewards.
- **TNPoS (Trust-enhanced Nominated Proof-of-Stake):** PezkuwiChain's novel consensus mechanism that integrates trust scores.
- **Trust Score:** A reputation metric calculated by `pezpallet-trust`.
- **Wasm (WebAssembly):** The portable binary instruction format used for the PezkuwiChain runtime, enabling forkless upgrades.
- **welati:** The governance pallet for PezkuwiChain. The name means "citizen" in Kurdish.
- **perwerde:** The education and certification pallet. The name means "education" in Kurdish.
- **welati:** The governance pezpallet for PezkuwiChain. The name means "citizen" in Kurdish.
- **perwerde:** The education and certification pezpallet. The name means "education" in Kurdish.
- **XCM (Cross-Consensus Messaging):** A messaging format for communication between different consensus systems.
---