From be60fe053182a506a5508b7aa1311394bc0d7962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Molina?= Date: Mon, 11 Nov 2024 12:55:24 +0100 Subject: [PATCH] Version 1.0.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 57 ++++-------------------------------------------------- src/lib.rs | 8 ++++---- 4 files changed, 10 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8c468c..f89a327 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1650,7 +1650,7 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pallet-blacklist" -version = "0.0.1" +version = "1.0.0" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/Cargo.toml b/Cargo.toml index 2fcdda8..03e8ca5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-blacklist" -version = "0.0.1" +version = "1.0.0" authors = ["José Molina "] edition = "2021" license = "Unlicensed" diff --git a/README.md b/README.md index 7755268..4fb638a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Adds an account to the blacklist. Emits the `AccountBlacklisted` event on succes ### Parameters: * `origin` – Origin for the call. It should be Root. - * `accountId` - The account to blacklist. + * `account` - The account to blacklist. ### Errors: * `AccountAlreadyBlacklisted` - The `accountId` was already blacklisted. @@ -35,59 +35,10 @@ Adds an account to the blacklist. Emits the `BlacklistedAccountRemoved` event on ### Parameters: * `origin` – Origin for the call. It should be Root. - * `accountId` - The account to remove from the blacklist. + * `account` - The account to remove from the blacklist. ### Errors: - * `AccountIsNotBlacklisted` - The `accountId` was not previously blacklisted. + * `AccountIsNotBlacklisted` - The `AccountId` was not previously blacklisted. -## How to add `pallet-blacklist` to a node - -:information_source: The pallet is compatible with Substrate version **[polkadot-v0.9.42](https://github.com/paritytech/substrate/tree/polkadot-v0.9.42).** - -:information_source: This section is based on -[Substrate node template](https://github.com/substrate-developer-hub/substrate-node-template/tree/polkadot-v0.9.42). - -### Runtime's `Cargo.toml` - -Add `pallet-blacklist` to the dependencies: - -```toml -[dependencies] -# --snip-- -pallet-blacklist = { version = "0.0.1", default-features = false, git = "https://github.com/Moliholy/pallet-blacklist.git" } -# --snip-- -``` - -Update the runtime's `std` feature: -```toml -std = [ - # --snip-- - "pallet-blacklist/std", - # --snip-- -] -``` - -Configure the blacklist pallet. -```rust -impl pallet_blacklist::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BlacklistingOrigin = EnsureRoot; - type WeightInfo = pallet_blacklist::weights::SubstrateWeight; -} -``` - -Add the pallet to the `construct_runtime` macro call. -```rust -construct_runtime!( - pub enum Runtime where - // --snip-- - { - // --snip--- - Blacklist: pallet_blacklist, - // --snip--- - } -); -``` - -Once configured, this pallet **should be used as a valid origin so that any account that is not on the blacklist has a valid origin.** \ No newline at end of file +Once configured, this pallet **should be used as a valid origin so that any account that is not on the blacklist has a valid origin.** diff --git a/src/lib.rs b/src/lib.rs index 6a57efd..4278f72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,9 +47,9 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub (super) fn deposit_event)] pub enum Event { - /// A new account has been blacklisted + /// A new account has been blacklisted. AccountBlacklisted { account: T::AccountId }, - /// A blacklisted account has been removed + /// A blacklisted account has been removed. BlacklistedAccountRemoved { account: T::AccountId }, } @@ -68,7 +68,7 @@ pub mod pallet { #[pallet::call] impl Pallet { - /// Adds an account to the blacklist + /// Adds an account to the blacklist. #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::blacklist_account())] pub fn blacklist_account(origin: OriginFor, account: T::AccountId) -> DispatchResult { @@ -86,7 +86,7 @@ pub mod pallet { Ok(()) } - /// Removes an account from the blacklist + /// Removes an account from the blacklist. #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::remove_blacklisted_account())] pub fn remove_blacklisted_account(