From c5894fdf40ad25a78483cb2e2be6d30b526d5419 Mon Sep 17 00:00:00 2001 From: Utkarsh Bhardwaj Date: Wed, 8 Jan 2025 16:53:13 +0000 Subject: [PATCH] add license header to code files (#292) * add license header to code files * fix typo in license * remove copyright from license headers --- .../build-custom-pallet/src/lib.rs | 19 +++++++++++ .../tests/integration_tests.rs | 19 +++++++++++ .../zero-to-hero/build-custom-pallet.md | 32 +++++++++---------- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs b/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs index fec0ddca9..62f86ad8e 100644 --- a/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs +++ b/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs @@ -1,3 +1,22 @@ +// This file is part of 'custom-pallet'. + +// SPDX-License-Identifier: MIT-0 + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; diff --git a/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/tests/integration_tests.rs b/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/tests/integration_tests.rs index fc5752713..6dafdcc8f 100644 --- a/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/tests/integration_tests.rs +++ b/.snippets/code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/tests/integration_tests.rs @@ -1,3 +1,22 @@ +// This file is part of 'custom-pallet'. + +// SPDX-License-Identifier: MIT-0 + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + use custom_pallet::{self, *}; use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types, traits::ConstU32}; use frame_system::RawOrigin; diff --git a/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet.md b/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet.md index facb90817..e17c8b406 100644 --- a/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet.md +++ b/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet.md @@ -94,9 +94,9 @@ You now have the bare minimum of package dependencies that your pallet requires 2. Prepare the scaffolding for the pallet by adding the following: ```rust - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:1:16' - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:23:23' - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:184:184' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:20:35' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:42:42' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:203:203' ``` 3. Verify that it compiles by running the following command: @@ -118,7 +118,7 @@ In this step, you will configure two essential components that are critical for Add the following `Config` trait definition to your pallet: ```rust ---8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:14:23' +--8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:33:42' ``` ### Add Events @@ -144,7 +144,7 @@ Below are the events defined for this pallet: Define the events in the pallet as follows: ```rust ---8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:25:51' +--8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:44:70' ``` ### Add Storage Items @@ -158,7 +158,7 @@ Storage items are used to manage the pallet's state. This pallet defines two ite Define the storage items as follows: ```rust ---8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:53:59' +--8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:72:78' ``` ### Implement Custom Errors @@ -170,7 +170,7 @@ To add custom errors, use the `#[pallet::error]` macro to define the `Error` enu Add the following errors to the pallet: ```rust ---8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:61:71' +--8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:80:90' ``` ### Implement Calls @@ -180,10 +180,10 @@ The `#[pallet::call]` macro defines the dispatchable functions (or calls) the pa The structure of the dispatchable calls in this pallet is as follows: ```rust ---8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:73:84' - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:99:110' - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:143:154' ---8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:182:183' +--8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:92:103' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:118:129' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:162:173' +--8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:201:202' ``` Below you can find the implementations of each dispatchable call in this pallet: @@ -200,7 +200,7 @@ Below you can find the implementations of each dispatchable call in this pallet: - Emits a `CounterValueSet` event on success ```rust - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:75:99' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:94:118' ``` ???- function "increment(origin: OriginFor, amount_to_increment: u32) -> DispatchResult" @@ -217,7 +217,7 @@ Below you can find the implementations of each dispatchable call in this pallet: - Emits a `CounterIncremented` event on success ```rust - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:101:143' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:120:162' ``` @@ -235,7 +235,7 @@ Below you can find the implementations of each dispatchable call in this pallet: - Emits a `CounterDecremented` event on success ```rust - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:145:182' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs:164:201' ``` ## Verify Compilation @@ -256,7 +256,7 @@ To review this implementation, you can find the complete pallet code below: ???+ example "Complete Pallet Code" ```rust - --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs::184' + --8<-- 'code/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/src/lib.rs::203' ``` ## Where to Go Next @@ -271,4 +271,4 @@ To review this implementation, you can find the complete pallet code below: [:octicons-arrow-right-24: Get Started](/tutorials/polkadot-sdk/parachains/zero-to-hero/pallet-unit-testing/) - \ No newline at end of file +