Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moliholy committed Nov 11, 2024
1 parent 31e62ea commit be60fe0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-blacklist"
version = "0.0.1"
version = "1.0.0"
authors = ["José Molina <[email protected]>"]
edition = "2021"
license = "Unlicensed"
Expand Down
57 changes: 4 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
</details>

## 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<AccountId>;
type WeightInfo = pallet_blacklist::weights::SubstrateWeight<Runtime>;
}
```

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.**
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.**
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub (super) fn deposit_event)]
pub enum Event<T: Config> {
/// 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 },
}

Expand All @@ -68,7 +68,7 @@ pub mod pallet {

#[pallet::call]
impl<T: Config> Pallet<T> {
/// 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<T>, account: T::AccountId) -> DispatchResult {
Expand All @@ -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(
Expand Down

0 comments on commit be60fe0

Please sign in to comment.