mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Enhancement on Substrate Node Template (#8473)
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
||||
edition = '2018'
|
||||
name = 'pallet-template'
|
||||
version = "2.0.0"
|
||||
version = "3.0.0"
|
||||
license = "Unlicense"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/substrate/"
|
||||
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
|
||||
description = "FRAME pallet template for defining custom runtime logic."
|
||||
readme = "README.md"
|
||||
|
||||
@@ -14,40 +14,15 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
|
||||
[dependencies.frame-support]
|
||||
default-features = false
|
||||
version = "3.0.0"
|
||||
path = "../../../../frame/support"
|
||||
|
||||
[dependencies.frame-system]
|
||||
default-features = false
|
||||
version = "3.0.0"
|
||||
path = "../../../../frame/system"
|
||||
|
||||
[dependencies.frame-benchmarking]
|
||||
default-features = false
|
||||
version = "3.1.0"
|
||||
path = "../../../../frame/benchmarking"
|
||||
optional = true
|
||||
frame-support = { default-features = false, version = "3.0.0", path = "../../../../frame/support" }
|
||||
frame-system = { default-features = false, version = "3.0.0", path = "../../../../frame/system" }
|
||||
frame-benchmarking = { default-features = false, version = "3.1.0", path = "../../../../frame/benchmarking", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde = { version = "1.0.101" }
|
||||
|
||||
[dev-dependencies.sp-core]
|
||||
default-features = false
|
||||
version = "3.0.0"
|
||||
path = "../../../../primitives/core"
|
||||
|
||||
[dev-dependencies.sp-io]
|
||||
default-features = false
|
||||
version = "3.0.0"
|
||||
path = "../../../../primitives/io"
|
||||
|
||||
[dev-dependencies.sp-runtime]
|
||||
default-features = false
|
||||
version = "3.0.0"
|
||||
path = "../../../../primitives/runtime"
|
||||
serde = { version = "1.0.119" }
|
||||
sp-core = { default-features = false, version = "3.0.0", path = "../../../../primitives/core" }
|
||||
sp-io = { default-features = false, version = "3.0.0", path = "../../../../primitives/io" }
|
||||
sp-runtime = { default-features = false, version = "3.0.0", path = "../../../../primitives/runtime" }
|
||||
|
||||
[features]
|
||||
default = ['std']
|
||||
@@ -57,5 +32,6 @@ std = [
|
||||
'frame-system/std',
|
||||
'frame-benchmarking/std',
|
||||
]
|
||||
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
||||
|
||||
@@ -17,7 +17,7 @@ mod benchmarking;
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*};
|
||||
use frame_support::{dispatch::DispatchResult, pallet_prelude::*};
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||
@@ -70,7 +70,7 @@ pub mod pallet {
|
||||
/// An example dispatchable that takes a singles value as a parameter, writes the value to
|
||||
/// storage and emits an event. This function must be dispatched by a signed extrinsic.
|
||||
#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
|
||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResultWithPostInfo {
|
||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
||||
// Check that the extrinsic was signed and get the signer.
|
||||
// This function will return an error if the extrinsic is not signed.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/origin
|
||||
@@ -82,12 +82,12 @@ pub mod pallet {
|
||||
// Emit an event.
|
||||
Self::deposit_event(Event::SomethingStored(something, who));
|
||||
// Return a successful DispatchResultWithPostInfo
|
||||
Ok(().into())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// An example dispatchable that may throw a custom error.
|
||||
#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
|
||||
pub fn cause_error(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
|
||||
let _who = ensure_signed(origin)?;
|
||||
|
||||
// Read a value from storage.
|
||||
@@ -99,7 +99,7 @@ pub mod pallet {
|
||||
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
|
||||
// Update the value in storage with the incremented result.
|
||||
<Something<T>>::put(new);
|
||||
Ok(().into())
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user